-})();
-Ext.reg('paging', Ext.PagingToolbar);/**\r
- * @class Ext.History\r
- * @extends Ext.util.Observable\r
- * History management component that allows you to register arbitrary tokens that signify application\r
- * history state on navigation actions. You can then handle the history {@link #change} event in order\r
- * to reset your application UI to the appropriate state when the user navigates forward or backward through\r
- * the browser history stack.\r
- * @singleton\r
- */\r
-Ext.History = (function () {\r
- var iframe, hiddenField;\r
- var ready = false;\r
- var currentToken;\r
-\r
- function getHash() {\r
- var href = top.location.href, i = href.indexOf("#");\r
- return i >= 0 ? href.substr(i + 1) : null;\r
- }\r
-\r
- function doSave() {\r
- hiddenField.value = currentToken;\r
- }\r
-\r
- function handleStateChange(token) {\r
- currentToken = token;\r
- Ext.History.fireEvent('change', token);\r
- }\r
-\r
- function updateIFrame (token) {\r
- var html = ['<html><body><div id="state">',token,'</div></body></html>'].join('');\r
- try {\r
- var doc = iframe.contentWindow.document;\r
- doc.open();\r
- doc.write(html);\r
- doc.close();\r
- return true;\r
- } catch (e) {\r
- return false;\r
- }\r
- }\r
-\r
- function checkIFrame() {\r
- if (!iframe.contentWindow || !iframe.contentWindow.document) {\r
- setTimeout(checkIFrame, 10);\r
- return;\r
- }\r
-\r
- var doc = iframe.contentWindow.document;\r
- var elem = doc.getElementById("state");\r
- var token = elem ? elem.innerText : null;\r
-\r
- var hash = getHash();\r
-\r
- setInterval(function () {\r
-\r
- doc = iframe.contentWindow.document;\r
- elem = doc.getElementById("state");\r
-\r
- var newtoken = elem ? elem.innerText : null;\r
-\r
- var newHash = getHash();\r
-\r
- if (newtoken !== token) {\r
- token = newtoken;\r
- handleStateChange(token);\r
- top.location.hash = token;\r
- hash = token;\r
- doSave();\r
- } else if (newHash !== hash) {\r
- hash = newHash;\r
- updateIFrame(newHash);\r
- }\r
-\r
- }, 50);\r
-\r
- ready = true;\r
-\r
- Ext.History.fireEvent('ready', Ext.History);\r
- }\r
-\r
- function startUp() {\r
- currentToken = hiddenField.value ? hiddenField.value : getHash();\r
-\r
- if (Ext.isIE) {\r
- checkIFrame();\r
- } else {\r
- var hash = getHash();\r
- setInterval(function () {\r
- var newHash = getHash();\r
- if (newHash !== hash) {\r
- hash = newHash;\r
- handleStateChange(hash);\r
- doSave();\r
- }\r
- }, 50);\r
- ready = true;\r
- Ext.History.fireEvent('ready', Ext.History);\r
- }\r
- }\r
-\r
- return {\r
- /**\r
- * The id of the hidden field required for storing the current history token.\r
- * @type String\r
- * @property\r
- */\r
- fieldId: 'x-history-field',\r
- /**\r
- * The id of the iframe required by IE to manage the history stack.\r
- * @type String\r
- * @property\r
- */\r
- iframeId: 'x-history-frame',\r
- \r
- events:{},\r
-\r
- /**\r
- * Initialize the global History instance.\r
- * @param {Boolean} onReady (optional) A callback function that will be called once the history\r
- * component is fully initialized.\r
- * @param {Object} scope (optional) The callback scope\r
- */\r
- init: function (onReady, scope) {\r
- if(ready) {\r
- Ext.callback(onReady, scope, [this]);\r
- return;\r
- }\r
- if(!Ext.isReady){\r
- Ext.onReady(function(){\r
- Ext.History.init(onReady, scope);\r
- });\r
- return;\r
- }\r
- hiddenField = Ext.getDom(Ext.History.fieldId);\r
- if (Ext.isIE) {\r
- iframe = Ext.getDom(Ext.History.iframeId);\r
- }\r
- this.addEvents('ready', 'change');\r
- if(onReady){\r
- this.on('ready', onReady, scope, {single:true});\r
- }\r
- startUp();\r
- },\r
-\r
- /**\r
- * Add a new token to the history stack. This can be any arbitrary value, although it would\r
- * commonly be the concatenation of a component id and another id marking the specifc history\r
- * state of that component. Example usage:\r
- * <pre><code>\r
-// Handle tab changes on a TabPanel\r
-tabPanel.on('tabchange', function(tabPanel, tab){\r
- Ext.History.add(tabPanel.id + ':' + tab.id);\r
-});\r
-</code></pre>\r
- * @param {String} token The value that defines a particular application-specific history state\r
- * @param {Boolean} preventDuplicates When true, if the passed token matches the current token\r
- * it will not save a new history step. Set to false if the same state can be saved more than once\r
- * at the same history stack location (defaults to true).\r
- */\r
- add: function (token, preventDup) {\r
- if(preventDup !== false){\r
- if(this.getToken() == token){\r
- return true;\r
- }\r
- }\r
- if (Ext.isIE) {\r
- return updateIFrame(token);\r
- } else {\r
- top.location.hash = token;\r
- return true;\r
- }\r
- },\r
-\r
- /**\r
- * Programmatically steps back one step in browser history (equivalent to the user pressing the Back button).\r
- */\r
- back: function(){\r
- history.go(-1);\r
- },\r
-\r
- /**\r
- * Programmatically steps forward one step in browser history (equivalent to the user pressing the Forward button).\r
- */\r
- forward: function(){\r
- history.go(1);\r
- },\r
-\r
- /**\r
- * Retrieves the currently-active history token.\r
- * @return {String} The token\r
- */\r
- getToken: function() {\r
- return ready ? currentToken : getHash();\r
- }\r
- };\r
-})();\r
-Ext.apply(Ext.History, new Ext.util.Observable());/**\r
- * @class Ext.Tip\r
- * @extends Ext.Panel\r
- * This is the base class for {@link Ext.QuickTip} and {@link Ext.Tooltip} that provides the basic layout and\r
- * positioning that all tip-based classes require. This class can be used directly for simple, statically-positioned\r
- * tips that are displayed programmatically, or it can be extended to provide custom tip implementations.\r
- * @constructor\r
- * Create a new Tip\r
- * @param {Object} config The configuration options\r
- */\r
-Ext.Tip = Ext.extend(Ext.Panel, {\r
- /**\r
- * @cfg {Boolean} closable True to render a close tool button into the tooltip header (defaults to false).\r
- */\r
- /**\r
- * @cfg {Number} width\r
- * Width in pixels of the tip (defaults to auto). Width will be ignored if it exceeds the bounds of\r
- * {@link #minWidth} or {@link #maxWidth}. The maximum supported value is 500.\r
- */\r
- /**\r
- * @cfg {Number} minWidth The minimum width of the tip in pixels (defaults to 40).\r
- */\r
- minWidth : 40,\r
- /**\r
- * @cfg {Number} maxWidth The maximum width of the tip in pixels (defaults to 300). The maximum supported value is 500.\r
- */\r
- maxWidth : 300,\r
- /**\r
- * @cfg {Boolean/String} shadow True or "sides" for the default effect, "frame" for 4-way shadow, and "drop"\r
- * for bottom-right shadow (defaults to "sides").\r
- */\r
- shadow : "sides",\r
- /**\r
- * @cfg {String} defaultAlign <b>Experimental</b>. The default {@link Ext.Element#alignTo} anchor position value\r
- * for this tip relative to its element of origin (defaults to "tl-bl?").\r
- */\r
- defaultAlign : "tl-bl?",\r
- autoRender: true,\r
- quickShowInterval : 250,\r
-\r
- // private panel overrides\r
- frame:true,\r
- hidden:true,\r
- baseCls: 'x-tip',\r
- floating:{shadow:true,shim:true,useDisplay:true,constrain:false},\r
- autoHeight:true,\r
-\r
- closeAction: 'hide',\r
-\r
- // private\r
- initComponent : function(){\r
- Ext.Tip.superclass.initComponent.call(this);\r
- if(this.closable && !this.title){\r
- this.elements += ',header';\r
- }\r
- },\r
-\r
- // private\r
- afterRender : function(){\r
- Ext.Tip.superclass.afterRender.call(this);\r
- if(this.closable){\r
- this.addTool({\r
- id: 'close',\r
- handler: this[this.closeAction],\r
- scope: this\r
- });\r
- }\r
- },\r
-\r
- /**\r
- * Shows this tip at the specified XY position. Example usage:\r
- * <pre><code>\r
-// Show the tip at x:50 and y:100\r
-tip.showAt([50,100]);\r
-</code></pre>\r
- * @param {Array} xy An array containing the x and y coordinates\r
- */\r
- showAt : function(xy){\r
- Ext.Tip.superclass.show.call(this);\r
- if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){\r
- this.doAutoWidth();\r
- }\r
- if(this.constrainPosition){\r
- xy = this.el.adjustForConstraints(xy);\r
- }\r
- this.setPagePosition(xy[0], xy[1]);\r
- },\r
-\r
- // protected\r
- doAutoWidth : function(){\r
- var bw = this.body.getTextWidth();\r
- if(this.title){\r
- bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));\r
- }\r
- bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");\r
- this.setWidth(bw.constrain(this.minWidth, this.maxWidth));\r
- \r
- // IE7 repaint bug on initial show\r
- if(Ext.isIE7 && !this.repainted){\r
- this.el.repaint();\r
- this.repainted = true;\r
- }\r
- },\r
-\r
- /**\r
- * <b>Experimental</b>. Shows this tip at a position relative to another element using a standard {@link Ext.Element#alignTo}\r
- * anchor position value. Example usage:\r
- * <pre><code>\r
-// Show the tip at the default position ('tl-br?')\r
-tip.showBy('my-el');\r
-\r
-// Show the tip's top-left corner anchored to the element's top-right corner\r
-tip.showBy('my-el', 'tl-tr');\r
-</code></pre>\r
- * @param {Mixed} el An HTMLElement, Ext.Element or string id of the target element to align to\r
- * @param {String} position (optional) A valid {@link Ext.Element#alignTo} anchor position (defaults to 'tl-br?' or\r
- * {@link #defaultAlign} if specified).\r
- */\r
- showBy : function(el, pos){\r
- if(!this.rendered){\r
- this.render(Ext.getBody());\r
- }\r
- this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));\r
- },\r
-\r
- initDraggable : function(){\r
- this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);\r
- this.header.addClass('x-tip-draggable');\r
- }\r
-});\r
-\r
-// private - custom Tip DD implementation\r
-Ext.Tip.DD = function(tip, config){\r
- Ext.apply(this, config);\r
- this.tip = tip;\r
- Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);\r
- this.setHandleElId(tip.header.id);\r
- this.scroll = false;\r
-};\r
-\r
-Ext.extend(Ext.Tip.DD, Ext.dd.DD, {\r
- moveOnly:true,\r
- scroll:false,\r
- headerOffsets:[100, 25],\r
- startDrag : function(){\r
- this.tip.el.disableShadow();\r
- },\r
- endDrag : function(e){\r
- this.tip.el.enableShadow(true);\r
- }\r
-});/**\r
- * @class Ext.ToolTip\r
- * @extends Ext.Tip\r
- * A standard tooltip implementation for providing additional information when hovering over a target element.\r
- * @constructor\r
- * Create a new Tooltip\r
- * @param {Object} config The configuration options\r
- */\r
-Ext.ToolTip = Ext.extend(Ext.Tip, {\r
- /**\r
- * When a Tooltip is configured with the {@link #delegate} option to cause selected child elements of the {@link #target}\r
- * Element to each trigger a seperate show event, this property is set to the DOM element which triggered the show.\r
- * @type DOMElement\r
- * @property triggerElement\r
- */\r
- /**\r
- * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to monitor for mouseover events to trigger\r
- * showing this ToolTip.\r
- */\r
- /**\r
- * @cfg {Boolean} autoHide True to automatically hide the tooltip after the mouse exits the target element\r
- * or after the {@link #dismissDelay} has expired if set (defaults to true). If {@link closable} = true a close\r
- * tool button will be rendered into the tooltip header.\r
- */\r
- /**\r
- * @cfg {Number} showDelay Delay in milliseconds before the tooltip displays after the mouse enters the\r
- * target element (defaults to 500)\r
- */\r
- showDelay: 500,\r
- /**\r
- * @cfg {Number} hideDelay Delay in milliseconds after the mouse exits the target element but before the\r
- * tooltip actually hides (defaults to 200). Set to 0 for the tooltip to hide immediately.\r
- */\r
- hideDelay: 200,\r
- /**\r
- * @cfg {Number} dismissDelay Delay in milliseconds before the tooltip automatically hides (defaults to 5000).\r
- * To disable automatic hiding, set dismissDelay = 0.\r
- */\r
- dismissDelay: 5000,\r
- /**\r
- * @cfg {Array} mouseOffset An XY offset from the mouse position where the tooltip should be shown (defaults to [15,18]).\r
- */\r
- /**\r
- * @cfg {Boolean} trackMouse True to have the tooltip follow the mouse as it moves over the target element (defaults to false).\r
- */\r
- trackMouse : false,\r
- /**\r
- * @cfg {Boolean} anchorToTarget True to anchor the tooltip to the target element, false to\r
- * anchor it relative to the mouse coordinates (defaults to true). When anchorToTarget is\r
- * true, use {@link #defaultAlign} to control tooltip alignment to the target element. When\r
- * anchorToTarget is false, use {@link #anchorPosition} instead to control alignment.\r
- */\r
- anchorToTarget: true,\r
- /**\r
- * @cfg {Number} anchorOffset A numeric pixel value used to offset the default position of the\r
- * anchor arrow (defaults to 0). When the anchor position is on the top or bottom of the tooltip,\r
- * anchorOffset will be used as a horizontal offset. Likewise, when the anchor position is on the\r
- * left or right side, anchorOffset will be used as a vertical offset.\r
- */\r
- anchorOffset: 0,\r
- /**\r
- * @cfg {String} delegate <p>Optional. A {@link Ext.DomQuery DomQuery} selector which allows selection of individual elements\r
- * within the {@link #target} element to trigger showing and hiding the ToolTip as the mouse moves within the target.</p>\r
- * <p>When specified, the child element of the target which caused a show event is placed into the {@link #triggerElement} property\r
- * before the ToolTip is shown.</p>\r
- * <p>This may be useful when a Component has regular, repeating elements in it, each of which need a Tooltip which contains\r
- * information specific to that element. For example:</p><pre><code>\r
-var myGrid = new Ext.grid.gridPanel(gridConfig);\r
-myGrid.on('render', function(grid) {\r
- var store = grid.getStore(); // Capture the Store.\r
- var view = grid.getView(); // Capture the GridView.\r
- myGrid.tip = new Ext.ToolTip({\r
- target: view.mainBody, // The overall target element.\r
- delegate: '.x-grid3-row', // Each grid row causes its own seperate show and hide.\r
- trackMouse: true, // Moving within the row should not hide the tip.\r
- renderTo: document.body, // Render immediately so that tip.body can be referenced prior to the first show.\r
- listeners: { // Change content dynamically depending on which element triggered the show.\r
- beforeshow: function updateTipBody(tip) {\r
- var rowIndex = view.findRowIndex(tip.triggerElement);\r
- tip.body.dom.innerHTML = "Over Record ID " + store.getAt(rowIndex).id;\r
- }\r
- }\r
- });\r
-});</code></pre>\r
- */\r
-\r
- // private\r
- targetCounter: 0,\r
-\r
- constrainPosition: false,\r
-\r
- // private\r
- initComponent: function(){\r
- Ext.ToolTip.superclass.initComponent.call(this);\r
- this.lastActive = new Date();\r
- this.initTarget(this.target);\r
- this.origAnchor = this.anchor;\r
- },\r
-\r
- // private\r
- onRender : function(ct, position){\r
- Ext.ToolTip.superclass.onRender.call(this, ct, position);\r
- this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();\r
- this.anchorEl = this.el.createChild({\r
- cls: 'x-tip-anchor ' + this.anchorCls\r
- });\r
- },\r
-\r
- // private\r
- afterRender : function(){\r
- Ext.ToolTip.superclass.afterRender.call(this);\r
- this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1);\r
- },\r
-\r
- /**\r
- * Binds this ToolTip to the specified element. The tooltip will be displayed when the mouse moves over the element.\r
- * @param {Mixed} t The Element, HtmlElement, or ID of an element to bind to\r
- */\r
- initTarget : function(target){\r
- var t;\r
- if((t = Ext.get(target))){\r
- if(this.target){\r
- this.target = Ext.get(this.target);\r
- this.target.un('mouseover', this.onTargetOver, this);\r
- this.target.un('mouseout', this.onTargetOut, this);\r
- this.target.un('mousemove', this.onMouseMove, this);\r
- }\r
- this.mon(t, {\r
- mouseover: this.onTargetOver,\r
- mouseout: this.onTargetOut,\r
- mousemove: this.onMouseMove,\r
- scope: this\r
- });\r
- this.target = t;\r
- }\r
- if(this.anchor){\r
- this.anchorTarget = this.target;\r
- }\r
- },\r
-\r
- // private\r
- onMouseMove : function(e){\r
- var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;\r
- if (t) {\r
- this.targetXY = e.getXY();\r
- if (t === this.triggerElement) {\r
- if(!this.hidden && this.trackMouse){\r
- this.setPagePosition(this.getTargetXY());\r
- }\r
- } else {\r
- this.hide();\r
- this.lastActive = new Date(0);\r
- this.onTargetOver(e);\r
- }\r
- } else if (!this.closable && this.isVisible()) {\r
- this.hide();\r
- }\r
- },\r
-\r
- // private\r
- getTargetXY : function(){\r
- if(this.anchor){\r
- this.targetCounter++;\r
- var offsets = this.getOffsets();\r
- var xy = (this.anchorToTarget && !this.trackMouse) ?\r
- this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) :\r
- this.targetXY;\r
-\r
- var dw = Ext.lib.Dom.getViewWidth()-5;\r
- var dh = Ext.lib.Dom.getViewHeight()-5;\r
- var scrollX = (document.documentElement.scrollLeft || document.body.scrollLeft || 0)+5;\r
- var scrollY = (document.documentElement.scrollTop || document.body.scrollTop || 0)+5;\r
-\r
- var axy = [xy[0] + offsets[0], xy[1] + offsets[1]];\r
- var sz = this.getSize();\r
- this.anchorEl.removeClass(this.anchorCls);\r
-\r
- if(this.targetCounter < 2){\r
- if(axy[0] < scrollX){\r
- if(this.anchorToTarget){\r
- this.defaultAlign = 'l-r';\r
- if(this.mouseOffset){this.mouseOffset[0] *= -1;}\r
- }\r
- this.anchor = 'left';\r
- return this.getTargetXY();\r
- }\r
- if(axy[0]+sz.width > dw){\r
- if(this.anchorToTarget){\r
- this.defaultAlign = 'r-l';\r
- if(this.mouseOffset){this.mouseOffset[0] *= -1;}\r
- }\r
- this.anchor = 'right';\r
- return this.getTargetXY();\r
- }\r
- if(axy[1] < scrollY){\r
- if(this.anchorToTarget){\r
- this.defaultAlign = 't-b';\r
- if(this.mouseOffset){this.mouseOffset[1] *= -1;}\r
- }\r
- this.anchor = 'top';\r
- return this.getTargetXY();\r
- }\r
- if(axy[1]+sz.height > dh){\r
- if(this.anchorToTarget){\r
- this.defaultAlign = 'b-t';\r
- if(this.mouseOffset){this.mouseOffset[1] *= -1;}\r
- }\r
- this.anchor = 'bottom';\r
- return this.getTargetXY();\r
- }\r
- }\r
-\r
- this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();\r
- this.anchorEl.addClass(this.anchorCls);\r
- this.targetCounter = 0;\r
- return axy;\r
- }else{\r
- var mouseOffset = this.getMouseOffset();\r
- return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];\r
- }\r
- },\r
-\r
- getMouseOffset : function(){\r
- var offset = this.anchor ? [0,0] : [15,18];\r
- if(this.mouseOffset){\r
- offset[0] += this.mouseOffset[0];\r
- offset[1] += this.mouseOffset[1];\r
- }\r
- return offset;\r
- },\r
-\r
- // private\r
- getAnchorPosition : function(){\r
- if(this.anchor){\r
- this.tipAnchor = this.anchor.charAt(0);\r
- }else{\r
- var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);\r
- if(!m){\r
- throw "AnchorTip.defaultAlign is invalid";\r
- }\r
- this.tipAnchor = m[1].charAt(0);\r
- }\r
-\r
- switch(this.tipAnchor){\r
- case 't': return 'top';\r
- case 'b': return 'bottom';\r
- case 'r': return 'right';\r
- }\r
- return 'left';\r
- },\r
-\r
- // private\r
- getAnchorAlign : function(){\r
- switch(this.anchor){\r
- case 'top' : return 'tl-bl';\r
- case 'left' : return 'tl-tr';\r
- case 'right': return 'tr-tl';\r
- default : return 'bl-tl';\r
- }\r
- },\r
-\r
- // private\r
- getOffsets: function(){\r
- var offsets, ap = this.getAnchorPosition().charAt(0);\r
- if(this.anchorToTarget && !this.trackMouse){\r
- switch(ap){\r
- case 't':\r
- offsets = [0, 9];\r
- break;\r
- case 'b':\r
- offsets = [0, -13];\r
- break;\r
- case 'r':\r
- offsets = [-13, 0];\r
- break;\r
- default:\r
- offsets = [9, 0];\r
- break;\r
- }\r
- }else{\r
- switch(ap){\r
- case 't':\r
- offsets = [-15-this.anchorOffset, 30];\r
- break;\r
- case 'b':\r
- offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];\r
- break;\r
- case 'r':\r
- offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];\r
- break;\r
- default:\r
- offsets = [25, -13-this.anchorOffset];\r
- break;\r
- }\r
- }\r
- var mouseOffset = this.getMouseOffset();\r
- offsets[0] += mouseOffset[0];\r
- offsets[1] += mouseOffset[1];\r
-\r
- return offsets;\r
- },\r
-\r
- // private\r
- onTargetOver : function(e){\r
- if(this.disabled || e.within(this.target.dom, true)){\r
- return;\r
- }\r
- var t = e.getTarget(this.delegate);\r
- if (t) {\r
- this.triggerElement = t;\r
- this.clearTimer('hide');\r
- this.targetXY = e.getXY();\r
- this.delayShow();\r
- }\r
- },\r
-\r
- // private\r
- delayShow : function(){\r
- if(this.hidden && !this.showTimer){\r
- if(this.lastActive.getElapsed() < this.quickShowInterval){\r
- this.show();\r
- }else{\r
- this.showTimer = this.show.defer(this.showDelay, this);\r
- }\r
- }else if(!this.hidden && this.autoHide !== false){\r
- this.show();\r
- }\r
- },\r
-\r
- // private\r
- onTargetOut : function(e){\r
- if(this.disabled || e.within(this.target.dom, true)){\r
- return;\r
- }\r
- this.clearTimer('show');\r
- if(this.autoHide !== false){\r
- this.delayHide();\r
- }\r
- },\r
-\r
- // private\r
- delayHide : function(){\r
- if(!this.hidden && !this.hideTimer){\r
- this.hideTimer = this.hide.defer(this.hideDelay, this);\r
- }\r
- },\r
-\r
- /**\r
- * Hides this tooltip if visible.\r
- */\r
- hide: function(){\r
- this.clearTimer('dismiss');\r
- this.lastActive = new Date();\r
- if(this.anchorEl){\r
- this.anchorEl.hide();\r
- }\r
- Ext.ToolTip.superclass.hide.call(this);\r
- delete this.triggerElement;\r
- },\r
-\r
- /**\r
- * Shows this tooltip at the current event target XY position.\r
- */\r
- show : function(){\r
- if(this.anchor){\r
- // pre-show it off screen so that the el will have dimensions\r
- // for positioning calcs when getting xy next\r
- this.showAt([-1000,-1000]);\r
- this.origConstrainPosition = this.constrainPosition;\r
- this.constrainPosition = false;\r
- this.anchor = this.origAnchor;\r
- }\r
- this.showAt(this.getTargetXY());\r
-\r
- if(this.anchor){\r
- this.syncAnchor();\r
- this.anchorEl.show();\r
- this.constrainPosition = this.origConstrainPosition;\r
- }else{\r
- this.anchorEl.hide();\r
- }\r
- },\r
-\r
- // inherit docs\r
- showAt : function(xy){\r
- this.lastActive = new Date();\r
- this.clearTimers();\r
- Ext.ToolTip.superclass.showAt.call(this, xy);\r
- if(this.dismissDelay && this.autoHide !== false){\r
- this.dismissTimer = this.hide.defer(this.dismissDelay, this);\r
- }\r
- },\r
-\r
- // private\r
- syncAnchor : function(){\r
- var anchorPos, targetPos, offset;\r
- switch(this.tipAnchor.charAt(0)){\r
- case 't':\r
- anchorPos = 'b';\r
- targetPos = 'tl';\r
- offset = [20+this.anchorOffset, 2];\r
- break;\r
- case 'r':\r
- anchorPos = 'l';\r
- targetPos = 'tr';\r
- offset = [-2, 11+this.anchorOffset];\r
- break;\r
- case 'b':\r
- anchorPos = 't';\r
- targetPos = 'bl';\r
- offset = [20+this.anchorOffset, -2];\r
- break;\r
- default:\r
- anchorPos = 'r';\r
- targetPos = 'tl';\r
- offset = [2, 11+this.anchorOffset];\r
- break;\r
- }\r
- this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);\r
- },\r
-\r
- // private\r
- setPagePosition : function(x, y){\r
- Ext.ToolTip.superclass.setPagePosition.call(this, x, y);\r
- if(this.anchor){\r
- this.syncAnchor();\r
- }\r
- },\r
-\r
- // private\r
- clearTimer : function(name){\r
- name = name + 'Timer';\r
- clearTimeout(this[name]);\r
- delete this[name];\r
- },\r
-\r
- // private\r
- clearTimers : function(){\r
- this.clearTimer('show');\r
- this.clearTimer('dismiss');\r
- this.clearTimer('hide');\r
- },\r
-\r
- // private\r
- onShow : function(){\r
- Ext.ToolTip.superclass.onShow.call(this);\r
- Ext.getDoc().on('mousedown', this.onDocMouseDown, this);\r
- },\r
-\r
- // private\r
- onHide : function(){\r
- Ext.ToolTip.superclass.onHide.call(this);\r
- Ext.getDoc().un('mousedown', this.onDocMouseDown, this);\r
- },\r
-\r
- // private\r
- onDocMouseDown : function(e){\r
- if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){\r
- this.disable();\r
- this.enable.defer(100, this);\r
- }\r
- },\r
-\r
- // private\r
- onDisable : function(){\r
- this.clearTimers();\r
- this.hide();\r
- },\r
-\r
- // private\r
- adjustPosition : function(x, y){\r
- if(this.contstrainPosition){\r
- var ay = this.targetXY[1], h = this.getSize().height;\r
- if(y <= ay && (y+h) >= ay){\r
- y = ay-h-5;\r
- }\r
- }\r
- return {x : x, y: y};\r
- },\r
-\r
- // private\r
- onDestroy : function(){\r
- Ext.getDoc().un('mousedown', this.onDocMouseDown, this);\r
- Ext.ToolTip.superclass.onDestroy.call(this);\r
- }\r
-});/**\r
- * @class Ext.QuickTip\r
- * @extends Ext.ToolTip\r
- * A specialized tooltip class for tooltips that can be specified in markup and automatically managed by the global\r
- * {@link Ext.QuickTips} instance. See the QuickTips class header for additional usage details and examples.\r
- * @constructor\r
- * Create a new Tip\r
- * @param {Object} config The configuration options\r
- */\r
-Ext.QuickTip = Ext.extend(Ext.ToolTip, {\r
- /**\r
- * @cfg {Mixed} target The target HTMLElement, Ext.Element or id to associate with this quicktip (defaults to the document).\r
- */\r
- /**\r
- * @cfg {Boolean} interceptTitles True to automatically use the element's DOM title value if available (defaults to false).\r
- */\r
- interceptTitles : false,\r
-\r
- // private\r
- tagConfig : {\r
- namespace : "ext",\r
- attribute : "qtip",\r
- width : "qwidth",\r
- target : "target",\r
- title : "qtitle",\r
- hide : "hide",\r
- cls : "qclass",\r
- align : "qalign",\r
- anchor : "anchor"\r
- },\r
-\r
- // private\r
- initComponent : function(){\r
- this.target = this.target || Ext.getDoc();\r
- this.targets = this.targets || {};\r
- Ext.QuickTip.superclass.initComponent.call(this);\r
- },\r
-\r
- /**\r
- * Configures a new quick tip instance and assigns it to a target element. The following config values are\r
- * supported (for example usage, see the {@link Ext.QuickTips} class header):\r
- * <div class="mdetail-params"><ul>\r
- * <li>autoHide</li>\r
- * <li>cls</li>\r
- * <li>dismissDelay (overrides the singleton value)</li>\r
- * <li>target (required)</li>\r
- * <li>text (required)</li>\r
- * <li>title</li>\r
- * <li>width</li></ul></div>\r
- * @param {Object} config The config object\r
- */\r
- register : function(config){\r
- var cs = Ext.isArray(config) ? config : arguments;\r
- for(var i = 0, len = cs.length; i < len; i++){\r
- var c = cs[i];\r
- var target = c.target;\r
- if(target){\r
- if(Ext.isArray(target)){\r
- for(var j = 0, jlen = target.length; j < jlen; j++){\r
- this.targets[Ext.id(target[j])] = c;\r
- }\r
- } else{\r
- this.targets[Ext.id(target)] = c;\r
- }\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * Removes this quick tip from its element and destroys it.\r
- * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.\r
- */\r
- unregister : function(el){\r
- delete this.targets[Ext.id(el)];\r
- },\r
- \r
- /**\r
- * Hides a visible tip or cancels an impending show for a particular element.\r
- * @param {String/HTMLElement/Element} el The element that is the target of the tip.\r
- */\r
- cancelShow: function(el){\r
- var at = this.activeTarget;\r
- el = Ext.get(el).dom;\r
- if(this.isVisible()){\r
- if(at && at.el == el){\r
- this.hide();\r
- }\r
- }else if(at && at.el == el){\r
- this.clearTimer('show');\r
- }\r
- },\r
-\r
- // private\r
- onTargetOver : function(e){\r
- if(this.disabled){\r
- return;\r
- }\r
- this.targetXY = e.getXY();\r
- var t = e.getTarget();\r
- if(!t || t.nodeType !== 1 || t == document || t == document.body){\r
- return;\r
- }\r
- if(this.activeTarget && t == this.activeTarget.el){\r
- this.clearTimer('hide');\r
- this.show();\r
- return;\r
- }\r
- if(t && this.targets[t.id]){\r
- this.activeTarget = this.targets[t.id];\r
- this.activeTarget.el = t;\r
- this.anchor = this.activeTarget.anchor;\r
- if(this.anchor){\r
- this.anchorTarget = t;\r
- }\r
- this.delayShow();\r
- return;\r
- }\r
- \r
- var ttp, et = Ext.fly(t), cfg = this.tagConfig;\r
- var ns = cfg.namespace;\r
- if(this.interceptTitles && t.title){\r
- ttp = t.title;\r
- t.qtip = ttp;\r
- t.removeAttribute("title");\r
- e.preventDefault();\r
- } else{\r
- ttp = t.qtip || et.getAttribute(cfg.attribute, ns);\r
- }\r
- if(ttp){\r
- var autoHide = et.getAttribute(cfg.hide, ns);\r
- this.activeTarget = {\r
- el: t,\r
- text: ttp,\r
- width: et.getAttribute(cfg.width, ns),\r
- autoHide: autoHide != "user" && autoHide !== 'false',\r
- title: et.getAttribute(cfg.title, ns),\r
- cls: et.getAttribute(cfg.cls, ns),\r
- align: et.getAttribute(cfg.align, ns)\r
- \r
- };\r
- this.anchor = et.getAttribute(cfg.anchor, ns);\r
- if(this.anchor){\r
- this.anchorTarget = t;\r
- }\r
- this.delayShow();\r
- }\r
- },\r
-\r
- // private\r
- onTargetOut : function(e){\r
- this.clearTimer('show');\r
- if(this.autoHide !== false){\r
- this.delayHide();\r
- }\r
- },\r
-\r
- // inherit docs\r
- showAt : function(xy){\r
- var t = this.activeTarget;\r
- if(t){\r
- if(!this.rendered){\r
- this.render(Ext.getBody());\r
- this.activeTarget = t;\r
- }\r
- if(t.width){\r
- this.setWidth(t.width);\r
- this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));\r
- this.measureWidth = false;\r
- } else{\r
- this.measureWidth = true;\r
- }\r
- this.setTitle(t.title || '');\r
- this.body.update(t.text);\r
- this.autoHide = t.autoHide;\r
- this.dismissDelay = t.dismissDelay || this.dismissDelay;\r
- if(this.lastCls){\r
- this.el.removeClass(this.lastCls);\r
- delete this.lastCls;\r
- }\r
- if(t.cls){\r
- this.el.addClass(t.cls);\r
- this.lastCls = t.cls;\r
- }\r
- if(this.anchor){\r
- this.constrainPosition = false;\r
- }else if(t.align){ // TODO: this doesn't seem to work consistently\r
- xy = this.el.getAlignToXY(t.el, t.align);\r
- this.constrainPosition = false;\r
- }else{\r
- this.constrainPosition = true;\r
- }\r
- }\r
- Ext.QuickTip.superclass.showAt.call(this, xy);\r
- },\r
-\r
- // inherit docs\r
- hide: function(){\r
- delete this.activeTarget;\r
- Ext.QuickTip.superclass.hide.call(this);\r
- }\r
-});/**\r
- * @class Ext.QuickTips\r
- * <p>Provides attractive and customizable tooltips for any element. The QuickTips\r
- * singleton is used to configure and manage tooltips globally for multiple elements\r
- * in a generic manner. To create individual tooltips with maximum customizability,\r
- * you should consider either {@link Ext.Tip} or {@link Ext.ToolTip}.</p>\r
- * <p>Quicktips can be configured via tag attributes directly in markup, or by\r
- * registering quick tips programmatically via the {@link #register} method.</p>\r
- * <p>The singleton's instance of {@link Ext.QuickTip} is available via\r
- * {@link #getQuickTip}, and supports all the methods, and all the all the\r
- * configuration properties of Ext.QuickTip. These settings will apply to all\r
- * tooltips shown by the singleton.</p>\r
- * <p>Below is the summary of the configuration properties which can be used.\r
- * For detailed descriptions see {@link #getQuickTip}</p>\r
- * <p><b>QuickTips singleton configs (all are optional)</b></p>\r
- * <div class="mdetail-params"><ul><li>dismissDelay</li>\r
- * <li>hideDelay</li>\r
- * <li>maxWidth</li>\r
- * <li>minWidth</li>\r
- * <li>showDelay</li>\r
- * <li>trackMouse</li></ul></div>\r
- * <p><b>Target element configs (optional unless otherwise noted)</b></p>\r
- * <div class="mdetail-params"><ul><li>autoHide</li>\r
- * <li>cls</li>\r
- * <li>dismissDelay (overrides singleton value)</li>\r
- * <li>target (required)</li>\r
- * <li>text (required)</li>\r
- * <li>title</li>\r
- * <li>width</li></ul></div>\r
- * <p>Here is an example showing how some of these config options could be used:</p>\r
- * <pre><code>\r
-// Init the singleton. Any tag-based quick tips will start working.\r
-Ext.QuickTips.init();\r
-\r
-// Apply a set of config properties to the singleton\r
-Ext.apply(Ext.QuickTips.getQuickTip(), {\r
- maxWidth: 200,\r
- minWidth: 100,\r
- showDelay: 50,\r
- trackMouse: true\r
-});\r
-\r
-// Manually register a quick tip for a specific element\r
-Ext.QuickTips.register({\r
- target: 'my-div',\r
- title: 'My Tooltip',\r
- text: 'This tooltip was added in code',\r
- width: 100,\r
- dismissDelay: 20\r
-});\r
-</code></pre>\r
- * <p>To register a quick tip in markup, you simply add one or more of the valid QuickTip attributes prefixed with\r
- * the <b>ext:</b> namespace. The HTML element itself is automatically set as the quick tip target. Here is the summary\r
- * of supported attributes (optional unless otherwise noted):</p>\r
- * <ul><li><b>hide</b>: Specifying "user" is equivalent to setting autoHide = false. Any other value will be the\r
- * same as autoHide = true.</li>\r
- * <li><b>qclass</b>: A CSS class to be applied to the quick tip (equivalent to the 'cls' target element config).</li>\r
- * <li><b>qtip (required)</b>: The quick tip text (equivalent to the 'text' target element config).</li>\r
- * <li><b>qtitle</b>: The quick tip title (equivalent to the 'title' target element config).</li>\r
- * <li><b>qwidth</b>: The quick tip width (equivalent to the 'width' target element config).</li></ul>\r
- * <p>Here is an example of configuring an HTML element to display a tooltip from markup:</p>\r
- * <pre><code>\r
-// Add a quick tip to an HTML button\r
-<input type="button" value="OK" ext:qtitle="OK Button" ext:qwidth="100"\r
- ext:qtip="This is a quick tip from markup!"></input>\r
-</code></pre>\r
- * @singleton\r
- */\r
-Ext.QuickTips = function(){\r
- var tip, locks = [];\r
- return {\r
- /**\r
- * Initialize the global QuickTips instance and prepare any quick tips.\r
- * @param {Boolean} autoRender True to render the QuickTips container immediately to preload images. (Defaults to true) \r
- */\r
- init : function(autoRender){\r
- if(!tip){\r
- if(!Ext.isReady){\r
- Ext.onReady(function(){\r
- Ext.QuickTips.init(autoRender);\r
- });\r
- return;\r
- }\r
- tip = new Ext.QuickTip({elements:'header,body'});\r
- if(autoRender !== false){\r
- tip.render(Ext.getBody());\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * Enable quick tips globally.\r
- */\r
- enable : function(){\r
- if(tip){\r
- locks.pop();\r
- if(locks.length < 1){\r
- tip.enable();\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * Disable quick tips globally.\r
- */\r
- disable : function(){\r
- if(tip){\r
- tip.disable();\r
- }\r
- locks.push(1);\r
- },\r
-\r
- /**\r
- * Returns true if quick tips are enabled, else false.\r
- * @return {Boolean}\r
- */\r
- isEnabled : function(){\r
- return tip !== undefined && !tip.disabled;\r
- },\r
-\r
- /**\r
- * Gets the global QuickTips instance.\r
- */\r
- getQuickTip : function(){\r
- return tip;\r
- },\r
-\r
- /**\r
- * Configures a new quick tip instance and assigns it to a target element. See\r
- * {@link Ext.QuickTip#register} for details.\r
- * @param {Object} config The config object\r
- */\r
- register : function(){\r
- tip.register.apply(tip, arguments);\r
- },\r
-\r
- /**\r
- * Removes any registered quick tip from the target element and destroys it.\r
- * @param {String/HTMLElement/Element} el The element from which the quick tip is to be removed.\r
- */\r
- unregister : function(){\r
- tip.unregister.apply(tip, arguments);\r
- },\r
-\r
- /**\r
- * Alias of {@link #register}.\r
- * @param {Object} config The config object\r
- */\r
- tips :function(){\r
- tip.register.apply(tip, arguments);\r
- }\r
- }\r
-}();/**\r
- * @class Ext.tree.TreePanel\r
- * @extends Ext.Panel\r
- * <p>The TreePanel provides tree-structured UI representation of tree-structured data.</p>\r
- * <p>{@link Ext.tree.TreeNode TreeNode}s added to the TreePanel may each contain metadata\r
- * used by your application in their {@link Ext.tree.TreeNode#attributes attributes} property.</p>\r
- * <p><b>A TreePanel must have a {@link #root} node before it is rendered.</b> This may either be\r
- * specified using the {@link #root} config option, or using the {@link #setRootNode} method.\r
- * <p>An example of tree rendered to an existing div:</p><pre><code>\r
-var tree = new Ext.tree.TreePanel({\r
- renderTo: 'tree-div',\r
- useArrows: true,\r
- autoScroll: true,\r
- animate: true,\r
- enableDD: true,\r
- containerScroll: true,\r
- border: false,\r
- // auto create TreeLoader\r
- dataUrl: 'get-nodes.php',\r
-\r
- root: {\r
- nodeType: 'async',\r
- text: 'Ext JS',\r
- draggable: false,\r
- id: 'source'\r
- }\r
-});\r
-\r
-tree.getRootNode().expand();\r
- * </code></pre>\r
- * <p>The example above would work with a data packet similar to this:</p><pre><code>\r
-[{\r
- "text": "adapter",\r
- "id": "source\/adapter",\r
- "cls": "folder"\r
-}, {\r
- "text": "dd",\r
- "id": "source\/dd",\r
- "cls": "folder"\r
-}, {\r
- "text": "debug.js",\r
- "id": "source\/debug.js",\r
- "leaf": true,\r
- "cls": "file"\r
-}]\r
- * </code></pre>\r
- * <p>An example of tree within a Viewport:</p><pre><code>\r
-new Ext.Viewport({\r
- layout: 'border',\r
- items: [{\r
- region: 'west',\r
- collapsible: true,\r
- title: 'Navigation',\r
- xtype: 'treepanel',\r
- width: 200,\r
- autoScroll: true,\r
- split: true,\r
- loader: new Ext.tree.TreeLoader(),\r
- root: new Ext.tree.AsyncTreeNode({\r
- expanded: true,\r
- children: [{\r
- text: 'Menu Option 1',\r
- leaf: true\r
- }, {\r
- text: 'Menu Option 2',\r
- leaf: true\r
- }, {\r
- text: 'Menu Option 3',\r
- leaf: true\r
- }]\r
- }),\r
- rootVisible: false,\r
- listeners: {\r
- click: function(n) {\r
- Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');\r
- }\r
- }\r
- }, {\r
- region: 'center',\r
- xtype: 'tabpanel',\r
- // remaining code not shown ...\r
- }]\r
-});\r
-</code></pre>\r
- *\r
- * @cfg {Ext.tree.TreeNode} root The root node for the tree.\r
- * @cfg {Boolean} rootVisible <tt>false</tt> to hide the root node (defaults to <tt>true</tt>)\r
- * @cfg {Boolean} lines <tt>false</tt> to disable tree lines (defaults to <tt>true</tt>)\r
- * @cfg {Boolean} enableDD <tt>true</tt> to enable drag and drop\r
- * @cfg {Boolean} enableDrag <tt>true</tt> to enable just drag\r
- * @cfg {Boolean} enableDrop <tt>true</tt> to enable just drop\r
- * @cfg {Object} dragConfig Custom config to pass to the {@link Ext.tree.TreeDragZone} instance\r
- * @cfg {Object} dropConfig Custom config to pass to the {@link Ext.tree.TreeDropZone} instance\r
- * @cfg {String} ddGroup The DD group this TreePanel belongs to\r
- * @cfg {Boolean} ddAppendOnly <tt>true</tt> if the tree should only allow append drops (use for trees which are sorted)\r
- * @cfg {Boolean} ddScroll <tt>true</tt> to enable body scrolling\r
- * @cfg {Boolean} containerScroll <tt>true</tt> to register this container with ScrollManager\r
- * @cfg {Boolean} hlDrop <tt>false</tt> to disable node highlight on drop (defaults to the value of {@link Ext#enableFx})\r
- * @cfg {String} hlColor The color of the node highlight (defaults to <tt>'C3DAF9'</tt>)\r
- * @cfg {Boolean} animate <tt>true</tt> to enable animated expand/collapse (defaults to the value of {@link Ext#enableFx})\r
- * @cfg {Boolean} singleExpand <tt>true</tt> if only 1 node per branch may be expanded\r
- * @cfg {Object} selModel A tree selection model to use with this TreePanel (defaults to an {@link Ext.tree.DefaultSelectionModel})\r
- * @cfg {Boolean} trackMouseOver <tt>false</tt> to disable mouse over highlighting\r
- * @cfg {Ext.tree.TreeLoader} loader A {@link Ext.tree.TreeLoader} for use with this TreePanel\r
- * @cfg {String} pathSeparator The token used to separate sub-paths in path strings (defaults to <tt>'/'</tt>)\r
- * @cfg {Boolean} useArrows <tt>true</tt> to use Vista-style arrows in the tree (defaults to <tt>false</tt>)\r
- * @cfg {String} requestMethod The HTTP request method for loading data (defaults to the value of {@link Ext.Ajax#method}).\r
- *\r
- * @constructor\r
- * @param {Object} config\r
- * @xtype treepanel\r
- */\r
-Ext.tree.TreePanel = Ext.extend(Ext.Panel, {\r
- rootVisible : true,\r
- animate: Ext.enableFx,\r
- lines : true,\r
- enableDD : false,\r
- hlDrop : Ext.enableFx,\r
- pathSeparator: "/",\r
-\r
- initComponent : function(){\r
- Ext.tree.TreePanel.superclass.initComponent.call(this);\r
-\r
- if(!this.eventModel){\r
- this.eventModel = new Ext.tree.TreeEventModel(this);\r
- }\r
-\r
- // initialize the loader\r
- var l = this.loader;\r
- if(!l){\r
- l = new Ext.tree.TreeLoader({\r
- dataUrl: this.dataUrl,\r
- requestMethod: this.requestMethod\r
- });\r
- }else if(typeof l == 'object' && !l.load){\r
- l = new Ext.tree.TreeLoader(l);\r
- }\r
- this.loader = l;\r
-\r
- this.nodeHash = {};\r
-\r
- /**\r
- * The root node of this tree.\r
- * @type Ext.tree.TreeNode\r
- * @property root\r
- */\r
- if(this.root){\r
- var r = this.root;\r
- delete this.root;\r
- this.setRootNode(r);\r
- }\r
-\r
-\r
- this.addEvents(\r
-\r
- /**\r
- * @event append\r
- * Fires when a new child node is appended to a node in this tree.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The newly appended node\r
- * @param {Number} index The index of the newly appended node\r
- */\r
- "append",\r
- /**\r
- * @event remove\r
- * Fires when a child node is removed from a node in this tree.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node removed\r
- */\r
- "remove",\r
- /**\r
- * @event movenode\r
- * Fires when a node is moved to a new location in the tree\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} node The node moved\r
- * @param {Node} oldParent The old parent of this node\r
- * @param {Node} newParent The new parent of this node\r
- * @param {Number} index The index it was moved to\r
- */\r
- "movenode",\r
- /**\r
- * @event insert\r
- * Fires when a new child node is inserted in a node in this tree.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node inserted\r
- * @param {Node} refNode The child node the node was inserted before\r
- */\r
- "insert",\r
- /**\r
- * @event beforeappend\r
- * Fires before a new child is appended to a node in this tree, return false to cancel the append.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node to be appended\r
- */\r
- "beforeappend",\r
- /**\r
- * @event beforeremove\r
- * Fires before a child is removed from a node in this tree, return false to cancel the remove.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node to be removed\r
- */\r
- "beforeremove",\r
- /**\r
- * @event beforemovenode\r
- * Fires before a node is moved to a new location in the tree. Return false to cancel the move.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} node The node being moved\r
- * @param {Node} oldParent The parent of the node\r
- * @param {Node} newParent The new parent the node is moving to\r
- * @param {Number} index The index it is being moved to\r
- */\r
- "beforemovenode",\r
- /**\r
- * @event beforeinsert\r
- * Fires before a new child is inserted in a node in this tree, return false to cancel the insert.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node to be inserted\r
- * @param {Node} refNode The child node the node is being inserted before\r
- */\r
- "beforeinsert",\r
-\r
- /**\r
- * @event beforeload\r
- * Fires before a node is loaded, return false to cancel\r
- * @param {Node} node The node being loaded\r
- */\r
- "beforeload",\r
- /**\r
- * @event load\r
- * Fires when a node is loaded\r
- * @param {Node} node The node that was loaded\r
- */\r
- "load",\r
- /**\r
- * @event textchange\r
- * Fires when the text for a node is changed\r
- * @param {Node} node The node\r
- * @param {String} text The new text\r
- * @param {String} oldText The old text\r
- */\r
- "textchange",\r
- /**\r
- * @event beforeexpandnode\r
- * Fires before a node is expanded, return false to cancel.\r
- * @param {Node} node The node\r
- * @param {Boolean} deep\r
- * @param {Boolean} anim\r
- */\r
- "beforeexpandnode",\r
- /**\r
- * @event beforecollapsenode\r
- * Fires before a node is collapsed, return false to cancel.\r
- * @param {Node} node The node\r
- * @param {Boolean} deep\r
- * @param {Boolean} anim\r
- */\r
- "beforecollapsenode",\r
- /**\r
- * @event expandnode\r
- * Fires when a node is expanded\r
- * @param {Node} node The node\r
- */\r
- "expandnode",\r
- /**\r
- * @event disabledchange\r
- * Fires when the disabled status of a node changes\r
- * @param {Node} node The node\r
- * @param {Boolean} disabled\r
- */\r
- "disabledchange",\r
- /**\r
- * @event collapsenode\r
- * Fires when a node is collapsed\r
- * @param {Node} node The node\r
- */\r
- "collapsenode",\r
- /**\r
- * @event beforeclick\r
- * Fires before click processing on a node. Return false to cancel the default action.\r
- * @param {Node} node The node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "beforeclick",\r
- /**\r
- * @event click\r
- * Fires when a node is clicked\r
- * @param {Node} node The node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "click",\r
- /**\r
- * @event checkchange\r
- * Fires when a node with a checkbox's checked property changes\r
- * @param {Node} this This node\r
- * @param {Boolean} checked\r
- */\r
- "checkchange",\r
- /**\r
- * @event dblclick\r
- * Fires when a node is double clicked\r
- * @param {Node} node The node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "dblclick",\r
- /**\r
- * @event contextmenu\r
- * Fires when a node is right clicked. To display a context menu in response to this\r
- * event, first create a Menu object (see {@link Ext.menu.Menu} for details), then add\r
- * a handler for this event:<pre><code>\r
-new Ext.tree.TreePanel({\r
- title: 'My TreePanel',\r
- root: new Ext.tree.AsyncTreeNode({\r
- text: 'The Root',\r
- children: [\r
- { text: 'Child node 1', leaf: true },\r
- { text: 'Child node 2', leaf: true }\r
- ]\r
- }),\r
- contextMenu: new Ext.menu.Menu({\r
- items: [{\r
- id: 'delete-node',\r
- text: 'Delete Node'\r
- }],\r
- listeners: {\r
- itemclick: function(item) {\r
- switch (item.id) {\r
- case 'delete-node':\r
- var n = item.parentMenu.contextNode;\r
- if (n.parentNode) {\r
- n.remove();\r
- }\r
- break;\r
- }\r
- }\r
- }\r
- }),\r
- listeners: {\r
- contextmenu: function(node, e) {\r
-// Register the context node with the menu so that a Menu Item's handler function can access\r
-// it via its {@link Ext.menu.BaseItem#parentMenu parentMenu} property.\r
- node.select();\r
- var c = node.getOwnerTree().contextMenu;\r
- c.contextNode = node;\r
- c.showAt(e.getXY());\r
- }\r
- }\r
-});\r
-</code></pre>\r
- * @param {Node} node The node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "contextmenu",\r
- /**\r
- * @event beforechildrenrendered\r
- * Fires right before the child nodes for a node are rendered\r
- * @param {Node} node The node\r
- */\r
- "beforechildrenrendered",\r
- /**\r
- * @event startdrag\r
- * Fires when a node starts being dragged\r
- * @param {Ext.tree.TreePanel} this\r
- * @param {Ext.tree.TreeNode} node\r
- * @param {event} e The raw browser event\r
- */\r
- "startdrag",\r
- /**\r
- * @event enddrag\r
- * Fires when a drag operation is complete\r
- * @param {Ext.tree.TreePanel} this\r
- * @param {Ext.tree.TreeNode} node\r
- * @param {event} e The raw browser event\r
- */\r
- "enddrag",\r
- /**\r
- * @event dragdrop\r
- * Fires when a dragged node is dropped on a valid DD target\r
- * @param {Ext.tree.TreePanel} this\r
- * @param {Ext.tree.TreeNode} node\r
- * @param {DD} dd The dd it was dropped on\r
- * @param {event} e The raw browser event\r
- */\r
- "dragdrop",\r
- /**\r
- * @event beforenodedrop\r
- * Fires when a DD object is dropped on a node in this tree for preprocessing. Return false to cancel the drop. The dropEvent\r
- * passed to handlers has the following properties:<br />\r
- * <ul style="padding:5px;padding-left:16px;">\r
- * <li>tree - The TreePanel</li>\r
- * <li>target - The node being targeted for the drop</li>\r
- * <li>data - The drag data from the drag source</li>\r
- * <li>point - The point of the drop - append, above or below</li>\r
- * <li>source - The drag source</li>\r
- * <li>rawEvent - Raw mouse event</li>\r
- * <li>dropNode - Drop node(s) provided by the source <b>OR</b> you can supply node(s)\r
- * to be inserted by setting them on this object.</li>\r
- * <li>cancel - Set this to true to cancel the drop.</li>\r
- * <li>dropStatus - If the default drop action is cancelled but the drop is valid, setting this to true\r
- * will prevent the animated "repair" from appearing.</li>\r
- * </ul>\r
- * @param {Object} dropEvent\r
- */\r
- "beforenodedrop",\r
- /**\r
- * @event nodedrop\r
- * Fires after a DD object is dropped on a node in this tree. The dropEvent\r
- * passed to handlers has the following properties:<br />\r
- * <ul style="padding:5px;padding-left:16px;">\r
- * <li>tree - The TreePanel</li>\r
- * <li>target - The node being targeted for the drop</li>\r
- * <li>data - The drag data from the drag source</li>\r
- * <li>point - The point of the drop - append, above or below</li>\r
- * <li>source - The drag source</li>\r
- * <li>rawEvent - Raw mouse event</li>\r
- * <li>dropNode - Dropped node(s).</li>\r
- * </ul>\r
- * @param {Object} dropEvent\r
- */\r
- "nodedrop",\r
- /**\r
- * @event nodedragover\r
- * Fires when a tree node is being targeted for a drag drop, return false to signal drop not allowed. The dragOverEvent\r
- * passed to handlers has the following properties:<br />\r
- * <ul style="padding:5px;padding-left:16px;">\r
- * <li>tree - The TreePanel</li>\r
- * <li>target - The node being targeted for the drop</li>\r
- * <li>data - The drag data from the drag source</li>\r
- * <li>point - The point of the drop - append, above or below</li>\r
- * <li>source - The drag source</li>\r
- * <li>rawEvent - Raw mouse event</li>\r
- * <li>dropNode - Drop node(s) provided by the source.</li>\r
- * <li>cancel - Set this to true to signal drop not allowed.</li>\r
- * </ul>\r
- * @param {Object} dragOverEvent\r
- */\r
- "nodedragover"\r
- );\r
- if(this.singleExpand){\r
- this.on("beforeexpandnode", this.restrictExpand, this);\r
- }\r
- },\r
-\r
- // private\r
- proxyNodeEvent : function(ename, a1, a2, a3, a4, a5, a6){\r
- if(ename == 'collapse' || ename == 'expand' || ename == 'beforecollapse' || ename == 'beforeexpand' || ename == 'move' || ename == 'beforemove'){\r
- ename = ename+'node';\r
- }\r
- // args inline for performance while bubbling events\r
- return this.fireEvent(ename, a1, a2, a3, a4, a5, a6);\r
- },\r
-\r
-\r
- /**\r
- * Returns this root node for this tree\r
- * @return {Node}\r
- */\r
- getRootNode : function(){\r
- return this.root;\r
- },\r
-\r
- /**\r
- * Sets the root node for this tree. If the TreePanel has already rendered a root node, the\r
- * previous root node (and all of its descendants) are destroyed before the new root node is rendered.\r
- * @param {Node} node\r
- * @return {Node}\r
- */\r
- setRootNode : function(node){\r
- Ext.destroy(this.root);\r
- if(!node.render){ // attributes passed\r
- node = this.loader.createNode(node);\r
- }\r
- this.root = node;\r
- node.ownerTree = this;\r
- node.isRoot = true;\r
- this.registerNode(node);\r
- if(!this.rootVisible){\r
- var uiP = node.attributes.uiProvider;\r
- node.ui = uiP ? new uiP(node) : new Ext.tree.RootTreeNodeUI(node);\r
- }\r
- if (this.innerCt) {\r
- this.innerCt.update('');\r
- this.afterRender();\r
- }\r
- return node;\r
- },\r
-\r
- /**\r
- * Gets a node in this tree by its id\r
- * @param {String} id\r
- * @return {Node}\r
- */\r
- getNodeById : function(id){\r
- return this.nodeHash[id];\r
- },\r
-\r
- // private\r
- registerNode : function(node){\r
- this.nodeHash[node.id] = node;\r
- },\r
-\r
- // private\r
- unregisterNode : function(node){\r
- delete this.nodeHash[node.id];\r
- },\r
-\r
- // private\r
- toString : function(){\r
- return "[Tree"+(this.id?" "+this.id:"")+"]";\r
- },\r
-\r
- // private\r
- restrictExpand : function(node){\r
- var p = node.parentNode;\r
- if(p){\r
- if(p.expandedChild && p.expandedChild.parentNode == p){\r
- p.expandedChild.collapse();\r
- }\r
- p.expandedChild = node;\r
- }\r
- },\r
-\r
- /**\r
- * Retrieve an array of checked nodes, or an array of a specific attribute of checked nodes (e.g. "id")\r
- * @param {String} attribute (optional) Defaults to null (return the actual nodes)\r
- * @param {TreeNode} startNode (optional) The node to start from, defaults to the root\r
- * @return {Array}\r
- */\r
- getChecked : function(a, startNode){\r
- startNode = startNode || this.root;\r
- var r = [];\r
- var f = function(){\r
- if(this.attributes.checked){\r
- r.push(!a ? this : (a == 'id' ? this.id : this.attributes[a]));\r
- }\r
- };\r
- startNode.cascade(f);\r
- return r;\r
- },\r
-\r
- /**\r
- * Returns the container element for this TreePanel.\r
- * @return {Element} The container element for this TreePanel.\r
- */\r
- getEl : function(){\r
- return this.el;\r
- },\r
-\r
- /**\r
- * Returns the default {@link Ext.tree.TreeLoader} for this TreePanel.\r
- * @return {Ext.tree.TreeLoader} The TreeLoader for this TreePanel.\r
- */\r
- getLoader : function(){\r
- return this.loader;\r
- },\r
-\r
- /**\r
- * Expand all nodes\r
- */\r
- expandAll : function(){\r
- this.root.expand(true);\r
- },\r
-\r
- /**\r
- * Collapse all nodes\r
- */\r
- collapseAll : function(){\r
- this.root.collapse(true);\r
- },\r
-\r
- /**\r
- * Returns the selection model used by this TreePanel.\r
- * @return {TreeSelectionModel} The selection model used by this TreePanel\r
- */\r
- getSelectionModel : function(){\r
- if(!this.selModel){\r
- this.selModel = new Ext.tree.DefaultSelectionModel();\r
- }\r
- return this.selModel;\r
- },\r
-\r
- /**\r
- * Expands a specified path in this TreePanel. A path can be retrieved from a node with {@link Ext.data.Node#getPath}\r
- * @param {String} path\r
- * @param {String} attr (optional) The attribute used in the path (see {@link Ext.data.Node#getPath} for more info)\r
- * @param {Function} callback (optional) The callback to call when the expand is complete. The callback will be called with\r
- * (bSuccess, oLastNode) where bSuccess is if the expand was successful and oLastNode is the last node that was expanded.\r
- */\r
- expandPath : function(path, attr, callback){\r
- attr = attr || "id";\r
- var keys = path.split(this.pathSeparator);\r
- var curNode = this.root;\r
- if(curNode.attributes[attr] != keys[1]){ // invalid root\r
- if(callback){\r
- callback(false, null);\r
- }\r
- return;\r
- }\r
- var index = 1;\r
- var f = function(){\r
- if(++index == keys.length){\r
- if(callback){\r
- callback(true, curNode);\r
- }\r
- return;\r
- }\r
- var c = curNode.findChild(attr, keys[index]);\r
- if(!c){\r
- if(callback){\r
- callback(false, curNode);\r
- }\r
- return;\r
- }\r
- curNode = c;\r
- c.expand(false, false, f);\r
- };\r
- curNode.expand(false, false, f);\r
- },\r
-\r
- /**\r
- * Selects the node in this tree at the specified path. A path can be retrieved from a node with {@link Ext.data.Node#getPath}\r
- * @param {String} path\r
- * @param {String} attr (optional) The attribute used in the path (see {@link Ext.data.Node#getPath} for more info)\r
- * @param {Function} callback (optional) The callback to call when the selection is complete. The callback will be called with\r
- * (bSuccess, oSelNode) where bSuccess is if the selection was successful and oSelNode is the selected node.\r
- */\r
- selectPath : function(path, attr, callback){\r
- attr = attr || "id";\r
- var keys = path.split(this.pathSeparator);\r
- var v = keys.pop();\r
- if(keys.length > 0){\r
- var f = function(success, node){\r
- if(success && node){\r
- var n = node.findChild(attr, v);\r
- if(n){\r
- n.select();\r
- if(callback){\r
- callback(true, n);\r
- }\r
- }else if(callback){\r
- callback(false, n);\r
- }\r
- }else{\r
- if(callback){\r
- callback(false, n);\r
- }\r
- }\r
- };\r
- this.expandPath(keys.join(this.pathSeparator), attr, f);\r
- }else{\r
- this.root.select();\r
- if(callback){\r
- callback(true, this.root);\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * Returns the underlying Element for this tree\r
- * @return {Ext.Element} The Element\r
- */\r
- getTreeEl : function(){\r
- return this.body;\r
- },\r
-\r
- // private\r
- onRender : function(ct, position){\r
- Ext.tree.TreePanel.superclass.onRender.call(this, ct, position);\r
- this.el.addClass('x-tree');\r
- this.innerCt = this.body.createChild({tag:"ul",\r
- cls:"x-tree-root-ct " +\r
- (this.useArrows ? 'x-tree-arrows' : this.lines ? "x-tree-lines" : "x-tree-no-lines")});\r
- },\r
-\r
- // private\r
- initEvents : function(){\r
- Ext.tree.TreePanel.superclass.initEvents.call(this);\r
-\r
- if(this.containerScroll){\r
- Ext.dd.ScrollManager.register(this.body);\r
- }\r
- if((this.enableDD || this.enableDrop) && !this.dropZone){\r
- /**\r
- * The dropZone used by this tree if drop is enabled (see {@link #enableDD} or {@link #enableDrop})\r
- * @property dropZone\r
- * @type Ext.tree.TreeDropZone\r
- */\r
- this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || {\r
- ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true\r
- });\r
- }\r
- if((this.enableDD || this.enableDrag) && !this.dragZone){\r
- /**\r
- * The dragZone used by this tree if drag is enabled (see {@link #enableDD} or {@link #enableDrag})\r
- * @property dragZone\r
- * @type Ext.tree.TreeDragZone\r
- */\r
- this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || {\r
- ddGroup: this.ddGroup || "TreeDD",\r
- scroll: this.ddScroll\r
- });\r
- }\r
- this.getSelectionModel().init(this);\r
- },\r
-\r
- // private\r
- afterRender : function(){\r
- Ext.tree.TreePanel.superclass.afterRender.call(this);\r
- this.root.render();\r
- if(!this.rootVisible){\r
- this.root.renderChildren();\r
- }\r
- },\r
-\r
- onDestroy : function(){\r
- if(this.rendered){\r
- this.body.removeAllListeners();\r
- Ext.dd.ScrollManager.unregister(this.body);\r
- if(this.dropZone){\r
- this.dropZone.unreg();\r
- }\r
- if(this.dragZone){\r
- this.dragZone.unreg();\r
- }\r
- }\r
- this.root.destroy();\r
- this.nodeHash = null;\r
- Ext.tree.TreePanel.superclass.onDestroy.call(this);\r
- }\r
-\r
- /**\r
- * @cfg {String/Number} activeItem\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Boolean} autoDestroy\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Object/String/Function} autoLoad\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Boolean} autoWidth\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Boolean/Number} bufferResize\r
- * @hide\r
- */\r
- /**\r
- * @cfg {String} defaultType\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Object} defaults\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Boolean} hideBorders\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Mixed} items\r
- * @hide\r
- */\r
- /**\r
- * @cfg {String} layout\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Object} layoutConfig\r
- * @hide\r
- */\r
- /**\r
- * @cfg {Boolean} monitorResize\r
- * @hide\r
- */\r
- /**\r
- * @property items\r
- * @hide\r
- */\r
- /**\r
- * @method cascade\r
- * @hide\r
- */\r
- /**\r
- * @method doLayout\r
- * @hide\r
- */\r
- /**\r
- * @method find\r
- * @hide\r
- */\r
- /**\r
- * @method findBy\r
- * @hide\r
- */\r
- /**\r
- * @method findById\r
- * @hide\r
- */\r
- /**\r
- * @method findByType\r
- * @hide\r
- */\r
- /**\r
- * @method getComponent\r
- * @hide\r
- */\r
- /**\r
- * @method getLayout\r
- * @hide\r
- */\r
- /**\r
- * @method getUpdater\r
- * @hide\r
- */\r
- /**\r
- * @method insert\r
- * @hide\r
- */\r
- /**\r
- * @method load\r
- * @hide\r
- */\r
- /**\r
- * @method remove\r
- * @hide\r
- */\r
- /**\r
- * @event add\r
- * @hide\r
- */\r
- /**\r
- * @method removeAll\r
- * @hide\r
- */\r
- /**\r
- * @event afterLayout\r
- * @hide\r
- */\r
- /**\r
- * @event beforeadd\r
- * @hide\r
- */\r
- /**\r
- * @event beforeremove\r
- * @hide\r
- */\r
- /**\r
- * @event remove\r
- * @hide\r
- */\r
-\r
-\r
-\r
- /**\r
- * @cfg {String} allowDomMove @hide\r
- */\r
- /**\r
- * @cfg {String} autoEl @hide\r
- */\r
- /**\r
- * @cfg {String} applyTo @hide\r
- */\r
- /**\r
- * @cfg {String} contentEl @hide\r
- */\r
- /**\r
- * @cfg {String} disabledClass @hide\r
- */\r
- /**\r
- * @cfg {String} elements @hide\r
- */\r
- /**\r
- * @cfg {String} html @hide\r
- */\r
- /**\r
- * @cfg {Boolean} preventBodyReset\r
- * @hide\r
- */\r
- /**\r
- * @property disabled\r
- * @hide\r
- */\r
- /**\r
- * @method applyToMarkup\r
- * @hide\r
- */\r
- /**\r
- * @method enable\r
- * @hide\r
- */\r
- /**\r
- * @method disable\r
- * @hide\r
- */\r
- /**\r
- * @method setDisabled\r
- * @hide\r
- */\r
-});\r
-\r
-Ext.tree.TreePanel.nodeTypes = {};\r
-\r
-Ext.reg('treepanel', Ext.tree.TreePanel);Ext.tree.TreeEventModel = function(tree){\r
- this.tree = tree;\r
- this.tree.on('render', this.initEvents, this);\r
-}\r
-\r
-Ext.tree.TreeEventModel.prototype = {\r
- initEvents : function(){\r
- var el = this.tree.getTreeEl();\r
- el.on('click', this.delegateClick, this);\r
- if(this.tree.trackMouseOver !== false){\r
- this.tree.innerCt.on('mouseover', this.delegateOver, this);\r
- this.tree.innerCt.on('mouseout', this.delegateOut, this);\r
- }\r
- el.on('dblclick', this.delegateDblClick, this);\r
- el.on('contextmenu', this.delegateContextMenu, this);\r
- },\r
-\r
- getNode : function(e){\r
- var t;\r
- if(t = e.getTarget('.x-tree-node-el', 10)){\r
- var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');\r
- if(id){\r
- return this.tree.getNodeById(id);\r
- }\r
- }\r
- return null;\r
- },\r
-\r
- getNodeTarget : function(e){\r
- var t = e.getTarget('.x-tree-node-icon', 1);\r
- if(!t){\r
- t = e.getTarget('.x-tree-node-el', 6);\r
- }\r
- return t;\r
- },\r
-\r
- delegateOut : function(e, t){\r
- if(!this.beforeEvent(e)){\r
- return;\r
- }\r
- if(e.getTarget('.x-tree-ec-icon', 1)){\r
- var n = this.getNode(e);\r
- this.onIconOut(e, n);\r
- if(n == this.lastEcOver){\r
- delete this.lastEcOver;\r
- }\r
- }\r
- if((t = this.getNodeTarget(e)) && !e.within(t, true)){\r
- this.onNodeOut(e, this.getNode(e));\r
- }\r
- },\r
-\r
- delegateOver : function(e, t){\r
- if(!this.beforeEvent(e)){\r
- return;\r
- }\r
- if(Ext.isGecko && !this.trackingDoc){ // prevent hanging in FF\r
- Ext.getBody().on('mouseover', this.trackExit, this);\r
- this.trackingDoc = true;\r
- }\r
- if(this.lastEcOver){ // prevent hung highlight\r
- this.onIconOut(e, this.lastEcOver);\r
- delete this.lastEcOver;\r
- }\r
- if(e.getTarget('.x-tree-ec-icon', 1)){\r
- this.lastEcOver = this.getNode(e);\r
- this.onIconOver(e, this.lastEcOver);\r
- }\r
- if(t = this.getNodeTarget(e)){\r
- this.onNodeOver(e, this.getNode(e));\r
- }\r
- },\r
-\r
- trackExit : function(e){\r
- if(this.lastOverNode && !e.within(this.lastOverNode.ui.getEl())){\r
- this.onNodeOut(e, this.lastOverNode);\r
- delete this.lastOverNode;\r
- Ext.getBody().un('mouseover', this.trackExit, this);\r
- this.trackingDoc = false;\r
- }\r
- },\r
-\r
- delegateClick : function(e, t){\r
- if(!this.beforeEvent(e)){\r
- return;\r
- }\r
-\r
- if(e.getTarget('input[type=checkbox]', 1)){\r
- this.onCheckboxClick(e, this.getNode(e));\r
- }\r
- else if(e.getTarget('.x-tree-ec-icon', 1)){\r
- this.onIconClick(e, this.getNode(e));\r
- }\r
- else if(this.getNodeTarget(e)){\r
- this.onNodeClick(e, this.getNode(e));\r
- }\r
- },\r
-\r
- delegateDblClick : function(e, t){\r
- if(this.beforeEvent(e) && this.getNodeTarget(e)){\r
- this.onNodeDblClick(e, this.getNode(e));\r
- }\r
- },\r
-\r
- delegateContextMenu : function(e, t){\r
- if(this.beforeEvent(e) && this.getNodeTarget(e)){\r
- this.onNodeContextMenu(e, this.getNode(e));\r
- }\r
- },\r
-\r
- onNodeClick : function(e, node){\r
- node.ui.onClick(e);\r
- },\r
-\r
- onNodeOver : function(e, node){\r
- this.lastOverNode = node;\r
- node.ui.onOver(e);\r
- },\r
-\r
- onNodeOut : function(e, node){\r
- node.ui.onOut(e);\r
- },\r
-\r
- onIconOver : function(e, node){\r
- node.ui.addClass('x-tree-ec-over');\r
- },\r
-\r
- onIconOut : function(e, node){\r
- node.ui.removeClass('x-tree-ec-over');\r
- },\r
-\r
- onIconClick : function(e, node){\r
- node.ui.ecClick(e);\r
- },\r
-\r
- onCheckboxClick : function(e, node){\r
- node.ui.onCheckChange(e);\r
- },\r
-\r
- onNodeDblClick : function(e, node){\r
- node.ui.onDblClick(e);\r
- },\r
-\r
- onNodeContextMenu : function(e, node){\r
- node.ui.onContextMenu(e);\r
- },\r
-\r
- beforeEvent : function(e){\r
- if(this.disabled){\r
- e.stopEvent();\r
- return false;\r
- }\r
- return true;\r
- },\r
-\r
- disable: function(){\r
- this.disabled = true;\r
- },\r
-\r
- enable: function(){\r
- this.disabled = false;\r
- }\r
-};/**\r
- * @class Ext.tree.DefaultSelectionModel\r
- * @extends Ext.util.Observable\r
- * The default single selection for a TreePanel.\r
- */\r
-Ext.tree.DefaultSelectionModel = function(config){\r
- this.selNode = null;\r
- \r
- this.addEvents(\r
- /**\r
- * @event selectionchange\r
- * Fires when the selected node changes\r
- * @param {DefaultSelectionModel} this\r
- * @param {TreeNode} node the new selection\r
- */\r
- "selectionchange",\r
-\r
- /**\r
- * @event beforeselect\r
- * Fires before the selected node changes, return false to cancel the change\r
- * @param {DefaultSelectionModel} this\r
- * @param {TreeNode} node the new selection\r
- * @param {TreeNode} node the old selection\r
- */\r
- "beforeselect"\r
- );\r
-\r
- Ext.apply(this, config);\r
- Ext.tree.DefaultSelectionModel.superclass.constructor.call(this);\r
-};\r
-\r
-Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {\r
- init : function(tree){\r
- this.tree = tree;\r
- tree.getTreeEl().on("keydown", this.onKeyDown, this);\r
- tree.on("click", this.onNodeClick, this);\r
- },\r
- \r
- onNodeClick : function(node, e){\r
- this.select(node);\r
- },\r
- \r
- /**\r
- * Select a node.\r
- * @param {TreeNode} node The node to select\r
- * @return {TreeNode} The selected node\r
- */\r
- select : function(node){\r
- var last = this.selNode;\r
- if(node == last){\r
- node.ui.onSelectedChange(true);\r
- }else if(this.fireEvent('beforeselect', this, node, last) !== false){\r
- if(last){\r
- last.ui.onSelectedChange(false);\r
- }\r
- this.selNode = node;\r
- node.ui.onSelectedChange(true);\r
- this.fireEvent("selectionchange", this, node, last);\r
- }\r
- return node;\r
- },\r
- \r
- /**\r
- * Deselect a node.\r
- * @param {TreeNode} node The node to unselect\r
- */\r
- unselect : function(node){\r
- if(this.selNode == node){\r
- this.clearSelections();\r
- } \r
- },\r
- \r
- /**\r
- * Clear all selections\r
- */\r
- clearSelections : function(){\r
- var n = this.selNode;\r
- if(n){\r
- n.ui.onSelectedChange(false);\r
- this.selNode = null;\r
- this.fireEvent("selectionchange", this, null);\r
- }\r
- return n;\r
- },\r
- \r
- /**\r
- * Get the selected node\r
- * @return {TreeNode} The selected node\r
- */\r
- getSelectedNode : function(){\r
- return this.selNode; \r
- },\r
- \r
- /**\r
- * Returns true if the node is selected\r
- * @param {TreeNode} node The node to check\r
- * @return {Boolean}\r
- */\r
- isSelected : function(node){\r
- return this.selNode == node; \r
- },\r
-\r
- /**\r
- * Selects the node above the selected node in the tree, intelligently walking the nodes\r
- * @return TreeNode The new selection\r
- */\r
- selectPrevious : function(){\r
- var s = this.selNode || this.lastSelNode;\r
- if(!s){\r
- return null;\r
- }\r
- var ps = s.previousSibling;\r
- if(ps){\r
- if(!ps.isExpanded() || ps.childNodes.length < 1){\r
- return this.select(ps);\r
- } else{\r
- var lc = ps.lastChild;\r
- while(lc && lc.isExpanded() && lc.childNodes.length > 0){\r
- lc = lc.lastChild;\r
- }\r
- return this.select(lc);\r
- }\r
- } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){\r
- return this.select(s.parentNode);\r
- }\r
- return null;\r
- },\r
-\r
- /**\r
- * Selects the node above the selected node in the tree, intelligently walking the nodes\r
- * @return TreeNode The new selection\r
- */\r
- selectNext : function(){\r
- var s = this.selNode || this.lastSelNode;\r
- if(!s){\r
- return null;\r
- }\r
- if(s.firstChild && s.isExpanded()){\r
- return this.select(s.firstChild);\r
- }else if(s.nextSibling){\r
- return this.select(s.nextSibling);\r
- }else if(s.parentNode){\r
- var newS = null;\r
- s.parentNode.bubble(function(){\r
- if(this.nextSibling){\r
- newS = this.getOwnerTree().selModel.select(this.nextSibling);\r
- return false;\r
- }\r
- });\r
- return newS;\r
- }\r
- return null;\r
- },\r
-\r
- onKeyDown : function(e){\r
- var s = this.selNode || this.lastSelNode;\r
- // undesirable, but required\r
- var sm = this;\r
- if(!s){\r
- return;\r
- }\r
- var k = e.getKey();\r
- switch(k){\r
- case e.DOWN:\r
- e.stopEvent();\r
- this.selectNext();\r
- break;\r
- case e.UP:\r
- e.stopEvent();\r
- this.selectPrevious();\r
- break;\r
- case e.RIGHT:\r
- e.preventDefault();\r
- if(s.hasChildNodes()){\r
- if(!s.isExpanded()){\r
- s.expand();\r
- }else if(s.firstChild){\r
- this.select(s.firstChild, e);\r
- }\r
- }\r
- break;\r
- case e.LEFT:\r
- e.preventDefault();\r
- if(s.hasChildNodes() && s.isExpanded()){\r
- s.collapse();\r
- }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){\r
- this.select(s.parentNode, e);\r
- }\r
- break;\r
- };\r
- }\r
-});\r
-\r
-/**\r
- * @class Ext.tree.MultiSelectionModel\r
- * @extends Ext.util.Observable\r
- * Multi selection for a TreePanel.\r
- */\r
-Ext.tree.MultiSelectionModel = function(config){\r
- this.selNodes = [];\r
- this.selMap = {};\r
- this.addEvents(\r
- /**\r
- * @event selectionchange\r
- * Fires when the selected nodes change\r
- * @param {MultiSelectionModel} this\r
- * @param {Array} nodes Array of the selected nodes\r
- */\r
- "selectionchange"\r
- );\r
- Ext.apply(this, config);\r
- Ext.tree.MultiSelectionModel.superclass.constructor.call(this);\r
-};\r
-\r
-Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {\r
- init : function(tree){\r
- this.tree = tree;\r
- tree.getTreeEl().on("keydown", this.onKeyDown, this);\r
- tree.on("click", this.onNodeClick, this);\r
- },\r
- \r
- onNodeClick : function(node, e){\r
- if(e.ctrlKey && this.isSelected(node)){\r
- this.unselect(node);\r
- }else{\r
- this.select(node, e, e.ctrlKey);\r
- }\r
- },\r
- \r
- /**\r
- * Select a node.\r
- * @param {TreeNode} node The node to select\r
- * @param {EventObject} e (optional) An event associated with the selection\r
- * @param {Boolean} keepExisting True to retain existing selections\r
- * @return {TreeNode} The selected node\r
- */\r
- select : function(node, e, keepExisting){\r
- if(keepExisting !== true){\r
- this.clearSelections(true);\r
- }\r
- if(this.isSelected(node)){\r
- this.lastSelNode = node;\r
- return node;\r
- }\r
- this.selNodes.push(node);\r
- this.selMap[node.id] = node;\r
- this.lastSelNode = node;\r
- node.ui.onSelectedChange(true);\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
- return node;\r
- },\r
- \r
- /**\r
- * Deselect a node.\r
- * @param {TreeNode} node The node to unselect\r
- */\r
- unselect : function(node){\r
- if(this.selMap[node.id]){\r
- node.ui.onSelectedChange(false);\r
- var sn = this.selNodes;\r
- var index = sn.indexOf(node);\r
- if(index != -1){\r
- this.selNodes.splice(index, 1);\r
- }\r
- delete this.selMap[node.id];\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
- }\r
- },\r
- \r
- /**\r
- * Clear all selections\r
- */\r
- clearSelections : function(suppressEvent){\r
- var sn = this.selNodes;\r
- if(sn.length > 0){\r
- for(var i = 0, len = sn.length; i < len; i++){\r
- sn[i].ui.onSelectedChange(false);\r
- }\r
- this.selNodes = [];\r
- this.selMap = {};\r
- if(suppressEvent !== true){\r
- this.fireEvent("selectionchange", this, this.selNodes);\r
- }\r
- }\r
- },\r
- \r
- /**\r
- * Returns true if the node is selected\r
- * @param {TreeNode} node The node to check\r
- * @return {Boolean}\r
- */\r
- isSelected : function(node){\r
- return this.selMap[node.id] ? true : false; \r
- },\r
- \r
- /**\r
- * Returns an array of the selected nodes\r
- * @return {Array}\r
- */\r
- getSelectedNodes : function(){\r
- return this.selNodes; \r
- },\r
-\r
- onKeyDown : Ext.tree.DefaultSelectionModel.prototype.onKeyDown,\r
-\r
- selectNext : Ext.tree.DefaultSelectionModel.prototype.selectNext,\r
-\r
- selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious\r
-});/**\r
- * @class Ext.data.Tree\r
- * @extends Ext.util.Observable\r
- * Represents a tree data structure and bubbles all the events for its nodes. The nodes\r
- * in the tree have most standard DOM functionality.\r
- * @constructor\r
- * @param {Node} root (optional) The root node\r
- */\r
-Ext.data.Tree = function(root){\r
- this.nodeHash = {};\r
- /**\r
- * The root node for this tree\r
- * @type Node\r
- */\r
- this.root = null;\r
- if(root){\r
- this.setRootNode(root);\r
- }\r
- this.addEvents(\r
- /**\r
- * @event append\r
- * Fires when a new child node is appended to a node in this tree.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The newly appended node\r
- * @param {Number} index The index of the newly appended node\r
- */\r
- "append",\r
- /**\r
- * @event remove\r
- * Fires when a child node is removed from a node in this tree.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node removed\r
- */\r
- "remove",\r
- /**\r
- * @event move\r
- * Fires when a node is moved to a new location in the tree\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} node The node moved\r
- * @param {Node} oldParent The old parent of this node\r
- * @param {Node} newParent The new parent of this node\r
- * @param {Number} index The index it was moved to\r
- */\r
- "move",\r
- /**\r
- * @event insert\r
- * Fires when a new child node is inserted in a node in this tree.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node inserted\r
- * @param {Node} refNode The child node the node was inserted before\r
- */\r
- "insert",\r
- /**\r
- * @event beforeappend\r
- * Fires before a new child is appended to a node in this tree, return false to cancel the append.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node to be appended\r
- */\r
- "beforeappend",\r
- /**\r
- * @event beforeremove\r
- * Fires before a child is removed from a node in this tree, return false to cancel the remove.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node to be removed\r
- */\r
- "beforeremove",\r
- /**\r
- * @event beforemove\r
- * Fires before a node is moved to a new location in the tree. Return false to cancel the move.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} node The node being moved\r
- * @param {Node} oldParent The parent of the node\r
- * @param {Node} newParent The new parent the node is moving to\r
- * @param {Number} index The index it is being moved to\r
- */\r
- "beforemove",\r
- /**\r
- * @event beforeinsert\r
- * Fires before a new child is inserted in a node in this tree, return false to cancel the insert.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} parent The parent node\r
- * @param {Node} node The child node to be inserted\r
- * @param {Node} refNode The child node the node is being inserted before\r
- */\r
- "beforeinsert"\r
- );\r
-\r
- Ext.data.Tree.superclass.constructor.call(this);\r
-};\r
-\r
-Ext.extend(Ext.data.Tree, Ext.util.Observable, {\r
- /**\r
- * @cfg {String} pathSeparator\r
- * The token used to separate paths in node ids (defaults to '/').\r
- */\r
- pathSeparator: "/",\r
-\r
- // private\r
- proxyNodeEvent : function(){\r
- return this.fireEvent.apply(this, arguments);\r
- },\r
-\r
- /**\r
- * Returns the root node for this tree.\r
- * @return {Node}\r
- */\r
- getRootNode : function(){\r
- return this.root;\r
- },\r
-\r
- /**\r
- * Sets the root node for this tree.\r
- * @param {Node} node\r
- * @return {Node}\r
- */\r
- setRootNode : function(node){\r
- this.root = node;\r
- node.ownerTree = this;\r
- node.isRoot = true;\r
- this.registerNode(node);\r
- return node;\r
- },\r
-\r
- /**\r
- * Gets a node in this tree by its id.\r
- * @param {String} id\r
- * @return {Node}\r
- */\r
- getNodeById : function(id){\r
- return this.nodeHash[id];\r
- },\r
-\r
- // private\r
- registerNode : function(node){\r
- this.nodeHash[node.id] = node;\r
- },\r
-\r
- // private\r
- unregisterNode : function(node){\r
- delete this.nodeHash[node.id];\r
- },\r
-\r
- toString : function(){\r
- return "[Tree"+(this.id?" "+this.id:"")+"]";\r
- }\r
-});\r
-\r
-/**\r
- * @class Ext.data.Node\r
- * @extends Ext.util.Observable\r
- * @cfg {Boolean} leaf true if this node is a leaf and does not have children\r
- * @cfg {String} id The id for this node. If one is not specified, one is generated.\r
- * @constructor\r
- * @param {Object} attributes The attributes/config for the node\r
- */\r
-Ext.data.Node = function(attributes){\r
- /**\r
- * The attributes supplied for the node. You can use this property to access any custom attributes you supplied.\r
- * @type {Object}\r
- */\r
- this.attributes = attributes || {};\r
- this.leaf = this.attributes.leaf;\r
- /**\r
- * The node id. @type String\r
- */\r
- this.id = this.attributes.id;\r
- if(!this.id){\r
- this.id = Ext.id(null, "xnode-");\r
- this.attributes.id = this.id;\r
- }\r
- /**\r
- * All child nodes of this node. @type Array\r
- */\r
- this.childNodes = [];\r
- if(!this.childNodes.indexOf){ // indexOf is a must\r
- this.childNodes.indexOf = function(o){\r
- for(var i = 0, len = this.length; i < len; i++){\r
- if(this[i] == o){\r
- return i;\r
- }\r
- }\r
- return -1;\r
- };\r
- }\r
- /**\r
- * The parent node for this node. @type Node\r
- */\r
- this.parentNode = null;\r
- /**\r
- * The first direct child node of this node, or null if this node has no child nodes. @type Node\r
- */\r
- this.firstChild = null;\r
- /**\r
- * The last direct child node of this node, or null if this node has no child nodes. @type Node\r
- */\r
- this.lastChild = null;\r
- /**\r
- * The node immediately preceding this node in the tree, or null if there is no sibling node. @type Node\r
- */\r
- this.previousSibling = null;\r
- /**\r
- * The node immediately following this node in the tree, or null if there is no sibling node. @type Node\r
- */\r
- this.nextSibling = null;\r
-\r
- this.addEvents({\r
- /**\r
- * @event append\r
- * Fires when a new child node is appended\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} node The newly appended node\r
- * @param {Number} index The index of the newly appended node\r
- */\r
- "append" : true,\r
- /**\r
- * @event remove\r
- * Fires when a child node is removed\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} node The removed node\r
- */\r
- "remove" : true,\r
- /**\r
- * @event move\r
- * Fires when this node is moved to a new location in the tree\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} oldParent The old parent of this node\r
- * @param {Node} newParent The new parent of this node\r
- * @param {Number} index The index it was moved to\r
- */\r
- "move" : true,\r
- /**\r
- * @event insert\r
- * Fires when a new child node is inserted.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} node The child node inserted\r
- * @param {Node} refNode The child node the node was inserted before\r
- */\r
- "insert" : true,\r
- /**\r
- * @event beforeappend\r
- * Fires before a new child is appended, return false to cancel the append.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} node The child node to be appended\r
- */\r
- "beforeappend" : true,\r
- /**\r
- * @event beforeremove\r
- * Fires before a child is removed, return false to cancel the remove.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} node The child node to be removed\r
- */\r
- "beforeremove" : true,\r
- /**\r
- * @event beforemove\r
- * Fires before this node is moved to a new location in the tree. Return false to cancel the move.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} oldParent The parent of this node\r
- * @param {Node} newParent The new parent this node is moving to\r
- * @param {Number} index The index it is being moved to\r
- */\r
- "beforemove" : true,\r
- /**\r
- * @event beforeinsert\r
- * Fires before a new child is inserted, return false to cancel the insert.\r
- * @param {Tree} tree The owner tree\r
- * @param {Node} this This node\r
- * @param {Node} node The child node to be inserted\r
- * @param {Node} refNode The child node the node is being inserted before\r
- */\r
- "beforeinsert" : true\r
- });\r
- this.listeners = this.attributes.listeners;\r
- Ext.data.Node.superclass.constructor.call(this);\r
-};\r
-\r
-Ext.extend(Ext.data.Node, Ext.util.Observable, {\r
- // private\r
- fireEvent : function(evtName){\r
- // first do standard event for this node\r
- if(Ext.data.Node.superclass.fireEvent.apply(this, arguments) === false){\r
- return false;\r
- }\r
- // then bubble it up to the tree if the event wasn't cancelled\r
- var ot = this.getOwnerTree();\r
- if(ot){\r
- if(ot.proxyNodeEvent.apply(ot, arguments) === false){\r
- return false;\r
- }\r
- }\r
- return true;\r
- },\r
-\r
- /**\r
- * Returns true if this node is a leaf\r
- * @return {Boolean}\r
- */\r
- isLeaf : function(){\r
- return this.leaf === true;\r
- },\r
-\r
- // private\r
- setFirstChild : function(node){\r
- this.firstChild = node;\r
- },\r
-\r
- //private\r
- setLastChild : function(node){\r
- this.lastChild = node;\r
- },\r
-\r
-\r
- /**\r
- * Returns true if this node is the last child of its parent\r
- * @return {Boolean}\r
- */\r
- isLast : function(){\r
- return (!this.parentNode ? true : this.parentNode.lastChild == this);\r
- },\r
-\r
- /**\r
- * Returns true if this node is the first child of its parent\r
- * @return {Boolean}\r
- */\r
- isFirst : function(){\r
- return (!this.parentNode ? true : this.parentNode.firstChild == this);\r
- },\r
-\r
- /**\r
- * Returns true if this node has one or more child nodes, else false.\r
- * @return {Boolean}\r
- */\r
- hasChildNodes : function(){\r
- return !this.isLeaf() && this.childNodes.length > 0;\r
- },\r
- \r
- /**\r
- * Returns true if this node has one or more child nodes, or if the <tt>expandable</tt>\r
- * node attribute is explicitly specified as true (see {@link #attributes}), otherwise returns false.\r
- * @return {Boolean}\r
- */\r
- isExpandable : function(){\r
- return this.attributes.expandable || this.hasChildNodes();\r
- },\r
-\r
- /**\r
- * Insert node(s) as the last child node of this node.\r
- * @param {Node/Array} node The node or Array of nodes to append\r
- * @return {Node} The appended node if single append, or null if an array was passed\r
- */\r
- appendChild : function(node){\r
- var multi = false;\r
- if(Ext.isArray(node)){\r
- multi = node;\r
- }else if(arguments.length > 1){\r
- multi = arguments;\r
- }\r
- // if passed an array or multiple args do them one by one\r
- if(multi){\r
- for(var i = 0, len = multi.length; i < len; i++) {\r
- this.appendChild(multi[i]);\r
- }\r
- }else{\r
- if(this.fireEvent("beforeappend", this.ownerTree, this, node) === false){\r
- return false;\r
- }\r
- var index = this.childNodes.length;\r
- var oldParent = node.parentNode;\r
- // it's a move, make sure we move it cleanly\r
- if(oldParent){\r
- if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index) === false){\r
- return false;\r
- }\r
- oldParent.removeChild(node);\r
- }\r
- index = this.childNodes.length;\r
- if(index === 0){\r
- this.setFirstChild(node);\r
- }\r
- this.childNodes.push(node);\r
- node.parentNode = this;\r
- var ps = this.childNodes[index-1];\r
- if(ps){\r
- node.previousSibling = ps;\r
- ps.nextSibling = node;\r
- }else{\r
- node.previousSibling = null;\r
- }\r
- node.nextSibling = null;\r
- this.setLastChild(node);\r
- node.setOwnerTree(this.getOwnerTree());\r
- this.fireEvent("append", this.ownerTree, this, node, index);\r
- if(oldParent){\r
- node.fireEvent("move", this.ownerTree, node, oldParent, this, index);\r
- }\r
- return node;\r
- }\r
- },\r
-\r
- /**\r
- * Removes a child node from this node.\r
- * @param {Node} node The node to remove\r
- * @return {Node} The removed node\r
- */\r
- removeChild : function(node){\r
- var index = this.childNodes.indexOf(node);\r
- if(index == -1){\r
- return false;\r
- }\r
- if(this.fireEvent("beforeremove", this.ownerTree, this, node) === false){\r
- return false;\r
- }\r
-\r
- // remove it from childNodes collection\r
- this.childNodes.splice(index, 1);\r
-\r
- // update siblings\r
- if(node.previousSibling){\r
- node.previousSibling.nextSibling = node.nextSibling;\r
- }\r
- if(node.nextSibling){\r
- node.nextSibling.previousSibling = node.previousSibling;\r
- }\r
-\r
- // update child refs\r
- if(this.firstChild == node){\r
- this.setFirstChild(node.nextSibling);\r
- }\r
- if(this.lastChild == node){\r
- this.setLastChild(node.previousSibling);\r
- }\r
-\r
- node.setOwnerTree(null);\r
- // clear any references from the node\r
- node.parentNode = null;\r
- node.previousSibling = null;\r
- node.nextSibling = null;\r
- this.fireEvent("remove", this.ownerTree, this, node);\r
- return node;\r
- },\r
-\r
- /**\r
- * Inserts the first node before the second node in this nodes childNodes collection.\r
- * @param {Node} node The node to insert\r
- * @param {Node} refNode The node to insert before (if null the node is appended)\r
- * @return {Node} The inserted node\r
- */\r
- insertBefore : function(node, refNode){\r
- if(!refNode){ // like standard Dom, refNode can be null for append\r
- return this.appendChild(node);\r
- }\r
- // nothing to do\r
- if(node == refNode){\r
- return false;\r
- }\r
-\r
- if(this.fireEvent("beforeinsert", this.ownerTree, this, node, refNode) === false){\r
- return false;\r
- }\r
- var index = this.childNodes.indexOf(refNode);\r
- var oldParent = node.parentNode;\r
- var refIndex = index;\r
-\r
- // when moving internally, indexes will change after remove\r
- if(oldParent == this && this.childNodes.indexOf(node) < index){\r
- refIndex--;\r
- }\r
-\r
- // it's a move, make sure we move it cleanly\r
- if(oldParent){\r
- if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index, refNode) === false){\r
- return false;\r
- }\r
- oldParent.removeChild(node);\r
- }\r
- if(refIndex === 0){\r
- this.setFirstChild(node);\r
- }\r
- this.childNodes.splice(refIndex, 0, node);\r
- node.parentNode = this;\r
- var ps = this.childNodes[refIndex-1];\r
- if(ps){\r
- node.previousSibling = ps;\r
- ps.nextSibling = node;\r
- }else{\r
- node.previousSibling = null;\r
- }\r
- node.nextSibling = refNode;\r
- refNode.previousSibling = node;\r
- node.setOwnerTree(this.getOwnerTree());\r
- this.fireEvent("insert", this.ownerTree, this, node, refNode);\r
- if(oldParent){\r
- node.fireEvent("move", this.ownerTree, node, oldParent, this, refIndex, refNode);\r
- }\r
- return node;\r
- },\r
-\r
- /**\r
- * Removes this node from its parent\r
- * @return {Node} this\r
- */\r
- remove : function(){\r
- this.parentNode.removeChild(this);\r
- return this;\r
- },\r
-\r
- /**\r
- * Returns the child node at the specified index.\r
- * @param {Number} index\r
- * @return {Node}\r
- */\r
- item : function(index){\r
- return this.childNodes[index];\r
- },\r
-\r
- /**\r
- * Replaces one child node in this node with another.\r
- * @param {Node} newChild The replacement node\r
- * @param {Node} oldChild The node to replace\r
- * @return {Node} The replaced node\r
- */\r
- replaceChild : function(newChild, oldChild){\r
- var s = oldChild ? oldChild.nextSibling : null;\r
- this.removeChild(oldChild);\r
- this.insertBefore(newChild, s);\r
- return oldChild;\r
- },\r
-\r
- /**\r
- * Returns the index of a child node\r
- * @param {Node} node\r
- * @return {Number} The index of the node or -1 if it was not found\r
- */\r
- indexOf : function(child){\r
- return this.childNodes.indexOf(child);\r
- },\r
-\r
- /**\r
- * Returns the tree this node is in.\r
- * @return {Tree}\r
- */\r
- getOwnerTree : function(){\r
- // if it doesn't have one, look for one\r
- if(!this.ownerTree){\r
- var p = this;\r
- while(p){\r
- if(p.ownerTree){\r
- this.ownerTree = p.ownerTree;\r
- break;\r
- }\r
- p = p.parentNode;\r
- }\r
- }\r
- return this.ownerTree;\r
- },\r
-\r
- /**\r
- * Returns depth of this node (the root node has a depth of 0)\r
- * @return {Number}\r
- */\r
- getDepth : function(){\r
- var depth = 0;\r
- var p = this;\r
- while(p.parentNode){\r
- ++depth;\r
- p = p.parentNode;\r
- }\r
- return depth;\r
- },\r
-\r
- // private\r
- setOwnerTree : function(tree){\r
- // if it is a move, we need to update everyone\r
- if(tree != this.ownerTree){\r
- if(this.ownerTree){\r
- this.ownerTree.unregisterNode(this);\r
- }\r
- this.ownerTree = tree;\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- cs[i].setOwnerTree(tree);\r
- }\r
- if(tree){\r
- tree.registerNode(this);\r
- }\r
- }\r
- },\r
- \r
- /**\r
- * Changes the id of this node.\r
- * @param {String} id The new id for the node.\r
- */\r
- setId: function(id){\r
- if(id !== this.id){\r
- var t = this.ownerTree;\r
- if(t){\r
- t.unregisterNode(this);\r
- }\r
- this.id = id;\r
- if(t){\r
- t.registerNode(this);\r
- }\r
- this.onIdChange(id);\r
- }\r
- },\r
- \r
- // private\r
- onIdChange: Ext.emptyFn,\r
-\r
- /**\r
- * Returns the path for this node. The path can be used to expand or select this node programmatically.\r
- * @param {String} attr (optional) The attr to use for the path (defaults to the node's id)\r
- * @return {String} The path\r
- */\r
- getPath : function(attr){\r
- attr = attr || "id";\r
- var p = this.parentNode;\r
- var b = [this.attributes[attr]];\r
- while(p){\r
- b.unshift(p.attributes[attr]);\r
- p = p.parentNode;\r
- }\r
- var sep = this.getOwnerTree().pathSeparator;\r
- return sep + b.join(sep);\r
- },\r
-\r
- /**\r
- * Bubbles up the tree from this node, calling the specified function with each node. The scope (<i>this</i>) of\r
- * function call will be the scope provided or the current node. The arguments to the function\r
- * will be the args provided or the current node. If the function returns false at any point,\r
- * the bubble is stopped.\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The scope of the function (defaults to current node)\r
- * @param {Array} args (optional) The args to call the function with (default to passing the current node)\r
- */\r
- bubble : function(fn, scope, args){\r
- var p = this;\r
- while(p){\r
- if(fn.apply(scope || p, args || [p]) === false){\r
- break;\r
- }\r
- p = p.parentNode;\r
- }\r
- },\r
-\r
- /**\r
- * Cascades down the tree from this node, calling the specified function with each node. The scope (<i>this</i>) of\r
- * function call will be the scope provided or the current node. The arguments to the function\r
- * will be the args provided or the current node. If the function returns false at any point,\r
- * the cascade is stopped on that branch.\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The scope of the function (defaults to current node)\r
- * @param {Array} args (optional) The args to call the function with (default to passing the current node)\r
- */\r
- cascade : function(fn, scope, args){\r
- if(fn.apply(scope || this, args || [this]) !== false){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- cs[i].cascade(fn, scope, args);\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * Interates the child nodes of this node, calling the specified function with each node. The scope (<i>this</i>) of\r
- * function call will be the scope provided or the current node. The arguments to the function\r
- * will be the args provided or the current node. If the function returns false at any point,\r
- * the iteration stops.\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The scope of the function (defaults to current node)\r
- * @param {Array} args (optional) The args to call the function with (default to passing the current node)\r
- */\r
- eachChild : function(fn, scope, args){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- if(fn.apply(scope || this, args || [cs[i]]) === false){\r
- break;\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * Finds the first child that has the attribute with the specified value.\r
- * @param {String} attribute The attribute name\r
- * @param {Mixed} value The value to search for\r
- * @return {Node} The found child or null if none was found\r
- */\r
- findChild : function(attribute, value){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- if(cs[i].attributes[attribute] == value){\r
- return cs[i];\r
- }\r
- }\r
- return null;\r
- },\r
-\r
- /**\r
- * Finds the first child by a custom function. The child matches if the function passed\r
- * returns true.\r
- * @param {Function} fn\r
- * @param {Object} scope (optional)\r
- * @return {Node} The found child or null if none was found\r
- */\r
- findChildBy : function(fn, scope){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- if(fn.call(scope||cs[i], cs[i]) === true){\r
- return cs[i];\r
- }\r
- }\r
- return null;\r
- },\r
-\r
- /**\r
- * Sorts this nodes children using the supplied sort function\r
- * @param {Function} fn\r
- * @param {Object} scope (optional)\r
- */\r
- sort : function(fn, scope){\r
- var cs = this.childNodes;\r
- var len = cs.length;\r
- if(len > 0){\r
- var sortFn = scope ? function(){fn.apply(scope, arguments);} : fn;\r
- cs.sort(sortFn);\r
- for(var i = 0; i < len; i++){\r
- var n = cs[i];\r
- n.previousSibling = cs[i-1];\r
- n.nextSibling = cs[i+1];\r
- if(i === 0){\r
- this.setFirstChild(n);\r
- }\r
- if(i == len-1){\r
- this.setLastChild(n);\r
- }\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * Returns true if this node is an ancestor (at any point) of the passed node.\r
- * @param {Node} node\r
- * @return {Boolean}\r
- */\r
- contains : function(node){\r
- return node.isAncestor(this);\r
- },\r
-\r
- /**\r
- * Returns true if the passed node is an ancestor (at any point) of this node.\r
- * @param {Node} node\r
- * @return {Boolean}\r
- */\r
- isAncestor : function(node){\r
- var p = this.parentNode;\r
- while(p){\r
- if(p == node){\r
- return true;\r
- }\r
- p = p.parentNode;\r
- }\r
- return false;\r
- },\r
-\r
- toString : function(){\r
- return "[Node"+(this.id?" "+this.id:"")+"]";\r
- }\r
-});/**\r
- * @class Ext.tree.TreeNode\r
- * @extends Ext.data.Node\r
- * @cfg {String} text The text for this node\r
- * @cfg {Boolean} expanded true to start the node expanded\r
- * @cfg {Boolean} allowDrag False to make this node undraggable if {@link #draggable} = true (defaults to true)\r
- * @cfg {Boolean} allowDrop False if this node cannot have child nodes dropped on it (defaults to true)\r
- * @cfg {Boolean} disabled true to start the node disabled\r
- * @cfg {String} icon The path to an icon for the node. The preferred way to do this\r
- * is to use the cls or iconCls attributes and add the icon via a CSS background image.\r
- * @cfg {String} cls A css class to be added to the node\r
- * @cfg {String} iconCls A css class to be added to the nodes icon element for applying css background images\r
- * @cfg {String} href URL of the link used for the node (defaults to #)\r
- * @cfg {String} hrefTarget target frame for the link\r
- * @cfg {Boolean} hidden True to render hidden. (Defaults to false).\r
- * @cfg {String} qtip An Ext QuickTip for the node\r
- * @cfg {Boolean} expandable If set to true, the node will always show a plus/minus icon, even when empty\r
- * @cfg {String} qtipCfg An Ext QuickTip config for the node (used instead of qtip)\r
- * @cfg {Boolean} singleClickExpand True for single click expand on this node\r
- * @cfg {Function} uiProvider A UI <b>class</b> to use for this node (defaults to Ext.tree.TreeNodeUI)\r
- * @cfg {Boolean} checked True to render a checked checkbox for this node, false to render an unchecked checkbox\r
- * (defaults to undefined with no checkbox rendered)\r
- * @cfg {Boolean} draggable True to make this node draggable (defaults to false)\r
- * @cfg {Boolean} isTarget False to not allow this node to act as a drop target (defaults to true)\r
- * @cfg {Boolean} allowChildren False to not allow this node to have child nodes (defaults to true)\r
- * @cfg {Boolean} editable False to not allow this node to be edited by an (@link Ext.tree.TreeEditor} (defaults to true)\r
- * @constructor\r
- * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node\r
- */\r
-Ext.tree.TreeNode = function(attributes){\r
- attributes = attributes || {};\r
- if(typeof attributes == "string"){\r
- attributes = {text: attributes};\r
- }\r
- this.childrenRendered = false;\r
- this.rendered = false;\r
- Ext.tree.TreeNode.superclass.constructor.call(this, attributes);\r
- this.expanded = attributes.expanded === true;\r
- this.isTarget = attributes.isTarget !== false;\r
- this.draggable = attributes.draggable !== false && attributes.allowDrag !== false;\r
- this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false;\r
-\r
- /**\r
- * Read-only. The text for this node. To change it use setText().\r
- * @type String\r
- */\r
- this.text = attributes.text;\r
- /**\r
- * True if this node is disabled.\r
- * @type Boolean\r
- */\r
- this.disabled = attributes.disabled === true;\r
- /**\r
- * True if this node is hidden.\r
- * @type Boolean\r
- */\r
- this.hidden = attributes.hidden === true;\r
-\r
- this.addEvents(\r
- /**\r
- * @event textchange\r
- * Fires when the text for this node is changed\r
- * @param {Node} this This node\r
- * @param {String} text The new text\r
- * @param {String} oldText The old text\r
- */\r
- "textchange",\r
- /**\r
- * @event beforeexpand\r
- * Fires before this node is expanded, return false to cancel.\r
- * @param {Node} this This node\r
- * @param {Boolean} deep\r
- * @param {Boolean} anim\r
- */\r
- "beforeexpand",\r
- /**\r
- * @event beforecollapse\r
- * Fires before this node is collapsed, return false to cancel.\r
- * @param {Node} this This node\r
- * @param {Boolean} deep\r
- * @param {Boolean} anim\r
- */\r
- "beforecollapse",\r
- /**\r
- * @event expand\r
- * Fires when this node is expanded\r
- * @param {Node} this This node\r
- */\r
- "expand",\r
- /**\r
- * @event disabledchange\r
- * Fires when the disabled status of this node changes\r
- * @param {Node} this This node\r
- * @param {Boolean} disabled\r
- */\r
- "disabledchange",\r
- /**\r
- * @event collapse\r
- * Fires when this node is collapsed\r
- * @param {Node} this This node\r
- */\r
- "collapse",\r
- /**\r
- * @event beforeclick\r
- * Fires before click processing. Return false to cancel the default action.\r
- * @param {Node} this This node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "beforeclick",\r
- /**\r
- * @event click\r
- * Fires when this node is clicked\r
- * @param {Node} this This node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "click",\r
- /**\r
- * @event checkchange\r
- * Fires when a node with a checkbox's checked property changes\r
- * @param {Node} this This node\r
- * @param {Boolean} checked\r
- */\r
- "checkchange",\r
- /**\r
- * @event dblclick\r
- * Fires when this node is double clicked\r
- * @param {Node} this This node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "dblclick",\r
- /**\r
- * @event contextmenu\r
- * Fires when this node is right clicked\r
- * @param {Node} this This node\r
- * @param {Ext.EventObject} e The event object\r
- */\r
- "contextmenu",\r
- /**\r
- * @event beforechildrenrendered\r
- * Fires right before the child nodes for this node are rendered\r
- * @param {Node} this This node\r
- */\r
- "beforechildrenrendered"\r
- );\r
-\r
- var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;\r
-\r
- /**\r
- * Read-only. The UI for this node\r
- * @type TreeNodeUI\r
- */\r
- this.ui = new uiClass(this);\r
-};\r
-Ext.extend(Ext.tree.TreeNode, Ext.data.Node, {\r
- preventHScroll: true,\r
- /**\r
- * Returns true if this node is expanded\r
- * @return {Boolean}\r
- */\r
- isExpanded : function(){\r
- return this.expanded;\r
- },\r
-\r
-/**\r
- * Returns the UI object for this node.\r
- * @return {TreeNodeUI} The object which is providing the user interface for this tree\r
- * node. Unless otherwise specified in the {@link #uiProvider}, this will be an instance\r
- * of {@link Ext.tree.TreeNodeUI}\r
- */\r
- getUI : function(){\r
- return this.ui;\r
- },\r
-\r
- getLoader : function(){\r
- var owner;\r
- return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : new Ext.tree.TreeLoader());\r
- },\r
-\r
- // private override\r
- setFirstChild : function(node){\r
- var of = this.firstChild;\r
- Ext.tree.TreeNode.superclass.setFirstChild.call(this, node);\r
- if(this.childrenRendered && of && node != of){\r
- of.renderIndent(true, true);\r
- }\r
- if(this.rendered){\r
- this.renderIndent(true, true);\r
- }\r
- },\r
-\r
- // private override\r
- setLastChild : function(node){\r
- var ol = this.lastChild;\r
- Ext.tree.TreeNode.superclass.setLastChild.call(this, node);\r
- if(this.childrenRendered && ol && node != ol){\r
- ol.renderIndent(true, true);\r
- }\r
- if(this.rendered){\r
- this.renderIndent(true, true);\r
- }\r
- },\r
-\r
- // these methods are overridden to provide lazy rendering support\r
- // private override\r
- appendChild : function(n){\r
- if(!n.render && !Ext.isArray(n)){\r
- n = this.getLoader().createNode(n);\r
- }\r
- var node = Ext.tree.TreeNode.superclass.appendChild.call(this, n);\r
- if(node && this.childrenRendered){\r
- node.render();\r
- }\r
- this.ui.updateExpandIcon();\r
- return node;\r
- },\r
-\r
- // private override\r
- removeChild : function(node){\r
- this.ownerTree.getSelectionModel().unselect(node);\r
- Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);\r
- // if it's been rendered remove dom node\r
- if(this.childrenRendered){\r
- node.ui.remove();\r
- }\r
- if(this.childNodes.length < 1){\r
- this.collapse(false, false);\r
- }else{\r
- this.ui.updateExpandIcon();\r
- }\r
- if(!this.firstChild && !this.isHiddenRoot()) {\r
- this.childrenRendered = false;\r
- }\r
- return node;\r
- },\r
-\r
- // private override\r
- insertBefore : function(node, refNode){\r
- if(!node.render){ \r
- node = this.getLoader().createNode(node);\r
- }\r
- var newNode = Ext.tree.TreeNode.superclass.insertBefore.call(this, node, refNode);\r
- if(newNode && refNode && this.childrenRendered){\r
- node.render();\r
- }\r
- this.ui.updateExpandIcon();\r
- return newNode;\r
- },\r
-\r
- /**\r
- * Sets the text for this node\r
- * @param {String} text\r
- */\r
- setText : function(text){\r
- var oldText = this.text;\r
- this.text = text;\r
- this.attributes.text = text;\r
- if(this.rendered){ // event without subscribing\r
- this.ui.onTextChange(this, text, oldText);\r
- }\r
- this.fireEvent("textchange", this, text, oldText);\r
- },\r
-\r
- /**\r
- * Triggers selection of this node\r
- */\r
- select : function(){\r
- this.getOwnerTree().getSelectionModel().select(this);\r
- },\r
-\r
- /**\r
- * Triggers deselection of this node\r
- */\r
- unselect : function(){\r
- this.getOwnerTree().getSelectionModel().unselect(this);\r
- },\r
-\r
- /**\r
- * Returns true if this node is selected\r
- * @return {Boolean}\r
- */\r
- isSelected : function(){\r
- return this.getOwnerTree().getSelectionModel().isSelected(this);\r
- },\r
-\r
- /**\r
- * Expand this node.\r
- * @param {Boolean} deep (optional) True to expand all children as well\r
- * @param {Boolean} anim (optional) false to cancel the default animation\r
- * @param {Function} callback (optional) A callback to be called when\r
- * expanding this node completes (does not wait for deep expand to complete).\r
- * Called with 1 parameter, this node.\r
- * @param {Object} scope (optional) The scope in which to execute the callback.\r
- */\r
- expand : function(deep, anim, callback, scope){\r
- if(!this.expanded){\r
- if(this.fireEvent("beforeexpand", this, deep, anim) === false){\r
- return;\r
- }\r
- if(!this.childrenRendered){\r
- this.renderChildren();\r
- }\r
- this.expanded = true;\r
- if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){\r
- this.ui.animExpand(function(){\r
- this.fireEvent("expand", this);\r
- this.runCallback(callback, scope || this, [this]);\r
- if(deep === true){\r
- this.expandChildNodes(true);\r
- }\r
- }.createDelegate(this));\r
- return;\r
- }else{\r
- this.ui.expand();\r
- this.fireEvent("expand", this);\r
- this.runCallback(callback, scope || this, [this]);\r
- }\r
- }else{\r
- this.runCallback(callback, scope || this, [this]);\r
- }\r
- if(deep === true){\r
- this.expandChildNodes(true);\r
- }\r
- },\r
- \r
- runCallback: function(cb, scope, args){\r
- if(Ext.isFunction(cb)){\r
- cb.apply(scope, args);\r
- }\r
- },\r
-\r
- isHiddenRoot : function(){\r
- return this.isRoot && !this.getOwnerTree().rootVisible;\r
- },\r
-\r
- /**\r
- * Collapse this node.\r
- * @param {Boolean} deep (optional) True to collapse all children as well\r
- * @param {Boolean} anim (optional) false to cancel the default animation\r
- * @param {Function} callback (optional) A callback to be called when\r
- * expanding this node completes (does not wait for deep expand to complete).\r
- * Called with 1 parameter, this node.\r
- * @param {Object} scope (optional) The scope in which to execute the callback.\r
- */\r
- collapse : function(deep, anim, callback, scope){\r
- if(this.expanded && !this.isHiddenRoot()){\r
- if(this.fireEvent("beforecollapse", this, deep, anim) === false){\r
- return;\r
- }\r
- this.expanded = false;\r
- if((this.getOwnerTree().animate && anim !== false) || anim){\r
- this.ui.animCollapse(function(){\r
- this.fireEvent("collapse", this);\r
- this.runCallback(callback, scope || this, [this]);\r
- if(deep === true){\r
- this.collapseChildNodes(true);\r
- }\r
- }.createDelegate(this));\r
- return;\r
- }else{\r
- this.ui.collapse();\r
- this.fireEvent("collapse", this);\r
- this.runCallback(callback, scope || this, [this]);\r
- }\r
- }else if(!this.expanded){\r
- this.runCallback(callback, scope || this, [this]);\r
- }\r
- if(deep === true){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- cs[i].collapse(true, false);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- delayedExpand : function(delay){\r
- if(!this.expandProcId){\r
- this.expandProcId = this.expand.defer(delay, this);\r
- }\r
- },\r
-\r
- // private\r
- cancelExpand : function(){\r
- if(this.expandProcId){\r
- clearTimeout(this.expandProcId);\r
- }\r
- this.expandProcId = false;\r
- },\r
-\r
- /**\r
- * Toggles expanded/collapsed state of the node\r
- */\r
- toggle : function(){\r
- if(this.expanded){\r
- this.collapse();\r
- }else{\r
- this.expand();\r
- }\r
- },\r
-\r
- /**\r
- * Ensures all parent nodes are expanded, and if necessary, scrolls\r
- * the node into view.\r
- * @param {Function} callback (optional) A function to call when the node has been made visible.\r
- * @param {Object} scope (optional) The scope in which to execute the callback.\r
- */\r
- ensureVisible : function(callback, scope){\r
- var tree = this.getOwnerTree();\r
- tree.expandPath(this.parentNode ? this.parentNode.getPath() : this.getPath(), false, function(){\r
- var node = tree.getNodeById(this.id); // Somehow if we don't do this, we lose changes that happened to node in the meantime\r
- tree.getTreeEl().scrollChildIntoView(node.ui.anchor);\r
- this.runCallback(callback, scope || this, [this]);\r
- }.createDelegate(this));\r
- },\r
-\r
- /**\r
- * Expand all child nodes\r
- * @param {Boolean} deep (optional) true if the child nodes should also expand their child nodes\r
- */\r
- expandChildNodes : function(deep){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- cs[i].expand(deep);\r
- }\r
- },\r
-\r
- /**\r
- * Collapse all child nodes\r
- * @param {Boolean} deep (optional) true if the child nodes should also collapse their child nodes\r
- */\r
- collapseChildNodes : function(deep){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++) {\r
- cs[i].collapse(deep);\r
- }\r
- },\r
-\r
- /**\r
- * Disables this node\r
- */\r
- disable : function(){\r
- this.disabled = true;\r
- this.unselect();\r
- if(this.rendered && this.ui.onDisableChange){ // event without subscribing\r
- this.ui.onDisableChange(this, true);\r
- }\r
- this.fireEvent("disabledchange", this, true);\r
- },\r
-\r
- /**\r
- * Enables this node\r
- */\r
- enable : function(){\r
- this.disabled = false;\r
- if(this.rendered && this.ui.onDisableChange){ // event without subscribing\r
- this.ui.onDisableChange(this, false);\r
- }\r
- this.fireEvent("disabledchange", this, false);\r
- },\r
-\r
- // private\r
- renderChildren : function(suppressEvent){\r
- if(suppressEvent !== false){\r
- this.fireEvent("beforechildrenrendered", this);\r
- }\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++){\r
- cs[i].render(true);\r
- }\r
- this.childrenRendered = true;\r
- },\r
-\r
- // private\r
- sort : function(fn, scope){\r
- Ext.tree.TreeNode.superclass.sort.apply(this, arguments);\r
- if(this.childrenRendered){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++){\r
- cs[i].render(true);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- render : function(bulkRender){\r
- this.ui.render(bulkRender);\r
- if(!this.rendered){\r
- // make sure it is registered\r
- this.getOwnerTree().registerNode(this);\r
- this.rendered = true;\r
- if(this.expanded){\r
- this.expanded = false;\r
- this.expand(false, false);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- renderIndent : function(deep, refresh){\r
- if(refresh){\r
- this.ui.childIndent = null;\r
- }\r
- this.ui.renderIndent();\r
- if(deep === true && this.childrenRendered){\r
- var cs = this.childNodes;\r
- for(var i = 0, len = cs.length; i < len; i++){\r
- cs[i].renderIndent(true, refresh);\r
- }\r
- }\r
- },\r
-\r
- beginUpdate : function(){\r
- this.childrenRendered = false;\r
- },\r
-\r
- endUpdate : function(){\r
- if(this.expanded && this.rendered){\r
- this.renderChildren();\r
- }\r
- },\r
-\r
- destroy : function(){\r
- if(this.childNodes){\r
- for(var i = 0,l = this.childNodes.length; i < l; i++){\r
- this.childNodes[i].destroy();\r
- }\r
- this.childNodes = null;\r
- }\r
- if(this.ui.destroy){\r
- this.ui.destroy();\r
- }\r
- },\r
- \r
- // private\r
- onIdChange: function(id){\r
- this.ui.onIdChange(id);\r
- }\r
-});\r
-\r
-Ext.tree.TreePanel.nodeTypes.node = Ext.tree.TreeNode;/**\r
- * @class Ext.tree.AsyncTreeNode\r
- * @extends Ext.tree.TreeNode\r
- * @cfg {TreeLoader} loader A TreeLoader to be used by this node (defaults to the loader defined on the tree)\r
- * @constructor\r
- * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node \r
- */\r
- Ext.tree.AsyncTreeNode = function(config){\r
- this.loaded = config && config.loaded === true;\r
- this.loading = false;\r
- Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);\r
- /**\r
- * @event beforeload\r
- * Fires before this node is loaded, return false to cancel\r
- * @param {Node} this This node\r
- */\r
- this.addEvents('beforeload', 'load');\r
- /**\r
- * @event load\r
- * Fires when this node is loaded\r
- * @param {Node} this This node\r
- */\r
- /**\r
- * The loader used by this node (defaults to using the tree's defined loader)\r
- * @type TreeLoader\r
- * @property loader\r
- */\r
-};\r
-Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {\r
- expand : function(deep, anim, callback, scope){\r
- if(this.loading){ // if an async load is already running, waiting til it's done\r
- var timer;\r
- var f = function(){\r
- if(!this.loading){ // done loading\r
- clearInterval(timer);\r
- this.expand(deep, anim, callback, scope);\r
- }\r
- }.createDelegate(this);\r
- timer = setInterval(f, 200);\r
- return;\r
- }\r
- if(!this.loaded){\r
- if(this.fireEvent("beforeload", this) === false){\r
- return;\r
- }\r
- this.loading = true;\r
- this.ui.beforeLoad(this);\r
- var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();\r
- if(loader){\r
- loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback, scope]), this);\r
- return;\r
- }\r
- }\r
- Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);\r
- },\r
- \r
- /**\r
- * Returns true if this node is currently loading\r
- * @return {Boolean}\r
- */\r
- isLoading : function(){\r
- return this.loading; \r
- },\r
- \r
- loadComplete : function(deep, anim, callback, scope){\r
- this.loading = false;\r
- this.loaded = true;\r
- this.ui.afterLoad(this);\r
- this.fireEvent("load", this);\r
- this.expand(deep, anim, callback, scope);\r
- },\r
- \r
- /**\r
- * Returns true if this node has been loaded\r
- * @return {Boolean}\r
- */\r
- isLoaded : function(){\r
- return this.loaded;\r
- },\r
- \r
- hasChildNodes : function(){\r
- if(!this.isLeaf() && !this.loaded){\r
- return true;\r
- }else{\r
- return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);\r
- }\r
- },\r
-\r
- /**\r
- * Trigger a reload for this node\r
- * @param {Function} callback\r
- * @param {Object} scope (optional) The scope in which to execute the callback.\r
- */\r
- reload : function(callback, scope){\r
- this.collapse(false, false);\r
- while(this.firstChild){\r
- this.removeChild(this.firstChild).destroy();\r
- }\r
- this.childrenRendered = false;\r
- this.loaded = false;\r
- if(this.isHiddenRoot()){\r
- this.expanded = false;\r
- }\r
- this.expand(false, false, callback, scope);\r
- }\r
-});\r
-\r
-Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;/**\r
- * @class Ext.tree.TreeNodeUI\r
- * This class provides the default UI implementation for Ext TreeNodes.\r
- * The TreeNode UI implementation is separate from the\r
- * tree implementation, and allows customizing of the appearance of\r
- * tree nodes.<br>\r
- * <p>\r
- * If you are customizing the Tree's user interface, you\r
- * may need to extend this class, but you should never need to instantiate this class.<br>\r
- * <p>\r
- * This class provides access to the user interface components of an Ext TreeNode, through\r
- * {@link Ext.tree.TreeNode#getUI}\r
- */\r
-Ext.tree.TreeNodeUI = function(node){\r
- this.node = node;\r
- this.rendered = false;\r
- this.animating = false;\r
- this.wasLeaf = true;\r
- this.ecc = 'x-tree-ec-icon x-tree-elbow';\r
- this.emptyIcon = Ext.BLANK_IMAGE_URL;\r
-};\r
-\r
-Ext.tree.TreeNodeUI.prototype = {\r
- // private\r
- removeChild : function(node){\r
- if(this.rendered){\r
- this.ctNode.removeChild(node.ui.getEl());\r
- } \r
- },\r
-\r
- // private\r
- beforeLoad : function(){\r
- this.addClass("x-tree-node-loading");\r
- },\r
-\r
- // private\r
- afterLoad : function(){\r
- this.removeClass("x-tree-node-loading");\r
- },\r
-\r
- // private\r
- onTextChange : function(node, text, oldText){\r
- if(this.rendered){\r
- this.textNode.innerHTML = text;\r
- }\r
- },\r
-\r
- // private\r
- onDisableChange : function(node, state){\r
- this.disabled = state;\r
- if (this.checkbox) {\r
- this.checkbox.disabled = state;\r
- } \r
- if(state){\r
- this.addClass("x-tree-node-disabled");\r
- }else{\r
- this.removeClass("x-tree-node-disabled");\r
- } \r
- },\r
-\r
- // private\r
- onSelectedChange : function(state){\r
- if(state){\r
- this.focus();\r
- this.addClass("x-tree-selected");\r
- }else{\r
- //this.blur();\r
- this.removeClass("x-tree-selected");\r
- }\r
- },\r
-\r
- // private\r
- onMove : function(tree, node, oldParent, newParent, index, refNode){\r
- this.childIndent = null;\r
- if(this.rendered){\r
- var targetNode = newParent.ui.getContainer();\r
- if(!targetNode){//target not rendered\r
- this.holder = document.createElement("div");\r
- this.holder.appendChild(this.wrap);\r
- return;\r
- }\r
- var insertBefore = refNode ? refNode.ui.getEl() : null;\r
- if(insertBefore){\r
- targetNode.insertBefore(this.wrap, insertBefore);\r
- }else{\r
- targetNode.appendChild(this.wrap);\r
- }\r
- this.node.renderIndent(true, oldParent != newParent);\r
- }\r
- },\r
-\r
-/**\r
- * Adds one or more CSS classes to the node's UI element.\r
- * Duplicate classes are automatically filtered out.\r
- * @param {String/Array} className The CSS class to add, or an array of classes\r
- */\r
- addClass : function(cls){\r
- if(this.elNode){\r
- Ext.fly(this.elNode).addClass(cls);\r
- }\r
- },\r
-\r
-/**\r
- * Removes one or more CSS classes from the node's UI element.\r
- * @param {String/Array} className The CSS class to remove, or an array of classes\r
- */\r
- removeClass : function(cls){\r
- if(this.elNode){\r
- Ext.fly(this.elNode).removeClass(cls); \r
- }\r
- },\r
-\r
- // private\r
- remove : function(){\r
- if(this.rendered){\r
- this.holder = document.createElement("div");\r
- this.holder.appendChild(this.wrap);\r
- } \r
- },\r
-\r
- // private\r
- fireEvent : function(){\r
- return this.node.fireEvent.apply(this.node, arguments); \r
- },\r
-\r
- // private\r
- initEvents : function(){\r
- this.node.on("move", this.onMove, this);\r
-\r
- if(this.node.disabled){\r
- this.addClass("x-tree-node-disabled");\r
- if (this.checkbox) {\r
- this.checkbox.disabled = true;\r
- } \r
- }\r
- if(this.node.hidden){\r
- this.hide();\r
- }\r
- var ot = this.node.getOwnerTree();\r
- var dd = ot.enableDD || ot.enableDrag || ot.enableDrop;\r
- if(dd && (!this.node.isRoot || ot.rootVisible)){\r
- Ext.dd.Registry.register(this.elNode, {\r
- node: this.node,\r
- handles: this.getDDHandles(),\r
- isHandle: false\r
- });\r
- }\r
- },\r
-\r
- // private\r
- getDDHandles : function(){\r
- return [this.iconNode, this.textNode, this.elNode];\r
- },\r
-\r
-/**\r
- * Hides this node.\r
- */\r
- hide : function(){\r
- this.node.hidden = true;\r
- if(this.wrap){\r
- this.wrap.style.display = "none";\r
- }\r
- },\r
-\r
-/**\r
- * Shows this node.\r
- */\r
- show : function(){\r
- this.node.hidden = false;\r
- if(this.wrap){\r
- this.wrap.style.display = "";\r
- } \r
- },\r
-\r
- // private\r
- onContextMenu : function(e){\r
- if (this.node.hasListener("contextmenu") || this.node.getOwnerTree().hasListener("contextmenu")) {\r
- e.preventDefault();\r
- this.focus();\r
- this.fireEvent("contextmenu", this.node, e);\r
- }\r
- },\r
-\r
- // private\r
- onClick : function(e){\r
- if(this.dropping){\r
- e.stopEvent();\r
- return;\r
- }\r
- if(this.fireEvent("beforeclick", this.node, e) !== false){\r
- var a = e.getTarget('a');\r
- if(!this.disabled && this.node.attributes.href && a){\r
- this.fireEvent("click", this.node, e);\r
- return;\r
- }else if(a && e.ctrlKey){\r
- e.stopEvent();\r
- }\r
- e.preventDefault();\r
- if(this.disabled){\r
- return;\r
- }\r
-\r
- if(this.node.attributes.singleClickExpand && !this.animating && this.node.isExpandable()){\r
- this.node.toggle();\r
- }\r
-\r
- this.fireEvent("click", this.node, e);\r
- }else{\r
- e.stopEvent();\r
- }\r
- },\r
-\r
- // private\r
- onDblClick : function(e){\r
- e.preventDefault();\r
- if(this.disabled){\r
- return;\r
- }\r
- if(this.checkbox){\r
- this.toggleCheck();\r
- }\r
- if(!this.animating && this.node.isExpandable()){\r
- this.node.toggle();\r
- }\r
- this.fireEvent("dblclick", this.node, e);\r
- },\r
-\r
- onOver : function(e){\r
- this.addClass('x-tree-node-over');\r
- },\r
-\r
- onOut : function(e){\r
- this.removeClass('x-tree-node-over');\r
- },\r
-\r
- // private\r
- onCheckChange : function(){\r
- var checked = this.checkbox.checked;\r
- // fix for IE6\r
- this.checkbox.defaultChecked = checked; \r
- this.node.attributes.checked = checked;\r
- this.fireEvent('checkchange', this.node, checked);\r
- },\r
-\r
- // private\r
- ecClick : function(e){\r
- if(!this.animating && this.node.isExpandable()){\r
- this.node.toggle();\r
- }\r
- },\r
-\r
- // private\r
- startDrop : function(){\r
- this.dropping = true;\r
- },\r
- \r
- // delayed drop so the click event doesn't get fired on a drop\r
- endDrop : function(){ \r
- setTimeout(function(){\r
- this.dropping = false;\r
- }.createDelegate(this), 50); \r
- },\r
-\r
- // private\r
- expand : function(){\r
- this.updateExpandIcon();\r
- this.ctNode.style.display = "";\r
- },\r
-\r
- // private\r
- focus : function(){\r
- if(!this.node.preventHScroll){\r
- try{this.anchor.focus();\r
- }catch(e){}\r
- }else{\r
- try{\r
- var noscroll = this.node.getOwnerTree().getTreeEl().dom;\r
- var l = noscroll.scrollLeft;\r
- this.anchor.focus();\r
- noscroll.scrollLeft = l;\r
- }catch(e){}\r
- }\r
- },\r
-\r
-/**\r
- * Sets the checked status of the tree node to the passed value, or, if no value was passed,\r
- * toggles the checked status. If the node was rendered with no checkbox, this has no effect.\r
- * @param {Boolean} (optional) The new checked status.\r
- */\r
- toggleCheck : function(value){\r
- var cb = this.checkbox;\r
- if(cb){\r
- cb.checked = (value === undefined ? !cb.checked : value);\r
- this.onCheckChange();\r
- }\r
- },\r
-\r
- // private\r
- blur : function(){\r
- try{\r
- this.anchor.blur();\r
- }catch(e){} \r
- },\r
-\r
- // private\r
- animExpand : function(callback){\r
- var ct = Ext.get(this.ctNode);\r
- ct.stopFx();\r
- if(!this.node.isExpandable()){\r
- this.updateExpandIcon();\r
- this.ctNode.style.display = "";\r
- Ext.callback(callback);\r
- return;\r
- }\r
- this.animating = true;\r
- this.updateExpandIcon();\r
- \r
- ct.slideIn('t', {\r
- callback : function(){\r
- this.animating = false;\r
- Ext.callback(callback);\r
- },\r
- scope: this,\r
- duration: this.node.ownerTree.duration || .25\r
- });\r
- },\r
-\r
- // private\r
- highlight : function(){\r
- var tree = this.node.getOwnerTree();\r
- Ext.fly(this.wrap).highlight(\r
- tree.hlColor || "C3DAF9",\r
- {endColor: tree.hlBaseColor}\r
- );\r
- },\r
-\r
- // private\r
- collapse : function(){\r
- this.updateExpandIcon();\r
- this.ctNode.style.display = "none";\r
- },\r
-\r
- // private\r
- animCollapse : function(callback){\r
- var ct = Ext.get(this.ctNode);\r
- ct.enableDisplayMode('block');\r
- ct.stopFx();\r
-\r
- this.animating = true;\r
- this.updateExpandIcon();\r
-\r
- ct.slideOut('t', {\r
- callback : function(){\r
- this.animating = false;\r
- Ext.callback(callback);\r
- },\r
- scope: this,\r
- duration: this.node.ownerTree.duration || .25\r
- });\r
- },\r
-\r
- // private\r
- getContainer : function(){\r
- return this.ctNode; \r
- },\r
-\r
- // private\r
- getEl : function(){\r
- return this.wrap; \r
- },\r
-\r
- // private\r
- appendDDGhost : function(ghostNode){\r
- ghostNode.appendChild(this.elNode.cloneNode(true));\r
- },\r
-\r
- // private\r
- getDDRepairXY : function(){\r
- return Ext.lib.Dom.getXY(this.iconNode);\r
- },\r
-\r
- // private\r
- onRender : function(){\r
- this.render(); \r
- },\r
-\r
- // private\r
- render : function(bulkRender){\r
- var n = this.node, a = n.attributes;\r
- var targetNode = n.parentNode ? \r
- n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;\r
- \r
- if(!this.rendered){\r
- this.rendered = true;\r
-\r
- this.renderElements(n, a, targetNode, bulkRender);\r
-\r
- if(a.qtip){\r
- if(this.textNode.setAttributeNS){\r
- this.textNode.setAttributeNS("ext", "qtip", a.qtip);\r
- if(a.qtipTitle){\r
- this.textNode.setAttributeNS("ext", "qtitle", a.qtipTitle);\r
- }\r
- }else{\r
- this.textNode.setAttribute("ext:qtip", a.qtip);\r
- if(a.qtipTitle){\r
- this.textNode.setAttribute("ext:qtitle", a.qtipTitle);\r
- }\r
- } \r
- }else if(a.qtipCfg){\r
- a.qtipCfg.target = Ext.id(this.textNode);\r
- Ext.QuickTips.register(a.qtipCfg);\r
- }\r
- this.initEvents();\r
- if(!this.node.expanded){\r
- this.updateExpandIcon(true);\r
- }\r
- }else{\r
- if(bulkRender === true) {\r
- targetNode.appendChild(this.wrap);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- renderElements : function(n, a, targetNode, bulkRender){\r
- // add some indent caching, this helps performance when rendering a large tree\r
- this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';\r
-\r
- var cb = typeof a.checked == 'boolean';\r
-\r
- var href = a.href ? a.href : Ext.isGecko ? "" : "#";\r
- var buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',\r
- '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",\r
- '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',\r
- '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',\r
- cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',\r
- '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',\r
- a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",\r
- '<ul class="x-tree-node-ct" style="display:none;"></ul>',\r
- "</li>"].join('');\r
-\r
- var nel;\r
- if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){\r
- this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);\r
- }else{\r
- this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);\r
- }\r
- \r
- this.elNode = this.wrap.childNodes[0];\r
- this.ctNode = this.wrap.childNodes[1];\r
- var cs = this.elNode.childNodes;\r
- this.indentNode = cs[0];\r
- this.ecNode = cs[1];\r
- this.iconNode = cs[2];\r
- var index = 3;\r
- if(cb){\r
- this.checkbox = cs[3];\r
- // fix for IE6\r
- this.checkbox.defaultChecked = this.checkbox.checked; \r
- index++;\r
- }\r
- this.anchor = cs[index];\r
- this.textNode = cs[index].firstChild;\r
- },\r
-\r
-/**\r
- * Returns the <a> element that provides focus for the node's UI.\r
- * @return {HtmlElement} The DOM anchor element.\r
- */\r
- getAnchor : function(){\r
- return this.anchor;\r
- },\r
- \r
-/**\r
- * Returns the text node.\r
- * @return {HtmlNode} The DOM text node.\r
- */\r
- getTextEl : function(){\r
- return this.textNode;\r
- },\r
- \r
-/**\r
- * Returns the icon <img> element.\r
- * @return {HtmlElement} The DOM image element.\r
- */\r
- getIconEl : function(){\r
- return this.iconNode;\r
- },\r
-\r
-/**\r
- * Returns the checked status of the node. If the node was rendered with no\r
- * checkbox, it returns false.\r
- * @return {Boolean} The checked flag.\r
- */\r
- isChecked : function(){\r
- return this.checkbox ? this.checkbox.checked : false; \r
- },\r
-\r
- // private\r
- updateExpandIcon : function(){\r
- if(this.rendered){\r
- var n = this.node, c1, c2;\r
- var cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow";\r
- var hasChild = n.hasChildNodes();\r
- if(hasChild || n.attributes.expandable){\r
- if(n.expanded){\r
- cls += "-minus";\r
- c1 = "x-tree-node-collapsed";\r
- c2 = "x-tree-node-expanded";\r
- }else{\r
- cls += "-plus";\r
- c1 = "x-tree-node-expanded";\r
- c2 = "x-tree-node-collapsed";\r
- }\r
- if(this.wasLeaf){\r
- this.removeClass("x-tree-node-leaf");\r
- this.wasLeaf = false;\r
- }\r
- if(this.c1 != c1 || this.c2 != c2){\r
- Ext.fly(this.elNode).replaceClass(c1, c2);\r
- this.c1 = c1; this.c2 = c2;\r
- }\r
- }else{\r
- if(!this.wasLeaf){\r
- Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf");\r
- delete this.c1;\r
- delete this.c2;\r
- this.wasLeaf = true;\r
- }\r
- }\r
- var ecc = "x-tree-ec-icon "+cls;\r
- if(this.ecc != ecc){\r
- this.ecNode.className = ecc;\r
- this.ecc = ecc;\r
- }\r
- }\r
- },\r
- \r
- // private\r
- onIdChange: function(id){\r
- if(this.rendered){\r
- this.elNode.setAttribute('ext:tree-node-id', id);\r
- }\r
- },\r
-\r
- // private\r
- getChildIndent : function(){\r
- if(!this.childIndent){\r
- var buf = [];\r
- var p = this.node;\r
- while(p){\r
- if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){\r
- if(!p.isLast()) {\r
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');\r
- } else {\r
- buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');\r
- }\r
- }\r
- p = p.parentNode;\r
- }\r
- this.childIndent = buf.join("");\r
- }\r
- return this.childIndent;\r
- },\r
-\r
- // private\r
- renderIndent : function(){\r
- if(this.rendered){\r
- var indent = "";\r
- var p = this.node.parentNode;\r
- if(p){\r
- indent = p.ui.getChildIndent();\r
- }\r
- if(this.indentMarkup != indent){ // don't rerender if not required\r
- this.indentNode.innerHTML = indent;\r
- this.indentMarkup = indent;\r
- }\r
- this.updateExpandIcon();\r
- }\r
- },\r
-\r
- destroy : function(){\r
- if(this.elNode){\r
- Ext.dd.Registry.unregister(this.elNode.id);\r
- }\r
- delete this.elNode;\r
- delete this.ctNode;\r
- delete this.indentNode;\r
- delete this.ecNode;\r
- delete this.iconNode;\r
- delete this.checkbox;\r
- delete this.anchor;\r
- delete this.textNode;\r
- \r
- if (this.holder){\r
- delete this.wrap;\r
- Ext.removeNode(this.holder);\r
- delete this.holder;\r
- }else{\r
- Ext.removeNode(this.wrap);\r
- delete this.wrap;\r
- }\r
- }\r
-};\r
-\r
-/**\r
- * @class Ext.tree.RootTreeNodeUI\r
- * This class provides the default UI implementation for <b>root</b> Ext TreeNodes.\r
- * The RootTreeNode UI implementation allows customizing the appearance of the root tree node.<br>\r
- * <p>\r
- * If you are customizing the Tree's user interface, you\r
- * may need to extend this class, but you should never need to instantiate this class.<br>\r
- */\r
-Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {\r
- // private\r
- render : function(){\r
- if(!this.rendered){\r
- var targetNode = this.node.ownerTree.innerCt.dom;\r
- this.node.expanded = true;\r
- targetNode.innerHTML = '<div class="x-tree-root-node"></div>';\r
- this.wrap = this.ctNode = targetNode.firstChild;\r
- }\r
- },\r
- collapse : Ext.emptyFn,\r
- expand : Ext.emptyFn\r
-});/**\r
- * @class Ext.tree.TreeLoader\r
- * @extends Ext.util.Observable\r
- * A TreeLoader provides for lazy loading of an {@link Ext.tree.TreeNode}'s child\r
- * nodes from a specified URL. The response must be a JavaScript Array definition\r
- * whose elements are node definition objects. e.g.:\r
- * <pre><code>\r
- [{\r
- id: 1,\r
- text: 'A leaf Node',\r
- leaf: true\r
- },{\r
- id: 2,\r
- text: 'A folder Node',\r
- children: [{\r
- id: 3,\r
- text: 'A child Node',\r
- leaf: true\r
- }]\r
- }]\r
-</code></pre>\r
- * <br><br>\r
- * A server request is sent, and child nodes are loaded only when a node is expanded.\r
- * The loading node's id is passed to the server under the parameter name "node" to\r
- * enable the server to produce the correct child nodes.\r
- * <br><br>\r
- * To pass extra parameters, an event handler may be attached to the "beforeload"\r
- * event, and the parameters specified in the TreeLoader's baseParams property:\r
- * <pre><code>\r
- myTreeLoader.on("beforeload", function(treeLoader, node) {\r
- this.baseParams.category = node.attributes.category;\r
- }, this);\r
-</code></pre>\r
- * This would pass an HTTP parameter called "category" to the server containing\r
- * the value of the Node's "category" attribute.\r
- * @constructor\r
- * Creates a new Treeloader.\r
- * @param {Object} config A config object containing config properties.\r
- */\r
-Ext.tree.TreeLoader = function(config){\r
- this.baseParams = {};\r
- Ext.apply(this, config);\r
-\r
- this.addEvents(\r
- /**\r
- * @event beforeload\r
- * Fires before a network request is made to retrieve the Json text which specifies a node's children.\r
- * @param {Object} This TreeLoader object.\r
- * @param {Object} node The {@link Ext.tree.TreeNode} object being loaded.\r
- * @param {Object} callback The callback function specified in the {@link #load} call.\r
- */\r
- "beforeload",\r
- /**\r
- * @event load\r
- * Fires when the node has been successfuly loaded.\r
- * @param {Object} This TreeLoader object.\r
- * @param {Object} node The {@link Ext.tree.TreeNode} object being loaded.\r
- * @param {Object} response The response object containing the data from the server.\r
- */\r
- "load",\r
- /**\r
- * @event loadexception\r
- * Fires if the network request failed.\r
- * @param {Object} This TreeLoader object.\r
- * @param {Object} node The {@link Ext.tree.TreeNode} object being loaded.\r
- * @param {Object} response The response object containing the data from the server.\r
- */\r
- "loadexception"\r
- );\r
- Ext.tree.TreeLoader.superclass.constructor.call(this);\r
- if(typeof this.paramOrder == 'string'){\r
- this.paramOrder = this.paramOrder.split(/[\s,|]/);\r
- }\r
-};\r
-\r
-Ext.extend(Ext.tree.TreeLoader, Ext.util.Observable, {\r
- /**\r
- * @cfg {String} dataUrl The URL from which to request a Json string which\r
- * specifies an array of node definition objects representing the child nodes\r
- * to be loaded.\r
- */\r
- /**\r
- * @cfg {String} requestMethod The HTTP request method for loading data (defaults to the value of {@link Ext.Ajax#method}).\r
- */\r
- /**\r
- * @cfg {String} url Equivalent to {@link #dataUrl}.\r
- */\r
- /**\r
- * @cfg {Boolean} preloadChildren If set to true, the loader recursively loads "children" attributes when doing the first load on nodes.\r
- */\r
- /**\r
- * @cfg {Object} baseParams (optional) An object containing properties which\r
- * specify HTTP parameters to be passed to each request for child nodes.\r
- */\r
- /**\r
- * @cfg {Object} baseAttrs (optional) An object containing attributes to be added to all nodes\r
- * created by this loader. If the attributes sent by the server have an attribute in this object,\r
- * they take priority.\r
- */\r
- /**\r
- * @cfg {Object} uiProviders (optional) An object containing properties which\r
- * specify custom {@link Ext.tree.TreeNodeUI} implementations. If the optional\r
- * <i>uiProvider</i> attribute of a returned child node is a string rather\r
- * than a reference to a TreeNodeUI implementation, then that string value\r
- * is used as a property name in the uiProviders object.\r
- */\r
- uiProviders : {},\r
-\r
- /**\r
- * @cfg {Boolean} clearOnLoad (optional) Default to true. Remove previously existing\r
- * child nodes before loading.\r
- */\r
- clearOnLoad : true,\r
-\r
- /**\r
- * @cfg {Array/String} paramOrder Defaults to <tt>undefined</tt>. Only used when using directFn.\r
- * A list of params to be executed\r
- * server side. Specify the params in the order in which they must be executed on the server-side\r
- * as either (1) an Array of String values, or (2) a String of params delimited by either whitespace,\r
- * comma, or pipe. For example,\r
- * any of the following would be acceptable:<pre><code>\r
-paramOrder: ['param1','param2','param3']\r
-paramOrder: 'param1 param2 param3'\r
-paramOrder: 'param1,param2,param3'\r
-paramOrder: 'param1|param2|param'\r
- </code></pre>\r
- */\r
- paramOrder: undefined,\r
-\r
- /**\r
- * @cfg {Boolean} paramsAsHash Only used when using directFn.\r
- * Send parameters as a collection of named arguments (defaults to <tt>false</tt>). Providing a\r
- * <tt>{@link #paramOrder}</tt> nullifies this configuration.\r
- */\r
- paramsAsHash: false,\r
-\r
- /**\r
- * @cfg {Function} directFn\r
- * Function to call when executing a request.\r
- */\r
- directFn : undefined,\r
-\r
- /**\r
- * Load an {@link Ext.tree.TreeNode} from the URL specified in the constructor.\r
- * This is called automatically when a node is expanded, but may be used to reload\r
- * a node (or append new children if the {@link #clearOnLoad} option is false.)\r
- * @param {Ext.tree.TreeNode} node\r
- * @param {Function} callback\r
- * @param (Object) scope\r
- */\r
- load : function(node, callback, scope){\r
- if(this.clearOnLoad){\r
- while(node.firstChild){\r
- node.removeChild(node.firstChild);\r
- }\r
- }\r
- if(this.doPreload(node)){ // preloaded json children\r
- this.runCallback(callback, scope || node, []);\r
- }else if(this.directFn || this.dataUrl || this.url){\r
- this.requestData(node, callback, scope || node);\r
- }\r
- },\r
-\r
- doPreload : function(node){\r
- if(node.attributes.children){\r
- if(node.childNodes.length < 1){ // preloaded?\r
- var cs = node.attributes.children;\r
- node.beginUpdate();\r
- for(var i = 0, len = cs.length; i < len; i++){\r
- var cn = node.appendChild(this.createNode(cs[i]));\r
- if(this.preloadChildren){\r
- this.doPreload(cn);\r
- }\r
- }\r
- node.endUpdate();\r
- }\r
- return true;\r
- }\r
- return false;\r
- },\r
-\r
- getParams: function(node){\r
- var buf = [], bp = this.baseParams;\r
- if(this.directFn){\r
- buf.push(node.id);\r
- if(bp){\r
- if(this.paramOrder){\r
- for(var i = 0, len = this.paramOrder.length; i < len; i++){\r
- buf.push(bp[this.paramOrder[i]]);\r
- }\r
- }else if(this.paramsAsHash){\r
- buf.push(bp);\r
- }\r
- }\r
- return buf;\r
- }else{\r
- for(var key in bp){\r
- if(!Ext.isFunction(bp[key])){\r
- buf.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&");\r
- }\r
- }\r
- buf.push("node=", encodeURIComponent(node.id));\r
- return buf.join("");\r
- }\r
- },\r
-\r
- requestData : function(node, callback, scope){\r
- if(this.fireEvent("beforeload", this, node, callback) !== false){\r
- if(this.directFn){\r
- var args = this.getParams(node);\r
- args.push(this.processDirectResponse.createDelegate(this, [{callback: callback, node: node, scope: scope}], true));\r
- this.directFn.apply(window, args);\r
- }else{\r
- this.transId = Ext.Ajax.request({\r
- method:this.requestMethod,\r
- url: this.dataUrl||this.url,\r
- success: this.handleResponse,\r
- failure: this.handleFailure,\r
- scope: this,\r
- argument: {callback: callback, node: node, scope: scope},\r
- params: this.getParams(node)\r
- });\r
- }\r
- }else{\r
- // if the load is cancelled, make sure we notify\r
- // the node that we are done\r
- this.runCallback(callback, scope || node, []);\r
- }\r
- },\r
-\r
- processDirectResponse: function(result, response, args){\r
- if(response.status){\r
- this.handleResponse({\r
- responseData: Ext.isArray(result) ? result : null,\r
- responseText: result,\r
- argument: args\r
- });\r
- }else{\r
- this.handleFailure({\r
- argument: args\r
- });\r
- }\r
- },\r
-\r
- // private\r
- runCallback: function(cb, scope, args){\r
- if(Ext.isFunction(cb)){\r
- cb.apply(scope, args);\r
- }\r
- },\r
-\r
- isLoading : function(){\r
- return !!this.transId;\r
- },\r
-\r
- abort : function(){\r
- if(this.isLoading()){\r
- Ext.Ajax.abort(this.transId);\r
- }\r
- },\r
-\r
- /**\r
- * <p>Override this function for custom TreeNode node implementation, or to\r
- * modify the attributes at creation time.</p>\r
- * Example:<pre><code>\r
-new Ext.tree.TreePanel({\r
- ...\r
- new Ext.tree.TreeLoader({\r
- url: 'dataUrl',\r
- createNode: function(attr) {\r
-// Allow consolidation consignments to have\r
-// consignments dropped into them.\r
- if (attr.isConsolidation) {\r
- attr.iconCls = 'x-consol',\r
- attr.allowDrop = true;\r
- }\r
- return Ext.tree.TreeLoader.prototype.call(this, attr);\r
- }\r
- }),\r
- ...\r
-});\r
-</code></pre>\r
- * @param attr {Object} The attributes from which to create the new node.\r
- */\r
- createNode : function(attr){\r
- // apply baseAttrs, nice idea Corey!\r
- if(this.baseAttrs){\r
- Ext.applyIf(attr, this.baseAttrs);\r
- }\r
- if(this.applyLoader !== false){\r
- attr.loader = this;\r
- }\r
- if(typeof attr.uiProvider == 'string'){\r
- attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);\r
- }\r
- if(attr.nodeType){\r
- return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr);\r
- }else{\r
- return attr.leaf ?\r
- new Ext.tree.TreeNode(attr) :\r
- new Ext.tree.AsyncTreeNode(attr);\r
- }\r
- },\r
-\r
- processResponse : function(response, node, callback, scope){\r
- var json = response.responseText;\r
- try {\r
- var o = response.responseData || Ext.decode(json);\r
- node.beginUpdate();\r
- for(var i = 0, len = o.length; i < len; i++){\r
- var n = this.createNode(o[i]);\r
- if(n){\r
- node.appendChild(n);\r
- }\r
- }\r
- node.endUpdate();\r
- this.runCallback(callback, scope || node, [node]);\r
- }catch(e){\r
- this.handleFailure(response);\r
- }\r
- },\r
-\r
- handleResponse : function(response){\r
- this.transId = false;\r
- var a = response.argument;\r
- this.processResponse(response, a.node, a.callback, a.scope);\r
- this.fireEvent("load", this, a.node, response);\r
- },\r
-\r
- handleFailure : function(response){\r
- this.transId = false;\r
- var a = response.argument;\r
- this.fireEvent("loadexception", this, a.node, response);\r
- this.runCallback(a.callback, a.scope || a.node, [a.node]);\r
- }\r
-});/**
- * @class Ext.tree.TreeFilter
- * Note this class is experimental and doesn't update the indent (lines) or expand collapse icons of the nodes
- * @param {TreePanel} tree
- * @param {Object} config (optional)
- */
+
+ onBlur : function(){
+
+ if(this.allowBlur === true && this.editing && this.selectSameEditor !== true){
+ this.completeEdit();
+ }
+ },
+
+
+ onHide : function(){
+ if(this.editing){
+ this.completeEdit();
+ return;
+ }
+ this.field.blur();
+ if(this.field.collapse){
+ this.field.collapse();
+ }
+ this.el.hide();
+ if(this.hideEl !== false){
+ this.boundEl.show();
+ }
+ },
+
+
+ setValue : function(v){
+ this.field.setValue(v);
+ },
+
+
+ getValue : function(){
+ return this.field.getValue();
+ },
+
+ beforeDestroy : function(){
+ Ext.destroyMembers(this, 'field');
+
+ delete this.parentEl;
+ delete this.boundEl;
+ }
+});
+Ext.reg('editor', Ext.Editor);
+
+Ext.ColorPalette = Ext.extend(Ext.Component, {
+
+
+ itemCls : 'x-color-palette',
+
+ value : null,
+
+ clickEvent :'click',
+
+ ctype : 'Ext.ColorPalette',
+
+
+ allowReselect : false,
+
+
+ colors : [
+ '000000', '993300', '333300', '003300', '003366', '000080', '333399', '333333',
+ '800000', 'FF6600', '808000', '008000', '008080', '0000FF', '666699', '808080',
+ 'FF0000', 'FF9900', '99CC00', '339966', '33CCCC', '3366FF', '800080', '969696',
+ 'FF00FF', 'FFCC00', 'FFFF00', '00FF00', '00FFFF', '00CCFF', '993366', 'C0C0C0',
+ 'FF99CC', 'FFCC99', 'FFFF99', 'CCFFCC', 'CCFFFF', '99CCFF', 'CC99FF', 'FFFFFF'
+ ],
+
+
+
+
+
+ initComponent : function(){
+ Ext.ColorPalette.superclass.initComponent.call(this);
+ this.addEvents(
+
+ 'select'
+ );
+
+ if(this.handler){
+ this.on('select', this.handler, this.scope, true);
+ }
+ },
+
+
+ onRender : function(container, position){
+ this.autoEl = {
+ tag: 'div',
+ cls: this.itemCls
+ };
+ Ext.ColorPalette.superclass.onRender.call(this, container, position);
+ var t = this.tpl || new Ext.XTemplate(
+ '<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on"> </span></em></a></tpl>'
+ );
+ t.overwrite(this.el, this.colors);
+ this.mon(this.el, this.clickEvent, this.handleClick, this, {delegate: 'a'});
+ if(this.clickEvent != 'click'){
+ this.mon(this.el, 'click', Ext.emptyFn, this, {delegate: 'a', preventDefault: true});
+ }
+ },
+
+
+ afterRender : function(){
+ Ext.ColorPalette.superclass.afterRender.call(this);
+ if(this.value){
+ var s = this.value;
+ this.value = null;
+ this.select(s, true);
+ }
+ },
+
+
+ handleClick : function(e, t){
+ e.preventDefault();
+ if(!this.disabled){
+ var c = t.className.match(/(?:^|\s)color-(.{6})(?:\s|$)/)[1];
+ this.select(c.toUpperCase());
+ }
+ },
+
+
+ select : function(color, suppressEvent){
+ color = color.replace('#', '');
+ if(color != this.value || this.allowReselect){
+ var el = this.el;
+ if(this.value){
+ el.child('a.color-'+this.value).removeClass('x-color-palette-sel');
+ }
+ el.child('a.color-'+color).addClass('x-color-palette-sel');
+ this.value = color;
+ if(suppressEvent !== true){
+ this.fireEvent('select', this, color);
+ }
+ }
+ }
+
+
+});
+Ext.reg('colorpalette', Ext.ColorPalette);
+Ext.DatePicker = Ext.extend(Ext.BoxComponent, {
+
+ todayText : 'Today',
+
+ okText : ' OK ',
+
+ cancelText : 'Cancel',
+
+
+
+ todayTip : '{0} (Spacebar)',
+
+ minText : 'This date is before the minimum date',
+
+ maxText : 'This date is after the maximum date',
+
+ format : 'm/d/y',
+
+ disabledDaysText : 'Disabled',
+
+ disabledDatesText : 'Disabled',
+
+ monthNames : Date.monthNames,
+
+ dayNames : Date.dayNames,
+
+ nextText : 'Next Month (Control+Right)',
+
+ prevText : 'Previous Month (Control+Left)',
+
+ monthYearText : 'Choose a month (Control+Up/Down to move years)',
+
+ startDay : 0,
+
+ showToday : true,
+
+
+
+
+
+
+
+
+ focusOnSelect: true,
+
+
+
+ initHour: 12,
+
+
+ initComponent : function(){
+ Ext.DatePicker.superclass.initComponent.call(this);
+
+ this.value = this.value ?
+ this.value.clearTime(true) : new Date().clearTime();
+
+ this.addEvents(
+
+ 'select'
+ );
+
+ if(this.handler){
+ this.on('select', this.handler, this.scope || this);
+ }
+
+ this.initDisabledDays();
+ },
+
+
+ initDisabledDays : function(){
+ if(!this.disabledDatesRE && this.disabledDates){
+ var dd = this.disabledDates,
+ len = dd.length - 1,
+ re = '(?:';
+
+ Ext.each(dd, function(d, i){
+ re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
+ if(i != len){
+ re += '|';
+ }
+ }, this);
+ this.disabledDatesRE = new RegExp(re + ')');
+ }
+ },
+
+
+ setDisabledDates : function(dd){
+ if(Ext.isArray(dd)){
+ this.disabledDates = dd;
+ this.disabledDatesRE = null;
+ }else{
+ this.disabledDatesRE = dd;
+ }
+ this.initDisabledDays();
+ this.update(this.value, true);
+ },
+
+
+ setDisabledDays : function(dd){
+ this.disabledDays = dd;
+ this.update(this.value, true);
+ },
+
+
+ setMinDate : function(dt){
+ this.minDate = dt;
+ this.update(this.value, true);
+ },
+
+
+ setMaxDate : function(dt){
+ this.maxDate = dt;
+ this.update(this.value, true);
+ },
+
+
+ setValue : function(value){
+ this.value = value.clearTime(true);
+ this.update(this.value);
+ },
+
+
+ getValue : function(){
+ return this.value;
+ },
+
+
+ focus : function(){
+ this.update(this.activeDate);
+ },
+
+
+ onEnable: function(initial){
+ Ext.DatePicker.superclass.onEnable.call(this);
+ this.doDisabled(false);
+ this.update(initial ? this.value : this.activeDate);
+ if(Ext.isIE){
+ this.el.repaint();
+ }
+
+ },
+
+
+ onDisable : function(){
+ Ext.DatePicker.superclass.onDisable.call(this);
+ this.doDisabled(true);
+ if(Ext.isIE && !Ext.isIE8){
+
+ Ext.each([].concat(this.textNodes, this.el.query('th span')), function(el){
+ Ext.fly(el).repaint();
+ });
+ }
+ },
+
+
+ doDisabled : function(disabled){
+ this.keyNav.setDisabled(disabled);
+ this.prevRepeater.setDisabled(disabled);
+ this.nextRepeater.setDisabled(disabled);
+ if(this.showToday){
+ this.todayKeyListener.setDisabled(disabled);
+ this.todayBtn.setDisabled(disabled);
+ }
+ },
+
+
+ onRender : function(container, position){
+ var m = [
+ '<table cellspacing="0">',
+ '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'"> </a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'"> </a></td></tr>',
+ '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'],
+ dn = this.dayNames,
+ i;
+ for(i = 0; i < 7; i++){
+ var d = this.startDay+i;
+ if(d > 6){
+ d = d-7;
+ }
+ m.push('<th><span>', dn[d].substr(0,1), '</span></th>');
+ }
+ m[m.length] = '</tr></thead><tbody><tr>';
+ for(i = 0; i < 42; i++) {
+ if(i % 7 === 0 && i !== 0){
+ m[m.length] = '</tr><tr>';
+ }
+ m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
+ }
+ m.push('</tr></tbody></table></td></tr>',
+ this.showToday ? '<tr><td colspan="3" class="x-date-bottom" align="center"></td></tr>' : '',
+ '</table><div class="x-date-mp"></div>');
+
+ var el = document.createElement('div');
+ el.className = 'x-date-picker';
+ el.innerHTML = m.join('');
+
+ container.dom.insertBefore(el, position);
+
+ this.el = Ext.get(el);
+ this.eventEl = Ext.get(el.firstChild);
+
+ this.prevRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-left a'), {
+ handler: this.showPrevMonth,
+ scope: this,
+ preventDefault:true,
+ stopDefault:true
+ });
+
+ this.nextRepeater = new Ext.util.ClickRepeater(this.el.child('td.x-date-right a'), {
+ handler: this.showNextMonth,
+ scope: this,
+ preventDefault:true,
+ stopDefault:true
+ });
+
+ this.monthPicker = this.el.down('div.x-date-mp');
+ this.monthPicker.enableDisplayMode('block');
+
+ this.keyNav = new Ext.KeyNav(this.eventEl, {
+ 'left' : function(e){
+ if(e.ctrlKey){
+ this.showPrevMonth();
+ }else{
+ this.update(this.activeDate.add('d', -1));
+ }
+ },
+
+ 'right' : function(e){
+ if(e.ctrlKey){
+ this.showNextMonth();
+ }else{
+ this.update(this.activeDate.add('d', 1));
+ }
+ },
+
+ 'up' : function(e){
+ if(e.ctrlKey){
+ this.showNextYear();
+ }else{
+ this.update(this.activeDate.add('d', -7));
+ }
+ },
+
+ 'down' : function(e){
+ if(e.ctrlKey){
+ this.showPrevYear();
+ }else{
+ this.update(this.activeDate.add('d', 7));
+ }
+ },
+
+ 'pageUp' : function(e){
+ this.showNextMonth();
+ },
+
+ 'pageDown' : function(e){
+ this.showPrevMonth();
+ },
+
+ 'enter' : function(e){
+ e.stopPropagation();
+ return true;
+ },
+
+ scope : this
+ });
+
+ this.el.unselectable();
+
+ this.cells = this.el.select('table.x-date-inner tbody td');
+ this.textNodes = this.el.query('table.x-date-inner tbody span');
+
+ this.mbtn = new Ext.Button({
+ text: ' ',
+ tooltip: this.monthYearText,
+ renderTo: this.el.child('td.x-date-middle', true)
+ });
+ this.mbtn.el.child('em').addClass('x-btn-arrow');
+
+ if(this.showToday){
+ this.todayKeyListener = this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
+ var today = (new Date()).dateFormat(this.format);
+ this.todayBtn = new Ext.Button({
+ renderTo: this.el.child('td.x-date-bottom', true),
+ text: String.format(this.todayText, today),
+ tooltip: String.format(this.todayTip, today),
+ handler: this.selectToday,
+ scope: this
+ });
+ }
+ this.mon(this.eventEl, 'mousewheel', this.handleMouseWheel, this);
+ this.mon(this.eventEl, 'click', this.handleDateClick, this, {delegate: 'a.x-date-date'});
+ this.mon(this.mbtn, 'click', this.showMonthPicker, this);
+ this.onEnable(true);
+ },
+
+
+ createMonthPicker : function(){
+ if(!this.monthPicker.dom.firstChild){
+ var buf = ['<table border="0" cellspacing="0">'];
+ for(var i = 0; i < 6; i++){
+ buf.push(
+ '<tr><td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i), '</a></td>',
+ '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', Date.getShortMonthName(i + 6), '</a></td>',
+ i === 0 ?
+ '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
+ '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
+ );
+ }
+ buf.push(
+ '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
+ this.okText,
+ '</button><button type="button" class="x-date-mp-cancel">',
+ this.cancelText,
+ '</button></td></tr>',
+ '</table>'
+ );
+ this.monthPicker.update(buf.join(''));
+
+ this.mon(this.monthPicker, 'click', this.onMonthClick, this);
+ this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);
+
+ this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
+ this.mpYears = this.monthPicker.select('td.x-date-mp-year');
+
+ this.mpMonths.each(function(m, a, i){
+ i += 1;
+ if((i%2) === 0){
+ m.dom.xmonth = 5 + Math.round(i * 0.5);
+ }else{
+ m.dom.xmonth = Math.round((i-1) * 0.5);
+ }
+ });
+ }
+ },
+
+
+ showMonthPicker : function(){
+ if(!this.disabled){
+ this.createMonthPicker();
+ var size = this.el.getSize();
+ this.monthPicker.setSize(size);
+ this.monthPicker.child('table').setSize(size);
+
+ this.mpSelMonth = (this.activeDate || this.value).getMonth();
+ this.updateMPMonth(this.mpSelMonth);
+ this.mpSelYear = (this.activeDate || this.value).getFullYear();
+ this.updateMPYear(this.mpSelYear);
+
+ this.monthPicker.slideIn('t', {duration:0.2});
+ }
+ },
+
+
+ updateMPYear : function(y){
+ this.mpyear = y;
+ var ys = this.mpYears.elements;
+ for(var i = 1; i <= 10; i++){
+ var td = ys[i-1], y2;
+ if((i%2) === 0){
+ y2 = y + Math.round(i * 0.5);
+ td.firstChild.innerHTML = y2;
+ td.xyear = y2;
+ }else{
+ y2 = y - (5-Math.round(i * 0.5));
+ td.firstChild.innerHTML = y2;
+ td.xyear = y2;
+ }
+ this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
+ }
+ },
+
+
+ updateMPMonth : function(sm){
+ this.mpMonths.each(function(m, a, i){
+ m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
+ });
+ },
+
+
+ selectMPMonth : function(m){
+
+ },
+
+
+ onMonthClick : function(e, t){
+ e.stopEvent();
+ var el = new Ext.Element(t), pn;
+ if(el.is('button.x-date-mp-cancel')){
+ this.hideMonthPicker();
+ }
+ else if(el.is('button.x-date-mp-ok')){
+ var d = new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate());
+ if(d.getMonth() != this.mpSelMonth){
+
+ d = new Date(this.mpSelYear, this.mpSelMonth, 1).getLastDateOfMonth();
+ }
+ this.update(d);
+ this.hideMonthPicker();
+ }
+ else if((pn = el.up('td.x-date-mp-month', 2))){
+ this.mpMonths.removeClass('x-date-mp-sel');
+ pn.addClass('x-date-mp-sel');
+ this.mpSelMonth = pn.dom.xmonth;
+ }
+ else if((pn = el.up('td.x-date-mp-year', 2))){
+ this.mpYears.removeClass('x-date-mp-sel');
+ pn.addClass('x-date-mp-sel');
+ this.mpSelYear = pn.dom.xyear;
+ }
+ else if(el.is('a.x-date-mp-prev')){
+ this.updateMPYear(this.mpyear-10);
+ }
+ else if(el.is('a.x-date-mp-next')){
+ this.updateMPYear(this.mpyear+10);
+ }
+ },
+
+
+ onMonthDblClick : function(e, t){
+ e.stopEvent();
+ var el = new Ext.Element(t), pn;
+ if((pn = el.up('td.x-date-mp-month', 2))){
+ this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
+ this.hideMonthPicker();
+ }
+ else if((pn = el.up('td.x-date-mp-year', 2))){
+ this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
+ this.hideMonthPicker();
+ }
+ },
+
+
+ hideMonthPicker : function(disableAnim){
+ if(this.monthPicker){
+ if(disableAnim === true){
+ this.monthPicker.hide();
+ }else{
+ this.monthPicker.slideOut('t', {duration:0.2});
+ }
+ }
+ },
+
+
+ showPrevMonth : function(e){
+ this.update(this.activeDate.add('mo', -1));
+ },
+
+
+ showNextMonth : function(e){
+ this.update(this.activeDate.add('mo', 1));
+ },
+
+
+ showPrevYear : function(){
+ this.update(this.activeDate.add('y', -1));
+ },
+
+
+ showNextYear : function(){
+ this.update(this.activeDate.add('y', 1));
+ },
+
+
+ handleMouseWheel : function(e){
+ e.stopEvent();
+ if(!this.disabled){
+ var delta = e.getWheelDelta();
+ if(delta > 0){
+ this.showPrevMonth();
+ } else if(delta < 0){
+ this.showNextMonth();
+ }
+ }
+ },
+
+
+ handleDateClick : function(e, t){
+ e.stopEvent();
+ if(!this.disabled && t.dateValue && !Ext.fly(t.parentNode).hasClass('x-date-disabled')){
+ this.cancelFocus = this.focusOnSelect === false;
+ this.setValue(new Date(t.dateValue));
+ delete this.cancelFocus;
+ this.fireEvent('select', this, this.value);
+ }
+ },
+
+
+ selectToday : function(){
+ if(this.todayBtn && !this.todayBtn.disabled){
+ this.setValue(new Date().clearTime());
+ this.fireEvent('select', this, this.value);
+ }
+ },
+
+
+ update : function(date, forceRefresh){
+ if(this.rendered){
+ var vd = this.activeDate, vis = this.isVisible();
+ this.activeDate = date;
+ if(!forceRefresh && vd && this.el){
+ var t = date.getTime();
+ if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
+ this.cells.removeClass('x-date-selected');
+ this.cells.each(function(c){
+ if(c.dom.firstChild.dateValue == t){
+ c.addClass('x-date-selected');
+ if(vis && !this.cancelFocus){
+ Ext.fly(c.dom.firstChild).focus(50);
+ }
+ return false;
+ }
+ }, this);
+ return;
+ }
+ }
+ var days = date.getDaysInMonth(),
+ firstOfMonth = date.getFirstDateOfMonth(),
+ startingPos = firstOfMonth.getDay()-this.startDay;
+
+ if(startingPos < 0){
+ startingPos += 7;
+ }
+ days += startingPos;
+
+ var pm = date.add('mo', -1),
+ prevStart = pm.getDaysInMonth()-startingPos,
+ cells = this.cells.elements,
+ textEls = this.textNodes,
+
+ d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart, this.initHour)),
+ today = new Date().clearTime().getTime(),
+ sel = date.clearTime(true).getTime(),
+ min = this.minDate ? this.minDate.clearTime(true) : Number.NEGATIVE_INFINITY,
+ max = this.maxDate ? this.maxDate.clearTime(true) : Number.POSITIVE_INFINITY,
+ ddMatch = this.disabledDatesRE,
+ ddText = this.disabledDatesText,
+ ddays = this.disabledDays ? this.disabledDays.join('') : false,
+ ddaysText = this.disabledDaysText,
+ format = this.format;
+
+ if(this.showToday){
+ var td = new Date().clearTime(),
+ disable = (td < min || td > max ||
+ (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||
+ (ddays && ddays.indexOf(td.getDay()) != -1));
+
+ if(!this.disabled){
+ this.todayBtn.setDisabled(disable);
+ this.todayKeyListener[disable ? 'disable' : 'enable']();
+ }
+ }
+
+ var setCellClass = function(cal, cell){
+ cell.title = '';
+ var t = d.clearTime(true).getTime();
+ cell.firstChild.dateValue = t;
+ if(t == today){
+ cell.className += ' x-date-today';
+ cell.title = cal.todayText;
+ }
+ if(t == sel){
+ cell.className += ' x-date-selected';
+ if(vis){
+ Ext.fly(cell.firstChild).focus(50);
+ }
+ }
+
+ if(t < min) {
+ cell.className = ' x-date-disabled';
+ cell.title = cal.minText;
+ return;
+ }
+ if(t > max) {
+ cell.className = ' x-date-disabled';
+ cell.title = cal.maxText;
+ return;
+ }
+ if(ddays){
+ if(ddays.indexOf(d.getDay()) != -1){
+ cell.title = ddaysText;
+ cell.className = ' x-date-disabled';
+ }
+ }
+ if(ddMatch && format){
+ var fvalue = d.dateFormat(format);
+ if(ddMatch.test(fvalue)){
+ cell.title = ddText.replace('%0', fvalue);
+ cell.className = ' x-date-disabled';
+ }
+ }
+ };
+
+ var i = 0;
+ for(; i < startingPos; i++) {
+ textEls[i].innerHTML = (++prevStart);
+ d.setDate(d.getDate()+1);
+ cells[i].className = 'x-date-prevday';
+ setCellClass(this, cells[i]);
+ }
+ for(; i < days; i++){
+ var intDay = i - startingPos + 1;
+ textEls[i].innerHTML = (intDay);
+ d.setDate(d.getDate()+1);
+ cells[i].className = 'x-date-active';
+ setCellClass(this, cells[i]);
+ }
+ var extraDays = 0;
+ for(; i < 42; i++) {
+ textEls[i].innerHTML = (++extraDays);
+ d.setDate(d.getDate()+1);
+ cells[i].className = 'x-date-nextday';
+ setCellClass(this, cells[i]);
+ }
+
+ this.mbtn.setText(this.monthNames[date.getMonth()] + ' ' + date.getFullYear());
+
+ if(!this.internalRender){
+ var main = this.el.dom.firstChild,
+ w = main.offsetWidth;
+ this.el.setWidth(w + this.el.getBorderWidth('lr'));
+ Ext.fly(main).setWidth(w);
+ this.internalRender = true;
+
+
+
+ if(Ext.isOpera && !this.secondPass){
+ main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + 'px';
+ this.secondPass = true;
+ this.update.defer(10, this, [date]);
+ }
+ }
+ }
+ },
+
+
+ beforeDestroy : function() {
+ if(this.rendered){
+ Ext.destroy(
+ this.keyNav,
+ this.monthPicker,
+ this.eventEl,
+ this.mbtn,
+ this.nextRepeater,
+ this.prevRepeater,
+ this.cells.el,
+ this.todayBtn
+ );
+ delete this.textNodes;
+ delete this.cells.elements;
+ }
+ }
+
+
+});
+
+Ext.reg('datepicker', Ext.DatePicker);
+
+Ext.LoadMask = function(el, config){
+ this.el = Ext.get(el);
+ Ext.apply(this, config);
+ if(this.store){
+ this.store.on({
+ scope: this,
+ beforeload: this.onBeforeLoad,
+ load: this.onLoad,
+ exception: this.onLoad
+ });
+ this.removeMask = Ext.value(this.removeMask, false);
+ }else{
+ var um = this.el.getUpdater();
+ um.showLoadIndicator = false;
+ um.on({
+ scope: this,
+ beforeupdate: this.onBeforeLoad,
+ update: this.onLoad,
+ failure: this.onLoad
+ });
+ this.removeMask = Ext.value(this.removeMask, true);
+ }
+};
+
+Ext.LoadMask.prototype = {
+
+
+
+ msg : 'Loading...',
+
+ msgCls : 'x-mask-loading',
+
+
+ disabled: false,
+
+
+ disable : function(){
+ this.disabled = true;
+ },
+
+
+ enable : function(){
+ this.disabled = false;
+ },
+
+
+ onLoad : function(){
+ this.el.unmask(this.removeMask);
+ },
+
+
+ onBeforeLoad : function(){
+ if(!this.disabled){
+ this.el.mask(this.msg, this.msgCls);
+ }
+ },
+
+
+ show: function(){
+ this.onBeforeLoad();
+ },
+
+
+ hide: function(){
+ this.onLoad();
+ },
+
+
+ destroy : function(){
+ if(this.store){
+ this.store.un('beforeload', this.onBeforeLoad, this);
+ this.store.un('load', this.onLoad, this);
+ this.store.un('exception', this.onLoad, this);
+ }else{
+ var um = this.el.getUpdater();
+ um.un('beforeupdate', this.onBeforeLoad, this);
+ um.un('update', this.onLoad, this);
+ um.un('failure', this.onLoad, this);
+ }
+ }
+};Ext.ns('Ext.slider');
+
+
+Ext.slider.Thumb = Ext.extend(Object, {
+
+
+ dragging: false,
+
+
+ constructor: function(config) {
+
+ Ext.apply(this, config || {}, {
+ cls: 'x-slider-thumb',
+
+
+ constrain: false
+ });
+
+ Ext.slider.Thumb.superclass.constructor.call(this, config);
+
+ if (this.slider.vertical) {
+ Ext.apply(this, Ext.slider.Thumb.Vertical);
+ }
+ },
+
+
+ render: function() {
+ this.el = this.slider.innerEl.insertFirst({cls: this.cls});
+
+ this.initEvents();
+ },
+
+
+ enable: function() {
+ this.disabled = false;
+ this.el.removeClass(this.slider.disabledClass);
+ },
+
+
+ disable: function() {
+ this.disabled = true;
+ this.el.addClass(this.slider.disabledClass);
+ },
+
+
+ initEvents: function() {
+ var el = this.el;
+
+ el.addClassOnOver('x-slider-thumb-over');
+
+ this.tracker = new Ext.dd.DragTracker({
+ onBeforeStart: this.onBeforeDragStart.createDelegate(this),
+ onStart : this.onDragStart.createDelegate(this),
+ onDrag : this.onDrag.createDelegate(this),
+ onEnd : this.onDragEnd.createDelegate(this),
+ tolerance : 3,
+ autoStart : 300
+ });
+
+ this.tracker.initEl(el);
+ },
+
+
+ onBeforeDragStart : function(e) {
+ if (this.disabled) {
+ return false;
+ } else {
+ this.slider.promoteThumb(this);
+ return true;
+ }
+ },
+
+
+ onDragStart: function(e){
+ this.el.addClass('x-slider-thumb-drag');
+ this.dragging = true;
+ this.dragStartValue = this.value;
+
+ this.slider.fireEvent('dragstart', this.slider, e, this);
+ },
+
+
+ onDrag: function(e) {
+ var slider = this.slider,
+ index = this.index,
+ newValue = this.getNewValue();
+
+ if (this.constrain) {
+ var above = slider.thumbs[index + 1],
+ below = slider.thumbs[index - 1];
+
+ if (below != undefined && newValue <= below.value) newValue = below.value;
+ if (above != undefined && newValue >= above.value) newValue = above.value;
+ }
+
+ slider.setValue(index, newValue, false);
+ slider.fireEvent('drag', slider, e, this);
+ },
+
+ getNewValue: function() {
+ var slider = this.slider,
+ pos = slider.innerEl.translatePoints(this.tracker.getXY());
+
+ return Ext.util.Format.round(slider.reverseValue(pos.left), slider.decimalPrecision);
+ },
+
+
+ onDragEnd: function(e) {
+ var slider = this.slider,
+ value = this.value;
+
+ this.el.removeClass('x-slider-thumb-drag');
+
+ this.dragging = false;
+ slider.fireEvent('dragend', slider, e);
+
+ if (this.dragStartValue != value) {
+ slider.fireEvent('changecomplete', slider, value, this);
+ }
+ },
+
+
+ destroy: function(){
+ Ext.destroyMembers(this, 'tracker', 'el');
+ }
+});
+
+
+Ext.slider.MultiSlider = Ext.extend(Ext.BoxComponent, {
+
+
+ vertical: false,
+
+ minValue: 0,
+
+ maxValue: 100,
+
+ decimalPrecision: 0,
+
+ keyIncrement: 1,
+
+ increment: 0,
+
+
+ clickRange: [5,15],
+
+
+ clickToChange : true,
+
+ animate: true,
+
+ constrainThumbs: true,
+
+
+ topThumbZIndex: 10000,
+
+
+ initComponent : function(){
+ if(!Ext.isDefined(this.value)){
+ this.value = this.minValue;
+ }
+
+
+ this.thumbs = [];
+
+ Ext.slider.MultiSlider.superclass.initComponent.call(this);
+
+ this.keyIncrement = Math.max(this.increment, this.keyIncrement);
+ this.addEvents(
+
+ 'beforechange',
+
+
+ 'change',
+
+
+ 'changecomplete',
+
+
+ 'dragstart',
+
+
+ 'drag',
+
+
+ 'dragend'
+ );
+
+
+ if (this.values == undefined || Ext.isEmpty(this.values)) this.values = [0];
+
+ var values = this.values;
+
+ for (var i=0; i < values.length; i++) {
+ this.addThumb(values[i]);
+ }
+
+ if(this.vertical){
+ Ext.apply(this, Ext.slider.Vertical);
+ }
+ },
+
+
+ addThumb: function(value) {
+ var thumb = new Ext.slider.Thumb({
+ value : value,
+ slider : this,
+ index : this.thumbs.length,
+ constrain: this.constrainThumbs
+ });
+ this.thumbs.push(thumb);
+
+
+ if (this.rendered) thumb.render();
+ },
+
+
+ promoteThumb: function(topThumb) {
+ var thumbs = this.thumbs,
+ zIndex, thumb;
+
+ for (var i = 0, j = thumbs.length; i < j; i++) {
+ thumb = thumbs[i];
+
+ if (thumb == topThumb) {
+ zIndex = this.topThumbZIndex;
+ } else {
+ zIndex = '';
+ }
+
+ thumb.el.setStyle('zIndex', zIndex);
+ }
+ },
+
+
+ onRender : function() {
+ this.autoEl = {
+ cls: 'x-slider ' + (this.vertical ? 'x-slider-vert' : 'x-slider-horz'),
+ cn : {
+ cls: 'x-slider-end',
+ cn : {
+ cls:'x-slider-inner',
+ cn : [{tag:'a', cls:'x-slider-focus', href:"#", tabIndex: '-1', hidefocus:'on'}]
+ }
+ }
+ };
+
+ Ext.slider.MultiSlider.superclass.onRender.apply(this, arguments);
+
+ this.endEl = this.el.first();
+ this.innerEl = this.endEl.first();
+ this.focusEl = this.innerEl.child('.x-slider-focus');
+
+
+ for (var i=0; i < this.thumbs.length; i++) {
+ this.thumbs[i].render();
+ }
+
+
+ var thumb = this.innerEl.child('.x-slider-thumb');
+ this.halfThumb = (this.vertical ? thumb.getHeight() : thumb.getWidth()) / 2;
+
+ this.initEvents();
+ },
+
+
+ initEvents : function(){
+ this.mon(this.el, {
+ scope : this,
+ mousedown: this.onMouseDown,
+ keydown : this.onKeyDown
+ });
+
+ this.focusEl.swallowEvent("click", true);
+ },
+
+
+ onMouseDown : function(e){
+ if(this.disabled){
+ return;
+ }
+
+
+ var thumbClicked = false;
+ for (var i=0; i < this.thumbs.length; i++) {
+ thumbClicked = thumbClicked || e.target == this.thumbs[i].el.dom;
+ }
+
+ if (this.clickToChange && !thumbClicked) {
+ var local = this.innerEl.translatePoints(e.getXY());
+ this.onClickChange(local);
+ }
+ this.focus();
+ },
+
+
+ onClickChange : function(local) {
+ if (local.top > this.clickRange[0] && local.top < this.clickRange[1]) {
+
+ var thumb = this.getNearest(local, 'left'),
+ index = thumb.index;
+
+ this.setValue(index, Ext.util.Format.round(this.reverseValue(local.left), this.decimalPrecision), undefined, true);
+ }
+ },
+
+
+ getNearest: function(local, prop) {
+ var localValue = prop == 'top' ? this.innerEl.getHeight() - local[prop] : local[prop],
+ clickValue = this.reverseValue(localValue),
+ nearestDistance = (this.maxValue - this.minValue) + 5,
+ index = 0,
+ nearest = null;
+
+ for (var i=0; i < this.thumbs.length; i++) {
+ var thumb = this.thumbs[i],
+ value = thumb.value,
+ dist = Math.abs(value - clickValue);
+
+ if (Math.abs(dist <= nearestDistance)) {
+ nearest = thumb;
+ index = i;
+ nearestDistance = dist;
+ }
+ }
+ return nearest;
+ },
+
+
+ onKeyDown : function(e){
+
+ if(this.disabled || this.thumbs.length !== 1){
+ e.preventDefault();
+ return;
+ }
+ var k = e.getKey(),
+ val;
+ switch(k){
+ case e.UP:
+ case e.RIGHT:
+ e.stopEvent();
+ val = e.ctrlKey ? this.maxValue : this.getValue(0) + this.keyIncrement;
+ this.setValue(0, val, undefined, true);
+ break;
+ case e.DOWN:
+ case e.LEFT:
+ e.stopEvent();
+ val = e.ctrlKey ? this.minValue : this.getValue(0) - this.keyIncrement;
+ this.setValue(0, val, undefined, true);
+ break;
+ default:
+ e.preventDefault();
+ }
+ },
+
+
+ doSnap : function(value){
+ if (!(this.increment && value)) {
+ return value;
+ }
+ var newValue = value,
+ inc = this.increment,
+ m = value % inc;
+ if (m != 0) {
+ newValue -= m;
+ if (m * 2 >= inc) {
+ newValue += inc;
+ } else if (m * 2 < -inc) {
+ newValue -= inc;
+ }
+ }
+ return newValue.constrain(this.minValue, this.maxValue);
+ },
+
+
+ afterRender : function(){
+ Ext.slider.MultiSlider.superclass.afterRender.apply(this, arguments);
+
+ for (var i=0; i < this.thumbs.length; i++) {
+ var thumb = this.thumbs[i];
+
+ if (thumb.value !== undefined) {
+ var v = this.normalizeValue(thumb.value);
+
+ if (v !== thumb.value) {
+
+ this.setValue(i, v, false);
+ } else {
+ this.moveThumb(i, this.translateValue(v), false);
+ }
+ }
+ };
+ },
+
+
+ getRatio : function(){
+ var w = this.innerEl.getWidth(),
+ v = this.maxValue - this.minValue;
+ return v == 0 ? w : (w/v);
+ },
+
+
+ normalizeValue : function(v){
+ v = this.doSnap(v);
+ v = Ext.util.Format.round(v, this.decimalPrecision);
+ v = v.constrain(this.minValue, this.maxValue);
+ return v;
+ },
+
+
+ setMinValue : function(val){
+ this.minValue = val;
+ var i = 0,
+ thumbs = this.thumbs,
+ len = thumbs.length,
+ t;
+
+ for(; i < len; ++i){
+ t = thumbs[i];
+ t.value = t.value < val ? val : t.value;
+ }
+ this.syncThumb();
+ },
+
+
+ setMaxValue : function(val){
+ this.maxValue = val;
+ var i = 0,
+ thumbs = this.thumbs,
+ len = thumbs.length,
+ t;
+
+ for(; i < len; ++i){
+ t = thumbs[i];
+ t.value = t.value > val ? val : t.value;
+ }
+ this.syncThumb();
+ },
+
+
+ setValue : function(index, v, animate, changeComplete) {
+ var thumb = this.thumbs[index],
+ el = thumb.el;
+
+ v = this.normalizeValue(v);
+
+ if (v !== thumb.value && this.fireEvent('beforechange', this, v, thumb.value, thumb) !== false) {
+ thumb.value = v;
+ if(this.rendered){
+ this.moveThumb(index, this.translateValue(v), animate !== false);
+ this.fireEvent('change', this, v, thumb);
+ if(changeComplete){
+ this.fireEvent('changecomplete', this, v, thumb);
+ }
+ }
+ }
+ },
+
+
+ translateValue : function(v) {
+ var ratio = this.getRatio();
+ return (v * ratio) - (this.minValue * ratio) - this.halfThumb;
+ },
+
+
+ reverseValue : function(pos){
+ var ratio = this.getRatio();
+ return (pos + (this.minValue * ratio)) / ratio;
+ },
+
+
+ moveThumb: function(index, v, animate){
+ var thumb = this.thumbs[index].el;
+
+ if(!animate || this.animate === false){
+ thumb.setLeft(v);
+ }else{
+ thumb.shift({left: v, stopFx: true, duration:.35});
+ }
+ },
+
+
+ focus : function(){
+ this.focusEl.focus(10);
+ },
+
+
+ onResize : function(w, h){
+ var thumbs = this.thumbs,
+ len = thumbs.length,
+ i = 0;
+
+
+ for(; i < len; ++i){
+ thumbs[i].el.stopFx();
+ }
+
+ if(Ext.isNumber(w)){
+ this.innerEl.setWidth(w - (this.el.getPadding('l') + this.endEl.getPadding('r')));
+ }
+ this.syncThumb();
+ Ext.slider.MultiSlider.superclass.onResize.apply(this, arguments);
+ },
+
+
+ onDisable: function(){
+ Ext.slider.MultiSlider.superclass.onDisable.call(this);
+
+ for (var i=0; i < this.thumbs.length; i++) {
+ var thumb = this.thumbs[i],
+ el = thumb.el;
+
+ thumb.disable();
+
+ if(Ext.isIE){
+
+
+ var xy = el.getXY();
+ el.hide();
+
+ this.innerEl.addClass(this.disabledClass).dom.disabled = true;
+
+ if (!this.thumbHolder) {
+ this.thumbHolder = this.endEl.createChild({cls: 'x-slider-thumb ' + this.disabledClass});
+ }
+
+ this.thumbHolder.show().setXY(xy);
+ }
+ }
+ },
+
+
+ onEnable: function(){
+ Ext.slider.MultiSlider.superclass.onEnable.call(this);
+
+ for (var i=0; i < this.thumbs.length; i++) {
+ var thumb = this.thumbs[i],
+ el = thumb.el;
+
+ thumb.enable();
+
+ if (Ext.isIE) {
+ this.innerEl.removeClass(this.disabledClass).dom.disabled = false;
+
+ if (this.thumbHolder) this.thumbHolder.hide();
+
+ el.show();
+ this.syncThumb();
+ }
+ }
+ },
+
+
+ syncThumb : function() {
+ if (this.rendered) {
+ for (var i=0; i < this.thumbs.length; i++) {
+ this.moveThumb(i, this.translateValue(this.thumbs[i].value));
+ }
+ }
+ },
+
+
+ getValue : function(index) {
+ return this.thumbs[index].value;
+ },
+
+
+ getValues: function() {
+ var values = [];
+
+ for (var i=0; i < this.thumbs.length; i++) {
+ values.push(this.thumbs[i].value);
+ }
+
+ return values;
+ },
+
+
+ beforeDestroy : function(){
+ var thumbs = this.thumbs;
+ for(var i = 0, len = thumbs.length; i < len; ++i){
+ thumbs[i].destroy();
+ thumbs[i] = null;
+ }
+ Ext.destroyMembers(this, 'endEl', 'innerEl', 'focusEl', 'thumbHolder');
+ Ext.slider.MultiSlider.superclass.beforeDestroy.call(this);
+ }
+});
+
+Ext.reg('multislider', Ext.slider.MultiSlider);
+
+
+Ext.slider.SingleSlider = Ext.extend(Ext.slider.MultiSlider, {
+ constructor: function(config) {
+ config = config || {};
+
+ Ext.applyIf(config, {
+ values: [config.value || 0]
+ });
+
+ Ext.slider.SingleSlider.superclass.constructor.call(this, config);
+ },
+
+
+ getValue: function() {
+
+ return Ext.slider.SingleSlider.superclass.getValue.call(this, 0);
+ },
+
+
+ setValue: function(value, animate) {
+ var args = Ext.toArray(arguments),
+ len = args.length;
+
+
+
+
+ if (len == 1 || (len <= 3 && typeof arguments[1] != 'number')) {
+ args.unshift(0);
+ }
+
+ return Ext.slider.SingleSlider.superclass.setValue.apply(this, args);
+ },
+
+
+ syncThumb : function() {
+ return Ext.slider.SingleSlider.superclass.syncThumb.apply(this, [0].concat(arguments));
+ },
+
+
+ getNearest : function(){
+
+ return this.thumbs[0];
+ }
+});
+
+
+Ext.Slider = Ext.slider.SingleSlider;
+
+Ext.reg('slider', Ext.slider.SingleSlider);
+
+
+Ext.slider.Vertical = {
+ onResize : function(w, h){
+ this.innerEl.setHeight(h - (this.el.getPadding('t') + this.endEl.getPadding('b')));
+ this.syncThumb();
+ },
+
+ getRatio : function(){
+ var h = this.innerEl.getHeight(),
+ v = this.maxValue - this.minValue;
+ return h/v;
+ },
+
+ moveThumb: function(index, v, animate) {
+ var thumb = this.thumbs[index],
+ el = thumb.el;
+
+ if (!animate || this.animate === false) {
+ el.setBottom(v);
+ } else {
+ el.shift({bottom: v, stopFx: true, duration:.35});
+ }
+ },
+
+ onClickChange : function(local) {
+ if (local.left > this.clickRange[0] && local.left < this.clickRange[1]) {
+ var thumb = this.getNearest(local, 'top'),
+ index = thumb.index,
+ value = this.minValue + this.reverseValue(this.innerEl.getHeight() - local.top);
+
+ this.setValue(index, Ext.util.Format.round(value, this.decimalPrecision), undefined, true);
+ }
+ }
+};
+
+
+Ext.slider.Thumb.Vertical = {
+ getNewValue: function() {
+ var slider = this.slider,
+ innerEl = slider.innerEl,
+ pos = innerEl.translatePoints(this.tracker.getXY()),
+ bottom = innerEl.getHeight() - pos.top;
+
+ return slider.minValue + Ext.util.Format.round(bottom / slider.getRatio(), slider.decimalPrecision);
+ }
+};
+
+Ext.ProgressBar = Ext.extend(Ext.BoxComponent, {
+
+ baseCls : 'x-progress',
+
+
+ animate : false,
+
+
+ waitTimer : null,
+
+
+ initComponent : function(){
+ Ext.ProgressBar.superclass.initComponent.call(this);
+ this.addEvents(
+
+ "update"
+ );
+ },
+
+
+ onRender : function(ct, position){
+ var tpl = new Ext.Template(
+ '<div class="{cls}-wrap">',
+ '<div class="{cls}-inner">',
+ '<div class="{cls}-bar">',
+ '<div class="{cls}-text">',
+ '<div> </div>',
+ '</div>',
+ '</div>',
+ '<div class="{cls}-text {cls}-text-back">',
+ '<div> </div>',
+ '</div>',
+ '</div>',
+ '</div>'
+ );
+
+ this.el = position ? tpl.insertBefore(position, {cls: this.baseCls}, true)
+ : tpl.append(ct, {cls: this.baseCls}, true);
+
+ if(this.id){
+ this.el.dom.id = this.id;
+ }
+ var inner = this.el.dom.firstChild;
+ this.progressBar = Ext.get(inner.firstChild);
+
+ if(this.textEl){
+
+ this.textEl = Ext.get(this.textEl);
+ delete this.textTopEl;
+ }else{
+
+ this.textTopEl = Ext.get(this.progressBar.dom.firstChild);
+ var textBackEl = Ext.get(inner.childNodes[1]);
+ this.textTopEl.setStyle("z-index", 99).addClass('x-hidden');
+ this.textEl = new Ext.CompositeElement([this.textTopEl.dom.firstChild, textBackEl.dom.firstChild]);
+ this.textEl.setWidth(inner.offsetWidth);
+ }
+ this.progressBar.setHeight(inner.offsetHeight);
+ },
+
+
+ afterRender : function(){
+ Ext.ProgressBar.superclass.afterRender.call(this);
+ if(this.value){
+ this.updateProgress(this.value, this.text);
+ }else{
+ this.updateText(this.text);
+ }
+ },
+
+
+ updateProgress : function(value, text, animate){
+ this.value = value || 0;
+ if(text){
+ this.updateText(text);
+ }
+ if(this.rendered && !this.isDestroyed){
+ var w = Math.floor(value*this.el.dom.firstChild.offsetWidth);
+ this.progressBar.setWidth(w, animate === true || (animate !== false && this.animate));
+ if(this.textTopEl){
+
+ this.textTopEl.removeClass('x-hidden').setWidth(w);
+ }
+ }
+ this.fireEvent('update', this, value, text);
+ return this;
+ },
+
+
+ wait : function(o){
+ if(!this.waitTimer){
+ var scope = this;
+ o = o || {};
+ this.updateText(o.text);
+ this.waitTimer = Ext.TaskMgr.start({
+ run: function(i){
+ var inc = o.increment || 10;
+ i -= 1;
+ this.updateProgress(((((i+inc)%inc)+1)*(100/inc))*0.01, null, o.animate);
+ },
+ interval: o.interval || 1000,
+ duration: o.duration,
+ onStop: function(){
+ if(o.fn){
+ o.fn.apply(o.scope || this);
+ }
+ this.reset();
+ },
+ scope: scope
+ });
+ }
+ return this;
+ },
+
+
+ isWaiting : function(){
+ return this.waitTimer !== null;
+ },
+
+
+ updateText : function(text){
+ this.text = text || ' ';
+ if(this.rendered){
+ this.textEl.update(this.text);
+ }
+ return this;
+ },
+
+
+ syncProgressBar : function(){
+ if(this.value){
+ this.updateProgress(this.value, this.text);
+ }
+ return this;
+ },
+
+
+ setSize : function(w, h){
+ Ext.ProgressBar.superclass.setSize.call(this, w, h);
+ if(this.textTopEl){
+ var inner = this.el.dom.firstChild;
+ this.textEl.setSize(inner.offsetWidth, inner.offsetHeight);
+ }
+ this.syncProgressBar();
+ return this;
+ },
+
+
+ reset : function(hide){
+ this.updateProgress(0);
+ if(this.textTopEl){
+ this.textTopEl.addClass('x-hidden');
+ }
+ this.clearTimer();
+ if(hide === true){
+ this.hide();
+ }
+ return this;
+ },
+
+
+ clearTimer : function(){
+ if(this.waitTimer){
+ this.waitTimer.onStop = null;
+ Ext.TaskMgr.stop(this.waitTimer);
+ this.waitTimer = null;
+ }
+ },
+
+ onDestroy: function(){
+ this.clearTimer();
+ if(this.rendered){
+ if(this.textEl.isComposite){
+ this.textEl.clear();
+ }
+ Ext.destroyMembers(this, 'textEl', 'progressBar', 'textTopEl');
+ }
+ Ext.ProgressBar.superclass.onDestroy.call(this);
+ }
+});
+Ext.reg('progress', Ext.ProgressBar);
+
+(function() {
+
+var Event=Ext.EventManager;
+var Dom=Ext.lib.Dom;
+
+
+Ext.dd.DragDrop = function(id, sGroup, config) {
+ if(id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+Ext.dd.DragDrop.prototype = {
+
+
+
+
+ id: null,
+
+
+ config: null,
+
+
+ dragElId: null,
+
+
+ handleElId: null,
+
+
+ invalidHandleTypes: null,
+
+
+ invalidHandleIds: null,
+
+
+ invalidHandleClasses: null,
+
+
+ startPageX: 0,
+
+
+ startPageY: 0,
+
+
+ groups: null,
+
+
+ locked: false,
+
+
+ lock: function() {
+ this.locked = true;
+ },
+
+
+ moveOnly: false,
+
+
+ unlock: function() {
+ this.locked = false;
+ },
+
+
+ isTarget: true,
+
+
+ padding: null,
+
+
+ _domRef: null,
+
+
+ __ygDragDrop: true,
+
+
+ constrainX: false,
+
+
+ constrainY: false,
+
+
+ minX: 0,
+
+
+ maxX: 0,
+
+
+ minY: 0,
+
+
+ maxY: 0,
+
+
+ maintainOffset: false,
+
+
+ xTicks: null,
+
+
+ yTicks: null,
+
+
+ primaryButtonOnly: true,
+
+
+ available: false,
+
+
+ hasOuterHandles: false,
+
+
+ b4StartDrag: function(x, y) { },
+
+
+ startDrag: function(x, y) { },
+
+
+ b4Drag: function(e) { },
+
+
+ onDrag: function(e) { },
+
+
+ onDragEnter: function(e, id) { },
+
+
+ b4DragOver: function(e) { },
+
+
+ onDragOver: function(e, id) { },
+
+
+ b4DragOut: function(e) { },
+
+
+ onDragOut: function(e, id) { },
+
+
+ b4DragDrop: function(e) { },
+
+
+ onDragDrop: function(e, id) { },
+
+
+ onInvalidDrop: function(e) { },
+
+
+ b4EndDrag: function(e) { },
+
+
+ endDrag: function(e) { },
+
+
+ b4MouseDown: function(e) { },
+
+
+ onMouseDown: function(e) { },
+
+
+ onMouseUp: function(e) { },
+
+
+ onAvailable: function () {
+ },
+
+
+ defaultPadding : {left:0, right:0, top:0, bottom:0},
+
+
+ constrainTo : function(constrainTo, pad, inContent){
+ if(Ext.isNumber(pad)){
+ pad = {left: pad, right:pad, top:pad, bottom:pad};
+ }
+ pad = pad || this.defaultPadding;
+ var b = Ext.get(this.getEl()).getBox(),
+ ce = Ext.get(constrainTo),
+ s = ce.getScroll(),
+ c,
+ cd = ce.dom;
+ if(cd == document.body){
+ c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
+ }else{
+ var xy = ce.getXY();
+ c = {x : xy[0], y: xy[1], width: cd.clientWidth, height: cd.clientHeight};
+ }
+
+
+ var topSpace = b.y - c.y,
+ leftSpace = b.x - c.x;
+
+ this.resetConstraints();
+ this.setXConstraint(leftSpace - (pad.left||0),
+ c.width - leftSpace - b.width - (pad.right||0),
+ this.xTickSize
+ );
+ this.setYConstraint(topSpace - (pad.top||0),
+ c.height - topSpace - b.height - (pad.bottom||0),
+ this.yTickSize
+ );
+ },
+
+
+ getEl: function() {
+ if (!this._domRef) {
+ this._domRef = Ext.getDom(this.id);
+ }
+
+ return this._domRef;
+ },
+
+
+ getDragEl: function() {
+ return Ext.getDom(this.dragElId);
+ },
+
+
+ init: function(id, sGroup, config) {
+ this.initTarget(id, sGroup, config);
+ Event.on(this.id, "mousedown", this.handleMouseDown, this);
+
+ },
+
+
+ initTarget: function(id, sGroup, config) {
+
+
+ this.config = config || {};
+
+
+ this.DDM = Ext.dd.DDM;
+
+ this.groups = {};
+
+
+
+ if (typeof id !== "string") {
+ id = Ext.id(id);
+ }
+
+
+ this.id = id;
+
+
+ this.addToGroup((sGroup) ? sGroup : "default");
+
+
+
+ this.handleElId = id;
+
+
+ this.setDragElId(id);
+
+
+ this.invalidHandleTypes = { A: "A" };
+ this.invalidHandleIds = {};
+ this.invalidHandleClasses = [];
+
+ this.applyConfig();
+
+ this.handleOnAvailable();
+ },
+
+
+ applyConfig: function() {
+
+
+
+ this.padding = this.config.padding || [0, 0, 0, 0];
+ this.isTarget = (this.config.isTarget !== false);
+ this.maintainOffset = (this.config.maintainOffset);
+ this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
+
+ },
+
+
+ handleOnAvailable: function() {
+ this.available = true;
+ this.resetConstraints();
+ this.onAvailable();
+ },
+
+
+ setPadding: function(iTop, iRight, iBot, iLeft) {
+
+ if (!iRight && 0 !== iRight) {
+ this.padding = [iTop, iTop, iTop, iTop];
+ } else if (!iBot && 0 !== iBot) {
+ this.padding = [iTop, iRight, iTop, iRight];
+ } else {
+ this.padding = [iTop, iRight, iBot, iLeft];
+ }
+ },
+
+
+ setInitPosition: function(diffX, diffY) {
+ var el = this.getEl();
+
+ if (!this.DDM.verifyEl(el)) {
+ return;
+ }
+
+ var dx = diffX || 0;
+ var dy = diffY || 0;
+
+ var p = Dom.getXY( el );
+
+ this.initPageX = p[0] - dx;
+ this.initPageY = p[1] - dy;
+
+ this.lastPageX = p[0];
+ this.lastPageY = p[1];
+
+ this.setStartPosition(p);
+ },
+
+
+ setStartPosition: function(pos) {
+ var p = pos || Dom.getXY( this.getEl() );
+ this.deltaSetXY = null;
+
+ this.startPageX = p[0];
+ this.startPageY = p[1];
+ },
+
+
+ addToGroup: function(sGroup) {
+ this.groups[sGroup] = true;
+ this.DDM.regDragDrop(this, sGroup);
+ },
+
+
+ removeFromGroup: function(sGroup) {
+ if (this.groups[sGroup]) {
+ delete this.groups[sGroup];
+ }
+
+ this.DDM.removeDDFromGroup(this, sGroup);
+ },
+
+
+ setDragElId: function(id) {
+ this.dragElId = id;
+ },
+
+
+ setHandleElId: function(id) {
+ if (typeof id !== "string") {
+ id = Ext.id(id);
+ }
+ this.handleElId = id;
+ this.DDM.regHandle(this.id, id);
+ },
+
+
+ setOuterHandleElId: function(id) {
+ if (typeof id !== "string") {
+ id = Ext.id(id);
+ }
+ Event.on(id, "mousedown",
+ this.handleMouseDown, this);
+ this.setHandleElId(id);
+
+ this.hasOuterHandles = true;
+ },
+
+
+ unreg: function() {
+ Event.un(this.id, "mousedown",
+ this.handleMouseDown);
+ this._domRef = null;
+ this.DDM._remove(this);
+ },
+
+ destroy : function(){
+ this.unreg();
+ },
+
+
+ isLocked: function() {
+ return (this.DDM.isLocked() || this.locked);
+ },
+
+
+ handleMouseDown: function(e, oDD){
+ if (this.primaryButtonOnly && e.button != 0) {
+ return;
+ }
+
+ if (this.isLocked()) {
+ return;
+ }
+
+ this.DDM.refreshCache(this.groups);
+
+ var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
+ if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
+ } else {
+ if (this.clickValidator(e)) {
+
+
+ this.setStartPosition();
+
+ this.b4MouseDown(e);
+ this.onMouseDown(e);
+
+ this.DDM.handleMouseDown(e, this);
+
+ this.DDM.stopEvent(e);
+ } else {
+
+
+ }
+ }
+ },
+
+ clickValidator: function(e) {
+ var target = e.getTarget();
+ return ( this.isValidHandleChild(target) &&
+ (this.id == this.handleElId ||
+ this.DDM.handleWasClicked(target, this.id)) );
+ },
+
+
+ addInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ this.invalidHandleTypes[type] = type;
+ },
+
+
+ addInvalidHandleId: function(id) {
+ if (typeof id !== "string") {
+ id = Ext.id(id);
+ }
+ this.invalidHandleIds[id] = id;
+ },
+
+
+ addInvalidHandleClass: function(cssClass) {
+ this.invalidHandleClasses.push(cssClass);
+ },
+
+
+ removeInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+
+ delete this.invalidHandleTypes[type];
+ },
+
+
+ removeInvalidHandleId: function(id) {
+ if (typeof id !== "string") {
+ id = Ext.id(id);
+ }
+ delete this.invalidHandleIds[id];
+ },
+
+
+ removeInvalidHandleClass: function(cssClass) {
+ for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
+ if (this.invalidHandleClasses[i] == cssClass) {
+ delete this.invalidHandleClasses[i];
+ }
+ }
+ },
+
+
+ isValidHandleChild: function(node) {
+
+ var valid = true;
+
+ var nodeName;
+ try {
+ nodeName = node.nodeName.toUpperCase();
+ } catch(e) {
+ nodeName = node.nodeName;
+ }
+ valid = valid && !this.invalidHandleTypes[nodeName];
+ valid = valid && !this.invalidHandleIds[node.id];
+
+ for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
+ valid = !Ext.fly(node).hasClass(this.invalidHandleClasses[i]);
+ }
+
+
+ return valid;
+
+ },
+
+
+ setXTicks: function(iStartX, iTickSize) {
+ this.xTicks = [];
+ this.xTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.xTicks.sort(this.DDM.numericSort) ;
+ },
+
+
+ setYTicks: function(iStartY, iTickSize) {
+ this.yTicks = [];
+ this.yTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.yTicks.sort(this.DDM.numericSort) ;
+ },
+
+
+ setXConstraint: function(iLeft, iRight, iTickSize) {
+ this.leftConstraint = iLeft;
+ this.rightConstraint = iRight;
+
+ this.minX = this.initPageX - iLeft;
+ this.maxX = this.initPageX + iRight;
+ if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
+
+ this.constrainX = true;
+ },
+
+
+ clearConstraints: function() {
+ this.constrainX = false;
+ this.constrainY = false;
+ this.clearTicks();
+ },
+
+
+ clearTicks: function() {
+ this.xTicks = null;
+ this.yTicks = null;
+ this.xTickSize = 0;
+ this.yTickSize = 0;
+ },
+
+
+ setYConstraint: function(iUp, iDown, iTickSize) {
+ this.topConstraint = iUp;
+ this.bottomConstraint = iDown;
+
+ this.minY = this.initPageY - iUp;
+ this.maxY = this.initPageY + iDown;
+ if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
+
+ this.constrainY = true;
+
+ },
+
+
+ resetConstraints: function() {
+
+ if (this.initPageX || this.initPageX === 0) {
+
+ var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
+ var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
+
+ this.setInitPosition(dx, dy);
+
+
+ } else {
+ this.setInitPosition();
+ }
+
+ if (this.constrainX) {
+ this.setXConstraint( this.leftConstraint,
+ this.rightConstraint,
+ this.xTickSize );
+ }
+
+ if (this.constrainY) {
+ this.setYConstraint( this.topConstraint,
+ this.bottomConstraint,
+ this.yTickSize );
+ }
+ },
+
+
+ getTick: function(val, tickArray) {
+ if (!tickArray) {
+
+
+ return val;
+ } else if (tickArray[0] >= val) {
+
+
+ return tickArray[0];
+ } else {
+ for (var i=0, len=tickArray.length; i<len; ++i) {
+ var next = i + 1;
+ if (tickArray[next] && tickArray[next] >= val) {
+ var diff1 = val - tickArray[i];
+ var diff2 = tickArray[next] - val;
+ return (diff2 > diff1) ? tickArray[i] : tickArray[next];
+ }
+ }
+
+
+
+ return tickArray[tickArray.length - 1];
+ }
+ },
+
+
+ toString: function() {
+ return ("DragDrop " + this.id);
+ }
+
+};
+
+})();
+
+
+
+
+if (!Ext.dd.DragDropMgr) {
+
+
+Ext.dd.DragDropMgr = function() {
+
+ var Event = Ext.EventManager;
+
+ return {
+
+
+ ids: {},
+
+
+ handleIds: {},
+
+
+ dragCurrent: null,
+
+
+ dragOvers: {},
+
+
+ deltaX: 0,
+
+
+ deltaY: 0,
+
+
+ preventDefault: true,
+
+
+ stopPropagation: true,
+
+
+ initialized: false,
+
+
+ locked: false,
+
+
+ init: function() {
+ this.initialized = true;
+ },
+
+
+ POINT: 0,
+
+
+ INTERSECT: 1,
+
+
+ mode: 0,
+
+
+ _execOnAll: function(sMethod, args) {
+ for (var i in this.ids) {
+ for (var j in this.ids[i]) {
+ var oDD = this.ids[i][j];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+ oDD[sMethod].apply(oDD, args);
+ }
+ }
+ },
+
+
+ _onLoad: function() {
+
+ this.init();
+
+
+ Event.on(document, "mouseup", this.handleMouseUp, this, true);
+ Event.on(document, "mousemove", this.handleMouseMove, this, true);
+ Event.on(window, "unload", this._onUnload, this, true);
+ Event.on(window, "resize", this._onResize, this, true);
+
+
+ },
+
+
+ _onResize: function(e) {
+ this._execOnAll("resetConstraints", []);
+ },
+
+
+ lock: function() { this.locked = true; },
+
+
+ unlock: function() { this.locked = false; },
+
+
+ isLocked: function() { return this.locked; },
+
+
+ locationCache: {},
+
+
+ useCache: true,
+
+
+ clickPixelThresh: 3,
+
+
+ clickTimeThresh: 350,
+
+
+ dragThreshMet: false,
+
+
+ clickTimeout: null,
+
+
+ startX: 0,
+
+
+ startY: 0,
+
+
+ regDragDrop: function(oDD, sGroup) {
+ if (!this.initialized) { this.init(); }
+
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+ this.ids[sGroup][oDD.id] = oDD;
+ },
+
+
+ removeDDFromGroup: function(oDD, sGroup) {
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+
+ var obj = this.ids[sGroup];
+ if (obj && obj[oDD.id]) {
+ delete obj[oDD.id];
+ }
+ },
+
+
+ _remove: function(oDD) {
+ for (var g in oDD.groups) {
+ if (g && this.ids[g] && this.ids[g][oDD.id]) {
+ delete this.ids[g][oDD.id];
+ }
+ }
+ delete this.handleIds[oDD.id];
+ },
+
+
+ regHandle: function(sDDId, sHandleId) {
+ if (!this.handleIds[sDDId]) {
+ this.handleIds[sDDId] = {};
+ }
+ this.handleIds[sDDId][sHandleId] = sHandleId;
+ },
+
+
+ isDragDrop: function(id) {
+ return ( this.getDDById(id) ) ? true : false;
+ },
+
+
+ getRelated: function(p_oDD, bTargetsOnly) {
+ var oDDs = [];
+ for (var i in p_oDD.groups) {
+ for (var j in this.ids[i]) {
+ var dd = this.ids[i][j];
+ if (! this.isTypeOfDD(dd)) {
+ continue;
+ }
+ if (!bTargetsOnly || dd.isTarget) {
+ oDDs[oDDs.length] = dd;
+ }
+ }
+ }
+
+ return oDDs;
+ },
+
+
+ isLegalTarget: function (oDD, oTargetDD) {
+ var targets = this.getRelated(oDD, true);
+ for (var i=0, len=targets.length;i<len;++i) {
+ if (targets[i].id == oTargetDD.id) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+
+ isTypeOfDD: function (oDD) {
+ return (oDD && oDD.__ygDragDrop);
+ },
+
+
+ isHandle: function(sDDId, sHandleId) {
+ return ( this.handleIds[sDDId] &&
+ this.handleIds[sDDId][sHandleId] );
+ },
+
+
+ getDDById: function(id) {
+ for (var i in this.ids) {
+ if (this.ids[i][id]) {
+ return this.ids[i][id];
+ }
+ }
+ return null;
+ },
+
+
+ handleMouseDown: function(e, oDD) {
+ if(Ext.QuickTips){
+ Ext.QuickTips.ddDisable();
+ }
+ if(this.dragCurrent){
+
+
+ this.handleMouseUp(e);
+ }
+
+ this.currentTarget = e.getTarget();
+ this.dragCurrent = oDD;
+
+ var el = oDD.getEl();
+
+
+ this.startX = e.getPageX();
+ this.startY = e.getPageY();
+
+ this.deltaX = this.startX - el.offsetLeft;
+ this.deltaY = this.startY - el.offsetTop;
+
+ this.dragThreshMet = false;
+
+ this.clickTimeout = setTimeout(
+ function() {
+ var DDM = Ext.dd.DDM;
+ DDM.startDrag(DDM.startX, DDM.startY);
+ },
+ this.clickTimeThresh );
+ },
+
+
+ startDrag: function(x, y) {
+ clearTimeout(this.clickTimeout);
+ if (this.dragCurrent) {
+ this.dragCurrent.b4StartDrag(x, y);
+ this.dragCurrent.startDrag(x, y);
+ }
+ this.dragThreshMet = true;
+ },
+
+
+ handleMouseUp: function(e) {
+
+ if(Ext.QuickTips){
+ Ext.QuickTips.ddEnable();
+ }
+ if (! this.dragCurrent) {
+ return;
+ }
+
+ clearTimeout(this.clickTimeout);
+
+ if (this.dragThreshMet) {
+ this.fireEvents(e, true);
+ } else {
+ }
+
+ this.stopDrag(e);
+
+ this.stopEvent(e);
+ },
+
+
+ stopEvent: function(e){
+ if(this.stopPropagation) {
+ e.stopPropagation();
+ }
+
+ if (this.preventDefault) {
+ e.preventDefault();
+ }
+ },
+
+
+ stopDrag: function(e) {
+
+ if (this.dragCurrent) {
+ if (this.dragThreshMet) {
+ this.dragCurrent.b4EndDrag(e);
+ this.dragCurrent.endDrag(e);
+ }
+
+ this.dragCurrent.onMouseUp(e);
+ }
+
+ this.dragCurrent = null;
+ this.dragOvers = {};
+ },
+
+
+ handleMouseMove: function(e) {
+ if (! this.dragCurrent) {
+ return true;
+ }
+
+
+
+ if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
+ this.stopEvent(e);
+ return this.handleMouseUp(e);
+ }
+
+ if (!this.dragThreshMet) {
+ var diffX = Math.abs(this.startX - e.getPageX());
+ var diffY = Math.abs(this.startY - e.getPageY());
+ if (diffX > this.clickPixelThresh ||
+ diffY > this.clickPixelThresh) {
+ this.startDrag(this.startX, this.startY);
+ }
+ }
+
+ if (this.dragThreshMet) {
+ this.dragCurrent.b4Drag(e);
+ this.dragCurrent.onDrag(e);
+ if(!this.dragCurrent.moveOnly){
+ this.fireEvents(e, false);
+ }
+ }
+
+ this.stopEvent(e);
+
+ return true;
+ },
+
+
+ fireEvents: function(e, isDrop) {
+ var dc = this.dragCurrent;
+
+
+
+ if (!dc || dc.isLocked()) {
+ return;
+ }
+
+ var pt = e.getPoint();
+
+
+ var oldOvers = [];
+
+ var outEvts = [];
+ var overEvts = [];
+ var dropEvts = [];
+ var enterEvts = [];
+
+
+
+ for (var i in this.dragOvers) {
+
+ var ddo = this.dragOvers[i];
+
+ if (! this.isTypeOfDD(ddo)) {
+ continue;
+ }
+
+ if (! this.isOverTarget(pt, ddo, this.mode)) {
+ outEvts.push( ddo );
+ }
+
+ oldOvers[i] = true;
+ delete this.dragOvers[i];
+ }
+
+ for (var sGroup in dc.groups) {
+
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+
+ for (i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+
+ if (oDD.isTarget && !oDD.isLocked() && ((oDD != dc) || (dc.ignoreSelf === false))) {
+ if (this.isOverTarget(pt, oDD, this.mode)) {
+
+ if (isDrop) {
+ dropEvts.push( oDD );
+
+ } else {
+
+
+ if (!oldOvers[oDD.id]) {
+ enterEvts.push( oDD );
+
+ } else {
+ overEvts.push( oDD );
+ }
+
+ this.dragOvers[oDD.id] = oDD;
+ }
+ }
+ }
+ }
+ }
+
+ if (this.mode) {
+ if (outEvts.length) {
+ dc.b4DragOut(e, outEvts);
+ dc.onDragOut(e, outEvts);
+ }
+
+ if (enterEvts.length) {
+ dc.onDragEnter(e, enterEvts);
+ }
+
+ if (overEvts.length) {
+ dc.b4DragOver(e, overEvts);
+ dc.onDragOver(e, overEvts);
+ }
+
+ if (dropEvts.length) {
+ dc.b4DragDrop(e, dropEvts);
+ dc.onDragDrop(e, dropEvts);
+ }
+
+ } else {
+
+ var len = 0;
+ for (i=0, len=outEvts.length; i<len; ++i) {
+ dc.b4DragOut(e, outEvts[i].id);
+ dc.onDragOut(e, outEvts[i].id);
+ }
+
+
+ for (i=0,len=enterEvts.length; i<len; ++i) {
+
+ dc.onDragEnter(e, enterEvts[i].id);
+ }
+
+
+ for (i=0,len=overEvts.length; i<len; ++i) {
+ dc.b4DragOver(e, overEvts[i].id);
+ dc.onDragOver(e, overEvts[i].id);
+ }
+
+
+ for (i=0, len=dropEvts.length; i<len; ++i) {
+ dc.b4DragDrop(e, dropEvts[i].id);
+ dc.onDragDrop(e, dropEvts[i].id);
+ }
+
+ }
+
+
+ if (isDrop && !dropEvts.length) {
+ dc.onInvalidDrop(e);
+ }
+
+ },
+
+
+ getBestMatch: function(dds) {
+ var winner = null;
+
+
+
+
+
+
+ var len = dds.length;
+
+ if (len == 1) {
+ winner = dds[0];
+ } else {
+
+ for (var i=0; i<len; ++i) {
+ var dd = dds[i];
+
+
+
+ if (dd.cursorIsOver) {
+ winner = dd;
+ break;
+
+ } else {
+ if (!winner ||
+ winner.overlap.getArea() < dd.overlap.getArea()) {
+ winner = dd;
+ }
+ }
+ }
+ }
+
+ return winner;
+ },
+
+
+ refreshCache: function(groups) {
+ for (var sGroup in groups) {
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+ for (var i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+
+ if (this.isTypeOfDD(oDD)) {
+
+ var loc = this.getLocation(oDD);
+ if (loc) {
+ this.locationCache[oDD.id] = loc;
+ } else {
+ delete this.locationCache[oDD.id];
+
+
+
+ }
+ }
+ }
+ }
+ },
+
+
+ verifyEl: function(el) {
+ if (el) {
+ var parent;
+ if(Ext.isIE){
+ try{
+ parent = el.offsetParent;
+ }catch(e){}
+ }else{
+ parent = el.offsetParent;
+ }
+ if (parent) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+
+ getLocation: function(oDD) {
+ if (! this.isTypeOfDD(oDD)) {
+ return null;
+ }
+
+ var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
+
+ try {
+ pos= Ext.lib.Dom.getXY(el);
+ } catch (e) { }
+
+ if (!pos) {
+ return null;
+ }
+
+ x1 = pos[0];
+ x2 = x1 + el.offsetWidth;
+ y1 = pos[1];
+ y2 = y1 + el.offsetHeight;
+
+ t = y1 - oDD.padding[0];
+ r = x2 + oDD.padding[1];
+ b = y2 + oDD.padding[2];
+ l = x1 - oDD.padding[3];
+
+ return new Ext.lib.Region( t, r, b, l );
+ },
+
+
+ isOverTarget: function(pt, oTarget, intersect) {
+
+ var loc = this.locationCache[oTarget.id];
+ if (!loc || !this.useCache) {
+ loc = this.getLocation(oTarget);
+ this.locationCache[oTarget.id] = loc;
+
+ }
+
+ if (!loc) {
+ return false;
+ }
+
+ oTarget.cursorIsOver = loc.contains( pt );
+
+
+
+
+
+
+ var dc = this.dragCurrent;
+ if (!dc || !dc.getTargetCoord ||
+ (!intersect && !dc.constrainX && !dc.constrainY)) {
+ return oTarget.cursorIsOver;
+ }
+
+ oTarget.overlap = null;
+
+
+
+
+
+ var pos = dc.getTargetCoord(pt.x, pt.y);
+
+ var el = dc.getDragEl();
+ var curRegion = new Ext.lib.Region( pos.y,
+ pos.x + el.offsetWidth,
+ pos.y + el.offsetHeight,
+ pos.x );
+
+ var overlap = curRegion.intersect(loc);
+
+ if (overlap) {
+ oTarget.overlap = overlap;
+ return (intersect) ? true : oTarget.cursorIsOver;
+ } else {
+ return false;
+ }
+ },
+
+
+ _onUnload: function(e, me) {
+ Ext.dd.DragDropMgr.unregAll();
+ },
+
+
+ unregAll: function() {
+
+ if (this.dragCurrent) {
+ this.stopDrag();
+ this.dragCurrent = null;
+ }
+
+ this._execOnAll("unreg", []);
+
+ for (var i in this.elementCache) {
+ delete this.elementCache[i];
+ }
+
+ this.elementCache = {};
+ this.ids = {};
+ },
+
+
+ elementCache: {},
+
+
+ getElWrapper: function(id) {
+ var oWrapper = this.elementCache[id];
+ if (!oWrapper || !oWrapper.el) {
+ oWrapper = this.elementCache[id] =
+ new this.ElementWrapper(Ext.getDom(id));
+ }
+ return oWrapper;
+ },
+
+
+ getElement: function(id) {
+ return Ext.getDom(id);
+ },
+
+
+ getCss: function(id) {
+ var el = Ext.getDom(id);
+ return (el) ? el.style : null;
+ },
+
+
+ ElementWrapper: function(el) {
+
+ this.el = el || null;
+
+ this.id = this.el && el.id;
+
+ this.css = this.el && el.style;
+ },
+
+
+ getPosX: function(el) {
+ return Ext.lib.Dom.getX(el);
+ },
+
+
+ getPosY: function(el) {
+ return Ext.lib.Dom.getY(el);
+ },
+
+
+ swapNode: function(n1, n2) {
+ if (n1.swapNode) {
+ n1.swapNode(n2);
+ } else {
+ var p = n2.parentNode;
+ var s = n2.nextSibling;
+
+ if (s == n1) {
+ p.insertBefore(n1, n2);
+ } else if (n2 == n1.nextSibling) {
+ p.insertBefore(n2, n1);
+ } else {
+ n1.parentNode.replaceChild(n2, n1);
+ p.insertBefore(n1, s);
+ }
+ }
+ },
+
+
+ getScroll: function () {
+ var t, l, dde=document.documentElement, db=document.body;
+ if (dde && (dde.scrollTop || dde.scrollLeft)) {
+ t = dde.scrollTop;
+ l = dde.scrollLeft;
+ } else if (db) {
+ t = db.scrollTop;
+ l = db.scrollLeft;
+ } else {
+
+ }
+ return { top: t, left: l };
+ },
+
+
+ getStyle: function(el, styleProp) {
+ return Ext.fly(el).getStyle(styleProp);
+ },
+
+
+ getScrollTop: function () {
+ return this.getScroll().top;
+ },
+
+
+ getScrollLeft: function () {
+ return this.getScroll().left;
+ },
+
+
+ moveToEl: function (moveEl, targetEl) {
+ var aCoord = Ext.lib.Dom.getXY(targetEl);
+ Ext.lib.Dom.setXY(moveEl, aCoord);
+ },
+
+
+ numericSort: function(a, b) {
+ return (a - b);
+ },
+
+
+ _timeoutCount: 0,
+
+
+ _addListeners: function() {
+ var DDM = Ext.dd.DDM;
+ if ( Ext.lib.Event && document ) {
+ DDM._onLoad();
+ } else {
+ if (DDM._timeoutCount > 2000) {
+ } else {
+ setTimeout(DDM._addListeners, 10);
+ if (document && document.body) {
+ DDM._timeoutCount += 1;
+ }
+ }
+ }
+ },
+
+
+ handleWasClicked: function(node, id) {
+ if (this.isHandle(id, node.id)) {
+ return true;
+ } else {
+
+ var p = node.parentNode;
+
+ while (p) {
+ if (this.isHandle(id, p.id)) {
+ return true;
+ } else {
+ p = p.parentNode;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ };
+
+}();
+
+
+Ext.dd.DDM = Ext.dd.DragDropMgr;
+Ext.dd.DDM._addListeners();
+
+}
+
+
+Ext.dd.DD = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
+
+
+ scroll: true,
+
+
+ autoOffset: function(iPageX, iPageY) {
+ var x = iPageX - this.startPageX;
+ var y = iPageY - this.startPageY;
+ this.setDelta(x, y);
+ },
+
+
+ setDelta: function(iDeltaX, iDeltaY) {
+ this.deltaX = iDeltaX;
+ this.deltaY = iDeltaY;
+ },
+
+
+ setDragElPos: function(iPageX, iPageY) {
+
+
+
+ var el = this.getDragEl();
+ this.alignElWithMouse(el, iPageX, iPageY);
+ },
+
+
+ alignElWithMouse: function(el, iPageX, iPageY) {
+ var oCoord = this.getTargetCoord(iPageX, iPageY);
+ var fly = el.dom ? el : Ext.fly(el, '_dd');
+ if (!this.deltaSetXY) {
+ var aCoord = [oCoord.x, oCoord.y];
+ fly.setXY(aCoord);
+ var newLeft = fly.getLeft(true);
+ var newTop = fly.getTop(true);
+ this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
+ } else {
+ fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
+ }
+
+ this.cachePosition(oCoord.x, oCoord.y);
+ this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
+ return oCoord;
+ },
+
+
+ cachePosition: function(iPageX, iPageY) {
+ if (iPageX) {
+ this.lastPageX = iPageX;
+ this.lastPageY = iPageY;
+ } else {
+ var aCoord = Ext.lib.Dom.getXY(this.getEl());
+ this.lastPageX = aCoord[0];
+ this.lastPageY = aCoord[1];
+ }
+ },
+
+
+ autoScroll: function(x, y, h, w) {
+
+ if (this.scroll) {
+
+ var clientH = Ext.lib.Dom.getViewHeight();
+
+
+ var clientW = Ext.lib.Dom.getViewWidth();
+
+
+ var st = this.DDM.getScrollTop();
+
+
+ var sl = this.DDM.getScrollLeft();
+
+
+ var bot = h + y;
+
+
+ var right = w + x;
+
+
+
+
+ var toBot = (clientH + st - y - this.deltaY);
+
+
+ var toRight = (clientW + sl - x - this.deltaX);
+
+
+
+
+ var thresh = 40;
+
+
+
+
+ var scrAmt = (document.all) ? 80 : 30;
+
+
+
+ if ( bot > clientH && toBot < thresh ) {
+ window.scrollTo(sl, st + scrAmt);
+ }
+
+
+
+ if ( y < st && st > 0 && y - st < thresh ) {
+ window.scrollTo(sl, st - scrAmt);
+ }
+
+
+
+ if ( right > clientW && toRight < thresh ) {
+ window.scrollTo(sl + scrAmt, st);
+ }
+
+
+
+ if ( x < sl && sl > 0 && x - sl < thresh ) {
+ window.scrollTo(sl - scrAmt, st);
+ }
+ }
+ },
+
+
+ getTargetCoord: function(iPageX, iPageY) {
+ var x = iPageX - this.deltaX;
+ var y = iPageY - this.deltaY;
+
+ if (this.constrainX) {
+ if (x < this.minX) { x = this.minX; }
+ if (x > this.maxX) { x = this.maxX; }
+ }
+
+ if (this.constrainY) {
+ if (y < this.minY) { y = this.minY; }
+ if (y > this.maxY) { y = this.maxY; }
+ }
+
+ x = this.getTick(x, this.xTicks);
+ y = this.getTick(y, this.yTicks);
+
+
+ return {x:x, y:y};
+ },
+
+
+ applyConfig: function() {
+ Ext.dd.DD.superclass.applyConfig.call(this);
+ this.scroll = (this.config.scroll !== false);
+ },
+
+
+ b4MouseDown: function(e) {
+
+ this.autoOffset(e.getPageX(),
+ e.getPageY());
+ },
+
+
+ b4Drag: function(e) {
+ this.setDragElPos(e.getPageX(),
+ e.getPageY());
+ },
+
+ toString: function() {
+ return ("DD " + this.id);
+ }
+
+
+
+
+
+
+});
+
+Ext.dd.DDProxy = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ this.initFrame();
+ }
+};
+
+
+Ext.dd.DDProxy.dragElId = "ygddfdiv";
+
+Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
+
+
+ resizeFrame: true,
+
+
+ centerFrame: false,
+
+
+ createFrame: function() {
+ var self = this;
+ var body = document.body;
+
+ if (!body || !body.firstChild) {
+ setTimeout( function() { self.createFrame(); }, 50 );
+ return;
+ }
+
+ var div = this.getDragEl();
+
+ if (!div) {
+ div = document.createElement("div");
+ div.id = this.dragElId;
+ var s = div.style;
+
+ s.position = "absolute";
+ s.visibility = "hidden";
+ s.cursor = "move";
+ s.border = "2px solid #aaa";
+ s.zIndex = 999;
+
+
+
+
+ body.insertBefore(div, body.firstChild);
+ }
+ },
+
+
+ initFrame: function() {
+ this.createFrame();
+ },
+
+ applyConfig: function() {
+ Ext.dd.DDProxy.superclass.applyConfig.call(this);
+
+ this.resizeFrame = (this.config.resizeFrame !== false);
+ this.centerFrame = (this.config.centerFrame);
+ this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
+ },
+
+
+ showFrame: function(iPageX, iPageY) {
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+ var s = dragEl.style;
+
+ this._resizeProxy();
+
+ if (this.centerFrame) {
+ this.setDelta( Math.round(parseInt(s.width, 10)/2),
+ Math.round(parseInt(s.height, 10)/2) );
+ }
+
+ this.setDragElPos(iPageX, iPageY);
+
+ Ext.fly(dragEl).show();
+ },
+
+
+ _resizeProxy: function() {
+ if (this.resizeFrame) {
+ var el = this.getEl();
+ Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
+ }
+ },
+
+
+ b4MouseDown: function(e) {
+ var x = e.getPageX();
+ var y = e.getPageY();
+ this.autoOffset(x, y);
+ this.setDragElPos(x, y);
+ },
+
+
+ b4StartDrag: function(x, y) {
+
+ this.showFrame(x, y);
+ },
+
+
+ b4EndDrag: function(e) {
+ Ext.fly(this.getDragEl()).hide();
+ },
+
+
+
+
+ endDrag: function(e) {
+
+ var lel = this.getEl();
+ var del = this.getDragEl();
+
+
+ del.style.visibility = "";
+
+ this.beforeMove();
+
+
+ lel.style.visibility = "hidden";
+ Ext.dd.DDM.moveToEl(lel, del);
+ del.style.visibility = "hidden";
+ lel.style.visibility = "";
+
+ this.afterDrag();
+ },
+
+ beforeMove : function(){
+
+ },
+
+ afterDrag : function(){
+
+ },
+
+ toString: function() {
+ return ("DDProxy " + this.id);
+ }
+
+});
+
+Ext.dd.DDTarget = function(id, sGroup, config) {
+ if (id) {
+ this.initTarget(id, sGroup, config);
+ }
+};
+
+
+Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
+
+ getDragEl: Ext.emptyFn,
+
+ isValidHandleChild: Ext.emptyFn,
+
+ startDrag: Ext.emptyFn,
+
+ endDrag: Ext.emptyFn,
+
+ onDrag: Ext.emptyFn,
+
+ onDragDrop: Ext.emptyFn,
+
+ onDragEnter: Ext.emptyFn,
+
+ onDragOut: Ext.emptyFn,
+
+ onDragOver: Ext.emptyFn,
+
+ onInvalidDrop: Ext.emptyFn,
+
+ onMouseDown: Ext.emptyFn,
+
+ onMouseUp: Ext.emptyFn,
+
+ setXConstraint: Ext.emptyFn,
+
+ setYConstraint: Ext.emptyFn,
+
+ resetConstraints: Ext.emptyFn,
+
+ clearConstraints: Ext.emptyFn,
+
+ clearTicks: Ext.emptyFn,
+
+ setInitPosition: Ext.emptyFn,
+
+ setDragElId: Ext.emptyFn,
+
+ setHandleElId: Ext.emptyFn,
+
+ setOuterHandleElId: Ext.emptyFn,
+
+ addInvalidHandleClass: Ext.emptyFn,
+
+ addInvalidHandleId: Ext.emptyFn,
+
+ addInvalidHandleType: Ext.emptyFn,
+
+ removeInvalidHandleClass: Ext.emptyFn,
+
+ removeInvalidHandleId: Ext.emptyFn,
+
+ removeInvalidHandleType: Ext.emptyFn,
+
+ toString: function() {
+ return ("DDTarget " + this.id);
+ }
+});
+Ext.dd.DragTracker = Ext.extend(Ext.util.Observable, {
+
+ active: false,
+
+ tolerance: 5,
+
+ autoStart: false,
+
+ constructor : function(config){
+ Ext.apply(this, config);
+ this.addEvents(
+
+ 'mousedown',
+
+ 'mouseup',
+
+ 'mousemove',
+
+ 'dragstart',
+
+ 'dragend',
+
+ 'drag'
+ );
+
+ this.dragRegion = new Ext.lib.Region(0,0,0,0);
+
+ if(this.el){
+ this.initEl(this.el);
+ }
+ Ext.dd.DragTracker.superclass.constructor.call(this, config);
+ },
+
+ initEl: function(el){
+ this.el = Ext.get(el);
+ el.on('mousedown', this.onMouseDown, this,
+ this.delegate ? {delegate: this.delegate} : undefined);
+ },
+
+ destroy : function(){
+ this.el.un('mousedown', this.onMouseDown, this);
+ delete this.el;
+ },
+
+ onMouseDown: function(e, target){
+ if(this.fireEvent('mousedown', this, e) !== false && this.onBeforeStart(e) !== false){
+ this.startXY = this.lastXY = e.getXY();
+ this.dragTarget = this.delegate ? target : this.el.dom;
+ if(this.preventDefault !== false){
+ e.preventDefault();
+ }
+ Ext.getDoc().on({
+ scope: this,
+ mouseup: this.onMouseUp,
+ mousemove: this.onMouseMove,
+ selectstart: this.stopSelect
+ });
+ if(this.autoStart){
+ this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this, [e]);
+ }
+ }
+ },
+
+ onMouseMove: function(e, target){
+
+ if(this.active && Ext.isIE && !e.browserEvent.button){
+ e.preventDefault();
+ this.onMouseUp(e);
+ return;
+ }
+
+ e.preventDefault();
+ var xy = e.getXY(), s = this.startXY;
+ this.lastXY = xy;
+ if(!this.active){
+ if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
+ this.triggerStart(e);
+ }else{
+ return;
+ }
+ }
+ this.fireEvent('mousemove', this, e);
+ this.onDrag(e);
+ this.fireEvent('drag', this, e);
+ },
+
+ onMouseUp: function(e) {
+ var doc = Ext.getDoc(),
+ wasActive = this.active;
+
+ doc.un('mousemove', this.onMouseMove, this);
+ doc.un('mouseup', this.onMouseUp, this);
+ doc.un('selectstart', this.stopSelect, this);
+ e.preventDefault();
+ this.clearStart();
+ this.active = false;
+ delete this.elRegion;
+ this.fireEvent('mouseup', this, e);
+ if(wasActive){
+ this.onEnd(e);
+ this.fireEvent('dragend', this, e);
+ }
+ },
+
+ triggerStart: function(e) {
+ this.clearStart();
+ this.active = true;
+ this.onStart(e);
+ this.fireEvent('dragstart', this, e);
+ },
+
+ clearStart : function() {
+ if(this.timer){
+ clearTimeout(this.timer);
+ delete this.timer;
+ }
+ },
+
+ stopSelect : function(e) {
+ e.stopEvent();
+ return false;
+ },
+
+
+ onBeforeStart : function(e) {
+
+ },
+
+
+ onStart : function(xy) {
+
+ },
+
+
+ onDrag : function(e) {
+
+ },
+
+
+ onEnd : function(e) {
+
+ },
+
+
+ getDragTarget : function(){
+ return this.dragTarget;
+ },
+
+ getDragCt : function(){
+ return this.el;
+ },
+
+ getXY : function(constrain){
+ return constrain ?
+ this.constrainModes[constrain].call(this, this.lastXY) : this.lastXY;
+ },
+
+ getOffset : function(constrain){
+ var xy = this.getXY(constrain),
+ s = this.startXY;
+ return [s[0]-xy[0], s[1]-xy[1]];
+ },
+
+ constrainModes: {
+ 'point' : function(xy){
+
+ if(!this.elRegion){
+ this.elRegion = this.getDragCt().getRegion();
+ }
+
+ var dr = this.dragRegion;
+
+ dr.left = xy[0];
+ dr.top = xy[1];
+ dr.right = xy[0];
+ dr.bottom = xy[1];
+
+ dr.constrainTo(this.elRegion);
+
+ return [dr.left, dr.top];
+ }
+ }
+});
+Ext.dd.ScrollManager = function(){
+ var ddm = Ext.dd.DragDropMgr;
+ var els = {};
+ var dragEl = null;
+ var proc = {};
+
+ var onStop = function(e){
+ dragEl = null;
+ clearProc();
+ };
+
+ var triggerRefresh = function(){
+ if(ddm.dragCurrent){
+ ddm.refreshCache(ddm.dragCurrent.groups);
+ }
+ };
+
+ var doScroll = function(){
+ if(ddm.dragCurrent){
+ var dds = Ext.dd.ScrollManager;
+ var inc = proc.el.ddScrollConfig ?
+ proc.el.ddScrollConfig.increment : dds.increment;
+ if(!dds.animate){
+ if(proc.el.scroll(proc.dir, inc)){
+ triggerRefresh();
+ }
+ }else{
+ proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
+ }
+ }
+ };
+
+ var clearProc = function(){
+ if(proc.id){
+ clearInterval(proc.id);
+ }
+ proc.id = 0;
+ proc.el = null;
+ proc.dir = "";
+ };
+
+ var startProc = function(el, dir){
+ clearProc();
+ proc.el = el;
+ proc.dir = dir;
+ var group = el.ddScrollConfig ? el.ddScrollConfig.ddGroup : undefined,
+ freq = (el.ddScrollConfig && el.ddScrollConfig.frequency)
+ ? el.ddScrollConfig.frequency
+ : Ext.dd.ScrollManager.frequency;
+
+ if (group === undefined || ddm.dragCurrent.ddGroup == group) {
+ proc.id = setInterval(doScroll, freq);
+ }
+ };
+
+ var onFire = function(e, isDrop){
+ if(isDrop || !ddm.dragCurrent){ return; }
+ var dds = Ext.dd.ScrollManager;
+ if(!dragEl || dragEl != ddm.dragCurrent){
+ dragEl = ddm.dragCurrent;
+
+ dds.refreshCache();
+ }
+
+ var xy = Ext.lib.Event.getXY(e);
+ var pt = new Ext.lib.Point(xy[0], xy[1]);
+ for(var id in els){
+ var el = els[id], r = el._region;
+ var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
+ if(r && r.contains(pt) && el.isScrollable()){
+ if(r.bottom - pt.y <= c.vthresh){
+ if(proc.el != el){
+ startProc(el, "down");
+ }
+ return;
+ }else if(r.right - pt.x <= c.hthresh){
+ if(proc.el != el){
+ startProc(el, "left");
+ }
+ return;
+ }else if(pt.y - r.top <= c.vthresh){
+ if(proc.el != el){
+ startProc(el, "up");
+ }
+ return;
+ }else if(pt.x - r.left <= c.hthresh){
+ if(proc.el != el){
+ startProc(el, "right");
+ }
+ return;
+ }
+ }
+ }
+ clearProc();
+ };
+
+ ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
+ ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
+
+ return {
+
+ register : function(el){
+ if(Ext.isArray(el)){
+ for(var i = 0, len = el.length; i < len; i++) {
+ this.register(el[i]);
+ }
+ }else{
+ el = Ext.get(el);
+ els[el.id] = el;
+ }
+ },
+
+
+ unregister : function(el){
+ if(Ext.isArray(el)){
+ for(var i = 0, len = el.length; i < len; i++) {
+ this.unregister(el[i]);
+ }
+ }else{
+ el = Ext.get(el);
+ delete els[el.id];
+ }
+ },
+
+
+ vthresh : 25,
+
+ hthresh : 25,
+
+
+ increment : 100,
+
+
+ frequency : 500,
+
+
+ animate: true,
+
+
+ animDuration: .4,
+
+
+ ddGroup: undefined,
+
+
+ refreshCache : function(){
+ for(var id in els){
+ if(typeof els[id] == 'object'){
+ els[id]._region = els[id].getRegion();
+ }
+ }
+ }
+ };
+}();
+Ext.dd.Registry = function(){
+ var elements = {};
+ var handles = {};
+ var autoIdSeed = 0;
+
+ var getId = function(el, autogen){
+ if(typeof el == "string"){
+ return el;
+ }
+ var id = el.id;
+ if(!id && autogen !== false){
+ id = "extdd-" + (++autoIdSeed);
+ el.id = id;
+ }
+ return id;
+ };
+
+ return {
+
+ register : function(el, data){
+ data = data || {};
+ if(typeof el == "string"){
+ el = document.getElementById(el);
+ }
+ data.ddel = el;
+ elements[getId(el)] = data;
+ if(data.isHandle !== false){
+ handles[data.ddel.id] = data;
+ }
+ if(data.handles){
+ var hs = data.handles;
+ for(var i = 0, len = hs.length; i < len; i++){
+ handles[getId(hs[i])] = data;
+ }
+ }
+ },
+
+
+ unregister : function(el){
+ var id = getId(el, false);
+ var data = elements[id];
+ if(data){
+ delete elements[id];
+ if(data.handles){
+ var hs = data.handles;
+ for(var i = 0, len = hs.length; i < len; i++){
+ delete handles[getId(hs[i], false)];
+ }
+ }
+ }
+ },
+
+
+ getHandle : function(id){
+ if(typeof id != "string"){
+ id = id.id;
+ }
+ return handles[id];
+ },
+
+
+ getHandleFromEvent : function(e){
+ var t = Ext.lib.Event.getTarget(e);
+ return t ? handles[t.id] : null;
+ },
+
+
+ getTarget : function(id){
+ if(typeof id != "string"){
+ id = id.id;
+ }
+ return elements[id];
+ },
+
+
+ getTargetFromEvent : function(e){
+ var t = Ext.lib.Event.getTarget(e);
+ return t ? elements[t.id] || handles[t.id] : null;
+ }
+ };
+}();
+Ext.dd.StatusProxy = function(config){
+ Ext.apply(this, config);
+ this.id = this.id || Ext.id();
+ this.el = new Ext.Layer({
+ dh: {
+ id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
+ {tag: "div", cls: "x-dd-drop-icon"},
+ {tag: "div", cls: "x-dd-drag-ghost"}
+ ]
+ },
+ shadow: !config || config.shadow !== false
+ });
+ this.ghost = Ext.get(this.el.dom.childNodes[1]);
+ this.dropStatus = this.dropNotAllowed;
+};
+
+Ext.dd.StatusProxy.prototype = {
+
+ dropAllowed : "x-dd-drop-ok",
+
+ dropNotAllowed : "x-dd-drop-nodrop",
+
+
+ setStatus : function(cssClass){
+ cssClass = cssClass || this.dropNotAllowed;
+ if(this.dropStatus != cssClass){
+ this.el.replaceClass(this.dropStatus, cssClass);
+ this.dropStatus = cssClass;
+ }
+ },
+
+
+ reset : function(clearGhost){
+ this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
+ this.dropStatus = this.dropNotAllowed;
+ if(clearGhost){
+ this.ghost.update("");
+ }
+ },
+
+
+ update : function(html){
+ if(typeof html == "string"){
+ this.ghost.update(html);
+ }else{
+ this.ghost.update("");
+ html.style.margin = "0";
+ this.ghost.dom.appendChild(html);
+ }
+ var el = this.ghost.dom.firstChild;
+ if(el){
+ Ext.fly(el).setStyle('float', 'none');
+ }
+ },
+
+
+ getEl : function(){
+ return this.el;
+ },
+
+
+ getGhost : function(){
+ return this.ghost;
+ },
+
+
+ hide : function(clear){
+ this.el.hide();
+ if(clear){
+ this.reset(true);
+ }
+ },
+
+
+ stop : function(){
+ if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
+ this.anim.stop();
+ }
+ },
+
+
+ show : function(){
+ this.el.show();
+ },
+
+
+ sync : function(){
+ this.el.sync();
+ },
+
+
+ repair : function(xy, callback, scope){
+ this.callback = callback;
+ this.scope = scope;
+ if(xy && this.animRepair !== false){
+ this.el.addClass("x-dd-drag-repair");
+ this.el.hideUnders(true);
+ this.anim = this.el.shift({
+ duration: this.repairDuration || .5,
+ easing: 'easeOut',
+ xy: xy,
+ stopFx: true,
+ callback: this.afterRepair,
+ scope: this
+ });
+ }else{
+ this.afterRepair();
+ }
+ },
+
+
+ afterRepair : function(){
+ this.hide(true);
+ if(typeof this.callback == "function"){
+ this.callback.call(this.scope || this);
+ }
+ this.callback = null;
+ this.scope = null;
+ },
+
+ destroy: function(){
+ Ext.destroy(this.ghost, this.el);
+ }
+};
+Ext.dd.DragSource = function(el, config){
+ this.el = Ext.get(el);
+ if(!this.dragData){
+ this.dragData = {};
+ }
+
+ Ext.apply(this, config);
+
+ if(!this.proxy){
+ this.proxy = new Ext.dd.StatusProxy();
+ }
+ Ext.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
+ {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
+
+ this.dragging = false;
+};
+
+Ext.extend(Ext.dd.DragSource, Ext.dd.DDProxy, {
+
+
+ dropAllowed : "x-dd-drop-ok",
+
+ dropNotAllowed : "x-dd-drop-nodrop",
+
+
+ getDragData : function(e){
+ return this.dragData;
+ },
+
+
+ onDragEnter : function(e, id){
+ var target = Ext.dd.DragDropMgr.getDDById(id);
+ this.cachedTarget = target;
+ if(this.beforeDragEnter(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ var status = target.notifyEnter(this, e, this.dragData);
+ this.proxy.setStatus(status);
+ }else{
+ this.proxy.setStatus(this.dropAllowed);
+ }
+
+ if(this.afterDragEnter){
+
+ this.afterDragEnter(target, e, id);
+ }
+ }
+ },
+
+
+ beforeDragEnter : function(target, e, id){
+ return true;
+ },
+
+
+ alignElWithMouse: function() {
+ Ext.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
+ this.proxy.sync();
+ },
+
+
+ onDragOver : function(e, id){
+ var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
+ if(this.beforeDragOver(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ var status = target.notifyOver(this, e, this.dragData);
+ this.proxy.setStatus(status);
+ }
+
+ if(this.afterDragOver){
+
+ this.afterDragOver(target, e, id);
+ }
+ }
+ },
+
+
+ beforeDragOver : function(target, e, id){
+ return true;
+ },
+
+
+ onDragOut : function(e, id){
+ var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
+ if(this.beforeDragOut(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ target.notifyOut(this, e, this.dragData);
+ }
+ this.proxy.reset();
+ if(this.afterDragOut){
+
+ this.afterDragOut(target, e, id);
+ }
+ }
+ this.cachedTarget = null;
+ },
+
+
+ beforeDragOut : function(target, e, id){
+ return true;
+ },
+
+
+ onDragDrop : function(e, id){
+ var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
+ if(this.beforeDragDrop(target, e, id) !== false){
+ if(target.isNotifyTarget){
+ if(target.notifyDrop(this, e, this.dragData)){
+ this.onValidDrop(target, e, id);
+ }else{
+ this.onInvalidDrop(target, e, id);
+ }
+ }else{
+ this.onValidDrop(target, e, id);
+ }
+
+ if(this.afterDragDrop){
+
+ this.afterDragDrop(target, e, id);
+ }
+ }
+ delete this.cachedTarget;
+ },
+
+
+ beforeDragDrop : function(target, e, id){
+ return true;
+ },
+
+
+ onValidDrop : function(target, e, id){
+ this.hideProxy();
+ if(this.afterValidDrop){
+
+ this.afterValidDrop(target, e, id);
+ }
+ },
+
+
+ getRepairXY : function(e, data){
+ return this.el.getXY();
+ },
+
+
+ onInvalidDrop : function(target, e, id){
+ this.beforeInvalidDrop(target, e, id);
+ if(this.cachedTarget){
+ if(this.cachedTarget.isNotifyTarget){
+ this.cachedTarget.notifyOut(this, e, this.dragData);
+ }
+ this.cacheTarget = null;
+ }
+ this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
+
+ if(this.afterInvalidDrop){
+
+ this.afterInvalidDrop(e, id);
+ }
+ },
+
+
+ afterRepair : function(){
+ if(Ext.enableFx){
+ this.el.highlight(this.hlColor || "c3daf9");
+ }
+ this.dragging = false;
+ },
+
+
+ beforeInvalidDrop : function(target, e, id){
+ return true;
+ },
+
+
+ handleMouseDown : function(e){
+ if(this.dragging) {
+ return;
+ }
+ var data = this.getDragData(e);
+ if(data && this.onBeforeDrag(data, e) !== false){
+ this.dragData = data;
+ this.proxy.stop();
+ Ext.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
+ }
+ },
+
+
+ onBeforeDrag : function(data, e){
+ return true;
+ },
+
+
+ onStartDrag : Ext.emptyFn,
+
+
+ startDrag : function(x, y){
+ this.proxy.reset();
+ this.dragging = true;
+ this.proxy.update("");
+ this.onInitDrag(x, y);
+ this.proxy.show();
+ },
+
+
+ onInitDrag : function(x, y){
+ var clone = this.el.dom.cloneNode(true);
+ clone.id = Ext.id();
+ this.proxy.update(clone);
+ this.onStartDrag(x, y);
+ return true;
+ },
+
+
+ getProxy : function(){
+ return this.proxy;
+ },
+
+
+ hideProxy : function(){
+ this.proxy.hide();
+ this.proxy.reset(true);
+ this.dragging = false;
+ },
+
+
+ triggerCacheRefresh : function(){
+ Ext.dd.DDM.refreshCache(this.groups);
+ },
+
+
+ b4EndDrag: function(e) {
+ },
+
+
+ endDrag : function(e){
+ this.onEndDrag(this.dragData, e);
+ },
+
+
+ onEndDrag : function(data, e){
+ },
+
+
+ autoOffset : function(x, y) {
+ this.setDelta(-12, -20);
+ },
+
+ destroy: function(){
+ Ext.dd.DragSource.superclass.destroy.call(this);
+ Ext.destroy(this.proxy);
+ }
+});
+Ext.dd.DropTarget = Ext.extend(Ext.dd.DDTarget, {
+
+ constructor : function(el, config){
+ this.el = Ext.get(el);
+
+ Ext.apply(this, config);
+
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.register(this.el);
+ }
+
+ Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
+ {isTarget: true});
+ },
+
+
+
+
+ dropAllowed : "x-dd-drop-ok",
+
+ dropNotAllowed : "x-dd-drop-nodrop",
+
+
+ isTarget : true,
+
+
+ isNotifyTarget : true,
+
+
+ notifyEnter : function(dd, e, data){
+ if(this.overClass){
+ this.el.addClass(this.overClass);
+ }
+ return this.dropAllowed;
+ },
+
+
+ notifyOver : function(dd, e, data){
+ return this.dropAllowed;
+ },
+
+
+ notifyOut : function(dd, e, data){
+ if(this.overClass){
+ this.el.removeClass(this.overClass);
+ }
+ },
+
+
+ notifyDrop : function(dd, e, data){
+ return false;
+ },
+
+ destroy : function(){
+ Ext.dd.DropTarget.superclass.destroy.call(this);
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.unregister(this.el);
+ }
+ }
+});
+Ext.dd.DragZone = Ext.extend(Ext.dd.DragSource, {
+
+ constructor : function(el, config){
+ Ext.dd.DragZone.superclass.constructor.call(this, el, config);
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.register(this.el);
+ }
+ },
+
+
+
+
+
+
+ getDragData : function(e){
+ return Ext.dd.Registry.getHandleFromEvent(e);
+ },
+
+
+ onInitDrag : function(x, y){
+ this.proxy.update(this.dragData.ddel.cloneNode(true));
+ this.onStartDrag(x, y);
+ return true;
+ },
+
+
+ afterRepair : function(){
+ if(Ext.enableFx){
+ Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
+ }
+ this.dragging = false;
+ },
+
+
+ getRepairXY : function(e){
+ return Ext.Element.fly(this.dragData.ddel).getXY();
+ },
+
+ destroy : function(){
+ Ext.dd.DragZone.superclass.destroy.call(this);
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.unregister(this.el);
+ }
+ }
+});
+Ext.dd.DropZone = function(el, config){
+ Ext.dd.DropZone.superclass.constructor.call(this, el, config);
+};
+
+Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
+
+ getTargetFromEvent : function(e){
+ return Ext.dd.Registry.getTargetFromEvent(e);
+ },
+
+
+ onNodeEnter : function(n, dd, e, data){
+
+ },
+
+
+ onNodeOver : function(n, dd, e, data){
+ return this.dropAllowed;
+ },
+
+
+ onNodeOut : function(n, dd, e, data){
+
+ },
+
+
+ onNodeDrop : function(n, dd, e, data){
+ return false;
+ },
+
+
+ onContainerOver : function(dd, e, data){
+ return this.dropNotAllowed;
+ },
+
+
+ onContainerDrop : function(dd, e, data){
+ return false;
+ },
+
+
+ notifyEnter : function(dd, e, data){
+ return this.dropNotAllowed;
+ },
+
+
+ notifyOver : function(dd, e, data){
+ var n = this.getTargetFromEvent(e);
+ if(!n){
+ if(this.lastOverNode){
+ this.onNodeOut(this.lastOverNode, dd, e, data);
+ this.lastOverNode = null;
+ }
+ return this.onContainerOver(dd, e, data);
+ }
+ if(this.lastOverNode != n){
+ if(this.lastOverNode){
+ this.onNodeOut(this.lastOverNode, dd, e, data);
+ }
+ this.onNodeEnter(n, dd, e, data);
+ this.lastOverNode = n;
+ }
+ return this.onNodeOver(n, dd, e, data);
+ },
+
+
+ notifyOut : function(dd, e, data){
+ if(this.lastOverNode){
+ this.onNodeOut(this.lastOverNode, dd, e, data);
+ this.lastOverNode = null;
+ }
+ },
+
+
+ notifyDrop : function(dd, e, data){
+ if(this.lastOverNode){
+ this.onNodeOut(this.lastOverNode, dd, e, data);
+ this.lastOverNode = null;
+ }
+ var n = this.getTargetFromEvent(e);
+ return n ?
+ this.onNodeDrop(n, dd, e, data) :
+ this.onContainerDrop(dd, e, data);
+ },
+
+
+ triggerCacheRefresh : function(){
+ Ext.dd.DDM.refreshCache(this.groups);
+ }
+});
+Ext.Element.addMethods({
+
+ initDD : function(group, config, overrides){
+ var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
+ return Ext.apply(dd, overrides);
+ },
+
+
+ initDDProxy : function(group, config, overrides){
+ var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
+ return Ext.apply(dd, overrides);
+ },
+
+
+ initDDTarget : function(group, config, overrides){
+ var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
+ return Ext.apply(dd, overrides);
+ }
+});
+
+Ext.data.Api = (function() {
+
+
+
+
+
+ var validActions = {};
+
+ return {
+
+ actions : {
+ create : 'create',
+ read : 'read',
+ update : 'update',
+ destroy : 'destroy'
+ },
+
+
+ restActions : {
+ create : 'POST',
+ read : 'GET',
+ update : 'PUT',
+ destroy : 'DELETE'
+ },
+
+
+ isAction : function(action) {
+ return (Ext.data.Api.actions[action]) ? true : false;
+ },
+
+
+ getVerb : function(name) {
+ if (validActions[name]) {
+ return validActions[name];
+ }
+ for (var verb in this.actions) {
+ if (this.actions[verb] === name) {
+ validActions[name] = verb;
+ break;
+ }
+ }
+ return (validActions[name] !== undefined) ? validActions[name] : null;
+ },
+
+
+ isValid : function(api){
+ var invalid = [];
+ var crud = this.actions;
+ for (var action in api) {
+ if (!(action in crud)) {
+ invalid.push(action);
+ }
+ }
+ return (!invalid.length) ? true : invalid;
+ },
+
+
+ hasUniqueUrl : function(proxy, verb) {
+ var url = (proxy.api[verb]) ? proxy.api[verb].url : null;
+ var unique = true;
+ for (var action in proxy.api) {
+ if ((unique = (action === verb) ? true : (proxy.api[action].url != url) ? true : false) === false) {
+ break;
+ }
+ }
+ return unique;
+ },
+
+
+ prepare : function(proxy) {
+ if (!proxy.api) {
+ proxy.api = {};
+ }
+ for (var verb in this.actions) {
+ var action = this.actions[verb];
+ proxy.api[action] = proxy.api[action] || proxy.url || proxy.directFn;
+ if (typeof(proxy.api[action]) == 'string') {
+ proxy.api[action] = {
+ url: proxy.api[action],
+ method: (proxy.restful === true) ? Ext.data.Api.restActions[action] : undefined
+ };
+ }
+ }
+ },
+
+
+ restify : function(proxy) {
+ proxy.restful = true;
+ for (var verb in this.restActions) {
+ proxy.api[this.actions[verb]].method ||
+ (proxy.api[this.actions[verb]].method = this.restActions[verb]);
+ }
+
+
+ proxy.onWrite = proxy.onWrite.createInterceptor(function(action, o, response, rs) {
+ var reader = o.reader;
+ var res = new Ext.data.Response({
+ action: action,
+ raw: response
+ });
+
+ switch (response.status) {
+ case 200:
+ return true;
+ break;
+ case 201:
+ if (Ext.isEmpty(res.raw.responseText)) {
+ res.success = true;
+ } else {
+
+ return true;
+ }
+ break;
+ case 204:
+ res.success = true;
+ res.data = null;
+ break;
+ default:
+ return true;
+ break;
+ }
+ if (res.success === true) {
+ this.fireEvent("write", this, action, res.data, res, rs, o.request.arg);
+ } else {
+ this.fireEvent('exception', this, 'remote', action, o, res, rs);
+ }
+ o.request.callback.call(o.request.scope, res.data, res, res.success);
+
+ return false;
+ }, proxy);
+ }
+ };
+})();
+
+
+Ext.data.Response = function(params, response) {
+ Ext.apply(this, params, {
+ raw: response
+ });
+};
+Ext.data.Response.prototype = {
+ message : null,
+ success : false,
+ status : null,
+ root : null,
+ raw : null,
+
+ getMessage : function() {
+ return this.message;
+ },
+ getSuccess : function() {
+ return this.success;
+ },
+ getStatus : function() {
+ return this.status;
+ },
+ getRoot : function() {
+ return this.root;
+ },
+ getRawResponse : function() {
+ return this.raw;
+ }
+};
+
+
+Ext.data.Api.Error = Ext.extend(Ext.Error, {
+ constructor : function(message, arg) {
+ this.arg = arg;
+ Ext.Error.call(this, message);
+ },
+ name: 'Ext.data.Api'
+});
+Ext.apply(Ext.data.Api.Error.prototype, {
+ lang: {
+ 'action-url-undefined': 'No fallback url defined for this action. When defining a DataProxy api, please be sure to define an url for each CRUD action in Ext.data.Api.actions or define a default url in addition to your api-configuration.',
+ 'invalid': 'received an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions defined in Ext.data.Api.actions',
+ 'invalid-url': 'Invalid url. Please review your proxy configuration.',
+ 'execute': 'Attempted to execute an unknown action. Valid API actions are defined in Ext.data.Api.actions"'
+ }
+});
+
+
+
+
+Ext.data.SortTypes = {
+
+ none : function(s){
+ return s;
+ },
+
+
+ stripTagsRE : /<\/?[^>]+>/gi,
+
+
+ asText : function(s){
+ return String(s).replace(this.stripTagsRE, "");
+ },
+
+
+ asUCText : function(s){
+ return String(s).toUpperCase().replace(this.stripTagsRE, "");
+ },
+
+
+ asUCString : function(s) {
+ return String(s).toUpperCase();
+ },
+
+
+ asDate : function(s) {
+ if(!s){
+ return 0;
+ }
+ if(Ext.isDate(s)){
+ return s.getTime();
+ }
+ return Date.parse(String(s));
+ },
+
+
+ asFloat : function(s) {
+ var val = parseFloat(String(s).replace(/,/g, ""));
+ return isNaN(val) ? 0 : val;
+ },
+
+
+ asInt : function(s) {
+ var val = parseInt(String(s).replace(/,/g, ""), 10);
+ return isNaN(val) ? 0 : val;
+ }
+};
+Ext.data.Record = function(data, id){
+
+ this.id = (id || id === 0) ? id : Ext.data.Record.id(this);
+ this.data = data || {};
+};
+
+
+Ext.data.Record.create = function(o){
+ var f = Ext.extend(Ext.data.Record, {});
+ var p = f.prototype;
+ p.fields = new Ext.util.MixedCollection(false, function(field){
+ return field.name;
+ });
+ for(var i = 0, len = o.length; i < len; i++){
+ p.fields.add(new Ext.data.Field(o[i]));
+ }
+ f.getField = function(name){
+ return p.fields.get(name);
+ };
+ return f;
+};
+
+Ext.data.Record.PREFIX = 'ext-record';
+Ext.data.Record.AUTO_ID = 1;
+Ext.data.Record.EDIT = 'edit';
+Ext.data.Record.REJECT = 'reject';
+Ext.data.Record.COMMIT = 'commit';
+
+
+
+Ext.data.Record.id = function(rec) {
+ rec.phantom = true;
+ return [Ext.data.Record.PREFIX, '-', Ext.data.Record.AUTO_ID++].join('');
+};
+
+Ext.data.Record.prototype = {
+
+
+
+
+
+
+ dirty : false,
+ editing : false,
+ error : null,
+
+ modified : null,
+
+ phantom : false,
+
+
+ join : function(store){
+
+ this.store = store;
+ },
+
+
+ set : function(name, value){
+ var encode = Ext.isPrimitive(value) ? String : Ext.encode;
+ if(encode(this.data[name]) == encode(value)) {
+ return;
+ }
+ this.dirty = true;
+ if(!this.modified){
+ this.modified = {};
+ }
+ if(this.modified[name] === undefined){
+ this.modified[name] = this.data[name];
+ }
+ this.data[name] = value;
+ if(!this.editing){
+ this.afterEdit();
+ }
+ },
+
+
+ afterEdit : function(){
+ if (this.store != undefined && typeof this.store.afterEdit == "function") {
+ this.store.afterEdit(this);
+ }
+ },
+
+
+ afterReject : function(){
+ if(this.store){
+ this.store.afterReject(this);
+ }
+ },
+
+
+ afterCommit : function(){
+ if(this.store){
+ this.store.afterCommit(this);
+ }
+ },
+
+
+ get : function(name){
+ return this.data[name];
+ },
+
+
+ beginEdit : function(){
+ this.editing = true;
+ this.modified = this.modified || {};
+ },
+
+
+ cancelEdit : function(){
+ this.editing = false;
+ delete this.modified;
+ },
+
+
+ endEdit : function(){
+ this.editing = false;
+ if(this.dirty){
+ this.afterEdit();
+ }
+ },
+
+
+ reject : function(silent){
+ var m = this.modified;
+ for(var n in m){
+ if(typeof m[n] != "function"){
+ this.data[n] = m[n];
+ }
+ }
+ this.dirty = false;
+ delete this.modified;
+ this.editing = false;
+ if(silent !== true){
+ this.afterReject();
+ }
+ },
+
+
+ commit : function(silent){
+ this.dirty = false;
+ delete this.modified;
+ this.editing = false;
+ if(silent !== true){
+ this.afterCommit();
+ }
+ },
+
+
+ getChanges : function(){
+ var m = this.modified, cs = {};
+ for(var n in m){
+ if(m.hasOwnProperty(n)){
+ cs[n] = this.data[n];
+ }
+ }
+ return cs;
+ },
+
+
+ hasError : function(){
+ return this.error !== null;
+ },
+
+
+ clearError : function(){
+ this.error = null;
+ },
+
+
+ copy : function(newId) {
+ return new this.constructor(Ext.apply({}, this.data), newId || this.id);
+ },
+
+
+ isModified : function(fieldName){
+ return !!(this.modified && this.modified.hasOwnProperty(fieldName));
+ },
+
+
+ isValid : function() {
+ return this.fields.find(function(f) {
+ return (f.allowBlank === false && Ext.isEmpty(this.data[f.name])) ? true : false;
+ },this) ? false : true;
+ },
+
+
+ markDirty : function(){
+ this.dirty = true;
+ if(!this.modified){
+ this.modified = {};
+ }
+ this.fields.each(function(f) {
+ this.modified[f.name] = this.data[f.name];
+ },this);
+ }
+};
+
+Ext.StoreMgr = Ext.apply(new Ext.util.MixedCollection(), {
+
+
+
+ register : function(){
+ for(var i = 0, s; (s = arguments[i]); i++){
+ this.add(s);
+ }
+ },
+
+
+ unregister : function(){
+ for(var i = 0, s; (s = arguments[i]); i++){
+ this.remove(this.lookup(s));
+ }
+ },
+
+
+ lookup : function(id){
+ if(Ext.isArray(id)){
+ var fields = ['field1'], expand = !Ext.isArray(id[0]);
+ if(!expand){
+ for(var i = 2, len = id[0].length; i <= len; ++i){
+ fields.push('field' + i);
+ }
+ }
+ return new Ext.data.ArrayStore({
+ fields: fields,
+ data: id,
+ expandData: expand,
+ autoDestroy: true,
+ autoCreated: true
+
+ });
+ }
+ return Ext.isObject(id) ? (id.events ? id : Ext.create(id, 'store')) : this.get(id);
+ },
+
+
+ getKey : function(o){
+ return o.storeId;
+ }
+});
+Ext.data.Store = Ext.extend(Ext.util.Observable, {
+
+
+
+
+
+
+
+ writer : undefined,
+
+
+
+ remoteSort : false,
+
+
+ autoDestroy : false,
+
+
+ pruneModifiedRecords : false,
+
+
+ lastOptions : null,
+
+
+ autoSave : true,
+
+
+ batch : true,
+
+
+ restful: false,
+
+
+ paramNames : undefined,
+
+
+ defaultParamNames : {
+ start : 'start',
+ limit : 'limit',
+ sort : 'sort',
+ dir : 'dir'
+ },
+
+ isDestroyed: false,
+ hasMultiSort: false,
+
+
+ batchKey : '_ext_batch_',
+
+ constructor : function(config){
+
+
+
+
+ this.data = new Ext.util.MixedCollection(false);
+ this.data.getKey = function(o){
+ return o.id;
+ };
+
+
+
+ this.removed = [];
+
+ if(config && config.data){
+ this.inlineData = config.data;
+ delete config.data;
+ }
+
+ Ext.apply(this, config);
+
+
+ this.baseParams = Ext.isObject(this.baseParams) ? this.baseParams : {};
+
+ this.paramNames = Ext.applyIf(this.paramNames || {}, this.defaultParamNames);
+
+ if((this.url || this.api) && !this.proxy){
+ this.proxy = new Ext.data.HttpProxy({url: this.url, api: this.api});
+ }
+
+ if (this.restful === true && this.proxy) {
+
+
+ this.batch = false;
+ Ext.data.Api.restify(this.proxy);
+ }
+
+ if(this.reader){
+ if(!this.recordType){
+ this.recordType = this.reader.recordType;
+ }
+ if(this.reader.onMetaChange){
+ this.reader.onMetaChange = this.reader.onMetaChange.createSequence(this.onMetaChange, this);
+ }
+ if (this.writer) {
+ if (this.writer instanceof(Ext.data.DataWriter) === false) {
+ this.writer = this.buildWriter(this.writer);
+ }
+ this.writer.meta = this.reader.meta;
+ this.pruneModifiedRecords = true;
+ }
+ }
+
+
+
+ if(this.recordType){
+
+ this.fields = this.recordType.prototype.fields;
+ }
+ this.modified = [];
+
+ this.addEvents(
+
+ 'datachanged',
+
+ 'metachange',
+
+ 'add',
+
+ 'remove',
+
+ 'update',
+
+ 'clear',
+
+ 'exception',
+
+ 'beforeload',
+
+ 'load',
+
+ 'loadexception',
+
+ 'beforewrite',
+
+ 'write',
+
+ 'beforesave',
+
+ 'save'
+
+ );
+
+ if(this.proxy){
+
+ this.relayEvents(this.proxy, ['loadexception', 'exception']);
+ }
+
+ if (this.writer) {
+ this.on({
+ scope: this,
+ add: this.createRecords,
+ remove: this.destroyRecord,
+ update: this.updateRecord,
+ clear: this.onClear
+ });
+ }
+
+ this.sortToggle = {};
+ if(this.sortField){
+ this.setDefaultSort(this.sortField, this.sortDir);
+ }else if(this.sortInfo){
+ this.setDefaultSort(this.sortInfo.field, this.sortInfo.direction);
+ }
+
+ Ext.data.Store.superclass.constructor.call(this);
+
+ if(this.id){
+ this.storeId = this.id;
+ delete this.id;
+ }
+ if(this.storeId){
+ Ext.StoreMgr.register(this);
+ }
+ if(this.inlineData){
+ this.loadData(this.inlineData);
+ delete this.inlineData;
+ }else if(this.autoLoad){
+ this.load.defer(10, this, [
+ typeof this.autoLoad == 'object' ?
+ this.autoLoad : undefined]);
+ }
+
+ this.batchCounter = 0;
+ this.batches = {};
+ },
+
+
+ buildWriter : function(config) {
+ var klass = undefined,
+ type = (config.format || 'json').toLowerCase();
+ switch (type) {
+ case 'json':
+ klass = Ext.data.JsonWriter;
+ break;
+ case 'xml':
+ klass = Ext.data.XmlWriter;
+ break;
+ default:
+ klass = Ext.data.JsonWriter;
+ }
+ return new klass(config);
+ },
+
+
+ destroy : function(){
+ if(!this.isDestroyed){
+ if(this.storeId){
+ Ext.StoreMgr.unregister(this);
+ }
+ this.clearData();
+ this.data = null;
+ Ext.destroy(this.proxy);
+ this.reader = this.writer = null;
+ this.purgeListeners();
+ this.isDestroyed = true;
+ }
+ },
+
+
+ add : function(records) {
+ var i, len, record, index;
+
+ records = [].concat(records);
+ if (records.length < 1) {
+ return;
+ }
+
+ for (i = 0, len = records.length; i < len; i++) {
+ record = records[i];
+
+ record.join(this);
+
+ if (record.dirty || record.phantom) {
+ this.modified.push(record);
+ }
+ }
+
+ index = this.data.length;
+ this.data.addAll(records);
+
+ if (this.snapshot) {
+ this.snapshot.addAll(records);
+ }
+
+ this.fireEvent('add', this, records, index);
+ },
+
+
+ addSorted : function(record){
+ var index = this.findInsertIndex(record);
+ this.insert(index, record);
+ },
+
+
+ doUpdate : function(rec){
+ this.data.replace(rec.id, rec);
+ if(this.snapshot){
+ this.snapshot.replace(rec.id, rec);
+ }
+ this.fireEvent('update', this, rec, Ext.data.Record.COMMIT);
+ },
+
+
+ remove : function(record){
+ if(Ext.isArray(record)){
+ Ext.each(record, function(r){
+ this.remove(r);
+ }, this);
+ return;
+ }
+ var index = this.data.indexOf(record);
+ if(index > -1){
+ record.join(null);
+ this.data.removeAt(index);
+ }
+ if(this.pruneModifiedRecords){
+ this.modified.remove(record);
+ }
+ if(this.snapshot){
+ this.snapshot.remove(record);
+ }
+ if(index > -1){
+ this.fireEvent('remove', this, record, index);
+ }
+ },
+
+
+ removeAt : function(index){
+ this.remove(this.getAt(index));
+ },
+
+
+ removeAll : function(silent){
+ var items = [];
+ this.each(function(rec){
+ items.push(rec);
+ });
+ this.clearData();
+ if(this.snapshot){
+ this.snapshot.clear();
+ }
+ if(this.pruneModifiedRecords){
+ this.modified = [];
+ }
+ if (silent !== true) {
+ this.fireEvent('clear', this, items);
+ }
+ },
+
+
+ onClear: function(store, records){
+ Ext.each(records, function(rec, index){
+ this.destroyRecord(this, rec, index);
+ }, this);
+ },
+
+
+ insert : function(index, records) {
+ var i, len, record;
+
+ records = [].concat(records);
+ for (i = 0, len = records.length; i < len; i++) {
+ record = records[i];
+
+ this.data.insert(index + i, record);
+ record.join(this);
+
+ if (record.dirty || record.phantom) {
+ this.modified.push(record);
+ }
+ }
+
+ if (this.snapshot) {
+ this.snapshot.addAll(records);
+ }
+
+ this.fireEvent('add', this, records, index);
+ },
+
+
+ indexOf : function(record){
+ return this.data.indexOf(record);
+ },
+
+
+ indexOfId : function(id){
+ return this.data.indexOfKey(id);
+ },
+
+
+ getById : function(id){
+ return (this.snapshot || this.data).key(id);
+ },
+
+
+ getAt : function(index){
+ return this.data.itemAt(index);
+ },
+
+
+ getRange : function(start, end){
+ return this.data.getRange(start, end);
+ },
+
+
+ storeOptions : function(o){
+ o = Ext.apply({}, o);
+ delete o.callback;
+ delete o.scope;
+ this.lastOptions = o;
+ },
+
+
+ clearData: function(){
+ this.data.each(function(rec) {
+ rec.join(null);
+ });
+ this.data.clear();
+ },
+
+
+ load : function(options) {
+ options = Ext.apply({}, options);
+ this.storeOptions(options);
+ if(this.sortInfo && this.remoteSort){
+ var pn = this.paramNames;
+ options.params = Ext.apply({}, options.params);
+ options.params[pn.sort] = this.sortInfo.field;
+ options.params[pn.dir] = this.sortInfo.direction;
+ }
+ try {
+ return this.execute('read', null, options);
+ } catch(e) {
+ this.handleException(e);
+ return false;
+ }
+ },
+
+
+ updateRecord : function(store, record, action) {
+ if (action == Ext.data.Record.EDIT && this.autoSave === true && (!record.phantom || (record.phantom && record.isValid()))) {
+ this.save();
+ }
+ },
+
+
+ createRecords : function(store, records, index) {
+ var modified = this.modified,
+ length = records.length,
+ record, i;
+
+ for (i = 0; i < length; i++) {
+ record = records[i];
+
+ if (record.phantom && record.isValid()) {
+ record.markDirty();
+
+ if (modified.indexOf(record) == -1) {
+ modified.push(record);
+ }
+ }
+ }
+ if (this.autoSave === true) {
+ this.save();
+ }
+ },
+
+
+ destroyRecord : function(store, record, index) {
+ if (this.modified.indexOf(record) != -1) {
+ this.modified.remove(record);
+ }
+ if (!record.phantom) {
+ this.removed.push(record);
+
+
+
+
+ record.lastIndex = index;
+
+ if (this.autoSave === true) {
+ this.save();
+ }
+ }
+ },
+
+
+ execute : function(action, rs, options, batch) {
+
+ if (!Ext.data.Api.isAction(action)) {
+ throw new Ext.data.Api.Error('execute', action);
+ }
+
+ options = Ext.applyIf(options||{}, {
+ params: {}
+ });
+ if(batch !== undefined){
+ this.addToBatch(batch);
+ }
+
+
+ var doRequest = true;
+
+ if (action === 'read') {
+ doRequest = this.fireEvent('beforeload', this, options);
+ Ext.applyIf(options.params, this.baseParams);
+ }
+ else {
+
+
+ if (this.writer.listful === true && this.restful !== true) {
+ rs = (Ext.isArray(rs)) ? rs : [rs];
+ }
+
+ else if (Ext.isArray(rs) && rs.length == 1) {
+ rs = rs.shift();
+ }
+
+ if ((doRequest = this.fireEvent('beforewrite', this, action, rs, options)) !== false) {
+ this.writer.apply(options.params, this.baseParams, action, rs);
+ }
+ }
+ if (doRequest !== false) {
+
+ if (this.writer && this.proxy.url && !this.proxy.restful && !Ext.data.Api.hasUniqueUrl(this.proxy, action)) {
+ options.params.xaction = action;
+ }
+
+
+
+
+
+ this.proxy.request(Ext.data.Api.actions[action], rs, options.params, this.reader, this.createCallback(action, rs, batch), this, options);
+ }
+ return doRequest;
+ },
+
+
+ save : function() {
+ if (!this.writer) {
+ throw new Ext.data.Store.Error('writer-undefined');
+ }
+
+ var queue = [],
+ len,
+ trans,
+ batch,
+ data = {},
+ i;
+
+ if(this.removed.length){
+ queue.push(['destroy', this.removed]);
+ }
+
+
+ var rs = [].concat(this.getModifiedRecords());
+ if(rs.length){
+
+ var phantoms = [];
+ for(i = rs.length-1; i >= 0; i--){
+ if(rs[i].phantom === true){
+ var rec = rs.splice(i, 1).shift();
+ if(rec.isValid()){
+ phantoms.push(rec);
+ }
+ }else if(!rs[i].isValid()){
+ rs.splice(i,1);
+ }
+ }
+
+ if(phantoms.length){
+ queue.push(['create', phantoms]);
+ }
+
+
+ if(rs.length){
+ queue.push(['update', rs]);
+ }
+ }
+ len = queue.length;
+ if(len){
+ batch = ++this.batchCounter;
+ for(i = 0; i < len; ++i){
+ trans = queue[i];
+ data[trans[0]] = trans[1];
+ }
+ if(this.fireEvent('beforesave', this, data) !== false){
+ for(i = 0; i < len; ++i){
+ trans = queue[i];
+ this.doTransaction(trans[0], trans[1], batch);
+ }
+ return batch;
+ }
+ }
+ return -1;
+ },
+
+
+ doTransaction : function(action, rs, batch) {
+ function transaction(records) {
+ try{
+ this.execute(action, records, undefined, batch);
+ }catch (e){
+ this.handleException(e);
+ }
+ }
+ if(this.batch === false){
+ for(var i = 0, len = rs.length; i < len; i++){
+ transaction.call(this, rs[i]);
+ }
+ }else{
+ transaction.call(this, rs);
+ }
+ },
+
+
+ addToBatch : function(batch){
+ var b = this.batches,
+ key = this.batchKey + batch,
+ o = b[key];
+
+ if(!o){
+ b[key] = o = {
+ id: batch,
+ count: 0,
+ data: {}
+ };
+ }
+ ++o.count;
+ },
+
+ removeFromBatch : function(batch, action, data){
+ var b = this.batches,
+ key = this.batchKey + batch,
+ o = b[key],
+ arr;
+
+
+ if(o){
+ arr = o.data[action] || [];
+ o.data[action] = arr.concat(data);
+ if(o.count === 1){
+ data = o.data;
+ delete b[key];
+ this.fireEvent('save', this, batch, data);
+ }else{
+ --o.count;
+ }
+ }
+ },
+
+
+
+ createCallback : function(action, rs, batch) {
+ var actions = Ext.data.Api.actions;
+ return (action == 'read') ? this.loadRecords : function(data, response, success) {
+
+ this['on' + Ext.util.Format.capitalize(action) + 'Records'](success, rs, [].concat(data));
+
+ if (success === true) {
+ this.fireEvent('write', this, action, data, response, rs);
+ }
+ this.removeFromBatch(batch, action, data);
+ };
+ },
+
+
+
+
+ clearModified : function(rs) {
+ if (Ext.isArray(rs)) {
+ for (var n=rs.length-1;n>=0;n--) {
+ this.modified.splice(this.modified.indexOf(rs[n]), 1);
+ }
+ } else {
+ this.modified.splice(this.modified.indexOf(rs), 1);
+ }
+ },
+
+
+ reMap : function(record) {
+ if (Ext.isArray(record)) {
+ for (var i = 0, len = record.length; i < len; i++) {
+ this.reMap(record[i]);
+ }
+ } else {
+ delete this.data.map[record._phid];
+ this.data.map[record.id] = record;
+ var index = this.data.keys.indexOf(record._phid);
+ this.data.keys.splice(index, 1, record.id);
+ delete record._phid;
+ }
+ },
+
+
+ onCreateRecords : function(success, rs, data) {
+ if (success === true) {
+ try {
+ this.reader.realize(rs, data);
+ this.reMap(rs);
+ }
+ catch (e) {
+ this.handleException(e);
+ if (Ext.isArray(rs)) {
+
+ this.onCreateRecords(success, rs, data);
+ }
+ }
+ }
+ },
+
+
+ onUpdateRecords : function(success, rs, data) {
+ if (success === true) {
+ try {
+ this.reader.update(rs, data);
+ } catch (e) {
+ this.handleException(e);
+ if (Ext.isArray(rs)) {
+
+ this.onUpdateRecords(success, rs, data);
+ }
+ }
+ }
+ },
+
+
+ onDestroyRecords : function(success, rs, data) {
+
+ rs = (rs instanceof Ext.data.Record) ? [rs] : [].concat(rs);
+ for (var i=0,len=rs.length;i<len;i++) {
+ this.removed.splice(this.removed.indexOf(rs[i]), 1);
+ }
+ if (success === false) {
+
+
+ for (i=rs.length-1;i>=0;i--) {
+ this.insert(rs[i].lastIndex, rs[i]);
+ }
+ }
+ },
+
+
+ handleException : function(e) {
+
+ Ext.handleError(e);
+ },
+
+
+ reload : function(options){
+ this.load(Ext.applyIf(options||{}, this.lastOptions));
+ },
+
+
+
+ loadRecords : function(o, options, success){
+ var i, len;
+
+ if (this.isDestroyed === true) {
+ return;
+ }
+ if(!o || success === false){
+ if(success !== false){
+ this.fireEvent('load', this, [], options);
+ }
+ if(options.callback){
+ options.callback.call(options.scope || this, [], options, false, o);
+ }
+ return;
+ }
+ var r = o.records, t = o.totalRecords || r.length;
+ if(!options || options.add !== true){
+ if(this.pruneModifiedRecords){
+ this.modified = [];
+ }
+ for(i = 0, len = r.length; i < len; i++){
+ r[i].join(this);
+ }
+ if(this.snapshot){
+ this.data = this.snapshot;
+ delete this.snapshot;
+ }
+ this.clearData();
+ this.data.addAll(r);
+ this.totalLength = t;
+ this.applySort();
+ this.fireEvent('datachanged', this);
+ }else{
+ var toAdd = [],
+ rec,
+ cnt = 0;
+ for(i = 0, len = r.length; i < len; ++i){
+ rec = r[i];
+ if(this.indexOfId(rec.id) > -1){
+ this.doUpdate(rec);
+ }else{
+ toAdd.push(rec);
+ ++cnt;
+ }
+ }
+ this.totalLength = Math.max(t, this.data.length + cnt);
+ this.add(toAdd);
+ }
+ this.fireEvent('load', this, r, options);
+ if(options.callback){
+ options.callback.call(options.scope || this, r, options, true);
+ }
+ },
+
+
+ loadData : function(o, append){
+ var r = this.reader.readRecords(o);
+ this.loadRecords(r, {add: append}, true);
+ },
+
+
+ getCount : function(){
+ return this.data.length || 0;
+ },
+
+
+ getTotalCount : function(){
+ return this.totalLength || 0;
+ },
+
+
+ getSortState : function(){
+ return this.sortInfo;
+ },
+
+
+ applySort : function(){
+ if ((this.sortInfo || this.multiSortInfo) && !this.remoteSort) {
+ this.sortData();
+ }
+ },
+
+
+ sortData : function() {
+ var sortInfo = this.hasMultiSort ? this.multiSortInfo : this.sortInfo,
+ direction = sortInfo.direction || "ASC",
+ sorters = sortInfo.sorters,
+ sortFns = [];
+
+
+ if (!this.hasMultiSort) {
+ sorters = [{direction: direction, field: sortInfo.field}];
+ }
+
+
+ for (var i=0, j = sorters.length; i < j; i++) {
+ sortFns.push(this.createSortFunction(sorters[i].field, sorters[i].direction));
+ }
+
+ if (sortFns.length == 0) {
+ return;
+ }
+
+
+
+ var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1;
+
+
+ var fn = function(r1, r2) {
+ var result = sortFns[0].call(this, r1, r2);
+
+
+ if (sortFns.length > 1) {
+ for (var i=1, j = sortFns.length; i < j; i++) {
+ result = result || sortFns[i].call(this, r1, r2);
+ }
+ }
+
+ return directionModifier * result;
+ };
+
+
+ this.data.sort(direction, fn);
+ if (this.snapshot && this.snapshot != this.data) {
+ this.snapshot.sort(direction, fn);
+ }
+ },
+
+
+ createSortFunction: function(field, direction) {
+ direction = direction || "ASC";
+ var directionModifier = direction.toUpperCase() == "DESC" ? -1 : 1;
+
+ var sortType = this.fields.get(field).sortType;
+
+
+
+ return function(r1, r2) {
+ var v1 = sortType(r1.data[field]),
+ v2 = sortType(r2.data[field]);
+
+ return directionModifier * (v1 > v2 ? 1 : (v1 < v2 ? -1 : 0));
+ };
+ },
+
+
+ setDefaultSort : function(field, dir) {
+ dir = dir ? dir.toUpperCase() : 'ASC';
+ this.sortInfo = {field: field, direction: dir};
+ this.sortToggle[field] = dir;
+ },
+
+
+ sort : function(fieldName, dir) {
+ if (Ext.isArray(arguments[0])) {
+ return this.multiSort.call(this, fieldName, dir);
+ } else {
+ return this.singleSort(fieldName, dir);
+ }
+ },
+
+
+ singleSort: function(fieldName, dir) {
+ var field = this.fields.get(fieldName);
+ if (!field) {
+ return false;
+ }
+
+ var name = field.name,
+ sortInfo = this.sortInfo || null,
+ sortToggle = this.sortToggle ? this.sortToggle[name] : null;
+
+ if (!dir) {
+ if (sortInfo && sortInfo.field == name) {
+ dir = (this.sortToggle[name] || 'ASC').toggle('ASC', 'DESC');
+ } else {
+ dir = field.sortDir;
+ }
+ }
+
+ this.sortToggle[name] = dir;
+ this.sortInfo = {field: name, direction: dir};
+ this.hasMultiSort = false;
+
+ if (this.remoteSort) {
+ if (!this.load(this.lastOptions)) {
+ if (sortToggle) {
+ this.sortToggle[name] = sortToggle;
+ }
+ if (sortInfo) {
+ this.sortInfo = sortInfo;
+ }
+ }
+ } else {
+ this.applySort();
+ this.fireEvent('datachanged', this);
+ }
+ return true;
+ },
+
+
+ multiSort: function(sorters, direction) {
+ this.hasMultiSort = true;
+ direction = direction || "ASC";
+
+
+ if (this.multiSortInfo && direction == this.multiSortInfo.direction) {
+ direction = direction.toggle("ASC", "DESC");
+ }
+
+
+ this.multiSortInfo = {
+ sorters : sorters,
+ direction: direction
+ };
+
+ if (this.remoteSort) {
+ this.singleSort(sorters[0].field, sorters[0].direction);
+
+ } else {
+ this.applySort();
+ this.fireEvent('datachanged', this);
+ }
+ },
+
+
+ each : function(fn, scope){
+ this.data.each(fn, scope);
+ },
+
+
+ getModifiedRecords : function(){
+ return this.modified;
+ },
+
+
+ sum : function(property, start, end){
+ var rs = this.data.items, v = 0;
+ start = start || 0;
+ end = (end || end === 0) ? end : rs.length-1;
+
+ for(var i = start; i <= end; i++){
+ v += (rs[i].data[property] || 0);
+ }
+ return v;
+ },
+
+
+ createFilterFn : function(property, value, anyMatch, caseSensitive, exactMatch){
+ if(Ext.isEmpty(value, false)){
+ return false;
+ }
+ value = this.data.createValueMatcher(value, anyMatch, caseSensitive, exactMatch);
+ return function(r) {
+ return value.test(r.data[property]);
+ };
+ },
+
+
+ createMultipleFilterFn: function(filters) {
+ return function(record) {
+ var isMatch = true;
+
+ for (var i=0, j = filters.length; i < j; i++) {
+ var filter = filters[i],
+ fn = filter.fn,
+ scope = filter.scope;
+
+ isMatch = isMatch && fn.call(scope, record);
+ }
+
+ return isMatch;
+ };
+ },
+
+
+ filter : function(property, value, anyMatch, caseSensitive, exactMatch){
+ var fn;
+
+ if (Ext.isObject(property)) {
+ property = [property];
+ }
+
+ if (Ext.isArray(property)) {
+ var filters = [];
+
+
+ for (var i=0, j = property.length; i < j; i++) {
+ var filter = property[i],
+ func = filter.fn,
+ scope = filter.scope || this;
+
+
+ if (!Ext.isFunction(func)) {
+ func = this.createFilterFn(filter.property, filter.value, filter.anyMatch, filter.caseSensitive, filter.exactMatch);
+ }
+
+ filters.push({fn: func, scope: scope});
+ }
+
+ fn = this.createMultipleFilterFn(filters);
+ } else {
+
+ fn = this.createFilterFn(property, value, anyMatch, caseSensitive, exactMatch);
+ }
+
+ return fn ? this.filterBy(fn) : this.clearFilter();
+ },
+
+
+ filterBy : function(fn, scope){
+ this.snapshot = this.snapshot || this.data;
+ this.data = this.queryBy(fn, scope || this);
+ this.fireEvent('datachanged', this);
+ },
+
+
+ clearFilter : function(suppressEvent){
+ if(this.isFiltered()){
+ this.data = this.snapshot;
+ delete this.snapshot;
+ if(suppressEvent !== true){
+ this.fireEvent('datachanged', this);
+ }
+ }
+ },
+
+
+ isFiltered : function(){
+ return !!this.snapshot && this.snapshot != this.data;
+ },
+
+
+ query : function(property, value, anyMatch, caseSensitive){
+ var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
+ return fn ? this.queryBy(fn) : this.data.clone();
+ },
+
+
+ queryBy : function(fn, scope){
+ var data = this.snapshot || this.data;
+ return data.filterBy(fn, scope||this);
+ },
+
+
+ find : function(property, value, start, anyMatch, caseSensitive){
+ var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
+ return fn ? this.data.findIndexBy(fn, null, start) : -1;
+ },
+
+
+ findExact: function(property, value, start){
+ return this.data.findIndexBy(function(rec){
+ return rec.get(property) === value;
+ }, this, start);
+ },
+
+
+ findBy : function(fn, scope, start){
+ return this.data.findIndexBy(fn, scope, start);
+ },
+
+
+ collect : function(dataIndex, allowNull, bypassFilter){
+ var d = (bypassFilter === true && this.snapshot) ?
+ this.snapshot.items : this.data.items;
+ var v, sv, r = [], l = {};
+ for(var i = 0, len = d.length; i < len; i++){
+ v = d[i].data[dataIndex];
+ sv = String(v);
+ if((allowNull || !Ext.isEmpty(v)) && !l[sv]){
+ l[sv] = true;
+ r[r.length] = v;
+ }
+ }
+ return r;
+ },
+
+
+ afterEdit : function(record){
+ if(this.modified.indexOf(record) == -1){
+ this.modified.push(record);
+ }
+ this.fireEvent('update', this, record, Ext.data.Record.EDIT);
+ },
+
+
+ afterReject : function(record){
+ this.modified.remove(record);
+ this.fireEvent('update', this, record, Ext.data.Record.REJECT);
+ },
+
+
+ afterCommit : function(record){
+ this.modified.remove(record);
+ this.fireEvent('update', this, record, Ext.data.Record.COMMIT);
+ },
+
+
+ commitChanges : function(){
+ var modified = this.modified.slice(0),
+ length = modified.length,
+ i;
+
+ for (i = 0; i < length; i++){
+ modified[i].commit();
+ }
+
+ this.modified = [];
+ this.removed = [];
+ },
+
+
+ rejectChanges : function() {
+ var modified = this.modified.slice(0),
+ removed = this.removed.slice(0).reverse(),
+ mLength = modified.length,
+ rLength = removed.length,
+ i;
+
+ for (i = 0; i < mLength; i++) {
+ modified[i].reject();
+ }
+
+ for (i = 0; i < rLength; i++) {
+ this.insert(removed[i].lastIndex || 0, removed[i]);
+ removed[i].reject();
+ }
+
+ this.modified = [];
+ this.removed = [];
+ },
+
+
+ onMetaChange : function(meta){
+ this.recordType = this.reader.recordType;
+ this.fields = this.recordType.prototype.fields;
+ delete this.snapshot;
+ if(this.reader.meta.sortInfo){
+ this.sortInfo = this.reader.meta.sortInfo;
+ }else if(this.sortInfo && !this.fields.get(this.sortInfo.field)){
+ delete this.sortInfo;
+ }
+ if(this.writer){
+ this.writer.meta = this.reader.meta;
+ }
+ this.modified = [];
+ this.fireEvent('metachange', this, this.reader.meta);
+ },
+
+
+ findInsertIndex : function(record){
+ this.suspendEvents();
+ var data = this.data.clone();
+ this.data.add(record);
+ this.applySort();
+ var index = this.data.indexOf(record);
+ this.data = data;
+ this.resumeEvents();
+ return index;
+ },
+
+
+ setBaseParam : function (name, value){
+ this.baseParams = this.baseParams || {};
+ this.baseParams[name] = value;
+ }
+});
+
+Ext.reg('store', Ext.data.Store);
+
+
+Ext.data.Store.Error = Ext.extend(Ext.Error, {
+ name: 'Ext.data.Store'
+});
+Ext.apply(Ext.data.Store.Error.prototype, {
+ lang: {
+ 'writer-undefined' : 'Attempted to execute a write-action without a DataWriter installed.'
+ }
+});
+
+Ext.data.Field = Ext.extend(Object, {
+
+ constructor : function(config){
+ if(Ext.isString(config)){
+ config = {name: config};
+ }
+ Ext.apply(this, config);
+
+ var types = Ext.data.Types,
+ st = this.sortType,
+ t;
+
+ if(this.type){
+ if(Ext.isString(this.type)){
+ this.type = Ext.data.Types[this.type.toUpperCase()] || types.AUTO;
+ }
+ }else{
+ this.type = types.AUTO;
+ }
+
+
+ if(Ext.isString(st)){
+ this.sortType = Ext.data.SortTypes[st];
+ }else if(Ext.isEmpty(st)){
+ this.sortType = this.type.sortType;
+ }
+
+ if(!this.convert){
+ this.convert = this.type.convert;
+ }
+ },
+
+
+
+
+
+ dateFormat: null,
+
+
+ useNull: false,
+
+
+ defaultValue: "",
+
+ mapping: null,
+
+ sortType : null,
+
+ sortDir : "ASC",
+
+ allowBlank : true
+});
+
+Ext.data.DataReader = function(meta, recordType){
+
+ this.meta = meta;
+
+ this.recordType = Ext.isArray(recordType) ?
+ Ext.data.Record.create(recordType) : recordType;
+
+
+ if (this.recordType){
+ this.buildExtractors();
+ }
+};
+
+Ext.data.DataReader.prototype = {
+
+
+ getTotal: Ext.emptyFn,
+
+ getRoot: Ext.emptyFn,
+
+ getMessage: Ext.emptyFn,
+
+ getSuccess: Ext.emptyFn,
+
+ getId: Ext.emptyFn,
+
+ buildExtractors : Ext.emptyFn,
+
+ extractValues : Ext.emptyFn,
+
+
+ realize: function(rs, data){
+ if (Ext.isArray(rs)) {
+ for (var i = rs.length - 1; i >= 0; i--) {
+
+ if (Ext.isArray(data)) {
+ this.realize(rs.splice(i,1).shift(), data.splice(i,1).shift());
+ }
+ else {
+
+
+ this.realize(rs.splice(i,1).shift(), data);
+ }
+ }
+ }
+ else {
+
+ if (Ext.isArray(data) && data.length == 1) {
+ data = data.shift();
+ }
+ if (!this.isData(data)) {
+
+
+ throw new Ext.data.DataReader.Error('realize', rs);
+ }
+ rs.phantom = false;
+ rs._phid = rs.id;
+ rs.id = this.getId(data);
+ rs.data = data;
+
+ rs.commit();
+ }
+ },
+
+
+ update : function(rs, data) {
+ if (Ext.isArray(rs)) {
+ for (var i=rs.length-1; i >= 0; i--) {
+ if (Ext.isArray(data)) {
+ this.update(rs.splice(i,1).shift(), data.splice(i,1).shift());
+ }
+ else {
+
+
+ this.update(rs.splice(i,1).shift(), data);
+ }
+ }
+ }
+ else {
+
+ if (Ext.isArray(data) && data.length == 1) {
+ data = data.shift();
+ }
+ if (this.isData(data)) {
+ rs.data = Ext.apply(rs.data, data);
+ }
+ rs.commit();
+ }
+ },
+
+
+ extractData : function(root, returnRecords) {
+
+ var rawName = (this instanceof Ext.data.JsonReader) ? 'json' : 'node';
+
+ var rs = [];
+
+
+
+ if (this.isData(root) && !(this instanceof Ext.data.XmlReader)) {
+ root = [root];
+ }
+ var f = this.recordType.prototype.fields,
+ fi = f.items,
+ fl = f.length,
+ rs = [];
+ if (returnRecords === true) {
+ var Record = this.recordType;
+ for (var i = 0; i < root.length; i++) {
+ var n = root[i];
+ var record = new Record(this.extractValues(n, fi, fl), this.getId(n));
+ record[rawName] = n;
+ rs.push(record);
+ }
+ }
+ else {
+ for (var i = 0; i < root.length; i++) {
+ var data = this.extractValues(root[i], fi, fl);
+ data[this.meta.idProperty] = this.getId(root[i]);
+ rs.push(data);
+ }
+ }
+ return rs;
+ },
+
+
+ isData : function(data) {
+ return (data && Ext.isObject(data) && !Ext.isEmpty(this.getId(data))) ? true : false;
+ },
+
+
+ onMetaChange : function(meta){
+ delete this.ef;
+ this.meta = meta;
+ this.recordType = Ext.data.Record.create(meta.fields);
+ this.buildExtractors();
+ }
+};
+
+
+Ext.data.DataReader.Error = Ext.extend(Ext.Error, {
+ constructor : function(message, arg) {
+ this.arg = arg;
+ Ext.Error.call(this, message);
+ },
+ name: 'Ext.data.DataReader'
+});
+Ext.apply(Ext.data.DataReader.Error.prototype, {
+ lang : {
+ 'update': "#update received invalid data from server. Please see docs for DataReader#update and review your DataReader configuration.",
+ 'realize': "#realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.",
+ 'invalid-response': "#readResponse received an invalid response from the server."
+ }
+});
+
+Ext.data.DataWriter = function(config){
+ Ext.apply(this, config);
+};
+Ext.data.DataWriter.prototype = {
+
+
+ writeAllFields : false,
+
+ listful : false,
+
+
+ apply : function(params, baseParams, action, rs) {
+ var data = [],
+ renderer = action + 'Record';
+
+ if (Ext.isArray(rs)) {
+ Ext.each(rs, function(rec){
+ data.push(this[renderer](rec));
+ }, this);
+ }
+ else if (rs instanceof Ext.data.Record) {
+ data = this[renderer](rs);
+ }
+ this.render(params, baseParams, data);
+ },
+
+
+ render : Ext.emptyFn,
+
+
+ updateRecord : Ext.emptyFn,
+
+
+ createRecord : Ext.emptyFn,
+
+
+ destroyRecord : Ext.emptyFn,
+
+
+ toHash : function(rec, config) {
+ var map = rec.fields.map,
+ data = {},
+ raw = (this.writeAllFields === false && rec.phantom === false) ? rec.getChanges() : rec.data,
+ m;
+ Ext.iterate(raw, function(prop, value){
+ if((m = map[prop])){
+ data[m.mapping ? m.mapping : m.name] = value;
+ }
+ });
+
+
+
+ if (rec.phantom) {
+ if (rec.fields.containsKey(this.meta.idProperty) && Ext.isEmpty(rec.data[this.meta.idProperty])) {
+ delete data[this.meta.idProperty];
+ }
+ } else {
+ data[this.meta.idProperty] = rec.id;
+ }
+ return data;
+ },
+
+
+ toArray : function(data) {
+ var fields = [];
+ Ext.iterate(data, function(k, v) {fields.push({name: k, value: v});},this);
+ return fields;
+ }
+};
+Ext.data.DataProxy = function(conn){
+
+
+ conn = conn || {};
+
+
+
+
+
+ this.api = conn.api;
+ this.url = conn.url;
+ this.restful = conn.restful;
+ this.listeners = conn.listeners;
+
+
+ this.prettyUrls = conn.prettyUrls;
+
+
+
+ this.addEvents(
+
+ 'exception',
+
+ 'beforeload',
+
+ 'load',
+
+ 'loadexception',
+
+ 'beforewrite',
+
+ 'write'
+ );
+ Ext.data.DataProxy.superclass.constructor.call(this);
+
+
+ try {
+ Ext.data.Api.prepare(this);
+ } catch (e) {
+ if (e instanceof Ext.data.Api.Error) {
+ e.toConsole();
+ }
+ }
+
+ Ext.data.DataProxy.relayEvents(this, ['beforewrite', 'write', 'exception']);
+};
+
+Ext.extend(Ext.data.DataProxy, Ext.util.Observable, {
+
+ restful: false,
+
+
+ setApi : function() {
+ if (arguments.length == 1) {
+ var valid = Ext.data.Api.isValid(arguments[0]);
+ if (valid === true) {
+ this.api = arguments[0];
+ }
+ else {
+ throw new Ext.data.Api.Error('invalid', valid);
+ }
+ }
+ else if (arguments.length == 2) {
+ if (!Ext.data.Api.isAction(arguments[0])) {
+ throw new Ext.data.Api.Error('invalid', arguments[0]);
+ }
+ this.api[arguments[0]] = arguments[1];
+ }
+ Ext.data.Api.prepare(this);
+ },
+
+
+ isApiAction : function(action) {
+ return (this.api[action]) ? true : false;
+ },
+
+
+ request : function(action, rs, params, reader, callback, scope, options) {
+ if (!this.api[action] && !this.load) {
+ throw new Ext.data.DataProxy.Error('action-undefined', action);
+ }
+ params = params || {};
+ if ((action === Ext.data.Api.actions.read) ? this.fireEvent("beforeload", this, params) : this.fireEvent("beforewrite", this, action, rs, params) !== false) {
+ this.doRequest.apply(this, arguments);
+ }
+ else {
+ callback.call(scope || this, null, options, false);
+ }
+ },
+
+
+
+ load : null,
+
+
+ doRequest : function(action, rs, params, reader, callback, scope, options) {
+
+
+
+ this.load(params, reader, callback, scope, options);
+ },
+
+
+ onRead : Ext.emptyFn,
+
+ onWrite : Ext.emptyFn,
+
+ buildUrl : function(action, record) {
+ record = record || null;
+
+
+
+
+ var url = (this.conn && this.conn.url) ? this.conn.url : (this.api[action]) ? this.api[action].url : this.url;
+ if (!url) {
+ throw new Ext.data.Api.Error('invalid-url', action);
+ }
+
+
+
+
+
+
+
+ var provides = null;
+ var m = url.match(/(.*)(\.json|\.xml|\.html)$/);
+ if (m) {
+ provides = m[2];
+ url = m[1];
+ }
+
+ if ((this.restful === true || this.prettyUrls === true) && record instanceof Ext.data.Record && !record.phantom) {
+ url += '/' + record.id;
+ }
+ return (provides === null) ? url : url + provides;
+ },
+
+
+ destroy: function(){
+ this.purgeListeners();
+ }
+});
+
+
+
+Ext.apply(Ext.data.DataProxy, Ext.util.Observable.prototype);
+Ext.util.Observable.call(Ext.data.DataProxy);
+
+
+Ext.data.DataProxy.Error = Ext.extend(Ext.Error, {
+ constructor : function(message, arg) {
+ this.arg = arg;
+ Ext.Error.call(this, message);
+ },
+ name: 'Ext.data.DataProxy'
+});
+Ext.apply(Ext.data.DataProxy.Error.prototype, {
+ lang: {
+ 'action-undefined': "DataProxy attempted to execute an API-action but found an undefined url / function. Please review your Proxy url/api-configuration.",
+ 'api-invalid': 'Recieved an invalid API-configuration. Please ensure your proxy API-configuration contains only the actions from Ext.data.Api.actions.'
+ }
+});
+
+
+
+Ext.data.Request = function(params) {
+ Ext.apply(this, params);
+};
+Ext.data.Request.prototype = {
+
+ action : undefined,
+
+ rs : undefined,
+
+ params: undefined,
+
+ callback : Ext.emptyFn,
+
+ scope : undefined,
+
+ reader : undefined
+};
+
+Ext.data.Response = function(params) {
+ Ext.apply(this, params);
+};
+Ext.data.Response.prototype = {
+
+ action: undefined,
+
+ success : undefined,
+
+ message : undefined,
+
+ data: undefined,
+
+ raw: undefined,
+
+ records: undefined
+};
+
+Ext.data.ScriptTagProxy = function(config){
+ Ext.apply(this, config);
+
+ Ext.data.ScriptTagProxy.superclass.constructor.call(this, config);
+
+ this.head = document.getElementsByTagName("head")[0];
+
+
+};
+
+Ext.data.ScriptTagProxy.TRANS_ID = 1000;
+
+Ext.extend(Ext.data.ScriptTagProxy, Ext.data.DataProxy, {
+
+
+ timeout : 30000,
+
+ callbackParam : "callback",
+
+ nocache : true,
+
+
+ doRequest : function(action, rs, params, reader, callback, scope, arg) {
+ var p = Ext.urlEncode(Ext.apply(params, this.extraParams));
+
+ var url = this.buildUrl(action, rs);
+ if (!url) {
+ throw new Ext.data.Api.Error('invalid-url', url);
+ }
+ url = Ext.urlAppend(url, p);
+
+ if(this.nocache){
+ url = Ext.urlAppend(url, '_dc=' + (new Date().getTime()));
+ }
+ var transId = ++Ext.data.ScriptTagProxy.TRANS_ID;
+ var trans = {
+ id : transId,
+ action: action,
+ cb : "stcCallback"+transId,
+ scriptId : "stcScript"+transId,
+ params : params,
+ arg : arg,
+ url : url,
+ callback : callback,
+ scope : scope,
+ reader : reader
+ };
+ window[trans.cb] = this.createCallback(action, rs, trans);
+ url += String.format("&{0}={1}", this.callbackParam, trans.cb);
+ if(this.autoAbort !== false){
+ this.abort();
+ }
+
+ trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
+
+ var script = document.createElement("script");
+ script.setAttribute("src", url);
+ script.setAttribute("type", "text/javascript");
+ script.setAttribute("id", trans.scriptId);
+ this.head.appendChild(script);
+
+ this.trans = trans;
+ },
+
+
+ createCallback : function(action, rs, trans) {
+ var self = this;
+ return function(res) {
+ self.trans = false;
+ self.destroyTrans(trans, true);
+ if (action === Ext.data.Api.actions.read) {
+ self.onRead.call(self, action, trans, res);
+ } else {
+ self.onWrite.call(self, action, trans, res, rs);
+ }
+ };
+ },
+
+ onRead : function(action, trans, res) {
+ var result;
+ try {
+ result = trans.reader.readRecords(res);
+ }catch(e){
+
+ this.fireEvent("loadexception", this, trans, res, e);
+
+ this.fireEvent('exception', this, 'response', action, trans, res, e);
+ trans.callback.call(trans.scope||window, null, trans.arg, false);
+ return;
+ }
+ if (result.success === false) {
+
+ this.fireEvent('loadexception', this, trans, res);
+
+ this.fireEvent('exception', this, 'remote', action, trans, res, null);
+ } else {
+ this.fireEvent("load", this, res, trans.arg);
+ }
+ trans.callback.call(trans.scope||window, result, trans.arg, result.success);
+ },
+
+ onWrite : function(action, trans, response, rs) {
+ var reader = trans.reader;
+ try {
+
+ var res = reader.readResponse(action, response);
+ } catch (e) {
+ this.fireEvent('exception', this, 'response', action, trans, res, e);
+ trans.callback.call(trans.scope||window, null, res, false);
+ return;
+ }
+ if(!res.success === true){
+ this.fireEvent('exception', this, 'remote', action, trans, res, rs);
+ trans.callback.call(trans.scope||window, null, res, false);
+ return;
+ }
+ this.fireEvent("write", this, action, res.data, res, rs, trans.arg );
+ trans.callback.call(trans.scope||window, res.data, res, true);
+ },
+
+
+ isLoading : function(){
+ return this.trans ? true : false;
+ },
+
+
+ abort : function(){
+ if(this.isLoading()){
+ this.destroyTrans(this.trans);
+ }
+ },
+
+
+ destroyTrans : function(trans, isLoaded){
+ this.head.removeChild(document.getElementById(trans.scriptId));
+ clearTimeout(trans.timeoutId);
+ if(isLoaded){
+ window[trans.cb] = undefined;
+ try{
+ delete window[trans.cb];
+ }catch(e){}
+ }else{
+
+ window[trans.cb] = function(){
+ window[trans.cb] = undefined;
+ try{
+ delete window[trans.cb];
+ }catch(e){}
+ };
+ }
+ },
+
+
+ handleFailure : function(trans){
+ this.trans = false;
+ this.destroyTrans(trans, false);
+ if (trans.action === Ext.data.Api.actions.read) {
+
+ this.fireEvent("loadexception", this, null, trans.arg);
+ }
+
+ this.fireEvent('exception', this, 'response', trans.action, {
+ response: null,
+ options: trans.arg
+ });
+ trans.callback.call(trans.scope||window, null, trans.arg, false);
+ },
+
+
+ destroy: function(){
+ this.abort();
+ Ext.data.ScriptTagProxy.superclass.destroy.call(this);
+ }
+});
+Ext.data.HttpProxy = function(conn){
+ Ext.data.HttpProxy.superclass.constructor.call(this, conn);
+
+
+ this.conn = conn;
+
+
+
+
+
+ this.conn.url = null;
+
+ this.useAjax = !conn || !conn.events;
+
+
+ var actions = Ext.data.Api.actions;
+ this.activeRequest = {};
+ for (var verb in actions) {
+ this.activeRequest[actions[verb]] = undefined;
+ }
+};
+
+Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
+
+ getConnection : function() {
+ return this.useAjax ? Ext.Ajax : this.conn;
+ },
+
+
+ setUrl : function(url, makePermanent) {
+ this.conn.url = url;
+ if (makePermanent === true) {
+ this.url = url;
+ this.api = null;
+ Ext.data.Api.prepare(this);
+ }
+ },
+
+
+ doRequest : function(action, rs, params, reader, cb, scope, arg) {
+ var o = {
+ method: (this.api[action]) ? this.api[action]['method'] : undefined,
+ request: {
+ callback : cb,
+ scope : scope,
+ arg : arg
+ },
+ reader: reader,
+ callback : this.createCallback(action, rs),
+ scope: this
+ };
+
+
+
+ if (params.jsonData) {
+ o.jsonData = params.jsonData;
+ } else if (params.xmlData) {
+ o.xmlData = params.xmlData;
+ } else {
+ o.params = params || {};
+ }
+
+
+
+ this.conn.url = this.buildUrl(action, rs);
+
+ if(this.useAjax){
+
+ Ext.applyIf(o, this.conn);
+
+
+ if (this.activeRequest[action]) {
+
+
+
+
+
+ }
+ this.activeRequest[action] = Ext.Ajax.request(o);
+ }else{
+ this.conn.request(o);
+ }
+
+ this.conn.url = null;
+ },
+
+
+ createCallback : function(action, rs) {
+ return function(o, success, response) {
+ this.activeRequest[action] = undefined;
+ if (!success) {
+ if (action === Ext.data.Api.actions.read) {
+
+
+ this.fireEvent('loadexception', this, o, response);
+ }
+ this.fireEvent('exception', this, 'response', action, o, response);
+ o.request.callback.call(o.request.scope, null, o.request.arg, false);
+ return;
+ }
+ if (action === Ext.data.Api.actions.read) {
+ this.onRead(action, o, response);
+ } else {
+ this.onWrite(action, o, response, rs);
+ }
+ };
+ },
+
+
+ onRead : function(action, o, response) {
+ var result;
+ try {
+ result = o.reader.read(response);
+ }catch(e){
+
+
+ this.fireEvent('loadexception', this, o, response, e);
+
+ this.fireEvent('exception', this, 'response', action, o, response, e);
+ o.request.callback.call(o.request.scope, null, o.request.arg, false);
+ return;
+ }
+ if (result.success === false) {
+
+
+ this.fireEvent('loadexception', this, o, response);
+
+
+ var res = o.reader.readResponse(action, response);
+ this.fireEvent('exception', this, 'remote', action, o, res, null);
+ }
+ else {
+ this.fireEvent('load', this, o, o.request.arg);
+ }
+
+
+
+ o.request.callback.call(o.request.scope, result, o.request.arg, result.success);
+ },
+
+ onWrite : function(action, o, response, rs) {
+ var reader = o.reader;
+ var res;
+ try {
+ res = reader.readResponse(action, response);
+ } catch (e) {
+ this.fireEvent('exception', this, 'response', action, o, response, e);
+ o.request.callback.call(o.request.scope, null, o.request.arg, false);
+ return;
+ }
+ if (res.success === true) {
+ this.fireEvent('write', this, action, res.data, res, rs, o.request.arg);
+ } else {
+ this.fireEvent('exception', this, 'remote', action, o, res, rs);
+ }
+
+
+
+ o.request.callback.call(o.request.scope, res.data, res, res.success);
+ },
+
+
+ destroy: function(){
+ if(!this.useAjax){
+ this.conn.abort();
+ }else if(this.activeRequest){
+ var actions = Ext.data.Api.actions;
+ for (var verb in actions) {
+ if(this.activeRequest[actions[verb]]){
+ Ext.Ajax.abort(this.activeRequest[actions[verb]]);
+ }
+ }
+ }
+ Ext.data.HttpProxy.superclass.destroy.call(this);
+ }
+});
+Ext.data.MemoryProxy = function(data){
+
+ var api = {};
+ api[Ext.data.Api.actions.read] = true;
+ Ext.data.MemoryProxy.superclass.constructor.call(this, {
+ api: api
+ });
+ this.data = data;
+};
+
+Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
+
+
+
+ doRequest : function(action, rs, params, reader, callback, scope, arg) {
+
+ params = params || {};
+ var result;
+ try {
+ result = reader.readRecords(this.data);
+ }catch(e){
+
+ this.fireEvent("loadexception", this, null, arg, e);
+
+ this.fireEvent('exception', this, 'response', action, arg, null, e);
+ callback.call(scope, null, arg, false);
+ return;
+ }
+ callback.call(scope, result, arg, true);
+ }
+});
+Ext.data.Types = new function(){
+ var st = Ext.data.SortTypes;
+ Ext.apply(this, {
+
+ stripRe: /[\$,%]/g,
+
+
+ AUTO: {
+ convert: function(v){ return v; },
+ sortType: st.none,
+ type: 'auto'
+ },
+
+
+ STRING: {
+ convert: function(v){ return (v === undefined || v === null) ? '' : String(v); },
+ sortType: st.asUCString,
+ type: 'string'
+ },
+
+
+ INT: {
+ convert: function(v){
+ return v !== undefined && v !== null && v !== '' ?
+ parseInt(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);
+ },
+ sortType: st.none,
+ type: 'int'
+ },
+
+
+ FLOAT: {
+ convert: function(v){
+ return v !== undefined && v !== null && v !== '' ?
+ parseFloat(String(v).replace(Ext.data.Types.stripRe, ''), 10) : (this.useNull ? null : 0);
+ },
+ sortType: st.none,
+ type: 'float'
+ },
+
+
+ BOOL: {
+ convert: function(v){ return v === true || v === 'true' || v == 1; },
+ sortType: st.none,
+ type: 'bool'
+ },
+
+
+ DATE: {
+ convert: function(v){
+ var df = this.dateFormat;
+ if(!v){
+ return null;
+ }
+ if(Ext.isDate(v)){
+ return v;
+ }
+ if(df){
+ if(df == 'timestamp'){
+ return new Date(v*1000);
+ }
+ if(df == 'time'){
+ return new Date(parseInt(v, 10));
+ }
+ return Date.parseDate(v, df);
+ }
+ var parsed = Date.parse(v);
+ return parsed ? new Date(parsed) : null;
+ },
+ sortType: st.asDate,
+ type: 'date'
+ }
+ });
+
+ Ext.apply(this, {
+
+ BOOLEAN: this.BOOL,
+
+ INTEGER: this.INT,
+
+ NUMBER: this.FLOAT
+ });
+};
+Ext.data.JsonWriter = Ext.extend(Ext.data.DataWriter, {
+
+ encode : true,
+
+ encodeDelete: false,
+
+ constructor : function(config){
+ Ext.data.JsonWriter.superclass.constructor.call(this, config);
+ },
+
+
+ render : function(params, baseParams, data) {
+ if (this.encode === true) {
+
+ Ext.apply(params, baseParams);
+ params[this.meta.root] = Ext.encode(data);
+ } else {
+
+ var jdata = Ext.apply({}, baseParams);
+ jdata[this.meta.root] = data;
+ params.jsonData = jdata;
+ }
+ },
+
+ createRecord : function(rec) {
+ return this.toHash(rec);
+ },
+
+ updateRecord : function(rec) {
+ return this.toHash(rec);
+
+ },
+
+ destroyRecord : function(rec){
+ if(this.encodeDelete){
+ var data = {};
+ data[this.meta.idProperty] = rec.id;
+ return data;
+ }else{
+ return rec.id;
+ }
+ }
+});
+Ext.data.JsonReader = function(meta, recordType){
+ meta = meta || {};
+
+
+
+
+ Ext.applyIf(meta, {
+ idProperty: 'id',
+ successProperty: 'success',
+ totalProperty: 'total'
+ });
+
+ Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
+};
+Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
+
+
+ read : function(response){
+ var json = response.responseText;
+ var o = Ext.decode(json);
+ if(!o) {
+ throw {message: 'JsonReader.read: Json object not found'};
+ }
+ return this.readRecords(o);
+ },
+
+
+
+ readResponse : function(action, response) {
+ var o = (response.responseText !== undefined) ? Ext.decode(response.responseText) : response;
+ if(!o) {
+ throw new Ext.data.JsonReader.Error('response');
+ }
+
+ var root = this.getRoot(o);
+ if (action === Ext.data.Api.actions.create) {
+ var def = Ext.isDefined(root);
+ if (def && Ext.isEmpty(root)) {
+ throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
+ }
+ else if (!def) {
+ throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
+ }
+ }
+
+
+ var res = new Ext.data.Response({
+ action: action,
+ success: this.getSuccess(o),
+ data: (root) ? this.extractData(root, false) : [],
+ message: this.getMessage(o),
+ raw: o
+ });
+
+
+ if (Ext.isEmpty(res.success)) {
+ throw new Ext.data.JsonReader.Error('successProperty-response', this.meta.successProperty);
+ }
+ return res;
+ },
+
+
+ readRecords : function(o){
+
+ this.jsonData = o;
+ if(o.metaData){
+ this.onMetaChange(o.metaData);
+ }
+ var s = this.meta, Record = this.recordType,
+ f = Record.prototype.fields, fi = f.items, fl = f.length, v;
+
+ var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
+ if(s.totalProperty){
+ v = parseInt(this.getTotal(o), 10);
+ if(!isNaN(v)){
+ totalRecords = v;
+ }
+ }
+ if(s.successProperty){
+ v = this.getSuccess(o);
+ if(v === false || v === 'false'){
+ success = false;
+ }
+ }
+
+
+ return {
+ success : success,
+ records : this.extractData(root, true),
+ totalRecords : totalRecords
+ };
+ },
+
+
+ buildExtractors : function() {
+ if(this.ef){
+ return;
+ }
+ var s = this.meta, Record = this.recordType,
+ f = Record.prototype.fields, fi = f.items, fl = f.length;
+
+ if(s.totalProperty) {
+ this.getTotal = this.createAccessor(s.totalProperty);
+ }
+ if(s.successProperty) {
+ this.getSuccess = this.createAccessor(s.successProperty);
+ }
+ if (s.messageProperty) {
+ this.getMessage = this.createAccessor(s.messageProperty);
+ }
+ this.getRoot = s.root ? this.createAccessor(s.root) : function(p){return p;};
+ if (s.id || s.idProperty) {
+ var g = this.createAccessor(s.id || s.idProperty);
+ this.getId = function(rec) {
+ var r = g(rec);
+ return (r === undefined || r === '') ? null : r;
+ };
+ } else {
+ this.getId = function(){return null;};
+ }
+ var ef = [];
+ for(var i = 0; i < fl; i++){
+ f = fi[i];
+ var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
+ ef.push(this.createAccessor(map));
+ }
+ this.ef = ef;
+ },
+
+
+ simpleAccess : function(obj, subsc) {
+ return obj[subsc];
+ },
+
+
+ createAccessor : function(){
+ var re = /[\[\.]/;
+ return function(expr) {
+ if(Ext.isEmpty(expr)){
+ return Ext.emptyFn;
+ }
+ if(Ext.isFunction(expr)){
+ return expr;
+ }
+ var i = String(expr).search(re);
+ if(i >= 0){
+ return new Function('obj', 'return obj' + (i > 0 ? '.' : '') + expr);
+ }
+ return function(obj){
+ return obj[expr];
+ };
+
+ };
+ }(),
+
+
+ extractValues : function(data, items, len) {
+ var f, values = {};
+ for(var j = 0; j < len; j++){
+ f = items[j];
+ var v = this.ef[j](data);
+ values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
+ }
+ return values;
+ }
+});
+
+
+Ext.data.JsonReader.Error = Ext.extend(Ext.Error, {
+ constructor : function(message, arg) {
+ this.arg = arg;
+ Ext.Error.call(this, message);
+ },
+ name : 'Ext.data.JsonReader'
+});
+Ext.apply(Ext.data.JsonReader.Error.prototype, {
+ lang: {
+ 'response': 'An error occurred while json-decoding your server response',
+ 'successProperty-response': 'Could not locate your "successProperty" in your server response. Please review your JsonReader config to ensure the config-property "successProperty" matches the property in your server-response. See the JsonReader docs.',
+ 'root-undefined-config': 'Your JsonReader was configured without a "root" property. Please review your JsonReader config and make sure to define the root property. See the JsonReader docs.',
+ 'idProperty-undefined' : 'Your JsonReader was configured without an "idProperty" Please review your JsonReader configuration and ensure the "idProperty" is set (e.g.: "id"). See the JsonReader docs.',
+ 'root-empty': 'Data was expected to be returned by the server in the "root" property of the response. Please review your JsonReader configuration to ensure the "root" property matches that returned in the server-response. See JsonReader docs.'
+ }
+});
+
+Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
+
+
+
+
+ readRecords : function(o){
+ this.arrayData = o;
+ var s = this.meta,
+ sid = s ? Ext.num(s.idIndex, s.id) : null,
+ recordType = this.recordType,
+ fields = recordType.prototype.fields,
+ records = [],
+ success = true,
+ v;
+
+ var root = this.getRoot(o);
+
+ for(var i = 0, len = root.length; i < len; i++) {
+ var n = root[i],
+ values = {},
+ id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
+ for(var j = 0, jlen = fields.length; j < jlen; j++) {
+ var f = fields.items[j],
+ k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
+ v = n[k] !== undefined ? n[k] : f.defaultValue;
+ v = f.convert(v, n);
+ values[f.name] = v;
+ }
+ var record = new recordType(values, id);
+ record.json = n;
+ records[records.length] = record;
+ }
+
+ var totalRecords = records.length;
+
+ if(s.totalProperty) {
+ v = parseInt(this.getTotal(o), 10);
+ if(!isNaN(v)) {
+ totalRecords = v;
+ }
+ }
+ if(s.successProperty){
+ v = this.getSuccess(o);
+ if(v === false || v === 'false'){
+ success = false;
+ }
+ }
+
+ return {
+ success : success,
+ records : records,
+ totalRecords : totalRecords
+ };
+ }
+});
+Ext.data.ArrayStore = Ext.extend(Ext.data.Store, {
+
+ constructor: function(config){
+ Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, {
+ reader: new Ext.data.ArrayReader(config)
+ }));
+ },
+
+ loadData : function(data, append){
+ if(this.expandData === true){
+ var r = [];
+ for(var i = 0, len = data.length; i < len; i++){
+ r[r.length] = [data[i]];
+ }
+ data = r;
+ }
+ Ext.data.ArrayStore.superclass.loadData.call(this, data, append);
+ }
+});
+Ext.reg('arraystore', Ext.data.ArrayStore);
+
+
+Ext.data.SimpleStore = Ext.data.ArrayStore;
+Ext.reg('simplestore', Ext.data.SimpleStore);
+Ext.data.JsonStore = Ext.extend(Ext.data.Store, {
+
+ constructor: function(config){
+ Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(config, {
+ reader: new Ext.data.JsonReader(config)
+ }));
+ }
+});
+Ext.reg('jsonstore', Ext.data.JsonStore);
+Ext.data.XmlWriter = function(params) {
+ Ext.data.XmlWriter.superclass.constructor.apply(this, arguments);
+
+ this.tpl = (typeof(this.tpl) === 'string') ? new Ext.XTemplate(this.tpl).compile() : this.tpl.compile();
+};
+Ext.extend(Ext.data.XmlWriter, Ext.data.DataWriter, {
+
+ documentRoot: 'xrequest',
+
+ forceDocumentRoot: false,
+
+ root: 'records',
+
+ xmlVersion : '1.0',
+
+ xmlEncoding: 'ISO-8859-15',
+
+
+ tpl: '<tpl for="."><\u003fxml version="{version}" encoding="{encoding}"\u003f><tpl if="documentRoot"><{documentRoot}><tpl for="baseParams"><tpl for="."><{name}>{value}</{name}></tpl></tpl></tpl><tpl if="records.length>1"><{root}></tpl><tpl for="records"><{parent.record}><tpl for="."><{name}>{value}</{name}></tpl></{parent.record}></tpl><tpl if="records.length>1"></{root}></tpl><tpl if="documentRoot"></{documentRoot}></tpl></tpl>',
+
+
+
+ render : function(params, baseParams, data) {
+ baseParams = this.toArray(baseParams);
+ params.xmlData = this.tpl.applyTemplate({
+ version: this.xmlVersion,
+ encoding: this.xmlEncoding,
+ documentRoot: (baseParams.length > 0 || this.forceDocumentRoot === true) ? this.documentRoot : false,
+ record: this.meta.record,
+ root: this.root,
+ baseParams: baseParams,
+ records: (Ext.isArray(data[0])) ? data : [data]
+ });
+ },
+
+
+ createRecord : function(rec) {
+ return this.toArray(this.toHash(rec));
+ },
+
+
+ updateRecord : function(rec) {
+ return this.toArray(this.toHash(rec));
+
+ },
+
+ destroyRecord : function(rec) {
+ var data = {};
+ data[this.meta.idProperty] = rec.id;
+ return this.toArray(data);
+ }
+});
+
+Ext.data.XmlReader = function(meta, recordType){
+ meta = meta || {};
+
+
+ Ext.applyIf(meta, {
+ idProperty: meta.idProperty || meta.idPath || meta.id,
+ successProperty: meta.successProperty || meta.success
+ });
+
+ Ext.data.XmlReader.superclass.constructor.call(this, meta, recordType || meta.fields);
+};
+Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, {
+
+ read : function(response){
+ var doc = response.responseXML;
+ if(!doc) {
+ throw {message: "XmlReader.read: XML Document not available"};
+ }
+ return this.readRecords(doc);
+ },
+
+
+ readRecords : function(doc){
+
+ this.xmlData = doc;
+
+ var root = doc.documentElement || doc,
+ q = Ext.DomQuery,
+ totalRecords = 0,
+ success = true;
+
+ if(this.meta.totalProperty){
+ totalRecords = this.getTotal(root, 0);
+ }
+ if(this.meta.successProperty){
+ success = this.getSuccess(root);
+ }
+
+ var records = this.extractData(q.select(this.meta.record, root), true);
+
+
+ return {
+ success : success,
+ records : records,
+ totalRecords : totalRecords || records.length
+ };
+ },
+
+
+ readResponse : function(action, response) {
+ var q = Ext.DomQuery,
+ doc = response.responseXML,
+ root = doc.documentElement || doc;
+
+
+ var res = new Ext.data.Response({
+ action: action,
+ success : this.getSuccess(root),
+ message: this.getMessage(root),
+ data: this.extractData(q.select(this.meta.record, root) || q.select(this.meta.root, root), false),
+ raw: doc
+ });
+
+ if (Ext.isEmpty(res.success)) {
+ throw new Ext.data.DataReader.Error('successProperty-response', this.meta.successProperty);
+ }
+
+
+ if (action === Ext.data.Api.actions.create) {
+ var def = Ext.isDefined(res.data);
+ if (def && Ext.isEmpty(res.data)) {
+ throw new Ext.data.JsonReader.Error('root-empty', this.meta.root);
+ }
+ else if (!def) {
+ throw new Ext.data.JsonReader.Error('root-undefined-response', this.meta.root);
+ }
+ }
+ return res;
+ },
+
+ getSuccess : function() {
+ return true;
+ },
+
+
+ buildExtractors : function() {
+ if(this.ef){
+ return;
+ }
+ var s = this.meta,
+ Record = this.recordType,
+ f = Record.prototype.fields,
+ fi = f.items,
+ fl = f.length;
+
+ if(s.totalProperty) {
+ this.getTotal = this.createAccessor(s.totalProperty);
+ }
+ if(s.successProperty) {
+ this.getSuccess = this.createAccessor(s.successProperty);
+ }
+ if (s.messageProperty) {
+ this.getMessage = this.createAccessor(s.messageProperty);
+ }
+ this.getRoot = function(res) {
+ return (!Ext.isEmpty(res[this.meta.record])) ? res[this.meta.record] : res[this.meta.root];
+ };
+ if (s.idPath || s.idProperty) {
+ var g = this.createAccessor(s.idPath || s.idProperty);
+ this.getId = function(rec) {
+ var id = g(rec) || rec.id;
+ return (id === undefined || id === '') ? null : id;
+ };
+ } else {
+ this.getId = function(){return null;};
+ }
+ var ef = [];
+ for(var i = 0; i < fl; i++){
+ f = fi[i];
+ var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
+ ef.push(this.createAccessor(map));
+ }
+ this.ef = ef;
+ },
+
+
+ createAccessor : function(){
+ var q = Ext.DomQuery;
+ return function(key) {
+ if (Ext.isFunction(key)) {
+ return key;
+ }
+ switch(key) {
+ case this.meta.totalProperty:
+ return function(root, def){
+ return q.selectNumber(key, root, def);
+ };
+ break;
+ case this.meta.successProperty:
+ return function(root, def) {
+ var sv = q.selectValue(key, root, true);
+ var success = sv !== false && sv !== 'false';
+ return success;
+ };
+ break;
+ default:
+ return function(root, def) {
+ return q.selectValue(key, root, def);
+ };
+ break;
+ }
+ };
+ }(),
+
+
+ extractValues : function(data, items, len) {
+ var f, values = {};
+ for(var j = 0; j < len; j++){
+ f = items[j];
+ var v = this.ef[j](data);
+ values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, data);
+ }
+ return values;
+ }
+});
+Ext.data.XmlStore = Ext.extend(Ext.data.Store, {
+
+ constructor: function(config){
+ Ext.data.XmlStore.superclass.constructor.call(this, Ext.apply(config, {
+ reader: new Ext.data.XmlReader(config)
+ }));
+ }
+});
+Ext.reg('xmlstore', Ext.data.XmlStore);
+Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {
+
+
+ constructor: function(config) {
+ config = config || {};
+
+
+
+
+
+ this.hasMultiSort = true;
+ this.multiSortInfo = this.multiSortInfo || {sorters: []};
+
+ var sorters = this.multiSortInfo.sorters,
+ groupField = config.groupField || this.groupField,
+ sortInfo = config.sortInfo || this.sortInfo,
+ groupDir = config.groupDir || this.groupDir;
+
+
+ if(groupField){
+ sorters.push({
+ field : groupField,
+ direction: groupDir
+ });
+ }
+
+
+ if (sortInfo) {
+ sorters.push(sortInfo);
+ }
+
+ Ext.data.GroupingStore.superclass.constructor.call(this, config);
+
+ this.addEvents(
+
+ 'groupchange'
+ );
+
+ this.applyGroupField();
+ },
+
+
+
+ remoteGroup : false,
+
+ groupOnSort:false,
+
+
+ groupDir : 'ASC',
+
+
+ clearGrouping : function(){
+ this.groupField = false;
+
+ if(this.remoteGroup){
+ if(this.baseParams){
+ delete this.baseParams.groupBy;
+ delete this.baseParams.groupDir;
+ }
+ var lo = this.lastOptions;
+ if(lo && lo.params){
+ delete lo.params.groupBy;
+ delete lo.params.groupDir;
+ }
+
+ this.reload();
+ }else{
+ this.sort();
+ this.fireEvent('datachanged', this);
+ }
+ },
+
+
+ groupBy : function(field, forceRegroup, direction) {
+ direction = direction ? (String(direction).toUpperCase() == 'DESC' ? 'DESC' : 'ASC') : this.groupDir;
+
+ if (this.groupField == field && this.groupDir == direction && !forceRegroup) {
+ return;
+ }
+
+
+
+ var sorters = this.multiSortInfo.sorters;
+ if (sorters.length > 0 && sorters[0].field == this.groupField) {
+ sorters.shift();
+ }
+
+ this.groupField = field;
+ this.groupDir = direction;
+ this.applyGroupField();
+
+ var fireGroupEvent = function() {
+ this.fireEvent('groupchange', this, this.getGroupState());
+ };
+
+ if (this.groupOnSort) {
+ this.sort(field, direction);
+ fireGroupEvent.call(this);
+ return;
+ }
+
+ if (this.remoteGroup) {
+ this.on('load', fireGroupEvent, this, {single: true});
+ this.reload();
+ } else {
+ this.sort(sorters);
+ fireGroupEvent.call(this);
+ }
+ },
+
+
+
+ sort : function(fieldName, dir) {
+ if (this.remoteSort) {
+ return Ext.data.GroupingStore.superclass.sort.call(this, fieldName, dir);
+ }
+
+ var sorters = [];
+
+
+ if (Ext.isArray(arguments[0])) {
+ sorters = arguments[0];
+ } else if (fieldName == undefined) {
+
+
+ sorters = this.sortInfo ? [this.sortInfo] : [];
+ } else {
+
+
+ var field = this.fields.get(fieldName);
+ if (!field) return false;
+
+ var name = field.name,
+ sortInfo = this.sortInfo || null,
+ sortToggle = this.sortToggle ? this.sortToggle[name] : null;
+
+ if (!dir) {
+ if (sortInfo && sortInfo.field == name) {
+ dir = (this.sortToggle[name] || 'ASC').toggle('ASC', 'DESC');
+ } else {
+ dir = field.sortDir;
+ }
+ }
+
+ this.sortToggle[name] = dir;
+ this.sortInfo = {field: name, direction: dir};
+
+ sorters = [this.sortInfo];
+ }
+
+
+ if (this.groupField) {
+ sorters.unshift({direction: this.groupDir, field: this.groupField});
+ }
+
+ return this.multiSort.call(this, sorters, dir);
+ },
+
+
+ applyGroupField: function(){
+ if (this.remoteGroup) {
+ if(!this.baseParams){
+ this.baseParams = {};
+ }
+
+ Ext.apply(this.baseParams, {
+ groupBy : this.groupField,
+ groupDir: this.groupDir
+ });
+
+ var lo = this.lastOptions;
+ if (lo && lo.params) {
+ lo.params.groupDir = this.groupDir;
+
+
+ delete lo.params.groupBy;
+ }
+ }
+ },
+
+
+ applyGrouping : function(alwaysFireChange){
+ if(this.groupField !== false){
+ this.groupBy(this.groupField, true, this.groupDir);
+ return true;
+ }else{
+ if(alwaysFireChange === true){
+ this.fireEvent('datachanged', this);
+ }
+ return false;
+ }
+ },
+
+
+ getGroupState : function(){
+ return this.groupOnSort && this.groupField !== false ?
+ (this.sortInfo ? this.sortInfo.field : undefined) : this.groupField;
+ }
+});
+Ext.reg('groupingstore', Ext.data.GroupingStore);
+
+Ext.data.DirectProxy = function(config){
+ Ext.apply(this, config);
+ if(typeof this.paramOrder == 'string'){
+ this.paramOrder = this.paramOrder.split(/[\s,|]/);
+ }
+ Ext.data.DirectProxy.superclass.constructor.call(this, config);
+};
+
+Ext.extend(Ext.data.DirectProxy, Ext.data.DataProxy, {
+
+ paramOrder: undefined,
+
+
+ paramsAsHash: true,
+
+
+ directFn : undefined,
+
+
+ doRequest : function(action, rs, params, reader, callback, scope, options) {
+ var args = [],
+ directFn = this.api[action] || this.directFn;
+
+ switch (action) {
+ case Ext.data.Api.actions.create:
+ args.push(params.jsonData);
+ break;
+ case Ext.data.Api.actions.read:
+
+ if(directFn.directCfg.method.len > 0){
+ if(this.paramOrder){
+ for(var i = 0, len = this.paramOrder.length; i < len; i++){
+ args.push(params[this.paramOrder[i]]);
+ }
+ }else if(this.paramsAsHash){
+ args.push(params);
+ }
+ }
+ break;
+ case Ext.data.Api.actions.update:
+ args.push(params.jsonData);
+ break;
+ case Ext.data.Api.actions.destroy:
+ args.push(params.jsonData);
+ break;
+ }
+
+ var trans = {
+ params : params || {},
+ request: {
+ callback : callback,
+ scope : scope,
+ arg : options
+ },
+ reader: reader
+ };
+
+ args.push(this.createCallback(action, rs, trans), this);
+ directFn.apply(window, args);
+ },
+
+
+ createCallback : function(action, rs, trans) {
+ var me = this;
+ return function(result, res) {
+ if (!res.status) {
+
+ if (action === Ext.data.Api.actions.read) {
+ me.fireEvent("loadexception", me, trans, res, null);
+ }
+ me.fireEvent('exception', me, 'remote', action, trans, res, null);
+ trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
+ return;
+ }
+ if (action === Ext.data.Api.actions.read) {
+ me.onRead(action, trans, result, res);
+ } else {
+ me.onWrite(action, trans, result, res, rs);
+ }
+ };
+ },
+
+
+ onRead : function(action, trans, result, res) {
+ var records;
+ try {
+ records = trans.reader.readRecords(result);
+ }
+ catch (ex) {
+
+ this.fireEvent("loadexception", this, trans, res, ex);
+
+ this.fireEvent('exception', this, 'response', action, trans, res, ex);
+ trans.request.callback.call(trans.request.scope, null, trans.request.arg, false);
+ return;
+ }
+ this.fireEvent("load", this, res, trans.request.arg);
+ trans.request.callback.call(trans.request.scope, records, trans.request.arg, true);
+ },
+
+ onWrite : function(action, trans, result, res, rs) {
+ var data = trans.reader.extractData(trans.reader.getRoot(result), false);
+ var success = trans.reader.getSuccess(result);
+ success = (success !== false);
+ if (success){
+ this.fireEvent("write", this, action, data, res, rs, trans.request.arg);
+ }else{
+ this.fireEvent('exception', this, 'remote', action, trans, result, rs);
+ }
+ trans.request.callback.call(trans.request.scope, data, res, success);
+ }
+});
+
+Ext.data.DirectStore = Ext.extend(Ext.data.Store, {
+ constructor : function(config){
+
+ var c = Ext.apply({}, {
+ batchTransactions: false
+ }, config);
+ Ext.data.DirectStore.superclass.constructor.call(this, Ext.apply(c, {
+ proxy: Ext.isDefined(c.proxy) ? c.proxy : new Ext.data.DirectProxy(Ext.copyTo({}, c, 'paramOrder,paramsAsHash,directFn,api')),
+ reader: (!Ext.isDefined(c.reader) && c.fields) ? new Ext.data.JsonReader(Ext.copyTo({}, c, 'totalProperty,root,idProperty'), c.fields) : c.reader
+ }));
+ }
+});
+Ext.reg('directstore', Ext.data.DirectStore);
+
+Ext.Direct = Ext.extend(Ext.util.Observable, {
+
+
+
+ exceptions: {
+ TRANSPORT: 'xhr',
+ PARSE: 'parse',
+ LOGIN: 'login',
+ SERVER: 'exception'
+ },
+
+
+ constructor: function(){
+ this.addEvents(
+
+ 'event',
+
+ 'exception'
+ );
+ this.transactions = {};
+ this.providers = {};
+ },
+
+
+ addProvider : function(provider){
+ var a = arguments;
+ if(a.length > 1){
+ for(var i = 0, len = a.length; i < len; i++){
+ this.addProvider(a[i]);
+ }
+ return;
+ }
+
+
+ if(!provider.events){
+ provider = new Ext.Direct.PROVIDERS[provider.type](provider);
+ }
+ provider.id = provider.id || Ext.id();
+ this.providers[provider.id] = provider;
+
+ provider.on('data', this.onProviderData, this);
+ provider.on('exception', this.onProviderException, this);
+
+
+ if(!provider.isConnected()){
+ provider.connect();
+ }
+
+ return provider;
+ },
+
+
+ getProvider : function(id){
+ return this.providers[id];
+ },
+
+ removeProvider : function(id){
+ var provider = id.id ? id : this.providers[id];
+ provider.un('data', this.onProviderData, this);
+ provider.un('exception', this.onProviderException, this);
+ delete this.providers[provider.id];
+ return provider;
+ },
+
+ addTransaction: function(t){
+ this.transactions[t.tid] = t;
+ return t;
+ },
+
+ removeTransaction: function(t){
+ delete this.transactions[t.tid || t];
+ return t;
+ },
+
+ getTransaction: function(tid){
+ return this.transactions[tid.tid || tid];
+ },
+
+ onProviderData : function(provider, e){
+ if(Ext.isArray(e)){
+ for(var i = 0, len = e.length; i < len; i++){
+ this.onProviderData(provider, e[i]);
+ }
+ return;
+ }
+ if(e.name && e.name != 'event' && e.name != 'exception'){
+ this.fireEvent(e.name, e);
+ }else if(e.type == 'exception'){
+ this.fireEvent('exception', e);
+ }
+ this.fireEvent('event', e, provider);
+ },
+
+ createEvent : function(response, extraProps){
+ return new Ext.Direct.eventTypes[response.type](Ext.apply(response, extraProps));
+ }
+});
+
+Ext.Direct = new Ext.Direct();
+
+Ext.Direct.TID = 1;
+Ext.Direct.PROVIDERS = {};
+Ext.Direct.Transaction = function(config){
+ Ext.apply(this, config);
+ this.tid = ++Ext.Direct.TID;
+ this.retryCount = 0;
+};
+Ext.Direct.Transaction.prototype = {
+ send: function(){
+ this.provider.queueTransaction(this);
+ },
+
+ retry: function(){
+ this.retryCount++;
+ this.send();
+ },
+
+ getProvider: function(){
+ return this.provider;
+ }
+};Ext.Direct.Event = function(config){
+ Ext.apply(this, config);
+};
+
+Ext.Direct.Event.prototype = {
+ status: true,
+ getData: function(){
+ return this.data;
+ }
+};
+
+Ext.Direct.RemotingEvent = Ext.extend(Ext.Direct.Event, {
+ type: 'rpc',
+ getTransaction: function(){
+ return this.transaction || Ext.Direct.getTransaction(this.tid);
+ }
+});
+
+Ext.Direct.ExceptionEvent = Ext.extend(Ext.Direct.RemotingEvent, {
+ status: false,
+ type: 'exception'
+});
+
+Ext.Direct.eventTypes = {
+ 'rpc': Ext.Direct.RemotingEvent,
+ 'event': Ext.Direct.Event,
+ 'exception': Ext.Direct.ExceptionEvent
+};
+
+Ext.direct.Provider = Ext.extend(Ext.util.Observable, {
+
+
+
+ priority: 1,
+
+
+
+
+ constructor : function(config){
+ Ext.apply(this, config);
+ this.addEvents(
+
+ 'connect',
+
+ 'disconnect',
+
+ 'data',
+
+ 'exception'
+ );
+ Ext.direct.Provider.superclass.constructor.call(this, config);
+ },
+
+
+ isConnected: function(){
+ return false;
+ },
+
+
+ connect: Ext.emptyFn,
+
+
+ disconnect: Ext.emptyFn
+});
+
+Ext.direct.JsonProvider = Ext.extend(Ext.direct.Provider, {
+ parseResponse: function(xhr){
+ if(!Ext.isEmpty(xhr.responseText)){
+ if(typeof xhr.responseText == 'object'){
+ return xhr.responseText;
+ }
+ return Ext.decode(xhr.responseText);
+ }
+ return null;
+ },
+
+ getEvents: function(xhr){
+ var data = null;
+ try{
+ data = this.parseResponse(xhr);
+ }catch(e){
+ var event = new Ext.Direct.ExceptionEvent({
+ data: e,
+ xhr: xhr,
+ code: Ext.Direct.exceptions.PARSE,
+ message: 'Error parsing json response: \n\n ' + data
+ });
+ return [event];
+ }
+ var events = [];
+ if(Ext.isArray(data)){
+ for(var i = 0, len = data.length; i < len; i++){
+ events.push(Ext.Direct.createEvent(data[i]));
+ }
+ }else{
+ events.push(Ext.Direct.createEvent(data));
+ }
+ return events;
+ }
+});
+Ext.direct.PollingProvider = Ext.extend(Ext.direct.JsonProvider, {
+
+
+ priority: 3,
+
+
+ interval: 3000,
+
+
+
+
+
+
+ constructor : function(config){
+ Ext.direct.PollingProvider.superclass.constructor.call(this, config);
+ this.addEvents(
+
+ 'beforepoll',
+
+ 'poll'
+ );
+ },
+
+
+ isConnected: function(){
+ return !!this.pollTask;
+ },
+
+
+ connect: function(){
+ if(this.url && !this.pollTask){
+ this.pollTask = Ext.TaskMgr.start({
+ run: function(){
+ if(this.fireEvent('beforepoll', this) !== false){
+ if(typeof this.url == 'function'){
+ this.url(this.baseParams);
+ }else{
+ Ext.Ajax.request({
+ url: this.url,
+ callback: this.onData,
+ scope: this,
+ params: this.baseParams
+ });
+ }
+ }
+ },
+ interval: this.interval,
+ scope: this
+ });
+ this.fireEvent('connect', this);
+ }else if(!this.url){
+ throw 'Error initializing PollingProvider, no url configured.';
+ }
+ },
+
+
+ disconnect: function(){
+ if(this.pollTask){
+ Ext.TaskMgr.stop(this.pollTask);
+ delete this.pollTask;
+ this.fireEvent('disconnect', this);
+ }
+ },
+
+
+ onData: function(opt, success, xhr){
+ if(success){
+ var events = this.getEvents(xhr);
+ for(var i = 0, len = events.length; i < len; i++){
+ var e = events[i];
+ this.fireEvent('data', this, e);
+ }
+ }else{
+ var e = new Ext.Direct.ExceptionEvent({
+ data: e,
+ code: Ext.Direct.exceptions.TRANSPORT,
+ message: 'Unable to connect to the server.',
+ xhr: xhr
+ });
+ this.fireEvent('data', this, e);
+ }
+ }
+});
+
+Ext.Direct.PROVIDERS['polling'] = Ext.direct.PollingProvider;
+Ext.direct.RemotingProvider = Ext.extend(Ext.direct.JsonProvider, {
+
+
+
+
+
+
+
+
+
+ enableBuffer: 10,
+
+
+ maxRetries: 1,
+
+
+ timeout: undefined,
+
+ constructor : function(config){
+ Ext.direct.RemotingProvider.superclass.constructor.call(this, config);
+ this.addEvents(
+
+ 'beforecall',
+
+ 'call'
+ );
+ this.namespace = (Ext.isString(this.namespace)) ? Ext.ns(this.namespace) : this.namespace || window;
+ this.transactions = {};
+ this.callBuffer = [];
+ },
+
+
+ initAPI : function(){
+ var o = this.actions;
+ for(var c in o){
+ var cls = this.namespace[c] || (this.namespace[c] = {}),
+ ms = o[c];
+ for(var i = 0, len = ms.length; i < len; i++){
+ var m = ms[i];
+ cls[m.name] = this.createMethod(c, m);
+ }
+ }
+ },
+
+
+ isConnected: function(){
+ return !!this.connected;
+ },
+
+ connect: function(){
+ if(this.url){
+ this.initAPI();
+ this.connected = true;
+ this.fireEvent('connect', this);
+ }else if(!this.url){
+ throw 'Error initializing RemotingProvider, no url configured.';
+ }
+ },
+
+ disconnect: function(){
+ if(this.connected){
+ this.connected = false;
+ this.fireEvent('disconnect', this);
+ }
+ },
+
+ onData: function(opt, success, xhr){
+ if(success){
+ var events = this.getEvents(xhr);
+ for(var i = 0, len = events.length; i < len; i++){
+ var e = events[i],
+ t = this.getTransaction(e);
+ this.fireEvent('data', this, e);
+ if(t){
+ this.doCallback(t, e, true);
+ Ext.Direct.removeTransaction(t);
+ }
+ }
+ }else{
+ var ts = [].concat(opt.ts);
+ for(var i = 0, len = ts.length; i < len; i++){
+ var t = this.getTransaction(ts[i]);
+ if(t && t.retryCount < this.maxRetries){
+ t.retry();
+ }else{
+ var e = new Ext.Direct.ExceptionEvent({
+ data: e,
+ transaction: t,
+ code: Ext.Direct.exceptions.TRANSPORT,
+ message: 'Unable to connect to the server.',
+ xhr: xhr
+ });
+ this.fireEvent('data', this, e);
+ if(t){
+ this.doCallback(t, e, false);
+ Ext.Direct.removeTransaction(t);
+ }
+ }
+ }
+ }
+ },
+
+ getCallData: function(t){
+ return {
+ action: t.action,
+ method: t.method,
+ data: t.data,
+ type: 'rpc',
+ tid: t.tid
+ };
+ },
+
+ doSend : function(data){
+ var o = {
+ url: this.url,
+ callback: this.onData,
+ scope: this,
+ ts: data,
+ timeout: this.timeout
+ }, callData;
+
+ if(Ext.isArray(data)){
+ callData = [];
+ for(var i = 0, len = data.length; i < len; i++){
+ callData.push(this.getCallData(data[i]));
+ }
+ }else{
+ callData = this.getCallData(data);
+ }
+
+ if(this.enableUrlEncode){
+ var params = {};
+ params[Ext.isString(this.enableUrlEncode) ? this.enableUrlEncode : 'data'] = Ext.encode(callData);
+ o.params = params;
+ }else{
+ o.jsonData = callData;
+ }
+ Ext.Ajax.request(o);
+ },
+
+ combineAndSend : function(){
+ var len = this.callBuffer.length;
+ if(len > 0){
+ this.doSend(len == 1 ? this.callBuffer[0] : this.callBuffer);
+ this.callBuffer = [];
+ }
+ },
+
+ queueTransaction: function(t){
+ if(t.form){
+ this.processForm(t);
+ return;
+ }
+ this.callBuffer.push(t);
+ if(this.enableBuffer){
+ if(!this.callTask){
+ this.callTask = new Ext.util.DelayedTask(this.combineAndSend, this);
+ }
+ this.callTask.delay(Ext.isNumber(this.enableBuffer) ? this.enableBuffer : 10);
+ }else{
+ this.combineAndSend();
+ }
+ },
+
+ doCall : function(c, m, args){
+ var data = null, hs = args[m.len], scope = args[m.len+1];
+
+ if(m.len !== 0){
+ data = args.slice(0, m.len);
+ }
+
+ var t = new Ext.Direct.Transaction({
+ provider: this,
+ args: args,
+ action: c,
+ method: m.name,
+ data: data,
+ cb: scope && Ext.isFunction(hs) ? hs.createDelegate(scope) : hs
+ });
+
+ if(this.fireEvent('beforecall', this, t, m) !== false){
+ Ext.Direct.addTransaction(t);
+ this.queueTransaction(t);
+ this.fireEvent('call', this, t, m);
+ }
+ },
+
+ doForm : function(c, m, form, callback, scope){
+ var t = new Ext.Direct.Transaction({
+ provider: this,
+ action: c,
+ method: m.name,
+ args:[form, callback, scope],
+ cb: scope && Ext.isFunction(callback) ? callback.createDelegate(scope) : callback,
+ isForm: true
+ });
+
+ if(this.fireEvent('beforecall', this, t, m) !== false){
+ Ext.Direct.addTransaction(t);
+ var isUpload = String(form.getAttribute("enctype")).toLowerCase() == 'multipart/form-data',
+ params = {
+ extTID: t.tid,
+ extAction: c,
+ extMethod: m.name,
+ extType: 'rpc',
+ extUpload: String(isUpload)
+ };
+
+
+
+ Ext.apply(t, {
+ form: Ext.getDom(form),
+ isUpload: isUpload,
+ params: callback && Ext.isObject(callback.params) ? Ext.apply(params, callback.params) : params
+ });
+ this.fireEvent('call', this, t, m);
+ this.processForm(t);
+ }
+ },
+
+ processForm: function(t){
+ Ext.Ajax.request({
+ url: this.url,
+ params: t.params,
+ callback: this.onData,
+ scope: this,
+ form: t.form,
+ isUpload: t.isUpload,
+ ts: t
+ });
+ },
+
+ createMethod : function(c, m){
+ var f;
+ if(!m.formHandler){
+ f = function(){
+ this.doCall(c, m, Array.prototype.slice.call(arguments, 0));
+ }.createDelegate(this);
+ }else{
+ f = function(form, callback, scope){
+ this.doForm(c, m, form, callback, scope);
+ }.createDelegate(this);
+ }
+ f.directCfg = {
+ action: c,
+ method: m
+ };
+ return f;
+ },
+
+ getTransaction: function(opt){
+ return opt && opt.tid ? Ext.Direct.getTransaction(opt.tid) : null;
+ },
+
+ doCallback: function(t, e){
+ var fn = e.status ? 'success' : 'failure';
+ if(t && t.cb){
+ var hs = t.cb,
+ result = Ext.isDefined(e.result) ? e.result : e.data;
+ if(Ext.isFunction(hs)){
+ hs(result, e);
+ } else{
+ Ext.callback(hs[fn], hs.scope, [result, e]);
+ Ext.callback(hs.callback, hs.scope, [result, e]);
+ }
+ }
+ }
+});
+Ext.Direct.PROVIDERS['remoting'] = Ext.direct.RemotingProvider;
+Ext.Resizable = Ext.extend(Ext.util.Observable, {
+
+ constructor: function(el, config){
+ this.el = Ext.get(el);
+ if(config && config.wrap){
+ config.resizeChild = this.el;
+ this.el = this.el.wrap(typeof config.wrap == 'object' ? config.wrap : {cls:'xresizable-wrap'});
+ this.el.id = this.el.dom.id = config.resizeChild.id + '-rzwrap';
+ this.el.setStyle('overflow', 'hidden');
+ this.el.setPositioning(config.resizeChild.getPositioning());
+ config.resizeChild.clearPositioning();
+ if(!config.width || !config.height){
+ var csize = config.resizeChild.getSize();
+ this.el.setSize(csize.width, csize.height);
+ }
+ if(config.pinned && !config.adjustments){
+ config.adjustments = 'auto';
+ }
+ }
+
+
+ this.proxy = this.el.createProxy({tag: 'div', cls: 'x-resizable-proxy', id: this.el.id + '-rzproxy'}, Ext.getBody());
+ this.proxy.unselectable();
+ this.proxy.enableDisplayMode('block');
+
+ Ext.apply(this, config);
+
+ if(this.pinned){
+ this.disableTrackOver = true;
+ this.el.addClass('x-resizable-pinned');
+ }
+
+ var position = this.el.getStyle('position');
+ if(position != 'absolute' && position != 'fixed'){
+ this.el.setStyle('position', 'relative');
+ }
+ if(!this.handles){
+ this.handles = 's,e,se';
+ if(this.multiDirectional){
+ this.handles += ',n,w';
+ }
+ }
+ if(this.handles == 'all'){
+ this.handles = 'n s e w ne nw se sw';
+ }
+ var hs = this.handles.split(/\s*?[,;]\s*?| /);
+ var ps = Ext.Resizable.positions;
+ for(var i = 0, len = hs.length; i < len; i++){
+ if(hs[i] && ps[hs[i]]){
+ var pos = ps[hs[i]];
+ this[pos] = new Ext.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent, this.handleCls);
+ }
+ }
+
+ this.corner = this.southeast;
+
+ if(this.handles.indexOf('n') != -1 || this.handles.indexOf('w') != -1){
+ this.updateBox = true;
+ }
+
+ this.activeHandle = null;
+
+ if(this.resizeChild){
+ if(typeof this.resizeChild == 'boolean'){
+ this.resizeChild = Ext.get(this.el.dom.firstChild, true);
+ }else{
+ this.resizeChild = Ext.get(this.resizeChild, true);
+ }
+ }
+
+ if(this.adjustments == 'auto'){
+ var rc = this.resizeChild;
+ var hw = this.west, he = this.east, hn = this.north, hs = this.south;
+ if(rc && (hw || hn)){
+ rc.position('relative');
+ rc.setLeft(hw ? hw.el.getWidth() : 0);
+ rc.setTop(hn ? hn.el.getHeight() : 0);
+ }
+ this.adjustments = [
+ (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
+ (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
+ ];
+ }
+
+ if(this.draggable){
+ this.dd = this.dynamic ?
+ this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
+ this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
+ if(this.constrainTo){
+ this.dd.constrainTo(this.constrainTo);
+ }
+ }
+
+ this.addEvents(
+
+ 'beforeresize',
+
+ 'resize'
+ );
+
+ if(this.width !== null && this.height !== null){
+ this.resizeTo(this.width, this.height);
+ }else{
+ this.updateChildSize();
+ }
+ if(Ext.isIE){
+ this.el.dom.style.zoom = 1;
+ }
+ Ext.Resizable.superclass.constructor.call(this);
+ },
+
+
+ adjustments : [0, 0],
+
+ animate : false,
+
+
+ disableTrackOver : false,
+
+ draggable: false,
+
+ duration : 0.35,
+
+ dynamic : false,
+
+ easing : 'easeOutStrong',
+
+ enabled : true,
+
+
+ handles : false,
+
+ multiDirectional : false,
+
+ height : null,
+
+ width : null,
+
+ heightIncrement : 0,
+
+ widthIncrement : 0,
+
+ minHeight : 5,
+
+ minWidth : 5,
+
+ maxHeight : 10000,
+
+ maxWidth : 10000,
+
+ minX: 0,
+
+ minY: 0,
+
+ pinned : false,
+
+ preserveRatio : false,
+
+ resizeChild : false,
+
+ transparent: false,
+
+
+
+
+
+
+ resizeTo : function(width, height){
+ this.el.setSize(width, height);
+ this.updateChildSize();
+ this.fireEvent('resize', this, width, height, null);
+ },
+
+
+ startSizing : function(e, handle){
+ this.fireEvent('beforeresize', this, e);
+ if(this.enabled){
+
+ if(!this.overlay){
+ this.overlay = this.el.createProxy({tag: 'div', cls: 'x-resizable-overlay', html: ' '}, Ext.getBody());
+ this.overlay.unselectable();
+ this.overlay.enableDisplayMode('block');
+ this.overlay.on({
+ scope: this,
+ mousemove: this.onMouseMove,
+ mouseup: this.onMouseUp
+ });
+ }
+ this.overlay.setStyle('cursor', handle.el.getStyle('cursor'));
+
+ this.resizing = true;
+ this.startBox = this.el.getBox();
+ this.startPoint = e.getXY();
+ this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
+ (this.startBox.y + this.startBox.height) - this.startPoint[1]];
+
+ this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
+ this.overlay.show();
+
+ if(this.constrainTo) {
+ var ct = Ext.get(this.constrainTo);
+ this.resizeRegion = ct.getRegion().adjust(
+ ct.getFrameWidth('t'),
+ ct.getFrameWidth('l'),
+ -ct.getFrameWidth('b'),
+ -ct.getFrameWidth('r')
+ );
+ }
+
+ this.proxy.setStyle('visibility', 'hidden');
+ this.proxy.show();
+ this.proxy.setBox(this.startBox);
+ if(!this.dynamic){
+ this.proxy.setStyle('visibility', 'visible');
+ }
+ }
+ },
+
+
+ onMouseDown : function(handle, e){
+ if(this.enabled){
+ e.stopEvent();
+ this.activeHandle = handle;
+ this.startSizing(e, handle);
+ }
+ },
+
+
+ onMouseUp : function(e){
+ this.activeHandle = null;
+ var size = this.resizeElement();
+ this.resizing = false;
+ this.handleOut();
+ this.overlay.hide();
+ this.proxy.hide();
+ this.fireEvent('resize', this, size.width, size.height, e);
+ },
+
+
+ updateChildSize : function(){
+ if(this.resizeChild){
+ var el = this.el;
+ var child = this.resizeChild;
+ var adj = this.adjustments;
+ if(el.dom.offsetWidth){
+ var b = el.getSize(true);
+ child.setSize(b.width+adj[0], b.height+adj[1]);
+ }
+
+
+
+
+ if(Ext.isIE){
+ setTimeout(function(){
+ if(el.dom.offsetWidth){
+ var b = el.getSize(true);
+ child.setSize(b.width+adj[0], b.height+adj[1]);
+ }
+ }, 10);
+ }
+ }
+ },
+
+
+ snap : function(value, inc, min){
+ if(!inc || !value){
+ return value;
+ }
+ var newValue = value;
+ var m = value % inc;
+ if(m > 0){
+ if(m > (inc/2)){
+ newValue = value + (inc-m);
+ }else{
+ newValue = value - m;
+ }
+ }
+ return Math.max(min, newValue);
+ },
+
+
+ resizeElement : function(){
+ var box = this.proxy.getBox();
+ if(this.updateBox){
+ this.el.setBox(box, false, this.animate, this.duration, null, this.easing);
+ }else{
+ this.el.setSize(box.width, box.height, this.animate, this.duration, null, this.easing);
+ }
+ this.updateChildSize();
+ if(!this.dynamic){
+ this.proxy.hide();
+ }
+ if(this.draggable && this.constrainTo){
+ this.dd.resetConstraints();
+ this.dd.constrainTo(this.constrainTo);
+ }
+ return box;
+ },
+
+
+ constrain : function(v, diff, m, mx){
+ if(v - diff < m){
+ diff = v - m;
+ }else if(v - diff > mx){
+ diff = v - mx;
+ }
+ return diff;
+ },
+
+
+ onMouseMove : function(e){
+ if(this.enabled && this.activeHandle){
+ try{
+
+ if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {
+ return;
+ }
+
+
+ var curSize = this.curSize || this.startBox,
+ x = this.startBox.x, y = this.startBox.y,
+ ox = x,
+ oy = y,
+ w = curSize.width,
+ h = curSize.height,
+ ow = w,
+ oh = h,
+ mw = this.minWidth,
+ mh = this.minHeight,
+ mxw = this.maxWidth,
+ mxh = this.maxHeight,
+ wi = this.widthIncrement,
+ hi = this.heightIncrement,
+ eventXY = e.getXY(),
+ diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0])),
+ diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1])),
+ pos = this.activeHandle.position,
+ tw,
+ th;
+
+ switch(pos){
+ case 'east':
+ w += diffX;
+ w = Math.min(Math.max(mw, w), mxw);
+ break;
+ case 'south':
+ h += diffY;
+ h = Math.min(Math.max(mh, h), mxh);
+ break;
+ case 'southeast':
+ w += diffX;
+ h += diffY;
+ w = Math.min(Math.max(mw, w), mxw);
+ h = Math.min(Math.max(mh, h), mxh);
+ break;
+ case 'north':
+ diffY = this.constrain(h, diffY, mh, mxh);
+ y += diffY;
+ h -= diffY;
+ break;
+ case 'west':
+ diffX = this.constrain(w, diffX, mw, mxw);
+ x += diffX;
+ w -= diffX;
+ break;
+ case 'northeast':
+ w += diffX;
+ w = Math.min(Math.max(mw, w), mxw);
+ diffY = this.constrain(h, diffY, mh, mxh);
+ y += diffY;
+ h -= diffY;
+ break;
+ case 'northwest':
+ diffX = this.constrain(w, diffX, mw, mxw);
+ diffY = this.constrain(h, diffY, mh, mxh);
+ y += diffY;
+ h -= diffY;
+ x += diffX;
+ w -= diffX;
+ break;
+ case 'southwest':
+ diffX = this.constrain(w, diffX, mw, mxw);
+ h += diffY;
+ h = Math.min(Math.max(mh, h), mxh);
+ x += diffX;
+ w -= diffX;
+ break;
+ }
+
+ var sw = this.snap(w, wi, mw);
+ var sh = this.snap(h, hi, mh);
+ if(sw != w || sh != h){
+ switch(pos){
+ case 'northeast':
+ y -= sh - h;
+ break;
+ case 'north':
+ y -= sh - h;
+ break;
+ case 'southwest':
+ x -= sw - w;
+ break;
+ case 'west':
+ x -= sw - w;
+ break;
+ case 'northwest':
+ x -= sw - w;
+ y -= sh - h;
+ break;
+ }
+ w = sw;
+ h = sh;
+ }
+
+ if(this.preserveRatio){
+ switch(pos){
+ case 'southeast':
+ case 'east':
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ w = ow * (h/oh);
+ break;
+ case 'south':
+ w = ow * (h/oh);
+ w = Math.min(Math.max(mw, w), mxw);
+ h = oh * (w/ow);
+ break;
+ case 'northeast':
+ w = ow * (h/oh);
+ w = Math.min(Math.max(mw, w), mxw);
+ h = oh * (w/ow);
+ break;
+ case 'north':
+ tw = w;
+ w = ow * (h/oh);
+ w = Math.min(Math.max(mw, w), mxw);
+ h = oh * (w/ow);
+ x += (tw - w) / 2;
+ break;
+ case 'southwest':
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ tw = w;
+ w = ow * (h/oh);
+ x += tw - w;
+ break;
+ case 'west':
+ th = h;
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ y += (th - h) / 2;
+ tw = w;
+ w = ow * (h/oh);
+ x += tw - w;
+ break;
+ case 'northwest':
+ tw = w;
+ th = h;
+ h = oh * (w/ow);
+ h = Math.min(Math.max(mh, h), mxh);
+ w = ow * (h/oh);
+ y += th - h;
+ x += tw - w;
+ break;
+
+ }
+ }
+ this.proxy.setBounds(x, y, w, h);
+ if(this.dynamic){
+ this.resizeElement();
+ }
+ }catch(ex){}
+ }
+ },
+
+
+ handleOver : function(){
+ if(this.enabled){
+ this.el.addClass('x-resizable-over');
+ }
+ },
+
+
+ handleOut : function(){
+ if(!this.resizing){
+ this.el.removeClass('x-resizable-over');
+ }
+ },
+
+
+ getEl : function(){
+ return this.el;
+ },
+
+
+ getResizeChild : function(){
+ return this.resizeChild;
+ },
+
+
+ destroy : function(removeEl){
+ Ext.destroy(this.dd, this.overlay, this.proxy);
+ this.overlay = null;
+ this.proxy = null;
+
+ var ps = Ext.Resizable.positions;
+ for(var k in ps){
+ if(typeof ps[k] != 'function' && this[ps[k]]){
+ this[ps[k]].destroy();
+ }
+ }
+ if(removeEl){
+ this.el.update('');
+ Ext.destroy(this.el);
+ this.el = null;
+ }
+ this.purgeListeners();
+ },
+
+ syncHandleHeight : function(){
+ var h = this.el.getHeight(true);
+ if(this.west){
+ this.west.el.setHeight(h);
+ }
+ if(this.east){
+ this.east.el.setHeight(h);
+ }
+ }
+});
+
+
+
+Ext.Resizable.positions = {
+ n: 'north', s: 'south', e: 'east', w: 'west', se: 'southeast', sw: 'southwest', nw: 'northwest', ne: 'northeast'
+};
+
+Ext.Resizable.Handle = Ext.extend(Object, {
+ constructor : function(rz, pos, disableTrackOver, transparent, cls){
+ if(!this.tpl){
+
+ var tpl = Ext.DomHelper.createTemplate(
+ {tag: 'div', cls: 'x-resizable-handle x-resizable-handle-{0}'}
+ );
+ tpl.compile();
+ Ext.Resizable.Handle.prototype.tpl = tpl;
+ }
+ this.position = pos;
+ this.rz = rz;
+ this.el = this.tpl.append(rz.el.dom, [this.position], true);
+ this.el.unselectable();
+ if(transparent){
+ this.el.setOpacity(0);
+ }
+ if(!Ext.isEmpty(cls)){
+ this.el.addClass(cls);
+ }
+ this.el.on('mousedown', this.onMouseDown, this);
+ if(!disableTrackOver){
+ this.el.on({
+ scope: this,
+ mouseover: this.onMouseOver,
+ mouseout: this.onMouseOut
+ });
+ }
+ },
+
+
+ afterResize : function(rz){
+
+ },
+
+ onMouseDown : function(e){
+ this.rz.onMouseDown(this, e);
+ },
+
+ onMouseOver : function(e){
+ this.rz.handleOver(this, e);
+ },
+
+ onMouseOut : function(e){
+ this.rz.handleOut(this, e);
+ },
+
+ destroy : function(){
+ Ext.destroy(this.el);
+ this.el = null;
+ }
+});
+
+Ext.Window = Ext.extend(Ext.Panel, {
+
+
+
+
+
+
+
+
+
+
+
+
+ baseCls : 'x-window',
+
+ resizable : true,
+
+ draggable : true,
+
+ closable : true,
+
+ closeAction : 'close',
+
+ constrain : false,
+
+ constrainHeader : false,
+
+ plain : false,
+
+ minimizable : false,
+
+ maximizable : false,
+
+ minHeight : 100,
+
+ minWidth : 200,
+
+ expandOnShow : true,
+
+
+ showAnimDuration: 0.25,
+
+
+ hideAnimDuration: 0.25,
+
+
+ collapsible : false,
+
+
+ initHidden : undefined,
+
+
+ hidden : true,
+
+
+
+
+
+
+ elements : 'header,body',
+
+ frame : true,
+
+ floating : true,
+
+
+ initComponent : function(){
+ this.initTools();
+ Ext.Window.superclass.initComponent.call(this);
+ this.addEvents(
+
+
+
+ 'resize',
+
+ 'maximize',
+
+ 'minimize',
+
+ 'restore'
+ );
+
+ if(Ext.isDefined(this.initHidden)){
+ this.hidden = this.initHidden;
+ }
+ if(this.hidden === false){
+ this.hidden = true;
+ this.show();
+ }
+ },
+
+
+ getState : function(){
+ return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox(true));
+ },
+
+
+ onRender : function(ct, position){
+ Ext.Window.superclass.onRender.call(this, ct, position);
+
+ if(this.plain){
+ this.el.addClass('x-window-plain');
+ }
+
+
+ this.focusEl = this.el.createChild({
+ tag: 'a', href:'#', cls:'x-dlg-focus',
+ tabIndex:'-1', html: ' '});
+ this.focusEl.swallowEvent('click', true);
+
+ this.proxy = this.el.createProxy('x-window-proxy');
+ this.proxy.enableDisplayMode('block');
+
+ if(this.modal){
+ this.mask = this.container.createChild({cls:'ext-el-mask'}, this.el.dom);
+ this.mask.enableDisplayMode('block');
+ this.mask.hide();
+ this.mon(this.mask, 'click', this.focus, this);
+ }
+ if(this.maximizable){
+ this.mon(this.header, 'dblclick', this.toggleMaximize, this);
+ }
+ },
+
+
+ initEvents : function(){
+ Ext.Window.superclass.initEvents.call(this);
+ if(this.animateTarget){
+ this.setAnimateTarget(this.animateTarget);
+ }
+
+ if(this.resizable){
+ this.resizer = new Ext.Resizable(this.el, {
+ minWidth: this.minWidth,
+ minHeight:this.minHeight,
+ handles: this.resizeHandles || 'all',
+ pinned: true,
+ resizeElement : this.resizerAction,
+ handleCls: 'x-window-handle'
+ });
+ this.resizer.window = this;
+ this.mon(this.resizer, 'beforeresize', this.beforeResize, this);
+ }
+
+ if(this.draggable){
+ this.header.addClass('x-window-draggable');
+ }
+ this.mon(this.el, 'mousedown', this.toFront, this);
+ this.manager = this.manager || Ext.WindowMgr;
+ this.manager.register(this);
+ if(this.maximized){
+ this.maximized = false;
+ this.maximize();
+ }
+ if(this.closable){
+ var km = this.getKeyMap();
+ km.on(27, this.onEsc, this);
+ km.disable();
+ }
+ },
+
+ initDraggable : function(){
+
+ this.dd = new Ext.Window.DD(this);
+ },
+
+
+ onEsc : function(k, e){
+ e.stopEvent();
+ this[this.closeAction]();
+ },
+
+
+ beforeDestroy : function(){
+ if(this.rendered){
+ this.hide();
+ this.clearAnchor();
+ Ext.destroy(
+ this.focusEl,
+ this.resizer,
+ this.dd,
+ this.proxy,
+ this.mask
+ );
+ }
+ Ext.Window.superclass.beforeDestroy.call(this);
+ },
+
+
+ onDestroy : function(){
+ if(this.manager){
+ this.manager.unregister(this);
+ }
+ Ext.Window.superclass.onDestroy.call(this);
+ },
+
+
+ initTools : function(){
+ if(this.minimizable){
+ this.addTool({
+ id: 'minimize',
+ handler: this.minimize.createDelegate(this, [])
+ });
+ }
+ if(this.maximizable){
+ this.addTool({
+ id: 'maximize',
+ handler: this.maximize.createDelegate(this, [])
+ });
+ this.addTool({
+ id: 'restore',
+ handler: this.restore.createDelegate(this, []),
+ hidden:true
+ });
+ }
+ if(this.closable){
+ this.addTool({
+ id: 'close',
+ handler: this[this.closeAction].createDelegate(this, [])
+ });
+ }
+ },
+
+
+ resizerAction : function(){
+ var box = this.proxy.getBox();
+ this.proxy.hide();
+ this.window.handleResize(box);
+ return box;
+ },
+
+
+ beforeResize : function(){
+ this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40);
+ this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
+ this.resizeBox = this.el.getBox();
+ },
+
+
+ updateHandles : function(){
+ if(Ext.isIE && this.resizer){
+ this.resizer.syncHandleHeight();
+ this.el.repaint();
+ }
+ },
+
+
+ handleResize : function(box){
+ var rz = this.resizeBox;
+ if(rz.x != box.x || rz.y != box.y){
+ this.updateBox(box);
+ }else{
+ this.setSize(box);
+ if (Ext.isIE6 && Ext.isStrict) {
+ this.doLayout();
+ }
+ }
+ this.focus();
+ this.updateHandles();
+ this.saveState();
+ },
+
+
+ focus : function(){
+ var f = this.focusEl,
+ db = this.defaultButton,
+ t = typeof db,
+ el,
+ ct;
+ if(Ext.isDefined(db)){
+ if(Ext.isNumber(db) && this.fbar){
+ f = this.fbar.items.get(db);
+ }else if(Ext.isString(db)){
+ f = Ext.getCmp(db);
+ }else{
+ f = db;
+ }
+ el = f.getEl();
+ ct = Ext.getDom(this.container);
+ if (el && ct) {
+ if (ct != document.body && !Ext.lib.Region.getRegion(ct).contains(Ext.lib.Region.getRegion(el.dom))){
+ return;
+ }
+ }
+ }
+ f = f || this.focusEl;
+ f.focus.defer(10, f);
+ },
+
+
+ setAnimateTarget : function(el){
+ el = Ext.get(el);
+ this.animateTarget = el;
+ },
+
+
+ beforeShow : function(){
+ delete this.el.lastXY;
+ delete this.el.lastLT;
+ if(this.x === undefined || this.y === undefined){
+ var xy = this.el.getAlignToXY(this.container, 'c-c');
+ var pos = this.el.translatePoints(xy[0], xy[1]);
+ this.x = this.x === undefined? pos.left : this.x;
+ this.y = this.y === undefined? pos.top : this.y;
+ }
+ this.el.setLeftTop(this.x, this.y);
+
+ if(this.expandOnShow){
+ this.expand(false);
+ }
+
+ if(this.modal){
+ Ext.getBody().addClass('x-body-masked');
+ this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
+ this.mask.show();
+ }
+ },
+
+
+ show : function(animateTarget, cb, scope){
+ if(!this.rendered){
+ this.render(Ext.getBody());
+ }
+ if(this.hidden === false){
+ this.toFront();
+ return this;
+ }
+ if(this.fireEvent('beforeshow', this) === false){
+ return this;
+ }
+ if(cb){
+ this.on('show', cb, scope, {single:true});
+ }
+ this.hidden = false;
+ if(Ext.isDefined(animateTarget)){
+ this.setAnimateTarget(animateTarget);
+ }
+ this.beforeShow();
+ if(this.animateTarget){
+ this.animShow();
+ }else{
+ this.afterShow();
+ }
+ return this;
+ },
+
+
+ afterShow : function(isAnim){
+ if (this.isDestroyed){
+ return false;
+ }
+ this.proxy.hide();
+ this.el.setStyle('display', 'block');
+ this.el.show();
+ if(this.maximized){
+ this.fitContainer();
+ }
+ if(Ext.isMac && Ext.isGecko2){
+ this.cascade(this.setAutoScroll);
+ }
+
+ if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
+ Ext.EventManager.onWindowResize(this.onWindowResize, this);
+ }
+ this.doConstrain();
+ this.doLayout();
+ if(this.keyMap){
+ this.keyMap.enable();
+ }
+ this.toFront();
+ this.updateHandles();
+ if(isAnim && (Ext.isIE || Ext.isWebKit)){
+ var sz = this.getSize();
+ this.onResize(sz.width, sz.height);
+ }
+ this.onShow();
+ this.fireEvent('show', this);
+ },
+
+
+ animShow : function(){
+ this.proxy.show();
+ this.proxy.setBox(this.animateTarget.getBox());
+ this.proxy.setOpacity(0);
+ var b = this.getBox();
+ this.el.setStyle('display', 'none');
+ this.proxy.shift(Ext.apply(b, {
+ callback: this.afterShow.createDelegate(this, [true], false),
+ scope: this,
+ easing: 'easeNone',
+ duration: this.showAnimDuration,
+ opacity: 0.5
+ }));
+ },
+
+
+ hide : function(animateTarget, cb, scope){
+ if(this.hidden || this.fireEvent('beforehide', this) === false){
+ return this;
+ }
+ if(cb){
+ this.on('hide', cb, scope, {single:true});
+ }
+ this.hidden = true;
+ if(animateTarget !== undefined){
+ this.setAnimateTarget(animateTarget);
+ }
+ if(this.modal){
+ this.mask.hide();
+ Ext.getBody().removeClass('x-body-masked');
+ }
+ if(this.animateTarget){
+ this.animHide();
+ }else{
+ this.el.hide();
+ this.afterHide();
+ }
+ return this;
+ },
+
+
+ afterHide : function(){
+ this.proxy.hide();
+ if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
+ Ext.EventManager.removeResizeListener(this.onWindowResize, this);
+ }
+ if(this.keyMap){
+ this.keyMap.disable();
+ }
+ this.onHide();
+ this.fireEvent('hide', this);
+ },
+
+
+ animHide : function(){
+ this.proxy.setOpacity(0.5);
+ this.proxy.show();
+ var tb = this.getBox(false);
+ this.proxy.setBox(tb);
+ this.el.hide();
+ this.proxy.shift(Ext.apply(this.animateTarget.getBox(), {
+ callback: this.afterHide,
+ scope: this,
+ duration: this.hideAnimDuration,
+ easing: 'easeNone',
+ opacity: 0
+ }));
+ },
+
+
+ onShow : Ext.emptyFn,
+
+
+ onHide : Ext.emptyFn,
+
+
+ onWindowResize : function(){
+ if(this.maximized){
+ this.fitContainer();
+ }
+ if(this.modal){
+ this.mask.setSize('100%', '100%');
+ var force = this.mask.dom.offsetHeight;
+ this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
+ }
+ this.doConstrain();
+ },
+
+
+ doConstrain : function(){
+ if(this.constrain || this.constrainHeader){
+ var offsets;
+ if(this.constrain){
+ offsets = {
+ right:this.el.shadowOffset,
+ left:this.el.shadowOffset,
+ bottom:this.el.shadowOffset
+ };
+ }else {
+ var s = this.getSize();
+ offsets = {
+ right:-(s.width - 100),
+ bottom:-(s.height - 25)
+ };
+ }
+
+ var xy = this.el.getConstrainToXY(this.container, true, offsets);
+ if(xy){
+ this.setPosition(xy[0], xy[1]);
+ }
+ }
+ },
+
+
+ ghost : function(cls){
+ var ghost = this.createGhost(cls);
+ var box = this.getBox(true);
+ ghost.setLeftTop(box.x, box.y);
+ ghost.setWidth(box.width);
+ this.el.hide();
+ this.activeGhost = ghost;
+ return ghost;
+ },
+
+
+ unghost : function(show, matchPosition){
+ if(!this.activeGhost) {
+ return;
+ }
+ if(show !== false){
+ this.el.show();
+ this.focus.defer(10, this);
+ if(Ext.isMac && Ext.isGecko2){
+ this.cascade(this.setAutoScroll);
+ }
+ }
+ if(matchPosition !== false){
+ this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
+ }
+ this.activeGhost.hide();
+ this.activeGhost.remove();
+ delete this.activeGhost;
+ },
+
+
+ minimize : function(){
+ this.fireEvent('minimize', this);
+ return this;
+ },
+
+
+ close : function(){
+ if(this.fireEvent('beforeclose', this) !== false){
+ if(this.hidden){
+ this.doClose();
+ }else{
+ this.hide(null, this.doClose, this);
+ }
+ }
+ },
+
+
+ doClose : function(){
+ this.fireEvent('close', this);
+ this.destroy();
+ },
+
+
+ maximize : function(){
+ if(!this.maximized){
+ this.expand(false);
+ this.restoreSize = this.getSize();
+ this.restorePos = this.getPosition(true);
+ if (this.maximizable){
+ this.tools.maximize.hide();
+ this.tools.restore.show();
+ }
+ this.maximized = true;
+ this.el.disableShadow();
+
+ if(this.dd){
+ this.dd.lock();
+ }
+ if(this.collapsible){
+ this.tools.toggle.hide();
+ }
+ this.el.addClass('x-window-maximized');
+ this.container.addClass('x-window-maximized-ct');
+
+ this.setPosition(0, 0);
+ this.fitContainer();
+ this.fireEvent('maximize', this);
+ }
+ return this;
+ },
+
+
+ restore : function(){
+ if(this.maximized){
+ var t = this.tools;
+ this.el.removeClass('x-window-maximized');
+ if(t.restore){
+ t.restore.hide();
+ }
+ if(t.maximize){
+ t.maximize.show();
+ }
+ this.setPosition(this.restorePos[0], this.restorePos[1]);
+ this.setSize(this.restoreSize.width, this.restoreSize.height);
+ delete this.restorePos;
+ delete this.restoreSize;
+ this.maximized = false;
+ this.el.enableShadow(true);
+
+ if(this.dd){
+ this.dd.unlock();
+ }
+ if(this.collapsible && t.toggle){
+ t.toggle.show();
+ }
+ this.container.removeClass('x-window-maximized-ct');
+
+ this.doConstrain();
+ this.fireEvent('restore', this);
+ }
+ return this;
+ },
+
+
+ toggleMaximize : function(){
+ return this[this.maximized ? 'restore' : 'maximize']();
+ },
+
+
+ fitContainer : function(){
+ var vs = this.container.getViewSize(false);
+ this.setSize(vs.width, vs.height);
+ },
+
+
+
+ setZIndex : function(index){
+ if(this.modal){
+ this.mask.setStyle('z-index', index);
+ }
+ this.el.setZIndex(++index);
+ index += 5;
+
+ if(this.resizer){
+ this.resizer.proxy.setStyle('z-index', ++index);
+ }
+
+ this.lastZIndex = index;
+ },
+
+
+ alignTo : function(element, position, offsets){
+ var xy = this.el.getAlignToXY(element, position, offsets);
+ this.setPagePosition(xy[0], xy[1]);
+ return this;
+ },
+
+
+ anchorTo : function(el, alignment, offsets, monitorScroll){
+ this.clearAnchor();
+ this.anchorTarget = {
+ el: el,
+ alignment: alignment,
+ offsets: offsets
+ };
+
+ Ext.EventManager.onWindowResize(this.doAnchor, this);
+ var tm = typeof monitorScroll;
+ if(tm != 'undefined'){
+ Ext.EventManager.on(window, 'scroll', this.doAnchor, this,
+ {buffer: tm == 'number' ? monitorScroll : 50});
+ }
+ return this.doAnchor();
+ },
+
+
+ doAnchor : function(){
+ var o = this.anchorTarget;
+ this.alignTo(o.el, o.alignment, o.offsets);
+ return this;
+ },
+
+
+ clearAnchor : function(){
+ if(this.anchorTarget){
+ Ext.EventManager.removeResizeListener(this.doAnchor, this);
+ Ext.EventManager.un(window, 'scroll', this.doAnchor, this);
+ delete this.anchorTarget;
+ }
+ return this;
+ },
+
+
+ toFront : function(e){
+ if(this.manager.bringToFront(this)){
+ if(!e || !e.getTarget().focus){
+ this.focus();
+ }
+ }
+ return this;
+ },
+
+
+ setActive : function(active){
+ if(active){
+ if(!this.maximized){
+ this.el.enableShadow(true);
+ }
+ this.fireEvent('activate', this);
+ }else{
+ this.el.disableShadow();
+ this.fireEvent('deactivate', this);
+ }
+ },
+
+
+ toBack : function(){
+ this.manager.sendToBack(this);
+ return this;
+ },
+
+
+ center : function(){
+ var xy = this.el.getAlignToXY(this.container, 'c-c');
+ this.setPagePosition(xy[0], xy[1]);
+ return this;
+ }
+
+
+});
+Ext.reg('window', Ext.Window);
+
+
+Ext.Window.DD = Ext.extend(Ext.dd.DD, {
+
+ constructor : function(win){
+ this.win = win;
+ Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
+ this.setHandleElId(win.header.id);
+ this.scroll = false;
+ },
+
+ moveOnly:true,
+ headerOffsets:[100, 25],
+ startDrag : function(){
+ var w = this.win;
+ this.proxy = w.ghost(w.initialConfig.cls);
+ if(w.constrain !== false){
+ var so = w.el.shadowOffset;
+ this.constrainTo(w.container, {right: so, left: so, bottom: so});
+ }else if(w.constrainHeader !== false){
+ var s = this.proxy.getSize();
+ this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
+ }
+ },
+ b4Drag : Ext.emptyFn,
+
+ onDrag : function(e){
+ this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
+ },
+
+ endDrag : function(e){
+ this.win.unghost();
+ this.win.saveState();
+ }
+});
+
+Ext.WindowGroup = function(){
+ var list = {};
+ var accessList = [];
+ var front = null;
+
+
+ var sortWindows = function(d1, d2){
+ return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
+ };
+
+
+ var orderWindows = function(){
+ var a = accessList, len = a.length;
+ if(len > 0){
+ a.sort(sortWindows);
+ var seed = a[0].manager.zseed;
+ for(var i = 0; i < len; i++){
+ var win = a[i];
+ if(win && !win.hidden){
+ win.setZIndex(seed + (i*10));
+ }
+ }
+ }
+ activateLast();
+ };
+
+
+ var setActiveWin = function(win){
+ if(win != front){
+ if(front){
+ front.setActive(false);
+ }
+ front = win;
+ if(win){
+ win.setActive(true);
+ }
+ }
+ };
+
+
+ var activateLast = function(){
+ for(var i = accessList.length-1; i >=0; --i) {
+ if(!accessList[i].hidden){
+ setActiveWin(accessList[i]);
+ return;
+ }
+ }
+
+ setActiveWin(null);
+ };
+
+ return {
+
+ zseed : 9000,
+
+
+ register : function(win){
+ if(win.manager){
+ win.manager.unregister(win);
+ }
+ win.manager = this;
+
+ list[win.id] = win;
+ accessList.push(win);
+ win.on('hide', activateLast);
+ },
+
+
+ unregister : function(win){
+ delete win.manager;
+ delete list[win.id];
+ win.un('hide', activateLast);
+ accessList.remove(win);
+ },
+
+
+ get : function(id){
+ return typeof id == "object" ? id : list[id];
+ },
+
+
+ bringToFront : function(win){
+ win = this.get(win);
+ if(win != front){
+ win._lastAccess = new Date().getTime();
+ orderWindows();
+ return true;
+ }
+ return false;
+ },
+
+
+ sendToBack : function(win){
+ win = this.get(win);
+ win._lastAccess = -(new Date().getTime());
+ orderWindows();
+ return win;
+ },
+
+
+ hideAll : function(){
+ for(var id in list){
+ if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
+ list[id].hide();
+ }
+ }
+ },
+
+
+ getActive : function(){
+ return front;
+ },
+
+
+ getBy : function(fn, scope){
+ var r = [];
+ for(var i = accessList.length-1; i >=0; --i) {
+ var win = accessList[i];
+ if(fn.call(scope||win, win) !== false){
+ r.push(win);
+ }
+ }
+ return r;
+ },
+
+
+ each : function(fn, scope){
+ for(var id in list){
+ if(list[id] && typeof list[id] != "function"){
+ if(fn.call(scope || list[id], list[id]) === false){
+ return;
+ }
+ }
+ }
+ }
+ };
+};
+
+
+
+Ext.WindowMgr = new Ext.WindowGroup();
+Ext.MessageBox = function(){
+ var dlg, opt, mask, waitTimer,
+ bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl,
+ buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '',
+ buttonNames = ['ok', 'yes', 'no', 'cancel'];
+
+
+ var handleButton = function(button){
+ buttons[button].blur();
+ if(dlg.isVisible()){
+ dlg.hide();
+ handleHide();
+ Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value, opt], 1);
+ }
+ };
+
+
+ var handleHide = function(){
+ if(opt && opt.cls){
+ dlg.el.removeClass(opt.cls);
+ }
+ progressBar.reset();
+ };
+
+
+ var handleEsc = function(d, k, e){
+ if(opt && opt.closable !== false){
+ dlg.hide();
+ handleHide();
+ }
+ if(e){
+ e.stopEvent();
+ }
+ };
+
+
+ var updateButtons = function(b){
+ var width = 0,
+ cfg;
+ if(!b){
+ Ext.each(buttonNames, function(name){
+ buttons[name].hide();
+ });
+ return width;
+ }
+ dlg.footer.dom.style.display = '';
+ Ext.iterate(buttons, function(name, btn){
+ cfg = b[name];
+ if(cfg){
+ btn.show();
+ btn.setText(Ext.isString(cfg) ? cfg : Ext.MessageBox.buttonText[name]);
+ width += btn.getEl().getWidth() + 15;
+ }else{
+ btn.hide();
+ }
+ });
+ return width;
+ };
+
+ return {
+
+ getDialog : function(titleText){
+ if(!dlg){
+ var btns = [];
+
+ buttons = {};
+ Ext.each(buttonNames, function(name){
+ btns.push(buttons[name] = new Ext.Button({
+ text: this.buttonText[name],
+ handler: handleButton.createCallback(name),
+ hideMode: 'offsets'
+ }));
+ }, this);
+ dlg = new Ext.Window({
+ autoCreate : true,
+ title:titleText,
+ resizable:false,
+ constrain:true,
+ constrainHeader:true,
+ minimizable : false,
+ maximizable : false,
+ stateful: false,
+ modal: true,
+ shim:true,
+ buttonAlign:"center",
+ width:400,
+ height:100,
+ minHeight: 80,
+ plain:true,
+ footer:true,
+ closable:true,
+ close : function(){
+ if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
+ handleButton("no");
+ }else{
+ handleButton("cancel");
+ }
+ },
+ fbar: new Ext.Toolbar({
+ items: btns,
+ enableOverflow: false
+ })
+ });
+ dlg.render(document.body);
+ dlg.getEl().addClass('x-window-dlg');
+ mask = dlg.mask;
+ bodyEl = dlg.body.createChild({
+ html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><div class="ext-mb-fix-cursor"><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div></div>'
+ });
+ iconEl = Ext.get(bodyEl.dom.firstChild);
+ var contentEl = bodyEl.dom.childNodes[1];
+ msgEl = Ext.get(contentEl.firstChild);
+ textboxEl = Ext.get(contentEl.childNodes[2].firstChild);
+ textboxEl.enableDisplayMode();
+ textboxEl.addKeyListener([10,13], function(){
+ if(dlg.isVisible() && opt && opt.buttons){
+ if(opt.buttons.ok){
+ handleButton("ok");
+ }else if(opt.buttons.yes){
+ handleButton("yes");
+ }
+ }
+ });
+ textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]);
+ textareaEl.enableDisplayMode();
+ progressBar = new Ext.ProgressBar({
+ renderTo:bodyEl
+ });
+ bodyEl.createChild({cls:'x-clear'});
+ }
+ return dlg;
+ },
+
+
+ updateText : function(text){
+ if(!dlg.isVisible() && !opt.width){
+ dlg.setSize(this.maxWidth, 100);
+ }
+
+ msgEl.update(text ? text + ' ' : ' ');
+
+ var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0,
+ mw = msgEl.getWidth() + msgEl.getMargins('lr'),
+ fw = dlg.getFrameWidth('lr'),
+ bw = dlg.body.getFrameWidth('lr'),
+ w;
+
+ w = Math.max(Math.min(opt.width || iw+mw+fw+bw, opt.maxWidth || this.maxWidth),
+ Math.max(opt.minWidth || this.minWidth, bwidth || 0));
+
+ if(opt.prompt === true){
+ activeTextEl.setWidth(w-iw-fw-bw);
+ }
+ if(opt.progress === true || opt.wait === true){
+ progressBar.setSize(w-iw-fw-bw);
+ }
+ if(Ext.isIE && w == bwidth){
+ w += 4;
+ }
+ msgEl.update(text || ' ');
+ dlg.setSize(w, 'auto').center();
+ return this;
+ },
+
+
+ updateProgress : function(value, progressText, msg){
+ progressBar.updateProgress(value, progressText);
+ if(msg){
+ this.updateText(msg);
+ }
+ return this;
+ },
+
+
+ isVisible : function(){
+ return dlg && dlg.isVisible();
+ },
+
+
+ hide : function(){
+ var proxy = dlg ? dlg.activeGhost : null;
+ if(this.isVisible() || proxy){
+ dlg.hide();
+ handleHide();
+ if (proxy){
+
+
+ dlg.unghost(false, false);
+ }
+ }
+ return this;
+ },
+
+
+ show : function(options){
+ if(this.isVisible()){
+ this.hide();
+ }
+ opt = options;
+ var d = this.getDialog(opt.title || " ");
+
+ d.setTitle(opt.title || " ");
+ var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
+ d.tools.close.setDisplayed(allowClose);
+ activeTextEl = textboxEl;
+ opt.prompt = opt.prompt || (opt.multiline ? true : false);
+ if(opt.prompt){
+ if(opt.multiline){
+ textboxEl.hide();
+ textareaEl.show();
+ textareaEl.setHeight(Ext.isNumber(opt.multiline) ? opt.multiline : this.defaultTextHeight);
+ activeTextEl = textareaEl;
+ }else{
+ textboxEl.show();
+ textareaEl.hide();
+ }
+ }else{
+ textboxEl.hide();
+ textareaEl.hide();
+ }
+ activeTextEl.dom.value = opt.value || "";
+ if(opt.prompt){
+ d.focusEl = activeTextEl;
+ }else{
+ var bs = opt.buttons;
+ var db = null;
+ if(bs && bs.ok){
+ db = buttons["ok"];
+ }else if(bs && bs.yes){
+ db = buttons["yes"];
+ }
+ if (db){
+ d.focusEl = db;
+ }
+ }
+ if(Ext.isDefined(opt.iconCls)){
+ d.setIconClass(opt.iconCls);
+ }
+ this.setIcon(Ext.isDefined(opt.icon) ? opt.icon : bufferIcon);
+ bwidth = updateButtons(opt.buttons);
+ progressBar.setVisible(opt.progress === true || opt.wait === true);
+ this.updateProgress(0, opt.progressText);
+ this.updateText(opt.msg);
+ if(opt.cls){
+ d.el.addClass(opt.cls);
+ }
+ d.proxyDrag = opt.proxyDrag === true;
+ d.modal = opt.modal !== false;
+ d.mask = opt.modal !== false ? mask : false;
+ if(!d.isVisible()){
+
+ document.body.appendChild(dlg.el.dom);
+ d.setAnimateTarget(opt.animEl);
+
+ d.on('show', function(){
+ if(allowClose === true){
+ d.keyMap.enable();
+ }else{
+ d.keyMap.disable();
+ }
+ }, this, {single:true});
+ d.show(opt.animEl);
+ }
+ if(opt.wait === true){
+ progressBar.wait(opt.waitConfig);
+ }
+ return this;
+ },
+
+
+ setIcon : function(icon){
+ if(!dlg){
+ bufferIcon = icon;
+ return;
+ }
+ bufferIcon = undefined;
+ if(icon && icon != ''){
+ iconEl.removeClass('x-hidden');
+ iconEl.replaceClass(iconCls, icon);
+ bodyEl.addClass('x-dlg-icon');
+ iconCls = icon;
+ }else{
+ iconEl.replaceClass(iconCls, 'x-hidden');
+ bodyEl.removeClass('x-dlg-icon');
+ iconCls = '';
+ }
+ return this;
+ },
+
+
+ progress : function(title, msg, progressText){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: false,
+ progress:true,
+ closable:false,
+ minWidth: this.minProgressWidth,
+ progressText: progressText
+ });
+ return this;
+ },
+
+
+ wait : function(msg, title, config){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: false,
+ closable:false,
+ wait:true,
+ modal:true,
+ minWidth: this.minProgressWidth,
+ waitConfig: config
+ });
+ return this;
+ },
+
+
+ alert : function(title, msg, fn, scope){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: this.OK,
+ fn: fn,
+ scope : scope,
+ minWidth: this.minWidth
+ });
+ return this;
+ },
+
+
+ confirm : function(title, msg, fn, scope){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: this.YESNO,
+ fn: fn,
+ scope : scope,
+ icon: this.QUESTION,
+ minWidth: this.minWidth
+ });
+ return this;
+ },
+
+
+ prompt : function(title, msg, fn, scope, multiline, value){
+ this.show({
+ title : title,
+ msg : msg,
+ buttons: this.OKCANCEL,
+ fn: fn,
+ minWidth: this.minPromptWidth,
+ scope : scope,
+ prompt:true,
+ multiline: multiline,
+ value: value
+ });
+ return this;
+ },
+
+
+ OK : {ok:true},
+
+ CANCEL : {cancel:true},
+
+ OKCANCEL : {ok:true, cancel:true},
+
+ YESNO : {yes:true, no:true},
+
+ YESNOCANCEL : {yes:true, no:true, cancel:true},
+
+ INFO : 'ext-mb-info',
+
+ WARNING : 'ext-mb-warning',
+
+ QUESTION : 'ext-mb-question',
+
+ ERROR : 'ext-mb-error',
+
+
+ defaultTextHeight : 75,
+
+ maxWidth : 600,
+
+ minWidth : 100,
+
+ minProgressWidth : 250,
+
+ minPromptWidth: 250,
+
+ buttonText : {
+ ok : "OK",
+ cancel : "Cancel",
+ yes : "Yes",
+ no : "No"
+ }
+ };
+}();
+
+
+Ext.Msg = Ext.MessageBox;
+Ext.dd.PanelProxy = Ext.extend(Object, {
+
+ constructor : function(panel, config){
+ this.panel = panel;
+ this.id = this.panel.id +'-ddproxy';
+ Ext.apply(this, config);
+ },
+
+
+ insertProxy : true,
+
+
+ setStatus : Ext.emptyFn,
+ reset : Ext.emptyFn,
+ update : Ext.emptyFn,
+ stop : Ext.emptyFn,
+ sync: Ext.emptyFn,
+
+
+ getEl : function(){
+ return this.ghost;
+ },
+
+
+ getGhost : function(){
+ return this.ghost;
+ },
+
+
+ getProxy : function(){
+ return this.proxy;
+ },
+
+
+ hide : function(){
+ if(this.ghost){
+ if(this.proxy){
+ this.proxy.remove();
+ delete this.proxy;
+ }
+ this.panel.el.dom.style.display = '';
+ this.ghost.remove();
+ delete this.ghost;
+ }
+ },
+
+
+ show : function(){
+ if(!this.ghost){
+ this.ghost = this.panel.createGhost(this.panel.initialConfig.cls, undefined, Ext.getBody());
+ this.ghost.setXY(this.panel.el.getXY());
+ if(this.insertProxy){
+ this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
+ this.proxy.setSize(this.panel.getSize());
+ }
+ this.panel.el.dom.style.display = 'none';
+ }
+ },
+
+
+ repair : function(xy, callback, scope){
+ this.hide();
+ if(typeof callback == "function"){
+ callback.call(scope || this);
+ }
+ },
+
+
+ moveProxy : function(parentNode, before){
+ if(this.proxy){
+ parentNode.insertBefore(this.proxy.dom, before);
+ }
+ }
+});
+
+
+Ext.Panel.DD = Ext.extend(Ext.dd.DragSource, {
+
+ constructor : function(panel, cfg){
+ this.panel = panel;
+ this.dragData = {panel: panel};
+ this.proxy = new Ext.dd.PanelProxy(panel, cfg);
+ Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
+ var h = panel.header,
+ el = panel.body;
+ if(h){
+ this.setHandleElId(h.id);
+ el = panel.header;
+ }
+ el.setStyle('cursor', 'move');
+ this.scroll = false;
+ },
+
+ showFrame: Ext.emptyFn,
+ startDrag: Ext.emptyFn,
+ b4StartDrag: function(x, y) {
+ this.proxy.show();
+ },
+ b4MouseDown: function(e) {
+ var x = e.getPageX(),
+ y = e.getPageY();
+ this.autoOffset(x, y);
+ },
+ onInitDrag : function(x, y){
+ this.onStartDrag(x, y);
+ return true;
+ },
+ createFrame : Ext.emptyFn,
+ getDragEl : function(e){
+ return this.proxy.ghost.dom;
+ },
+ endDrag : function(e){
+ this.proxy.hide();
+ this.panel.saveState();
+ },
+
+ autoOffset : function(x, y) {
+ x -= this.startPageX;
+ y -= this.startPageY;
+ this.setDelta(x, y);
+ }
+});
+Ext.state.Provider = Ext.extend(Ext.util.Observable, {
+
+ constructor : function(){
+
+ this.addEvents("statechange");
+ this.state = {};
+ Ext.state.Provider.superclass.constructor.call(this);
+ },
+
+
+ get : function(name, defaultValue){
+ return typeof this.state[name] == "undefined" ?
+ defaultValue : this.state[name];
+ },
+
+
+ clear : function(name){
+ delete this.state[name];
+ this.fireEvent("statechange", this, name, null);
+ },
+
+
+ set : function(name, value){
+ this.state[name] = value;
+ this.fireEvent("statechange", this, name, value);
+ },
+
+
+ decodeValue : function(cookie){
+
+ var re = /^(a|n|d|b|s|o|e)\:(.*)$/,
+ matches = re.exec(unescape(cookie)),
+ all,
+ type,
+ v,
+ kv;
+ if(!matches || !matches[1]){
+ return;
+ }
+ type = matches[1];
+ v = matches[2];
+ switch(type){
+ case 'e':
+ return null;
+ case 'n':
+ return parseFloat(v);
+ case 'd':
+ return new Date(Date.parse(v));
+ case 'b':
+ return (v == '1');
+ case 'a':
+ all = [];
+ if(v != ''){
+ Ext.each(v.split('^'), function(val){
+ all.push(this.decodeValue(val));
+ }, this);
+ }
+ return all;
+ case 'o':
+ all = {};
+ if(v != ''){
+ Ext.each(v.split('^'), function(val){
+ kv = val.split('=');
+ all[kv[0]] = this.decodeValue(kv[1]);
+ }, this);
+ }
+ return all;
+ default:
+ return v;
+ }
+ },
+
+
+ encodeValue : function(v){
+ var enc,
+ flat = '',
+ i = 0,
+ len,
+ key;
+ if(v == null){
+ return 'e:1';
+ }else if(typeof v == 'number'){
+ enc = 'n:' + v;
+ }else if(typeof v == 'boolean'){
+ enc = 'b:' + (v ? '1' : '0');
+ }else if(Ext.isDate(v)){
+ enc = 'd:' + v.toGMTString();
+ }else if(Ext.isArray(v)){
+ for(len = v.length; i < len; i++){
+ flat += this.encodeValue(v[i]);
+ if(i != len - 1){
+ flat += '^';
+ }
+ }
+ enc = 'a:' + flat;
+ }else if(typeof v == 'object'){
+ for(key in v){
+ if(typeof v[key] != 'function' && v[key] !== undefined){
+ flat += key + '=' + this.encodeValue(v[key]) + '^';
+ }
+ }
+ enc = 'o:' + flat.substring(0, flat.length-1);
+ }else{
+ enc = 's:' + v;
+ }
+ return escape(enc);
+ }
+});
+
+Ext.state.Manager = function(){
+ var provider = new Ext.state.Provider();
+
+ return {
+
+ setProvider : function(stateProvider){
+ provider = stateProvider;
+ },
+
+
+ get : function(key, defaultValue){
+ return provider.get(key, defaultValue);
+ },
+
+
+ set : function(key, value){
+ provider.set(key, value);
+ },
+
+
+ clear : function(key){
+ provider.clear(key);
+ },
+
+
+ getProvider : function(){
+ return provider;
+ }
+ };
+}();
+
+Ext.state.CookieProvider = Ext.extend(Ext.state.Provider, {
+
+ constructor : function(config){
+ Ext.state.CookieProvider.superclass.constructor.call(this);
+ this.path = "/";
+ this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
+ this.domain = null;
+ this.secure = false;
+ Ext.apply(this, config);
+ this.state = this.readCookies();
+ },
+
+
+ set : function(name, value){
+ if(typeof value == "undefined" || value === null){
+ this.clear(name);
+ return;
+ }
+ this.setCookie(name, value);
+ Ext.state.CookieProvider.superclass.set.call(this, name, value);
+ },
+
+
+ clear : function(name){
+ this.clearCookie(name);
+ Ext.state.CookieProvider.superclass.clear.call(this, name);
+ },
+
+
+ readCookies : function(){
+ var cookies = {},
+ c = document.cookie + ";",
+ re = /\s?(.*?)=(.*?);/g,
+ matches,
+ name,
+ value;
+ while((matches = re.exec(c)) != null){
+ name = matches[1];
+ value = matches[2];
+ if(name && name.substring(0,3) == "ys-"){
+ cookies[name.substr(3)] = this.decodeValue(value);
+ }
+ }
+ return cookies;
+ },
+
+
+ setCookie : function(name, value){
+ document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
+ ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
+ ((this.path == null) ? "" : ("; path=" + this.path)) +
+ ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
+ ((this.secure == true) ? "; secure" : "");
+ },
+
+
+ clearCookie : function(name){
+ document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
+ ((this.path == null) ? "" : ("; path=" + this.path)) +
+ ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
+ ((this.secure == true) ? "; secure" : "");
+ }
+});
+Ext.DataView = Ext.extend(Ext.BoxComponent, {
+
+
+
+
+
+
+
+
+
+ selectedClass : "x-view-selected",
+
+ emptyText : "",
+
+
+ deferEmptyText: true,
+
+ trackOver: false,
+
+
+ blockRefresh: false,
+
+
+ last: false,
+
+
+ initComponent : function(){
+ Ext.DataView.superclass.initComponent.call(this);
+ if(Ext.isString(this.tpl) || Ext.isArray(this.tpl)){
+ this.tpl = new Ext.XTemplate(this.tpl);
+ }
+
+ this.addEvents(
+
+ "beforeclick",
+
+ "click",
+
+ "mouseenter",
+
+ "mouseleave",
+
+ "containerclick",
+
+ "dblclick",
+
+ "contextmenu",
+
+ "containercontextmenu",
+
+ "selectionchange",
+
+
+ "beforeselect"
+ );
+
+ this.store = Ext.StoreMgr.lookup(this.store);
+ this.all = new Ext.CompositeElementLite();
+ this.selected = new Ext.CompositeElementLite();
+ },
+
+
+ afterRender : function(){
+ Ext.DataView.superclass.afterRender.call(this);
+
+ this.mon(this.getTemplateTarget(), {
+ "click": this.onClick,
+ "dblclick": this.onDblClick,
+ "contextmenu": this.onContextMenu,
+ scope:this
+ });
+
+ if(this.overClass || this.trackOver){
+ this.mon(this.getTemplateTarget(), {
+ "mouseover": this.onMouseOver,
+ "mouseout": this.onMouseOut,
+ scope:this
+ });
+ }
+
+ if(this.store){
+ this.bindStore(this.store, true);
+ }
+ },
+
+
+ refresh : function() {
+ this.clearSelections(false, true);
+ var el = this.getTemplateTarget(),
+ records = this.store.getRange();
+
+ el.update('');
+ if(records.length < 1){
+ if(!this.deferEmptyText || this.hasSkippedEmptyText){
+ el.update(this.emptyText);
+ }
+ this.all.clear();
+ }else{
+ this.tpl.overwrite(el, this.collectData(records, 0));
+ this.all.fill(Ext.query(this.itemSelector, el.dom));
+ this.updateIndexes(0);
+ }
+ this.hasSkippedEmptyText = true;
+ },
+
+ getTemplateTarget: function(){
+ return this.el;
+ },
+
+
+ prepareData : function(data){
+ return data;
+ },
+
+
+ collectData : function(records, startIndex){
+ var r = [],
+ i = 0,
+ len = records.length;
+ for(; i < len; i++){
+ r[r.length] = this.prepareData(records[i].data, startIndex + i, records[i]);
+ }
+ return r;
+ },
+
+
+ bufferRender : function(records, index){
+ var div = document.createElement('div');
+ this.tpl.overwrite(div, this.collectData(records, index));
+ return Ext.query(this.itemSelector, div);
+ },
+
+
+ onUpdate : function(ds, record){
+ var index = this.store.indexOf(record);
+ if(index > -1){
+ var sel = this.isSelected(index),
+ original = this.all.elements[index],
+ node = this.bufferRender([record], index)[0];
+
+ this.all.replaceElement(index, node, true);
+ if(sel){
+ this.selected.replaceElement(original, node);
+ this.all.item(index).addClass(this.selectedClass);
+ }
+ this.updateIndexes(index, index);
+ }
+ },
+
+
+ onAdd : function(ds, records, index){
+ if(this.all.getCount() === 0){
+ this.refresh();
+ return;
+ }
+ var nodes = this.bufferRender(records, index), n, a = this.all.elements;
+ if(index < this.all.getCount()){
+ n = this.all.item(index).insertSibling(nodes, 'before', true);
+ a.splice.apply(a, [index, 0].concat(nodes));
+ }else{
+ n = this.all.last().insertSibling(nodes, 'after', true);
+ a.push.apply(a, nodes);
+ }
+ this.updateIndexes(index);
+ },
+
+
+ onRemove : function(ds, record, index){
+ this.deselect(index);
+ this.all.removeElement(index, true);
+ this.updateIndexes(index);
+ if (this.store.getCount() === 0){
+ this.refresh();
+ }
+ },
+
+
+ refreshNode : function(index){
+ this.onUpdate(this.store, this.store.getAt(index));
+ },
+
+
+ updateIndexes : function(startIndex, endIndex){
+ var ns = this.all.elements;
+ startIndex = startIndex || 0;
+ endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
+ for(var i = startIndex; i <= endIndex; i++){
+ ns[i].viewIndex = i;
+ }
+ },
+
+
+ getStore : function(){
+ return this.store;
+ },
+
+
+ bindStore : function(store, initial){
+ if(!initial && this.store){
+ if(store !== this.store && this.store.autoDestroy){
+ this.store.destroy();
+ }else{
+ this.store.un("beforeload", this.onBeforeLoad, this);
+ this.store.un("datachanged", this.onDataChanged, this);
+ this.store.un("add", this.onAdd, this);
+ this.store.un("remove", this.onRemove, this);
+ this.store.un("update", this.onUpdate, this);
+ this.store.un("clear", this.refresh, this);
+ }
+ if(!store){
+ this.store = null;
+ }
+ }
+ if(store){
+ store = Ext.StoreMgr.lookup(store);
+ store.on({
+ scope: this,
+ beforeload: this.onBeforeLoad,
+ datachanged: this.onDataChanged,
+ add: this.onAdd,
+ remove: this.onRemove,
+ update: this.onUpdate,
+ clear: this.refresh
+ });
+ }
+ this.store = store;
+ if(store){
+ this.refresh();
+ }
+ },
+
+
+ onDataChanged: function() {
+ if (this.blockRefresh !== true) {
+ this.refresh.apply(this, arguments);
+ }
+ },
+
+
+ findItemFromChild : function(node){
+ return Ext.fly(node).findParent(this.itemSelector, this.getTemplateTarget());
+ },
+
+
+ onClick : function(e){
+ var item = e.getTarget(this.itemSelector, this.getTemplateTarget()),
+ index;
+ if(item){
+ index = this.indexOf(item);
+ if(this.onItemClick(item, index, e) !== false){
+ this.fireEvent("click", this, index, item, e);
+ }
+ }else{
+ if(this.fireEvent("containerclick", this, e) !== false){
+ this.onContainerClick(e);
+ }
+ }
+ },
+
+ onContainerClick : function(e){
+ this.clearSelections();
+ },
+
+
+ onContextMenu : function(e){
+ var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
+ if(item){
+ this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
+ }else{
+ this.fireEvent("containercontextmenu", this, e);
+ }
+ },
+
+
+ onDblClick : function(e){
+ var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
+ if(item){
+ this.fireEvent("dblclick", this, this.indexOf(item), item, e);
+ }
+ },
+
+
+ onMouseOver : function(e){
+ var item = e.getTarget(this.itemSelector, this.getTemplateTarget());
+ if(item && item !== this.lastItem){
+ this.lastItem = item;
+ Ext.fly(item).addClass(this.overClass);
+ this.fireEvent("mouseenter", this, this.indexOf(item), item, e);
+ }
+ },
+
+
+ onMouseOut : function(e){
+ if(this.lastItem){
+ if(!e.within(this.lastItem, true, true)){
+ Ext.fly(this.lastItem).removeClass(this.overClass);
+ this.fireEvent("mouseleave", this, this.indexOf(this.lastItem), this.lastItem, e);
+ delete this.lastItem;
+ }
+ }
+ },
+
+
+ onItemClick : function(item, index, e){
+ if(this.fireEvent("beforeclick", this, index, item, e) === false){
+ return false;
+ }
+ if(this.multiSelect){
+ this.doMultiSelection(item, index, e);
+ e.preventDefault();
+ }else if(this.singleSelect){
+ this.doSingleSelection(item, index, e);
+ e.preventDefault();
+ }
+ return true;
+ },
+
+
+ doSingleSelection : function(item, index, e){
+ if(e.ctrlKey && this.isSelected(index)){
+ this.deselect(index);
+ }else{
+ this.select(index, false);
+ }
+ },
+
+
+ doMultiSelection : function(item, index, e){
+ if(e.shiftKey && this.last !== false){
+ var last = this.last;
+ this.selectRange(last, index, e.ctrlKey);
+ this.last = last;
+ }else{
+ if((e.ctrlKey||this.simpleSelect) && this.isSelected(index)){
+ this.deselect(index);
+ }else{
+ this.select(index, e.ctrlKey || e.shiftKey || this.simpleSelect);
+ }
+ }
+ },
+
+
+ getSelectionCount : function(){
+ return this.selected.getCount();
+ },
+
+
+ getSelectedNodes : function(){
+ return this.selected.elements;
+ },
+
+
+ getSelectedIndexes : function(){
+ var indexes = [],
+ selected = this.selected.elements,
+ i = 0,
+ len = selected.length;
+
+ for(; i < len; i++){
+ indexes.push(selected[i].viewIndex);
+ }
+ return indexes;
+ },
+
+
+ getSelectedRecords : function(){
+ return this.getRecords(this.selected.elements);
+ },
+
+
+ getRecords : function(nodes){
+ var records = [],
+ i = 0,
+ len = nodes.length;
+
+ for(; i < len; i++){
+ records[records.length] = this.store.getAt(nodes[i].viewIndex);
+ }
+ return records;
+ },
+
+
+ getRecord : function(node){
+ return this.store.getAt(node.viewIndex);
+ },
+
+
+ clearSelections : function(suppressEvent, skipUpdate){
+ if((this.multiSelect || this.singleSelect) && this.selected.getCount() > 0){
+ if(!skipUpdate){
+ this.selected.removeClass(this.selectedClass);
+ }
+ this.selected.clear();
+ this.last = false;
+ if(!suppressEvent){
+ this.fireEvent("selectionchange", this, this.selected.elements);
+ }
+ }
+ },
+
+
+ isSelected : function(node){
+ return this.selected.contains(this.getNode(node));
+ },
+
+
+ deselect : function(node){
+ if(this.isSelected(node)){
+ node = this.getNode(node);
+ this.selected.removeElement(node);
+ if(this.last == node.viewIndex){
+ this.last = false;
+ }
+ Ext.fly(node).removeClass(this.selectedClass);
+ this.fireEvent("selectionchange", this, this.selected.elements);
+ }
+ },
+
+
+ select : function(nodeInfo, keepExisting, suppressEvent){
+ if(Ext.isArray(nodeInfo)){
+ if(!keepExisting){
+ this.clearSelections(true);
+ }
+ for(var i = 0, len = nodeInfo.length; i < len; i++){
+ this.select(nodeInfo[i], true, true);
+ }
+ if(!suppressEvent){
+ this.fireEvent("selectionchange", this, this.selected.elements);
+ }
+ } else{
+ var node = this.getNode(nodeInfo);
+ if(!keepExisting){
+ this.clearSelections(true);
+ }
+ if(node && !this.isSelected(node)){
+ if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){
+ Ext.fly(node).addClass(this.selectedClass);
+ this.selected.add(node);
+ this.last = node.viewIndex;
+ if(!suppressEvent){
+ this.fireEvent("selectionchange", this, this.selected.elements);
+ }
+ }
+ }
+ }
+ },
+
+
+ selectRange : function(start, end, keepExisting){
+ if(!keepExisting){
+ this.clearSelections(true);
+ }
+ this.select(this.getNodes(start, end), true);
+ },
+
+
+ getNode : function(nodeInfo){
+ if(Ext.isString(nodeInfo)){
+ return document.getElementById(nodeInfo);
+ }else if(Ext.isNumber(nodeInfo)){
+ return this.all.elements[nodeInfo];
+ }else if(nodeInfo instanceof Ext.data.Record){
+ var idx = this.store.indexOf(nodeInfo);
+ return this.all.elements[idx];
+ }
+ return nodeInfo;
+ },
+
+
+ getNodes : function(start, end){
+ var ns = this.all.elements,
+ nodes = [],
+ i;
+
+ start = start || 0;
+ end = !Ext.isDefined(end) ? Math.max(ns.length - 1, 0) : end;
+ if(start <= end){
+ for(i = start; i <= end && ns[i]; i++){
+ nodes.push(ns[i]);
+ }
+ } else{
+ for(i = start; i >= end && ns[i]; i--){
+ nodes.push(ns[i]);
+ }
+ }
+ return nodes;
+ },
+
+
+ indexOf : function(node){
+ node = this.getNode(node);
+ if(Ext.isNumber(node.viewIndex)){
+ return node.viewIndex;
+ }
+ return this.all.indexOf(node);
+ },
+
+
+ onBeforeLoad : function(){
+ if(this.loadingText){
+ this.clearSelections(false, true);
+ this.getTemplateTarget().update('<div class="loading-indicator">'+this.loadingText+'</div>');
+ this.all.clear();
+ }
+ },
+
+ onDestroy : function(){
+ this.all.clear();
+ this.selected.clear();
+ Ext.DataView.superclass.onDestroy.call(this);
+ this.bindStore(null);
+ }
+});
+
+
+Ext.DataView.prototype.setStore = Ext.DataView.prototype.bindStore;
+
+Ext.reg('dataview', Ext.DataView);
+
+Ext.list.ListView = Ext.extend(Ext.DataView, {
+
+
+
+ itemSelector: 'dl',
+
+ selectedClass:'x-list-selected',
+
+ overClass:'x-list-over',
+
+
+ scrollOffset : undefined,
+
+ columnResize: true,
+
+
+ columnSort: true,
+
+
+
+ maxColumnWidth: Ext.isIE ? 99 : 100,
+
+ initComponent : function(){
+ if(this.columnResize){
+ this.colResizer = new Ext.list.ColumnResizer(this.colResizer);
+ this.colResizer.init(this);
+ }
+ if(this.columnSort){
+ this.colSorter = new Ext.list.Sorter(this.columnSort);
+ this.colSorter.init(this);
+ }
+ if(!this.internalTpl){
+ this.internalTpl = new Ext.XTemplate(
+ '<div class="x-list-header"><div class="x-list-header-inner">',
+ '<tpl for="columns">',
+ '<div style="width:{[values.width*100]}%;text-align:{align};"><em unselectable="on" id="',this.id, '-xlhd-{#}">',
+ '{header}',
+ '</em></div>',
+ '</tpl>',
+ '<div class="x-clear"></div>',
+ '</div></div>',
+ '<div class="x-list-body"><div class="x-list-body-inner">',
+ '</div></div>'
+ );
+ }
+ if(!this.tpl){
+ this.tpl = new Ext.XTemplate(
+ '<tpl for="rows">',
+ '<dl>',
+ '<tpl for="parent.columns">',
+ '<dt style="width:{[values.width*100]}%;text-align:{align};">',
+ '<em unselectable="on"<tpl if="cls"> class="{cls}</tpl>">',
+ '{[values.tpl.apply(parent)]}',
+ '</em></dt>',
+ '</tpl>',
+ '<div class="x-clear"></div>',
+ '</dl>',
+ '</tpl>'
+ );
+ };
+
+ var cs = this.columns,
+ allocatedWidth = 0,
+ colsWithWidth = 0,
+ len = cs.length,
+ columns = [];
+
+ for(var i = 0; i < len; i++){
+ var c = cs[i];
+ if(!c.isColumn) {
+ c.xtype = c.xtype ? (/^lv/.test(c.xtype) ? c.xtype : 'lv' + c.xtype) : 'lvcolumn';
+ c = Ext.create(c);
+ }
+ if(c.width) {
+ allocatedWidth += c.width*100;
+ if(allocatedWidth > this.maxColumnWidth){
+ c.width -= (allocatedWidth - this.maxColumnWidth) / 100;
+ }
+ colsWithWidth++;
+ }
+ columns.push(c);
+ }
+
+ cs = this.columns = columns;
+
+
+ if(colsWithWidth < len){
+ var remaining = len - colsWithWidth;
+ if(allocatedWidth < this.maxColumnWidth){
+ var perCol = ((this.maxColumnWidth-allocatedWidth) / remaining)/100;
+ for(var j = 0; j < len; j++){
+ var c = cs[j];
+ if(!c.width){
+ c.width = perCol;
+ }
+ }
+ }
+ }
+ Ext.list.ListView.superclass.initComponent.call(this);
+ },
+
+ onRender : function(){
+ this.autoEl = {
+ cls: 'x-list-wrap'
+ };
+ Ext.list.ListView.superclass.onRender.apply(this, arguments);
+
+ this.internalTpl.overwrite(this.el, {columns: this.columns});
+
+ this.innerBody = Ext.get(this.el.dom.childNodes[1].firstChild);
+ this.innerHd = Ext.get(this.el.dom.firstChild.firstChild);
+
+ if(this.hideHeaders){
+ this.el.dom.firstChild.style.display = 'none';
+ }
+ },
+
+ getTemplateTarget : function(){
+ return this.innerBody;
+ },
+
+
+ collectData : function(){
+ var rs = Ext.list.ListView.superclass.collectData.apply(this, arguments);
+ return {
+ columns: this.columns,
+ rows: rs
+ };
+ },
+
+ verifyInternalSize : function(){
+ if(this.lastSize){
+ this.onResize(this.lastSize.width, this.lastSize.height);
+ }
+ },
+
+
+ onResize : function(w, h){
+ var body = this.innerBody.dom,
+ header = this.innerHd.dom,
+ scrollWidth = w - Ext.num(this.scrollOffset, Ext.getScrollBarWidth()) + 'px',
+ parentNode;
+
+ if(!body){
+ return;
+ }
+ parentNode = body.parentNode;
+ if(Ext.isNumber(w)){
+ if(this.reserveScrollOffset || ((parentNode.offsetWidth - parentNode.clientWidth) > 10)){
+ body.style.width = scrollWidth;
+ header.style.width = scrollWidth;
+ }else{
+ body.style.width = w + 'px';
+ header.style.width = w + 'px';
+ setTimeout(function(){
+ if((parentNode.offsetWidth - parentNode.clientWidth) > 10){
+ body.style.width = scrollWidth;
+ header.style.width = scrollWidth;
+ }
+ }, 10);
+ }
+ }
+ if(Ext.isNumber(h)){
+ parentNode.style.height = Math.max(0, h - header.parentNode.offsetHeight) + 'px';
+ }
+ },
+
+ updateIndexes : function(){
+ Ext.list.ListView.superclass.updateIndexes.apply(this, arguments);
+ this.verifyInternalSize();
+ },
+
+ findHeaderIndex : function(header){
+ header = header.dom || header;
+ var parentNode = header.parentNode,
+ children = parentNode.parentNode.childNodes,
+ i = 0,
+ c;
+ for(; c = children[i]; i++){
+ if(c == parentNode){
+ return i;
+ }
+ }
+ return -1;
+ },
+
+ setHdWidths : function(){
+ var els = this.innerHd.dom.getElementsByTagName('div'),
+ i = 0,
+ columns = this.columns,
+ len = columns.length;
+
+ for(; i < len; i++){
+ els[i].style.width = (columns[i].width*100) + '%';
+ }
+ }
+});
+
+Ext.reg('listview', Ext.list.ListView);
+
+
+Ext.ListView = Ext.list.ListView;
+Ext.list.Column = Ext.extend(Object, {
+
+ isColumn: true,
+
+
+ align: 'left',
+
+ header: '',
+
+
+ width: null,
+
+
+ cls: '',
+
+
+
+
+
+ constructor : function(c){
+ if(!c.tpl){
+ c.tpl = new Ext.XTemplate('{' + c.dataIndex + '}');
+ }
+ else if(Ext.isString(c.tpl)){
+ c.tpl = new Ext.XTemplate(c.tpl);
+ }
+
+ Ext.apply(this, c);
+ }
+});
+
+Ext.reg('lvcolumn', Ext.list.Column);
+
+
+Ext.list.NumberColumn = Ext.extend(Ext.list.Column, {
+
+ format: '0,000.00',
+
+ constructor : function(c) {
+ c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':number("' + (c.format || this.format) + '")}');
+ Ext.list.NumberColumn.superclass.constructor.call(this, c);
+ }
+});
+
+Ext.reg('lvnumbercolumn', Ext.list.NumberColumn);
+
+
+Ext.list.DateColumn = Ext.extend(Ext.list.Column, {
+ format: 'm/d/Y',
+ constructor : function(c) {
+ c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':date("' + (c.format || this.format) + '")}');
+ Ext.list.DateColumn.superclass.constructor.call(this, c);
+ }
+});
+Ext.reg('lvdatecolumn', Ext.list.DateColumn);
+
+
+Ext.list.BooleanColumn = Ext.extend(Ext.list.Column, {
+
+ trueText: 'true',
+
+ falseText: 'false',
+
+ undefinedText: ' ',
+
+ constructor : function(c) {
+ c.tpl = c.tpl || new Ext.XTemplate('{' + c.dataIndex + ':this.format}');
+
+ var t = this.trueText, f = this.falseText, u = this.undefinedText;
+ c.tpl.format = function(v){
+ if(v === undefined){
+ return u;
+ }
+ if(!v || v === 'false'){
+ return f;
+ }
+ return t;
+ };
+
+ Ext.list.DateColumn.superclass.constructor.call(this, c);
+ }
+});
+
+Ext.reg('lvbooleancolumn', Ext.list.BooleanColumn);
+Ext.list.ColumnResizer = Ext.extend(Ext.util.Observable, {
+
+ minPct: .05,
+
+ constructor: function(config){
+ Ext.apply(this, config);
+ Ext.list.ColumnResizer.superclass.constructor.call(this);
+ },
+ init : function(listView){
+ this.view = listView;
+ listView.on('render', this.initEvents, this);
+ },
+
+ initEvents : function(view){
+ view.mon(view.innerHd, 'mousemove', this.handleHdMove, this);
+ this.tracker = new Ext.dd.DragTracker({
+ onBeforeStart: this.onBeforeStart.createDelegate(this),
+ onStart: this.onStart.createDelegate(this),
+ onDrag: this.onDrag.createDelegate(this),
+ onEnd: this.onEnd.createDelegate(this),
+ tolerance: 3,
+ autoStart: 300
+ });
+ this.tracker.initEl(view.innerHd);
+ view.on('beforedestroy', this.tracker.destroy, this.tracker);
+ },
+
+ handleHdMove : function(e, t){
+ var handleWidth = 5,
+ x = e.getPageX(),
+ header = e.getTarget('em', 3, true);
+ if(header){
+ var region = header.getRegion(),
+ style = header.dom.style,
+ parentNode = header.dom.parentNode;
+
+ if(x - region.left <= handleWidth && parentNode != parentNode.parentNode.firstChild){
+ this.activeHd = Ext.get(parentNode.previousSibling.firstChild);
+ style.cursor = Ext.isWebKit ? 'e-resize' : 'col-resize';
+ } else if(region.right - x <= handleWidth && parentNode != parentNode.parentNode.lastChild.previousSibling){
+ this.activeHd = header;
+ style.cursor = Ext.isWebKit ? 'w-resize' : 'col-resize';
+ } else{
+ delete this.activeHd;
+ style.cursor = '';
+ }
+ }
+ },
+
+ onBeforeStart : function(e){
+ this.dragHd = this.activeHd;
+ return !!this.dragHd;
+ },
+
+ onStart: function(e){
+
+ var me = this,
+ view = me.view,
+ dragHeader = me.dragHd,
+ x = me.tracker.getXY()[0];
+
+ me.proxy = view.el.createChild({cls:'x-list-resizer'});
+ me.dragX = dragHeader.getX();
+ me.headerIndex = view.findHeaderIndex(dragHeader);
+
+ me.headersDisabled = view.disableHeaders;
+ view.disableHeaders = true;
+
+ me.proxy.setHeight(view.el.getHeight());
+ me.proxy.setX(me.dragX);
+ me.proxy.setWidth(x - me.dragX);
+
+ this.setBoundaries();
+
+ },
+
+
+ setBoundaries: function(relativeX){
+ var view = this.view,
+ headerIndex = this.headerIndex,
+ width = view.innerHd.getWidth(),
+ relativeX = view.innerHd.getX(),
+ minWidth = Math.ceil(width * this.minPct),
+ maxWidth = width - minWidth,
+ numColumns = view.columns.length,
+ headers = view.innerHd.select('em', true),
+ minX = minWidth + relativeX,
+ maxX = maxWidth + relativeX,
+ header;
+
+ if (numColumns == 2) {
+ this.minX = minX;
+ this.maxX = maxX;
+ }else{
+ header = headers.item(headerIndex + 2);
+ this.minX = headers.item(headerIndex).getX() + minWidth;
+ this.maxX = header ? header.getX() - minWidth : maxX;
+ if (headerIndex == 0) {
+
+ this.minX = minX;
+ } else if (headerIndex == numColumns - 2) {
+
+ this.maxX = maxX;
+ }
+ }
+ },
+
+ onDrag: function(e){
+ var me = this,
+ cursorX = me.tracker.getXY()[0].constrain(me.minX, me.maxX);
+
+ me.proxy.setWidth(cursorX - this.dragX);
+ },
+
+ onEnd: function(e){
+
+ var newWidth = this.proxy.getWidth(),
+ index = this.headerIndex,
+ view = this.view,
+ columns = view.columns,
+ width = view.innerHd.getWidth(),
+ newPercent = Math.ceil(newWidth * view.maxColumnWidth / width) / 100,
+ disabled = this.headersDisabled,
+ headerCol = columns[index],
+ otherCol = columns[index + 1],
+ totalPercent = headerCol.width + otherCol.width;
+
+ this.proxy.remove();
+
+ headerCol.width = newPercent;
+ otherCol.width = totalPercent - newPercent;
+
+ delete this.dragHd;
+ view.setHdWidths();
+ view.refresh();
+
+ setTimeout(function(){
+ view.disableHeaders = disabled;
+ }, 100);
+ }
+});
+
+
+Ext.ListView.ColumnResizer = Ext.list.ColumnResizer;
+Ext.list.Sorter = Ext.extend(Ext.util.Observable, {
+
+ sortClasses : ["sort-asc", "sort-desc"],
+
+ constructor: function(config){
+ Ext.apply(this, config);
+ Ext.list.Sorter.superclass.constructor.call(this);
+ },
+
+ init : function(listView){
+ this.view = listView;
+ listView.on('render', this.initEvents, this);
+ },
+
+ initEvents : function(view){
+ view.mon(view.innerHd, 'click', this.onHdClick, this);
+ view.innerHd.setStyle('cursor', 'pointer');
+ view.mon(view.store, 'datachanged', this.updateSortState, this);
+ this.updateSortState.defer(10, this, [view.store]);
+ },
+
+ updateSortState : function(store){
+ var state = store.getSortState();
+ if(!state){
+ return;
+ }
+ this.sortState = state;
+ var cs = this.view.columns, sortColumn = -1;
+ for(var i = 0, len = cs.length; i < len; i++){
+ if(cs[i].dataIndex == state.field){
+ sortColumn = i;
+ break;
+ }
+ }
+ if(sortColumn != -1){
+ var sortDir = state.direction;
+ this.updateSortIcon(sortColumn, sortDir);
+ }
+ },
+
+ updateSortIcon : function(col, dir){
+ var sc = this.sortClasses;
+ var hds = this.view.innerHd.select('em').removeClass(sc);
+ hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
+ },
+
+ onHdClick : function(e){
+ var hd = e.getTarget('em', 3);
+ if(hd && !this.view.disableHeaders){
+ var index = this.view.findHeaderIndex(hd);
+ this.view.store.sort(this.view.columns[index].dataIndex);
+ }
+ }
+});
+
+
+Ext.ListView.Sorter = Ext.list.Sorter;
+Ext.TabPanel = Ext.extend(Ext.Panel, {
+
+
+
+ deferredRender : true,
+
+ tabWidth : 120,
+
+ minTabWidth : 30,
+
+ resizeTabs : false,
+
+ enableTabScroll : false,
+
+ scrollIncrement : 0,
+
+ scrollRepeatInterval : 400,
+
+ scrollDuration : 0.35,
+
+ animScroll : true,
+
+ tabPosition : 'top',
+
+ baseCls : 'x-tab-panel',
+
+ autoTabs : false,
+
+ autoTabSelector : 'div.x-tab',
+
+ activeTab : undefined,
+
+ tabMargin : 2,
+
+ plain : false,
+
+ wheelIncrement : 20,
+
+
+ idDelimiter : '__',
+
+
+ itemCls : 'x-tab-item',
+
+
+ elements : 'body',
+ headerAsText : false,
+ frame : false,
+ hideBorders :true,
+
+
+ initComponent : function(){
+ this.frame = false;
+ Ext.TabPanel.superclass.initComponent.call(this);
+ this.addEvents(
+
+ 'beforetabchange',
+
+ 'tabchange',
+
+ 'contextmenu'
+ );
+
+ this.setLayout(new Ext.layout.CardLayout(Ext.apply({
+ layoutOnCardChange: this.layoutOnTabChange,
+ deferredRender: this.deferredRender
+ }, this.layoutConfig)));
+
+ if(this.tabPosition == 'top'){
+ this.elements += ',header';
+ this.stripTarget = 'header';
+ }else {
+ this.elements += ',footer';
+ this.stripTarget = 'footer';
+ }
+ if(!this.stack){
+ this.stack = Ext.TabPanel.AccessStack();
+ }
+ this.initItems();
+ },
+
+
+ onRender : function(ct, position){
+ Ext.TabPanel.superclass.onRender.call(this, ct, position);
+
+ if(this.plain){
+ var pos = this.tabPosition == 'top' ? 'header' : 'footer';
+ this[pos].addClass('x-tab-panel-'+pos+'-plain');
+ }
+
+ var st = this[this.stripTarget];
+
+ this.stripWrap = st.createChild({cls:'x-tab-strip-wrap', cn:{
+ tag:'ul', cls:'x-tab-strip x-tab-strip-'+this.tabPosition}});
+
+ var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null);
+ st.createChild({cls:'x-tab-strip-spacer'}, beforeEl);
+ this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
+
+
+ this.edge = this.strip.createChild({tag:'li', cls:'x-tab-edge', cn: [{tag: 'span', cls: 'x-tab-strip-text', cn: ' '}]});
+ this.strip.createChild({cls:'x-clear'});
+
+ this.body.addClass('x-tab-panel-body-'+this.tabPosition);
+
+
+ if(!this.itemTpl){
+ var tt = new Ext.Template(
+ '<li class="{cls}" id="{id}"><a class="x-tab-strip-close"></a>',
+ '<a class="x-tab-right" href="#"><em class="x-tab-left">',
+ '<span class="x-tab-strip-inner"><span class="x-tab-strip-text {iconCls}">{text}</span></span>',
+ '</em></a></li>'
+ );
+ tt.disableFormats = true;
+ tt.compile();
+ Ext.TabPanel.prototype.itemTpl = tt;
+ }
+
+ this.items.each(this.initTab, this);
+ },
+
+
+ afterRender : function(){
+ Ext.TabPanel.superclass.afterRender.call(this);
+ if(this.autoTabs){
+ this.readTabs(false);
+ }
+ if(this.activeTab !== undefined){
+ var item = Ext.isObject(this.activeTab) ? this.activeTab : this.items.get(this.activeTab);
+ delete this.activeTab;
+ this.setActiveTab(item);
+ }
+ },
+
+
+ initEvents : function(){
+ Ext.TabPanel.superclass.initEvents.call(this);
+ this.mon(this.strip, {
+ scope: this,
+ mousedown: this.onStripMouseDown,
+ contextmenu: this.onStripContextMenu
+ });
+ if(this.enableTabScroll){
+ this.mon(this.strip, 'mousewheel', this.onWheel, this);
+ }
+ },
+
+
+ findTargets : function(e){
+ var item = null,
+ itemEl = e.getTarget('li:not(.x-tab-edge)', this.strip);
+
+ if(itemEl){
+ item = this.getComponent(itemEl.id.split(this.idDelimiter)[1]);
+ if(item.disabled){
+ return {
+ close : null,
+ item : null,
+ el : null
+ };
+ }
+ }
+ return {
+ close : e.getTarget('.x-tab-strip-close', this.strip),
+ item : item,
+ el : itemEl
+ };
+ },
+
+
+ onStripMouseDown : function(e){
+ if(e.button !== 0){
+ return;
+ }
+ e.preventDefault();
+ var t = this.findTargets(e);
+ if(t.close){
+ if (t.item.fireEvent('beforeclose', t.item) !== false) {
+ t.item.fireEvent('close', t.item);
+ this.remove(t.item);
+ }
+ return;
+ }
+ if(t.item && t.item != this.activeTab){
+ this.setActiveTab(t.item);
+ }
+ },
+
+
+ onStripContextMenu : function(e){
+ e.preventDefault();
+ var t = this.findTargets(e);
+ if(t.item){
+ this.fireEvent('contextmenu', this, t.item, e);
+ }
+ },
+
+
+ readTabs : function(removeExisting){
+ if(removeExisting === true){
+ this.items.each(function(item){
+ this.remove(item);
+ }, this);
+ }
+ var tabs = this.el.query(this.autoTabSelector);
+ for(var i = 0, len = tabs.length; i < len; i++){
+ var tab = tabs[i],
+ title = tab.getAttribute('title');
+ tab.removeAttribute('title');
+ this.add({
+ title: title,
+ contentEl: tab
+ });
+ }
+ },
+
+
+ initTab : function(item, index){
+ var before = this.strip.dom.childNodes[index],
+ p = this.getTemplateArgs(item),
+ el = before ?
+ this.itemTpl.insertBefore(before, p) :
+ this.itemTpl.append(this.strip, p),
+ cls = 'x-tab-strip-over',
+ tabEl = Ext.get(el);
+
+ tabEl.hover(function(){
+ if(!item.disabled){
+ tabEl.addClass(cls);
+ }
+ }, function(){
+ tabEl.removeClass(cls);
+ });
+
+ if(item.tabTip){
+ tabEl.child('span.x-tab-strip-text', true).qtip = item.tabTip;
+ }
+ item.tabEl = el;
+
+
+ tabEl.select('a').on('click', function(e){
+ if(!e.getPageX()){
+ this.onStripMouseDown(e);
+ }
+ }, this, {preventDefault: true});
+
+ item.on({
+ scope: this,
+ disable: this.onItemDisabled,
+ enable: this.onItemEnabled,
+ titlechange: this.onItemTitleChanged,
+ iconchange: this.onItemIconChanged,
+ beforeshow: this.onBeforeShowItem
+ });
+ },
+
+
+
+
+ getTemplateArgs : function(item) {
+ var cls = item.closable ? 'x-tab-strip-closable' : '';
+ if(item.disabled){
+ cls += ' x-item-disabled';
+ }
+ if(item.iconCls){
+ cls += ' x-tab-with-icon';
+ }
+ if(item.tabCls){
+ cls += ' ' + item.tabCls;
+ }
+
+ return {
+ id: this.id + this.idDelimiter + item.getItemId(),
+ text: item.title,
+ cls: cls,
+ iconCls: item.iconCls || ''
+ };
+ },
+
+
+ onAdd : function(c){
+ Ext.TabPanel.superclass.onAdd.call(this, c);
+ if(this.rendered){
+ var items = this.items;
+ this.initTab(c, items.indexOf(c));
+ this.delegateUpdates();
+ }
+ },
+
+
+ onBeforeAdd : function(item){
+ var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
+ if(existing){
+ this.setActiveTab(item);
+ return false;
+ }
+ Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
+ var es = item.elements;
+ item.elements = es ? es.replace(',header', '') : es;
+ item.border = (item.border === true);
+ },
+
+
+ onRemove : function(c){
+ var te = Ext.get(c.tabEl);
+
+ if(te){
+ te.select('a').removeAllListeners();
+ Ext.destroy(te);
+ }
+ Ext.TabPanel.superclass.onRemove.call(this, c);
+ this.stack.remove(c);
+ delete c.tabEl;
+ c.un('disable', this.onItemDisabled, this);
+ c.un('enable', this.onItemEnabled, this);
+ c.un('titlechange', this.onItemTitleChanged, this);
+ c.un('iconchange', this.onItemIconChanged, this);
+ c.un('beforeshow', this.onBeforeShowItem, this);
+ if(c == this.activeTab){
+ var next = this.stack.next();
+ if(next){
+ this.setActiveTab(next);
+ }else if(this.items.getCount() > 0){
+ this.setActiveTab(0);
+ }else{
+ this.setActiveTab(null);
+ }
+ }
+ if(!this.destroying){
+ this.delegateUpdates();
+ }
+ },
+
+
+ onBeforeShowItem : function(item){
+ if(item != this.activeTab){
+ this.setActiveTab(item);
+ return false;
+ }
+ },
+
+
+ onItemDisabled : function(item){
+ var el = this.getTabEl(item);
+ if(el){
+ Ext.fly(el).addClass('x-item-disabled');
+ }
+ this.stack.remove(item);
+ },
+
+
+ onItemEnabled : function(item){
+ var el = this.getTabEl(item);
+ if(el){
+ Ext.fly(el).removeClass('x-item-disabled');
+ }
+ },
+
+
+ onItemTitleChanged : function(item){
+ var el = this.getTabEl(item);
+ if(el){
+ Ext.fly(el).child('span.x-tab-strip-text', true).innerHTML = item.title;
+ }
+ },
+
+
+ onItemIconChanged : function(item, iconCls, oldCls){
+ var el = this.getTabEl(item);
+ if(el){
+ el = Ext.get(el);
+ el.child('span.x-tab-strip-text').replaceClass(oldCls, iconCls);
+ el[Ext.isEmpty(iconCls) ? 'removeClass' : 'addClass']('x-tab-with-icon');
+ }
+ },
+
+
+ getTabEl : function(item){
+ var c = this.getComponent(item);
+ return c ? c.tabEl : null;
+ },
+
+
+ onResize : function(){
+ Ext.TabPanel.superclass.onResize.apply(this, arguments);
+ this.delegateUpdates();
+ },
+
+
+ beginUpdate : function(){
+ this.suspendUpdates = true;
+ },
+
+
+ endUpdate : function(){
+ this.suspendUpdates = false;
+ this.delegateUpdates();
+ },
+
+
+ hideTabStripItem : function(item){
+ item = this.getComponent(item);
+ var el = this.getTabEl(item);
+ if(el){
+ el.style.display = 'none';
+ this.delegateUpdates();
+ }
+ this.stack.remove(item);
+ },
+
+
+ unhideTabStripItem : function(item){
+ item = this.getComponent(item);
+ var el = this.getTabEl(item);
+ if(el){
+ el.style.display = '';
+ this.delegateUpdates();
+ }
+ },
+
+
+ delegateUpdates : function(){
+ var rendered = this.rendered;
+ if(this.suspendUpdates){
+ return;
+ }
+ if(this.resizeTabs && rendered){
+ this.autoSizeTabs();
+ }
+ if(this.enableTabScroll && rendered){
+ this.autoScrollTabs();
+ }
+ },
+
+
+ autoSizeTabs : function(){
+ var count = this.items.length,
+ ce = this.tabPosition != 'bottom' ? 'header' : 'footer',
+ ow = this[ce].dom.offsetWidth,
+ aw = this[ce].dom.clientWidth;
+
+ if(!this.resizeTabs || count < 1 || !aw){
+ return;
+ }
+
+ var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.tabMargin, this.tabWidth), this.minTabWidth);
+ this.lastTabWidth = each;
+ var lis = this.strip.query('li:not(.x-tab-edge)');
+ for(var i = 0, len = lis.length; i < len; i++) {
+ var li = lis[i],
+ inner = Ext.fly(li).child('.x-tab-strip-inner', true),
+ tw = li.offsetWidth,
+ iw = inner.offsetWidth;
+ inner.style.width = (each - (tw-iw)) + 'px';
+ }
+ },
+
+
+ adjustBodyWidth : function(w){
+ if(this.header){
+ this.header.setWidth(w);
+ }
+ if(this.footer){
+ this.footer.setWidth(w);
+ }
+ return w;
+ },
+
+
+ setActiveTab : function(item){
+ item = this.getComponent(item);
+ if(this.fireEvent('beforetabchange', this, item, this.activeTab) === false){
+ return;
+ }
+ if(!this.rendered){
+ this.activeTab = item;
+ return;
+ }
+ if(this.activeTab != item){
+ if(this.activeTab){
+ var oldEl = this.getTabEl(this.activeTab);
+ if(oldEl){
+ Ext.fly(oldEl).removeClass('x-tab-strip-active');
+ }
+ }
+ this.activeTab = item;
+ if(item){
+ var el = this.getTabEl(item);
+ Ext.fly(el).addClass('x-tab-strip-active');
+ this.stack.add(item);
+
+ this.layout.setActiveItem(item);
+
+ this.delegateUpdates();
+ if(this.scrolling){
+ this.scrollToTab(item, this.animScroll);
+ }
+ }
+ this.fireEvent('tabchange', this, item);
+ }
+ },
+
+
+ getActiveTab : function(){
+ return this.activeTab || null;
+ },
+
+
+ getItem : function(item){
+ return this.getComponent(item);
+ },
+
+
+ autoScrollTabs : function(){
+ this.pos = this.tabPosition=='bottom' ? this.footer : this.header;
+ var count = this.items.length,
+ ow = this.pos.dom.offsetWidth,
+ tw = this.pos.dom.clientWidth,
+ wrap = this.stripWrap,
+ wd = wrap.dom,
+ cw = wd.offsetWidth,
+ pos = this.getScrollPos(),
+ l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos;
+
+ if(!this.enableTabScroll || cw < 20){
+ return;
+ }
+ if(count == 0 || l <= tw){
+
+ wd.scrollLeft = 0;
+ wrap.setWidth(tw);
+ if(this.scrolling){
+ this.scrolling = false;
+ this.pos.removeClass('x-tab-scrolling');
+ this.scrollLeft.hide();
+ this.scrollRight.hide();
+
+ if(Ext.isAir || Ext.isWebKit){
+ wd.style.marginLeft = '';
+ wd.style.marginRight = '';
+ }
+ }
+ }else{
+ if(!this.scrolling){
+ this.pos.addClass('x-tab-scrolling');
+
+ if(Ext.isAir || Ext.isWebKit){
+ wd.style.marginLeft = '18px';
+ wd.style.marginRight = '18px';
+ }
+ }
+ tw -= wrap.getMargins('lr');
+ wrap.setWidth(tw > 20 ? tw : 20);
+ if(!this.scrolling){
+ if(!this.scrollLeft){
+ this.createScrollers();
+ }else{
+ this.scrollLeft.show();
+ this.scrollRight.show();
+ }
+ }
+ this.scrolling = true;
+ if(pos > (l-tw)){
+ wd.scrollLeft = l-tw;
+ }else{
+ this.scrollToTab(this.activeTab, false);
+ }
+ this.updateScrollButtons();
+ }
+ },
+
+
+ createScrollers : function(){
+ this.pos.addClass('x-tab-scrolling-' + this.tabPosition);
+ var h = this.stripWrap.dom.offsetHeight;
+
+
+ var sl = this.pos.insertFirst({
+ cls:'x-tab-scroller-left'
+ });
+ sl.setHeight(h);
+ sl.addClassOnOver('x-tab-scroller-left-over');
+ this.leftRepeater = new Ext.util.ClickRepeater(sl, {
+ interval : this.scrollRepeatInterval,
+ handler: this.onScrollLeft,
+ scope: this
+ });
+ this.scrollLeft = sl;
+
+
+ var sr = this.pos.insertFirst({
+ cls:'x-tab-scroller-right'
+ });
+ sr.setHeight(h);
+ sr.addClassOnOver('x-tab-scroller-right-over');
+ this.rightRepeater = new Ext.util.ClickRepeater(sr, {
+ interval : this.scrollRepeatInterval,
+ handler: this.onScrollRight,
+ scope: this
+ });
+ this.scrollRight = sr;
+ },
+
+
+ getScrollWidth : function(){
+ return this.edge.getOffsetsTo(this.stripWrap)[0] + this.getScrollPos();
+ },
+
+
+ getScrollPos : function(){
+ return parseInt(this.stripWrap.dom.scrollLeft, 10) || 0;
+ },
+
+
+ getScrollArea : function(){
+ return parseInt(this.stripWrap.dom.clientWidth, 10) || 0;
+ },
+
+
+ getScrollAnim : function(){
+ return {duration:this.scrollDuration, callback: this.updateScrollButtons, scope: this};
+ },
+
+
+ getScrollIncrement : function(){
+ return this.scrollIncrement || (this.resizeTabs ? this.lastTabWidth+2 : 100);
+ },
+
+
+
+ scrollToTab : function(item, animate){
+ if(!item){
+ return;
+ }
+ var el = this.getTabEl(item),
+ pos = this.getScrollPos(),
+ area = this.getScrollArea(),
+ left = Ext.fly(el).getOffsetsTo(this.stripWrap)[0] + pos,
+ right = left + el.offsetWidth;
+ if(left < pos){
+ this.scrollTo(left, animate);
+ }else if(right > (pos + area)){
+ this.scrollTo(right - area, animate);
+ }
+ },
+
+
+ scrollTo : function(pos, animate){
+ this.stripWrap.scrollTo('left', pos, animate ? this.getScrollAnim() : false);
+ if(!animate){
+ this.updateScrollButtons();
+ }
+ },
+
+ onWheel : function(e){
+ var d = e.getWheelDelta()*this.wheelIncrement*-1;
+ e.stopEvent();
+
+ var pos = this.getScrollPos(),
+ newpos = pos + d,
+ sw = this.getScrollWidth()-this.getScrollArea();
+
+ var s = Math.max(0, Math.min(sw, newpos));
+ if(s != pos){
+ this.scrollTo(s, false);
+ }
+ },
+
+
+ onScrollRight : function(){
+ var sw = this.getScrollWidth()-this.getScrollArea(),
+ pos = this.getScrollPos(),
+ s = Math.min(sw, pos + this.getScrollIncrement());
+ if(s != pos){
+ this.scrollTo(s, this.animScroll);
+ }
+ },
+
+
+ onScrollLeft : function(){
+ var pos = this.getScrollPos(),
+ s = Math.max(0, pos - this.getScrollIncrement());
+ if(s != pos){
+ this.scrollTo(s, this.animScroll);
+ }
+ },
+
+
+ updateScrollButtons : function(){
+ var pos = this.getScrollPos();
+ this.scrollLeft[pos === 0 ? 'addClass' : 'removeClass']('x-tab-scroller-left-disabled');
+ this.scrollRight[pos >= (this.getScrollWidth()-this.getScrollArea()) ? 'addClass' : 'removeClass']('x-tab-scroller-right-disabled');
+ },
+
+
+ beforeDestroy : function() {
+ Ext.destroy(this.leftRepeater, this.rightRepeater);
+ this.deleteMembers('strip', 'edge', 'scrollLeft', 'scrollRight', 'stripWrap');
+ this.activeTab = null;
+ Ext.TabPanel.superclass.beforeDestroy.apply(this);
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+});
+Ext.reg('tabpanel', Ext.TabPanel);
+
+
+Ext.TabPanel.prototype.activate = Ext.TabPanel.prototype.setActiveTab;
+
+
+Ext.TabPanel.AccessStack = function(){
+ var items = [];
+ return {
+ add : function(item){
+ items.push(item);
+ if(items.length > 10){
+ items.shift();
+ }
+ },
+
+ remove : function(item){
+ var s = [];
+ for(var i = 0, len = items.length; i < len; i++) {
+ if(items[i] != item){
+ s.push(items[i]);
+ }
+ }
+ items = s;
+ },
+
+ next : function(){
+ return items.pop();
+ }
+ };
+};
+
+Ext.Button = Ext.extend(Ext.BoxComponent, {
+
+ hidden : false,
+
+ disabled : false,
+
+ pressed : false,
+
+
+
+
+
+
+ enableToggle : false,
+
+
+
+ menuAlign : 'tl-bl?',
+
+
+
+
+ type : 'button',
+
+
+ menuClassTarget : 'tr:nth(2)',
+
+
+ clickEvent : 'click',
+
+
+ handleMouseEvents : true,
+
+
+ tooltipType : 'qtip',
+
+
+ buttonSelector : 'button:first-child',
+
+
+ scale : 'small',
+
+
+
+
+ iconAlign : 'left',
+
+
+ arrowAlign : 'right',
+
+
+
+
+
+
+ initComponent : function(){
+ if(this.menu){
+ this.menu = Ext.menu.MenuMgr.get(this.menu);
+ this.menu.ownerCt = this;
+ }
+
+ Ext.Button.superclass.initComponent.call(this);
+
+ this.addEvents(
+
+ 'click',
+
+ 'toggle',
+
+ 'mouseover',
+
+ 'mouseout',
+
+ 'menushow',
+
+ 'menuhide',
+
+ 'menutriggerover',
+
+ 'menutriggerout'
+ );
+
+ if (this.menu){
+ this.menu.ownerCt = undefined;
+ }
+ if(Ext.isString(this.toggleGroup)){
+ this.enableToggle = true;
+ }
+ },
+
+
+ getTemplateArgs : function(){
+ return [this.type, 'x-btn-' + this.scale + ' x-btn-icon-' + this.scale + '-' + this.iconAlign, this.getMenuClass(), this.cls, this.id];
+ },
+
+
+ setButtonClass : function(){
+ if(this.useSetClass){
+ if(!Ext.isEmpty(this.oldCls)){
+ this.el.removeClass([this.oldCls, 'x-btn-pressed']);
+ }
+ this.oldCls = (this.iconCls || this.icon) ? (this.text ? 'x-btn-text-icon' : 'x-btn-icon') : 'x-btn-noicon';
+ this.el.addClass([this.oldCls, this.pressed ? 'x-btn-pressed' : null]);
+ }
+ },
+
+
+ getMenuClass : function(){
+ return this.menu ? (this.arrowAlign != 'bottom' ? 'x-btn-arrow' : 'x-btn-arrow-bottom') : '';
+ },
+
+
+ onRender : function(ct, position){
+ if(!this.template){
+ if(!Ext.Button.buttonTemplate){
+
+ Ext.Button.buttonTemplate = new Ext.Template(
+ '<table id="{4}" cellspacing="0" class="x-btn {3}"><tbody class="{1}">',
+ '<tr><td class="x-btn-tl"><i> </i></td><td class="x-btn-tc"></td><td class="x-btn-tr"><i> </i></td></tr>',
+ '<tr><td class="x-btn-ml"><i> </i></td><td class="x-btn-mc"><em class="{2}" unselectable="on"><button type="{0}"></button></em></td><td class="x-btn-mr"><i> </i></td></tr>',
+ '<tr><td class="x-btn-bl"><i> </i></td><td class="x-btn-bc"></td><td class="x-btn-br"><i> </i></td></tr>',
+ '</tbody></table>');
+ Ext.Button.buttonTemplate.compile();
+ }
+ this.template = Ext.Button.buttonTemplate;
+ }
+
+ var btn, targs = this.getTemplateArgs();
+
+ if(position){
+ btn = this.template.insertBefore(position, targs, true);
+ }else{
+ btn = this.template.append(ct, targs, true);
+ }
+
+ this.btnEl = btn.child(this.buttonSelector);
+ this.mon(this.btnEl, {
+ scope: this,
+ focus: this.onFocus,
+ blur: this.onBlur
+ });
+
+ this.initButtonEl(btn, this.btnEl);
+
+ Ext.ButtonToggleMgr.register(this);
+ },
+
+
+ initButtonEl : function(btn, btnEl){
+ this.el = btn;
+ this.setIcon(this.icon);
+ this.setText(this.text);
+ this.setIconClass(this.iconCls);
+ if(Ext.isDefined(this.tabIndex)){
+ btnEl.dom.tabIndex = this.tabIndex;
+ }
+ if(this.tooltip){
+ this.setTooltip(this.tooltip, true);
+ }
+
+ if(this.handleMouseEvents){
+ this.mon(btn, {
+ scope: this,
+ mouseover: this.onMouseOver,
+ mousedown: this.onMouseDown
+ });
+
+
+
+ }
+
+ if(this.menu){
+ this.mon(this.menu, {
+ scope: this,
+ show: this.onMenuShow,
+ hide: this.onMenuHide
+ });
+ }
+
+ if(this.repeat){
+ var repeater = new Ext.util.ClickRepeater(btn, Ext.isObject(this.repeat) ? this.repeat : {});
+ this.mon(repeater, 'click', this.onRepeatClick, this);
+ }else{
+ this.mon(btn, this.clickEvent, this.onClick, this);
+ }
+ },
+
+
+ afterRender : function(){
+ Ext.Button.superclass.afterRender.call(this);
+ this.useSetClass = true;
+ this.setButtonClass();
+ this.doc = Ext.getDoc();
+ this.doAutoWidth();
+ },
+
+
+ setIconClass : function(cls){
+ this.iconCls = cls;
+ if(this.el){
+ this.btnEl.dom.className = '';
+ this.btnEl.addClass(['x-btn-text', cls || '']);
+ this.setButtonClass();
+ }
+ return this;
+ },
+
+
+ setTooltip : function(tooltip, initial){
+ if(this.rendered){
+ if(!initial){
+ this.clearTip();
+ }
+ if(Ext.isObject(tooltip)){
+ Ext.QuickTips.register(Ext.apply({
+ target: this.btnEl.id
+ }, tooltip));
+ this.tooltip = tooltip;
+ }else{
+ this.btnEl.dom[this.tooltipType] = tooltip;
+ }
+ }else{
+ this.tooltip = tooltip;
+ }
+ return this;
+ },
+
+
+ clearTip : function(){
+ if(Ext.isObject(this.tooltip)){
+ Ext.QuickTips.unregister(this.btnEl);
+ }
+ },
+
+
+ beforeDestroy : function(){
+ if(this.rendered){
+ this.clearTip();
+ }
+ if(this.menu && this.destroyMenu !== false) {
+ Ext.destroy(this.btnEl, this.menu);
+ }
+ Ext.destroy(this.repeater);
+ },
+
+
+ onDestroy : function(){
+ if(this.rendered){
+ this.doc.un('mouseover', this.monitorMouseOver, this);
+ this.doc.un('mouseup', this.onMouseUp, this);
+ delete this.doc;
+ delete this.btnEl;
+ Ext.ButtonToggleMgr.unregister(this);
+ }
+ Ext.Button.superclass.onDestroy.call(this);
+ },
+
+
+ doAutoWidth : function(){
+ if(this.autoWidth !== false && this.el && this.text && this.width === undefined){
+ this.el.setWidth('auto');
+ if(Ext.isIE7 && Ext.isStrict){
+ var ib = this.btnEl;
+ if(ib && ib.getWidth() > 20){
+ ib.clip();
+ ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
+ }
+ }
+ if(this.minWidth){
+ if(this.el.getWidth() < this.minWidth){
+ this.el.setWidth(this.minWidth);
+ }
+ }
+ }
+ },
+
+
+ setHandler : function(handler, scope){
+ this.handler = handler;
+ this.scope = scope;
+ return this;
+ },
+
+
+ setText : function(text){
+ this.text = text;
+ if(this.el){
+ this.btnEl.update(text || ' ');
+ this.setButtonClass();
+ }
+ this.doAutoWidth();
+ return this;
+ },
+
+
+ setIcon : function(icon){
+ this.icon = icon;
+ if(this.el){
+ this.btnEl.setStyle('background-image', icon ? 'url(' + icon + ')' : '');
+ this.setButtonClass();
+ }
+ return this;
+ },
+
+
+ getText : function(){
+ return this.text;
+ },
+
+
+ toggle : function(state, suppressEvent){
+ state = state === undefined ? !this.pressed : !!state;
+ if(state != this.pressed){
+ if(this.rendered){
+ this.el[state ? 'addClass' : 'removeClass']('x-btn-pressed');
+ }
+ this.pressed = state;
+ if(!suppressEvent){
+ this.fireEvent('toggle', this, state);
+ if(this.toggleHandler){
+ this.toggleHandler.call(this.scope || this, this, state);
+ }
+ }
+ }
+ return this;
+ },
+
+
+ onDisable : function(){
+ this.onDisableChange(true);
+ },
+
+
+ onEnable : function(){
+ this.onDisableChange(false);
+ },
+
+ onDisableChange : function(disabled){
+ if(this.el){
+ if(!Ext.isIE6 || !this.text){
+ this.el[disabled ? 'addClass' : 'removeClass'](this.disabledClass);
+ }
+ this.el.dom.disabled = disabled;
+ }
+ this.disabled = disabled;
+ },
+
+
+ showMenu : function(){
+ if(this.rendered && this.menu){
+ if(this.tooltip){
+ Ext.QuickTips.getQuickTip().cancelShow(this.btnEl);
+ }
+ if(this.menu.isVisible()){
+ this.menu.hide();
+ }
+ this.menu.ownerCt = this;
+ this.menu.show(this.el, this.menuAlign);
+ }
+ return this;
+ },
+
+
+ hideMenu : function(){
+ if(this.hasVisibleMenu()){
+ this.menu.hide();
+ }
+ return this;
+ },
+
+
+ hasVisibleMenu : function(){
+ return this.menu && this.menu.ownerCt == this && this.menu.isVisible();
+ },
+
+
+ onRepeatClick : function(repeat, e){
+ this.onClick(e);
+ },
+
+
+ onClick : function(e){
+ if(e){
+ e.preventDefault();
+ }
+ if(e.button !== 0){
+ return;
+ }
+ if(!this.disabled){
+ this.doToggle();
+ if(this.menu && !this.hasVisibleMenu() && !this.ignoreNextClick){
+ this.showMenu();
+ }
+ this.fireEvent('click', this, e);
+ if(this.handler){
+
+ this.handler.call(this.scope || this, this, e);
+ }
+ }
+ },
+
+
+ doToggle: function(){
+ if (this.enableToggle && (this.allowDepress !== false || !this.pressed)) {
+ this.toggle();
+ }
+ },
+
+
+ isMenuTriggerOver : function(e, internal){
+ return this.menu && !internal;
+ },
+
+
+ isMenuTriggerOut : function(e, internal){
+ return this.menu && !internal;
+ },
+
+
+ onMouseOver : function(e){
+ if(!this.disabled){
+ var internal = e.within(this.el, true);
+ if(!internal){
+ this.el.addClass('x-btn-over');
+ if(!this.monitoringMouseOver){
+ this.doc.on('mouseover', this.monitorMouseOver, this);
+ this.monitoringMouseOver = true;
+ }
+ this.fireEvent('mouseover', this, e);
+ }
+ if(this.isMenuTriggerOver(e, internal)){
+ this.fireEvent('menutriggerover', this, this.menu, e);
+ }
+ }
+ },
+
+
+ monitorMouseOver : function(e){
+ if(e.target != this.el.dom && !e.within(this.el)){
+ if(this.monitoringMouseOver){
+ this.doc.un('mouseover', this.monitorMouseOver, this);
+ this.monitoringMouseOver = false;
+ }
+ this.onMouseOut(e);
+ }
+ },
+
+
+ onMouseOut : function(e){
+ var internal = e.within(this.el) && e.target != this.el.dom;
+ this.el.removeClass('x-btn-over');
+ this.fireEvent('mouseout', this, e);
+ if(this.isMenuTriggerOut(e, internal)){
+ this.fireEvent('menutriggerout', this, this.menu, e);
+ }
+ },
+
+ focus : function() {
+ this.btnEl.focus();
+ },
+
+ blur : function() {
+ this.btnEl.blur();
+ },
+
+
+ onFocus : function(e){
+ if(!this.disabled){
+ this.el.addClass('x-btn-focus');
+ }
+ },
+
+ onBlur : function(e){
+ this.el.removeClass('x-btn-focus');
+ },
+
+
+ getClickEl : function(e, isUp){
+ return this.el;
+ },
+
+
+ onMouseDown : function(e){
+ if(!this.disabled && e.button === 0){
+ this.getClickEl(e).addClass('x-btn-click');
+ this.doc.on('mouseup', this.onMouseUp, this);
+ }
+ },
+
+ onMouseUp : function(e){
+ if(e.button === 0){
+ this.getClickEl(e, true).removeClass('x-btn-click');
+ this.doc.un('mouseup', this.onMouseUp, this);
+ }
+ },
+
+ onMenuShow : function(e){
+ if(this.menu.ownerCt == this){
+ this.menu.ownerCt = this;
+ this.ignoreNextClick = 0;
+ this.el.addClass('x-btn-menu-active');
+ this.fireEvent('menushow', this, this.menu);
+ }
+ },
+
+ onMenuHide : function(e){
+ if(this.menu.ownerCt == this){
+ this.el.removeClass('x-btn-menu-active');
+ this.ignoreNextClick = this.restoreClick.defer(250, this);
+ this.fireEvent('menuhide', this, this.menu);
+ delete this.menu.ownerCt;
+ }
+ },
+
+
+ restoreClick : function(){
+ this.ignoreNextClick = 0;
+ }
+
+
+
+
+
+
+
+});
+Ext.reg('button', Ext.Button);
+
+
+Ext.ButtonToggleMgr = function(){
+ var groups = {};
+
+ function toggleGroup(btn, state){
+ if(state){
+ var g = groups[btn.toggleGroup];
+ for(var i = 0, l = g.length; i < l; i++){
+ if(g[i] != btn){
+ g[i].toggle(false);
+ }
+ }
+ }
+ }
+
+ return {
+ register : function(btn){
+ if(!btn.toggleGroup){
+ return;
+ }
+ var g = groups[btn.toggleGroup];
+ if(!g){
+ g = groups[btn.toggleGroup] = [];
+ }
+ g.push(btn);
+ btn.on('toggle', toggleGroup);
+ },
+
+ unregister : function(btn){
+ if(!btn.toggleGroup){
+ return;
+ }
+ var g = groups[btn.toggleGroup];
+ if(g){
+ g.remove(btn);
+ btn.un('toggle', toggleGroup);
+ }
+ },
+
+
+ getPressed : function(group){
+ var g = groups[group];
+ if(g){
+ for(var i = 0, len = g.length; i < len; i++){
+ if(g[i].pressed === true){
+ return g[i];
+ }
+ }
+ }
+ return null;
+ }
+ };
+}();
+
+Ext.SplitButton = Ext.extend(Ext.Button, {
+
+ arrowSelector : 'em',
+ split: true,
+
+
+ initComponent : function(){
+ Ext.SplitButton.superclass.initComponent.call(this);
+
+ this.addEvents("arrowclick");
+ },
+
+
+ onRender : function(){
+ Ext.SplitButton.superclass.onRender.apply(this, arguments);
+ if(this.arrowTooltip){
+ this.el.child(this.arrowSelector).dom[this.tooltipType] = this.arrowTooltip;
+ }
+ },
+
+
+ setArrowHandler : function(handler, scope){
+ this.arrowHandler = handler;
+ this.scope = scope;
+ },
+
+ getMenuClass : function(){
+ return 'x-btn-split' + (this.arrowAlign == 'bottom' ? '-bottom' : '');
+ },
+
+ isClickOnArrow : function(e){
+ if (this.arrowAlign != 'bottom') {
+ var visBtn = this.el.child('em.x-btn-split');
+ var right = visBtn.getRegion().right - visBtn.getPadding('r');
+ return e.getPageX() > right;
+ } else {
+ return e.getPageY() > this.btnEl.getRegion().bottom;
+ }
+ },
+
+
+ onClick : function(e, t){
+ e.preventDefault();
+ if(!this.disabled){
+ if(this.isClickOnArrow(e)){
+ if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
+ this.showMenu();
+ }
+ this.fireEvent("arrowclick", this, e);
+ if(this.arrowHandler){
+ this.arrowHandler.call(this.scope || this, this, e);
+ }
+ }else{
+ this.doToggle();
+ this.fireEvent("click", this, e);
+ if(this.handler){
+ this.handler.call(this.scope || this, this, e);
+ }
+ }
+ }
+ },
+
+
+ isMenuTriggerOver : function(e){
+ return this.menu && e.target.tagName == this.arrowSelector;
+ },
+
+
+ isMenuTriggerOut : function(e, internal){
+ return this.menu && e.target.tagName != this.arrowSelector;
+ }
+});
+
+Ext.reg('splitbutton', Ext.SplitButton);
+Ext.CycleButton = Ext.extend(Ext.SplitButton, {
+
+
+
+
+
+
+
+
+ getItemText : function(item){
+ if(item && this.showText === true){
+ var text = '';
+ if(this.prependText){
+ text += this.prependText;
+ }
+ text += item.text;
+ return text;
+ }
+ return undefined;
+ },
+
+
+ setActiveItem : function(item, suppressEvent){
+ if(!Ext.isObject(item)){
+ item = this.menu.getComponent(item);
+ }
+ if(item){
+ if(!this.rendered){
+ this.text = this.getItemText(item);
+ this.iconCls = item.iconCls;
+ }else{
+ var t = this.getItemText(item);
+ if(t){
+ this.setText(t);
+ }
+ this.setIconClass(item.iconCls);
+ }
+ this.activeItem = item;
+ if(!item.checked){
+ item.setChecked(true, false);
+ }
+ if(this.forceIcon){
+ this.setIconClass(this.forceIcon);
+ }
+ if(!suppressEvent){
+ this.fireEvent('change', this, item);
+ }
+ }
+ },
+
+
+ getActiveItem : function(){
+ return this.activeItem;
+ },
+
+
+ initComponent : function(){
+ this.addEvents(
+
+ "change"
+ );
+
+ if(this.changeHandler){
+ this.on('change', this.changeHandler, this.scope||this);
+ delete this.changeHandler;
+ }
+
+ this.itemCount = this.items.length;
+
+ this.menu = {cls:'x-cycle-menu', items:[]};
+ var checked = 0;
+ Ext.each(this.items, function(item, i){
+ Ext.apply(item, {
+ group: item.group || this.id,
+ itemIndex: i,
+ checkHandler: this.checkHandler,
+ scope: this,
+ checked: item.checked || false
+ });
+ this.menu.items.push(item);
+ if(item.checked){
+ checked = i;
+ }
+ }, this);
+ Ext.CycleButton.superclass.initComponent.call(this);
+ this.on('click', this.toggleSelected, this);
+ this.setActiveItem(checked, true);
+ },
+
+
+ checkHandler : function(item, pressed){
+ if(pressed){
+ this.setActiveItem(item);
+ }
+ },
+
+
+ toggleSelected : function(){
+ var m = this.menu;
+ m.render();
+
+ if(!m.hasLayout){
+ m.doLayout();
+ }
+
+ var nextIdx, checkItem;
+ for (var i = 1; i < this.itemCount; i++) {
+ nextIdx = (this.activeItem.itemIndex + i) % this.itemCount;
+
+ checkItem = m.items.itemAt(nextIdx);
+
+ if (!checkItem.disabled) {
+ checkItem.setChecked(true);
+ break;
+ }
+ }
+ }
+});
+Ext.reg('cycle', Ext.CycleButton);
+Ext.Toolbar = function(config){
+ if(Ext.isArray(config)){
+ config = {items: config, layout: 'toolbar'};
+ } else {
+ config = Ext.apply({
+ layout: 'toolbar'
+ }, config);
+ if(config.buttons) {
+ config.items = config.buttons;
+ }
+ }
+ Ext.Toolbar.superclass.constructor.call(this, config);
+};
+
+(function(){
+
+var T = Ext.Toolbar;
+
+Ext.extend(T, Ext.Container, {
+
+ defaultType: 'button',
+
+
+
+ enableOverflow : false,
+
+
+
+
+ trackMenus : true,
+ internalDefaults: {removeMode: 'container', hideParent: true},
+ toolbarCls: 'x-toolbar',
+
+ initComponent : function(){
+ T.superclass.initComponent.call(this);
+
+
+ this.addEvents('overflowchange');
+ },
+
+
+ onRender : function(ct, position){
+ if(!this.el){
+ if(!this.autoCreate){
+ this.autoCreate = {
+ cls: this.toolbarCls + ' x-small-editor'
+ };
+ }
+ this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
+ Ext.Toolbar.superclass.onRender.apply(this, arguments);
+ }
+ },
+
+
+
+
+ lookupComponent : function(c){
+ if(Ext.isString(c)){
+ if(c == '-'){
+ c = new T.Separator();
+ }else if(c == ' '){
+ c = new T.Spacer();
+ }else if(c == '->'){
+ c = new T.Fill();
+ }else{
+ c = new T.TextItem(c);
+ }
+ this.applyDefaults(c);
+ }else{
+ if(c.isFormField || c.render){
+ c = this.createComponent(c);
+ }else if(c.tag){
+ c = new T.Item({autoEl: c});
+ }else if(c.tagName){
+ c = new T.Item({el:c});
+ }else if(Ext.isObject(c)){
+ c = c.xtype ? this.createComponent(c) : this.constructButton(c);
+ }
+ }
+ return c;
+ },
+
+
+ applyDefaults : function(c){
+ if(!Ext.isString(c)){
+ c = Ext.Toolbar.superclass.applyDefaults.call(this, c);
+ var d = this.internalDefaults;
+ if(c.events){
+ Ext.applyIf(c.initialConfig, d);
+ Ext.apply(c, d);
+ }else{
+ Ext.applyIf(c, d);
+ }
+ }
+ return c;
+ },
+
+
+ addSeparator : function(){
+ return this.add(new T.Separator());
+ },
+
+
+ addSpacer : function(){
+ return this.add(new T.Spacer());
+ },
+
+
+ addFill : function(){
+ this.add(new T.Fill());
+ },
+
+
+ addElement : function(el){
+ return this.addItem(new T.Item({el:el}));
+ },
+
+
+ addItem : function(item){
+ return this.add.apply(this, arguments);
+ },
+
+
+ addButton : function(config){
+ if(Ext.isArray(config)){
+ var buttons = [];
+ for(var i = 0, len = config.length; i < len; i++) {
+ buttons.push(this.addButton(config[i]));
+ }
+ return buttons;
+ }
+ return this.add(this.constructButton(config));
+ },
+
+
+ addText : function(text){
+ return this.addItem(new T.TextItem(text));
+ },
+
+
+ addDom : function(config){
+ return this.add(new T.Item({autoEl: config}));
+ },
+
+
+ addField : function(field){
+ return this.add(field);
+ },
+
+
+ insertButton : function(index, item){
+ if(Ext.isArray(item)){
+ var buttons = [];
+ for(var i = 0, len = item.length; i < len; i++) {
+ buttons.push(this.insertButton(index + i, item[i]));
+ }
+ return buttons;
+ }
+ return Ext.Toolbar.superclass.insert.call(this, index, item);
+ },
+
+
+ trackMenu : function(item, remove){
+ if(this.trackMenus && item.menu){
+ var method = remove ? 'mun' : 'mon';
+ this[method](item, 'menutriggerover', this.onButtonTriggerOver, this);
+ this[method](item, 'menushow', this.onButtonMenuShow, this);
+ this[method](item, 'menuhide', this.onButtonMenuHide, this);
+ }
+ },
+
+
+ constructButton : function(item){
+ var b = item.events ? item : this.createComponent(item, item.split ? 'splitbutton' : this.defaultType);
+ return b;
+ },
+
+
+ onAdd : function(c){
+ Ext.Toolbar.superclass.onAdd.call(this);
+ this.trackMenu(c);
+ if(this.disabled){
+ c.disable();
+ }
+ },
+
+
+ onRemove : function(c){
+ Ext.Toolbar.superclass.onRemove.call(this);
+ if (c == this.activeMenuBtn) {
+ delete this.activeMenuBtn;
+ }
+ this.trackMenu(c, true);
+ },
+
+
+ onDisable : function(){
+ this.items.each(function(item){
+ if(item.disable){
+ item.disable();
+ }
+ });
+ },
+
+
+ onEnable : function(){
+ this.items.each(function(item){
+ if(item.enable){
+ item.enable();
+ }
+ });
+ },
+
+
+ onButtonTriggerOver : function(btn){
+ if(this.activeMenuBtn && this.activeMenuBtn != btn){
+ this.activeMenuBtn.hideMenu();
+ btn.showMenu();
+ this.activeMenuBtn = btn;
+ }
+ },
+
+
+ onButtonMenuShow : function(btn){
+ this.activeMenuBtn = btn;
+ },
+
+
+ onButtonMenuHide : function(btn){
+ delete this.activeMenuBtn;
+ }
+});
+Ext.reg('toolbar', Ext.Toolbar);
+
+
+T.Item = Ext.extend(Ext.BoxComponent, {
+ hideParent: true,
+ enable:Ext.emptyFn,
+ disable:Ext.emptyFn,
+ focus:Ext.emptyFn
+
+});
+Ext.reg('tbitem', T.Item);
+
+
+T.Separator = Ext.extend(T.Item, {
+ onRender : function(ct, position){
+ this.el = ct.createChild({tag:'span', cls:'xtb-sep'}, position);
+ }
+});
+Ext.reg('tbseparator', T.Separator);
+
+
+T.Spacer = Ext.extend(T.Item, {
+
+
+ onRender : function(ct, position){
+ this.el = ct.createChild({tag:'div', cls:'xtb-spacer', style: this.width?'width:'+this.width+'px':''}, position);
+ }
+});
+Ext.reg('tbspacer', T.Spacer);
+
+
+T.Fill = Ext.extend(T.Item, {
+
+ render : Ext.emptyFn,
+ isFill : true
+});
+Ext.reg('tbfill', T.Fill);
+
+
+T.TextItem = Ext.extend(T.Item, {
+
+
+ constructor: function(config){
+ T.TextItem.superclass.constructor.call(this, Ext.isString(config) ? {text: config} : config);
+ },
+
+
+ onRender : function(ct, position) {
+ this.autoEl = {cls: 'xtb-text', html: this.text || ''};
+ T.TextItem.superclass.onRender.call(this, ct, position);
+ },
+
+
+ setText : function(t) {
+ if(this.rendered){
+ this.el.update(t);
+ }else{
+ this.text = t;
+ }
+ }
+});
+Ext.reg('tbtext', T.TextItem);
+
+
+T.Button = Ext.extend(Ext.Button, {});
+T.SplitButton = Ext.extend(Ext.SplitButton, {});
+Ext.reg('tbbutton', T.Button);
+Ext.reg('tbsplit', T.SplitButton);
+
+})();
+
+Ext.ButtonGroup = Ext.extend(Ext.Panel, {
+
+
+ baseCls: 'x-btn-group',
+
+ layout:'table',
+ defaultType: 'button',
+
+ frame: true,
+ internalDefaults: {removeMode: 'container', hideParent: true},
+
+ initComponent : function(){
+ this.layoutConfig = this.layoutConfig || {};
+ Ext.applyIf(this.layoutConfig, {
+ columns : this.columns
+ });
+ if(!this.title){
+ this.addClass('x-btn-group-notitle');
+ }
+ this.on('afterlayout', this.onAfterLayout, this);
+ Ext.ButtonGroup.superclass.initComponent.call(this);
+ },
+
+ applyDefaults : function(c){
+ c = Ext.ButtonGroup.superclass.applyDefaults.call(this, c);
+ var d = this.internalDefaults;
+ if(c.events){
+ Ext.applyIf(c.initialConfig, d);
+ Ext.apply(c, d);
+ }else{
+ Ext.applyIf(c, d);
+ }
+ return c;
+ },
+
+ onAfterLayout : function(){
+ var bodyWidth = this.body.getFrameWidth('lr') + this.body.dom.firstChild.offsetWidth;
+ this.body.setWidth(bodyWidth);
+ this.el.setWidth(bodyWidth + this.getFrameWidth());
+ }
+
+});
+
+Ext.reg('buttongroup', Ext.ButtonGroup);
+
+(function() {
+
+var T = Ext.Toolbar;
+
+Ext.PagingToolbar = Ext.extend(Ext.Toolbar, {
+
+
+
+ pageSize : 20,
+
+
+ displayMsg : 'Displaying {0} - {1} of {2}',
+
+ emptyMsg : 'No data to display',
+
+ beforePageText : 'Page',
+
+ afterPageText : 'of {0}',
+
+ firstText : 'First Page',
+
+ prevText : 'Previous Page',
+
+ nextText : 'Next Page',
+
+ lastText : 'Last Page',
+
+ refreshText : 'Refresh',
+
+
+
+
+
+
+
+ initComponent : function(){
+ var pagingItems = [this.first = new T.Button({
+ tooltip: this.firstText,
+ overflowText: this.firstText,
+ iconCls: 'x-tbar-page-first',
+ disabled: true,
+ handler: this.moveFirst,
+ scope: this
+ }), this.prev = new T.Button({
+ tooltip: this.prevText,
+ overflowText: this.prevText,
+ iconCls: 'x-tbar-page-prev',
+ disabled: true,
+ handler: this.movePrevious,
+ scope: this
+ }), '-', this.beforePageText,
+ this.inputItem = new Ext.form.NumberField({
+ cls: 'x-tbar-page-number',
+ allowDecimals: false,
+ allowNegative: false,
+ enableKeyEvents: true,
+ selectOnFocus: true,
+ submitValue: false,
+ listeners: {
+ scope: this,
+ keydown: this.onPagingKeyDown,
+ blur: this.onPagingBlur
+ }
+ }), this.afterTextItem = new T.TextItem({
+ text: String.format(this.afterPageText, 1)
+ }), '-', this.next = new T.Button({
+ tooltip: this.nextText,
+ overflowText: this.nextText,
+ iconCls: 'x-tbar-page-next',
+ disabled: true,
+ handler: this.moveNext,
+ scope: this
+ }), this.last = new T.Button({
+ tooltip: this.lastText,
+ overflowText: this.lastText,
+ iconCls: 'x-tbar-page-last',
+ disabled: true,
+ handler: this.moveLast,
+ scope: this
+ }), '-', this.refresh = new T.Button({
+ tooltip: this.refreshText,
+ overflowText: this.refreshText,
+ iconCls: 'x-tbar-loading',
+ handler: this.doRefresh,
+ scope: this
+ })];
+
+
+ var userItems = this.items || this.buttons || [];
+ if (this.prependButtons) {
+ this.items = userItems.concat(pagingItems);
+ }else{
+ this.items = pagingItems.concat(userItems);
+ }
+ delete this.buttons;
+ if(this.displayInfo){
+ this.items.push('->');
+ this.items.push(this.displayItem = new T.TextItem({}));
+ }
+ Ext.PagingToolbar.superclass.initComponent.call(this);
+ this.addEvents(
+
+ 'change',
+
+ 'beforechange'
+ );
+ this.on('afterlayout', this.onFirstLayout, this, {single: true});
+ this.cursor = 0;
+ this.bindStore(this.store, true);
+ },
+
+
+ onFirstLayout : function(){
+ if(this.dsLoaded){
+ this.onLoad.apply(this, this.dsLoaded);
+ }
+ },
+
+
+ updateInfo : function(){
+ if(this.displayItem){
+ var count = this.store.getCount();
+ var msg = count == 0 ?
+ this.emptyMsg :
+ String.format(
+ this.displayMsg,
+ this.cursor+1, this.cursor+count, this.store.getTotalCount()
+ );
+ this.displayItem.setText(msg);
+ }
+ },
+
+
+ onLoad : function(store, r, o){
+ if(!this.rendered){
+ this.dsLoaded = [store, r, o];
+ return;
+ }
+ var p = this.getParams();
+ this.cursor = (o.params && o.params[p.start]) ? o.params[p.start] : 0;
+ var d = this.getPageData(), ap = d.activePage, ps = d.pages;
+
+ this.afterTextItem.setText(String.format(this.afterPageText, d.pages));
+ this.inputItem.setValue(ap);
+ this.first.setDisabled(ap == 1);
+ this.prev.setDisabled(ap == 1);
+ this.next.setDisabled(ap == ps);
+ this.last.setDisabled(ap == ps);
+ this.refresh.enable();
+ this.updateInfo();
+ this.fireEvent('change', this, d);
+ },
+
+
+ getPageData : function(){
+ var total = this.store.getTotalCount();
+ return {
+ total : total,
+ activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
+ pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
+ };
+ },
+
+
+ changePage : function(page){
+ this.doLoad(((page-1) * this.pageSize).constrain(0, this.store.getTotalCount()));
+ },
+
+
+ onLoadError : function(){
+ if(!this.rendered){
+ return;
+ }
+ this.refresh.enable();
+ },
+
+
+ readPage : function(d){
+ var v = this.inputItem.getValue(), pageNum;
+ if (!v || isNaN(pageNum = parseInt(v, 10))) {
+ this.inputItem.setValue(d.activePage);
+ return false;
+ }
+ return pageNum;
+ },
+
+ onPagingFocus : function(){
+ this.inputItem.select();
+ },
+
+
+ onPagingBlur : function(e){
+ this.inputItem.setValue(this.getPageData().activePage);
+ },
+
+
+ onPagingKeyDown : function(field, e){
+ var k = e.getKey(), d = this.getPageData(), pageNum;
+ if (k == e.RETURN) {
+ e.stopEvent();
+ pageNum = this.readPage(d);
+ if(pageNum !== false){
+ pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
+ this.doLoad(pageNum * this.pageSize);
+ }
+ }else if (k == e.HOME || k == e.END){
+ e.stopEvent();
+ pageNum = k == e.HOME ? 1 : d.pages;
+ field.setValue(pageNum);
+ }else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN){
+ e.stopEvent();
+ if((pageNum = this.readPage(d))){
+ var increment = e.shiftKey ? 10 : 1;
+ if(k == e.DOWN || k == e.PAGEDOWN){
+ increment *= -1;
+ }
+ pageNum += increment;
+ if(pageNum >= 1 & pageNum <= d.pages){
+ field.setValue(pageNum);
+ }
+ }
+ }
+ },
+
+
+ getParams : function(){
+
+ return this.paramNames || this.store.paramNames;
+ },
+
+
+ beforeLoad : function(){
+ if(this.rendered && this.refresh){
+ this.refresh.disable();
+ }
+ },
+
+
+ doLoad : function(start){
+ var o = {}, pn = this.getParams();
+ o[pn.start] = start;
+ o[pn.limit] = this.pageSize;
+ if(this.fireEvent('beforechange', this, o) !== false){
+ this.store.load({params:o});
+ }
+ },
+
+
+ moveFirst : function(){
+ this.doLoad(0);
+ },
+
+
+ movePrevious : function(){
+ this.doLoad(Math.max(0, this.cursor-this.pageSize));
+ },
+
+
+ moveNext : function(){
+ this.doLoad(this.cursor+this.pageSize);
+ },
+
+
+ moveLast : function(){
+ var total = this.store.getTotalCount(),
+ extra = total % this.pageSize;
+
+ this.doLoad(extra ? (total - extra) : total - this.pageSize);
+ },
+
+
+ doRefresh : function(){
+ this.doLoad(this.cursor);
+ },
+
+
+ bindStore : function(store, initial){
+ var doLoad;
+ if(!initial && this.store){
+ if(store !== this.store && this.store.autoDestroy){
+ this.store.destroy();
+ }else{
+ this.store.un('beforeload', this.beforeLoad, this);
+ this.store.un('load', this.onLoad, this);
+ this.store.un('exception', this.onLoadError, this);
+ }
+ if(!store){
+ this.store = null;
+ }
+ }
+ if(store){
+ store = Ext.StoreMgr.lookup(store);
+ store.on({
+ scope: this,
+ beforeload: this.beforeLoad,
+ load: this.onLoad,
+ exception: this.onLoadError
+ });
+ doLoad = true;
+ }
+ this.store = store;
+ if(doLoad){
+ this.onLoad(store, null, {});
+ }
+ },
+
+
+ unbind : function(store){
+ this.bindStore(null);
+ },
+
+
+ bind : function(store){
+ this.bindStore(store);
+ },
+
+
+ onDestroy : function(){
+ this.bindStore(null);
+ Ext.PagingToolbar.superclass.onDestroy.call(this);
+ }
+});
+
+})();
+Ext.reg('paging', Ext.PagingToolbar);
+Ext.History = (function () {
+ var iframe, hiddenField;
+ var ready = false;
+ var currentToken;
+
+ function getHash() {
+ var href = location.href, i = href.indexOf("#");
+ return i >= 0 ? href.substr(i + 1) : null;
+ }
+
+ function doSave() {
+ hiddenField.value = currentToken;
+ }
+
+ function handleStateChange(token) {
+ currentToken = token;
+ Ext.History.fireEvent('change', token);
+ }
+
+ function updateIFrame (token) {
+ var html = ['<html><body><div id="state">',Ext.util.Format.htmlEncode(token),'</div></body></html>'].join('');
+ try {
+ var doc = iframe.contentWindow.document;
+ doc.open();
+ doc.write(html);
+ doc.close();
+ return true;
+ } catch (e) {
+ return false;
+ }
+ }
+
+ function checkIFrame() {
+ if (!iframe.contentWindow || !iframe.contentWindow.document) {
+ setTimeout(checkIFrame, 10);
+ return;
+ }
+
+ var doc = iframe.contentWindow.document;
+ var elem = doc.getElementById("state");
+ var token = elem ? elem.innerText : null;
+
+ var hash = getHash();
+
+ setInterval(function () {
+
+ doc = iframe.contentWindow.document;
+ elem = doc.getElementById("state");
+
+ var newtoken = elem ? elem.innerText : null;
+
+ var newHash = getHash();
+
+ if (newtoken !== token) {
+ token = newtoken;
+ handleStateChange(token);
+ top.location.hash = token;
+ hash = token;
+ doSave();
+ } else if (newHash !== hash) {
+ hash = newHash;
+ updateIFrame(newHash);
+ }
+
+ }, 50);
+
+ ready = true;
+
+ Ext.History.fireEvent('ready', Ext.History);
+ }
+
+ function startUp() {
+ currentToken = hiddenField.value ? hiddenField.value : getHash();
+
+ if (Ext.isIE) {
+ checkIFrame();
+ } else {
+ var hash = getHash();
+ setInterval(function () {
+ var newHash = getHash();
+ if (newHash !== hash) {
+ hash = newHash;
+ handleStateChange(hash);
+ doSave();
+ }
+ }, 50);
+ ready = true;
+ Ext.History.fireEvent('ready', Ext.History);
+ }
+ }
+
+ return {
+
+ fieldId: 'x-history-field',
+
+ iframeId: 'x-history-frame',
+
+ events:{},
+
+
+ init: function (onReady, scope) {
+ if(ready) {
+ Ext.callback(onReady, scope, [this]);
+ return;
+ }
+ if(!Ext.isReady){
+ Ext.onReady(function(){
+ Ext.History.init(onReady, scope);
+ });
+ return;
+ }
+ hiddenField = Ext.getDom(Ext.History.fieldId);
+ if (Ext.isIE) {
+ iframe = Ext.getDom(Ext.History.iframeId);
+ }
+ this.addEvents(
+
+ 'ready',
+
+ 'change'
+ );
+ if(onReady){
+ this.on('ready', onReady, scope, {single:true});
+ }
+ startUp();
+ },
+
+
+ add: function (token, preventDup) {
+ if(preventDup !== false){
+ if(this.getToken() == token){
+ return true;
+ }
+ }
+ if (Ext.isIE) {
+ return updateIFrame(token);
+ } else {
+ top.location.hash = token;
+ return true;
+ }
+ },
+
+
+ back: function(){
+ history.go(-1);
+ },
+
+
+ forward: function(){
+ history.go(1);
+ },
+
+
+ getToken: function() {
+ return ready ? currentToken : getHash();
+ }
+ };
+})();
+Ext.apply(Ext.History, new Ext.util.Observable());
+Ext.Tip = Ext.extend(Ext.Panel, {
+
+
+
+ minWidth : 40,
+
+ maxWidth : 300,
+
+ shadow : "sides",
+
+ defaultAlign : "tl-bl?",
+ autoRender: true,
+ quickShowInterval : 250,
+
+
+ frame:true,
+ hidden:true,
+ baseCls: 'x-tip',
+ floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
+ autoHeight:true,
+
+ closeAction: 'hide',
+
+
+ initComponent : function(){
+ Ext.Tip.superclass.initComponent.call(this);
+ if(this.closable && !this.title){
+ this.elements += ',header';
+ }
+ },
+
+
+ afterRender : function(){
+ Ext.Tip.superclass.afterRender.call(this);
+ if(this.closable){
+ this.addTool({
+ id: 'close',
+ handler: this[this.closeAction],
+ scope: this
+ });
+ }
+ },
+
+
+ showAt : function(xy){
+ Ext.Tip.superclass.show.call(this);
+ if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
+ this.doAutoWidth();
+ }
+ if(this.constrainPosition){
+ xy = this.el.adjustForConstraints(xy);
+ }
+ this.setPagePosition(xy[0], xy[1]);
+ },
+
+
+ doAutoWidth : function(adjust){
+ adjust = adjust || 0;
+ var bw = this.body.getTextWidth();
+ if(this.title){
+ bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
+ }
+ bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr") + adjust;
+ this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
+
+
+ if(Ext.isIE7 && !this.repainted){
+ this.el.repaint();
+ this.repainted = true;
+ }
+ },
+
+
+ showBy : function(el, pos){
+ if(!this.rendered){
+ this.render(Ext.getBody());
+ }
+ this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
+ },
+
+ initDraggable : function(){
+ this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
+ this.header.addClass('x-tip-draggable');
+ }
+});
+
+Ext.reg('tip', Ext.Tip);
+
+
+Ext.Tip.DD = function(tip, config){
+ Ext.apply(this, config);
+ this.tip = tip;
+ Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
+ this.setHandleElId(tip.header.id);
+ this.scroll = false;
+};
+
+Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
+ moveOnly:true,
+ scroll:false,
+ headerOffsets:[100, 25],
+ startDrag : function(){
+ this.tip.el.disableShadow();
+ },
+ endDrag : function(e){
+ this.tip.el.enableShadow(true);
+ }
+});
+Ext.ToolTip = Ext.extend(Ext.Tip, {
+
+
+
+
+ showDelay : 500,
+
+ hideDelay : 200,
+
+ dismissDelay : 5000,
+
+
+ trackMouse : false,
+
+ anchorToTarget : true,
+
+ anchorOffset : 0,
+
+
+
+ targetCounter : 0,
+
+ constrainPosition : false,
+
+
+ initComponent : function(){
+ Ext.ToolTip.superclass.initComponent.call(this);
+ this.lastActive = new Date();
+ this.initTarget(this.target);
+ this.origAnchor = this.anchor;
+ },
+
+
+ onRender : function(ct, position){
+ Ext.ToolTip.superclass.onRender.call(this, ct, position);
+ this.anchorCls = 'x-tip-anchor-' + this.getAnchorPosition();
+ this.anchorEl = this.el.createChild({
+ cls: 'x-tip-anchor ' + this.anchorCls
+ });
+ },
+
+
+ afterRender : function(){
+ Ext.ToolTip.superclass.afterRender.call(this);
+ this.anchorEl.setStyle('z-index', this.el.getZIndex() + 1).setVisibilityMode(Ext.Element.DISPLAY);
+ },
+
+
+ initTarget : function(target){
+ var t;
+ if((t = Ext.get(target))){
+ if(this.target){
+ var tg = Ext.get(this.target);
+ this.mun(tg, 'mouseover', this.onTargetOver, this);
+ this.mun(tg, 'mouseout', this.onTargetOut, this);
+ this.mun(tg, 'mousemove', this.onMouseMove, this);
+ }
+ this.mon(t, {
+ mouseover: this.onTargetOver,
+ mouseout: this.onTargetOut,
+ mousemove: this.onMouseMove,
+ scope: this
+ });
+ this.target = t;
+ }
+ if(this.anchor){
+ this.anchorTarget = this.target;
+ }
+ },
+
+
+ onMouseMove : function(e){
+ var t = this.delegate ? e.getTarget(this.delegate) : this.triggerElement = true;
+ if (t) {
+ this.targetXY = e.getXY();
+ if (t === this.triggerElement) {
+ if(!this.hidden && this.trackMouse){
+ this.setPagePosition(this.getTargetXY());
+ }
+ } else {
+ this.hide();
+ this.lastActive = new Date(0);
+ this.onTargetOver(e);
+ }
+ } else if (!this.closable && this.isVisible()) {
+ this.hide();
+ }
+ },
+
+
+ getTargetXY : function(){
+ if(this.delegate){
+ this.anchorTarget = this.triggerElement;
+ }
+ if(this.anchor){
+ this.targetCounter++;
+ var offsets = this.getOffsets(),
+ xy = (this.anchorToTarget && !this.trackMouse) ? this.el.getAlignToXY(this.anchorTarget, this.getAnchorAlign()) : this.targetXY,
+ dw = Ext.lib.Dom.getViewWidth() - 5,
+ dh = Ext.lib.Dom.getViewHeight() - 5,
+ de = document.documentElement,
+ bd = document.body,
+ scrollX = (de.scrollLeft || bd.scrollLeft || 0) + 5,
+ scrollY = (de.scrollTop || bd.scrollTop || 0) + 5,
+ axy = [xy[0] + offsets[0], xy[1] + offsets[1]],
+ sz = this.getSize();
+
+ this.anchorEl.removeClass(this.anchorCls);
+
+ if(this.targetCounter < 2){
+ if(axy[0] < scrollX){
+ if(this.anchorToTarget){
+ this.defaultAlign = 'l-r';
+ if(this.mouseOffset){this.mouseOffset[0] *= -1;}
+ }
+ this.anchor = 'left';
+ return this.getTargetXY();
+ }
+ if(axy[0]+sz.width > dw){
+ if(this.anchorToTarget){
+ this.defaultAlign = 'r-l';
+ if(this.mouseOffset){this.mouseOffset[0] *= -1;}
+ }
+ this.anchor = 'right';
+ return this.getTargetXY();
+ }
+ if(axy[1] < scrollY){
+ if(this.anchorToTarget){
+ this.defaultAlign = 't-b';
+ if(this.mouseOffset){this.mouseOffset[1] *= -1;}
+ }
+ this.anchor = 'top';
+ return this.getTargetXY();
+ }
+ if(axy[1]+sz.height > dh){
+ if(this.anchorToTarget){
+ this.defaultAlign = 'b-t';
+ if(this.mouseOffset){this.mouseOffset[1] *= -1;}
+ }
+ this.anchor = 'bottom';
+ return this.getTargetXY();
+ }
+ }
+
+ this.anchorCls = 'x-tip-anchor-'+this.getAnchorPosition();
+ this.anchorEl.addClass(this.anchorCls);
+ this.targetCounter = 0;
+ return axy;
+ }else{
+ var mouseOffset = this.getMouseOffset();
+ return [this.targetXY[0]+mouseOffset[0], this.targetXY[1]+mouseOffset[1]];
+ }
+ },
+
+ getMouseOffset : function(){
+ var offset = this.anchor ? [0,0] : [15,18];
+ if(this.mouseOffset){
+ offset[0] += this.mouseOffset[0];
+ offset[1] += this.mouseOffset[1];
+ }
+ return offset;
+ },
+
+
+ getAnchorPosition : function(){
+ if(this.anchor){
+ this.tipAnchor = this.anchor.charAt(0);
+ }else{
+ var m = this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);
+ if(!m){
+ throw 'AnchorTip.defaultAlign is invalid';
+ }
+ this.tipAnchor = m[1].charAt(0);
+ }
+
+ switch(this.tipAnchor){
+ case 't': return 'top';
+ case 'b': return 'bottom';
+ case 'r': return 'right';
+ }
+ return 'left';
+ },
+
+
+ getAnchorAlign : function(){
+ switch(this.anchor){
+ case 'top' : return 'tl-bl';
+ case 'left' : return 'tl-tr';
+ case 'right': return 'tr-tl';
+ default : return 'bl-tl';
+ }
+ },
+
+
+ getOffsets : function(){
+ var offsets,
+ ap = this.getAnchorPosition().charAt(0);
+ if(this.anchorToTarget && !this.trackMouse){
+ switch(ap){
+ case 't':
+ offsets = [0, 9];
+ break;
+ case 'b':
+ offsets = [0, -13];
+ break;
+ case 'r':
+ offsets = [-13, 0];
+ break;
+ default:
+ offsets = [9, 0];
+ break;
+ }
+ }else{
+ switch(ap){
+ case 't':
+ offsets = [-15-this.anchorOffset, 30];
+ break;
+ case 'b':
+ offsets = [-19-this.anchorOffset, -13-this.el.dom.offsetHeight];
+ break;
+ case 'r':
+ offsets = [-15-this.el.dom.offsetWidth, -13-this.anchorOffset];
+ break;
+ default:
+ offsets = [25, -13-this.anchorOffset];
+ break;
+ }
+ }
+ var mouseOffset = this.getMouseOffset();
+ offsets[0] += mouseOffset[0];
+ offsets[1] += mouseOffset[1];
+
+ return offsets;
+ },
+
+
+ onTargetOver : function(e){
+ if(this.disabled || e.within(this.target.dom, true)){
+ return;
+ }
+ var t = e.getTarget(this.delegate);
+ if (t) {
+ this.triggerElement = t;
+ this.clearTimer('hide');
+ this.targetXY = e.getXY();
+ this.delayShow();
+ }
+ },
+
+
+ delayShow : function(){
+ if(this.hidden && !this.showTimer){
+ if(this.lastActive.getElapsed() < this.quickShowInterval){
+ this.show();
+ }else{
+ this.showTimer = this.show.defer(this.showDelay, this);
+ }
+ }else if(!this.hidden && this.autoHide !== false){
+ this.show();
+ }
+ },
+
+
+ onTargetOut : function(e){
+ if(this.disabled || e.within(this.target.dom, true)){
+ return;
+ }
+ this.clearTimer('show');
+ if(this.autoHide !== false){
+ this.delayHide();
+ }
+ },
+
+
+ delayHide : function(){
+ if(!this.hidden && !this.hideTimer){
+ this.hideTimer = this.hide.defer(this.hideDelay, this);
+ }
+ },
+
+
+ hide: function(){
+ this.clearTimer('dismiss');
+ this.lastActive = new Date();
+ if(this.anchorEl){
+ this.anchorEl.hide();
+ }
+ Ext.ToolTip.superclass.hide.call(this);
+ delete this.triggerElement;
+ },
+
+
+ show : function(){
+ if(this.anchor){
+
+
+ this.showAt([-1000,-1000]);
+ this.origConstrainPosition = this.constrainPosition;
+ this.constrainPosition = false;
+ this.anchor = this.origAnchor;
+ }
+ this.showAt(this.getTargetXY());
+
+ if(this.anchor){
+ this.anchorEl.show();
+ this.syncAnchor();
+ this.constrainPosition = this.origConstrainPosition;
+ }else{
+ this.anchorEl.hide();
+ }
+ },
+
+
+ showAt : function(xy){
+ this.lastActive = new Date();
+ this.clearTimers();
+ Ext.ToolTip.superclass.showAt.call(this, xy);
+ if(this.dismissDelay && this.autoHide !== false){
+ this.dismissTimer = this.hide.defer(this.dismissDelay, this);
+ }
+ if(this.anchor && !this.anchorEl.isVisible()){
+ this.syncAnchor();
+ this.anchorEl.show();
+ }else{
+ this.anchorEl.hide();
+ }
+ },
+
+
+ syncAnchor : function(){
+ var anchorPos, targetPos, offset;
+ switch(this.tipAnchor.charAt(0)){
+ case 't':
+ anchorPos = 'b';
+ targetPos = 'tl';
+ offset = [20+this.anchorOffset, 2];
+ break;
+ case 'r':
+ anchorPos = 'l';
+ targetPos = 'tr';
+ offset = [-2, 11+this.anchorOffset];
+ break;
+ case 'b':
+ anchorPos = 't';
+ targetPos = 'bl';
+ offset = [20+this.anchorOffset, -2];
+ break;
+ default:
+ anchorPos = 'r';
+ targetPos = 'tl';
+ offset = [2, 11+this.anchorOffset];
+ break;
+ }
+ this.anchorEl.alignTo(this.el, anchorPos+'-'+targetPos, offset);
+ },
+
+
+ setPagePosition : function(x, y){
+ Ext.ToolTip.superclass.setPagePosition.call(this, x, y);
+ if(this.anchor){
+ this.syncAnchor();
+ }
+ },
+
+
+ clearTimer : function(name){
+ name = name + 'Timer';
+ clearTimeout(this[name]);
+ delete this[name];
+ },
+
+
+ clearTimers : function(){
+ this.clearTimer('show');
+ this.clearTimer('dismiss');
+ this.clearTimer('hide');
+ },
+
+
+ onShow : function(){
+ Ext.ToolTip.superclass.onShow.call(this);
+ Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
+ },
+
+
+ onHide : function(){
+ Ext.ToolTip.superclass.onHide.call(this);
+ Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
+ },
+
+
+ onDocMouseDown : function(e){
+ if(this.autoHide !== true && !this.closable && !e.within(this.el.dom)){
+ this.disable();
+ this.doEnable.defer(100, this);
+ }
+ },
+
+
+ doEnable : function(){
+ if(!this.isDestroyed){
+ this.enable();
+ }
+ },
+
+
+ onDisable : function(){
+ this.clearTimers();
+ this.hide();
+ },
+
+
+ adjustPosition : function(x, y){
+ if(this.contstrainPosition){
+ var ay = this.targetXY[1], h = this.getSize().height;
+ if(y <= ay && (y+h) >= ay){
+ y = ay-h-5;
+ }
+ }
+ return {x : x, y: y};
+ },
+
+ beforeDestroy : function(){
+ this.clearTimers();
+ Ext.destroy(this.anchorEl);
+ delete this.anchorEl;
+ delete this.target;
+ delete this.anchorTarget;
+ delete this.triggerElement;
+ Ext.ToolTip.superclass.beforeDestroy.call(this);
+ },
+
+
+ onDestroy : function(){
+ Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
+ Ext.ToolTip.superclass.onDestroy.call(this);
+ }
+});
+
+Ext.reg('tooltip', Ext.ToolTip);
+Ext.QuickTip = Ext.extend(Ext.ToolTip, {
+
+
+ interceptTitles : false,
+
+
+ tagConfig : {
+ namespace : "ext",
+ attribute : "qtip",
+ width : "qwidth",
+ target : "target",
+ title : "qtitle",
+ hide : "hide",
+ cls : "qclass",
+ align : "qalign",
+ anchor : "anchor"
+ },
+
+
+ initComponent : function(){
+ this.target = this.target || Ext.getDoc();
+ this.targets = this.targets || {};
+ Ext.QuickTip.superclass.initComponent.call(this);
+ },
+
+
+ register : function(config){
+ var cs = Ext.isArray(config) ? config : arguments;
+ for(var i = 0, len = cs.length; i < len; i++){
+ var c = cs[i];
+ var target = c.target;
+ if(target){
+ if(Ext.isArray(target)){
+ for(var j = 0, jlen = target.length; j < jlen; j++){
+ this.targets[Ext.id(target[j])] = c;
+ }
+ } else{
+ this.targets[Ext.id(target)] = c;
+ }
+ }
+ }
+ },
+
+
+ unregister : function(el){
+ delete this.targets[Ext.id(el)];
+ },
+
+
+ cancelShow: function(el){
+ var at = this.activeTarget;
+ el = Ext.get(el).dom;
+ if(this.isVisible()){
+ if(at && at.el == el){
+ this.hide();
+ }
+ }else if(at && at.el == el){
+ this.clearTimer('show');
+ }
+ },
+
+ getTipCfg: function(e) {
+ var t = e.getTarget(),
+ ttp,
+ cfg;
+ if(this.interceptTitles && t.title && Ext.isString(t.title)){
+ ttp = t.title;
+ t.qtip = ttp;
+ t.removeAttribute("title");
+ e.preventDefault();
+ }else{
+ cfg = this.tagConfig;
+ ttp = t.qtip || Ext.fly(t).getAttribute(cfg.attribute, cfg.namespace);
+ }
+ return ttp;
+ },
+
+
+ onTargetOver : function(e){
+ if(this.disabled){
+ return;
+ }
+ this.targetXY = e.getXY();
+ var t = e.getTarget();
+ if(!t || t.nodeType !== 1 || t == document || t == document.body){
+ return;
+ }
+ if(this.activeTarget && ((t == this.activeTarget.el) || Ext.fly(this.activeTarget.el).contains(t))){
+ this.clearTimer('hide');
+ this.show();
+ return;
+ }
+ if(t && this.targets[t.id]){
+ this.activeTarget = this.targets[t.id];
+ this.activeTarget.el = t;
+ this.anchor = this.activeTarget.anchor;
+ if(this.anchor){
+ this.anchorTarget = t;
+ }
+ this.delayShow();
+ return;
+ }
+ var ttp, et = Ext.fly(t), cfg = this.tagConfig, ns = cfg.namespace;
+ if(ttp = this.getTipCfg(e)){
+ var autoHide = et.getAttribute(cfg.hide, ns);
+ this.activeTarget = {
+ el: t,
+ text: ttp,
+ width: et.getAttribute(cfg.width, ns),
+ autoHide: autoHide != "user" && autoHide !== 'false',
+ title: et.getAttribute(cfg.title, ns),
+ cls: et.getAttribute(cfg.cls, ns),
+ align: et.getAttribute(cfg.align, ns)
+
+ };
+ this.anchor = et.getAttribute(cfg.anchor, ns);
+ if(this.anchor){
+ this.anchorTarget = t;
+ }
+ this.delayShow();
+ }
+ },
+
+
+ onTargetOut : function(e){
+
+
+ if (this.activeTarget && e.within(this.activeTarget.el) && !this.getTipCfg(e)) {
+ return;
+ }
+
+ this.clearTimer('show');
+ if(this.autoHide !== false){
+ this.delayHide();
+ }
+ },
+
+
+ showAt : function(xy){
+ var t = this.activeTarget;
+ if(t){
+ if(!this.rendered){
+ this.render(Ext.getBody());
+ this.activeTarget = t;
+ }
+ if(t.width){
+ this.setWidth(t.width);
+ this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
+ this.measureWidth = false;
+ } else{
+ this.measureWidth = true;
+ }
+ this.setTitle(t.title || '');
+ this.body.update(t.text);
+ this.autoHide = t.autoHide;
+ this.dismissDelay = t.dismissDelay || this.dismissDelay;
+ if(this.lastCls){
+ this.el.removeClass(this.lastCls);
+ delete this.lastCls;
+ }
+ if(t.cls){
+ this.el.addClass(t.cls);
+ this.lastCls = t.cls;
+ }
+ if(this.anchor){
+ this.constrainPosition = false;
+ }else if(t.align){
+ xy = this.el.getAlignToXY(t.el, t.align);
+ this.constrainPosition = false;
+ }else{
+ this.constrainPosition = true;
+ }
+ }
+ Ext.QuickTip.superclass.showAt.call(this, xy);
+ },
+
+
+ hide: function(){
+ delete this.activeTarget;
+ Ext.QuickTip.superclass.hide.call(this);
+ }
+});
+Ext.reg('quicktip', Ext.QuickTip);
+Ext.QuickTips = function(){
+ var tip,
+ disabled = false;
+
+ return {
+
+ init : function(autoRender){
+ if(!tip){
+ if(!Ext.isReady){
+ Ext.onReady(function(){
+ Ext.QuickTips.init(autoRender);
+ });
+ return;
+ }
+ tip = new Ext.QuickTip({
+ elements:'header,body',
+ disabled: disabled
+ });
+ if(autoRender !== false){
+ tip.render(Ext.getBody());
+ }
+ }
+ },
+
+
+ ddDisable : function(){
+
+ if(tip && !disabled){
+ tip.disable();
+ }
+ },
+
+
+ ddEnable : function(){
+
+ if(tip && !disabled){
+ tip.enable();
+ }
+ },
+
+
+ enable : function(){
+ if(tip){
+ tip.enable();
+ }
+ disabled = false;
+ },
+
+
+ disable : function(){
+ if(tip){
+ tip.disable();
+ }
+ disabled = true;
+ },
+
+
+ isEnabled : function(){
+ return tip !== undefined && !tip.disabled;
+ },
+
+
+ getQuickTip : function(){
+ return tip;
+ },
+
+
+ register : function(){
+ tip.register.apply(tip, arguments);
+ },
+
+
+ unregister : function(){
+ tip.unregister.apply(tip, arguments);
+ },
+
+
+ tips : function(){
+ tip.register.apply(tip, arguments);
+ }
+ };
+}();
+Ext.slider.Tip = Ext.extend(Ext.Tip, {
+ minWidth: 10,
+ offsets : [0, -10],
+
+ init: function(slider) {
+ slider.on({
+ scope : this,
+ dragstart: this.onSlide,
+ drag : this.onSlide,
+ dragend : this.hide,
+ destroy : this.destroy
+ });
+ },
+
+
+ onSlide : function(slider, e, thumb) {
+ this.show();
+ this.body.update(this.getText(thumb));
+ this.doAutoWidth();
+ this.el.alignTo(thumb.el, 'b-t?', this.offsets);
+ },
+
+
+ getText : function(thumb) {
+ return String(thumb.value);
+ }
+});
+
+
+Ext.ux.SliderTip = Ext.slider.Tip;
+Ext.tree.TreePanel = Ext.extend(Ext.Panel, {
+ rootVisible : true,
+ animate : Ext.enableFx,
+ lines : true,
+ enableDD : false,
+ hlDrop : Ext.enableFx,
+ pathSeparator : '/',
+
+
+ bubbleEvents : [],
+
+ initComponent : function(){
+ Ext.tree.TreePanel.superclass.initComponent.call(this);
+
+ if(!this.eventModel){
+ this.eventModel = new Ext.tree.TreeEventModel(this);
+ }
+
+
+ var l = this.loader;
+ if(!l){
+ l = new Ext.tree.TreeLoader({
+ dataUrl: this.dataUrl,
+ requestMethod: this.requestMethod
+ });
+ }else if(Ext.isObject(l) && !l.load){
+ l = new Ext.tree.TreeLoader(l);
+ }
+ this.loader = l;
+
+ this.nodeHash = {};
+
+
+ if(this.root){
+ var r = this.root;
+ delete this.root;
+ this.setRootNode(r);
+ }
+
+
+ this.addEvents(
+
+
+ 'append',
+
+ 'remove',
+
+ 'movenode',
+
+ 'insert',
+
+ 'beforeappend',
+
+ 'beforeremove',
+
+ 'beforemovenode',
+
+ 'beforeinsert',
+
+
+ 'beforeload',
+
+ 'load',
+
+ 'textchange',
+
+ 'beforeexpandnode',
+
+ 'beforecollapsenode',
+
+ 'expandnode',
+
+ 'disabledchange',
+
+ 'collapsenode',
+
+ 'beforeclick',
+
+ 'click',
+
+ 'containerclick',
+
+ 'checkchange',
+
+ 'beforedblclick',
+
+ 'dblclick',
+
+ 'containerdblclick',
+
+ 'contextmenu',
+
+ 'containercontextmenu',
+
+ 'beforechildrenrendered',
+
+ 'startdrag',
+
+ 'enddrag',
+
+ 'dragdrop',
+
+ 'beforenodedrop',
+
+ 'nodedrop',
+
+ 'nodedragover'
+ );
+ if(this.singleExpand){
+ this.on('beforeexpandnode', this.restrictExpand, this);
+ }
+ },
+
+
+ proxyNodeEvent : function(ename, a1, a2, a3, a4, a5, a6){
+ if(ename == 'collapse' || ename == 'expand' || ename == 'beforecollapse' || ename == 'beforeexpand' || ename == 'move' || ename == 'beforemove'){
+ ename = ename+'node';
+ }
+
+ return this.fireEvent(ename, a1, a2, a3, a4, a5, a6);
+ },
+
+
+
+ getRootNode : function(){
+ return this.root;
+ },
+
+
+ setRootNode : function(node){
+ this.destroyRoot();
+ if(!node.render){
+ node = this.loader.createNode(node);
+ }
+ this.root = node;
+ node.ownerTree = this;
+ node.isRoot = true;
+ this.registerNode(node);
+ if(!this.rootVisible){
+ var uiP = node.attributes.uiProvider;
+ node.ui = uiP ? new uiP(node) : new Ext.tree.RootTreeNodeUI(node);
+ }
+ if(this.innerCt){
+ this.clearInnerCt();
+ this.renderRoot();
+ }
+ return node;
+ },
+
+ clearInnerCt : function(){
+ this.innerCt.update('');
+ },
+
+
+ renderRoot : function(){
+ this.root.render();
+ if(!this.rootVisible){
+ this.root.renderChildren();
+ }
+ },
+
+
+ getNodeById : function(id){
+ return this.nodeHash[id];
+ },
+
+
+ registerNode : function(node){
+ this.nodeHash[node.id] = node;
+ },
+
+
+ unregisterNode : function(node){
+ delete this.nodeHash[node.id];
+ },
+
+
+ toString : function(){
+ return '[Tree'+(this.id?' '+this.id:'')+']';
+ },
+
+
+ restrictExpand : function(node){
+ var p = node.parentNode;
+ if(p){
+ if(p.expandedChild && p.expandedChild.parentNode == p){
+ p.expandedChild.collapse();
+ }
+ p.expandedChild = node;
+ }
+ },
+
+
+ getChecked : function(a, startNode){
+ startNode = startNode || this.root;
+ var r = [];
+ var f = function(){
+ if(this.attributes.checked){
+ r.push(!a ? this : (a == 'id' ? this.id : this.attributes[a]));
+ }
+ };
+ startNode.cascade(f);
+ return r;
+ },
+
+
+ getLoader : function(){
+ return this.loader;
+ },
+
+
+ expandAll : function(){
+ this.root.expand(true);
+ },
+
+
+ collapseAll : function(){
+ this.root.collapse(true);
+ },
+
+
+ getSelectionModel : function(){
+ if(!this.selModel){
+ this.selModel = new Ext.tree.DefaultSelectionModel();
+ }
+ return this.selModel;
+ },
+
+
+ expandPath : function(path, attr, callback){
+ if(Ext.isEmpty(path)){
+ if(callback){
+ callback(false, undefined);
+ }
+ return;
+ }
+ attr = attr || 'id';
+ var keys = path.split(this.pathSeparator);
+ var curNode = this.root;
+ if(curNode.attributes[attr] != keys[1]){
+ if(callback){
+ callback(false, null);
+ }
+ return;
+ }
+ var index = 1;
+ var f = function(){
+ if(++index == keys.length){
+ if(callback){
+ callback(true, curNode);
+ }
+ return;
+ }
+ var c = curNode.findChild(attr, keys[index]);
+ if(!c){
+ if(callback){
+ callback(false, curNode);
+ }
+ return;
+ }
+ curNode = c;
+ c.expand(false, false, f);
+ };
+ curNode.expand(false, false, f);
+ },
+
+
+ selectPath : function(path, attr, callback){
+ if(Ext.isEmpty(path)){
+ if(callback){
+ callback(false, undefined);
+ }
+ return;
+ }
+ attr = attr || 'id';
+ var keys = path.split(this.pathSeparator),
+ v = keys.pop();
+ if(keys.length > 1){
+ var f = function(success, node){
+ if(success && node){
+ var n = node.findChild(attr, v);
+ if(n){
+ n.select();
+ if(callback){
+ callback(true, n);
+ }
+ }else if(callback){
+ callback(false, n);
+ }
+ }else{
+ if(callback){
+ callback(false, n);
+ }
+ }
+ };
+ this.expandPath(keys.join(this.pathSeparator), attr, f);
+ }else{
+ this.root.select();
+ if(callback){
+ callback(true, this.root);
+ }
+ }
+ },
+
+
+ getTreeEl : function(){
+ return this.body;
+ },
+
+
+ onRender : function(ct, position){
+ Ext.tree.TreePanel.superclass.onRender.call(this, ct, position);
+ this.el.addClass('x-tree');
+ this.innerCt = this.body.createChild({tag:'ul',
+ cls:'x-tree-root-ct ' +
+ (this.useArrows ? 'x-tree-arrows' : this.lines ? 'x-tree-lines' : 'x-tree-no-lines')});
+ },
+
+
+ initEvents : function(){
+ Ext.tree.TreePanel.superclass.initEvents.call(this);
+
+ if(this.containerScroll){
+ Ext.dd.ScrollManager.register(this.body);
+ }
+ if((this.enableDD || this.enableDrop) && !this.dropZone){
+
+ this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || {
+ ddGroup: this.ddGroup || 'TreeDD', appendOnly: this.ddAppendOnly === true
+ });
+ }
+ if((this.enableDD || this.enableDrag) && !this.dragZone){
+
+ this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || {
+ ddGroup: this.ddGroup || 'TreeDD',
+ scroll: this.ddScroll
+ });
+ }
+ this.getSelectionModel().init(this);
+ },
+
+
+ afterRender : function(){
+ Ext.tree.TreePanel.superclass.afterRender.call(this);
+ this.renderRoot();
+ },
+
+ beforeDestroy : function(){
+ if(this.rendered){
+ Ext.dd.ScrollManager.unregister(this.body);
+ Ext.destroy(this.dropZone, this.dragZone);
+ }
+ this.destroyRoot();
+ Ext.destroy(this.loader);
+ this.nodeHash = this.root = this.loader = null;
+ Ext.tree.TreePanel.superclass.beforeDestroy.call(this);
+ },
+
+
+ destroyRoot : function(){
+ if(this.root && this.root.destroy){
+ this.root.destroy(true);
+ }
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+});
+
+Ext.tree.TreePanel.nodeTypes = {};
+
+Ext.reg('treepanel', Ext.tree.TreePanel);Ext.tree.TreeEventModel = function(tree){
+ this.tree = tree;
+ this.tree.on('render', this.initEvents, this);
+};
+
+Ext.tree.TreeEventModel.prototype = {
+ initEvents : function(){
+ var t = this.tree;
+
+ if(t.trackMouseOver !== false){
+ t.mon(t.innerCt, {
+ scope: this,
+ mouseover: this.delegateOver,
+ mouseout: this.delegateOut
+ });
+ }
+ t.mon(t.getTreeEl(), {
+ scope: this,
+ click: this.delegateClick,
+ dblclick: this.delegateDblClick,
+ contextmenu: this.delegateContextMenu
+ });
+ },
+
+ getNode : function(e){
+ var t;
+ if(t = e.getTarget('.x-tree-node-el', 10)){
+ var id = Ext.fly(t, '_treeEvents').getAttribute('tree-node-id', 'ext');
+ if(id){
+ return this.tree.getNodeById(id);
+ }
+ }
+ return null;
+ },
+
+ getNodeTarget : function(e){
+ var t = e.getTarget('.x-tree-node-icon', 1);
+ if(!t){
+ t = e.getTarget('.x-tree-node-el', 6);
+ }
+ return t;
+ },
+
+ delegateOut : function(e, t){
+ if(!this.beforeEvent(e)){
+ return;
+ }
+ if(e.getTarget('.x-tree-ec-icon', 1)){
+ var n = this.getNode(e);
+ this.onIconOut(e, n);
+ if(n == this.lastEcOver){
+ delete this.lastEcOver;
+ }
+ }
+ if((t = this.getNodeTarget(e)) && !e.within(t, true)){
+ this.onNodeOut(e, this.getNode(e));
+ }
+ },
+
+ delegateOver : function(e, t){
+ if(!this.beforeEvent(e)){
+ return;
+ }
+ if(Ext.isGecko && !this.trackingDoc){
+ Ext.getBody().on('mouseover', this.trackExit, this);
+ this.trackingDoc = true;
+ }
+ if(this.lastEcOver){
+ this.onIconOut(e, this.lastEcOver);
+ delete this.lastEcOver;
+ }
+ if(e.getTarget('.x-tree-ec-icon', 1)){
+ this.lastEcOver = this.getNode(e);
+ this.onIconOver(e, this.lastEcOver);
+ }
+ if(t = this.getNodeTarget(e)){
+ this.onNodeOver(e, this.getNode(e));
+ }
+ },
+
+ trackExit : function(e){
+ if(this.lastOverNode){
+ if(this.lastOverNode.ui && !e.within(this.lastOverNode.ui.getEl())){
+ this.onNodeOut(e, this.lastOverNode);
+ }
+ delete this.lastOverNode;
+ Ext.getBody().un('mouseover', this.trackExit, this);
+ this.trackingDoc = false;
+ }
+
+ },
+
+ delegateClick : function(e, t){
+ if(this.beforeEvent(e)){
+ if(e.getTarget('input[type=checkbox]', 1)){
+ this.onCheckboxClick(e, this.getNode(e));
+ }else if(e.getTarget('.x-tree-ec-icon', 1)){
+ this.onIconClick(e, this.getNode(e));
+ }else if(this.getNodeTarget(e)){
+ this.onNodeClick(e, this.getNode(e));
+ }
+ }else{
+ this.checkContainerEvent(e, 'click');
+ }
+ },
+
+ delegateDblClick : function(e, t){
+ if(this.beforeEvent(e)){
+ if(this.getNodeTarget(e)){
+ this.onNodeDblClick(e, this.getNode(e));
+ }
+ }else{
+ this.checkContainerEvent(e, 'dblclick');
+ }
+ },
+
+ delegateContextMenu : function(e, t){
+ if(this.beforeEvent(e)){
+ if(this.getNodeTarget(e)){
+ this.onNodeContextMenu(e, this.getNode(e));
+ }
+ }else{
+ this.checkContainerEvent(e, 'contextmenu');
+ }
+ },
+
+ checkContainerEvent: function(e, type){
+ if(this.disabled){
+ e.stopEvent();
+ return false;
+ }
+ this.onContainerEvent(e, type);
+ },
+
+ onContainerEvent: function(e, type){
+ this.tree.fireEvent('container' + type, this.tree, e);
+ },
+
+ onNodeClick : function(e, node){
+ node.ui.onClick(e);
+ },
+
+ onNodeOver : function(e, node){
+ this.lastOverNode = node;
+ node.ui.onOver(e);
+ },
+
+ onNodeOut : function(e, node){
+ node.ui.onOut(e);
+ },
+
+ onIconOver : function(e, node){
+ node.ui.addClass('x-tree-ec-over');
+ },
+
+ onIconOut : function(e, node){
+ node.ui.removeClass('x-tree-ec-over');
+ },
+
+ onIconClick : function(e, node){
+ node.ui.ecClick(e);
+ },
+
+ onCheckboxClick : function(e, node){
+ node.ui.onCheckChange(e);
+ },
+
+ onNodeDblClick : function(e, node){
+ node.ui.onDblClick(e);
+ },
+
+ onNodeContextMenu : function(e, node){
+ node.ui.onContextMenu(e);
+ },
+
+ beforeEvent : function(e){
+ var node = this.getNode(e);
+ if(this.disabled || !node || !node.ui){
+ e.stopEvent();
+ return false;
+ }
+ return true;
+ },
+
+ disable: function(){
+ this.disabled = true;
+ },
+
+ enable: function(){
+ this.disabled = false;
+ }
+};
+Ext.tree.DefaultSelectionModel = Ext.extend(Ext.util.Observable, {
+
+ constructor : function(config){
+ this.selNode = null;
+
+ this.addEvents(
+
+ 'selectionchange',
+
+
+ 'beforeselect'
+ );
+
+ Ext.apply(this, config);
+ Ext.tree.DefaultSelectionModel.superclass.constructor.call(this);
+ },
+
+ init : function(tree){
+ this.tree = tree;
+ tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
+ tree.on('click', this.onNodeClick, this);
+ },
+
+ onNodeClick : function(node, e){
+ this.select(node);
+ },
+
+
+ select : function(node, selectNextNode){
+
+ if (!Ext.fly(node.ui.wrap).isVisible() && selectNextNode) {
+ return selectNextNode.call(this, node);
+ }
+ var last = this.selNode;
+ if(node == last){
+ node.ui.onSelectedChange(true);
+ }else if(this.fireEvent('beforeselect', this, node, last) !== false){
+ if(last && last.ui){
+ last.ui.onSelectedChange(false);
+ }
+ this.selNode = node;
+ node.ui.onSelectedChange(true);
+ this.fireEvent('selectionchange', this, node, last);
+ }
+ return node;
+ },
+
+
+ unselect : function(node, silent){
+ if(this.selNode == node){
+ this.clearSelections(silent);
+ }
+ },
+
+
+ clearSelections : function(silent){
+ var n = this.selNode;
+ if(n){
+ n.ui.onSelectedChange(false);
+ this.selNode = null;
+ if(silent !== true){
+ this.fireEvent('selectionchange', this, null);
+ }
+ }
+ return n;
+ },
+
+
+ getSelectedNode : function(){
+ return this.selNode;
+ },
+
+
+ isSelected : function(node){
+ return this.selNode == node;
+ },
+
+
+ selectPrevious : function( s){
+ if(!(s = s || this.selNode || this.lastSelNode)){
+ return null;
+ }
+
+ var ps = s.previousSibling;
+ if(ps){
+ if(!ps.isExpanded() || ps.childNodes.length < 1){
+ return this.select(ps, this.selectPrevious);
+ } else{
+ var lc = ps.lastChild;
+ while(lc && lc.isExpanded() && Ext.fly(lc.ui.wrap).isVisible() && lc.childNodes.length > 0){
+ lc = lc.lastChild;
+ }
+ return this.select(lc, this.selectPrevious);
+ }
+ } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){
+ return this.select(s.parentNode, this.selectPrevious);
+ }
+ return null;
+ },
+
+
+ selectNext : function( s){
+ if(!(s = s || this.selNode || this.lastSelNode)){
+ return null;
+ }
+
+ if(s.firstChild && s.isExpanded() && Ext.fly(s.ui.wrap).isVisible()){
+ return this.select(s.firstChild, this.selectNext);
+ }else if(s.nextSibling){
+ return this.select(s.nextSibling, this.selectNext);
+ }else if(s.parentNode){
+ var newS = null;
+ s.parentNode.bubble(function(){
+ if(this.nextSibling){
+ newS = this.getOwnerTree().selModel.select(this.nextSibling, this.selectNext);
+ return false;
+ }
+ });
+ return newS;
+ }
+ return null;
+ },
+
+ onKeyDown : function(e){
+ var s = this.selNode || this.lastSelNode;
+
+ var sm = this;
+ if(!s){
+ return;
+ }
+ var k = e.getKey();
+ switch(k){
+ case e.DOWN:
+ e.stopEvent();
+ this.selectNext();
+ break;
+ case e.UP:
+ e.stopEvent();
+ this.selectPrevious();
+ break;
+ case e.RIGHT:
+ e.preventDefault();
+ if(s.hasChildNodes()){
+ if(!s.isExpanded()){
+ s.expand();
+ }else if(s.firstChild){
+ this.select(s.firstChild, e);
+ }
+ }
+ break;
+ case e.LEFT:
+ e.preventDefault();
+ if(s.hasChildNodes() && s.isExpanded()){
+ s.collapse();
+ }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){
+ this.select(s.parentNode, e);
+ }
+ break;
+ };
+ }
+});
+
+
+Ext.tree.MultiSelectionModel = Ext.extend(Ext.util.Observable, {
+
+ constructor : function(config){
+ this.selNodes = [];
+ this.selMap = {};
+ this.addEvents(
+
+ 'selectionchange'
+ );
+ Ext.apply(this, config);
+ Ext.tree.MultiSelectionModel.superclass.constructor.call(this);
+ },
+
+ init : function(tree){
+ this.tree = tree;
+ tree.mon(tree.getTreeEl(), 'keydown', this.onKeyDown, this);
+ tree.on('click', this.onNodeClick, this);
+ },
+
+ onNodeClick : function(node, e){
+ if(e.ctrlKey && this.isSelected(node)){
+ this.unselect(node);
+ }else{
+ this.select(node, e, e.ctrlKey);
+ }
+ },
+
+
+ select : function(node, e, keepExisting){
+ if(keepExisting !== true){
+ this.clearSelections(true);
+ }
+ if(this.isSelected(node)){
+ this.lastSelNode = node;
+ return node;
+ }
+ this.selNodes.push(node);
+ this.selMap[node.id] = node;
+ this.lastSelNode = node;
+ node.ui.onSelectedChange(true);
+ this.fireEvent('selectionchange', this, this.selNodes);
+ return node;
+ },
+
+
+ unselect : function(node){
+ if(this.selMap[node.id]){
+ node.ui.onSelectedChange(false);
+ var sn = this.selNodes;
+ var index = sn.indexOf(node);
+ if(index != -1){
+ this.selNodes.splice(index, 1);
+ }
+ delete this.selMap[node.id];
+ this.fireEvent('selectionchange', this, this.selNodes);
+ }
+ },
+
+
+ clearSelections : function(suppressEvent){
+ var sn = this.selNodes;
+ if(sn.length > 0){
+ for(var i = 0, len = sn.length; i < len; i++){
+ sn[i].ui.onSelectedChange(false);
+ }
+ this.selNodes = [];
+ this.selMap = {};
+ if(suppressEvent !== true){
+ this.fireEvent('selectionchange', this, this.selNodes);
+ }
+ }
+ },
+
+
+ isSelected : function(node){
+ return this.selMap[node.id] ? true : false;
+ },
+
+
+ getSelectedNodes : function(){
+ return this.selNodes.concat([]);
+ },
+
+ onKeyDown : Ext.tree.DefaultSelectionModel.prototype.onKeyDown,
+
+ selectNext : Ext.tree.DefaultSelectionModel.prototype.selectNext,
+
+ selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious
+});
+Ext.data.Tree = Ext.extend(Ext.util.Observable, {
+
+ constructor: function(root){
+ this.nodeHash = {};
+
+ this.root = null;
+ if(root){
+ this.setRootNode(root);
+ }
+ this.addEvents(
+
+ "append",
+
+ "remove",
+
+ "move",
+
+ "insert",
+
+ "beforeappend",
+
+ "beforeremove",
+
+ "beforemove",
+
+ "beforeinsert"
+ );
+ Ext.data.Tree.superclass.constructor.call(this);
+ },
+
+
+ pathSeparator: "/",
+
+
+ proxyNodeEvent : function(){
+ return this.fireEvent.apply(this, arguments);
+ },
+
+
+ getRootNode : function(){
+ return this.root;
+ },
+
+
+ setRootNode : function(node){
+ this.root = node;
+ node.ownerTree = this;
+ node.isRoot = true;
+ this.registerNode(node);
+ return node;
+ },
+
+
+ getNodeById : function(id){
+ return this.nodeHash[id];
+ },
+
+
+ registerNode : function(node){
+ this.nodeHash[node.id] = node;
+ },
+
+
+ unregisterNode : function(node){
+ delete this.nodeHash[node.id];
+ },
+
+ toString : function(){
+ return "[Tree"+(this.id?" "+this.id:"")+"]";
+ }
+});
+
+
+Ext.data.Node = Ext.extend(Ext.util.Observable, {
+
+ constructor: function(attributes){
+
+ this.attributes = attributes || {};
+ this.leaf = this.attributes.leaf;
+
+ this.id = this.attributes.id;
+ if(!this.id){
+ this.id = Ext.id(null, "xnode-");
+ this.attributes.id = this.id;
+ }
+
+ this.childNodes = [];
+
+ this.parentNode = null;
+
+ this.firstChild = null;
+
+ this.lastChild = null;
+
+ this.previousSibling = null;
+
+ this.nextSibling = null;
+
+ this.addEvents({
+
+ "append" : true,
+
+ "remove" : true,
+
+ "move" : true,
+
+ "insert" : true,
+
+ "beforeappend" : true,
+
+ "beforeremove" : true,
+
+ "beforemove" : true,
+
+ "beforeinsert" : true
+ });
+ this.listeners = this.attributes.listeners;
+ Ext.data.Node.superclass.constructor.call(this);
+ },
+
+
+ fireEvent : function(evtName){
+
+ if(Ext.data.Node.superclass.fireEvent.apply(this, arguments) === false){
+ return false;
+ }
+
+ var ot = this.getOwnerTree();
+ if(ot){
+ if(ot.proxyNodeEvent.apply(ot, arguments) === false){
+ return false;
+ }
+ }
+ return true;
+ },
+
+
+ isLeaf : function(){
+ return this.leaf === true;
+ },
+
+
+ setFirstChild : function(node){
+ this.firstChild = node;
+ },
+
+
+ setLastChild : function(node){
+ this.lastChild = node;
+ },
+
+
+
+ isLast : function(){
+ return (!this.parentNode ? true : this.parentNode.lastChild == this);
+ },
+
+
+ isFirst : function(){
+ return (!this.parentNode ? true : this.parentNode.firstChild == this);
+ },
+
+
+ hasChildNodes : function(){
+ return !this.isLeaf() && this.childNodes.length > 0;
+ },
+
+
+ isExpandable : function(){
+ return this.attributes.expandable || this.hasChildNodes();
+ },
+
+
+ appendChild : function(node){
+ var multi = false;
+ if(Ext.isArray(node)){
+ multi = node;
+ }else if(arguments.length > 1){
+ multi = arguments;
+ }
+
+ if(multi){
+ for(var i = 0, len = multi.length; i < len; i++) {
+ this.appendChild(multi[i]);
+ }
+ }else{
+ if(this.fireEvent("beforeappend", this.ownerTree, this, node) === false){
+ return false;
+ }
+ var index = this.childNodes.length;
+ var oldParent = node.parentNode;
+
+ if(oldParent){
+ if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index) === false){
+ return false;
+ }
+ oldParent.removeChild(node);
+ }
+ index = this.childNodes.length;
+ if(index === 0){
+ this.setFirstChild(node);
+ }
+ this.childNodes.push(node);
+ node.parentNode = this;
+ var ps = this.childNodes[index-1];
+ if(ps){
+ node.previousSibling = ps;
+ ps.nextSibling = node;
+ }else{
+ node.previousSibling = null;
+ }
+ node.nextSibling = null;
+ this.setLastChild(node);
+ node.setOwnerTree(this.getOwnerTree());
+ this.fireEvent("append", this.ownerTree, this, node, index);
+ if(oldParent){
+ node.fireEvent("move", this.ownerTree, node, oldParent, this, index);
+ }
+ return node;
+ }
+ },
+
+
+ removeChild : function(node, destroy){
+ var index = this.childNodes.indexOf(node);
+ if(index == -1){
+ return false;
+ }
+ if(this.fireEvent("beforeremove", this.ownerTree, this, node) === false){
+ return false;
+ }
+
+
+ this.childNodes.splice(index, 1);
+
+
+ if(node.previousSibling){
+ node.previousSibling.nextSibling = node.nextSibling;
+ }
+ if(node.nextSibling){
+ node.nextSibling.previousSibling = node.previousSibling;
+ }
+
+
+ if(this.firstChild == node){
+ this.setFirstChild(node.nextSibling);
+ }
+ if(this.lastChild == node){
+ this.setLastChild(node.previousSibling);
+ }
+
+ this.fireEvent("remove", this.ownerTree, this, node);
+ if(destroy){
+ node.destroy(true);
+ }else{
+ node.clear();
+ }
+ return node;
+ },
+
+
+ clear : function(destroy){
+
+ this.setOwnerTree(null, destroy);
+ this.parentNode = this.previousSibling = this.nextSibling = null;
+ if(destroy){
+ this.firstChild = this.lastChild = null;
+ }
+ },
+
+
+ destroy : function( silent){
+
+ if(silent === true){
+ this.purgeListeners();
+ this.clear(true);
+ Ext.each(this.childNodes, function(n){
+ n.destroy(true);
+ });
+ this.childNodes = null;
+ }else{
+ this.remove(true);
+ }
+ },
+
+
+ insertBefore : function(node, refNode){
+ if(!refNode){
+ return this.appendChild(node);
+ }
+
+ if(node == refNode){
+ return false;
+ }
+
+ if(this.fireEvent("beforeinsert", this.ownerTree, this, node, refNode) === false){
+ return false;
+ }
+ var index = this.childNodes.indexOf(refNode);
+ var oldParent = node.parentNode;
+ var refIndex = index;
+
+
+ if(oldParent == this && this.childNodes.indexOf(node) < index){
+ refIndex--;
+ }
+
+
+ if(oldParent){
+ if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index, refNode) === false){
+ return false;
+ }
+ oldParent.removeChild(node);
+ }
+ if(refIndex === 0){
+ this.setFirstChild(node);
+ }
+ this.childNodes.splice(refIndex, 0, node);
+ node.parentNode = this;
+ var ps = this.childNodes[refIndex-1];
+ if(ps){
+ node.previousSibling = ps;
+ ps.nextSibling = node;
+ }else{
+ node.previousSibling = null;
+ }
+ node.nextSibling = refNode;
+ refNode.previousSibling = node;
+ node.setOwnerTree(this.getOwnerTree());
+ this.fireEvent("insert", this.ownerTree, this, node, refNode);
+ if(oldParent){
+ node.fireEvent("move", this.ownerTree, node, oldParent, this, refIndex, refNode);
+ }
+ return node;
+ },
+
+
+ remove : function(destroy){
+ if (this.parentNode) {
+ this.parentNode.removeChild(this, destroy);
+ }
+ return this;
+ },
+
+
+ removeAll : function(destroy){
+ var cn = this.childNodes,
+ n;
+ while((n = cn[0])){
+ this.removeChild(n, destroy);
+ }
+ return this;
+ },
+
+
+ item : function(index){
+ return this.childNodes[index];
+ },
+
+
+ replaceChild : function(newChild, oldChild){
+ var s = oldChild ? oldChild.nextSibling : null;
+ this.removeChild(oldChild);
+ this.insertBefore(newChild, s);
+ return oldChild;
+ },
+
+
+ indexOf : function(child){
+ return this.childNodes.indexOf(child);
+ },
+
+
+ getOwnerTree : function(){
+
+ if(!this.ownerTree){
+ var p = this;
+ while(p){
+ if(p.ownerTree){
+ this.ownerTree = p.ownerTree;
+ break;
+ }
+ p = p.parentNode;
+ }
+ }
+ return this.ownerTree;
+ },
+
+
+ getDepth : function(){
+ var depth = 0;
+ var p = this;
+ while(p.parentNode){
+ ++depth;
+ p = p.parentNode;
+ }
+ return depth;
+ },
+
+
+ setOwnerTree : function(tree, destroy){
+
+ if(tree != this.ownerTree){
+ if(this.ownerTree){
+ this.ownerTree.unregisterNode(this);
+ }
+ this.ownerTree = tree;
+
+ if(destroy !== true){
+ Ext.each(this.childNodes, function(n){
+ n.setOwnerTree(tree);
+ });
+ }
+ if(tree){
+ tree.registerNode(this);
+ }
+ }
+ },
+
+
+ setId: function(id){
+ if(id !== this.id){
+ var t = this.ownerTree;
+ if(t){
+ t.unregisterNode(this);
+ }
+ this.id = this.attributes.id = id;
+ if(t){
+ t.registerNode(this);
+ }
+ this.onIdChange(id);
+ }
+ },
+
+
+ onIdChange: Ext.emptyFn,
+
+
+ getPath : function(attr){
+ attr = attr || "id";
+ var p = this.parentNode;
+ var b = [this.attributes[attr]];
+ while(p){
+ b.unshift(p.attributes[attr]);
+ p = p.parentNode;
+ }
+ var sep = this.getOwnerTree().pathSeparator;
+ return sep + b.join(sep);
+ },
+
+
+ bubble : function(fn, scope, args){
+ var p = this;
+ while(p){
+ if(fn.apply(scope || p, args || [p]) === false){
+ break;
+ }
+ p = p.parentNode;
+ }
+ },
+
+
+ cascade : function(fn, scope, args){
+ if(fn.apply(scope || this, args || [this]) !== false){
+ var cs = this.childNodes;
+ for(var i = 0, len = cs.length; i < len; i++) {
+ cs[i].cascade(fn, scope, args);
+ }
+ }
+ },
+
+
+ eachChild : function(fn, scope, args){
+ var cs = this.childNodes;
+ for(var i = 0, len = cs.length; i < len; i++) {
+ if(fn.apply(scope || cs[i], args || [cs[i]]) === false){
+ break;
+ }
+ }
+ },
+
+
+ findChild : function(attribute, value, deep){
+ return this.findChildBy(function(){
+ return this.attributes[attribute] == value;
+ }, null, deep);
+ },
+
+
+ findChildBy : function(fn, scope, deep){
+ var cs = this.childNodes,
+ len = cs.length,
+ i = 0,
+ n,
+ res;
+ for(; i < len; i++){
+ n = cs[i];
+ if(fn.call(scope || n, n) === true){
+ return n;
+ }else if (deep){
+ res = n.findChildBy(fn, scope, deep);
+ if(res != null){
+ return res;
+ }
+ }
+
+ }
+ return null;
+ },
+
+
+ sort : function(fn, scope){
+ var cs = this.childNodes;
+ var len = cs.length;
+ if(len > 0){
+ var sortFn = scope ? function(){fn.apply(scope, arguments);} : fn;
+ cs.sort(sortFn);
+ for(var i = 0; i < len; i++){
+ var n = cs[i];
+ n.previousSibling = cs[i-1];
+ n.nextSibling = cs[i+1];
+ if(i === 0){
+ this.setFirstChild(n);
+ }
+ if(i == len-1){
+ this.setLastChild(n);
+ }
+ }
+ }
+ },
+
+
+ contains : function(node){
+ return node.isAncestor(this);
+ },
+
+
+ isAncestor : function(node){
+ var p = this.parentNode;
+ while(p){
+ if(p == node){
+ return true;
+ }
+ p = p.parentNode;
+ }
+ return false;
+ },
+
+ toString : function(){
+ return "[Node"+(this.id?" "+this.id:"")+"]";
+ }
+});
+Ext.tree.TreeNode = Ext.extend(Ext.data.Node, {
+
+ constructor : function(attributes){
+ attributes = attributes || {};
+ if(Ext.isString(attributes)){
+ attributes = {text: attributes};
+ }
+ this.childrenRendered = false;
+ this.rendered = false;
+ Ext.tree.TreeNode.superclass.constructor.call(this, attributes);
+ this.expanded = attributes.expanded === true;
+ this.isTarget = attributes.isTarget !== false;
+ this.draggable = attributes.draggable !== false && attributes.allowDrag !== false;
+ this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false;
+
+
+ this.text = attributes.text;
+
+ this.disabled = attributes.disabled === true;
+
+ this.hidden = attributes.hidden === true;
+
+ this.addEvents(
+
+ 'textchange',
+
+ 'beforeexpand',
+
+ 'beforecollapse',
+
+ 'expand',
+
+ 'disabledchange',
+
+ 'collapse',
+
+ 'beforeclick',
+
+ 'click',
+
+ 'checkchange',
+
+ 'beforedblclick',
+
+ 'dblclick',
+
+ 'contextmenu',
+
+ 'beforechildrenrendered'
+ );
+
+ var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;
+
+
+ this.ui = new uiClass(this);
+ },
+
+ preventHScroll : true,
+
+ isExpanded : function(){
+ return this.expanded;
+ },
+
+
+ getUI : function(){
+ return this.ui;
+ },
+
+ getLoader : function(){
+ var owner;
+ return this.loader || ((owner = this.getOwnerTree()) && owner.loader ? owner.loader : (this.loader = new Ext.tree.TreeLoader()));
+ },
+
+
+ setFirstChild : function(node){
+ var of = this.firstChild;
+ Ext.tree.TreeNode.superclass.setFirstChild.call(this, node);
+ if(this.childrenRendered && of && node != of){
+ of.renderIndent(true, true);
+ }
+ if(this.rendered){
+ this.renderIndent(true, true);
+ }
+ },
+
+
+ setLastChild : function(node){
+ var ol = this.lastChild;
+ Ext.tree.TreeNode.superclass.setLastChild.call(this, node);
+ if(this.childrenRendered && ol && node != ol){
+ ol.renderIndent(true, true);
+ }
+ if(this.rendered){
+ this.renderIndent(true, true);
+ }
+ },
+
+
+
+ appendChild : function(n){
+ if(!n.render && !Ext.isArray(n)){
+ n = this.getLoader().createNode(n);
+ }
+ var node = Ext.tree.TreeNode.superclass.appendChild.call(this, n);
+ if(node && this.childrenRendered){
+ node.render();
+ }
+ this.ui.updateExpandIcon();
+ return node;
+ },
+
+
+ removeChild : function(node, destroy){
+ this.ownerTree.getSelectionModel().unselect(node);
+ Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
+
+ if(!destroy){
+ var rendered = node.ui.rendered;
+
+ if(rendered){
+ node.ui.remove();
+ }
+ if(rendered && this.childNodes.length < 1){
+ this.collapse(false, false);
+ }else{
+ this.ui.updateExpandIcon();
+ }
+ if(!this.firstChild && !this.isHiddenRoot()){
+ this.childrenRendered = false;
+ }
+ }
+ return node;
+ },
+
+
+ insertBefore : function(node, refNode){
+ if(!node.render){
+ node = this.getLoader().createNode(node);
+ }
+ var newNode = Ext.tree.TreeNode.superclass.insertBefore.call(this, node, refNode);
+ if(newNode && refNode && this.childrenRendered){
+ node.render();
+ }
+ this.ui.updateExpandIcon();
+ return newNode;
+ },
+
+
+ setText : function(text){
+ var oldText = this.text;
+ this.text = this.attributes.text = text;
+ if(this.rendered){
+ this.ui.onTextChange(this, text, oldText);
+ }
+ this.fireEvent('textchange', this, text, oldText);
+ },
+
+
+ setIconCls : function(cls){
+ var old = this.attributes.iconCls;
+ this.attributes.iconCls = cls;
+ if(this.rendered){
+ this.ui.onIconClsChange(this, cls, old);
+ }
+ },
+
+
+ setTooltip : function(tip, title){
+ this.attributes.qtip = tip;
+ this.attributes.qtipTitle = title;
+ if(this.rendered){
+ this.ui.onTipChange(this, tip, title);
+ }
+ },
+
+
+ setIcon : function(icon){
+ this.attributes.icon = icon;
+ if(this.rendered){
+ this.ui.onIconChange(this, icon);
+ }
+ },
+
+
+ setHref : function(href, target){
+ this.attributes.href = href;
+ this.attributes.hrefTarget = target;
+ if(this.rendered){
+ this.ui.onHrefChange(this, href, target);
+ }
+ },
+
+
+ setCls : function(cls){
+ var old = this.attributes.cls;
+ this.attributes.cls = cls;
+ if(this.rendered){
+ this.ui.onClsChange(this, cls, old);
+ }
+ },
+
+
+ select : function(){
+ var t = this.getOwnerTree();
+ if(t){
+ t.getSelectionModel().select(this);
+ }
+ },
+
+
+ unselect : function(silent){
+ var t = this.getOwnerTree();
+ if(t){
+ t.getSelectionModel().unselect(this, silent);
+ }
+ },
+
+
+ isSelected : function(){
+ var t = this.getOwnerTree();
+ return t ? t.getSelectionModel().isSelected(this) : false;
+ },
+
+
+ expand : function(deep, anim, callback, scope){
+ if(!this.expanded){
+ if(this.fireEvent('beforeexpand', this, deep, anim) === false){
+ return;
+ }
+ if(!this.childrenRendered){
+ this.renderChildren();
+ }
+ this.expanded = true;
+ if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){
+ this.ui.animExpand(function(){
+ this.fireEvent('expand', this);
+ this.runCallback(callback, scope || this, [this]);
+ if(deep === true){
+ this.expandChildNodes(true, true);
+ }
+ }.createDelegate(this));
+ return;
+ }else{
+ this.ui.expand();
+ this.fireEvent('expand', this);
+ this.runCallback(callback, scope || this, [this]);
+ }
+ }else{
+ this.runCallback(callback, scope || this, [this]);
+ }
+ if(deep === true){
+ this.expandChildNodes(true);
+ }
+ },
+
+ runCallback : function(cb, scope, args){
+ if(Ext.isFunction(cb)){
+ cb.apply(scope, args);
+ }
+ },
+
+ isHiddenRoot : function(){
+ return this.isRoot && !this.getOwnerTree().rootVisible;
+ },
+
+
+ collapse : function(deep, anim, callback, scope){
+ if(this.expanded && !this.isHiddenRoot()){
+ if(this.fireEvent('beforecollapse', this, deep, anim) === false){
+ return;
+ }
+ this.expanded = false;
+ if((this.getOwnerTree().animate && anim !== false) || anim){
+ this.ui.animCollapse(function(){
+ this.fireEvent('collapse', this);
+ this.runCallback(callback, scope || this, [this]);
+ if(deep === true){
+ this.collapseChildNodes(true);
+ }
+ }.createDelegate(this));
+ return;
+ }else{
+ this.ui.collapse();
+ this.fireEvent('collapse', this);
+ this.runCallback(callback, scope || this, [this]);
+ }
+ }else if(!this.expanded){
+ this.runCallback(callback, scope || this, [this]);
+ }
+ if(deep === true){
+ var cs = this.childNodes;
+ for(var i = 0, len = cs.length; i < len; i++) {
+ cs[i].collapse(true, false);
+ }
+ }
+ },
+
+
+ delayedExpand : function(delay){
+ if(!this.expandProcId){
+ this.expandProcId = this.expand.defer(delay, this);
+ }
+ },
+
+
+ cancelExpand : function(){
+ if(this.expandProcId){
+ clearTimeout(this.expandProcId);
+ }
+ this.expandProcId = false;
+ },
+
+
+ toggle : function(){
+ if(this.expanded){
+ this.collapse();
+ }else{
+ this.expand();
+ }
+ },
+
+
+ ensureVisible : function(callback, scope){
+ var tree = this.getOwnerTree();
+ tree.expandPath(this.parentNode ? this.parentNode.getPath() : this.getPath(), false, function(){
+ var node = tree.getNodeById(this.id);
+ tree.getTreeEl().scrollChildIntoView(node.ui.anchor);
+ this.runCallback(callback, scope || this, [this]);
+ }.createDelegate(this));
+ },
+
+
+ expandChildNodes : function(deep, anim) {
+ var cs = this.childNodes,
+ i,
+ len = cs.length;
+ for (i = 0; i < len; i++) {
+ cs[i].expand(deep, anim);
+ }
+ },
+
+
+ collapseChildNodes : function(deep){
+ var cs = this.childNodes;
+ for(var i = 0, len = cs.length; i < len; i++) {
+ cs[i].collapse(deep);
+ }
+ },
+
+
+ disable : function(){
+ this.disabled = true;
+ this.unselect();
+ if(this.rendered && this.ui.onDisableChange){
+ this.ui.onDisableChange(this, true);
+ }
+ this.fireEvent('disabledchange', this, true);
+ },
+
+
+ enable : function(){
+ this.disabled = false;
+ if(this.rendered && this.ui.onDisableChange){
+ this.ui.onDisableChange(this, false);
+ }
+ this.fireEvent('disabledchange', this, false);
+ },
+
+
+ renderChildren : function(suppressEvent){
+ if(suppressEvent !== false){
+ this.fireEvent('beforechildrenrendered', this);
+ }
+ var cs = this.childNodes;
+ for(var i = 0, len = cs.length; i < len; i++){
+ cs[i].render(true);
+ }
+ this.childrenRendered = true;
+ },
+
+
+ sort : function(fn, scope){
+ Ext.tree.TreeNode.superclass.sort.apply(this, arguments);
+ if(this.childrenRendered){
+ var cs = this.childNodes;
+ for(var i = 0, len = cs.length; i < len; i++){
+ cs[i].render(true);
+ }
+ }
+ },
+
+
+ render : function(bulkRender){
+ this.ui.render(bulkRender);
+ if(!this.rendered){
+
+ this.getOwnerTree().registerNode(this);
+ this.rendered = true;
+ if(this.expanded){
+ this.expanded = false;
+ this.expand(false, false);
+ }
+ }
+ },
+
+
+ renderIndent : function(deep, refresh){
+ if(refresh){
+ this.ui.childIndent = null;
+ }
+ this.ui.renderIndent();
+ if(deep === true && this.childrenRendered){
+ var cs = this.childNodes;
+ for(var i = 0, len = cs.length; i < len; i++){
+ cs[i].renderIndent(true, refresh);
+ }
+ }
+ },
+
+ beginUpdate : function(){
+ this.childrenRendered = false;
+ },
+
+ endUpdate : function(){
+ if(this.expanded && this.rendered){
+ this.renderChildren();
+ }
+ },
+
+
+ destroy : function(silent){
+ if(silent === true){
+ this.unselect(true);
+ }
+ Ext.tree.TreeNode.superclass.destroy.call(this, silent);
+ Ext.destroy(this.ui, this.loader);
+ this.ui = this.loader = null;
+ },
+
+
+ onIdChange : function(id){
+ this.ui.onIdChange(id);
+ }
+});
+
+Ext.tree.TreePanel.nodeTypes.node = Ext.tree.TreeNode;
+ Ext.tree.AsyncTreeNode = function(config){
+ this.loaded = config && config.loaded === true;
+ this.loading = false;
+ Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
+
+ this.addEvents('beforeload', 'load');
+
+
+};
+Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
+ expand : function(deep, anim, callback, scope){
+ if(this.loading){
+ var timer;
+ var f = function(){
+ if(!this.loading){
+ clearInterval(timer);
+ this.expand(deep, anim, callback, scope);
+ }
+ }.createDelegate(this);
+ timer = setInterval(f, 200);
+ return;
+ }
+ if(!this.loaded){
+ if(this.fireEvent("beforeload", this) === false){
+ return;
+ }
+ this.loading = true;
+ this.ui.beforeLoad(this);
+ var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
+ if(loader){
+ loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback, scope]), this);
+ return;
+ }
+ }
+ Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);
+ },
+
+
+ isLoading : function(){
+ return this.loading;
+ },
+
+ loadComplete : function(deep, anim, callback, scope){
+ this.loading = false;
+ this.loaded = true;
+ this.ui.afterLoad(this);
+ this.fireEvent("load", this);
+ this.expand(deep, anim, callback, scope);
+ },
+
+
+ isLoaded : function(){
+ return this.loaded;
+ },
+
+ hasChildNodes : function(){
+ if(!this.isLeaf() && !this.loaded){
+ return true;
+ }else{
+ return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
+ }
+ },
+
+
+ reload : function(callback, scope){
+ this.collapse(false, false);
+ while(this.firstChild){
+ this.removeChild(this.firstChild).destroy();
+ }
+ this.childrenRendered = false;
+ this.loaded = false;
+ if(this.isHiddenRoot()){
+ this.expanded = false;
+ }
+ this.expand(false, false, callback, scope);
+ }
+});
+
+Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;
+Ext.tree.TreeNodeUI = Ext.extend(Object, {
+
+ constructor : function(node){
+ Ext.apply(this, {
+ node: node,
+ rendered: false,
+ animating: false,
+ wasLeaf: true,
+ ecc: 'x-tree-ec-icon x-tree-elbow',
+ emptyIcon: Ext.BLANK_IMAGE_URL
+ });
+ },
+
+
+ removeChild : function(node){
+ if(this.rendered){
+ this.ctNode.removeChild(node.ui.getEl());
+ }
+ },
+
+
+ beforeLoad : function(){
+ this.addClass("x-tree-node-loading");
+ },
+
+
+ afterLoad : function(){
+ this.removeClass("x-tree-node-loading");
+ },
+
+
+ onTextChange : function(node, text, oldText){
+ if(this.rendered){
+ this.textNode.innerHTML = text;
+ }
+ },
+
+
+ onIconClsChange : function(node, cls, oldCls){
+ if(this.rendered){
+ Ext.fly(this.iconNode).replaceClass(oldCls, cls);
+ }
+ },
+
+
+ onIconChange : function(node, icon){
+ if(this.rendered){
+
+ var empty = Ext.isEmpty(icon);
+ this.iconNode.src = empty ? this.emptyIcon : icon;
+ Ext.fly(this.iconNode)[empty ? 'removeClass' : 'addClass']('x-tree-node-inline-icon');
+ }
+ },
+
+
+ onTipChange : function(node, tip, title){
+ if(this.rendered){
+ var hasTitle = Ext.isDefined(title);
+ if(this.textNode.setAttributeNS){
+ this.textNode.setAttributeNS("ext", "qtip", tip);
+ if(hasTitle){
+ this.textNode.setAttributeNS("ext", "qtitle", title);
+ }
+ }else{
+ this.textNode.setAttribute("ext:qtip", tip);
+ if(hasTitle){
+ this.textNode.setAttribute("ext:qtitle", title);
+ }
+ }
+ }
+ },
+
+
+ onHrefChange : function(node, href, target){
+ if(this.rendered){
+ this.anchor.href = this.getHref(href);
+ if(Ext.isDefined(target)){
+ this.anchor.target = target;
+ }
+ }
+ },
+
+
+ onClsChange : function(node, cls, oldCls){
+ if(this.rendered){
+ Ext.fly(this.elNode).replaceClass(oldCls, cls);
+ }
+ },
+
+
+ onDisableChange : function(node, state){
+ this.disabled = state;
+ if (this.checkbox) {
+ this.checkbox.disabled = state;
+ }
+ this[state ? 'addClass' : 'removeClass']('x-tree-node-disabled');
+ },
+
+
+ onSelectedChange : function(state){
+ if(state){
+ this.focus();
+ this.addClass("x-tree-selected");
+ }else{
+
+ this.removeClass("x-tree-selected");
+ }
+ },
+
+
+ onMove : function(tree, node, oldParent, newParent, index, refNode){
+ this.childIndent = null;
+ if(this.rendered){
+ var targetNode = newParent.ui.getContainer();
+ if(!targetNode){
+ this.holder = document.createElement("div");
+ this.holder.appendChild(this.wrap);
+ return;
+ }
+ var insertBefore = refNode ? refNode.ui.getEl() : null;
+ if(insertBefore){
+ targetNode.insertBefore(this.wrap, insertBefore);
+ }else{
+ targetNode.appendChild(this.wrap);
+ }
+ this.node.renderIndent(true, oldParent != newParent);
+ }
+ },
+
+
+ addClass : function(cls){
+ if(this.elNode){
+ Ext.fly(this.elNode).addClass(cls);
+ }
+ },
+
+
+ removeClass : function(cls){
+ if(this.elNode){
+ Ext.fly(this.elNode).removeClass(cls);
+ }
+ },
+
+
+ remove : function(){
+ if(this.rendered){
+ this.holder = document.createElement("div");
+ this.holder.appendChild(this.wrap);
+ }
+ },
+
+
+ fireEvent : function(){
+ return this.node.fireEvent.apply(this.node, arguments);
+ },
+
+
+ initEvents : function(){
+ this.node.on("move", this.onMove, this);
+
+ if(this.node.disabled){
+ this.onDisableChange(this.node, true);
+ }
+ if(this.node.hidden){
+ this.hide();
+ }
+ var ot = this.node.getOwnerTree();
+ var dd = ot.enableDD || ot.enableDrag || ot.enableDrop;
+ if(dd && (!this.node.isRoot || ot.rootVisible)){
+ Ext.dd.Registry.register(this.elNode, {
+ node: this.node,
+ handles: this.getDDHandles(),
+ isHandle: false
+ });
+ }
+ },
+
+
+ getDDHandles : function(){
+ return [this.iconNode, this.textNode, this.elNode];
+ },
+
+
+ hide : function(){
+ this.node.hidden = true;
+ if(this.wrap){
+ this.wrap.style.display = "none";
+ }
+ },
+
+
+ show : function(){
+ this.node.hidden = false;
+ if(this.wrap){
+ this.wrap.style.display = "";
+ }
+ },
+
+
+ onContextMenu : function(e){
+ if (this.node.hasListener("contextmenu") || this.node.getOwnerTree().hasListener("contextmenu")) {
+ e.preventDefault();
+ this.focus();
+ this.fireEvent("contextmenu", this.node, e);
+ }
+ },
+
+
+ onClick : function(e){
+ if(this.dropping){
+ e.stopEvent();
+ return;
+ }
+ if(this.fireEvent("beforeclick", this.node, e) !== false){
+ var a = e.getTarget('a');
+ if(!this.disabled && this.node.attributes.href && a){
+ this.fireEvent("click", this.node, e);
+ return;
+ }else if(a && e.ctrlKey){
+ e.stopEvent();
+ }
+ e.preventDefault();
+ if(this.disabled){
+ return;
+ }
+
+ if(this.node.attributes.singleClickExpand && !this.animating && this.node.isExpandable()){
+ this.node.toggle();
+ }
+
+ this.fireEvent("click", this.node, e);
+ }else{
+ e.stopEvent();
+ }
+ },
+
+
+ onDblClick : function(e){
+ e.preventDefault();
+ if(this.disabled){
+ return;
+ }
+ if(this.fireEvent("beforedblclick", this.node, e) !== false){
+ if(this.checkbox){
+ this.toggleCheck();
+ }
+ if(!this.animating && this.node.isExpandable()){
+ this.node.toggle();
+ }
+ this.fireEvent("dblclick", this.node, e);
+ }
+ },
+
+ onOver : function(e){
+ this.addClass('x-tree-node-over');
+ },
+
+ onOut : function(e){
+ this.removeClass('x-tree-node-over');
+ },
+
+
+ onCheckChange : function(){
+ var checked = this.checkbox.checked;
+
+ this.checkbox.defaultChecked = checked;
+ this.node.attributes.checked = checked;
+ this.fireEvent('checkchange', this.node, checked);
+ },
+
+
+ ecClick : function(e){
+ if(!this.animating && this.node.isExpandable()){
+ this.node.toggle();
+ }
+ },
+
+
+ startDrop : function(){
+ this.dropping = true;
+ },
+
+
+ endDrop : function(){
+ setTimeout(function(){
+ this.dropping = false;
+ }.createDelegate(this), 50);
+ },
+
+
+ expand : function(){
+ this.updateExpandIcon();
+ this.ctNode.style.display = "";
+ },
+
+
+ focus : function(){
+ if(!this.node.preventHScroll){
+ try{this.anchor.focus();
+ }catch(e){}
+ }else{
+ try{
+ var noscroll = this.node.getOwnerTree().getTreeEl().dom;
+ var l = noscroll.scrollLeft;
+ this.anchor.focus();
+ noscroll.scrollLeft = l;
+ }catch(e){}
+ }
+ },
+
+
+ toggleCheck : function(value){
+ var cb = this.checkbox;
+ if(cb){
+ cb.checked = (value === undefined ? !cb.checked : value);
+ this.onCheckChange();
+ }
+ },
+
+
+ blur : function(){
+ try{
+ this.anchor.blur();
+ }catch(e){}
+ },
+
+
+ animExpand : function(callback){
+ var ct = Ext.get(this.ctNode);
+ ct.stopFx();
+ if(!this.node.isExpandable()){
+ this.updateExpandIcon();
+ this.ctNode.style.display = "";
+ Ext.callback(callback);
+ return;
+ }
+ this.animating = true;
+ this.updateExpandIcon();
+
+ ct.slideIn('t', {
+ callback : function(){
+ this.animating = false;
+ Ext.callback(callback);
+ },
+ scope: this,
+ duration: this.node.ownerTree.duration || .25
+ });
+ },
+
+
+ highlight : function(){
+ var tree = this.node.getOwnerTree();
+ Ext.fly(this.wrap).highlight(
+ tree.hlColor || "C3DAF9",
+ {endColor: tree.hlBaseColor}
+ );
+ },
+
+
+ collapse : function(){
+ this.updateExpandIcon();
+ this.ctNode.style.display = "none";
+ },
+
+
+ animCollapse : function(callback){
+ var ct = Ext.get(this.ctNode);
+ ct.enableDisplayMode('block');
+ ct.stopFx();
+
+ this.animating = true;
+ this.updateExpandIcon();
+
+ ct.slideOut('t', {
+ callback : function(){
+ this.animating = false;
+ Ext.callback(callback);
+ },
+ scope: this,
+ duration: this.node.ownerTree.duration || .25
+ });
+ },
+
+
+ getContainer : function(){
+ return this.ctNode;
+ },
+
+
+ getEl : function(){
+ return this.wrap;
+ },
+
+
+ appendDDGhost : function(ghostNode){
+ ghostNode.appendChild(this.elNode.cloneNode(true));
+ },
+
+
+ getDDRepairXY : function(){
+ return Ext.lib.Dom.getXY(this.iconNode);
+ },
+
+
+ onRender : function(){
+ this.render();
+ },
+
+
+ render : function(bulkRender){
+ var n = this.node, a = n.attributes;
+ var targetNode = n.parentNode ?
+ n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
+
+ if(!this.rendered){
+ this.rendered = true;
+
+ this.renderElements(n, a, targetNode, bulkRender);
+
+ if(a.qtip){
+ this.onTipChange(n, a.qtip, a.qtipTitle);
+ }else if(a.qtipCfg){
+ a.qtipCfg.target = Ext.id(this.textNode);
+ Ext.QuickTips.register(a.qtipCfg);
+ }
+ this.initEvents();
+ if(!this.node.expanded){
+ this.updateExpandIcon(true);
+ }
+ }else{
+ if(bulkRender === true) {
+ targetNode.appendChild(this.wrap);
+ }
+ }
+ },
+
+
+ renderElements : function(n, a, targetNode, bulkRender){
+
+ this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
+
+ var cb = Ext.isBoolean(a.checked),
+ nel,
+ href = this.getHref(a.href),
+ buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
+ '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
+ '<img alt="" src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
+ '<img alt="" src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
+ cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
+ '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
+ a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
+ '<ul class="x-tree-node-ct" style="display:none;"></ul>',
+ "</li>"].join('');
+
+ if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
+ this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
+ }else{
+ this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
+ }
+
+ this.elNode = this.wrap.childNodes[0];
+ this.ctNode = this.wrap.childNodes[1];
+ var cs = this.elNode.childNodes;
+ this.indentNode = cs[0];
+ this.ecNode = cs[1];
+ this.iconNode = cs[2];
+ var index = 3;
+ if(cb){
+ this.checkbox = cs[3];
+
+ this.checkbox.defaultChecked = this.checkbox.checked;
+ index++;
+ }
+ this.anchor = cs[index];
+ this.textNode = cs[index].firstChild;
+ },
+
+
+ getHref : function(href){
+ return Ext.isEmpty(href) ? (Ext.isGecko ? '' : '#') : href;
+ },
+
+
+ getAnchor : function(){
+ return this.anchor;
+ },
+
+
+ getTextEl : function(){
+ return this.textNode;
+ },
+
+
+ getIconEl : function(){
+ return this.iconNode;
+ },
+
+
+ isChecked : function(){
+ return this.checkbox ? this.checkbox.checked : false;
+ },
+
+
+ updateExpandIcon : function(){
+ if(this.rendered){
+ var n = this.node,
+ c1,
+ c2,
+ cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow",
+ hasChild = n.hasChildNodes();
+ if(hasChild || n.attributes.expandable){
+ if(n.expanded){
+ cls += "-minus";
+ c1 = "x-tree-node-collapsed";
+ c2 = "x-tree-node-expanded";
+ }else{
+ cls += "-plus";
+ c1 = "x-tree-node-expanded";
+ c2 = "x-tree-node-collapsed";
+ }
+ if(this.wasLeaf){
+ this.removeClass("x-tree-node-leaf");
+ this.wasLeaf = false;
+ }
+ if(this.c1 != c1 || this.c2 != c2){
+ Ext.fly(this.elNode).replaceClass(c1, c2);
+ this.c1 = c1; this.c2 = c2;
+ }
+ }else{
+ if(!this.wasLeaf){
+ Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-collapsed");
+ delete this.c1;
+ delete this.c2;
+ this.wasLeaf = true;
+ }
+ }
+ var ecc = "x-tree-ec-icon "+cls;
+ if(this.ecc != ecc){
+ this.ecNode.className = ecc;
+ this.ecc = ecc;
+ }
+ }
+ },
+
+
+ onIdChange: function(id){
+ if(this.rendered){
+ this.elNode.setAttribute('ext:tree-node-id', id);
+ }
+ },
+
+
+ getChildIndent : function(){
+ if(!this.childIndent){
+ var buf = [],
+ p = this.node;
+ while(p){
+ if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){
+ if(!p.isLast()) {
+ buf.unshift('<img alt="" src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
+ } else {
+ buf.unshift('<img alt="" src="'+this.emptyIcon+'" class="x-tree-icon" />');
+ }
+ }
+ p = p.parentNode;
+ }
+ this.childIndent = buf.join("");
+ }
+ return this.childIndent;
+ },
+
+
+ renderIndent : function(){
+ if(this.rendered){
+ var indent = "",
+ p = this.node.parentNode;
+ if(p){
+ indent = p.ui.getChildIndent();
+ }
+ if(this.indentMarkup != indent){
+ this.indentNode.innerHTML = indent;
+ this.indentMarkup = indent;
+ }
+ this.updateExpandIcon();
+ }
+ },
+
+ destroy : function(){
+ if(this.elNode){
+ Ext.dd.Registry.unregister(this.elNode.id);
+ }
+
+ Ext.each(['textnode', 'anchor', 'checkbox', 'indentNode', 'ecNode', 'iconNode', 'elNode', 'ctNode', 'wrap', 'holder'], function(el){
+ if(this[el]){
+ Ext.fly(this[el]).remove();
+ delete this[el];
+ }
+ }, this);
+ delete this.node;
+ }
+});
+
+
+Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
+
+ render : function(){
+ if(!this.rendered){
+ var targetNode = this.node.ownerTree.innerCt.dom;
+ this.node.expanded = true;
+ targetNode.innerHTML = '<div class="x-tree-root-node"></div>';
+ this.wrap = this.ctNode = targetNode.firstChild;
+ }
+ },
+ collapse : Ext.emptyFn,
+ expand : Ext.emptyFn
+});
+Ext.tree.TreeLoader = function(config){
+ this.baseParams = {};
+ Ext.apply(this, config);
+
+ this.addEvents(
+
+ "beforeload",
+
+ "load",
+
+ "loadexception"
+ );
+ Ext.tree.TreeLoader.superclass.constructor.call(this);
+ if(Ext.isString(this.paramOrder)){
+ this.paramOrder = this.paramOrder.split(/[\s,|]/);
+ }
+};
+
+Ext.extend(Ext.tree.TreeLoader, Ext.util.Observable, {
+
+
+
+
+
+
+
+ uiProviders : {},
+
+
+ clearOnLoad : true,
+
+
+ paramOrder: undefined,
+
+
+ paramsAsHash: false,
+
+
+ nodeParameter: 'node',
+
+
+ directFn : undefined,
+
+
+ load : function(node, callback, scope){
+ if(this.clearOnLoad){
+ while(node.firstChild){
+ node.removeChild(node.firstChild);
+ }
+ }
+ if(this.doPreload(node)){
+ this.runCallback(callback, scope || node, [node]);
+ }else if(this.directFn || this.dataUrl || this.url){
+ this.requestData(node, callback, scope || node);
+ }
+ },
+
+ doPreload : function(node){
+ if(node.attributes.children){
+ if(node.childNodes.length < 1){
+ var cs = node.attributes.children;
+ node.beginUpdate();
+ for(var i = 0, len = cs.length; i < len; i++){
+ var cn = node.appendChild(this.createNode(cs[i]));
+ if(this.preloadChildren){
+ this.doPreload(cn);
+ }
+ }
+ node.endUpdate();
+ }
+ return true;
+ }
+ return false;
+ },
+
+ getParams: function(node){
+ var bp = Ext.apply({}, this.baseParams),
+ np = this.nodeParameter,
+ po = this.paramOrder;
+
+ np && (bp[ np ] = node.id);
+
+ if(this.directFn){
+ var buf = [node.id];
+ if(po){
+
+ if(np && po.indexOf(np) > -1){
+ buf = [];
+ }
+
+ for(var i = 0, len = po.length; i < len; i++){
+ buf.push(bp[ po[i] ]);
+ }
+ }else if(this.paramsAsHash){
+ buf = [bp];
+ }
+ return buf;
+ }else{
+ return bp;
+ }
+ },
+
+ requestData : function(node, callback, scope){
+ if(this.fireEvent("beforeload", this, node, callback) !== false){
+ if(this.directFn){
+ var args = this.getParams(node);
+ args.push(this.processDirectResponse.createDelegate(this, [{callback: callback, node: node, scope: scope}], true));
+ this.directFn.apply(window, args);
+ }else{
+ this.transId = Ext.Ajax.request({
+ method:this.requestMethod,
+ url: this.dataUrl||this.url,
+ success: this.handleResponse,
+ failure: this.handleFailure,
+ scope: this,
+ argument: {callback: callback, node: node, scope: scope},
+ params: this.getParams(node)
+ });
+ }
+ }else{
+
+
+ this.runCallback(callback, scope || node, []);
+ }
+ },
+
+ processDirectResponse: function(result, response, args){
+ if(response.status){
+ this.handleResponse({
+ responseData: Ext.isArray(result) ? result : null,
+ responseText: result,
+ argument: args
+ });
+ }else{
+ this.handleFailure({
+ argument: args
+ });
+ }
+ },
+
+
+ runCallback: function(cb, scope, args){
+ if(Ext.isFunction(cb)){
+ cb.apply(scope, args);
+ }
+ },
+
+ isLoading : function(){
+ return !!this.transId;
+ },
+
+ abort : function(){
+ if(this.isLoading()){
+ Ext.Ajax.abort(this.transId);
+ }
+ },
+
+
+ createNode : function(attr){
+
+ if(this.baseAttrs){
+ Ext.applyIf(attr, this.baseAttrs);
+ }
+ if(this.applyLoader !== false && !attr.loader){
+ attr.loader = this;
+ }
+ if(Ext.isString(attr.uiProvider)){
+ attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
+ }
+ if(attr.nodeType){
+ return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr);
+ }else{
+ return attr.leaf ?
+ new Ext.tree.TreeNode(attr) :
+ new Ext.tree.AsyncTreeNode(attr);
+ }
+ },
+
+ processResponse : function(response, node, callback, scope){
+ var json = response.responseText;
+ try {
+ var o = response.responseData || Ext.decode(json);
+ node.beginUpdate();
+ for(var i = 0, len = o.length; i < len; i++){
+ var n = this.createNode(o[i]);
+ if(n){
+ node.appendChild(n);
+ }
+ }
+ node.endUpdate();
+ this.runCallback(callback, scope || node, [node]);
+ }catch(e){
+ this.handleFailure(response);
+ }
+ },
+
+ handleResponse : function(response){
+ this.transId = false;
+ var a = response.argument;
+ this.processResponse(response, a.node, a.callback, a.scope);
+ this.fireEvent("load", this, a.node, response);
+ },
+
+ handleFailure : function(response){
+ this.transId = false;
+ var a = response.argument;
+ this.fireEvent("loadexception", this, a.node, response);
+ this.runCallback(a.callback, a.scope || a.node, [a.node]);
+ },
+
+ destroy : function(){
+ this.abort();
+ this.purgeListeners();
+ }
+});