X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=roojs-ui-debug.js;h=7064634aaa09939211ccdb5080118d9a0f71f728;hb=4ed79f6289ef64f2f5b81ce2f0816e9883777ec0;hp=a7f7e9aa9b45c0a53133f40c48c29221aa5f54a8;hpb=37e1a1577754d049ea95bb158b3a8dcb11383dc3;p=roojs1 diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index a7f7e9aa9b..7064634aaa 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -10,1174 +10,1089 @@ */ - -/* - * These classes are derivatives of the similarly named classes in the YUI Library. - * The original license: - * Copyright (c) 2006, Yahoo! Inc. All rights reserved. - * Code licensed under the BSD License: - * http://developer.yahoo.net/yui/license.txt - */ - -(function() { - -var Event=Roo.EventManager; -var Dom=Roo.lib.Dom; - /** - * @class Roo.dd.DragDrop - * @extends Roo.util.Observable - * Defines the interface and base operation of items that that can be - * dragged or can be drop targets. It was designed to be extended, overriding - * the event handlers for startDrag, onDrag, onDragOver and onDragOut. - * Up to three html elements can be associated with a DragDrop instance: - * - * This class should not be instantiated until the onload event to ensure that - * the associated elements are available. - * The following would define a DragDrop obj that would interact with any - * other DragDrop obj in the "group1" group: - *
- *  dd = new Roo.dd.DragDrop("div1", "group1");
- * 
- * Since none of the event handlers have been implemented, nothing would - * actually happen if you were to run the code above. Normally you would - * override this class or one of the default implementations, but you can - * also override the methods you want on an instance of the class... - *
- *  dd.onDragDrop = function(e, id) {
- *    alert("dd was dropped on " + id);
- *  }
- * 
- * @constructor - * @param {String} id of the element that is linked to this instance - * @param {String} sGroup the group of related DragDrop objects - * @param {object} config an object containing configurable attributes - * Valid properties for DragDrop: - * padding, isTarget, maintainOffset, primaryButtonOnly + * @class Roo.data.SortTypes + * @static + * Defines the default sorting (casting?) comparison functions used when sorting data. */ -Roo.dd.DragDrop = function(id, sGroup, config) { - if (id) { - this.init(id, sGroup, config); - } - -}; - -Roo.extend(Roo.dd.DragDrop, Roo.util.Observable , { - - /** - * The id of the element associated with this object. This is what we - * refer to as the "linked element" because the size and position of - * this element is used to determine when the drag and drop objects have - * interacted. - * @property id - * @type String - */ - id: null, - - /** - * Configuration attributes passed into the constructor - * @property config - * @type object - */ - config: null, - - /** - * The id of the element that will be dragged. By default this is same - * as the linked element , but could be changed to another element. Ex: - * Roo.dd.DDProxy - * @property dragElId - * @type String - * @private - */ - dragElId: null, - - /** - * the id of the element that initiates the drag operation. By default - * this is the linked element, but could be changed to be a child of this - * element. This lets us do things like only starting the drag when the - * header element within the linked html element is clicked. - * @property handleElId - * @type String - * @private - */ - handleElId: null, - - /** - * An associative array of HTML tags that will be ignored if clicked. - * @property invalidHandleTypes - * @type {string: string} - */ - invalidHandleTypes: null, - - /** - * An associative array of ids for elements that will be ignored if clicked - * @property invalidHandleIds - * @type {string: string} - */ - invalidHandleIds: null, - - /** - * An indexted array of css class names for elements that will be ignored - * if clicked. - * @property invalidHandleClasses - * @type string[] - */ - invalidHandleClasses: null, - - /** - * The linked element's absolute X position at the time the drag was - * started - * @property startPageX - * @type int - * @private - */ - startPageX: 0, - - /** - * The linked element's absolute X position at the time the drag was - * started - * @property startPageY - * @type int - * @private - */ - startPageY: 0, - - /** - * The group defines a logical collection of DragDrop objects that are - * related. Instances only get events when interacting with other - * DragDrop object in the same group. This lets us define multiple - * groups using a single DragDrop subclass if we want. - * @property groups - * @type {string: string} - */ - groups: null, - - /** - * Individual drag/drop instances can be locked. This will prevent - * onmousedown start drag. - * @property locked - * @type boolean - * @private - */ - locked: false, - - /** - * Lock this instance - * @method lock - */ - lock: function() { this.locked = true; }, - - /** - * Unlock this instace - * @method unlock - */ - unlock: function() { this.locked = false; }, - - /** - * By default, all insances can be a drop target. This can be disabled by - * setting isTarget to false. - * @method isTarget - * @type boolean - */ - isTarget: true, - - /** - * The padding configured for this drag and drop object for calculating - * the drop zone intersection with this object. - * @method padding - * @type int[] - */ - padding: null, - - /** - * Cached reference to the linked element - * @property _domRef - * @private - */ - _domRef: null, - - /** - * Internal typeof flag - * @property __ygDragDrop - * @private - */ - __ygDragDrop: true, - - /** - * Set to true when horizontal contraints are applied - * @property constrainX - * @type boolean - * @private - */ - constrainX: false, - - /** - * Set to true when vertical contraints are applied - * @property constrainY - * @type boolean - * @private - */ - constrainY: false, - - /** - * The left constraint - * @property minX - * @type int - * @private - */ - minX: 0, - - /** - * The right constraint - * @property maxX - * @type int - * @private - */ - maxX: 0, - - /** - * The up constraint - * @property minY - * @type int - * @type int - * @private - */ - minY: 0, - - /** - * The down constraint - * @property maxY - * @type int - * @private - */ - maxY: 0, - - /** - * Maintain offsets when we resetconstraints. Set to true when you want - * the position of the element relative to its parent to stay the same - * when the page changes - * - * @property maintainOffset - * @type boolean - */ - maintainOffset: false, - - /** - * Array of pixel locations the element will snap to if we specified a - * horizontal graduation/interval. This array is generated automatically - * when you define a tick interval. - * @property xTicks - * @type int[] - */ - xTicks: null, - - /** - * Array of pixel locations the element will snap to if we specified a - * vertical graduation/interval. This array is generated automatically - * when you define a tick interval. - * @property yTicks - * @type int[] - */ - yTicks: null, - - /** - * By default the drag and drop instance will only respond to the primary - * button click (left button for a right-handed mouse). Set to true to - * allow drag and drop to start with any mouse click that is propogated - * by the browser - * @property primaryButtonOnly - * @type boolean - */ - primaryButtonOnly: true, - - /** - * The availabe property is false until the linked dom element is accessible. - * @property available - * @type boolean - */ - available: false, - - /** - * By default, drags can only be initiated if the mousedown occurs in the - * region the linked element is. This is done in part to work around a - * bug in some browsers that mis-report the mousedown if the previous - * mouseup happened outside of the window. This property is set to true - * if outer handles are defined. - * - * @property hasOuterHandles - * @type boolean - * @default false - */ - hasOuterHandles: false, - - /** - * Code that executes immediately before the startDrag event - * @method b4StartDrag - * @private - */ - b4StartDrag: function(x, y) { }, - - /** - * Abstract method called after a drag/drop object is clicked - * and the drag or mousedown time thresholds have beeen met. - * @method startDrag - * @param {int} X click location - * @param {int} Y click location - */ - startDrag: function(x, y) { /* override this */ }, - - /** - * Code that executes immediately before the onDrag event - * @method b4Drag - * @private - */ - b4Drag: function(e) { }, - - /** - * Abstract method called during the onMouseMove event while dragging an - * object. - * @method onDrag - * @param {Event} e the mousemove event - */ - onDrag: function(e) { /* override this */ }, - - /** - * Abstract method called when this element fist begins hovering over - * another DragDrop obj - * @method onDragEnter - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this is hovering over. In INTERSECT mode, an array of one or more - * dragdrop items being hovered over. - */ - onDragEnter: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragOver event - * @method b4DragOver - * @private - */ - b4DragOver: function(e) { }, - - /** - * Abstract method called when this element is hovering over another - * DragDrop obj - * @method onDragOver - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this is hovering over. In INTERSECT mode, an array of dd items - * being hovered over. - */ - onDragOver: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragOut event - * @method b4DragOut - * @private - */ - b4DragOut: function(e) { }, - - /** - * Abstract method called when we are no longer hovering over an element - * @method onDragOut - * @param {Event} e the mousemove event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this was hovering over. In INTERSECT mode, an array of dd items - * that the mouse is no longer over. - */ - onDragOut: function(e, id) { /* override this */ }, - - /** - * Code that executes immediately before the onDragDrop event - * @method b4DragDrop - * @private - */ - b4DragDrop: function(e) { }, - - /** - * Abstract method called when this item is dropped on another DragDrop - * obj - * @method onDragDrop - * @param {Event} e the mouseup event - * @param {String|DragDrop[]} id In POINT mode, the element - * id this was dropped on. In INTERSECT mode, an array of dd items this - * was dropped on. - */ - onDragDrop: function(e, id) { /* override this */ }, - - /** - * Abstract method called when this item is dropped on an area with no - * drop target - * @method onInvalidDrop - * @param {Event} e the mouseup event - */ - onInvalidDrop: function(e) { /* override this */ }, - - /** - * Code that executes immediately before the endDrag event - * @method b4EndDrag - * @private - */ - b4EndDrag: function(e) { }, - - /** - * Fired when we are done dragging the object - * @method endDrag - * @param {Event} e the mouseup event - */ - endDrag: function(e) { /* override this */ }, - - /** - * Code executed immediately before the onMouseDown event - * @method b4MouseDown - * @param {Event} e the mousedown event - * @private - */ - b4MouseDown: function(e) { }, - +Roo.data.SortTypes = { /** - * Event handler that fires when a drag/drop obj gets a mousedown - * @method onMouseDown - * @param {Event} e the mousedown event + * Default sort that does nothing + * @param {Mixed} s The value being converted + * @return {Mixed} The comparison value */ - onMouseDown: function(e) { /* override this */ }, - + none : function(s){ + return s; + }, + /** - * Event handler that fires when a drag/drop obj gets a mouseup - * @method onMouseUp - * @param {Event} e the mouseup event + * The regular expression used to strip tags + * @type {RegExp} + * @property */ - onMouseUp: function(e) { /* override this */ }, - + stripTagsRE : /<\/?[^>]+>/gi, + /** - * Override the onAvailable method to do what is needed after the initial - * position was determined. - * @method onAvailable + * Strips all HTML tags to sort on text only + * @param {Mixed} s The value being converted + * @return {String} The comparison value */ - onAvailable: function () { + asText : function(s){ + return String(s).replace(this.stripTagsRE, ""); }, - - /* - * Provides default constraint padding to "constrainTo" elements (defaults to {left: 0, right:0, top:0, bottom:0}). - * @type Object + + /** + * Strips all HTML tags to sort on text only - Case insensitive + * @param {Mixed} s The value being converted + * @return {String} The comparison value */ - defaultPadding : {left:0, right:0, top:0, bottom:0}, - - /* - * Initializes the drag drop object's constraints to restrict movement to a certain element. - * - * Usage: -

- var dd = new Roo.dd.DDProxy("dragDiv1", "proxytest",
-                { dragElId: "existingProxyDiv" });
- dd.startDrag = function(){
-     this.constrainTo("parent-id");
- };
- 
- * Or you can initalize it using the {@link Roo.Element} object: -

- Roo.get("dragDiv1").initDDProxy("proxytest", {dragElId: "existingProxyDiv"}, {
-     startDrag : function(){
-         this.constrainTo("parent-id");
-     }
- });
- 
- * @param {String/HTMLElement/Element} constrainTo The element to constrain to. - * @param {Object/Number} pad (optional) Pad provides a way to specify "padding" of the constraints, - * and can be either a number for symmetrical padding (4 would be equal to {left:4, right:4, top:4, bottom:4}) or - * an object containing the sides to pad. For example: {right:10, bottom:10} - * @param {Boolean} inContent (optional) Constrain the draggable in the content box of the element (inside padding and borders) - */ - constrainTo : function(constrainTo, pad, inContent){ - if(typeof pad == "number"){ - pad = {left: pad, right:pad, top:pad, bottom:pad}; - } - pad = pad || this.defaultPadding; - var b = Roo.get(this.getEl()).getBox(); - var ce = Roo.get(constrainTo); - var s = ce.getScroll(); - var c, cd = ce.dom; - if(cd == document.body){ - c = { x: s.left, y: s.top, width: Roo.lib.Dom.getViewWidth(), height: Roo.lib.Dom.getViewHeight()}; - }else{ - xy = ce.getXY(); - c = {x : xy[0]+s.left, y: xy[1]+s.top, width: cd.clientWidth, height: cd.clientHeight}; - } - - - var topSpace = b.y - c.y; - var leftSpace = b.x - c.x; - - this.resetConstraints(); - this.setXConstraint(leftSpace - (pad.left||0), // left - c.width - leftSpace - b.width - (pad.right||0) //right - ); - this.setYConstraint(topSpace - (pad.top||0), //top - c.height - topSpace - b.height - (pad.bottom||0) //bottom - ); + asUCText : function(s){ + return String(s).toUpperCase().replace(this.stripTagsRE, ""); }, - + /** - * Returns a reference to the linked element - * @method getEl - * @return {HTMLElement} the html element + * Case insensitive string + * @param {Mixed} s The value being converted + * @return {String} The comparison value */ - getEl: function() { - if (!this._domRef) { - this._domRef = Roo.getDom(this.id); - } - - return this._domRef; + asUCString : function(s) { + return String(s).toUpperCase(); }, - + /** - * Returns a reference to the actual element to drag. By default this is - * the same as the html element, but it can be assigned to another - * element. An example of this can be found in Roo.dd.DDProxy - * @method getDragEl - * @return {HTMLElement} the html element + * Date sorting + * @param {Mixed} s The value being converted + * @return {Number} The comparison value */ - getDragEl: function() { - return Roo.getDom(this.dragElId); + asDate : function(s) { + if(!s){ + return 0; + } + if(s instanceof Date){ + return s.getTime(); + } + return Date.parse(String(s)); }, - + /** - * Sets up the DragDrop object. Must be called in the constructor of any - * Roo.dd.DragDrop subclass - * @method init - * @param id the id of the linked element - * @param {String} sGroup the group of related items - * @param {object} config configuration attributes + * Float sorting + * @param {Mixed} s The value being converted + * @return {Float} The comparison value */ - init: function(id, sGroup, config) { - this.initTarget(id, sGroup, config); - if (!Roo.isTouch) { - Event.on(this.id, "mousedown", this.handleMouseDown, this); + asFloat : function(s) { + var val = parseFloat(String(s).replace(/,/g, "")); + if(isNaN(val)) { + val = 0; } - Event.on(this.id, "touchstart", this.handleMouseDown, this); - // Event.on(this.id, "selectstart", Event.preventDefault); + return val; }, - + /** - * Initializes Targeting functionality only... the object does not - * get a mousedown handler. - * @method initTarget - * @param id the id of the linked element - * @param {String} sGroup the group of related items - * @param {object} config configuration attributes + * Integer sorting + * @param {Mixed} s The value being converted + * @return {Number} The comparison value */ - initTarget: function(id, sGroup, config) { - - // configuration attributes - this.config = config || {}; - - // create a local reference to the drag and drop manager - this.DDM = Roo.dd.DDM; - // initialize the groups array - this.groups = {}; - - // assume that we have an element reference instead of an id if the - // parameter is not a string - if (typeof id !== "string") { - id = Roo.id(id); + asInt : function(s) { + var val = parseInt(String(s).replace(/,/g, "")); + if(isNaN(val)) { + val = 0; } + return val; + } +};/* + * Based on: + * Ext JS Library 1.1.1 + * Copyright(c) 2006-2007, Ext JS, LLC. + * + * Originally Released Under LGPL - original licence link has changed is not relivant. + * + * Fork - LGPL + *