+ "position" : this.getStyle(POSITION),
+ "left" : l,
+ "right" : l ? "" : this.getStyle(RIGHT),
+ "top" : t,
+ "bottom" : t ? "" : this.getStyle(BOTTOM),
+ "z-index" : this.getStyle(ZINDEX)
+ };
+ },
+
+
+ setPositioning : function(pc){
+ var me = this,
+ style = me.dom.style;
+
+ me.setStyle(pc);
+
+ if(pc.right == AUTO){
+ style.right = "";
+ }
+ if(pc.bottom == AUTO){
+ style.bottom = "";
+ }
+
+ return me;
+ },
+
+
+ translatePoints: function(x, y) {
+ if (Ext.isArray(x)) {
+ y = x[1];
+ x = x[0];
+ }
+ var me = this,
+ relative = me.isStyle(POSITION, RELATIVE),
+ o = me.getXY(),
+ left = parseInt(me.getStyle(LEFT), 10),
+ top = parseInt(me.getStyle(TOP), 10);
+
+ if (!Ext.isNumber(left)) {
+ left = relative ? 0 : me.dom.offsetLeft;
+ }
+ if (!Ext.isNumber(top)) {
+ top = relative ? 0 : me.dom.offsetTop;
+ }
+ left = (Ext.isNumber(x)) ? x - o[0] + left : undefined;
+ top = (Ext.isNumber(y)) ? y - o[1] + top : undefined;
+ return {
+ left: left,
+ top: top
+ };
+ },
+
+
+ setBox: function(box, adjust, animate) {
+ var me = this,
+ w = box.width,
+ h = box.height;
+ if ((adjust && !me.autoBoxAdjust) && !me.isBorderBox()) {
+ w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
+ h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
+ }
+ me.setBounds(box.x, box.y, w, h, animate);
+ return me;
+ },
+
+
+ getBox: function(contentBox, local) {
+ var me = this,
+ xy,
+ left,
+ top,
+ getBorderWidth = me.getBorderWidth,
+ getPadding = me.getPadding,
+ l, r, t, b, w, h, bx;
+ if (!local) {
+ xy = me.getXY();
+ } else {
+ left = parseInt(me.getStyle("left"), 10) || 0;
+ top = parseInt(me.getStyle("top"), 10) || 0;
+ xy = [left, top];
+ }
+ w = me.getWidth();
+ h = me.getHeight();
+ if (!contentBox) {
+ bx = {
+ x: xy[0],
+ y: xy[1],
+ 0: xy[0],
+ 1: xy[1],
+ width: w,
+ height: h
+ };
+ } else {
+ l = getBorderWidth.call(me, "l") + getPadding.call(me, "l");
+ r = getBorderWidth.call(me, "r") + getPadding.call(me, "r");
+ t = getBorderWidth.call(me, "t") + getPadding.call(me, "t");
+ b = getBorderWidth.call(me, "b") + getPadding.call(me, "b");
+ bx = {
+ x: xy[0] + l,
+ y: xy[1] + t,
+ 0: xy[0] + l,
+ 1: xy[1] + t,
+ width: w - (l + r),
+ height: h - (t + b)
+ };
+ }
+ bx.right = bx.x + bx.width;
+ bx.bottom = bx.y + bx.height;
+ return bx;
+ },
+
+
+ move: function(direction, distance, animate) {
+ var me = this,
+ xy = me.getXY(),
+ x = xy[0],
+ y = xy[1],
+ left = [x - distance, y],
+ right = [x + distance, y],
+ top = [x, y - distance],
+ bottom = [x, y + distance],
+ hash = {
+ l: left,
+ left: left,
+ r: right,
+ right: right,
+ t: top,
+ top: top,
+ up: top,
+ b: bottom,
+ bottom: bottom,
+ down: bottom
+ };
+
+ direction = direction.toLowerCase();
+ me.moveTo(hash[direction][0], hash[direction][1], animate);
+ },
+
+
+ setLeftTop: function(left, top) {
+ var me = this,
+ style = me.dom.style;
+ style.left = me.addUnits(left);
+ style.top = me.addUnits(top);
+ return me;
+ },
+
+
+ getRegion: function() {
+ return this.getPageBox(true);
+ },
+
+
+ getViewRegion: function() {
+ var me = this,
+ isBody = me.dom === document.body,
+ scroll, pos, top, left, width, height;
+
+
+ if (isBody) {
+ scroll = me.getScroll();
+ left = scroll.left;
+ top = scroll.top;
+ width = Ext.Element.getViewportWidth();
+ height = Ext.Element.getViewportHeight();
+ }
+ else {
+ pos = me.getXY();
+ left = pos[0] + me.getBorderWidth('l') + me.getPadding('l');
+ top = pos[1] + me.getBorderWidth('t') + me.getPadding('t');
+ width = me.getWidth(true);
+ height = me.getHeight(true);
+ }
+
+ return Ext.create('Ext.util.Region', top, left + width, top + height, left);
+ },
+
+
+ getPageBox : function(getRegion) {
+ var me = this,
+ el = me.dom,
+ isDoc = el === document.body,
+ w = isDoc ? Ext.Element.getViewWidth() : el.offsetWidth,
+ h = isDoc ? Ext.Element.getViewHeight() : el.offsetHeight,
+ xy = me.getXY(),
+ t = xy[1],
+ r = xy[0] + w,
+ b = xy[1] + h,
+ l = xy[0];
+
+ if (getRegion) {
+ return Ext.create('Ext.util.Region', t, r, b, l);
+ }
+ else {
+ return {
+ left: l,
+ top: t,
+ width: w,
+ height: h,
+ right: r,
+ bottom: b
+ };
+ }
+ },
+
+
+ setBounds: function(x, y, width, height, animate) {
+ var me = this;
+ if (!animate || !me.anim) {
+ me.setSize(width, height);
+ me.setLocation(x, y);
+ } else {
+ if (!Ext.isObject(animate)) {
+ animate = {};
+ }
+ me.animate(Ext.applyIf({
+ to: {
+ x: x,
+ y: y,
+ width: me.adjustWidth(width),
+ height: me.adjustHeight(height)
+ }
+ }, animate));
+ }
+ return me;
+ },
+
+
+ setRegion: function(region, animate) {
+ return this.setBounds(region.left, region.top, region.right - region.left, region.bottom - region.top, animate);
+ }
+});
+})();
+
+
+Ext.override(Ext.Element, {
+
+ isScrollable : function(){
+ var dom = this.dom;
+ return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
+ },
+
+
+ getScroll : function() {
+ var d = this.dom,
+ doc = document,
+ body = doc.body,
+ docElement = doc.documentElement,
+ l,
+ t,
+ ret;
+
+ if (d == doc || d == body) {
+ if (Ext.isIE && Ext.isStrict) {
+ l = docElement.scrollLeft;
+ t = docElement.scrollTop;
+ } else {
+ l = window.pageXOffset;
+ t = window.pageYOffset;
+ }
+ ret = {
+ left: l || (body ? body.scrollLeft : 0),
+ top : t || (body ? body.scrollTop : 0)
+ };
+ } else {
+ ret = {
+ left: d.scrollLeft,
+ top : d.scrollTop
+ };
+ }
+
+ return ret;
+ },
+
+
+ scrollTo : function(side, value, animate) {
+
+ var top = /top/i.test(side),
+ me = this,
+ dom = me.dom,
+ obj = {},
+ prop;
+ if (!animate || !me.anim) {
+
+ prop = 'scroll' + (top ? 'Top' : 'Left');
+ dom[prop] = value;
+ }
+ else {
+ if (!Ext.isObject(animate)) {
+ animate = {};
+ }
+ obj['scroll' + (top ? 'Top' : 'Left')] = value;
+ me.animate(Ext.applyIf({
+ to: obj
+ }, animate));
+ }
+ return me;
+ },
+
+
+ scrollIntoView : function(container, hscroll) {
+ container = Ext.getDom(container) || Ext.getBody().dom;
+ var el = this.dom,
+ offsets = this.getOffsetsTo(container),
+
+ left = offsets[0] + container.scrollLeft,
+ top = offsets[1] + container.scrollTop,
+ bottom = top + el.offsetHeight,
+ right = left + el.offsetWidth,
+
+ ctClientHeight = container.clientHeight,
+ ctScrollTop = parseInt(container.scrollTop, 10),
+ ctScrollLeft = parseInt(container.scrollLeft, 10),
+ ctBottom = ctScrollTop + ctClientHeight,
+ ctRight = ctScrollLeft + container.clientWidth;
+
+ if (el.offsetHeight > ctClientHeight || top < ctScrollTop) {
+ container.scrollTop = top;
+ } else if (bottom > ctBottom) {
+ container.scrollTop = bottom - ctClientHeight;
+ }
+
+ container.scrollTop = container.scrollTop;
+
+ if (hscroll !== false) {
+ if (el.offsetWidth > container.clientWidth || left < ctScrollLeft) {
+ container.scrollLeft = left;
+ }
+ else if (right > ctRight) {
+ container.scrollLeft = right - container.clientWidth;
+ }
+ container.scrollLeft = container.scrollLeft;
+ }
+ return this;
+ },
+
+
+ scrollChildIntoView : function(child, hscroll) {
+ Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
+ },
+
+
+ scroll : function(direction, distance, animate) {
+ if (!this.isScrollable()) {
+ return false;
+ }
+ var el = this.dom,
+ l = el.scrollLeft, t = el.scrollTop,
+ w = el.scrollWidth, h = el.scrollHeight,
+ cw = el.clientWidth, ch = el.clientHeight,
+ scrolled = false, v,
+ hash = {
+ l: Math.min(l + distance, w-cw),
+ r: v = Math.max(l - distance, 0),
+ t: Math.max(t - distance, 0),
+ b: Math.min(t + distance, h-ch)
+ };
+ hash.d = hash.b;
+ hash.u = hash.t;
+
+ direction = direction.substr(0, 1);
+ if ((v = hash[direction]) > -1) {
+ scrolled = true;
+ this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.anim(animate));
+ }
+ return scrolled;
+ }
+});
+
+Ext.Element.addMethods(
+ function() {
+ var VISIBILITY = "visibility",
+ DISPLAY = "display",
+ HIDDEN = "hidden",
+ NONE = "none",
+ XMASKED = Ext.baseCSSPrefix + "masked",
+ XMASKEDRELATIVE = Ext.baseCSSPrefix + "masked-relative",
+ data = Ext.Element.data;
+
+ return {
+
+ isVisible : function(deep) {
+ var vis = !this.isStyle(VISIBILITY, HIDDEN) && !this.isStyle(DISPLAY, NONE),
+ p = this.dom.parentNode;
+
+ if (deep !== true || !vis) {
+ return vis;
+ }
+
+ while (p && !(/^body/i.test(p.tagName))) {
+ if (!Ext.fly(p, '_isVisible').isVisible()) {
+ return false;
+ }
+ p = p.parentNode;
+ }
+ return true;
+ },
+
+
+ isDisplayed : function() {
+ return !this.isStyle(DISPLAY, NONE);
+ },
+
+
+ enableDisplayMode : function(display) {
+ this.setVisibilityMode(Ext.Element.DISPLAY);
+
+ if (!Ext.isEmpty(display)) {
+ data(this.dom, 'originalDisplay', display);
+ }
+
+ return this;
+ },
+
+
+ mask : function(msg, msgCls) {
+ var me = this,
+ dom = me.dom,
+ setExpression = dom.style.setExpression,
+ dh = Ext.DomHelper,
+ EXTELMASKMSG = Ext.baseCSSPrefix + "mask-msg",
+ el,
+ mask;
+
+ if (!(/^body/i.test(dom.tagName) && me.getStyle('position') == 'static')) {
+ me.addCls(XMASKEDRELATIVE);
+ }
+ el = data(dom, 'maskMsg');
+ if (el) {
+ el.remove();
+ }
+ el = data(dom, 'mask');
+ if (el) {
+ el.remove();
+ }
+
+ mask = dh.append(dom, {cls : Ext.baseCSSPrefix + "mask"}, true);
+ data(dom, 'mask', mask);
+
+ me.addCls(XMASKED);
+ mask.setDisplayed(true);
+
+ if (typeof msg == 'string') {
+ var mm = dh.append(dom, {cls : EXTELMASKMSG, cn:{tag:'div'}}, true);
+ data(dom, 'maskMsg', mm);
+ mm.dom.className = msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG;
+ mm.dom.firstChild.innerHTML = msg;
+ mm.setDisplayed(true);
+ mm.center(me);
+ }
+
+
+
+
+
+ if (!Ext.supports.IncludePaddingInWidthCalculation && setExpression) {
+ mask.dom.style.setExpression('width', 'this.parentNode.offsetWidth + "px"');
+ }
+
+
+
+ if (!Ext.supports.IncludePaddingInHeightCalculation && setExpression) {
+ mask.dom.style.setExpression('height', 'this.parentNode.offsetHeight + "px"');
+ }
+
+ else if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') {
+ mask.setSize(undefined, me.getHeight());
+ }
+ return mask;
+ },
+
+
+ unmask : function() {
+ var me = this,
+ dom = me.dom,
+ mask = data(dom, 'mask'),
+ maskMsg = data(dom, 'maskMsg');
+
+ if (mask) {
+
+ if (mask.dom.style.clearExpression) {
+ mask.dom.style.clearExpression('width');
+ mask.dom.style.clearExpression('height');
+ }
+ if (maskMsg) {
+ maskMsg.remove();
+ data(dom, 'maskMsg', undefined);
+ }
+
+ mask.remove();
+ data(dom, 'mask', undefined);
+ me.removeCls([XMASKED, XMASKEDRELATIVE]);
+ }
+ },
+
+ isMasked : function() {
+ var me = this,
+ mask = data(me.dom, 'mask'),
+ maskMsg = data(me.dom, 'maskMsg');
+
+ if (mask && mask.isVisible()) {
+ if (maskMsg) {
+ maskMsg.center(me);
+ }
+ return true;
+ }
+ return false;
+ },
+
+
+ createShim : function() {
+ var el = document.createElement('iframe'),
+ shim;
+
+ el.frameBorder = '0';
+ el.className = Ext.baseCSSPrefix + 'shim';
+ el.src = Ext.SSL_SECURE_URL;
+ shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
+ shim.autoBoxAdjust = false;
+ return shim;
+ }
+ };
+ }()
+);
+
+Ext.Element.addMethods({
+
+ addKeyListener : function(key, fn, scope){
+ var config;
+ if(typeof key != 'object' || Ext.isArray(key)){
+ config = {
+ key: key,
+ fn: fn,
+ scope: scope
+ };
+ }else{
+ config = {
+ key : key.key,
+ shift : key.shift,
+ ctrl : key.ctrl,
+ alt : key.alt,
+ fn: fn,
+ scope: scope
+ };
+ }
+ return Ext.create('Ext.util.KeyMap', this, config);
+ },
+
+
+ addKeyMap : function(config){
+ return Ext.create('Ext.util.KeyMap', this, config);
+ }
+});
+
+
+
+Ext.CompositeElementLite.importElementMethods();
+
+
+Ext.apply(Ext.CompositeElementLite.prototype, {
+ addElements : function(els, root){
+ if(!els){
+ return this;
+ }
+ if(typeof els == "string"){
+ els = Ext.Element.selectorFunction(els, root);
+ }
+ var yels = this.elements;
+ Ext.each(els, function(e) {
+ yels.push(Ext.get(e));
+ });
+ return this;
+ },
+
+
+ first : function(){
+ return this.item(0);
+ },
+
+
+ last : function(){
+ return this.item(this.getCount()-1);
+ },
+
+
+ contains : function(el){
+ return this.indexOf(el) != -1;
+ },
+
+
+ removeElement : function(keys, removeDom){
+ var me = this,
+ els = this.elements,
+ el;
+ Ext.each(keys, function(val){
+ if ((el = (els[val] || els[val = me.indexOf(val)]))) {
+ if(removeDom){
+ if(el.dom){
+ el.remove();
+ }else{
+ Ext.removeNode(el);
+ }
+ }
+ Ext.Array.erase(els, val, 1);
+ }
+ });
+ return this;
+ }
+});
+
+
+Ext.CompositeElement = Ext.extend(Ext.CompositeElementLite, {
+
+ constructor : function(els, root){
+ this.elements = [];
+ this.add(els, root);
+ },
+
+
+ getElement : function(el){
+
+ return el;
+ },
+
+
+ transformElement : function(el){
+ return Ext.get(el);
+ }
+});
+
+
+Ext.Element.select = function(selector, unique, root){
+ var els;
+ if(typeof selector == "string"){
+ els = Ext.Element.selectorFunction(selector, root);
+ }else if(selector.length !== undefined){
+ els = selector;
+ }else{
+ }
+ return (unique === true) ? new Ext.CompositeElement(els) : new Ext.CompositeElementLite(els);
+};
+
+
+Ext.select = Ext.Element.select;
+
+
+
+
+Ext.define('Ext.util.Observable', {
+
+
+
+ requires: ['Ext.util.Event'],
+
+ statics: {
+
+ releaseCapture: function(o) {
+ o.fireEvent = this.prototype.fireEvent;
+ },
+
+
+ capture: function(o, fn, scope) {
+ o.fireEvent = Ext.Function.createInterceptor(o.fireEvent, fn, scope);
+ },
+
+
+ observe: function(cls, listeners) {
+ if (cls) {
+ if (!cls.isObservable) {
+ Ext.applyIf(cls, new this());
+ this.capture(cls.prototype, cls.fireEvent, cls);
+ }
+ if (Ext.isObject(listeners)) {
+ cls.on(listeners);
+ }
+ return cls;
+ }
+ }
+ },
+
+
+
+
+
+ isObservable: true,
+
+ constructor: function(config) {
+ var me = this;
+
+ Ext.apply(me, config);
+ if (me.listeners) {
+ me.on(me.listeners);
+ delete me.listeners;
+ }
+ me.events = me.events || {};
+
+ if (me.bubbleEvents) {
+ me.enableBubble(me.bubbleEvents);
+ }
+ },
+
+
+ eventOptionsRe : /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|element|vertical|horizontal|freezeEvent)$/,
+
+
+ addManagedListener : function(item, ename, fn, scope, options) {
+ var me = this,
+ managedListeners = me.managedListeners = me.managedListeners || [],
+ config;
+
+ if (typeof ename !== 'string') {
+ options = ename;
+ for (ename in options) {
+ if (options.hasOwnProperty(ename)) {
+ config = options[ename];
+ if (!me.eventOptionsRe.test(ename)) {
+ me.addManagedListener(item, ename, config.fn || config, config.scope || options.scope, config.fn ? config : options);
+ }
+ }
+ }
+ }
+ else {
+ managedListeners.push({
+ item: item,
+ ename: ename,
+ fn: fn,
+ scope: scope,
+ options: options
+ });
+
+ item.on(ename, fn, scope, options);
+ }
+ },
+
+
+ removeManagedListener : function(item, ename, fn, scope) {
+ var me = this,
+ options,
+ config,
+ managedListeners,
+ length,
+ i;
+
+ if (typeof ename !== 'string') {
+ options = ename;
+ for (ename in options) {
+ if (options.hasOwnProperty(ename)) {
+ config = options[ename];
+ if (!me.eventOptionsRe.test(ename)) {
+ me.removeManagedListener(item, ename, config.fn || config, config.scope || options.scope);
+ }
+ }
+ }
+ }
+
+ managedListeners = me.managedListeners ? me.managedListeners.slice() : [];
+
+ for (i = 0, length = managedListeners.length; i < length; i++) {
+ me.removeManagedListenerItem(false, managedListeners[i], item, ename, fn, scope);
+ }
+ },
+
+
+ fireEvent: function(eventName) {
+ var name = eventName.toLowerCase(),
+ events = this.events,
+ event = events && events[name],
+ bubbles = event && event.bubble;
+
+ return this.continueFireEvent(name, Ext.Array.slice(arguments, 1), bubbles);
+ },
+
+
+ continueFireEvent: function(eventName, args, bubbles) {
+ var target = this,
+ queue, event,
+ ret = true;
+
+ do {
+ if (target.eventsSuspended === true) {
+ if ((queue = target.eventQueue)) {
+ queue.push([eventName, args, bubbles]);
+ }
+ return ret;
+ } else {
+ event = target.events[eventName];
+
+
+ if (event && event != true) {
+ if ((ret = event.fire.apply(event, args)) === false) {
+ break;
+ }
+ }
+ }
+ } while (bubbles && (target = target.getBubbleParent()));
+ return ret;
+ },
+
+
+ getBubbleParent: function(){
+ var me = this, parent = me.getBubbleTarget && me.getBubbleTarget();
+ if (parent && parent.isObservable) {
+ return parent;
+ }
+ return null;
+ },
+
+
+ addListener: function(ename, fn, scope, options) {
+ var me = this,
+ config,
+ event;
+
+ if (typeof ename !== 'string') {
+ options = ename;
+ for (ename in options) {
+ if (options.hasOwnProperty(ename)) {
+ config = options[ename];
+ if (!me.eventOptionsRe.test(ename)) {
+ me.addListener(ename, config.fn || config, config.scope || options.scope, config.fn ? config : options);
+ }
+ }
+ }
+ }
+ else {
+ ename = ename.toLowerCase();
+ me.events[ename] = me.events[ename] || true;
+ event = me.events[ename] || true;
+ if (Ext.isBoolean(event)) {
+ me.events[ename] = event = new Ext.util.Event(me, ename);
+ }
+ event.addListener(fn, scope, Ext.isObject(options) ? options : {});
+ }
+ },
+
+
+ removeListener: function(ename, fn, scope) {
+ var me = this,
+ config,
+ event,
+ options;
+
+ if (typeof ename !== 'string') {
+ options = ename;
+ for (ename in options) {
+ if (options.hasOwnProperty(ename)) {
+ config = options[ename];
+ if (!me.eventOptionsRe.test(ename)) {
+ me.removeListener(ename, config.fn || config, config.scope || options.scope);
+ }
+ }
+ }
+ } else {
+ ename = ename.toLowerCase();
+ event = me.events[ename];
+ if (event && event.isEvent) {
+ event.removeListener(fn, scope);
+ }
+ }
+ },
+
+
+ clearListeners: function() {
+ var events = this.events,
+ event,
+ key;
+
+ for (key in events) {
+ if (events.hasOwnProperty(key)) {
+ event = events[key];
+ if (event.isEvent) {
+ event.clearListeners();
+ }
+ }
+ }
+
+ this.clearManagedListeners();
+ },
+
+
+
+ clearManagedListeners : function() {
+ var managedListeners = this.managedListeners || [],
+ i = 0,
+ len = managedListeners.length;
+
+ for (; i < len; i++) {
+ this.removeManagedListenerItem(true, managedListeners[i]);
+ }
+
+ this.managedListeners = [];
+ },
+
+
+ removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){
+ if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {
+ managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope);
+ if (!isClear) {
+ Ext.Array.remove(this.managedListeners, managedListener);
+ }
+ }
+ },
+
+
+
+ addEvents: function(o) {
+ var me = this,
+ args,
+ len,
+ i;
+
+ me.events = me.events || {};
+ if (Ext.isString(o)) {
+ args = arguments;
+ i = args.length;
+
+ while (i--) {
+ me.events[args[i]] = me.events[args[i]] || true;
+ }
+ } else {
+ Ext.applyIf(me.events, o);
+ }
+ },
+
+
+ hasListener: function(ename) {
+ var event = this.events[ename.toLowerCase()];
+ return event && event.isEvent === true && event.listeners.length > 0;
+ },
+
+
+ suspendEvents: function(queueSuspended) {
+ this.eventsSuspended = true;
+ if (queueSuspended && !this.eventQueue) {
+ this.eventQueue = [];
+ }
+ },
+
+
+ resumeEvents: function() {
+ var me = this,
+ queued = me.eventQueue;
+
+ me.eventsSuspended = false;
+ delete me.eventQueue;
+
+ if (queued) {
+ Ext.each(queued, function(e) {
+ me.continueFireEvent.apply(me, e);
+ });
+ }
+ },
+
+
+ relayEvents : function(origin, events, prefix) {
+ prefix = prefix || '';
+ var me = this,
+ len = events.length,
+ i = 0,
+ oldName,
+ newName;
+
+ for (; i < len; i++) {
+ oldName = events[i].substr(prefix.length);
+ newName = prefix + oldName;
+ me.events[newName] = me.events[newName] || true;
+ origin.on(oldName, me.createRelayer(newName));
+ }
+ },
+
+
+ createRelayer: function(newName){
+ var me = this;
+ return function(){
+ return me.fireEvent.apply(me, [newName].concat(Array.prototype.slice.call(arguments, 0, -1)));
+ };
+ },
+
+
+ enableBubble: function(events) {
+ var me = this;
+ if (!Ext.isEmpty(events)) {
+ events = Ext.isArray(events) ? events: Ext.Array.toArray(arguments);
+ Ext.each(events,
+ function(ename) {
+ ename = ename.toLowerCase();
+ var ce = me.events[ename] || true;
+ if (Ext.isBoolean(ce)) {
+ ce = new Ext.util.Event(me, ename);
+ me.events[ename] = ce;
+ }
+ ce.bubble = true;
+ });
+ }
+ }
+}, function() {
+
+ this.createAlias({
+
+ on: 'addListener',
+
+ un: 'removeListener',
+
+ mon: 'addManagedListener',
+
+ mun: 'removeManagedListener'
+ });
+
+
+ this.observeClass = this.observe;
+
+ Ext.apply(Ext.util.Observable.prototype, function(){
+
+
+
+ function getMethodEvent(method){
+ var e = (this.methodEvents = this.methodEvents || {})[method],
+ returnValue,
+ v,
+ cancel,
+ obj = this;
+
+ if (!e) {
+ this.methodEvents[method] = e = {};
+ e.originalFn = this[method];
+ e.methodName = method;
+ e.before = [];
+ e.after = [];
+
+ var makeCall = function(fn, scope, args){
+ if((v = fn.apply(scope || obj, args)) !== undefined){
+ if (typeof v == 'object') {
+ if(v.returnValue !== undefined){
+ returnValue = v.returnValue;
+ }else{
+ returnValue = v;
+ }
+ cancel = !!v.cancel;
+ }
+ else
+ if (v === false) {
+ cancel = true;
+ }
+ else {
+ returnValue = v;
+ }
+ }
+ };
+
+ this[method] = function(){
+ var args = Array.prototype.slice.call(arguments, 0),
+ b, i, len;
+ returnValue = v = undefined;
+ cancel = false;
+
+ for(i = 0, len = e.before.length; i < len; i++){
+ b = e.before[i];
+ makeCall(b.fn, b.scope, args);
+ if (cancel) {
+ return returnValue;
+ }
+ }
+
+ if((v = e.originalFn.apply(obj, args)) !== undefined){
+ returnValue = v;
+ }
+
+ for(i = 0, len = e.after.length; i < len; i++){
+ b = e.after[i];
+ makeCall(b.fn, b.scope, args);
+ if (cancel) {
+ return returnValue;
+ }
+ }
+ return returnValue;
+ };
+ }
+ return e;
+ }
+
+ return {
+
+
+
+ beforeMethod : function(method, fn, scope){
+ getMethodEvent.call(this, method).before.push({
+ fn: fn,
+ scope: scope
+ });
+ },
+
+
+ afterMethod : function(method, fn, scope){
+ getMethodEvent.call(this, method).after.push({
+ fn: fn,
+ scope: scope
+ });
+ },
+
+ removeMethodListener: function(method, fn, scope){
+ var e = this.getMethodEvent(method),
+ i, len;
+ for(i = 0, len = e.before.length; i < len; i++){
+ if(e.before[i].fn == fn && e.before[i].scope == scope){
+ Ext.Array.erase(e.before, i, 1);
+ return;
+ }
+ }
+ for(i = 0, len = e.after.length; i < len; i++){
+ if(e.after[i].fn == fn && e.after[i].scope == scope){
+ Ext.Array.erase(e.after, i, 1);
+ return;
+ }
+ }
+ },
+
+ toggleEventLogging: function(toggle) {
+ Ext.util.Observable[toggle ? 'capture' : 'releaseCapture'](this, function(en) {
+ if (Ext.isDefined(Ext.global.console)) {
+ Ext.global.console.log(en, arguments);
+ }
+ });
+ }
+ };
+ }());
+});
+
+
+Ext.define('Ext.util.Animate', {
+
+ uses: ['Ext.fx.Manager', 'Ext.fx.Anim'],
+
+
+ animate: function(animObj) {
+ var me = this;
+ if (Ext.fx.Manager.hasFxBlock(me.id)) {
+ return me;
+ }
+ Ext.fx.Manager.queueFx(Ext.create('Ext.fx.Anim', me.anim(animObj)));
+ return this;
+ },
+
+
+ anim: function(config) {
+ if (!Ext.isObject(config)) {
+ return (config) ? {} : false;
+ }
+
+ var me = this;
+
+ if (config.stopAnimation) {
+ me.stopAnimation();
+ }
+
+ Ext.applyIf(config, Ext.fx.Manager.getFxDefaults(me.id));
+
+ return Ext.apply({
+ target: me,
+ paused: true
+ }, config);
+ },
+
+
+ stopFx: Ext.Function.alias(Ext.util.Animate, 'stopAnimation'),
+
+
+ stopAnimation: function() {
+ Ext.fx.Manager.stopAnimation(this.id);
+ return this;
+ },
+
+
+ syncFx: function() {
+ Ext.fx.Manager.setFxDefaults(this.id, {
+ concurrent: true
+ });
+ return this;
+ },
+
+
+ sequenceFx: function() {
+ Ext.fx.Manager.setFxDefaults(this.id, {
+ concurrent: false
+ });
+ return this;
+ },
+
+
+ hasActiveFx: Ext.Function.alias(Ext.util.Animate, 'getActiveAnimation'),
+
+
+ getActiveAnimation: function() {
+ return Ext.fx.Manager.getActiveAnimation(this.id);
+ }
+}, function(){
+
+ Ext.applyIf(Ext.Element.prototype, this.prototype);
+
+ Ext.CompositeElementLite.importElementMethods();
+});
+
+Ext.define('Ext.state.Provider', {
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+
+ prefix: 'ext-',
+
+ constructor : function(config){
+ config = config || {};
+ var me = this;
+ Ext.apply(me, config);
+
+ me.addEvents("statechange");
+ me.state = {};
+ me.mixins.observable.constructor.call(me);
+ },
+
+
+ get : function(name, defaultValue){
+ return typeof this.state[name] == "undefined" ?
+ defaultValue : this.state[name];
+ },
+
+
+ clear : function(name){
+ var me = this;
+ delete me.state[name];
+ me.fireEvent("statechange", me, name, null);
+ },
+
+
+ set : function(name, value){
+ var me = this;
+ me.state[name] = value;
+ me.fireEvent("statechange", me, name, value);
+ },
+
+
+ decodeValue : function(value){
+
+
+
+
+
+
+
+
+
+ var me = this,
+ re = /^(a|n|d|b|s|o|e)\:(.*)$/,
+ matches = re.exec(unescape(value)),
+ all,
+ type,
+ value,
+ keyValue;
+
+ if(!matches || !matches[1]){
+ return;
+ }
+
+ type = matches[1];
+ value = matches[2];
+ switch (type) {
+ case 'e':
+ return null;
+ case 'n':
+ return parseFloat(value);
+ case 'd':
+ return new Date(Date.parse(value));
+ case 'b':
+ return (value == '1');
+ case 'a':
+ all = [];
+ if(value != ''){
+ Ext.each(value.split('^'), function(val){
+ all.push(me.decodeValue(val));
+ }, me);
+ }
+ return all;
+ case 'o':
+ all = {};
+ if(value != ''){
+ Ext.each(value.split('^'), function(val){
+ keyValue = val.split('=');
+ all[keyValue[0]] = me.decodeValue(keyValue[1]);
+ }, me);
+ }
+ return all;
+ default:
+ return value;
+ }
+ },
+
+
+ encodeValue : function(value){
+ var flat = '',
+ i = 0,
+ enc,
+ len,
+ key;
+
+ if (value == null) {
+ return 'e:1';
+ } else if(typeof value == 'number') {
+ enc = 'n:' + value;
+ } else if(typeof value == 'boolean') {
+ enc = 'b:' + (value ? '1' : '0');
+ } else if(Ext.isDate(value)) {
+ enc = 'd:' + value.toGMTString();
+ } else if(Ext.isArray(value)) {
+ for (len = value.length; i < len; i++) {
+ flat += this.encodeValue(value[i]);
+ if (i != len - 1) {
+ flat += '^';
+ }
+ }
+ enc = 'a:' + flat;
+ } else if (typeof value == 'object') {
+ for (key in value) {
+ if (typeof value[key] != 'function' && value[key] !== undefined) {
+ flat += key + '=' + this.encodeValue(value[key]) + '^';
+ }
+ }
+ enc = 'o:' + flat.substring(0, flat.length-1);
+ } else {
+ enc = 's:' + value;
+ }
+ return escape(enc);
+ }
+});
+
+Ext.define('Ext.ComponentQuery', {
+ singleton: true,
+ uses: ['Ext.ComponentManager']
+}, function() {
+
+ var cq = this,
+
+
+
+ filterFnPattern = [
+ 'var r = [],',
+ 'i = 0,',
+ 'it = items,',
+ 'l = it.length,',
+ 'c;',
+ 'for (; i < l; i++) {',
+ 'c = it[i];',
+ 'if (c.{0}) {',
+ 'r.push(c);',
+ '}',
+ '}',
+ 'return r;'
+ ].join(''),
+
+ filterItems = function(items, operation) {
+
+
+
+ return operation.method.apply(this, [ items ].concat(operation.args));
+ },
+
+ getItems = function(items, mode) {
+ var result = [],
+ i = 0,
+ length = items.length,
+ candidate,
+ deep = mode !== '>';
+
+ for (; i < length; i++) {
+ candidate = items[i];
+ if (candidate.getRefItems) {
+ result = result.concat(candidate.getRefItems(deep));
+ }
+ }
+ return result;
+ },
+
+ getAncestors = function(items) {
+ var result = [],
+ i = 0,
+ length = items.length,
+ candidate;
+ for (; i < length; i++) {
+ candidate = items[i];
+ while (!!(candidate = (candidate.ownerCt || candidate.floatParent))) {
+ result.push(candidate);
+ }
+ }
+ return result;
+ },
+
+
+ filterByXType = function(items, xtype, shallow) {
+ if (xtype === '*') {
+ return items.slice();
+ }
+ else {
+ var result = [],
+ i = 0,
+ length = items.length,
+ candidate;
+ for (; i < length; i++) {
+ candidate = items[i];
+ if (candidate.isXType(xtype, shallow)) {
+ result.push(candidate);
+ }
+ }
+ return result;
+ }
+ },
+
+
+ filterByClassName = function(items, className) {
+ var EA = Ext.Array,
+ result = [],
+ i = 0,
+ length = items.length,
+ candidate;
+ for (; i < length; i++) {
+ candidate = items[i];
+ if (candidate.el ? candidate.el.hasCls(className) : EA.contains(candidate.initCls(), className)) {
+ result.push(candidate);
+ }
+ }
+ return result;
+ },
+
+
+ filterByAttribute = function(items, property, operator, value) {
+ var result = [],
+ i = 0,
+ length = items.length,
+ candidate;
+ for (; i < length; i++) {
+ candidate = items[i];
+ if (!value ? !!candidate[property] : (String(candidate[property]) === value)) {
+ result.push(candidate);
+ }
+ }
+ return result;
+ },
+
+
+ filterById = function(items, id) {
+ var result = [],
+ i = 0,
+ length = items.length,
+ candidate;
+ for (; i < length; i++) {
+ candidate = items[i];
+ if (candidate.getItemId() === id) {
+ result.push(candidate);
+ }
+ }
+ return result;
+ },
+
+
+ filterByPseudo = function(items, name, value) {
+ return cq.pseudos[name](items, value);
+ },
+
+
+
+ modeRe = /^(\s?([>\^])\s?|\s|$)/,
+
+
+ tokenRe = /^(#)?([\w\-]+|\*)(?:\((true|false)\))?/,
+
+ matchers = [{
+
+ re: /^\.([\w\-]+)(?:\((true|false)\))?/,
+ method: filterByXType
+ },{
+
+ re: /^(?:[\[](?:@)?([\w\-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]])/,
+ method: filterByAttribute
+ }, {
+
+ re: /^#([\w\-]+)/,
+ method: filterById
+ }, {
+
+ re: /^\:([\w\-]+)(?:\(((?:\{[^\}]+\})|(?:(?!\{)[^\s>\/]*?(?!\})))\))?/,
+ method: filterByPseudo
+ }, {
+
+ re: /^(?:\{([^\}]+)\})/,
+ method: filterFnPattern
+ }];
+
+
+
+ cq.Query = Ext.extend(Object, {
+ constructor: function(cfg) {
+ cfg = cfg || {};
+ Ext.apply(this, cfg);
+ },
+
+
+
+
+
+
+
+
+
+ execute : function(root) {
+ var operations = this.operations,
+ i = 0,
+ length = operations.length,
+ operation,
+ workingItems;
+
+
+ if (!root) {
+ workingItems = Ext.ComponentManager.all.getArray();
+ }
+
+ else if (Ext.isArray(root)) {
+ workingItems = root;
+ }
+
+
+
+ for (; i < length; i++) {
+ operation = operations[i];
+
+
+
+
+
+
+
+ if (operation.mode === '^') {
+ workingItems = getAncestors(workingItems || [root]);
+ }
+ else if (operation.mode) {
+ workingItems = getItems(workingItems || [root], operation.mode);
+ }
+ else {
+ workingItems = filterItems(workingItems || getItems([root]), operation);
+ }
+
+
+
+ if (i === length -1) {
+ return workingItems;
+ }
+ }
+ return [];
+ },
+
+ is: function(component) {
+ var operations = this.operations,
+ components = Ext.isArray(component) ? component : [component],
+ originalLength = components.length,
+ lastOperation = operations[operations.length-1],
+ ln, i;
+
+ components = filterItems(components, lastOperation);
+ if (components.length === originalLength) {
+ if (operations.length > 1) {
+ for (i = 0, ln = components.length; i < ln; i++) {
+ if (Ext.Array.indexOf(this.execute(), components[i]) === -1) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+ });
+
+ Ext.apply(this, {
+
+
+ cache: {},
+
+
+ pseudos: {
+ not: function(components, selector){
+ var CQ = Ext.ComponentQuery,
+ i = 0,
+ length = components.length,
+ results = [],
+ index = -1,
+ component;
+
+ for(; i < length; ++i) {
+ component = components[i];
+ if (!CQ.is(component, selector)) {
+ results[++index] = component;
+ }
+ }
+ return results;
+ },
+ last: function(components) {
+ return components[components.length - 1];
+ }
+ },
+
+
+ query: function(selector, root) {
+ var selectors = selector.split(','),
+ length = selectors.length,
+ i = 0,
+ results = [],
+ noDupResults = [],
+ dupMatcher = {},
+ query, resultsLn, cmp;
+
+ for (; i < length; i++) {
+ selector = Ext.String.trim(selectors[i]);
+ query = this.cache[selector];
+ if (!query) {
+ this.cache[selector] = query = this.parse(selector);
+ }
+ results = results.concat(query.execute(root));
+ }
+
+
+
+ if (length > 1) {
+ resultsLn = results.length;
+ for (i = 0; i < resultsLn; i++) {
+ cmp = results[i];
+ if (!dupMatcher[cmp.id]) {
+ noDupResults.push(cmp);
+ dupMatcher[cmp.id] = true;
+ }
+ }
+ results = noDupResults;
+ }
+ return results;
+ },
+
+
+ is: function(component, selector) {
+ if (!selector) {
+ return true;
+ }
+ var query = this.cache[selector];
+ if (!query) {
+ this.cache[selector] = query = this.parse(selector);
+ }
+ return query.is(component);
+ },
+
+ parse: function(selector) {
+ var operations = [],
+ length = matchers.length,
+ lastSelector,
+ tokenMatch,
+ matchedChar,
+ modeMatch,
+ selectorMatch,
+ i, matcher, method;
+
+
+
+
+ while (selector && lastSelector !== selector) {
+ lastSelector = selector;
+
+
+ tokenMatch = selector.match(tokenRe);
+
+ if (tokenMatch) {
+ matchedChar = tokenMatch[1];
+
+
+ if (matchedChar === '#') {
+ operations.push({
+ method: filterById,
+ args: [Ext.String.trim(tokenMatch[2])]
+ });
+ }
+
+
+ else if (matchedChar === '.') {
+ operations.push({
+ method: filterByClassName,
+ args: [Ext.String.trim(tokenMatch[2])]
+ });
+ }
+
+
+ else {
+ operations.push({
+ method: filterByXType,
+ args: [Ext.String.trim(tokenMatch[2]), Boolean(tokenMatch[3])]
+ });
+ }
+
+
+ selector = selector.replace(tokenMatch[0], '');
+ }
+
+
+
+
+ while (!(modeMatch = selector.match(modeRe))) {
+
+
+ for (i = 0; selector && i < length; i++) {
+ matcher = matchers[i];
+ selectorMatch = selector.match(matcher.re);
+ method = matcher.method;
+
+
+
+
+ if (selectorMatch) {
+ operations.push({
+ method: Ext.isString(matcher.method)
+
+
+
+ ? Ext.functionFactory('items', Ext.String.format.apply(Ext.String, [method].concat(selectorMatch.slice(1))))
+ : matcher.method,
+ args: selectorMatch.slice(1)
+ });
+ selector = selector.replace(selectorMatch[0], '');
+ break;
+ }
+ }
+ }
+
+
+
+
+
+ if (modeMatch[1]) {
+ operations.push({
+ mode: modeMatch[2]||modeMatch[1]
+ });
+ selector = selector.replace(modeMatch[0], '');
+ }
+ }
+
+
+
+ return new cq.Query({
+ operations: operations
+ });
+ }
+ });
+});
+
+Ext.define('Ext.util.HashMap', {
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+
+
+
+ constructor: function(config) {
+ config = config || {};
+
+ var me = this,
+ keyFn = config.keyFn;
+
+ me.addEvents(
+
+ 'add',
+
+ 'clear',
+
+ 'remove',
+
+ 'replace'
+ );
+
+ me.mixins.observable.constructor.call(me, config);
+ me.clear(true);
+
+ if (keyFn) {
+ me.getKey = keyFn;
+ }
+ },
+
+
+ getCount: function() {
+ return this.length;
+ },
+
+
+ getData: function(key, value) {
+
+ if (value === undefined) {
+ value = key;
+ key = this.getKey(value);
+ }
+
+ return [key, value];
+ },
+
+
+ getKey: function(o) {
+ return o.id;
+ },
+
+
+ add: function(key, value) {
+ var me = this,
+ data;
+
+ if (arguments.length === 1) {
+ value = key;
+ key = me.getKey(value);
+ }
+
+ if (me.containsKey(key)) {
+ return me.replace(key, value);
+ }
+
+ data = me.getData(key, value);
+ key = data[0];
+ value = data[1];
+ me.map[key] = value;
+ ++me.length;
+ me.fireEvent('add', me, key, value);
+ return value;
+ },
+
+
+ replace: function(key, value) {
+ var me = this,
+ map = me.map,
+ old;
+
+ if (!me.containsKey(key)) {
+ me.add(key, value);
+ }
+ old = map[key];
+ map[key] = value;
+ me.fireEvent('replace', me, key, value, old);
+ return value;
+ },
+
+
+ remove: function(o) {
+ var key = this.findKey(o);
+ if (key !== undefined) {
+ return this.removeAtKey(key);
+ }
+ return false;
+ },
+
+
+ removeAtKey: function(key) {
+ var me = this,
+ value;
+
+ if (me.containsKey(key)) {
+ value = me.map[key];
+ delete me.map[key];
+ --me.length;
+ me.fireEvent('remove', me, key, value);
+ return true;
+ }
+ return false;
+ },
+
+
+ get: function(key) {
+ return this.map[key];
+ },
+
+
+ clear: function( initial) {
+ var me = this;
+ me.map = {};
+ me.length = 0;
+ if (initial !== true) {
+ me.fireEvent('clear', me);
+ }
+ return me;
+ },
+
+
+ containsKey: function(key) {
+ return this.map[key] !== undefined;
+ },
+
+
+ contains: function(value) {
+ return this.containsKey(this.findKey(value));
+ },
+
+
+ getKeys: function() {
+ return this.getArray(true);
+ },
+
+
+ getValues: function() {
+ return this.getArray(false);
+ },
+
+
+ getArray: function(isKey) {
+ var arr = [],
+ key,
+ map = this.map;
+ for (key in map) {
+ if (map.hasOwnProperty(key)) {
+ arr.push(isKey ? key: map[key]);
+ }
+ }
+ return arr;
+ },
+
+
+ each: function(fn, scope) {
+
+ var items = Ext.apply({}, this.map),
+ key,
+ length = this.length;
+
+ scope = scope || this;
+ for (key in items) {
+ if (items.hasOwnProperty(key)) {
+ if (fn.call(scope, key, items[key], length) === false) {
+ break;
+ }
+ }
+ }
+ return this;
+ },
+
+
+ clone: function() {
+ var hash = new this.self(),
+ map = this.map,
+ key;
+
+ hash.suspendEvents();
+ for (key in map) {
+ if (map.hasOwnProperty(key)) {
+ hash.add(key, map[key]);
+ }
+ }
+ hash.resumeEvents();
+ return hash;
+ },
+
+
+ findKey: function(value) {
+ var key,
+ map = this.map;
+
+ for (key in map) {
+ if (map.hasOwnProperty(key) && map[key] === value) {
+ return key;
+ }
+ }
+ return undefined;
+ }
+});
+
+
+Ext.define('Ext.state.Manager', {
+ singleton: true,
+ requires: ['Ext.state.Provider'],
+ constructor: function() {
+ this.provider = Ext.create('Ext.state.Provider');
+ },
+
+
+
+ setProvider : function(stateProvider){
+ this.provider = stateProvider;
+ },
+
+
+ get : function(key, defaultValue){
+ return this.provider.get(key, defaultValue);
+ },
+
+
+ set : function(key, value){
+ this.provider.set(key, value);
+ },
+
+
+ clear : function(key){
+ this.provider.clear(key);
+ },
+
+
+ getProvider : function(){
+ return this.provider;
+ }
+});
+
+Ext.define('Ext.state.Stateful', {
+
+
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ requires: ['Ext.state.Manager'],
+
+
+
+
+ stateful: true,
+
+
+
+
+
+
+ saveDelay: 100,
+
+ autoGenIdRe: /^((\w+-)|(ext-comp-))\d{4,}$/i,
+
+ constructor: function(config) {
+ var me = this;
+
+ config = config || {};
+ if (Ext.isDefined(config.stateful)) {
+ me.stateful = config.stateful;
+ }
+ if (Ext.isDefined(config.saveDelay)) {
+ me.saveDelay = config.saveDelay;
+ }
+ me.stateId = me.stateId || config.stateId;
+
+ if (!me.stateEvents) {
+ me.stateEvents = [];
+ }
+ if (config.stateEvents) {
+ me.stateEvents.concat(config.stateEvents);
+ }
+ this.addEvents(
+
+ 'beforestaterestore',
+
+
+ 'staterestore',
+
+
+ 'beforestatesave',
+
+
+ 'statesave'
+ );
+ me.mixins.observable.constructor.call(me);
+ if (me.stateful !== false) {
+ me.initStateEvents();
+ me.initState();
+ }
+ },
+
+
+ initStateEvents: function() {
+ this.addStateEvents(this.stateEvents);
+ },
+
+
+ addStateEvents: function(events){
+ if (!Ext.isArray(events)) {
+ events = [events];
+ }
+
+ var me = this,
+ i = 0,
+ len = events.length;
+
+ for (; i < len; ++i) {
+ me.on(events[i], me.onStateChange, me);
+ }
+ },
+
+
+ onStateChange: function(){
+ var me = this,
+ delay = me.saveDelay;
+
+ if (delay > 0) {
+ if (!me.stateTask) {
+ me.stateTask = Ext.create('Ext.util.DelayedTask', me.saveState, me);
+ }
+ me.stateTask.delay(me.saveDelay);
+ } else {
+ me.saveState();
+ }
+ },
+
+
+ saveState: function() {
+ var me = this,
+ id,
+ state;
+
+ if (me.stateful !== false) {
+ id = me.getStateId();
+ if (id) {
+ state = me.getState();
+ if (me.fireEvent('beforestatesave', me, state) !== false) {
+ Ext.state.Manager.set(id, state);
+ me.fireEvent('statesave', me, state);
+ }
+ }
+ }
+ },
+
+
+ getState: function(){
+ return null;
+ },
+
+
+ applyState: function(state) {
+ if (state) {
+ Ext.apply(this, state);
+ }
+ },
+
+
+ getStateId: function() {
+ var me = this,
+ id = me.stateId;
+
+ if (!id) {
+ id = me.autoGenIdRe.test(String(me.id)) ? null : me.id;
+ }
+ return id;
+ },
+
+
+ initState: function(){
+ var me = this,
+ id = me.getStateId(),
+ state;
+
+ if (me.stateful !== false) {
+ if (id) {
+ state = Ext.state.Manager.get(id);
+ if (state) {
+ state = Ext.apply({}, state);
+ if (me.fireEvent('beforestaterestore', me, state) !== false) {
+ me.applyState(state);
+ me.fireEvent('staterestore', me, state);
+ }
+ }
+ }
+ }
+ },
+
+
+ savePropToState: function (propName, state, stateName) {
+ var me = this,
+ value = me[propName],
+ config = me.initialConfig;
+
+ if (me.hasOwnProperty(propName)) {
+ if (!config || config[propName] !== value) {
+ if (state) {
+ state[stateName || propName] = value;
+ }
+ return true;
+ }
+ }
+ return false;
+ },
+
+ savePropsToState: function (propNames, state) {
+ var me = this;
+ Ext.each(propNames, function (propName) {
+ me.savePropToState(propName, state);
+ });
+ return state;
+ },
+
+
+ destroy: function(){
+ var task = this.stateTask;
+ if (task) {
+ task.cancel();
+ }
+ this.clearListeners();
+
+ }
+
+});
+
+
+Ext.define('Ext.AbstractManager', {
+
+
+
+ requires: ['Ext.util.HashMap'],
+
+
+
+ typeName: 'type',
+
+ constructor: function(config) {
+ Ext.apply(this, config || {});
+
+
+ this.all = Ext.create('Ext.util.HashMap');
+
+ this.types = {};
+ },
+
+
+ get : function(id) {
+ return this.all.get(id);
+ },
+
+
+ register: function(item) {
+ this.all.add(item);
+ },
+
+
+ unregister: function(item) {
+ this.all.remove(item);
+ },
+
+
+ registerType : function(type, cls) {
+ this.types[type] = cls;
+ cls[this.typeName] = type;
+ },
+
+
+ isRegistered : function(type){
+ return this.types[type] !== undefined;
+ },
+
+
+ create: function(config, defaultType) {
+ var type = config[this.typeName] || config.type || defaultType,
+ Constructor = this.types[type];
+
+
+ return new Constructor(config);
+ },
+
+
+ onAvailable : function(id, fn, scope){
+ var all = this.all,
+ item;
+
+ if (all.containsKey(id)) {
+ item = all.get(id);
+ fn.call(scope || item, item);
+ } else {
+ all.on('add', function(map, key, item){
+ if (key == id) {
+ fn.call(scope || item, item);
+ all.un('add', fn, scope);
+ }
+ });
+ }
+ },
+
+
+ each: function(fn, scope){
+ this.all.each(fn, scope || this);
+ },
+
+
+ getCount: function(){
+ return this.all.getCount();
+ }
+});
+
+
+Ext.define('Ext.ComponentManager', {
+ extend: 'Ext.AbstractManager',
+ alternateClassName: 'Ext.ComponentMgr',
+
+ singleton: true,
+
+ typeName: 'xtype',
+
+
+ create: function(component, defaultType){
+ if (component instanceof Ext.AbstractComponent) {
+ return component;
+ }
+ else if (Ext.isString(component)) {
+ return Ext.createByAlias('widget.' + component);
+ }
+ else {
+ var type = component.xtype || defaultType,
+ config = component;
+
+ return Ext.createByAlias('widget.' + type, config);
+ }
+ },
+
+ registerType: function(type, cls) {
+ this.types[type] = cls;
+ cls[this.typeName] = type;
+ cls.prototype[this.typeName] = type;
+ }
+});
+
+Ext.define('Ext.AbstractComponent', {
+
+
+ requires: [
+ 'Ext.ComponentQuery',
+ 'Ext.ComponentManager'
+ ],
+
+ mixins: {
+ observable: 'Ext.util.Observable',
+ animate: 'Ext.util.Animate',
+ state: 'Ext.state.Stateful'
+ },
+
+
+
+ uses: [
+ 'Ext.PluginManager',
+ 'Ext.ComponentManager',
+ 'Ext.Element',
+ 'Ext.DomHelper',
+ 'Ext.XTemplate',
+ 'Ext.ComponentQuery',
+ 'Ext.ComponentLoader',
+ 'Ext.EventManager',
+ 'Ext.layout.Layout',
+ 'Ext.layout.component.Auto',
+ 'Ext.LoadMask',
+ 'Ext.ZIndexManager'
+ ],
+
+ statics: {
+ AUTO_ID: 1000
+ },
+
+
+
+ isComponent: true,
+
+ getAutoId: function() {
+ return ++Ext.AbstractComponent.AUTO_ID;
+ },
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ renderTpl: null,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ tplWriteMode: 'overwrite',
+
+
+ baseCls: Ext.baseCSSPrefix + 'component',
+
+
+
+
+
+
+
+
+ disabledCls: Ext.baseCSSPrefix + 'item-disabled',
+
+
+ ui: 'default',
+
+
+ uiCls: [],
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ hidden: false,
+
+
+ disabled: false,
+
+
+
+
+ draggable: false,
+
+
+ floating: false,
+
+
+ hideMode: 'display',
+
+
+
+
+
+
+ styleHtmlContent: false,
+
+
+ styleHtmlCls: Ext.baseCSSPrefix + 'html',
+
+
+
+
+
+
+
+
+
+ autoShow: false,
+
+
+ autoRender: false,
+
+ needsLayout: false,
+
+
+ allowDomMove: true,
+
+
+
+
+ rendered: false,
+
+
+ componentLayoutCounter: 0,
+
+ weight: 0,
+
+ trimRe: /^\s+|\s+$/g,
+ spacesRe: /\s+/,
+
+
+
+ maskOnDisable: true,
+
+
+ constructor : function(config) {
+ var me = this,
+ i, len;
+
+ config = config || {};
+ me.initialConfig = config;
+ Ext.apply(me, config);
+
+ me.addEvents(
+
+ 'beforeactivate',
+
+ 'activate',
+
+ 'beforedeactivate',
+
+ 'deactivate',
+
+ 'added',
+
+ 'disable',
+
+ 'enable',
+
+ 'beforeshow',
+
+ 'show',
+
+ 'beforehide',
+
+ 'hide',
+
+ 'removed',
+
+ 'beforerender',
+
+ 'render',
+
+ 'afterrender',
+
+ 'beforedestroy',
+
+ 'destroy',
+
+ 'resize',
+
+ 'move'
+ );
+
+ me.getId();
+
+ me.mons = [];
+ me.additionalCls = [];
+ me.renderData = me.renderData || {};
+ me.renderSelectors = me.renderSelectors || {};
+
+ if (me.plugins) {
+ me.plugins = [].concat(me.plugins);
+ me.constructPlugins();
+ }
+
+ me.initComponent();
+
+
+ Ext.ComponentManager.register(me);
+
+
+ me.mixins.observable.constructor.call(me);
+ me.mixins.state.constructor.call(me, config);
+
+
+ this.addStateEvents('resize');
+
+
+ if (me.plugins) {
+ me.plugins = [].concat(me.plugins);
+ for (i = 0, len = me.plugins.length; i < len; i++) {
+ me.plugins[i] = me.initPlugin(me.plugins[i]);
+ }
+ }
+
+ me.loader = me.getLoader();
+
+ if (me.renderTo) {
+ me.render(me.renderTo);
+
+
+
+ }
+
+ if (me.autoShow) {
+ me.show();
+ }
+
+ },
+
+ initComponent: function () {
+
+
+ this.constructPlugins();
+ },
+
+
+ getState: function() {
+ var me = this,
+ layout = me.ownerCt ? (me.shadowOwnerCt || me.ownerCt).getLayout() : null,
+ state = {
+ collapsed: me.collapsed
+ },
+ width = me.width,
+ height = me.height,
+ cm = me.collapseMemento,
+ anchors;
+
+
+
+ if (me.collapsed && cm) {
+ if (Ext.isDefined(cm.data.width)) {
+ width = cm.width;
+ }
+ if (Ext.isDefined(cm.data.height)) {
+ height = cm.height;
+ }
+ }
+
+
+ if (layout && me.flex) {
+ state.flex = me.flex;
+ if (layout.perpendicularPrefix) {
+ state[layout.perpendicularPrefix] = me['get' + layout.perpendicularPrefixCap]();
+ } else {
+ }
+ }
+
+ else if (layout && me.anchor) {
+ state.anchor = me.anchor;
+ anchors = me.anchor.split(' ').concat(null);
+ if (!anchors[0]) {
+ if (me.width) {
+ state.width = width;
+ }
+ }
+ if (!anchors[1]) {
+ if (me.height) {
+ state.height = height;
+ }
+ }
+ }
+
+ else {
+ if (me.width) {
+ state.width = width;
+ }
+ if (me.height) {
+ state.height = height;
+ }
+ }
+
+
+ if (state.width == me.initialConfig.width) {
+ delete state.width;
+ }
+ if (state.height == me.initialConfig.height) {
+ delete state.height;
+ }
+
+
+ if (layout && layout.align && (layout.align.indexOf('stretch') !== -1)) {
+ delete state[layout.perpendicularPrefix];
+ }
+ return state;
+ },
+
+ show: Ext.emptyFn,
+
+ animate: function(animObj) {
+ var me = this,
+ to;
+
+ animObj = animObj || {};
+ to = animObj.to || {};
+
+ if (Ext.fx.Manager.hasFxBlock(me.id)) {
+ return me;
+ }
+
+ if (!animObj.dynamic && (to.height || to.width)) {
+ var curWidth = me.getWidth(),
+ w = curWidth,
+ curHeight = me.getHeight(),
+ h = curHeight,
+ needsResize = false;
+
+ if (to.height && to.height > curHeight) {
+ h = to.height;
+ needsResize = true;
+ }
+ if (to.width && to.width > curWidth) {
+ w = to.width;
+ needsResize = true;
+ }
+
+
+
+
+ if (needsResize) {
+ var clearWidth = !Ext.isNumber(me.width),
+ clearHeight = !Ext.isNumber(me.height);
+
+ me.componentLayout.childrenChanged = true;
+ me.setSize(w, h, me.ownerCt);
+ me.el.setSize(curWidth, curHeight);
+ if (clearWidth) {
+ delete me.width;
+ }
+ if (clearHeight) {
+ delete me.height;
+ }
+ }
+ }
+ return me.mixins.animate.animate.apply(me, arguments);
+ },
+
+
+ findLayoutController: function() {
+ return this.findParentBy(function(c) {
+
+
+ return !c.ownerCt || (c.layout.layoutBusy && !c.ownerCt.layout.layoutBusy);
+ });
+ },
+
+ onShow : function() {
+
+ var needsLayout = this.needsLayout;
+ if (Ext.isObject(needsLayout)) {
+ this.doComponentLayout(needsLayout.width, needsLayout.height, needsLayout.isSetSize, needsLayout.ownerCt);
+ }
+ },
+
+ constructPlugin: function(plugin) {
+ if (plugin.ptype && typeof plugin.init != 'function') {
+ plugin.cmp = this;
+ plugin = Ext.PluginManager.create(plugin);
+ }
+ else if (typeof plugin == 'string') {
+ plugin = Ext.PluginManager.create({
+ ptype: plugin,
+ cmp: this
+ });
+ }
+ return plugin;
+ },
+
+
+ constructPlugins: function() {
+ var me = this,
+ plugins = me.plugins,
+ i, len;
+
+ if (plugins) {
+ for (i = 0, len = plugins.length; i < len; i++) {
+
+ plugins[i] = me.constructPlugin(plugins[i]);
+ }
+ }
+ },
+
+
+ initPlugin : function(plugin) {
+ plugin.init(this);
+
+ return plugin;
+ },
+
+
+ doAutoRender: function() {
+ var me = this;
+ if (me.floating) {
+ me.render(document.body);
+ } else {
+ me.render(Ext.isBoolean(me.autoRender) ? Ext.getBody() : me.autoRender);
+ }
+ },
+
+
+ render : function(container, position) {
+ var me = this;
+
+ if (!me.rendered && me.fireEvent('beforerender', me) !== false) {
+
+
+
+ me.rendering = true;
+
+
+
+ if (me.el) {
+ me.el = Ext.get(me.el);
+ }
+
+
+ if (me.floating) {
+ me.onFloatRender();
+ }
+
+ container = me.initContainer(container);
+
+ me.onRender(container, position);
+
+
+
+ me.el.setVisibilityMode(Ext.Element[me.hideMode.toUpperCase()]);
+
+ if (me.overCls) {
+ me.el.hover(me.addOverCls, me.removeOverCls, me);
+ }
+
+ me.fireEvent('render', me);
+
+ me.initContent();
+
+ me.afterRender(container);
+ me.fireEvent('afterrender', me);
+
+ me.initEvents();
+
+ if (me.hidden) {
+
+
+
+ me.el.hide();
+ }
+
+ if (me.disabled) {
+
+ me.disable(true);
+ }
+
+
+ delete me.rendering;
+ }
+ return me;
+ },
+
+
+ onRender : function(container, position) {
+ var me = this,
+ el = me.el,
+ styles = me.initStyles(),
+ renderTpl, renderData, i;
+
+ position = me.getInsertPosition(position);
+
+ if (!el) {
+ if (position) {
+ el = Ext.DomHelper.insertBefore(position, me.getElConfig(), true);
+ }
+ else {
+ el = Ext.DomHelper.append(container, me.getElConfig(), true);
+ }
+ }
+ else if (me.allowDomMove !== false) {
+ if (position) {
+ container.dom.insertBefore(el.dom, position);
+ } else {
+ container.dom.appendChild(el.dom);
+ }
+ }
+
+ if (Ext.scopeResetCSS && !me.ownerCt) {
+
+ if (el.dom == Ext.getBody().dom) {
+ el.parent().addCls(Ext.baseCSSPrefix + 'reset');
+ }
+ else {
+
+ me.resetEl = el.wrap({
+ cls: Ext.baseCSSPrefix + 'reset'
+ });
+ }
+ }
+
+ me.setUI(me.ui);
+
+ el.addCls(me.initCls());
+ el.setStyle(styles);
+
+
+
+
+
+
+
+
+
+
+
+
+ me.el = el;
+
+ me.initFrame();
+
+ renderTpl = me.initRenderTpl();
+ if (renderTpl) {
+ renderData = me.initRenderData();
+ renderTpl.append(me.getTargetEl(), renderData);
+ }
+
+ me.applyRenderSelectors();
+
+ me.rendered = true;
+ },
+
+
+ afterRender : function() {
+ var me = this,
+ pos,
+ xy;
+
+ me.getComponentLayout();
+
+
+
+
+ if (me.collapsed || (!me.ownerCt || (me.height || me.width))) {
+ me.setSize(me.width, me.height);
+ } else {
+
+
+
+
+ me.renderChildren();
+ }
+
+
+
+ if (me.floating && (me.x === undefined || me.y === undefined)) {
+ if (me.floatParent) {
+ xy = me.el.getAlignToXY(me.floatParent.getTargetEl(), 'c-c');
+ pos = me.floatParent.getTargetEl().translatePoints(xy[0], xy[1]);
+ } else {
+ xy = me.el.getAlignToXY(me.container, 'c-c');
+ pos = me.container.translatePoints(xy[0], xy[1]);
+ }
+ me.x = me.x === undefined ? pos.left: me.x;
+ me.y = me.y === undefined ? pos.top: me.y;
+ }
+
+ if (Ext.isDefined(me.x) || Ext.isDefined(me.y)) {
+ me.setPosition(me.x, me.y);
+ }
+
+ if (me.styleHtmlContent) {
+ me.getTargetEl().addCls(me.styleHtmlCls);
+ }
+ },
+
+
+ registerFloatingItem: function(cmp) {
+ var me = this;
+ if (!me.floatingItems) {
+ me.floatingItems = Ext.create('Ext.ZIndexManager', me);
+ }
+ me.floatingItems.register(cmp);
+ },
+
+ renderChildren: function () {
+ var me = this,
+ layout = me.getComponentLayout();
+
+ me.suspendLayout = true;
+ layout.renderChildren();
+ delete me.suspendLayout;
+ },
+
+ frameCls: Ext.baseCSSPrefix + 'frame',
+
+ frameIdRegex: /[-]frame\d+[TMB][LCR]$/,
+
+ frameElementCls: {
+ tl: [],
+ tc: [],
+ tr: [],
+ ml: [],
+ mc: [],
+ mr: [],
+ bl: [],
+ bc: [],
+ br: []
+ },
+
+ frameTpl: [
+ '<tpl if="top">',
+ '<tpl if="left"><div id="{fgid}TL" class="{frameCls}-tl {baseCls}-tl {baseCls}-{ui}-tl<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-tl</tpl></tpl>" style="background-position: {tl}; padding-left: {frameWidth}px" role="presentation"></tpl>',
+ '<tpl if="right"><div id="{fgid}TR" class="{frameCls}-tr {baseCls}-tr {baseCls}-{ui}-tr<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-tr</tpl></tpl>" style="background-position: {tr}; padding-right: {frameWidth}px" role="presentation"></tpl>',
+ '<div id="{fgid}TC" class="{frameCls}-tc {baseCls}-tc {baseCls}-{ui}-tc<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-tc</tpl></tpl>" style="background-position: {tc}; height: {frameWidth}px" role="presentation"></div>',
+ '<tpl if="right"></div></tpl>',
+ '<tpl if="left"></div></tpl>',
+ '</tpl>',
+ '<tpl if="left"><div id="{fgid}ML" class="{frameCls}-ml {baseCls}-ml {baseCls}-{ui}-ml<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-ml</tpl></tpl>" style="background-position: {ml}; padding-left: {frameWidth}px" role="presentation"></tpl>',
+ '<tpl if="right"><div id="{fgid}MR" class="{frameCls}-mr {baseCls}-mr {baseCls}-{ui}-mr<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-mr</tpl></tpl>" style="background-position: {mr}; padding-right: {frameWidth}px" role="presentation"></tpl>',
+ '<div id="{fgid}MC" class="{frameCls}-mc {baseCls}-mc {baseCls}-{ui}-mc<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-mc</tpl></tpl>" role="presentation"></div>',
+ '<tpl if="right"></div></tpl>',
+ '<tpl if="left"></div></tpl>',
+ '<tpl if="bottom">',
+ '<tpl if="left"><div id="{fgid}BL" class="{frameCls}-bl {baseCls}-bl {baseCls}-{ui}-bl<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-bl</tpl></tpl>" style="background-position: {bl}; padding-left: {frameWidth}px" role="presentation"></tpl>',
+ '<tpl if="right"><div id="{fgid}BR" class="{frameCls}-br {baseCls}-br {baseCls}-{ui}-br<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-br</tpl></tpl>" style="background-position: {br}; padding-right: {frameWidth}px" role="presentation"></tpl>',
+ '<div id="{fgid}BC" class="{frameCls}-bc {baseCls}-bc {baseCls}-{ui}-bc<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-bc</tpl></tpl>" style="background-position: {bc}; height: {frameWidth}px" role="presentation"></div>',
+ '<tpl if="right"></div></tpl>',
+ '<tpl if="left"></div></tpl>',
+ '</tpl>'
+ ],
+
+ frameTableTpl: [
+ '<table><tbody>',
+ '<tpl if="top">',
+ '<tr>',
+ '<tpl if="left"><td id="{fgid}TL" class="{frameCls}-tl {baseCls}-tl {baseCls}-{ui}-tl<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-tl</tpl></tpl>" style="background-position: {tl}; padding-left:{frameWidth}px" role="presentation"></td></tpl>',
+ '<td id="{fgid}TC" class="{frameCls}-tc {baseCls}-tc {baseCls}-{ui}-tc<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-tc</tpl></tpl>" style="background-position: {tc}; height: {frameWidth}px" role="presentation"></td>',
+ '<tpl if="right"><td id="{fgid}TR" class="{frameCls}-tr {baseCls}-tr {baseCls}-{ui}-tr<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-tr</tpl></tpl>" style="background-position: {tr}; padding-left: {frameWidth}px" role="presentation"></td></tpl>',
+ '</tr>',
+ '</tpl>',
+ '<tr>',
+ '<tpl if="left"><td id="{fgid}ML" class="{frameCls}-ml {baseCls}-ml {baseCls}-{ui}-ml<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-ml</tpl></tpl>" style="background-position: {ml}; padding-left: {frameWidth}px" role="presentation"></td></tpl>',
+ '<td id="{fgid}MC" class="{frameCls}-mc {baseCls}-mc {baseCls}-{ui}-mc<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-mc</tpl></tpl>" style="background-position: 0 0;" role="presentation"></td>',
+ '<tpl if="right"><td id="{fgid}MR" class="{frameCls}-mr {baseCls}-mr {baseCls}-{ui}-mr<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-mr</tpl></tpl>" style="background-position: {mr}; padding-left: {frameWidth}px" role="presentation"></td></tpl>',
+ '</tr>',
+ '<tpl if="bottom">',
+ '<tr>',
+ '<tpl if="left"><td id="{fgid}BL" class="{frameCls}-bl {baseCls}-bl {baseCls}-{ui}-bl<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-bl</tpl></tpl>" style="background-position: {bl}; padding-left: {frameWidth}px" role="presentation"></td></tpl>',
+ '<td id="{fgid}BC" class="{frameCls}-bc {baseCls}-bc {baseCls}-{ui}-bc<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-bc</tpl></tpl>" style="background-position: {bc}; height: {frameWidth}px" role="presentation"></td>',
+ '<tpl if="right"><td id="{fgid}BR" class="{frameCls}-br {baseCls}-br {baseCls}-{ui}-br<tpl if="uiCls"><tpl for="uiCls"> {parent.baseCls}-{parent.ui}-{.}-br</tpl></tpl>" style="background-position: {br}; padding-left: {frameWidth}px" role="presentation"></td></tpl>',
+ '</tr>',
+ '</tpl>',
+ '</tbody></table>'
+ ],
+
+
+ initFrame : function() {
+ if (Ext.supports.CSS3BorderRadius) {
+ return false;
+ }
+
+ var me = this,
+ frameInfo = me.getFrameInfo(),
+ frameWidth = frameInfo.width,
+ frameTpl = me.getFrameTpl(frameInfo.table),
+ frameGenId;
+
+ if (me.frame) {
+
+
+ me.frameGenId = frameGenId = (me.frameGenId || 0) + 1;
+ frameGenId = me.id + '-frame' + frameGenId;
+
+
+ frameTpl.insertFirst(me.el, Ext.apply({}, {
+ fgid: frameGenId,
+ ui: me.ui,
+ uiCls: me.uiCls,
+ frameCls: me.frameCls,
+ baseCls: me.baseCls,
+ frameWidth: frameWidth,
+ top: !!frameInfo.top,
+ left: !!frameInfo.left,
+ right: !!frameInfo.right,
+ bottom: !!frameInfo.bottom
+ }, me.getFramePositions(frameInfo)));
+
+
+ me.frameBody = me.el.down('.' + me.frameCls + '-mc');
+
+
+ me.removeChildEls(function (c) {
+ return c.id && me.frameIdRegex.test(c.id);
+ });
+
+
+ Ext.each(['TL','TC','TR','ML','MC','MR','BL','BC','BR'], function (suffix) {
+ me.childEls.push({ name: 'frame' + suffix, id: frameGenId + suffix });
+ });
+ }
+ },
+
+ updateFrame: function() {
+ if (Ext.supports.CSS3BorderRadius) {
+ return false;
+ }
+
+ var me = this,
+ wasTable = this.frameSize && this.frameSize.table,
+ oldFrameTL = this.frameTL,
+ oldFrameBL = this.frameBL,
+ oldFrameML = this.frameML,
+ oldFrameMC = this.frameMC,
+ newMCClassName;
+
+ this.initFrame();
+
+ if (oldFrameMC) {
+ if (me.frame) {
+
+ delete me.frameTL;
+ delete me.frameTC;
+ delete me.frameTR;
+ delete me.frameML;
+ delete me.frameMC;
+ delete me.frameMR;
+ delete me.frameBL;
+ delete me.frameBC;
+ delete me.frameBR;
+ this.applyRenderSelectors();
+
+
+ newMCClassName = this.frameMC.dom.className;
+
+
+ oldFrameMC.insertAfter(this.frameMC);
+ this.frameMC.remove();
+
+
+ this.frameBody = this.frameMC = oldFrameMC;
+
+
+ oldFrameMC.dom.className = newMCClassName;
+
+
+ if (wasTable) {
+ me.el.query('> table')[1].remove();
+ }
+ else {
+ if (oldFrameTL) {
+ oldFrameTL.remove();
+ }
+ if (oldFrameBL) {
+ oldFrameBL.remove();
+ }
+ oldFrameML.remove();
+ }
+ }
+ else {
+
+
+ }
+ }
+ else if (me.frame) {
+ this.applyRenderSelectors();
+ }
+ },
+
+ getFrameInfo: function() {
+ if (Ext.supports.CSS3BorderRadius) {
+ return false;
+ }
+
+ var me = this,
+ left = me.el.getStyle('background-position-x'),
+ top = me.el.getStyle('background-position-y'),
+ info, frameInfo = false, max;
+
+
+
+ if (!left && !top) {
+ info = me.el.getStyle('background-position').split(' ');
+ left = info[0];
+ top = info[1];
+ }
+
+
+
+
+ if (parseInt(left, 10) >= 1000000 && parseInt(top, 10) >= 1000000) {
+ max = Math.max;
+
+ frameInfo = {
+
+ table: left.substr(0, 3) == '110',
+
+
+ vertical: top.substr(0, 3) == '110',
+
+
+ top: max(left.substr(3, 2), left.substr(5, 2)),
+ right: max(left.substr(5, 2), top.substr(3, 2)),
+ bottom: max(top.substr(3, 2), top.substr(5, 2)),
+ left: max(top.substr(5, 2), left.substr(3, 2))
+ };
+
+ frameInfo.width = max(frameInfo.top, frameInfo.right, frameInfo.bottom, frameInfo.left);
+
+
+ me.el.setStyle('background-image', 'none');
+ }
+
+
+
+ if (me.frame === true && !frameInfo) {
+ }
+
+ me.frame = me.frame || !!frameInfo;
+ me.frameSize = frameInfo || false;
+
+ return frameInfo;
+ },
+
+ getFramePositions: function(frameInfo) {
+ var me = this,
+ frameWidth = frameInfo.width,
+ dock = me.dock,
+ positions, tc, bc, ml, mr;
+
+ if (frameInfo.vertical) {
+ tc = '0 -' + (frameWidth * 0) + 'px';
+ bc = '0 -' + (frameWidth * 1) + 'px';
+
+ if (dock && dock == "right") {
+ tc = 'right -' + (frameWidth * 0) + 'px';
+ bc = 'right -' + (frameWidth * 1) + 'px';
+ }
+
+ positions = {
+ tl: '0 -' + (frameWidth * 0) + 'px',
+ tr: '0 -' + (frameWidth * 1) + 'px',
+ bl: '0 -' + (frameWidth * 2) + 'px',
+ br: '0 -' + (frameWidth * 3) + 'px',
+
+ ml: '-' + (frameWidth * 1) + 'px 0',
+ mr: 'right 0',
+
+ tc: tc,
+ bc: bc
+ };
+ } else {
+ ml = '-' + (frameWidth * 0) + 'px 0';
+ mr = 'right 0';
+
+ if (dock && dock == "bottom") {
+ ml = 'left bottom';
+ mr = 'right bottom';
+ }
+
+ positions = {
+ tl: '0 -' + (frameWidth * 2) + 'px',
+ tr: 'right -' + (frameWidth * 3) + 'px',
+ bl: '0 -' + (frameWidth * 4) + 'px',
+ br: 'right -' + (frameWidth * 5) + 'px',
+
+ ml: ml,
+ mr: mr,
+
+ tc: '0 -' + (frameWidth * 0) + 'px',
+ bc: '0 -' + (frameWidth * 1) + 'px'
+ };
+ }
+
+ return positions;
+ },
+
+
+ getFrameTpl : function(table) {
+ return table ? this.getTpl('frameTableTpl') : this.getTpl('frameTpl');
+ },
+
+
+ initCls: function() {
+ var me = this,
+ cls = [];
+
+ cls.push(me.baseCls);
+
+ if (Ext.isDefined(me.cmpCls)) {
+ if (Ext.isDefined(Ext.global.console)) {
+ Ext.global.console.warn('Ext.Component: cmpCls has been deprecated. Please use componentCls.');
+ }
+ me.componentCls = me.cmpCls;
+ delete me.cmpCls;
+ }
+
+ if (me.componentCls) {
+ cls.push(me.componentCls);
+ } else {
+ me.componentCls = me.baseCls;
+ }
+ if (me.cls) {
+ cls.push(me.cls);
+ delete me.cls;
+ }
+
+ return cls.concat(me.additionalCls);
+ },
+
+
+ setUI: function(ui) {
+ var me = this,
+ oldUICls = Ext.Array.clone(me.uiCls),
+ newUICls = [],
+ classes = [],
+ cls,
+ i;
+
+
+ for (i = 0; i < oldUICls.length; i++) {
+ cls = oldUICls[i];
+
+ classes = classes.concat(me.removeClsWithUI(cls, true));
+ newUICls.push(cls);
+ }
+
+ if (classes.length) {
+ me.removeCls(classes);
+ }
+
+
+ me.removeUIFromElement();
+
+
+ me.ui = ui;
+
+
+ me.addUIToElement();
+
+
+ classes = [];
+ for (i = 0; i < newUICls.length; i++) {
+ cls = newUICls[i];
+ classes = classes.concat(me.addClsWithUI(cls, true));
+ }
+
+ if (classes.length) {
+ me.addCls(classes);
+ }
+ },
+
+
+ addClsWithUI: function(cls, skip) {
+ var me = this,
+ classes = [],
+ i;
+
+ if (!Ext.isArray(cls)) {
+ cls = [cls];
+ }
+
+ for (i = 0; i < cls.length; i++) {
+ if (cls[i] && !me.hasUICls(cls[i])) {
+ me.uiCls = Ext.Array.clone(me.uiCls);
+ me.uiCls.push(cls[i]);
+
+ classes = classes.concat(me.addUIClsToElement(cls[i]));
+ }
+ }
+
+ if (skip !== true) {
+ me.addCls(classes);
+ }
+
+ return classes;
+ },
+
+
+ removeClsWithUI: function(cls, skip) {
+ var me = this,
+ classes = [],
+ i;
+
+ if (!Ext.isArray(cls)) {
+ cls = [cls];
+ }
+
+ for (i = 0; i < cls.length; i++) {
+ if (cls[i] && me.hasUICls(cls[i])) {
+ me.uiCls = Ext.Array.remove(me.uiCls, cls[i]);
+
+ classes = classes.concat(me.removeUIClsFromElement(cls[i]));
+ }
+ }
+
+ if (skip !== true) {
+ me.removeCls(classes);
+ }
+
+ return classes;
+ },
+
+
+ hasUICls: function(cls) {
+ var me = this,
+ uiCls = me.uiCls || [];
+
+ return Ext.Array.contains(uiCls, cls);
+ },
+
+
+ addUIClsToElement: function(cls, force) {
+ var me = this,
+ result = [],
+ frameElementCls = me.frameElementCls;
+
+ result.push(Ext.baseCSSPrefix + cls);
+ result.push(me.baseCls + '-' + cls);
+ result.push(me.baseCls + '-' + me.ui + '-' + cls);
+
+ if (!force && me.frame && !Ext.supports.CSS3BorderRadius) {
+
+ var els = ['tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'],
+ classes, i, j, el;
+
+
+ for (i = 0; i < els.length; i++) {
+ el = me['frame' + els[i].toUpperCase()];
+ classes = [me.baseCls + '-' + me.ui + '-' + els[i], me.baseCls + '-' + me.ui + '-' + cls + '-' + els[i]];
+ if (el && el.dom) {
+ el.addCls(classes);
+ } else {
+ for (j = 0; j < classes.length; j++) {
+ if (Ext.Array.indexOf(frameElementCls[els[i]], classes[j]) == -1) {
+ frameElementCls[els[i]].push(classes[j]);
+ }
+ }
+ }
+ }
+ }
+
+ me.frameElementCls = frameElementCls;
+
+ return result;
+ },
+
+
+ removeUIClsFromElement: function(cls, force) {
+ var me = this,
+ result = [],
+ frameElementCls = me.frameElementCls;
+
+ result.push(Ext.baseCSSPrefix + cls);
+ result.push(me.baseCls + '-' + cls);
+ result.push(me.baseCls + '-' + me.ui + '-' + cls);
+
+ if (!force && me.frame && !Ext.supports.CSS3BorderRadius) {
+
+ var els = ['tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'],
+ i, el;
+ cls = me.baseCls + '-' + me.ui + '-' + cls + '-' + els[i];
+
+ for (i = 0; i < els.length; i++) {
+ el = me['frame' + els[i].toUpperCase()];
+ if (el && el.dom) {
+ el.removeCls(cls);
+ } else {
+ Ext.Array.remove(frameElementCls[els[i]], cls);
+ }
+ }
+ }
+
+ me.frameElementCls = frameElementCls;
+
+ return result;
+ },
+
+
+ addUIToElement: function(force) {
+ var me = this,
+ frameElementCls = me.frameElementCls;
+
+ me.addCls(me.baseCls + '-' + me.ui);
+
+ if (me.frame && !Ext.supports.CSS3BorderRadius) {
+
+ var els = ['tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'],
+ i, el, cls;
+
+
+ for (i = 0; i < els.length; i++) {
+ el = me['frame' + els[i].toUpperCase()];
+ cls = me.baseCls + '-' + me.ui + '-' + els[i];
+ if (el) {
+ el.addCls(cls);
+ } else {
+ if (!Ext.Array.contains(frameElementCls[els[i]], cls)) {
+ frameElementCls[els[i]].push(cls);
+ }
+ }
+ }
+ }
+ },
+
+
+ removeUIFromElement: function() {
+ var me = this,
+ frameElementCls = me.frameElementCls;
+
+ me.removeCls(me.baseCls + '-' + me.ui);
+
+ if (me.frame && !Ext.supports.CSS3BorderRadius) {
+
+ var els = ['tl', 'tc', 'tr', 'ml', 'mc', 'mr', 'bl', 'bc', 'br'],
+ i, j, el, cls;
+
+
+ for (i = 0; i < els.length; i++) {
+ el = me['frame' + els[i].toUpperCase()];
+ cls = me.baseCls + '-' + me.ui + '-' + els[i];
+
+ if (el) {
+ el.removeCls(cls);
+ } else {
+ Ext.Array.remove(frameElementCls[els[i]], cls);
+ }
+ }
+ }
+ },
+
+ getElConfig : function() {
+ if (Ext.isString(this.autoEl)) {
+ this.autoEl = {
+ tag: this.autoEl
+ };
+ }
+
+ var result = this.autoEl || {tag: 'div'};
+ result.id = this.id;
+ return result;
+ },
+
+
+ getInsertPosition: function(position) {
+
+ if (position !== undefined) {
+ if (Ext.isNumber(position)) {
+ position = this.container.dom.childNodes[position];
+ }
+ else {
+ position = Ext.getDom(position);
+ }
+ }
+
+ return position;
+ },
+
+
+ initContainer: function(container) {
+ var me = this;
+
+
+
+
+ if (!container && me.el) {
+ container = me.el.dom.parentNode;
+ me.allowDomMove = false;
+ }
+
+ me.container = Ext.get(container);
+
+ if (me.ctCls) {
+ me.container.addCls(me.ctCls);
+ }
+
+ return me.container;
+ },
+
+
+ initRenderData: function() {
+ var me = this;
+
+ return Ext.applyIf(me.renderData, {
+ id: me.id,
+ ui: me.ui,
+ uiCls: me.uiCls,
+ baseCls: me.baseCls,
+ componentCls: me.componentCls,
+ frame: me.frame
+ });
+ },
+
+
+ getTpl: function(name) {
+ var me = this,
+ prototype = me.self.prototype,
+ ownerPrototype,
+ tpl;
+
+ if (me.hasOwnProperty(name)) {
+ tpl = me[name];
+ if (tpl && !(tpl instanceof Ext.XTemplate)) {
+ me[name] = Ext.ClassManager.dynInstantiate('Ext.XTemplate', tpl);
+ }
+
+ return me[name];
+ }
+
+ if (!(prototype[name] instanceof Ext.XTemplate)) {
+ ownerPrototype = prototype;
+
+ do {
+ if (ownerPrototype.hasOwnProperty(name)) {
+ tpl = ownerPrototype[name];
+ if (tpl && !(tpl instanceof Ext.XTemplate)) {
+ ownerPrototype[name] = Ext.ClassManager.dynInstantiate('Ext.XTemplate', tpl);
+ break;
+ }
+ }
+
+ ownerPrototype = ownerPrototype.superclass;
+ } while (ownerPrototype);
+ }
+
+ return prototype[name];
+ },
+
+
+ initRenderTpl: function() {
+ return this.getTpl('renderTpl');
+ },
+
+
+ initStyles: function() {
+ var style = {},
+ me = this,
+ Element = Ext.Element;
+
+ if (Ext.isString(me.style)) {
+ style = Element.parseStyles(me.style);
+ } else {
+ style = Ext.apply({}, me.style);
+ }
+
+
+
+ if (me.padding !== undefined) {
+ style.padding = Element.unitizeBox((me.padding === true) ? 5 : me.padding);
+ }
+
+ if (me.margin !== undefined) {
+ style.margin = Element.unitizeBox((me.margin === true) ? 5 : me.margin);
+ }
+
+ delete me.style;
+ return style;
+ },
+
+
+ initContent: function() {
+ var me = this,
+ target = me.getTargetEl(),
+ contentEl,
+ pre;
+
+ if (me.html) {
+ target.update(Ext.DomHelper.markup(me.html));
+ delete me.html;
+ }
+
+ if (me.contentEl) {
+ contentEl = Ext.get(me.contentEl);
+ pre = Ext.baseCSSPrefix;
+ contentEl.removeCls([pre + 'hidden', pre + 'hide-display', pre + 'hide-offsets', pre + 'hide-nosize']);
+ target.appendChild(contentEl.dom);
+ }
+
+ if (me.tpl) {
+
+ if (!me.tpl.isTemplate) {
+ me.tpl = Ext.create('Ext.XTemplate', me.tpl);
+ }
+
+ if (me.data) {
+ me.tpl[me.tplWriteMode](target, me.data);
+ delete me.data;
+ }
+ }
+ },
+
+
+ initEvents : function() {
+ var me = this,
+ afterRenderEvents = me.afterRenderEvents,
+ el,
+ property,
+ fn = function(listeners){
+ me.mon(el, listeners);
+ };
+ if (afterRenderEvents) {
+ for (property in afterRenderEvents) {
+ if (afterRenderEvents.hasOwnProperty(property)) {
+ el = me[property];
+ if (el && el.on) {
+ Ext.each(afterRenderEvents[property], fn);
+ }
+ }
+ }
+ }
+ },
+
+
+ addChildEls: function () {
+ var me = this,
+ childEls = me.childEls || (me.childEls = []);
+
+ childEls.push.apply(childEls, arguments);
+ },
+
+
+ removeChildEls: function (testFn) {
+ var me = this,
+ old = me.childEls,
+ keepers = (me.childEls = []),
+ n, i, cel;
+
+ for (i = 0, n = old.length; i < n; ++i) {
+ cel = old[i];
+ if (!testFn(cel)) {
+ keepers.push(cel);
+ }
+ }
+ },
+
+
+ applyRenderSelectors: function() {
+ var me = this,
+ childEls = me.childEls,
+ selectors = me.renderSelectors,
+ el = me.el,
+ dom = el.dom,
+ baseId, childName, childId, i, selector;
+
+ if (childEls) {
+ baseId = me.id + '-';
+ for (i = childEls.length; i--; ) {
+ childName = childId = childEls[i];
+ if (typeof(childName) != 'string') {
+ childId = childName.id || (baseId + childName.itemId);
+ childName = childName.name;
+ } else {
+ childId = baseId + childId;
+ }
+
+
+
+ me[childName] = el.getById(childId);
+ }
+ }
+
+
+
+
+ if (selectors) {
+ for (selector in selectors) {
+ if (selectors.hasOwnProperty(selector) && selectors[selector]) {
+ me[selector] = Ext.get(Ext.DomQuery.selectNode(selectors[selector], dom));
+ }
+ }
+ }
+ },
+
+
+ is: function(selector) {
+ return Ext.ComponentQuery.is(this, selector);
+ },
+
+
+ up: function(selector) {
+ var result = this.ownerCt;
+ if (selector) {
+ for (; result; result = result.ownerCt) {
+ if (Ext.ComponentQuery.is(result, selector)) {
+ return result;
+ }
+ }
+ }
+ return result;
+ },
+
+
+ nextSibling: function(selector) {
+ var o = this.ownerCt, it, last, idx, c;
+ if (o) {
+ it = o.items;
+ idx = it.indexOf(this) + 1;
+ if (idx) {
+ if (selector) {
+ for (last = it.getCount(); idx < last; idx++) {
+ if ((c = it.getAt(idx)).is(selector)) {
+ return c;
+ }
+ }
+ } else {
+ if (idx < it.getCount()) {
+ return it.getAt(idx);
+ }
+ }
+ }
+ }
+ return null;
+ },
+
+
+ previousSibling: function(selector) {
+ var o = this.ownerCt, it, idx, c;
+ if (o) {
+ it = o.items;
+ idx = it.indexOf(this);
+ if (idx != -1) {
+ if (selector) {
+ for (--idx; idx >= 0; idx--) {
+ if ((c = it.getAt(idx)).is(selector)) {
+ return c;
+ }
+ }
+ } else {
+ if (idx) {
+ return it.getAt(--idx);
+ }
+ }
+ }
+ }
+ return null;
+ },
+
+
+ previousNode: function(selector, includeSelf) {
+ var node = this,
+ result,
+ it, len, i;
+
+
+ if (includeSelf && node.is(selector)) {
+ return node;
+ }
+
+ result = this.prev(selector);
+ if (result) {
+ return result;
+ }
+
+ if (node.ownerCt) {
+ for (it = node.ownerCt.items.items, i = Ext.Array.indexOf(it, node) - 1; i > -1; i--) {
+ if (it[i].query) {
+ result = it[i].query(selector);
+ result = result[result.length - 1];
+ if (result) {
+ return result;
+ }
+ }
+ }
+ return node.ownerCt.previousNode(selector, true);
+ }
+ },
+
+
+ nextNode: function(selector, includeSelf) {
+ var node = this,
+ result,
+ it, len, i;
+
+
+ if (includeSelf && node.is(selector)) {
+ return node;
+ }
+
+ result = this.next(selector);
+ if (result) {
+ return result;
+ }
+
+ if (node.ownerCt) {
+ for (it = node.ownerCt.items, i = it.indexOf(node) + 1, it = it.items, len = it.length; i < len; i++) {
+ if (it[i].down) {
+ result = it[i].down(selector);
+ if (result) {
+ return result;
+ }
+ }
+ }
+ return node.ownerCt.nextNode(selector);
+ }
+ },
+
+
+ getId : function() {
+ return this.id || (this.id = 'ext-comp-' + (this.getAutoId()));
+ },
+
+ getItemId : function() {
+ return this.itemId || this.id;
+ },
+
+
+ getEl : function() {
+ return this.el;
+ },
+
+
+ getTargetEl: function() {
+ return this.frameBody || this.el;
+ },
+
+
+ isXType: function(xtype, shallow) {
+
+ if (Ext.isFunction(xtype)) {
+ xtype = xtype.xtype;
+
+ } else if (Ext.isObject(xtype)) {
+ xtype = xtype.statics().xtype;
+
+ }
+
+ return !shallow ? ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1: this.self.xtype == xtype;
+ },
+
+
+ getXTypes: function() {
+ var self = this.self,
+ xtypes, parentPrototype, parentXtypes;
+
+ if (!self.xtypes) {
+ xtypes = [];
+ parentPrototype = this;
+
+ while (parentPrototype) {
+ parentXtypes = parentPrototype.xtypes;
+
+ if (parentXtypes !== undefined) {
+ xtypes.unshift.apply(xtypes, parentXtypes);
+ }
+
+ parentPrototype = parentPrototype.superclass;
+ }
+
+ self.xtypeChain = xtypes;
+ self.xtypes = xtypes.join('/');
+ }
+
+ return self.xtypes;
+ },
+
+
+ update : function(htmlOrData, loadScripts, cb) {
+ var me = this;
+
+ if (me.tpl && !Ext.isString(htmlOrData)) {
+ me.data = htmlOrData;
+ if (me.rendered) {
+ me.tpl[me.tplWriteMode](me.getTargetEl(), htmlOrData || {});
+ }
+ } else {
+ me.html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;
+ if (me.rendered) {
+ me.getTargetEl().update(me.html, loadScripts, cb);
+ }
+ }
+
+ if (me.rendered) {
+ me.doComponentLayout();
+ }
+ },
+
+
+ setVisible : function(visible) {
+ return this[visible ? 'show': 'hide']();
+ },
+
+
+ isVisible: function(deep) {
+ var me = this,
+ child = me,
+ visible = !me.hidden,
+ ancestor = me.ownerCt;
+
+
+ me.hiddenAncestor = false;
+ if (me.destroyed) {
+ return false;
+ }
+
+ if (deep && visible && me.rendered && ancestor) {
+ while (ancestor) {
+
+
+
+
+ if (ancestor.hidden || (ancestor.collapsed &&
+ !(ancestor.getDockedItems && Ext.Array.contains(ancestor.getDockedItems(), child)))) {
+
+ me.hiddenAncestor = ancestor;
+ visible = false;
+ break;
+ }
+ child = ancestor;
+ ancestor = ancestor.ownerCt;
+ }
+ }
+ return visible;
+ },
+
+
+ enable: function(silent) {
+ var me = this;
+
+ if (me.rendered) {
+ me.el.removeCls(me.disabledCls);
+ me.el.dom.disabled = false;
+ me.onEnable();
+ }
+
+ me.disabled = false;
+
+ if (silent !== true) {
+ me.fireEvent('enable', me);
+ }
+
+ return me;
+ },
+
+
+ disable: function(silent) {
+ var me = this;
+
+ if (me.rendered) {
+ me.el.addCls(me.disabledCls);
+ me.el.dom.disabled = true;
+ me.onDisable();
+ }
+
+ me.disabled = true;
+
+ if (silent !== true) {
+ me.fireEvent('disable', me);
+ }
+
+ return me;
+ },
+
+
+ onEnable: function() {
+ if (this.maskOnDisable) {
+ this.el.unmask();
+ }
+ },
+
+
+ onDisable : function() {
+ if (this.maskOnDisable) {
+ this.el.mask();
+ }
+ },
+
+
+ isDisabled : function() {
+ return this.disabled;
+ },
+
+
+ setDisabled : function(disabled) {
+ return this[disabled ? 'disable': 'enable']();
+ },
+
+
+ isHidden : function() {
+ return this.hidden;
+ },
+
+
+ addCls : function(className) {
+ var me = this;
+ if (!className) {
+ return me;
+ }
+ if (!Ext.isArray(className)){
+ className = className.replace(me.trimRe, '').split(me.spacesRe);
+ }
+ if (me.rendered) {
+ me.el.addCls(className);
+ }
+ else {
+ me.additionalCls = Ext.Array.unique(me.additionalCls.concat(className));
+ }
+ return me;
+ },
+
+
+ addClass : function() {
+ return this.addCls.apply(this, arguments);
+ },
+
+
+ removeCls : function(className) {
+ var me = this;
+
+ if (!className) {
+ return me;
+ }
+ if (!Ext.isArray(className)){
+ className = className.replace(me.trimRe, '').split(me.spacesRe);
+ }
+ if (me.rendered) {
+ me.el.removeCls(className);
+ }
+ else if (me.additionalCls.length) {
+ Ext.each(className, function(cls) {
+ Ext.Array.remove(me.additionalCls, cls);
+ });
+ }
+ return me;
+ },
+
+
+ addOverCls: function() {
+ var me = this;
+ if (!me.disabled) {
+ me.el.addCls(me.overCls);
+ }
+ },
+
+ removeOverCls: function() {
+ this.el.removeCls(this.overCls);
+ },
+
+ addListener : function(element, listeners, scope, options) {
+ var me = this,
+ fn,
+ option;
+
+ if (Ext.isString(element) && (Ext.isObject(listeners) || options && options.element)) {
+ if (options.element) {
+ fn = listeners;
+
+ listeners = {};
+ listeners[element] = fn;
+ element = options.element;
+ if (scope) {
+ listeners.scope = scope;
+ }
+
+ for (option in options) {
+ if (options.hasOwnProperty(option)) {
+ if (me.eventOptionsRe.test(option)) {
+ listeners[option] = options[option];
+ }
+ }
+ }
+ }
+
+
+
+ if (me[element] && me[element].on) {
+ me.mon(me[element], listeners);
+ } else {
+ me.afterRenderEvents = me.afterRenderEvents || {};
+ if (!me.afterRenderEvents[element]) {
+ me.afterRenderEvents[element] = [];
+ }
+ me.afterRenderEvents[element].push(listeners);
+ }
+ }
+
+ return me.mixins.observable.addListener.apply(me, arguments);
+ },
+
+
+ removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){
+ var me = this,
+ element = managedListener.options ? managedListener.options.element : null;
+
+ if (element) {
+ element = me[element];
+ if (element && element.un) {
+ if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {
+ element.un(managedListener.ename, managedListener.fn, managedListener.scope);
+ if (!isClear) {
+ Ext.Array.remove(me.managedListeners, managedListener);
+ }
+ }
+ }
+ } else {
+ return me.mixins.observable.removeManagedListenerItem.apply(me, arguments);
+ }
+ },
+
+
+ getBubbleTarget : function() {
+ return this.ownerCt;
+ },
+
+
+ isFloating : function() {
+ return this.floating;
+ },
+
+
+ isDraggable : function() {
+ return !!this.draggable;
+ },
+
+
+ isDroppable : function() {
+ return !!this.droppable;
+ },
+
+
+ onAdded : function(container, pos) {
+ this.ownerCt = container;
+ this.fireEvent('added', this, container, pos);
+ },
+
+
+ onRemoved : function() {
+ var me = this;
+
+ me.fireEvent('removed', me, me.ownerCt);
+ delete me.ownerCt;
+ },
+
+
+ beforeDestroy : Ext.emptyFn,
+
+
+ onResize : Ext.emptyFn,
+
+
+ setSize : function(width, height) {
+ var me = this,
+ layoutCollection;
+
+
+ if (Ext.isObject(width)) {
+ height = width.height;
+ width = width.width;
+ }
+
+
+ if (Ext.isNumber(width)) {
+ width = Ext.Number.constrain(width, me.minWidth, me.maxWidth);
+ }
+ if (Ext.isNumber(height)) {
+ height = Ext.Number.constrain(height, me.minHeight, me.maxHeight);
+ }
+
+ if (!me.rendered || !me.isVisible()) {
+
+ if (me.hiddenAncestor) {
+ layoutCollection = me.hiddenAncestor.layoutOnShow;
+ layoutCollection.remove(me);
+ layoutCollection.add(me);
+ }
+ me.needsLayout = {
+ width: width,
+ height: height,
+ isSetSize: true
+ };
+ if (!me.rendered) {
+ me.width = (width !== undefined) ? width : me.width;
+ me.height = (height !== undefined) ? height : me.height;
+ }
+ return me;
+ }
+ me.doComponentLayout(width, height, true);
+
+ return me;
+ },
+
+ isFixedWidth: function() {
+ var me = this,
+ layoutManagedWidth = me.layoutManagedWidth;
+
+ if (Ext.isDefined(me.width) || layoutManagedWidth == 1) {
+ return true;
+ }
+ if (layoutManagedWidth == 2) {
+ return false;
+ }
+ return (me.ownerCt && me.ownerCt.isFixedWidth());
+ },
+
+ isFixedHeight: function() {
+ var me = this,
+ layoutManagedHeight = me.layoutManagedHeight;
+
+ if (Ext.isDefined(me.height) || layoutManagedHeight == 1) {
+ return true;
+ }
+ if (layoutManagedHeight == 2) {
+ return false;
+ }
+ return (me.ownerCt && me.ownerCt.isFixedHeight());
+ },
+
+ setCalculatedSize : function(width, height, callingContainer) {
+ var me = this,
+ layoutCollection;
+
+
+ if (Ext.isObject(width)) {
+ callingContainer = width.ownerCt;
+ height = width.height;
+ width = width.width;
+ }
+
+
+ if (Ext.isNumber(width)) {
+ width = Ext.Number.constrain(width, me.minWidth, me.maxWidth);
+ }
+ if (Ext.isNumber(height)) {
+ height = Ext.Number.constrain(height, me.minHeight, me.maxHeight);
+ }
+
+ if (!me.rendered || !me.isVisible()) {
+
+ if (me.hiddenAncestor) {
+ layoutCollection = me.hiddenAncestor.layoutOnShow;
+ layoutCollection.remove(me);
+ layoutCollection.add(me);
+ }
+ me.needsLayout = {
+ width: width,
+ height: height,
+ isSetSize: false,
+ ownerCt: callingContainer
+ };
+ return me;
+ }
+ me.doComponentLayout(width, height, false, callingContainer);
+
+ return me;
+ },
+
+
+ doComponentLayout : function(width, height, isSetSize, callingContainer) {
+ var me = this,
+ componentLayout = me.getComponentLayout(),
+ lastComponentSize = componentLayout.lastComponentSize || {
+ width: undefined,
+ height: undefined
+ };
+
+
+
+
+ if (me.rendered && componentLayout) {
+
+ if (!Ext.isDefined(width)) {
+ if (me.isFixedWidth()) {
+ width = Ext.isDefined(me.width) ? me.width : lastComponentSize.width;
+ }
+ }
+
+ if (!Ext.isDefined(height)) {
+ if (me.isFixedHeight()) {
+ height = Ext.isDefined(me.height) ? me.height : lastComponentSize.height;
+ }
+ }
+
+ if (isSetSize) {
+ me.width = width;
+ me.height = height;
+ }
+
+ componentLayout.layout(width, height, isSetSize, callingContainer);
+ }
+
+ return me;
+ },
+
+
+ forceComponentLayout: function () {
+ this.doComponentLayout();
+ },
+
+
+ setComponentLayout : function(layout) {
+ var currentLayout = this.componentLayout;
+ if (currentLayout && currentLayout.isLayout && currentLayout != layout) {
+ currentLayout.setOwner(null);
+ }
+ this.componentLayout = layout;
+ layout.setOwner(this);
+ },
+
+ getComponentLayout : function() {
+ var me = this;
+
+ if (!me.componentLayout || !me.componentLayout.isLayout) {
+ me.setComponentLayout(Ext.layout.Layout.create(me.componentLayout, 'autocomponent'));
+ }
+ return me.componentLayout;
+ },
+
+
+ afterComponentLayout: function(width, height, isSetSize, callingContainer) {
+ var me = this,
+ layout = me.componentLayout,
+ oldSize = me.preLayoutSize;
+
+ ++me.componentLayoutCounter;
+ if (!oldSize || ((width !== oldSize.width) || (height !== oldSize.height))) {
+ me.fireEvent('resize', me, width, height);
+ }
+ },
+
+
+ beforeComponentLayout: function(width, height, isSetSize, callingContainer) {
+ this.preLayoutSize = this.componentLayout.lastComponentSize;
+ return true;
+ },
+
+
+ setPosition : function(x, y) {
+ var me = this;
+
+ if (Ext.isObject(x)) {
+ y = x.y;
+ x = x.x;
+ }
+
+ if (!me.rendered) {
+ return me;
+ }
+
+ if (x !== undefined || y !== undefined) {
+ me.el.setBox(x, y);
+ me.onPosition(x, y);
+ me.fireEvent('move', me, x, y);
+ }
+ return me;
+ },
+
+
+ onPosition: Ext.emptyFn,
+
+
+ setWidth : function(width) {
+ return this.setSize(width);
+ },
+
+
+ setHeight : function(height) {
+ return this.setSize(undefined, height);
+ },
+
+
+ getSize : function() {
+ return this.el.getSize();
+ },
+
+
+ getWidth : function() {
+ return this.el.getWidth();
+ },
+
+
+ getHeight : function() {
+ return this.el.getHeight();
+ },
+
+
+ getLoader: function(){
+ var me = this,
+ autoLoad = me.autoLoad ? (Ext.isObject(me.autoLoad) ? me.autoLoad : {url: me.autoLoad}) : null,
+ loader = me.loader || autoLoad;
+
+ if (loader) {
+ if (!loader.isLoader) {
+ me.loader = Ext.create('Ext.ComponentLoader', Ext.apply({
+ target: me,
+ autoLoad: autoLoad
+ }, loader));
+ } else {
+ loader.setTarget(me);
+ }
+ return me.loader;
+
+ }
+ return null;
+ },
+
+
+ setLoading : function(load, targetEl) {
+ var me = this,
+ config;
+
+ if (me.rendered) {
+ if (load !== false && !me.collapsed) {
+ if (Ext.isObject(load)) {
+ config = load;
+ }
+ else if (Ext.isString(load)) {
+ config = {msg: load};
+ }
+ else {
+ config = {};
+ }
+ me.loadMask = me.loadMask || Ext.create('Ext.LoadMask', targetEl ? me.getTargetEl() : me.el, config);
+ me.loadMask.show();
+ } else if (me.loadMask) {
+ Ext.destroy(me.loadMask);
+ me.loadMask = null;
+ }
+ }
+
+ return me.loadMask;
+ },
+
+
+ setDocked : function(dock, layoutParent) {
+ var me = this;
+
+ me.dock = dock;
+ if (layoutParent && me.ownerCt && me.rendered) {
+ me.ownerCt.doComponentLayout();
+ }
+ return me;
+ },
+
+ onDestroy : function() {
+ var me = this;
+
+ if (me.monitorResize && Ext.EventManager.resizeEvent) {
+ Ext.EventManager.resizeEvent.removeListener(me.setSize, me);
+ }
+
+ Ext.destroy(
+ me.componentLayout,
+ me.loadMask,
+ me.floatingItems
+ );
+ },
+
+
+ cleanElementRefs: function(){
+ var me = this,
+ i = 0,
+ childEls = me.childEls,
+ selectors = me.renderSelectors,
+ selector,
+ name,
+ len;
+
+ if (me.rendered) {
+ if (childEls) {
+ for (len = childEls.length; i < len; ++i) {
+ name = childEls[i];
+ if (typeof(name) != 'string') {
+ name = name.name;
+ }
+ delete me[name];
+ }
+ }
+
+ if (selectors) {
+ for (selector in selectors) {
+ if (selectors.hasOwnProperty(selector)) {
+ delete me[selector];
+ }
+ }
+ }
+ }
+ delete me.rendered;
+ delete me.el;
+ delete me.frameBody;
+ },
+
+
+ destroy : function() {
+ var me = this;
+
+ if (!me.isDestroyed) {
+ if (me.fireEvent('beforedestroy', me) !== false) {
+ me.destroying = true;
+ me.beforeDestroy();
+
+ if (me.floating) {
+ delete me.floatParent;
+
+
+ if (me.zIndexManager) {
+ me.zIndexManager.unregister(me);
+ }
+ } else if (me.ownerCt && me.ownerCt.remove) {
+ me.ownerCt.remove(me, false);
+ }
+
+ me.onDestroy();
+
+
+ Ext.destroy(me.plugins);
+
+ if (me.rendered) {
+ me.el.remove();
+ }
+
+ me.fireEvent('destroy', me);
+ Ext.ComponentManager.unregister(me);
+
+ me.mixins.state.destroy.call(me);
+
+ me.clearListeners();
+
+ me.cleanElementRefs();
+ me.destroying = false;
+ me.isDestroyed = true;
+ }
+ }
+ },
+
+
+ getPlugin: function(pluginId) {
+ var i = 0,
+ plugins = this.plugins,
+ ln = plugins.length;
+ for (; i < ln; i++) {
+ if (plugins[i].pluginId === pluginId) {
+ return plugins[i];
+ }
+ }
+ },
+
+
+ isDescendantOf: function(container) {
+ return !!this.findParentBy(function(p){
+ return p === container;
+ });
+ }
+}, function() {
+ this.createAlias({
+ on: 'addListener',
+ prev: 'previousSibling',
+ next: 'nextSibling'
+ });
+});
+
+
+Ext.define('Ext.AbstractPlugin', {
+ disabled: false,
+
+ constructor: function(config) {
+ Ext.apply(this, config);
+ },
+
+ getCmp: function() {
+ return this.cmp;
+ },
+
+
+ init: Ext.emptyFn,
+
+
+ destroy: Ext.emptyFn,
+
+
+ enable: function() {
+ this.disabled = false;
+ },
+
+
+ disable: function() {
+ this.disabled = true;
+ }
+});
+
+Ext.define('Ext.data.Connection', {
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ statics: {
+ requestId: 0
+ },
+
+ url: null,
+ async: true,
+ method: null,
+ username: '',
+ password: '',
+
+
+ disableCaching: true,
+
+
+ withCredentials: false,
+
+
+ cors: false,
+
+
+ disableCachingParam: '_dc',
+
+
+ timeout : 30000,
+
+
+
+ useDefaultHeader : true,
+ defaultPostHeader : 'application/x-www-form-urlencoded; charset=UTF-8',
+ useDefaultXhrHeader : true,
+ defaultXhrHeader : 'XMLHttpRequest',
+
+ constructor : function(config) {
+ config = config || {};
+ Ext.apply(this, config);
+
+ this.addEvents(
+
+ 'beforerequest',
+
+ 'requestcomplete',
+
+ 'requestexception'
+ );
+ this.requests = {};
+ this.mixins.observable.constructor.call(this);
+ },
+
+
+ request : function(options) {
+ options = options || {};
+ var me = this,
+ scope = options.scope || window,
+ username = options.username || me.username,
+ password = options.password || me.password || '',
+ async,
+ requestOptions,
+ request,
+ headers,
+ xhr;
+
+ if (me.fireEvent('beforerequest', me, options) !== false) {
+
+ requestOptions = me.setOptions(options, scope);
+
+ if (this.isFormUpload(options) === true) {
+ this.upload(options.form, requestOptions.url, requestOptions.data, options);
+ return null;
+ }
+
+
+ if (options.autoAbort === true || me.autoAbort) {
+ me.abort();
+ }
+
+
+
+ if ((options.cors === true || me.cors === true) && Ext.isIe && Ext.ieVersion >= 8) {
+ xhr = new XDomainRequest();
+ } else {
+ xhr = this.getXhrInstance();
+ }
+
+ async = options.async !== false ? (options.async || me.async) : false;
+
+
+ if (username) {
+ xhr.open(requestOptions.method, requestOptions.url, async, username, password);
+ } else {
+ xhr.open(requestOptions.method, requestOptions.url, async);
+ }
+
+ if (options.withCredentials === true || me.withCredentials === true) {
+ xhr.withCredentials = true;
+ }
+
+ headers = me.setupHeaders(xhr, options, requestOptions.data, requestOptions.params);
+
+
+ request = {
+ id: ++Ext.data.Connection.requestId,
+ xhr: xhr,
+ headers: headers,
+ options: options,
+ async: async,
+ timeout: setTimeout(function() {
+ request.timedout = true;
+ me.abort(request);
+ }, options.timeout || me.timeout)
+ };
+ me.requests[request.id] = request;
+ me.latestId = request.id;
+
+ if (async) {
+ xhr.onreadystatechange = Ext.Function.bind(me.onStateChange, me, [request]);
+ }
+
+
+ xhr.send(requestOptions.data);
+ if (!async) {
+ return this.onComplete(request);
+ }
+ return request;
+ } else {
+ Ext.callback(options.callback, options.scope, [options, undefined, undefined]);
+ return null;
+ }
+ },
+
+
+ upload: function(form, url, params, options) {
+ form = Ext.getDom(form);
+ options = options || {};
+
+ var id = Ext.id(),
+ frame = document.createElement('iframe'),
+ hiddens = [],
+ encoding = 'multipart/form-data',
+ buf = {
+ target: form.target,
+ method: form.method,
+ encoding: form.encoding,
+ enctype: form.enctype,
+ action: form.action
+ }, hiddenItem;
+
+
+ Ext.fly(frame).set({
+ id: id,
+ name: id,
+ cls: Ext.baseCSSPrefix + 'hide-display',
+ src: Ext.SSL_SECURE_URL
+ });
+
+ document.body.appendChild(frame);
+
+
+ if (document.frames) {
+ document.frames[id].name = id;
+ }
+
+ Ext.fly(form).set({
+ target: id,
+ method: 'POST',
+ enctype: encoding,
+ encoding: encoding,
+ action: url || buf.action
+ });
+
+
+ if (params) {
+ Ext.iterate(Ext.Object.fromQueryString(params), function(name, value){
+ hiddenItem = document.createElement('input');
+ Ext.fly(hiddenItem).set({
+ type: 'hidden',
+ value: value,
+ name: name
+ });
+ form.appendChild(hiddenItem);
+ hiddens.push(hiddenItem);
+ });
+ }
+
+ Ext.fly(frame).on('load', Ext.Function.bind(this.onUploadComplete, this, [frame, options]), null, {single: true});
+ form.submit();
+
+ Ext.fly(form).set(buf);
+ Ext.each(hiddens, function(h) {
+ Ext.removeNode(h);
+ });
+ },
+
+
+ onUploadComplete: function(frame, options) {
+ var me = this,
+
+ response = {
+ responseText: '',
+ responseXML: null
+ }, doc, firstChild;
+
+ try {
+ doc = frame.contentWindow.document || frame.contentDocument || window.frames[frame.id].document;
+ if (doc) {
+ if (doc.body) {
+ if (/textarea/i.test((firstChild = doc.body.firstChild || {}).tagName)) {
+ response.responseText = firstChild.value;
+ } else {
+ response.responseText = doc.body.innerHTML;
+ }
+ }
+
+ response.responseXML = doc.XMLDocument || doc;
+ }
+ } catch (e) {
+ }
+
+ me.fireEvent('requestcomplete', me, response, options);
+
+ Ext.callback(options.success, options.scope, [response, options]);
+ Ext.callback(options.callback, options.scope, [options, true, response]);
+
+ setTimeout(function(){
+ Ext.removeNode(frame);
+ }, 100);
+ },
+
+
+ isFormUpload: function(options){
+ var form = this.getForm(options);
+ if (form) {
+ return (options.isUpload || (/multipart\/form-data/i).test(form.getAttribute('enctype')));
+ }
+ return false;
+ },
+
+
+ getForm: function(options){
+ return Ext.getDom(options.form) || null;
+ },
+
+
+ setOptions: function(options, scope){
+ var me = this,
+ params = options.params || {},
+ extraParams = me.extraParams,
+ urlParams = options.urlParams,
+ url = options.url || me.url,
+ jsonData = options.jsonData,
+ method,
+ disableCache,
+ data;
+
+
+
+ if (Ext.isFunction(params)) {
+ params = params.call(scope, options);
+ }
+
+
+ if (Ext.isFunction(url)) {
+ url = url.call(scope, options);
+ }
+
+ url = this.setupUrl(options, url);
+
+
+
+ data = options.rawData || options.xmlData || jsonData || null;
+ if (jsonData && !Ext.isPrimitive(jsonData)) {
+ data = Ext.encode(data);
+ }
+
+
+ if (Ext.isObject(params)) {
+ params = Ext.Object.toQueryString(params);
+ }
+
+ if (Ext.isObject(extraParams)) {
+ extraParams = Ext.Object.toQueryString(extraParams);
+ }
+
+ params = params + ((extraParams) ? ((params) ? '&' : '') + extraParams : '');
+
+ urlParams = Ext.isObject(urlParams) ? Ext.Object.toQueryString(urlParams) : urlParams;
+
+ params = this.setupParams(options, params);
+
+
+ method = (options.method || me.method || ((params || data) ? 'POST' : 'GET')).toUpperCase();
+ this.setupMethod(options, method);
+
+
+ disableCache = options.disableCaching !== false ? (options.disableCaching || me.disableCaching) : false;
+
+ if (method === 'GET' && disableCache) {
+ url = Ext.urlAppend(url, (options.disableCachingParam || me.disableCachingParam) + '=' + (new Date().getTime()));
+ }
+
+
+ if ((method == 'GET' || data) && params) {
+ url = Ext.urlAppend(url, params);
+ params = null;
+ }
+
+
+ if (urlParams) {
+ url = Ext.urlAppend(url, urlParams);
+ }
+
+ return {
+ url: url,
+ method: method,
+ data: data || params || null
+ };
+ },
+
+
+ setupUrl: function(options, url){
+ var form = this.getForm(options);
+ if (form) {
+ url = url || form.action;
+ }
+ return url;
+ },
+
+
+
+ setupParams: function(options, params) {
+ var form = this.getForm(options),
+ serializedForm;
+ if (form && !this.isFormUpload(options)) {
+ serializedForm = Ext.Element.serializeForm(form);
+ params = params ? (params + '&' + serializedForm) : serializedForm;
+ }
+ return params;
+ },
+
+
+ setupMethod: function(options, method){
+ if (this.isFormUpload(options)) {
+ return 'POST';
+ }
+ return method;
+ },
+
+
+ setupHeaders: function(xhr, options, data, params){
+ var me = this,
+ headers = Ext.apply({}, options.headers || {}, me.defaultHeaders || {}),
+ contentType = me.defaultPostHeader,
+ jsonData = options.jsonData,
+ xmlData = options.xmlData,
+ key,
+ header;
+
+ if (!headers['Content-Type'] && (data || params)) {
+ if (data) {
+ if (options.rawData) {
+ contentType = 'text/plain';
+ } else {
+ if (xmlData && Ext.isDefined(xmlData)) {
+ contentType = 'text/xml';
+ } else if (jsonData && Ext.isDefined(jsonData)) {
+ contentType = 'application/json';
+ }
+ }
+ }
+ headers['Content-Type'] = contentType;
+ }
+
+ if (me.useDefaultXhrHeader && !headers['X-Requested-With']) {
+ headers['X-Requested-With'] = me.defaultXhrHeader;
+ }
+
+ try{
+ for (key in headers) {
+ if (headers.hasOwnProperty(key)) {
+ header = headers[key];
+ xhr.setRequestHeader(key, header);
+ }
+
+ }
+ } catch(e) {
+ me.fireEvent('exception', key, header);
+ }
+ return headers;
+ },
+
+
+ getXhrInstance: (function(){
+ var options = [function(){
+ return new XMLHttpRequest();
+ }, function(){
+ return new ActiveXObject('MSXML2.XMLHTTP.3.0');
+ }, function(){
+ return new ActiveXObject('MSXML2.XMLHTTP');
+ }, function(){
+ return new ActiveXObject('Microsoft.XMLHTTP');
+ }], i = 0,
+ len = options.length,
+ xhr;
+
+ for(; i < len; ++i) {
+ try{
+ xhr = options[i];
+ xhr();
+ break;
+ }catch(e){}
+ }
+ return xhr;
+ })(),
+
+
+ isLoading : function(request) {
+ if (!request) {
+ request = this.getLatest();
+ }
+ if (!(request && request.xhr)) {
+ return false;
+ }
+
+ var state = request.xhr.readyState;
+ return !(state === 0 || state == 4);
+ },
+
+
+ abort : function(request) {
+ var me = this;
+
+ if (!request) {
+ request = me.getLatest();
+ }
+
+ if (request && me.isLoading(request)) {
+
+ request.xhr.onreadystatechange = null;
+ request.xhr.abort();
+ me.clearTimeout(request);
+ if (!request.timedout) {
+ request.aborted = true;
+ }
+ me.onComplete(request);
+ me.cleanup(request);
+ }
+ },
+
+
+ abortAll: function(){
+ var requests = this.requests,
+ id;
+
+ for (id in requests) {
+ if (requests.hasOwnProperty(id)) {
+ this.abort(requests[id]);
+ }
+ }
+ },
+
+
+ getLatest: function(){
+ var id = this.latestId,
+ request;
+
+ if (id) {
+ request = this.requests[id];
+ }
+ return request || null;
+ },
+
+
+ onStateChange : function(request) {
+ if (request.xhr.readyState == 4) {
+ this.clearTimeout(request);
+ this.onComplete(request);
+ this.cleanup(request);
+ }
+ },
+
+
+ clearTimeout: function(request){
+ clearTimeout(request.timeout);
+ delete request.timeout;
+ },
+
+
+ cleanup: function(request){
+ request.xhr = null;
+ delete request.xhr;
+ },
+
+
+ onComplete : function(request) {
+ var me = this,
+ options = request.options,
+ result,
+ success,
+ response;
+
+ try {
+ result = me.parseStatus(request.xhr.status);
+ } catch (e) {
+
+ result = {
+ success : false,
+ isException : false
+ };
+ }
+ success = result.success;
+
+ if (success) {
+ response = me.createResponse(request);
+ me.fireEvent('requestcomplete', me, response, options);
+ Ext.callback(options.success, options.scope, [response, options]);
+ } else {
+ if (result.isException || request.aborted || request.timedout) {
+ response = me.createException(request);
+ } else {
+ response = me.createResponse(request);
+ }
+ me.fireEvent('requestexception', me, response, options);
+ Ext.callback(options.failure, options.scope, [response, options]);
+ }
+ Ext.callback(options.callback, options.scope, [options, success, response]);
+ delete me.requests[request.id];
+ return response;
+ },
+
+
+ parseStatus: function(status) {
+
+ status = status == 1223 ? 204 : status;
+
+ var success = (status >= 200 && status < 300) || status == 304,
+ isException = false;
+
+ if (!success) {
+ switch (status) {
+ case 12002:
+ case 12029:
+ case 12030:
+ case 12031:
+ case 12152:
+ case 13030:
+ isException = true;
+ break;
+ }
+ }
+ return {
+ success: success,
+ isException: isException
+ };
+ },
+
+
+ createResponse : function(request) {
+ var xhr = request.xhr,
+ headers = {},
+ lines = xhr.getAllResponseHeaders().replace(/\r\n/g, '\n').split('\n'),
+ count = lines.length,
+ line, index, key, value, response;
+
+ while (count--) {
+ line = lines[count];
+ index = line.indexOf(':');
+ if(index >= 0) {
+ key = line.substr(0, index).toLowerCase();
+ if (line.charAt(index + 1) == ' ') {
+ ++index;
+ }
+ headers[key] = line.substr(index + 1);
+ }
+ }
+
+ request.xhr = null;
+ delete request.xhr;
+
+ response = {
+ request: request,
+ requestId : request.id,
+ status : xhr.status,
+ statusText : xhr.statusText,
+ getResponseHeader : function(header){ return headers[header.toLowerCase()]; },
+ getAllResponseHeaders : function(){ return headers; },
+ responseText : xhr.responseText,
+ responseXML : xhr.responseXML
+ };
+
+
+
+ xhr = null;
+ return response;
+ },
+
+
+ createException : function(request) {
+ return {
+ request : request,
+ requestId : request.id,
+ status : request.aborted ? -1 : 0,
+ statusText : request.aborted ? 'transaction aborted' : 'communication failure',
+ aborted: request.aborted,
+ timedout: request.timedout
+ };
+ }
+});
+
+
+Ext.define('Ext.Ajax', {
+ extend: 'Ext.data.Connection',
+ singleton: true,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ autoAbort : false
+});
+
+Ext.define('Ext.ElementLoader', {
+
+
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ uses: [
+ 'Ext.data.Connection',
+ 'Ext.Ajax'
+ ],
+
+ statics: {
+ Renderer: {
+ Html: function(loader, response, active){
+ loader.getTarget().update(response.responseText, active.scripts === true);
+ return true;
+ }
+ }
+ },
+
+
+
+
+ url: null,
+
+
+ params: null,
+
+
+ baseParams: null,
+
+
+ autoLoad: false,
+
+
+ target: null,
+
+
+ loadMask: false,
+
+
+ ajaxOptions: null,
+
+
+ scripts: false,
+
+
+
+
+
+
+
+
+
+
+
+ isLoader: true,
+
+ constructor: function(config) {
+ var me = this,
+ autoLoad;
+
+ config = config || {};
+ Ext.apply(me, config);
+ me.setTarget(me.target);
+ me.addEvents(
+
+ 'beforeload',
+
+
+ 'exception',
+
+
+ 'load'
+ );
+
+
+ me.mixins.observable.constructor.call(me);
+
+ if (me.autoLoad) {
+ autoLoad = me.autoLoad;
+ if (autoLoad === true) {
+ autoLoad = {};
+ }
+ me.load(autoLoad);
+ }
+ },
+
+
+ setTarget: function(target){
+ var me = this;
+ target = Ext.get(target);
+ if (me.target && me.target != target) {
+ me.abort();
+ }
+ me.target = target;
+ },
+
+
+ getTarget: function(){
+ return this.target || null;
+ },
+
+
+ abort: function(){
+ var active = this.active;
+ if (active !== undefined) {
+ Ext.Ajax.abort(active.request);
+ if (active.mask) {
+ this.removeMask();
+ }
+ delete this.active;
+ }
+ },
+
+
+ removeMask: function(){
+ this.target.unmask();
+ },
+
+
+ addMask: function(mask){
+ this.target.mask(mask === true ? null : mask);
+ },
+
+
+ load: function(options) {
+
+ options = Ext.apply({}, options);
+
+ var me = this,
+ target = me.target,
+ mask = Ext.isDefined(options.loadMask) ? options.loadMask : me.loadMask,
+ params = Ext.apply({}, options.params),
+ ajaxOptions = Ext.apply({}, options.ajaxOptions),
+ callback = options.callback || me.callback,
+ scope = options.scope || me.scope || me,
+ request;
+
+ Ext.applyIf(ajaxOptions, me.ajaxOptions);
+ Ext.applyIf(options, ajaxOptions);
+
+ Ext.applyIf(params, me.params);
+ Ext.apply(params, me.baseParams);
+
+ Ext.applyIf(options, {
+ url: me.url
+ });
+
+
+ Ext.apply(options, {
+ scope: me,
+ params: params,
+ callback: me.onComplete
+ });
+
+ if (me.fireEvent('beforeload', me, options) === false) {
+ return;
+ }
+
+ if (mask) {
+ me.addMask(mask);
+ }
+
+ request = Ext.Ajax.request(options);
+ me.active = {
+ request: request,
+ options: options,
+ mask: mask,
+ scope: scope,
+ callback: callback,
+ success: options.success || me.success,
+ failure: options.failure || me.failure,
+ renderer: options.renderer || me.renderer,
+ scripts: Ext.isDefined(options.scripts) ? options.scripts : me.scripts
+ };
+ me.setOptions(me.active, options);
+ },
+
+
+ setOptions: Ext.emptyFn,
+
+
+ onComplete: function(options, success, response) {
+ var me = this,
+ active = me.active,
+ scope = active.scope,
+ renderer = me.getRenderer(active.renderer);
+
+
+ if (success) {
+ success = renderer.call(me, me, response, active);
+ }
+
+ if (success) {
+ Ext.callback(active.success, scope, [me, response, options]);
+ me.fireEvent('load', me, response, options);
+ } else {
+ Ext.callback(active.failure, scope, [me, response, options]);
+ me.fireEvent('exception', me, response, options);
+ }
+ Ext.callback(active.callback, scope, [me, success, response, options]);
+
+ if (active.mask) {
+ me.removeMask();
+ }
+
+ delete me.active;
+ },
+
+
+ getRenderer: function(renderer){
+ if (Ext.isFunction(renderer)) {
+ return renderer;
+ }
+ return this.statics().Renderer.Html;
+ },
+
+
+ startAutoRefresh: function(interval, options){
+ var me = this;
+ me.stopAutoRefresh();
+ me.autoRefresh = setInterval(function(){
+ me.load(options);
+ }, interval);
+ },
+
+
+ stopAutoRefresh: function(){
+ clearInterval(this.autoRefresh);
+ delete this.autoRefresh;
+ },
+
+
+ isAutoRefreshing: function(){
+ return Ext.isDefined(this.autoRefresh);
+ },
+
+
+ destroy: function(){
+ var me = this;
+ me.stopAutoRefresh();
+ delete me.target;
+ me.abort();
+ me.clearListeners();
+ }
+});
+
+
+Ext.define('Ext.ComponentLoader', {
+
+
+
+ extend: 'Ext.ElementLoader',
+
+ statics: {
+ Renderer: {
+ Data: function(loader, response, active){
+ var success = true;
+ try {
+ loader.getTarget().update(Ext.decode(response.responseText));
+ } catch (e) {
+ success = false;
+ }
+ return success;
+ },
+
+ Component: function(loader, response, active){
+ var success = true,
+ target = loader.getTarget(),
+ items = [];
+
+
+ try {
+ items = Ext.decode(response.responseText);
+ } catch (e) {
+ success = false;
+ }
+
+ if (success) {
+ if (active.removeAll) {
+ target.removeAll();
+ }
+ target.add(items);
+ }
+ return success;
+ }
+ }
+ },
+
+
+
+
+ target: null,
+
+
+ loadMask: false,
+
+
+
+
+ renderer: 'html',
+
+
+ setTarget: function(target){
+ var me = this;
+
+ if (Ext.isString(target)) {
+ target = Ext.getCmp(target);
+ }
+
+ if (me.target && me.target != target) {
+ me.abort();
+ }
+ me.target = target;
+ },
+
+
+ removeMask: function(){
+ this.target.setLoading(false);
+ },
+
+
+ addMask: function(mask){
+ this.target.setLoading(mask);
+ },
+
+
+
+ setOptions: function(active, options){
+ active.removeAll = Ext.isDefined(options.removeAll) ? options.removeAll : this.removeAll;
+ },
+
+
+ getRenderer: function(renderer){
+ if (Ext.isFunction(renderer)) {
+ return renderer;
+ }
+
+ var renderers = this.statics().Renderer;
+ switch (renderer) {
+ case 'component':
+ return renderers.Component;
+ case 'data':
+ return renderers.Data;
+ default:
+ return Ext.ElementLoader.Renderer.Html;
+ }
+ }
+});
+
+
+Ext.define('Ext.data.Association', {
+
+
+
+
+
+ primaryKey: 'id',
+
+
+
+
+
+ defaultReaderType: 'json',
+
+ statics: {
+ create: function(association){
+ if (!association.isAssociation) {
+ if (Ext.isString(association)) {
+ association = {
+ type: association
+ };
+ }
+
+ switch (association.type) {
+ case 'belongsTo':
+ return Ext.create('Ext.data.BelongsToAssociation', association);
+ case 'hasMany':
+ return Ext.create('Ext.data.HasManyAssociation', association);
+
+
+
+ default:
+ }
+ }
+ return association;
+ }
+ },
+
+
+ constructor: function(config) {
+ Ext.apply(this, config);
+
+ var types = Ext.ModelManager.types,
+ ownerName = config.ownerModel,
+ associatedName = config.associatedModel,
+ ownerModel = types[ownerName],
+ associatedModel = types[associatedName],
+ ownerProto;
+
+
+ this.ownerModel = ownerModel;
+ this.associatedModel = associatedModel;
+
+
+
+
+
+ Ext.applyIf(this, {
+ ownerName : ownerName,
+ associatedName: associatedName
+ });
+ },
+
+
+ getReader: function(){
+ var me = this,
+ reader = me.reader,
+ model = me.associatedModel;
+
+ if (reader) {
+ if (Ext.isString(reader)) {
+ reader = {
+ type: reader
+ };
+ }
+ if (reader.isReader) {
+ reader.setModel(model);
+ } else {
+ Ext.applyIf(reader, {
+ model: model,
+ type : me.defaultReaderType
+ });
+ }
+ me.reader = Ext.createByAlias('reader.' + reader.type, reader);
+ }
+ return me.reader || null;
+ }
+});
+
+
+Ext.define('Ext.ModelManager', {
+ extend: 'Ext.AbstractManager',
+ alternateClassName: 'Ext.ModelMgr',
+ requires: ['Ext.data.Association'],
+
+ singleton: true,
+
+ typeName: 'mtype',
+
+
+ associationStack: [],
+
+
+ registerType: function(name, config) {
+ var proto = config.prototype,
+ model;
+ if (proto && proto.isModel) {
+
+ model = config;
+ } else {
+
+ if (!config.extend) {
+ config.extend = 'Ext.data.Model';
+ }
+ model = Ext.define(name, config);
+ }
+ this.types[name] = model;
+ return model;
+ },
+
+
+ onModelDefined: function(model) {
+ var stack = this.associationStack,
+ length = stack.length,
+ create = [],
+ association, i, created;
+
+ for (i = 0; i < length; i++) {
+ association = stack[i];
+
+ if (association.associatedModel == model.modelName) {
+ create.push(association);
+ }
+ }
+
+ for (i = 0, length = create.length; i < length; i++) {
+ created = create[i];
+ this.types[created.ownerModel].prototype.associations.add(Ext.data.Association.create(created));
+ Ext.Array.remove(stack, created);
+ }
+ },
+
+
+ registerDeferredAssociation: function(association){
+ this.associationStack.push(association);
+ },
+
+
+ getModel: function(id) {
+ var model = id;
+ if (typeof model == 'string') {
+ model = this.types[model];
+ }
+ return model;
+ },
+
+
+ create: function(config, name, id) {
+ var con = typeof name == 'function' ? name : this.types[name || config.name];
+
+ return new con(config, id);
+ }
+}, function() {
+
+
+ Ext.regModel = function() {
+ return this.ModelManager.registerType.apply(this.ModelManager, arguments);
+ };
+});
+
+
+Ext.define('Ext.PluginManager', {
+ extend: 'Ext.AbstractManager',
+ alternateClassName: 'Ext.PluginMgr',
+ singleton: true,
+ typeName: 'ptype',
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ create : function(config, defaultType){
+ if (config.init) {
+ return config;
+ } else {
+ return Ext.createByAlias('plugin.' + (config.ptype || defaultType), config);
+ }
+
+
+
+
+
+
+
+
+ },
+
+
+ findByType: function(type, defaultsOnly) {
+ var matches = [],
+ types = this.types;
+
+ for (var name in types) {
+ if (!types.hasOwnProperty(name)) {
+ continue;
+ }
+ var item = types[name];
+
+ if (item.type == type && (!defaultsOnly || (defaultsOnly === true && item.isDefault))) {
+ matches.push(item);
+ }
+ }
+
+ return matches;
+ }
+}, function() {
+
+ Ext.preg = function() {
+ return Ext.PluginManager.registerType.apply(Ext.PluginManager, arguments);
+ };
+});
+
+
+Ext.define('Ext.Template', {
+
+
+
+ requires: ['Ext.DomHelper', 'Ext.util.Format'],
+
+ inheritableStatics: {
+
+ from: function(el, config) {
+ el = Ext.getDom(el);
+ return new this(el.value || el.innerHTML, config || '');
+ }
+ },
+
+
+
+
+ constructor: function(html) {
+ var me = this,
+ args = arguments,
+ buffer = [],
+ i = 0,
+ length = args.length,
+ value;
+
+ me.initialConfig = {};
+
+ if (length > 1) {
+ for (; i < length; i++) {
+ value = args[i];
+ if (typeof value == 'object') {
+ Ext.apply(me.initialConfig, value);
+ Ext.apply(me, value);
+ } else {
+ buffer.push(value);
+ }
+ }
+ html = buffer.join('');
+ } else {
+ if (Ext.isArray(html)) {
+ buffer.push(html.join(''));
+ } else {
+ buffer.push(html);
+ }
+ }
+
+
+ me.html = buffer.join('');
+
+ if (me.compiled) {
+ me.compile();
+ }
+ },
+
+ isTemplate: true,
+
+
+
+
+ disableFormats: false,
+
+ re: /\{([\w\-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
+
+
+ applyTemplate: function(values) {
+ var me = this,
+ useFormat = me.disableFormats !== true,
+ fm = Ext.util.Format,
+ tpl = me;
+
+ if (me.compiled) {
+ return me.compiled(values);
+ }
+ function fn(m, name, format, args) {
+ if (format && useFormat) {
+ if (args) {
+ args = [values[name]].concat(Ext.functionFactory('return ['+ args +'];')());
+ } else {
+ args = [values[name]];
+ }
+ if (format.substr(0, 5) == "this.") {
+ return tpl[format.substr(5)].apply(tpl, args);
+ }
+ else {
+ return fm[format].apply(fm, args);
+ }
+ }
+ else {
+ return values[name] !== undefined ? values[name] : "";
+ }
+ }
+ return me.html.replace(me.re, fn);
+ },
+
+
+ set: function(html, compile) {
+ var me = this;
+ me.html = html;
+ me.compiled = null;
+ return compile ? me.compile() : me;
+ },
+
+ compileARe: /\\/g,
+ compileBRe: /(\r\n|\n)/g,
+ compileCRe: /'/g,
+
+ /**
+ * Compiles the template into an internal function, eliminating the RegEx overhead.
+ * @return {Ext.Template} this
+ */
+ compile: function() {
+ var me = this,
+ fm = Ext.util.Format,
+ useFormat = me.disableFormats !== true,
+ body, bodyReturn;
+
+ function fn(m, name, format, args) {
+ if (format && useFormat) {
+ args = args ? ',' + args: "";
+ if (format.substr(0, 5) != "this.") {
+ format = "fm." + format + '(';
+ }
+ else {
+ format = 'this.' + format.substr(5) + '(';
+ }
+ }
+ else {
+ args = '';
+ format = "(values['" + name + "'] == undefined ? '' : ";
+ }
+ return "'," + format + "values['" + name + "']" + args + ") ,'";
+ }
+
+ bodyReturn = me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn);
+ body = "this.compiled = function(values){ return ['" + bodyReturn + "'].join('');};";
+ eval(body);
+ return me;
+ },
+
+ /**
+ * Applies the supplied values to the template and inserts the new node(s) as the first child of el.
+ *
+ * @param {String/HTMLElement/Ext.Element} el The context element
+ * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.
+ * @param {Boolean} returnElement (optional) true to return a Ext.Element.
+ * @return {HTMLElement/Ext.Element} The new node or Element
+ */
+ insertFirst: function(el, values, returnElement) {
+ return this.doInsert('afterBegin', el, values, returnElement);
+ },
+
+ /**
+ * Applies the supplied values to the template and inserts the new node(s) before el.
+ *
+ * @param {String/HTMLElement/Ext.Element} el The context element
+ * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.
+ * @param {Boolean} returnElement (optional) true to return a Ext.Element.
+ * @return {HTMLElement/Ext.Element} The new node or Element
+ */
+ insertBefore: function(el, values, returnElement) {
+ return this.doInsert('beforeBegin', el, values, returnElement);
+ },
+
+ /**
+ * Applies the supplied values to the template and inserts the new node(s) after el.
+ *
+ * @param {String/HTMLElement/Ext.Element} el The context element
+ * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.
+ * @param {Boolean} returnElement (optional) true to return a Ext.Element.
+ * @return {HTMLElement/Ext.Element} The new node or Element
+ */
+ insertAfter: function(el, values, returnElement) {
+ return this.doInsert('afterEnd', el, values, returnElement);
+ },
+
+ /**
+ * Applies the supplied `values` to the template and appends the new node(s) to the specified `el`.
+ *
+ * For example usage see {@link Ext.Template Ext.Template class docs}.
+ *
+ * @param {String/HTMLElement/Ext.Element} el The context element
+ * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.
+ * @param {Boolean} returnElement (optional) true to return an Ext.Element.
+ * @return {HTMLElement/Ext.Element} The new node or Element
+ */
+ append: function(el, values, returnElement) {
+ return this.doInsert('beforeEnd', el, values, returnElement);
+ },
+
+ doInsert: function(where, el, values, returnEl) {
+ el = Ext.getDom(el);
+ var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
+ return returnEl ? Ext.get(newNode, true) : newNode;
+ },
+
+ /**
+ * Applies the supplied values to the template and overwrites the content of el with the new node(s).
+ *
+ * @param {String/HTMLElement/Ext.Element} el The context element
+ * @param {Object/Array} values The template values. See {@link #applyTemplate} for details.
+ * @param {Boolean} returnElement (optional) true to return a Ext.Element.
+ * @return {HTMLElement/Ext.Element} The new node or Element
+ */
+ overwrite: function(el, values, returnElement) {
+ el = Ext.getDom(el);
+ el.innerHTML = this.applyTemplate(values);
+ return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
+ }
+}, function() {
+
+ /**
+ * @method apply
+ * @member Ext.Template
+ * Alias for {@link #applyTemplate}.
+ * @alias Ext.Template#applyTemplate
+ */
+ this.createAlias('apply', 'applyTemplate');
+});
+
+/**
+ * A template class that supports advanced functionality like:
+ *
+ * - Autofilling arrays using templates and sub-templates
+ * - Conditional processing with basic comparison operators
+ * - Basic math function support
+ * - Execute arbitrary inline code with special built-in template variables
+ * - Custom member functions
+ * - Many special tags and built-in operators that aren't defined as part of the API, but are supported in the templates that can be created
+ *
+ * XTemplate provides the templating mechanism built into:
+ *
+ * - {@link Ext.view.View}
+ *
+ * The {@link Ext.Template} describes the acceptable parameters to pass to the constructor. The following examples
+ * demonstrate all of the supported features.
+ *
+ * # Sample Data
+ *
+ * This is the data object used for reference in each code example:
+ *
+ * var data = {
+ * name: 'Tommy Maintz',
+ * title: 'Lead Developer',
+ * company: 'Sencha Inc.',
+ * email: 'tommy@sencha.com',
+ * address: '5 Cups Drive',
+ * city: 'Palo Alto',
+ * state: 'CA',
+ * zip: '44102',
+ * drinks: ['Coffee', 'Soda', 'Water'],
+ * kids: [
+ * {
+ * name: 'Joshua',
+ * age:3
+ * },
+ * {
+ * name: 'Matthew',
+ * age:2
+ * },
+ * {
+ * name: 'Solomon',
+ * age:0
+ * }
+ * ]
+ * };
+ *
+ * # Auto filling of arrays
+ *
+ * The **tpl** tag and the **for** operator are used to process the provided data object:
+ *
+ * - If the value specified in for is an array, it will auto-fill, repeating the template block inside the tpl
+ * tag for each item in the array.
+ * - If for="." is specified, the data object provided is examined.
+ * - While processing an array, the special variable {#} will provide the current array index + 1 (starts at 1, not 0).
+ *
+ * Examples:
+ *
+ * <tpl for=".">...</tpl> // loop through array at root node
+ * <tpl for="foo">...</tpl> // loop through array at foo node
+ * <tpl for="foo.bar">...</tpl> // loop through array at foo.bar node
+ *
+ * Using the sample data above:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>Kids: ',
+ * '<tpl for=".">', // process the data.kids node
+ * '<p>{#}. {name}</p>', // use current array index to autonumber
+ * '</tpl></p>'
+ * );
+ * tpl.overwrite(panel.body, data.kids); // pass the kids property of the data object
+ *
+ * An example illustrating how the **for** property can be leveraged to access specified members of the provided data
+ * object to populate the template:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>Name: {name}</p>',
+ * '<p>Title: {title}</p>',
+ * '<p>Company: {company}</p>',
+ * '<p>Kids: ',
+ * '<tpl for="kids">', // interrogate the kids property within the data
+ * '<p>{name}</p>',
+ * '</tpl></p>'
+ * );
+ * tpl.overwrite(panel.body, data); // pass the root node of the data object
+ *
+ * Flat arrays that contain values (and not objects) can be auto-rendered using the special **`{.}`** variable inside a
+ * loop. This variable will represent the value of the array at the current index:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>{name}\'s favorite beverages:</p>',
+ * '<tpl for="drinks">',
+ * '<div> - {.}</div>',
+ * '</tpl>'
+ * );
+ * tpl.overwrite(panel.body, data);
+ *
+ * When processing a sub-template, for example while looping through a child array, you can access the parent object's
+ * members via the **parent** object:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>Name: {name}</p>',
+ * '<p>Kids: ',
+ * '<tpl for="kids">',
+ * '<tpl if="age > 1">',
+ * '<p>{name}</p>',
+ * '<p>Dad: {parent.name}</p>',
+ * '</tpl>',
+ * '</tpl></p>'
+ * );
+ * tpl.overwrite(panel.body, data);
+ *
+ * # Conditional processing with basic comparison operators
+ *
+ * The **tpl** tag and the **if** operator are used to provide conditional checks for deciding whether or not to render
+ * specific parts of the template. Notes:
+ *
+ * - Double quotes must be encoded if used within the conditional
+ * - There is no else operator -- if needed, two opposite if statements should be used.
+ *
+ * Examples:
+ *
+ * <tpl if="age > 1 && age < 10">Child</tpl>
+ * <tpl if="age >= 10 && age < 18">Teenager</tpl>
+ * <tpl if="this.isGirl(name)">...</tpl>
+ * <tpl if="id==\'download\'">...</tpl>
+ * <tpl if="needsIcon"><img src="{icon}" class="{iconCls}"/></tpl>
+ * // no good:
+ * <tpl if="name == "Tommy"">Hello</tpl>
+ * // encode " if it is part of the condition, e.g.
+ * <tpl if="name == "Tommy"">Hello</tpl>
+ *
+ * Using the sample data above:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>Name: {name}</p>',
+ * '<p>Kids: ',
+ * '<tpl for="kids">',
+ * '<tpl if="age > 1">',
+ * '<p>{name}</p>',
+ * '</tpl>',
+ * '</tpl></p>'
+ * );
+ * tpl.overwrite(panel.body, data);
+ *
+ * # Basic math support
+ *
+ * The following basic math operators may be applied directly on numeric data values:
+ *
+ * + - * /
+ *
+ * For example:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>Name: {name}</p>',
+ * '<p>Kids: ',
+ * '<tpl for="kids">',
+ * '<tpl if="age > 1">', // <-- Note that the > is encoded
+ * '<p>{#}: {name}</p>', // <-- Auto-number each item
+ * '<p>In 5 Years: {age+5}</p>', // <-- Basic math
+ * '<p>Dad: {parent.name}</p>',
+ * '</tpl>',
+ * '</tpl></p>'
+ * );
+ * tpl.overwrite(panel.body, data);
+ *
+ * # Execute arbitrary inline code with special built-in template variables
+ *
+ * Anything between `{[ ... ]}` is considered code to be executed in the scope of the template. There are some special
+ * variables available in that code:
+ *
+ * - **values**: The values in the current scope. If you are using scope changing sub-templates,
+ * you can change what values is.
+ * - **parent**: The scope (values) of the ancestor template.
+ * - **xindex**: If you are in a looping template, the index of the loop you are in (1-based).
+ * - **xcount**: If you are in a looping template, the total length of the array you are looping.
+ *
+ * This example demonstrates basic row striping using an inline code block and the xindex variable:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>Name: {name}</p>',
+ * '<p>Company: {[values.company.toUpperCase() + ", " + values.title]}</p>',
+ * '<p>Kids: ',
+ * '<tpl for="kids">',
+ * '<div class="{[xindex % 2 === 0 ? "even" : "odd"]}">',
+ * '{name}',
+ * '</div>',
+ * '</tpl></p>'
+ * );
+ * tpl.overwrite(panel.body, data);
+ *
+ * # Template member functions
+ *
+ * One or more member functions can be specified in a configuration object passed into the XTemplate constructor for
+ * more complex processing:
+ *
+ * var tpl = new Ext.XTemplate(
+ * '<p>Name: {name}</p>',
+ * '<p>Kids: ',
+ * '<tpl for="kids">',
+ * '<tpl if="this.isGirl(name)">',
+ * '<p>Girl: {name} - {age}</p>',
+ * '</tpl>',
+ * // use opposite if statement to simulate 'else' processing:
+ * '<tpl if="this.isGirl(name) == false">',
+ * '<p>Boy: {name} - {age}</p>',
+ * '</tpl>',
+ * '<tpl if="this.isBaby(age)">',
+ * '<p>{name} is a baby!</p>',
+ * '</tpl>',
+ * '</tpl></p>',
+ * {
+ * // XTemplate configuration:
+ * disableFormats: true,
+ * // member functions:
+ * isGirl: function(name){
+ * return name == 'Sara Grace';
+ * },
+ * isBaby: function(age){
+ * return age < 1;
+ * }
+ * }
+ * );
+ * tpl.overwrite(panel.body, data);
+ */
+Ext.define('Ext.XTemplate', {
+
+ /* Begin Definitions */
+
+ extend: 'Ext.Template',
+
+ /* End Definitions */
+
+ argsRe: /<tpl\b[^>]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/,
+ nameRe: /^<tpl\b[^>]*?for="(.*?)"/,
+ ifRe: /^<tpl\b[^>]*?if="(.*?)"/,
+ execRe: /^<tpl\b[^>]*?exec="(.*?)"/,
+ constructor: function() {
+ this.callParent(arguments);
+
+ var me = this,
+ html = me.html,
+ argsRe = me.argsRe,
+ nameRe = me.nameRe,
+ ifRe = me.ifRe,
+ execRe = me.execRe,
+ id = 0,
+ tpls = [],
+ VALUES = 'values',
+ PARENT = 'parent',
+ XINDEX = 'xindex',
+ XCOUNT = 'xcount',
+ RETURN = 'return ',
+ WITHVALUES = 'with(values){ ',
+ m, matchName, matchIf, matchExec, exp, fn, exec, name, i;
+
+ html = ['<tpl>', html, '</tpl>'].join('');
+
+ while ((m = html.match(argsRe))) {
+ exp = null;
+ fn = null;
+ exec = null;
+ matchName = m[0].match(nameRe);
+ matchIf = m[0].match(ifRe);
+ matchExec = m[0].match(execRe);
+
+ exp = matchIf ? matchIf[1] : null;
+ if (exp) {
+ fn = Ext.functionFactory(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES + 'try{' + RETURN + Ext.String.htmlDecode(exp) + ';}catch(e){return;}}');
+ }
+
+ exp = matchExec ? matchExec[1] : null;
+ if (exp) {
+ exec = Ext.functionFactory(VALUES, PARENT, XINDEX, XCOUNT, WITHVALUES + Ext.String.htmlDecode(exp) + ';}');
+ }
+
+ name = matchName ? matchName[1] : null;
+ if (name) {
+ if (name === '.') {
+ name = VALUES;
+ } else if (name === '..') {
+ name = PARENT;
+ }
+ name = Ext.functionFactory(VALUES, PARENT, 'try{' + WITHVALUES + RETURN + name + ';}}catch(e){return;}');
+ }
+
+ tpls.push({
+ id: id,
+ target: name,
+ exec: exec,
+ test: fn,
+ body: m[1] || ''
+ });
+
+ html = html.replace(m[0], '{xtpl' + id + '}');
+ id = id + 1;
+ }
+
+ for (i = tpls.length - 1; i >= 0; --i) {
+ me.compileTpl(tpls[i]);
+ }
+ me.master = tpls[tpls.length - 1];
+ me.tpls = tpls;
+ },
+
+ // @private
+ applySubTemplate: function(id, values, parent, xindex, xcount) {
+ var me = this, t = me.tpls[id];
+ return t.compiled.call(me, values, parent, xindex, xcount);
+ },
+
+ /**
+ * @cfg {RegExp} codeRe
+ * The regular expression used to match code variables. Default: matches {[expression]}.
+ */
+ codeRe: /\{\[((?:\\\]|.|\n)*?)\]\}/g,
+
+ /**
+ * @cfg {Boolean} compiled
+ * Only applies to {@link Ext.Template}, XTemplates are compiled automatically.
+ */
+
+ re: /\{([\w-\.\#]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\s?[\+\-\*\/]\s?[\d\.\+\-\*\/\(\)]+)?\}/g,
+
+ // @private
+ compileTpl: function(tpl) {
+ var fm = Ext.util.Format,
+ me = this,
+ useFormat = me.disableFormats !== true,
+ body, bodyReturn, evaluatedFn;
+
+ function fn(m, name, format, args, math) {
+ var v;
+ // name is what is inside the {}
+ // Name begins with xtpl, use a Sub Template
+ if (name.substr(0, 4) == 'xtpl') {
+ return "',this.applySubTemplate(" + name.substr(4) + ", values, parent, xindex, xcount),'";
+ }
+ // name = "." - Just use the values object.
+ if (name == '.') {
+ // filter to not include arrays/objects/nulls
+ v = 'Ext.Array.indexOf(["string", "number", "boolean"], typeof values) > -1 || Ext.isDate(values) ? values : ""';
+ }
+
+ // name = "#" - Use the xindex
+ else if (name == '#') {
+ v = 'xindex';
+ }
+ else if (name.substr(0, 7) == "parent.") {
+ v = name;
+ }
+ // name has a . in it - Use object literal notation, starting from values
+ else if (name.indexOf('.') != -1) {
+ v = "values." + name;
+ }
+
+ // name is a property of values
+ else {
+ v = "values['" + name + "']";
+ }
+ if (math) {
+ v = '(' + v + math + ')';
+ }
+ if (format && useFormat) {
+ args = args ? ',' + args : "";
+ if (format.substr(0, 5) != "this.") {
+ format = "fm." + format + '(';
+ }
+ else {
+ format = 'this.' + format.substr(5) + '(';
+ }
+ }
+ else {
+ args = '';
+ format = "(" + v + " === undefined ? '' : ";
+ }
+ return "'," + format + v + args + "),'";
+ }
+
+ function codeFn(m, code) {
+ // Single quotes get escaped when the template is compiled, however we want to undo this when running code.
+ return "',(" + code.replace(me.compileARe, "'") + "),'";
+ }
+
+ bodyReturn = tpl.body.replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.re, fn).replace(me.codeRe, codeFn);
+ body = "evaluatedFn = function(values, parent, xindex, xcount){return ['" + bodyReturn + "'].join('');};";
+ eval(body);
+
+ tpl.compiled = function(values, parent, xindex, xcount) {
+ var vs,
+ length,
+ buffer,
+ i;
+
+ if (tpl.test && !tpl.test.call(me, values, parent, xindex, xcount)) {
+ return '';
+ }
+
+ vs = tpl.target ? tpl.target.call(me, values, parent) : values;
+ if (!vs) {
+ return '';
+ }
+
+ parent = tpl.target ? values : parent;
+ if (tpl.target && Ext.isArray(vs)) {
+ buffer = [];
+ length = vs.length;
+ if (tpl.exec) {
+ for (i = 0; i < length; i++) {
+ buffer[buffer.length] = evaluatedFn.call(me, vs[i], parent, i + 1, length);
+ tpl.exec.call(me, vs[i], parent, i + 1, length);
+ }
+ } else {
+ for (i = 0; i < length; i++) {
+ buffer[buffer.length] = evaluatedFn.call(me, vs[i], parent, i + 1, length);
+ }
+ }
+ return buffer.join('');
+ }
+
+ if (tpl.exec) {
+ tpl.exec.call(me, vs, parent, xindex, xcount);
+ }
+ return evaluatedFn.call(me, vs, parent, xindex, xcount);
+ };
+
+ return this;
+ },
+
+ // inherit docs from Ext.Template
+ applyTemplate: function(values) {
+ return this.master.compiled.call(this, values, {}, 1, 1);
+ },
+
+ /**
+ * Does nothing. XTemplates are compiled automatically, so this function simply returns this.
+ * @return {Ext.XTemplate} this
+ */
+ compile: function() {
+ return this;
+ }
+}, function() {
+ // re-create the alias, inheriting it from Ext.Template doesn't work as intended.
+ this.createAlias('apply', 'applyTemplate');
+});
+
+
+Ext.define('Ext.app.Controller', {
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+
+
+
+
+
+
+
+
+ onClassExtended: function(cls, data) {
+ var className = Ext.getClassName(cls),
+ match = className.match(/^(.*)\.controller\./);
+
+ if (match !== null) {
+ var namespace = Ext.Loader.getPrefix(className) || match[1],
+ onBeforeClassCreated = data.onBeforeClassCreated,
+ requires = [],
+ modules = ['model', 'view', 'store'],
+ prefix;
+
+ data.onBeforeClassCreated = function(cls, data) {
+ var i, ln, module,
+ items, j, subLn, item;
+
+ for (i = 0,ln = modules.length; i < ln; i++) {
+ module = modules[i];
+
+ items = Ext.Array.from(data[module + 's']);
+
+ for (j = 0,subLn = items.length; j < subLn; j++) {
+ item = items[j];
+
+ prefix = Ext.Loader.getPrefix(item);
+
+ if (prefix === '' || prefix === item) {
+ requires.push(namespace + '.' + module + '.' + item);
+ }
+ else {
+ requires.push(item);
+ }
+ }
+ }
+
+ Ext.require(requires, Ext.Function.pass(onBeforeClassCreated, arguments, this));
+ };
+ }
+ },
+
+
+ constructor: function(config) {
+ this.mixins.observable.constructor.call(this, config);
+
+ Ext.apply(this, config || {});
+
+ this.createGetters('model', this.models);
+ this.createGetters('store', this.stores);
+ this.createGetters('view', this.views);
+
+ if (this.refs) {
+ this.ref(this.refs);
+ }
+ },
+
+
+ init: function(application) {},
+
+
+ onLaunch: function(application) {},
+
+ createGetters: function(type, refs) {
+ type = Ext.String.capitalize(type);
+ Ext.Array.each(refs, function(ref) {
+ var fn = 'get',
+ parts = ref.split('.');
+
+
+ Ext.Array.each(parts, function(part) {
+ fn += Ext.String.capitalize(part);
+ });
+ fn += type;
+
+ if (!this[fn]) {
+ this[fn] = Ext.Function.pass(this['get' + type], [ref], this);
+ }
+
+ this[fn](ref);
+ },
+ this);
+ },
+
+ ref: function(refs) {
+ var me = this;
+ refs = Ext.Array.from(refs);
+ Ext.Array.each(refs, function(info) {
+ var ref = info.ref,
+ fn = 'get' + Ext.String.capitalize(ref);
+ if (!me[fn]) {
+ me[fn] = Ext.Function.pass(me.getRef, [ref, info], me);
+ }
+ });
+ },
+
+ getRef: function(ref, info, config) {
+ this.refCache = this.refCache || {};
+ info = info || {};
+ config = config || {};
+
+ Ext.apply(info, config);
+
+ if (info.forceCreate) {
+ return Ext.ComponentManager.create(info, 'component');
+ }
+
+ var me = this,
+ selector = info.selector,
+ cached = me.refCache[ref];
+
+ if (!cached) {
+ me.refCache[ref] = cached = Ext.ComponentQuery.query(info.selector)[0];
+ if (!cached && info.autoCreate) {
+ me.refCache[ref] = cached = Ext.ComponentManager.create(info, 'component');
+ }
+ if (cached) {
+ cached.on('beforedestroy', function() {
+ me.refCache[ref] = null;
+ });
+ }
+ }
+
+ return cached;
+ },
+
+
+ control: function(selectors, listeners) {
+ this.application.control(selectors, listeners, this);
+ },
+
+
+ getController: function(name) {
+ return this.application.getController(name);
+ },
+
+
+ getStore: function(name) {
+ return this.application.getStore(name);
+ },
+
+
+ getModel: function(model) {
+ return this.application.getModel(model);
+ },
+
+
+ getView: function(view) {
+ return this.application.getView(view);
+ }
+});
+
+
+Ext.define('Ext.data.IdGenerator', {
+
+ isGenerator: true,
+
+
+ constructor: function(config) {
+ var me = this;
+
+ Ext.apply(me, config);
+
+ if (me.id) {
+ Ext.data.IdGenerator.all[me.id] = me;
+ }
+ },
+
+
+
+ getRecId: function (rec) {
+ return rec.modelName + '-' + rec.internalId;
+ },
+
+
+
+ statics: {
+
+ all: {},
+
+
+ get: function (config) {
+ var generator,
+ id,
+ type;
+
+ if (typeof config == 'string') {
+ id = type = config;
+ config = null;
+ } else if (config.isGenerator) {
+ return config;
+ } else {
+ id = config.id || config.type;
+ type = config.type;
+ }
+
+ generator = this.all[id];
+ if (!generator) {
+ generator = Ext.create('idgen.' + type, config);
+ }
+
+ return generator;
+ }
+ }
+});
+
+
+Ext.define('Ext.data.SortTypes', {
+
+ singleton: true,
+
+
+ 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.define('Ext.util.Filter', {
+
+
+
+
+
+
+
+
+
+ anyMatch: false,
+
+
+ exactMatch: false,
+
+
+ caseSensitive: false,
+
+
+
+
+ constructor: function(config) {
+ var me = this;
+ Ext.apply(me, config);
+
+
+
+ me.filter = me.filter || me.filterFn;
+
+ if (me.filter === undefined) {
+ if (me.property === undefined || me.value === undefined) {
+
+
+
+
+ } else {
+ me.filter = me.createFilterFn();
+ }
+
+ me.filterFn = me.filter;
+ }
+ },
+
+
+ createFilterFn: function() {
+ var me = this,
+ matcher = me.createValueMatcher(),
+ property = me.property;
+
+ return function(item) {
+ var value = me.getRoot.call(me, item)[property];
+ return matcher === null ? value === null : matcher.test(value);
+ };
+ },
+
+
+ getRoot: function(item) {
+ var root = this.root;
+ return root === undefined ? item : item[root];
+ },
+
+
+ createValueMatcher : function() {
+ var me = this,
+ value = me.value,
+ anyMatch = me.anyMatch,
+ exactMatch = me.exactMatch,
+ caseSensitive = me.caseSensitive,
+ escapeRe = Ext.String.escapeRegex;
+
+ if (value === null) {
+ return value;
+ }
+
+ if (!value.exec) {
+ value = String(value);
+
+ if (anyMatch === true) {
+ value = escapeRe(value);
+ } else {
+ value = '^' + escapeRe(value);
+ if (exactMatch === true) {
+ value += '$';
+ }
+ }
+ value = new RegExp(value, caseSensitive ? '' : 'i');
+ }
+
+ return value;
+ }
+});
+
+Ext.define('Ext.util.Sorter', {
+
+
+
+
+
+
+
+
+
+
+ direction: "ASC",
+
+ constructor: function(config) {
+ var me = this;
+
+ Ext.apply(me, config);
+
+
+ me.updateSortFunction();
+ },
+
+
+ createSortFunction: function(sorterFn) {
+ var me = this,
+ property = me.property,
+ direction = me.direction || "ASC",
+ modifier = direction.toUpperCase() == "DESC" ? -1 : 1;
+
+
+
+ return function(o1, o2) {
+ return modifier * sorterFn.call(me, o1, o2);
+ };
+ },
+
+
+ defaultSorterFn: function(o1, o2) {
+ var me = this,
+ transform = me.transform,
+ v1 = me.getRoot(o1)[me.property],
+ v2 = me.getRoot(o2)[me.property];
+
+ if (transform) {
+ v1 = transform(v1);
+ v2 = transform(v2);
+ }
+
+ return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
+ },
+
+
+ getRoot: function(item) {
+ return this.root === undefined ? item : item[this.root];
+ },
+
+
+ setDirection: function(direction) {
+ var me = this;
+ me.direction = direction;
+ me.updateSortFunction();
+ },
+
+
+ toggle: function() {
+ var me = this;
+ me.direction = Ext.String.toggle(me.direction, "ASC", "DESC");
+ me.updateSortFunction();
+ },
+
+
+ updateSortFunction: function(fn) {
+ var me = this;
+ fn = fn || me.sorterFn || me.defaultSorterFn;
+ me.sort = me.createSortFunction(fn);
+ }
+});
+
+Ext.define('Ext.data.Operation', {
+
+ synchronous: true,
+
+
+ action: undefined,
+
+
+ filters: undefined,
+
+
+ sorters: undefined,
+
+
+ group: undefined,
+
+
+ start: undefined,
+
+
+ limit: undefined,
+
+
+ batch: undefined,
+
+
+ callback: undefined,
+
+
+ scope: undefined,
+
+
+ started: false,
+
+
+ running: false,
+
+
+ complete: false,
+
+
+ success: undefined,
+
+
+ exception: false,
+
+
+ error: undefined,
+
+
+ actionCommitRecordsRe: /^(?:create|update)$/i,
+
+
+ actionSkipSyncRe: /^destroy$/i,
+
+
+ constructor: function(config) {
+ Ext.apply(this, config || {});
+ },
+
+
+ commitRecords: function (serverRecords) {
+ var me = this,
+ mc, index, clientRecords, serverRec, clientRec;
+
+ if (!me.actionSkipSyncRe.test(me.action)) {
+ clientRecords = me.records;
+
+ if (clientRecords && clientRecords.length) {
+ mc = Ext.create('Ext.util.MixedCollection', true, function(r) {return r.getId();});
+ mc.addAll(clientRecords);
+
+ for (index = serverRecords ? serverRecords.length : 0; index--; ) {
+ serverRec = serverRecords[index];
+ clientRec = mc.get(serverRec.getId());
+
+ if (clientRec) {
+ clientRec.beginEdit();
+ clientRec.set(serverRec.data);
+ clientRec.endEdit(true);
+ }
+ }
+
+ if (me.actionCommitRecordsRe.test(me.action)) {
+ for (index = clientRecords.length; index--; ) {
+ clientRecords[index].commit();
+ }
+ }
+ }
+ }
+ },
+
+
+ setStarted: function() {
+ this.started = true;
+ this.running = true;
+ },
+
+
+ setCompleted: function() {
+ this.complete = true;
+ this.running = false;
+ },
+
+
+ setSuccessful: function() {
+ this.success = true;
+ },
+
+
+ setException: function(error) {
+ this.exception = true;
+ this.success = false;
+ this.running = false;
+ this.error = error;
+ },
+
+
+ hasException: function() {
+ return this.exception === true;
+ },
+
+
+ getError: function() {
+ return this.error;
+ },
+
+
+ getRecords: function() {
+ var resultSet = this.getResultSet();
+
+ return (resultSet === undefined ? this.records : resultSet.records);
+ },
+
+
+ getResultSet: function() {
+ return this.resultSet;
+ },
+
+
+ isStarted: function() {
+ return this.started === true;
+ },
+
+
+ isRunning: function() {
+ return this.running === true;
+ },
+
+
+ isComplete: function() {
+ return this.complete === true;
+ },
+
+
+ wasSuccessful: function() {
+ return this.isComplete() && this.success === true;
+ },
+
+
+ setBatch: function(batch) {
+ this.batch = batch;
+ },
+
+
+ allowWrite: function() {
+ return this.action != 'read';
+ }
+});
+
+Ext.define('Ext.data.validations', {
+ singleton: true,
+
+
+ presenceMessage: 'must be present',
+
+
+ lengthMessage: 'is the wrong length',
+
+
+ formatMessage: 'is the wrong format',
+
+
+ inclusionMessage: 'is not included in the list of acceptable values',
+
+
+ exclusionMessage: 'is not an acceptable value',
+
+
+ emailMessage: 'is not a valid email address',
+
+
+ emailRe: /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
+
+
+ presence: function(config, value) {
+ if (value === undefined) {
+ value = config;
+ }
+
+
+ return !!value || value === 0;
+ },
+
+
+ length: function(config, value) {
+ if (value === undefined || value === null) {
+ return false;
+ }
+
+ var length = value.length,
+ min = config.min,
+ max = config.max;
+
+ if ((min && length < min) || (max && length > max)) {
+ return false;
+ } else {
+ return true;
+ }
+ },
+
+
+ email: function(config, email) {
+ return Ext.data.validations.emailRe.test(email);
+ },
+
+
+ format: function(config, value) {
+ return !!(config.matcher && config.matcher.test(value));
+ },
+
+
+ inclusion: function(config, value) {
+ return config.list && Ext.Array.indexOf(config.list,value) != -1;
+ },
+
+
+ exclusion: function(config, value) {
+ return config.list && Ext.Array.indexOf(config.list,value) == -1;
+ }
+});
+
+Ext.define('Ext.data.ResultSet', {
+
+ loaded: true,
+
+
+ count: 0,
+
+
+ total: 0,
+
+
+ success: false,
+
+
+
+
+ constructor: function(config) {
+ Ext.apply(this, config);
+
+
+ this.totalRecords = this.total;
+
+ if (config.count === undefined) {
+ this.count = this.records.length;
+ }
+ }
+});
+
+Ext.define('Ext.data.writer.Writer', {
+ alias: 'writer.base',
+ alternateClassName: ['Ext.data.DataWriter', 'Ext.data.Writer'],
+
+
+ writeAllFields: true,
+
+
+ nameProperty: 'name',
+
+
+ constructor: function(config) {
+ Ext.apply(this, config);
+ },
+
+
+ write: function(request) {
+ var operation = request.operation,
+ records = operation.records || [],
+ len = records.length,
+ i = 0,
+ data = [];
+
+ for (; i < len; i++) {
+ data.push(this.getRecordData(records[i]));
+ }
+ return this.writeRecords(request, data);
+ },
+
+
+ getRecordData: function(record) {
+ var isPhantom = record.phantom === true,
+ writeAll = this.writeAllFields || isPhantom,
+ nameProperty = this.nameProperty,
+ fields = record.fields,
+ data = {},
+ changes,
+ name,
+ field,
+ key;
+
+ if (writeAll) {
+ fields.each(function(field){
+ if (field.persist) {
+ name = field[nameProperty] || field.name;
+ data[name] = record.get(field.name);
+ }
+ });
+ } else {
+
+ changes = record.getChanges();
+ for (key in changes) {
+ if (changes.hasOwnProperty(key)) {
+ field = fields.get(key);
+ name = field[nameProperty] || field.name;
+ data[name] = changes[key];
+ }
+ }
+ if (!isPhantom) {
+
+ data[record.idProperty] = record.getId();
+ }
+ }
+ return data;
+ }
+});
+
+
+Ext.define('Ext.util.Floating', {
+
+ uses: ['Ext.Layer', 'Ext.window.Window'],
+
+
+ focusOnToFront: true,
+
+
+ shadow: 'sides',
+
+ constructor: function(config) {
+ var me = this;
+
+ me.floating = true;
+ me.el = Ext.create('Ext.Layer', Ext.apply({}, config, {
+ hideMode: me.hideMode,
+ hidden: me.hidden,
+ shadow: Ext.isDefined(me.shadow) ? me.shadow : 'sides',
+ shadowOffset: me.shadowOffset,
+ constrain: false,
+ shim: me.shim === false ? false : undefined
+ }), me.el);
+ },
+
+ onFloatRender: function() {
+ var me = this;
+ me.zIndexParent = me.getZIndexParent();
+ me.setFloatParent(me.ownerCt);
+ delete me.ownerCt;
+
+ if (me.zIndexParent) {
+ me.zIndexParent.registerFloatingItem(me);
+ } else {
+ Ext.WindowManager.register(me);
+ }
+ },
+
+ setFloatParent: function(floatParent) {
+ var me = this;
+
+
+ if (me.floatParent) {
+ me.mun(me.floatParent, {
+ hide: me.onFloatParentHide,
+ show: me.onFloatParentShow,
+ scope: me
+ });
+ }
+
+ me.floatParent = floatParent;
+
+
+ if (floatParent) {
+ me.mon(me.floatParent, {
+ hide: me.onFloatParentHide,
+ show: me.onFloatParentShow,
+ scope: me
+ });
+ }
+
+
+
+ if ((me.constrain || me.constrainHeader) && !me.constrainTo) {
+ me.constrainTo = floatParent ? floatParent.getTargetEl() : me.container;
+ }
+ },
+
+ onFloatParentHide: function() {
+ var me = this;
+
+ if (me.hideOnParentHide !== false) {
+ me.showOnParentShow = me.isVisible();
+ me.hide();
+ }
+ },
+
+ onFloatParentShow: function() {
+ if (this.showOnParentShow) {
+ delete this.showOnParentShow;
+ this.show();
+ }
+ },
+
+
+ getZIndexParent: function() {
+ var p = this.ownerCt,
+ c;
+
+ if (p) {
+ while (p) {
+ c = p;
+ p = p.ownerCt;
+ }
+ if (c.floating) {
+ return c;
+ }
+ }
+ },
+
+
+
+
+
+
+ setZIndex: function(index) {
+ var me = this;
+ me.el.setZIndex(index);
+
+
+ index += 10;
+
+
+
+ if (me.floatingItems) {
+ index = Math.floor(me.floatingItems.setBase(index) / 100) * 100 + 10000;
+ }
+ return index;
+ },
+
+
+ doConstrain: function(constrainTo) {
+ var me = this,
+ vector = me.getConstrainVector(constrainTo || me.el.getScopeParent()),
+ xy;
+
+ if (vector) {
+ xy = me.getPosition();
+ xy[0] += vector[0];
+ xy[1] += vector[1];
+ me.setPosition(xy);
+ }
+ },
+
+
+
+ getConstrainVector: function(constrainTo){
+ var me = this,
+ el;
+
+ if (me.constrain || me.constrainHeader) {
+ el = me.constrainHeader ? me.header.el : me.el;
+ constrainTo = constrainTo || (me.floatParent && me.floatParent.getTargetEl()) || me.container;
+ return el.getConstrainVector(constrainTo);
+ }
+ },
+
+
+ alignTo: function(element, position, offsets) {
+ if (element.isComponent) {
+ element = element.getEl();
+ }
+ var xy = this.el.getAlignToXY(element, position, offsets);
+ this.setPagePosition(xy);
+ return this;
+ },
+
+
+ toFront: function(preventFocus) {
+ var me = this;
+
+
+
+ if (me.zIndexParent) {
+ me.zIndexParent.toFront(true);
+ }
+ if (me.zIndexManager.bringToFront(me)) {
+ if (!Ext.isDefined(preventFocus)) {
+ preventFocus = !me.focusOnToFront;
+ }
+ if (!preventFocus) {
+
+
+
+ me.focus(false, true);
+ }
+ }
+ return me;
+ },
+
+
+ setActive: function(active, newActive) {
+ var me = this;
+
+ if (active) {
+ if (me.el.shadow && !me.maximized) {
+ me.el.enableShadow(true);
+ }
+ me.fireEvent('activate', me);
+ } else {
+
+
+ if ((me instanceof Ext.window.Window) && (newActive instanceof Ext.window.Window)) {
+ me.el.disableShadow();
+ }
+ me.fireEvent('deactivate', me);
+ }
+ },
+
+
+ toBack: function() {
+ this.zIndexManager.sendToBack(this);
+ return this;
+ },
+
+
+ center: function() {
+ var me = this,
+ xy = me.el.getAlignToXY(me.container, 'c-c');
+ me.setPagePosition(xy);
+ return me;
+ },
+
+
+ syncShadow : function(){
+ if (this.floating) {
+ this.el.sync(true);
+ }
+ },
+
+
+ fitContainer: function() {
+ var parent = this.floatParent,
+ container = parent ? parent.getTargetEl() : this.container,
+ size = container.getViewSize(false);
+
+ this.setSize(size);
+ }
+});
+
+Ext.define('Ext.layout.Layout', {
+
+
+
+
+
+ isLayout: true,
+ initialized: false,
+
+ statics: {
+ create: function(layout, defaultType) {
+ var type;
+ if (layout instanceof Ext.layout.Layout) {
+ return Ext.createByAlias('layout.' + layout);
+ } else {
+ if (!layout || typeof layout === 'string') {
+ type = layout || defaultType;
+ layout = {};
+ }
+ else {
+ type = layout.type || defaultType;
+ }
+ return Ext.createByAlias('layout.' + type, layout || {});
+ }
+ }
+ },
+
+ constructor : function(config) {
+ this.id = Ext.id(null, this.type + '-');
+ Ext.apply(this, config);
+ },
+
+
+ layout : function() {
+ var me = this;
+ me.layoutBusy = true;
+ me.initLayout();
+
+ if (me.beforeLayout.apply(me, arguments) !== false) {
+ me.layoutCancelled = false;
+ me.onLayout.apply(me, arguments);
+ me.childrenChanged = false;
+ me.owner.needsLayout = false;
+ me.layoutBusy = false;
+ me.afterLayout.apply(me, arguments);
+ }
+ else {
+ me.layoutCancelled = true;
+ }
+ me.layoutBusy = false;
+ me.doOwnerCtLayouts();
+ },
+
+ beforeLayout : function() {
+ this.renderChildren();
+ return true;
+ },
+
+ renderChildren: function () {
+ this.renderItems(this.getLayoutItems(), this.getRenderTarget());
+ },
+
+
+ renderItems : function(items, target) {
+ var me = this,
+ ln = items.length,
+ i = 0,
+ item;
+
+ for (; i < ln; i++) {
+ item = items[i];
+ if (item && !item.rendered) {
+ me.renderItem(item, target, i);
+ } else if (!me.isValidParent(item, target, i)) {
+ me.moveItem(item, target, i);
+ } else {
+
+ me.configureItem(item);
+ }
+ }
+ },
+
+
+ isValidParent : function(item, target, position) {
+ var dom = item.el ? item.el.dom : Ext.getDom(item);
+ if (dom && target && target.dom) {
+ if (Ext.isNumber(position) && dom !== target.dom.childNodes[position]) {
+ return false;
+ }
+ return (dom.parentNode == (target.dom || target));
+ }
+ return false;
+ },
+
+
+ renderItem : function(item, target, position) {
+ var me = this;
+ if (!item.rendered) {
+ if (me.itemCls) {
+ item.addCls(me.itemCls);
+ }
+ if (me.owner.itemCls) {
+ item.addCls(me.owner.itemCls);
+ }
+ item.render(target, position);
+ me.configureItem(item);
+ me.childrenChanged = true;
+ }
+ },
+
+
+ moveItem : function(item, target, position) {
+
+ target = target.dom || target;
+ if (typeof position == 'number') {
+ position = target.childNodes[position];
+ }
+ target.insertBefore(item.el.dom, position || null);
+ item.container = Ext.get(target);
+ this.configureItem(item);
+ this.childrenChanged = true;
+ },
+
+
+ initLayout : function() {
+ var me = this,
+ targetCls = me.targetCls;
+
+ if (!me.initialized && !Ext.isEmpty(targetCls)) {
+ me.getTarget().addCls(targetCls);
+ }
+ me.initialized = true;
+ },
+
+
+ setOwner : function(owner) {
+ this.owner = owner;
+ },
+
+
+ getLayoutItems : function() {
+ return [];
+ },
+
+
+ configureItem: Ext.emptyFn,
+
+
+ onLayout : Ext.emptyFn,
+ afterLayout : Ext.emptyFn,
+ onRemove : Ext.emptyFn,
+ onDestroy : Ext.emptyFn,
+ doOwnerCtLayouts : Ext.emptyFn,
+
+
+ afterRemove : function(item) {
+ var el = item.el,
+ owner = this.owner,
+ itemCls = this.itemCls,
+ ownerCls = owner.itemCls;
+
+
+ if (item.rendered && !item.isDestroyed) {
+ if (itemCls) {
+ el.removeCls(itemCls);
+ }
+ if (ownerCls) {
+ el.removeCls(ownerCls);
+ }
+ }
+
+
+
+
+ delete item.layoutManagedWidth;
+ delete item.layoutManagedHeight;
+ },
+
+
+ destroy : function() {
+ var targetCls = this.targetCls,
+ target;
+
+ if (!Ext.isEmpty(targetCls)) {
+ target = this.getTarget();
+ if (target) {
+ target.removeCls(targetCls);
+ }
+ }
+ this.onDestroy();
+ }
+});
+
+Ext.define('Ext.ZIndexManager', {
+
+ alternateClassName: 'Ext.WindowGroup',
+
+ statics: {
+ zBase : 9000
+ },
+
+ constructor: function(container) {
+ var me = this;
+
+ me.list = {};
+ me.zIndexStack = [];
+ me.front = null;
+
+ if (container) {
+
+
+ if (container.isContainer) {
+ container.on('resize', me._onContainerResize, me);
+ me.zseed = Ext.Number.from(container.getEl().getStyle('zIndex'), me.getNextZSeed());
+
+ me.targetEl = container.getTargetEl();
+ me.container = container;
+ }
+
+ else {
+ Ext.EventManager.onWindowResize(me._onContainerResize, me);
+ me.zseed = me.getNextZSeed();
+ me.targetEl = Ext.get(container);
+ }
+ }
+
+
+ else {
+ Ext.EventManager.onWindowResize(me._onContainerResize, me);
+ me.zseed = me.getNextZSeed();
+ Ext.onDocumentReady(function() {
+ me.targetEl = Ext.getBody();
+ });
+ }
+ },
+
+ getNextZSeed: function() {
+ return (Ext.ZIndexManager.zBase += 10000);
+ },
+
+ setBase: function(baseZIndex) {
+ this.zseed = baseZIndex;
+ return this.assignZIndices();
+ },
+
+
+ assignZIndices: function() {
+ var a = this.zIndexStack,
+ len = a.length,
+ i = 0,
+ zIndex = this.zseed,
+ comp;
+
+ for (; i < len; i++) {
+ comp = a[i];
+ if (comp && !comp.hidden) {
+
+
+
+
+
+
+
+
+ zIndex = comp.setZIndex(zIndex);
+ }
+ }
+ this._activateLast();
+ return zIndex;
+ },
+
+
+ _setActiveChild: function(comp) {
+ if (comp !== this.front) {
+
+ if (this.front) {
+ this.front.setActive(false, comp);
+ }
+ this.front = comp;
+ if (comp) {
+ comp.setActive(true);
+ if (comp.modal) {
+ this._showModalMask(comp);
+ }
+ }
+ }
+ },
+
+
+ _activateLast: function(justHidden) {
+ var comp,
+ lastActivated = false,
+ i;
+
+
+
+
+ for (i = this.zIndexStack.length-1; i >= 0; --i) {
+ comp = this.zIndexStack[i];
+ if (!comp.hidden) {
+ if (!lastActivated) {
+ this._setActiveChild(comp);
+ lastActivated = true;
+ }
+
+
+ if (comp.modal) {
+ this._showModalMask(comp);
+ return;
+ }
+ }
+ }
+
+
+
+ this._hideModalMask();
+ if (!lastActivated) {
+ this._setActiveChild(null);
+ }
+ },
+
+ _showModalMask: function(comp) {
+ var zIndex = comp.el.getStyle('zIndex') - 4,
+ maskTarget = comp.floatParent ? comp.floatParent.getTargetEl() : Ext.get(comp.getEl().dom.parentNode),
+ parentBox;
+
+ if (!maskTarget) {
+ return;
+ }
+
+ parentBox = maskTarget.getBox();
+
+ if (!this.mask) {
+ this.mask = Ext.getBody().createChild({
+ cls: Ext.baseCSSPrefix + 'mask'
+ });
+ this.mask.setVisibilityMode(Ext.Element.DISPLAY);
+ this.mask.on('click', this._onMaskClick, this);
+ }
+ if (maskTarget.dom === document.body) {
+ parentBox.height = Ext.Element.getViewHeight();
+ }
+ maskTarget.addCls(Ext.baseCSSPrefix + 'body-masked');
+ this.mask.setBox(parentBox);
+ this.mask.setStyle('zIndex', zIndex);
+ this.mask.show();
+ },
+
+ _hideModalMask: function() {
+ if (this.mask && this.mask.dom.parentNode) {
+ Ext.get(this.mask.dom.parentNode).removeCls(Ext.baseCSSPrefix + 'body-masked');
+ this.mask.hide();
+ }
+ },
+
+ _onMaskClick: function() {
+ if (this.front) {
+ this.front.focus();
+ }
+ },
+
+ _onContainerResize: function() {
+ if (this.mask && this.mask.isVisible()) {
+ this.mask.setSize(Ext.get(this.mask.dom.parentNode).getViewSize(true));
+ }
+ },
+
+
+ register : function(comp) {
+ if (comp.zIndexManager) {
+ comp.zIndexManager.unregister(comp);
+ }
+ comp.zIndexManager = this;
+
+ this.list[comp.id] = comp;
+ this.zIndexStack.push(comp);
+ comp.on('hide', this._activateLast, this);
+ },
+
+
+ unregister : function(comp) {
+ delete comp.zIndexManager;
+ if (this.list && this.list[comp.id]) {
+ delete this.list[comp.id];
+ comp.un('hide', this._activateLast);
+ Ext.Array.remove(this.zIndexStack, comp);
+
+
+ this._activateLast(comp);
+ }
+ },
+
+
+ get : function(id) {
+ return typeof id == "object" ? id : this.list[id];
+ },
+
+
+ bringToFront : function(comp) {
+ comp = this.get(comp);
+ if (comp !== this.front) {
+ Ext.Array.remove(this.zIndexStack, comp);
+ this.zIndexStack.push(comp);
+ this.assignZIndices();
+ return true;
+ }
+ if (comp.modal) {
+ this._showModalMask(comp);
+ }
+ return false;
+ },
+
+
+ sendToBack : function(comp) {
+ comp = this.get(comp);
+ Ext.Array.remove(this.zIndexStack, comp);
+ this.zIndexStack.unshift(comp);
+ this.assignZIndices();
+ return comp;
+ },
+
+
+ hideAll : function() {
+ for (var id in this.list) {
+ if (this.list[id].isComponent && this.list[id].isVisible()) {
+ this.list[id].hide();
+ }
+ }
+ },
+
+
+ hide: function() {
+ var i = 0,
+ ln = this.zIndexStack.length,
+ comp;
+
+ this.tempHidden = [];
+ for (; i < ln; i++) {
+ comp = this.zIndexStack[i];
+ if (comp.isVisible()) {
+ this.tempHidden.push(comp);
+ comp.hide();
+ }
+ }
+ },
+
+
+ show: function() {
+ var i = 0,
+ ln = this.tempHidden.length,
+ comp,
+ x,
+ y;
+
+ for (; i < ln; i++) {
+ comp = this.tempHidden[i];
+ x = comp.x;
+ y = comp.y;
+ comp.show();
+ comp.setPosition(x, y);
+ }
+ delete this.tempHidden;
+ },
+
+
+ getActive : function() {
+ return this.front;
+ },
+
+
+ getBy : function(fn, scope) {
+ var r = [],
+ i = 0,
+ len = this.zIndexStack.length,
+ comp;
+
+ for (; i < len; i++) {
+ comp = this.zIndexStack[i];
+ if (fn.call(scope||comp, comp) !== false) {
+ r.push(comp);
+ }
+ }
+ return r;
+ },
+
+
+ each : function(fn, scope) {
+ var comp;
+ for (var id in this.list) {
+ comp = this.list[id];
+ if (comp.isComponent && fn.call(scope || comp, comp) === false) {
+ return;
+ }
+ }
+ },
+
+
+ eachBottomUp: function (fn, scope) {
+ var comp,
+ stack = this.zIndexStack,
+ i, n;
+
+ for (i = 0, n = stack.length ; i < n; i++) {
+ comp = stack[i];
+ if (comp.isComponent && fn.call(scope || comp, comp) === false) {
+ return;
+ }
+ }
+ },
+
+
+ eachTopDown: function (fn, scope) {
+ var comp,
+ stack = this.zIndexStack,
+ i;
+
+ for (i = stack.length ; i-- > 0; ) {
+ comp = stack[i];
+ if (comp.isComponent && fn.call(scope || comp, comp) === false) {
+ return;
+ }
+ }
+ },
+
+ destroy: function() {
+ this.each(function(c) {
+ c.destroy();
+ });
+ delete this.zIndexStack;
+ delete this.list;
+ delete this.container;
+ delete this.targetEl;
+ }
+}, function() {
+
+ Ext.WindowManager = Ext.WindowMgr = new this();
+});
+
+
+Ext.define('Ext.layout.container.boxOverflow.None', {
+
+ alternateClassName: 'Ext.layout.boxOverflow.None',
+
+ constructor: function(layout, config) {
+ this.layout = layout;
+ Ext.apply(this, config || {});
+ },
+
+ handleOverflow: Ext.emptyFn,
+
+ clearOverflow: Ext.emptyFn,
+
+ onRemove: Ext.emptyFn,
+
+
+ getItem: function(item) {
+ return this.layout.owner.getComponent(item);
+ },
+
+ onRemove: Ext.emptyFn
+});
+
+Ext.define('Ext.util.KeyMap', {
+ alternateClassName: 'Ext.KeyMap',
+
+
+ constructor: function(el, binding, eventName){
+ var me = this;
+
+ Ext.apply(me, {
+ el: Ext.get(el),
+ eventName: eventName || me.eventName,
+ bindings: []
+ });
+ if (binding) {
+ me.addBinding(binding);
+ }
+ me.enable();
+ },
+
+ eventName: 'keydown',
+
+
+ addBinding : function(binding){
+ if (Ext.isArray(binding)) {
+ Ext.each(binding, this.addBinding, this);
+ return;
+ }
+
+ var keyCode = binding.key,
+ processed = false,
+ key,
+ keys,
+ keyString,
+ i,
+ len;
+
+ if (Ext.isString(keyCode)) {
+ keys = [];
+ keyString = keyCode.toUpperCase();
+
+ for (i = 0, len = keyString.length; i < len; ++i){
+ keys.push(keyString.charCodeAt(i));
+ }
+ keyCode = keys;
+ processed = true;
+ }
+
+ if (!Ext.isArray(keyCode)) {
+ keyCode = [keyCode];
+ }
+
+ if (!processed) {
+ for (i = 0, len = keyCode.length; i < len; ++i) {
+ key = keyCode[i];
+ if (Ext.isString(key)) {
+ keyCode[i] = key.toUpperCase().charCodeAt(0);
+ }
+ }
+ }
+
+ this.bindings.push(Ext.apply({
+ keyCode: keyCode
+ }, binding));
+ },
+
+
+ handleKeyDown: function(event) {
+ if (this.enabled) {
+ var bindings = this.bindings,
+ i = 0,
+ len = bindings.length;
+
+ event = this.processEvent(event);
+ for(; i < len; ++i){
+ this.processBinding(bindings[i], event);
+ }
+ }
+ },
+
+
+ processEvent: function(event){
+ return event;
+ },
+
+
+ processBinding: function(binding, event){
+ if (this.checkModifiers(binding, event)) {
+ var key = event.getKey(),
+ handler = binding.fn || binding.handler,
+ scope = binding.scope || this,
+ keyCode = binding.keyCode,
+ defaultEventAction = binding.defaultEventAction,
+ i,
+ len,
+ keydownEvent = new Ext.EventObjectImpl(event);
+
+
+ for (i = 0, len = keyCode.length; i < len; ++i) {
+ if (key === keyCode[i]) {
+ if (handler.call(scope, key, event) !== true && defaultEventAction) {
+ keydownEvent[defaultEventAction]();
+ }
+ break;
+ }
+ }
+ }
+ },
+
+
+ checkModifiers: function(binding, e){
+ var keys = ['shift', 'ctrl', 'alt'],
+ i = 0,
+ len = keys.length,
+ val, key;
+
+ for (; i < len; ++i){
+ key = keys[i];
+ val = binding[key];
+ if (!(val === undefined || (val === e[key + 'Key']))) {
+ return false;
+ }
+ }
+ return true;
+ },
+
+
+ on: function(key, fn, scope) {
+ var keyCode, shift, ctrl, alt;
+ if (Ext.isObject(key) && !Ext.isArray(key)) {
+ keyCode = key.key;
+ shift = key.shift;
+ ctrl = key.ctrl;
+ alt = key.alt;
+ } else {
+ keyCode = key;
+ }
+ this.addBinding({
+ key: keyCode,
+ shift: shift,
+ ctrl: ctrl,
+ alt: alt,
+ fn: fn,
+ scope: scope
+ });
+ },
+
+
+ isEnabled : function(){
+ return this.enabled;
+ },
+
+
+ enable: function(){
+ var me = this;
+
+ if (!me.enabled) {
+ me.el.on(me.eventName, me.handleKeyDown, me);
+ me.enabled = true;
+ }
+ },
+
+
+ disable: function(){
+ var me = this;
+
+ if (me.enabled) {
+ me.el.removeListener(me.eventName, me.handleKeyDown, me);
+ me.enabled = false;
+ }
+ },
+
+
+ setDisabled : function(disabled){
+ if (disabled) {
+ this.disable();
+ } else {
+ this.enable();
+ }
+ },
+
+
+ destroy: function(removeEl){
+ var me = this;
+
+ me.bindings = [];
+ me.disable();
+ if (removeEl === true) {
+ me.el.remove();
+ }
+ delete me.el;
+ }
+});
+
+Ext.define('Ext.util.ClickRepeater', {
+ extend: 'Ext.util.Observable',
+
+
+ constructor : function(el, config){
+ this.el = Ext.get(el);
+ this.el.unselectable();
+
+ Ext.apply(this, config);
+
+ this.addEvents(
+
+ "mousedown",
+
+ "click",
+
+ "mouseup"
+ );
+
+ if(!this.disabled){
+ this.disabled = true;
+ this.enable();
+ }
+
+
+ if(this.handler){
+ this.on("click", this.handler, this.scope || this);
+ }
+
+ this.callParent();
+ },
+
+
+
+
+
+
+
+
+ interval : 20,
+
+
+ delay: 250,
+
+
+ preventDefault : true,
+
+ stopDefault : false,
+
+ timer : 0,
+
+
+ enable: function(){
+ if(this.disabled){
+ this.el.on('mousedown', this.handleMouseDown, this);
+ if (Ext.isIE){
+ this.el.on('dblclick', this.handleDblClick, this);
+ }
+ if(this.preventDefault || this.stopDefault){
+ this.el.on('click', this.eventOptions, this);
+ }
+ }
+ this.disabled = false;
+ },
+
+
+ disable: function( force){
+ if(force || !this.disabled){
+ clearTimeout(this.timer);
+ if(this.pressedCls){
+ this.el.removeCls(this.pressedCls);
+ }
+ Ext.getDoc().un('mouseup', this.handleMouseUp, this);
+ this.el.removeAllListeners();
+ }
+ this.disabled = true;
+ },
+
+
+ setDisabled: function(disabled){
+ this[disabled ? 'disable' : 'enable']();
+ },
+
+ eventOptions: function(e){
+ if(this.preventDefault){
+ e.preventDefault();
+ }
+ if(this.stopDefault){
+ e.stopEvent();
+ }
+ },
+
+
+ destroy : function() {
+ this.disable(true);
+ Ext.destroy(this.el);
+ this.clearListeners();
+ },
+
+ handleDblClick : function(e){
+ clearTimeout(this.timer);
+ this.el.blur();
+
+ this.fireEvent("mousedown", this, e);
+ this.fireEvent("click", this, e);
+ },
+
+
+ handleMouseDown : function(e){
+ clearTimeout(this.timer);
+ this.el.blur();
+ if(this.pressedCls){
+ this.el.addCls(this.pressedCls);
+ }
+ this.mousedownTime = new Date();
+
+ Ext.getDoc().on("mouseup", this.handleMouseUp, this);
+ this.el.on("mouseout", this.handleMouseOut, this);
+
+ this.fireEvent("mousedown", this, e);
+ this.fireEvent("click", this, e);
+
+
+ if (this.accelerate) {
+ this.delay = 400;
+ }
+
+
+
+ e = new Ext.EventObjectImpl(e);
+
+ this.timer = Ext.defer(this.click, this.delay || this.interval, this, [e]);
+ },
+
+
+ click : function(e){
+ this.fireEvent("click", this, e);
+ this.timer = Ext.defer(this.click, this.accelerate ?
+ this.easeOutExpo(Ext.Date.getElapsed(this.mousedownTime),
+ 400,
+ -390,
+ 12000) :
+ this.interval, this, [e]);
+ },
+
+ easeOutExpo : function (t, b, c, d) {
+ return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
+ },
+
+
+ handleMouseOut : function(){
+ clearTimeout(this.timer);
+ if(this.pressedCls){
+ this.el.removeCls(this.pressedCls);
+ }
+ this.el.on("mouseover", this.handleMouseReturn, this);
+ },
+
+
+ handleMouseReturn : function(){
+ this.el.un("mouseover", this.handleMouseReturn, this);
+ if(this.pressedCls){
+ this.el.addCls(this.pressedCls);
+ }
+ this.click();
+ },
+
+
+ handleMouseUp : function(e){
+ clearTimeout(this.timer);
+ this.el.un("mouseover", this.handleMouseReturn, this);
+ this.el.un("mouseout", this.handleMouseOut, this);
+ Ext.getDoc().un("mouseup", this.handleMouseUp, this);
+ if(this.pressedCls){
+ this.el.removeCls(this.pressedCls);
+ }
+ this.fireEvent("mouseup", this, e);
+ }
+});
+
+
+Ext.define('Ext.layout.component.Component', {
+
+
+
+ extend: 'Ext.layout.Layout',
+
+
+
+ type: 'component',
+
+ monitorChildren: true,
+
+ initLayout : function() {
+ var me = this,
+ owner = me.owner,
+ ownerEl = owner.el;
+
+ if (!me.initialized) {
+ if (owner.frameSize) {
+ me.frameSize = owner.frameSize;
+ }
+ else {
+ owner.frameSize = me.frameSize = {
+ top: 0,
+ left: 0,
+ bottom: 0,
+ right: 0
+ };
+ }
+ }
+ me.callParent(arguments);
+ },
+
+ beforeLayout : function(width, height, isSetSize, callingContainer) {
+ this.callParent(arguments);
+
+ var me = this,
+ owner = me.owner,
+ ownerCt = owner.ownerCt,
+ layout = owner.layout,
+ isVisible = owner.isVisible(true),
+ ownerElChild = owner.el.child,
+ layoutCollection;
+
+
+ me.previousComponentSize = me.lastComponentSize;
+
+
+ if (!isSetSize
+ && ((!Ext.isNumber(width) && owner.isFixedWidth()) ||
+ (!Ext.isNumber(height) && owner.isFixedHeight()))
+
+ && callingContainer && callingContainer !== ownerCt) {
+
+ me.doContainerLayout();
+ return false;
+ }
+
+
+
+ if (!isVisible && (owner.hiddenAncestor || owner.floating)) {
+ if (owner.hiddenAncestor) {
+ layoutCollection = owner.hiddenAncestor.layoutOnShow;
+ layoutCollection.remove(owner);
+ layoutCollection.add(owner);
+ }
+ owner.needsLayout = {
+ width: width,
+ height: height,
+ isSetSize: false
+ };
+ }
+
+ if (isVisible && this.needsLayout(width, height)) {
+ return owner.beforeComponentLayout(width, height, isSetSize, callingContainer);
+ }
+ else {
+ return false;
+ }
+ },
+
+
+ needsLayout : function(width, height) {
+ var me = this,
+ widthBeingChanged,
+ heightBeingChanged;
+ me.lastComponentSize = me.lastComponentSize || {
+ width: -Infinity,
+ height: -Infinity
+ };
+
+
+ widthBeingChanged = !Ext.isDefined(width) || me.lastComponentSize.width !== width;
+
+
+ heightBeingChanged = !Ext.isDefined(height) || me.lastComponentSize.height !== height;
+
+
+
+ return !me.isSizing && (me.childrenChanged || widthBeingChanged || heightBeingChanged);
+ },
+
+
+ setElementSize: function(el, width, height) {
+ if (width !== undefined && height !== undefined) {
+ el.setSize(width, height);
+ }
+ else if (height !== undefined) {
+ el.setHeight(height);
+ }
+ else if (width !== undefined) {
+ el.setWidth(width);
+ }
+ },
+
+
+ getTarget : function() {
+ return this.owner.el;
+ },
+
+
+ getRenderTarget : function() {
+ return this.owner.el;
+ },
+
+
+ setTargetSize : function(width, height) {
+ var me = this;
+ me.setElementSize(me.owner.el, width, height);
+
+ if (me.owner.frameBody) {
+ var targetInfo = me.getTargetInfo(),
+ padding = targetInfo.padding,
+ border = targetInfo.border,
+ frameSize = me.frameSize;
+
+ me.setElementSize(me.owner.frameBody,
+ Ext.isNumber(width) ? (width - frameSize.left - frameSize.right - padding.left - padding.right - border.left - border.right) : width,
+ Ext.isNumber(height) ? (height - frameSize.top - frameSize.bottom - padding.top - padding.bottom - border.top - border.bottom) : height
+ );
+ }
+
+ me.autoSized = {
+ width: !Ext.isNumber(width),
+ height: !Ext.isNumber(height)
+ };
+
+ me.lastComponentSize = {
+ width: width,
+ height: height
+ };
+ },
+
+ getTargetInfo : function() {
+ if (!this.targetInfo) {
+ var target = this.getTarget(),
+ body = this.owner.getTargetEl();
+
+ this.targetInfo = {
+ padding: {
+ top: target.getPadding('t'),
+ right: target.getPadding('r'),
+ bottom: target.getPadding('b'),
+ left: target.getPadding('l')
+ },
+ border: {
+ top: target.getBorderWidth('t'),
+ right: target.getBorderWidth('r'),
+ bottom: target.getBorderWidth('b'),
+ left: target.getBorderWidth('l')
+ },
+ bodyMargin: {
+ top: body.getMargin('t'),
+ right: body.getMargin('r'),
+ bottom: body.getMargin('b'),
+ left: body.getMargin('l')
+ }
+ };
+ }
+ return this.targetInfo;
+ },
+
+
+ doOwnerCtLayouts: function() {
+ var owner = this.owner,
+ ownerCt = owner.ownerCt,
+ ownerCtComponentLayout, ownerCtContainerLayout,
+ curSize = this.lastComponentSize,
+ prevSize = this.previousComponentSize,
+ widthChange = (prevSize && curSize && Ext.isNumber(curSize.width )) ? curSize.width !== prevSize.width : true,
+ heightChange = (prevSize && curSize && Ext.isNumber(curSize.height)) ? curSize.height !== prevSize.height : true;
+
+
+ if (!ownerCt || (!widthChange && !heightChange)) {
+ return;
+ }
+
+ ownerCtComponentLayout = ownerCt.componentLayout;
+ ownerCtContainerLayout = ownerCt.layout;
+
+ if (!owner.floating && ownerCtComponentLayout && ownerCtComponentLayout.monitorChildren && !ownerCtComponentLayout.layoutBusy) {
+ if (!ownerCt.suspendLayout && ownerCtContainerLayout && !ownerCtContainerLayout.layoutBusy) {
+
+
+ if (((widthChange && !ownerCt.isFixedWidth()) || (heightChange && !ownerCt.isFixedHeight()))) {
+
+ this.isSizing = true;
+ ownerCt.doComponentLayout();
+ this.isSizing = false;
+ }
+
+ else if (ownerCtContainerLayout.bindToOwnerCtContainer === true) {
+ ownerCtContainerLayout.layout();
+ }
+ }
+ }
+ },
+
+ doContainerLayout: function() {
+ var me = this,
+ owner = me.owner,
+ ownerCt = owner.ownerCt,
+ layout = owner.layout,
+ ownerCtComponentLayout;
+
+
+
+ if (!owner.suspendLayout && layout && layout.isLayout && !layout.layoutBusy && !layout.isAutoDock) {
+ layout.layout();
+ }
+
+
+ if (ownerCt && ownerCt.componentLayout) {
+ ownerCtComponentLayout = ownerCt.componentLayout;
+ if (!owner.floating && ownerCtComponentLayout.monitorChildren && !ownerCtComponentLayout.layoutBusy) {
+ ownerCtComponentLayout.childrenChanged = true;
+ }
+ }
+ },
+
+ afterLayout : function(width, height, isSetSize, layoutOwner) {
+ this.doContainerLayout();
+ this.owner.afterComponentLayout(width, height, isSetSize, layoutOwner);
+ }
+});
+
+
+Ext.define('Ext.util.TextMetrics', {
+ statics: {
+ shared: null,
+
+ measure: function(el, text, fixedWidth){
+ var me = this,
+ shared = me.shared;
+
+ if(!shared){
+ shared = me.shared = new me(el, fixedWidth);
+ }
+ shared.bind(el);
+ shared.setFixedWidth(fixedWidth || 'auto');
+ return shared.getSize(text);
+ },
+
+
+ destroy: function(){
+ var me = this;
+ Ext.destroy(me.shared);
+ me.shared = null;
+ }
+ },
+
+
+ constructor: function(bindTo, fixedWidth){
+ var measure = this.measure = Ext.getBody().createChild({
+ cls: 'x-textmetrics'
+ });
+ this.el = Ext.get(bindTo);
+
+ measure.position('absolute');
+ measure.setLeftTop(-1000, -1000);
+ measure.hide();
+
+ if (fixedWidth) {
+ measure.setWidth(fixedWidth);
+ }
+ },
+
+
+ getSize: function(text){
+ var measure = this.measure,
+ size;
+
+ measure.update(text);
+ size = measure.getSize();
+ measure.update('');
+ return size;
+ },
+
+
+ bind: function(el){
+ var me = this;
+
+ me.el = Ext.get(el);
+ me.measure.setStyle(
+ me.el.getStyles('font-size','font-style', 'font-weight', 'font-family','line-height', 'text-transform', 'letter-spacing')
+ );
+ },
+
+
+ setFixedWidth : function(width){
+ this.measure.setWidth(width);
+ },
+
+
+ getWidth : function(text){
+ this.measure.dom.style.width = 'auto';
+ return this.getSize(text).width;
+ },
+
+
+ getHeight : function(text){
+ return this.getSize(text).height;
+ },
+
+
+ destroy: function(){
+ var me = this;
+ me.measure.remove();
+ delete me.el;
+ delete me.measure;
+ }
+}, function(){
+ Ext.Element.addMethods({
+
+ getTextWidth : function(text, min, max){
+ return Ext.Number.constrain(Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width, min || 0, max || 1000000);
+ }
+ });
+});
+
+
+Ext.define('Ext.layout.container.boxOverflow.Scroller', {
+
+
+
+ extend: 'Ext.layout.container.boxOverflow.None',
+ requires: ['Ext.util.ClickRepeater', 'Ext.Element'],
+ alternateClassName: 'Ext.layout.boxOverflow.Scroller',
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+
+
+
+ animateScroll: false,
+
+
+ scrollIncrement: 20,
+
+
+ wheelIncrement: 10,
+
+
+ scrollRepeatInterval: 60,
+
+
+ scrollDuration: 400,
+
+
+
+
+
+
+ scrollerCls: Ext.baseCSSPrefix + 'box-scroller',
+
+
+
+
+
+ constructor: function(layout, config) {
+ this.layout = layout;
+ Ext.apply(this, config || {});
+
+ this.addEvents(
+
+ 'scroll'
+ );
+ },
+
+ initCSSClasses: function() {
+ var me = this,
+ layout = me.layout;
+
+ if (!me.CSSinitialized) {
+ me.beforeCtCls = me.beforeCtCls || Ext.baseCSSPrefix + 'box-scroller-' + layout.parallelBefore;
+ me.afterCtCls = me.afterCtCls || Ext.baseCSSPrefix + 'box-scroller-' + layout.parallelAfter;
+ me.beforeScrollerCls = me.beforeScrollerCls || Ext.baseCSSPrefix + layout.owner.getXType() + '-scroll-' + layout.parallelBefore;
+ me.afterScrollerCls = me.afterScrollerCls || Ext.baseCSSPrefix + layout.owner.getXType() + '-scroll-' + layout.parallelAfter;
+ me.CSSinitializes = true;
+ }
+ },
+
+ handleOverflow: function(calculations, targetSize) {
+ var me = this,
+ layout = me.layout,
+ methodName = 'get' + layout.parallelPrefixCap,
+ newSize = {};
+
+ me.initCSSClasses();
+ me.callParent(arguments);
+ this.createInnerElements();
+ this.showScrollers();
+ newSize[layout.perpendicularPrefix] = targetSize[layout.perpendicularPrefix];
+ newSize[layout.parallelPrefix] = targetSize[layout.parallelPrefix] - (me.beforeCt[methodName]() + me.afterCt[methodName]());
+ return { targetSize: newSize };
+ },
+
+
+ createInnerElements: function() {
+ var me = this,
+ target = me.layout.getRenderTarget();
+
+
+
+ if (!me.beforeCt) {
+ target.addCls(Ext.baseCSSPrefix + me.layout.direction + '-box-overflow-body');
+ me.beforeCt = target.insertSibling({cls: Ext.layout.container.Box.prototype.innerCls + ' ' + me.beforeCtCls}, 'before');
+ me.afterCt = target.insertSibling({cls: Ext.layout.container.Box.prototype.innerCls + ' ' + me.afterCtCls}, 'after');
+ me.createWheelListener();
+ }
+ },
+
+
+ createWheelListener: function() {
+ this.layout.innerCt.on({
+ scope : this,
+ mousewheel: function(e) {
+ e.stopEvent();
+
+ this.scrollBy(e.getWheelDelta() * this.wheelIncrement * -1, false);
+ }
+ });
+ },
+
+
+ clearOverflow: function() {
+ this.hideScrollers();
+ },
+
+
+ showScrollers: function() {
+ this.createScrollers();
+ this.beforeScroller.show();
+ this.afterScroller.show();
+ this.updateScrollButtons();
+
+ this.layout.owner.addClsWithUI('scroller');
+ },
+
+
+ hideScrollers: function() {
+ if (this.beforeScroller != undefined) {
+ this.beforeScroller.hide();
+ this.afterScroller.hide();
+
+ this.layout.owner.removeClsWithUI('scroller');
+ }
+ },
+
+
+ createScrollers: function() {
+ if (!this.beforeScroller && !this.afterScroller) {
+ var before = this.beforeCt.createChild({
+ cls: Ext.String.format("{0} {1} ", this.scrollerCls, this.beforeScrollerCls)
+ });
+
+ var after = this.afterCt.createChild({
+ cls: Ext.String.format("{0} {1}", this.scrollerCls, this.afterScrollerCls)
+ });
+
+ before.addClsOnOver(this.beforeScrollerCls + '-hover');
+ after.addClsOnOver(this.afterScrollerCls + '-hover');
+
+ before.setVisibilityMode(Ext.Element.DISPLAY);
+ after.setVisibilityMode(Ext.Element.DISPLAY);
+
+ this.beforeRepeater = Ext.create('Ext.util.ClickRepeater', before, {
+ interval: this.scrollRepeatInterval,
+ handler : this.scrollLeft,
+ scope : this
+ });
+
+ this.afterRepeater = Ext.create('Ext.util.ClickRepeater', after, {
+ interval: this.scrollRepeatInterval,
+ handler : this.scrollRight,
+ scope : this
+ });
+
+
+ this.beforeScroller = before;
+
+
+ this.afterScroller = after;
+ }
+ },
+
+
+ destroy: function() {
+ Ext.destroy(this.beforeRepeater, this.afterRepeater, this.beforeScroller, this.afterScroller, this.beforeCt, this.afterCt);
+ },
+
+
+ scrollBy: function(delta, animate) {
+ this.scrollTo(this.getScrollPosition() + delta, animate);
+ },
+
+
+ getScrollAnim: function() {
+ return {
+ duration: this.scrollDuration,
+ callback: this.updateScrollButtons,
+ scope : this
+ };
+ },
+
+
+ updateScrollButtons: function() {
+ if (this.beforeScroller == undefined || this.afterScroller == undefined) {
+ return;
+ }
+
+ var beforeMeth = this.atExtremeBefore() ? 'addCls' : 'removeCls',
+ afterMeth = this.atExtremeAfter() ? 'addCls' : 'removeCls',
+ beforeCls = this.beforeScrollerCls + '-disabled',
+ afterCls = this.afterScrollerCls + '-disabled';
+
+ this.beforeScroller[beforeMeth](beforeCls);
+ this.afterScroller[afterMeth](afterCls);
+ this.scrolling = false;
+ },
+
+
+ atExtremeBefore: function() {
+ return this.getScrollPosition() === 0;
+ },
+
+
+ scrollLeft: function() {
+ this.scrollBy(-this.scrollIncrement, false);
+ },
+
+
+ scrollRight: function() {
+ this.scrollBy(this.scrollIncrement, false);
+ },
+
+
+ getScrollPosition: function(){
+ var layout = this.layout;
+ return parseInt(layout.innerCt.dom['scroll' + layout.parallelBeforeCap], 10) || 0;
+ },
+
+
+ getMaxScrollPosition: function() {
+ var layout = this.layout;
+ return layout.innerCt.dom['scroll' + layout.parallelPrefixCap] - this.layout.innerCt['get' + layout.parallelPrefixCap]();
+ },
+
+
+ atExtremeAfter: function() {
+ return this.getScrollPosition() >= this.getMaxScrollPosition();
+ },
+
+
+ scrollTo: function(position, animate) {
+ var me = this,
+ layout = me.layout,
+ oldPosition = me.getScrollPosition(),
+ newPosition = Ext.Number.constrain(position, 0, me.getMaxScrollPosition());
+
+ if (newPosition != oldPosition && !me.scrolling) {
+ if (animate == undefined) {
+ animate = me.animateScroll;
+ }
+
+ layout.innerCt.scrollTo(layout.parallelBefore, newPosition, animate ? me.getScrollAnim() : false);
+ if (animate) {
+ me.scrolling = true;
+ } else {
+ me.scrolling = false;
+ me.updateScrollButtons();
+ }
+
+ me.fireEvent('scroll', me, newPosition, animate ? me.getScrollAnim() : false);
+ }
+ },
+
+
+ scrollToItem: function(item, animate) {
+ var me = this,
+ layout = me.layout,
+ visibility,
+ box,
+ newPos;
+
+ item = me.getItem(item);
+ if (item != undefined) {
+ visibility = this.getItemVisibility(item);
+ if (!visibility.fullyVisible) {
+ box = item.getBox(true, true);
+ newPos = box[layout.parallelPosition];
+ if (visibility.hiddenEnd) {
+ newPos -= (this.layout.innerCt['get' + layout.parallelPrefixCap]() - box[layout.parallelPrefix]);
+ }
+ this.scrollTo(newPos, animate);
+ }
+ }
+ },
+
+
+ getItemVisibility: function(item) {
+ var me = this,
+ box = me.getItem(item).getBox(true, true),
+ layout = me.layout,
+ itemStart = box[layout.parallelPosition],
+ itemEnd = itemStart + box[layout.parallelPrefix],
+ scrollStart = me.getScrollPosition(),
+ scrollEnd = scrollStart + layout.innerCt['get' + layout.parallelPrefixCap]();
+
+ return {
+ hiddenStart : itemStart < scrollStart,
+ hiddenEnd : itemEnd > scrollEnd,
+ fullyVisible: itemStart > scrollStart && itemEnd < scrollEnd
+ };
+ }
+});
+
+Ext.define('Ext.util.Offset', {
+
+
+
+ statics: {
+ fromObject: function(obj) {
+ return new this(obj.x, obj.y);
+ }
+ },
+
+
+
+ constructor: function(x, y) {
+ this.x = (x != null && !isNaN(x)) ? x : 0;
+ this.y = (y != null && !isNaN(y)) ? y : 0;
+
+ return this;
+ },
+
+ copy: function() {
+ return new Ext.util.Offset(this.x, this.y);
+ },
+
+ copyFrom: function(p) {
+ this.x = p.x;
+ this.y = p.y;
+ },
+
+ toString: function() {
+ return "Offset[" + this.x + "," + this.y + "]";
+ },
+
+ equals: function(offset) {
+
+ return (this.x == offset.x && this.y == offset.y);
+ },
+
+ round: function(to) {
+ if (!isNaN(to)) {
+ var factor = Math.pow(10, to);
+ this.x = Math.round(this.x * factor) / factor;
+ this.y = Math.round(this.y * factor) / factor;
+ } else {
+ this.x = Math.round(this.x);
+ this.y = Math.round(this.y);
+ }
+ },
+
+ isZero: function() {
+ return this.x == 0 && this.y == 0;
+ }
+});
+
+
+Ext.define('Ext.util.KeyNav', {
+
+ alternateClassName: 'Ext.KeyNav',
+
+ requires: ['Ext.util.KeyMap'],
+
+ statics: {
+ keyOptions: {
+ left: 37,
+ right: 39,
+ up: 38,
+ down: 40,
+ space: 32,
+ pageUp: 33,
+ pageDown: 34,
+ del: 46,
+ backspace: 8,
+ home: 36,
+ end: 35,
+ enter: 13,
+ esc: 27,
+ tab: 9
+ }
+ },
+
+
+ constructor: function(el, config){
+ this.setConfig(el, config || {});
+ },
+
+
+ setConfig: function(el, config) {
+ if (this.map) {
+ this.map.destroy();
+ }
+
+ var map = Ext.create('Ext.util.KeyMap', el, null, this.getKeyEvent('forceKeyDown' in config ? config.forceKeyDown : this.forceKeyDown)),
+ keys = Ext.util.KeyNav.keyOptions,
+ scope = config.scope || this,
+ key;
+
+ this.map = map;
+ for (key in keys) {
+ if (keys.hasOwnProperty(key)) {
+ if (config[key]) {
+ map.addBinding({
+ scope: scope,
+ key: keys[key],
+ handler: Ext.Function.bind(this.handleEvent, scope, [config[key]], true),
+ defaultEventAction: config.defaultEventAction || this.defaultEventAction
+ });
+ }
+ }
+ }
+
+ map.disable();
+ if (!config.disabled) {
+ map.enable();
+ }
+ },
+
+
+ handleEvent: function(map, event, handler){
+ return handler.call(this, event);
+ },
+
+
+ disabled: false,
+
+
+ defaultEventAction: "stopEvent",
+
+
+ forceKeyDown: false,
+
+
+ destroy: function(removeEl){
+ this.map.destroy(removeEl);
+ delete this.map;
+ },
+
+
+ enable: function() {
+ this.map.enable();
+ this.disabled = false;
+ },
+
+
+ disable: function() {
+ this.map.disable();
+ this.disabled = true;
+ },
+
+
+ setDisabled : function(disabled){
+ this.map.setDisabled(disabled);
+ this.disabled = disabled;
+ },
+
+
+ getKeyEvent: function(forceKeyDown){
+ return (forceKeyDown || Ext.EventManager.useKeyDown) ? 'keydown' : 'keypress';
+ }
+});
+
+
+
+Ext.define('Ext.fx.Queue', {
+
+ requires: ['Ext.util.HashMap'],
+
+ constructor: function() {
+ this.targets = Ext.create('Ext.util.HashMap');
+ this.fxQueue = {};
+ },
+
+
+ getFxDefaults: function(targetId) {
+ var target = this.targets.get(targetId);
+ if (target) {
+ return target.fxDefaults;
+ }
+ return {};
+ },
+
+
+ setFxDefaults: function(targetId, obj) {
+ var target = this.targets.get(targetId);
+ if (target) {
+ target.fxDefaults = Ext.apply(target.fxDefaults || {}, obj);
+ }
+ },
+
+
+ stopAnimation: function(targetId) {
+ var me = this,
+ queue = me.getFxQueue(targetId),
+ ln = queue.length;
+ while (ln) {
+ queue[ln - 1].end();
+ ln--;
+ }
+ },
+
+
+ getActiveAnimation: function(targetId) {
+ var queue = this.getFxQueue(targetId);
+ return (queue && !!queue.length) ? queue[0] : false;
+ },
+
+
+ hasFxBlock: function(targetId) {
+ var queue = this.getFxQueue(targetId);
+ return queue && queue[0] && queue[0].block;
+ },
+
+
+ getFxQueue: function(targetId) {
+ if (!targetId) {
+ return false;
+ }
+ var me = this,
+ queue = me.fxQueue[targetId],
+ target = me.targets.get(targetId);
+
+ if (!target) {
+ return false;
+ }
+
+ if (!queue) {
+ me.fxQueue[targetId] = [];
+
+ if (target.type != 'element') {
+ target.target.on('destroy', function() {
+ me.fxQueue[targetId] = [];
+ });
+ }
+ }
+ return me.fxQueue[targetId];
+ },
+
+
+ queueFx: function(anim) {
+ var me = this,
+ target = anim.target,
+ queue, ln;
+
+ if (!target) {
+ return;
+ }
+
+ queue = me.getFxQueue(target.getId());
+ ln = queue.length;
+
+ if (ln) {
+ if (anim.concurrent) {
+ anim.paused = false;
+ }
+ else {
+ queue[ln - 1].on('afteranimate', function() {
+ anim.paused = false;
+ });
+ }
+ }
+ else {
+ anim.paused = false;
+ }
+ anim.on('afteranimate', function() {
+ Ext.Array.remove(queue, anim);
+ if (anim.remove) {
+ if (target.type == 'element') {
+ var el = Ext.get(target.id);
+ if (el) {
+ el.remove();
+ }
+ }
+ }
+ }, this);
+ queue.push(anim);
+ }
+});
+
+Ext.define('Ext.fx.target.Target', {
+
+ isAnimTarget: true,
+
+
+ constructor: function(target) {
+ this.target = target;
+ this.id = this.getId();
+ },
+
+ getId: function() {
+ return this.target.id;
+ }
+});
+
+
+
+Ext.define('Ext.fx.target.Sprite', {
+
+
+
+ extend: 'Ext.fx.target.Target',
+
+
+
+ type: 'draw',
+
+ getFromPrim: function(sprite, attr) {
+ var o;
+ if (attr == 'translate') {
+ o = {
+ x: sprite.attr.translation.x || 0,
+ y: sprite.attr.translation.y || 0
+ };
+ }
+ else if (attr == 'rotate') {
+ o = {
+ degrees: sprite.attr.rotation.degrees || 0,
+ x: sprite.attr.rotation.x,
+ y: sprite.attr.rotation.y
+ };
+ }
+ else {
+ o = sprite.attr[attr];
+ }
+ return o;
+ },
+
+ getAttr: function(attr, val) {
+ return [[this.target, val != undefined ? val : this.getFromPrim(this.target, attr)]];
+ },
+
+ setAttr: function(targetData) {
+ var ln = targetData.length,
+ spriteArr = [],
+ attrs, attr, attrArr, attPtr, spritePtr, idx, value, i, j, x, y, ln2;
+ for (i = 0; i < ln; i++) {
+ attrs = targetData[i].attrs;
+ for (attr in attrs) {
+ attrArr = attrs[attr];
+ ln2 = attrArr.length;
+ for (j = 0; j < ln2; j++) {
+ spritePtr = attrArr[j][0];
+ attPtr = attrArr[j][1];
+ if (attr === 'translate') {
+ value = {
+ x: attPtr.x,
+ y: attPtr.y
+ };
+ }
+ else if (attr === 'rotate') {
+ x = attPtr.x;
+ if (isNaN(x)) {
+ x = null;
+ }
+ y = attPtr.y;
+ if (isNaN(y)) {
+ y = null;
+ }
+ value = {
+ degrees: attPtr.degrees,
+ x: x,
+ y: y
+ };
+ }
+ else if (attr === 'width' || attr === 'height' || attr === 'x' || attr === 'y') {
+ value = parseFloat(attPtr);
+ }
+ else {
+ value = attPtr;
+ }
+ idx = Ext.Array.indexOf(spriteArr, spritePtr);
+ if (idx == -1) {
+ spriteArr.push([spritePtr, {}]);
+ idx = spriteArr.length - 1;
+ }
+ spriteArr[idx][1][attr] = value;
+ }
+ }
+ }
+ ln = spriteArr.length;
+ for (i = 0; i < ln; i++) {
+ spritePtr = spriteArr[i];
+ spritePtr[0].setAttributes(spritePtr[1]);
+ }
+ this.target.redraw();
+ }
+});
+
+
+
+Ext.define('Ext.fx.target.CompositeSprite', {
+
+
+
+ extend: 'Ext.fx.target.Sprite',
+
+
+
+ getAttr: function(attr, val) {
+ var out = [],
+ target = this.target;
+ target.each(function(sprite) {
+ out.push([sprite, val != undefined ? val : this.getFromPrim(sprite, attr)]);
+ }, this);
+ return out;
+ }
+});
+
+
+Ext.define('Ext.fx.target.Component', {
+
+
+
+ extend: 'Ext.fx.target.Target',
+
+
+
+ type: 'component',
+
+
+ getPropMethod: {
+ top: function() {
+ return this.getPosition(true)[1];
+ },
+ left: function() {
+ return this.getPosition(true)[0];
+ },
+ x: function() {
+ return this.getPosition()[0];
+ },
+ y: function() {
+ return this.getPosition()[1];
+ },
+ height: function() {
+ return this.getHeight();
+ },
+ width: function() {
+ return this.getWidth();
+ },
+ opacity: function() {
+ return this.el.getStyle('opacity');
+ }
+ },
+
+ compMethod: {
+ top: 'setPosition',
+ left: 'setPosition',
+ x: 'setPagePosition',
+ y: 'setPagePosition',
+ height: 'setSize',
+ width: 'setSize',
+ opacity: 'setOpacity'
+ },
+
+
+ getAttr: function(attr, val) {
+ return [[this.target, val !== undefined ? val : this.getPropMethod[attr].call(this.target)]];
+ },
+
+ setAttr: function(targetData, isFirstFrame, isLastFrame) {
+ var me = this,
+ target = me.target,
+ ln = targetData.length,
+ attrs, attr, o, i, j, meth, targets, left, top, w, h;
+ for (i = 0; i < ln; i++) {
+ attrs = targetData[i].attrs;
+ for (attr in attrs) {
+ targets = attrs[attr].length;
+ meth = {
+ setPosition: {},
+ setPagePosition: {},
+ setSize: {},
+ setOpacity: {}
+ };
+ for (j = 0; j < targets; j++) {
+ o = attrs[attr][j];
+
+
+
+
+ meth[me.compMethod[attr]].target = o[0];
+ meth[me.compMethod[attr]][attr] = o[1];
+ }
+ if (meth.setPosition.target) {
+ o = meth.setPosition;
+ left = (o.left === undefined) ? undefined : parseInt(o.left, 10);
+ top = (o.top === undefined) ? undefined : parseInt(o.top, 10);
+ o.target.setPosition(left, top);
+ }
+ if (meth.setPagePosition.target) {
+ o = meth.setPagePosition;
+ o.target.setPagePosition(o.x, o.y);
+ }
+ if (meth.setSize.target && meth.setSize.target.el) {
+ o = meth.setSize;
+
+ w = (o.width === undefined) ? o.target.getWidth() : parseInt(o.width, 10);
+ h = (o.height === undefined) ? o.target.getHeight() : parseInt(o.height, 10);
+
+
+
+
+
+
+
+
+ if (isLastFrame || me.dynamic) {
+ o.target.componentLayout.childrenChanged = true;
+
+
+ if (me.layoutAnimation) {
+ o.target.setCalculatedSize(w, h);
+ } else {
+ o.target.setSize(w, h);
+ }
+ }
+ else {
+ o.target.el.setSize(w, h);
+ }
+ }
+ if (meth.setOpacity.target) {
+ o = meth.setOpacity;
+ o.target.el.setStyle('opacity', o.opacity);
+ }
+ }
+ }
+ }
+});
+
+
+Ext.define('Ext.fx.CubicBezier', {
+
+
+
+ singleton: true,
+
+
+
+ cubicBezierAtTime: function(t, p1x, p1y, p2x, p2y, duration) {
+ var cx = 3 * p1x,
+ bx = 3 * (p2x - p1x) - cx,
+ ax = 1 - cx - bx,
+ cy = 3 * p1y,
+ by = 3 * (p2y - p1y) - cy,
+ ay = 1 - cy - by;
+ function sampleCurveX(t) {
+ return ((ax * t + bx) * t + cx) * t;
+ }
+ function solve(x, epsilon) {
+ var t = solveCurveX(x, epsilon);
+ return ((ay * t + by) * t + cy) * t;
+ }
+ function solveCurveX(x, epsilon) {
+ var t0, t1, t2, x2, d2, i;
+ for (t2 = x, i = 0; i < 8; i++) {
+ x2 = sampleCurveX(t2) - x;
+ if (Math.abs(x2) < epsilon) {
+ return t2;
+ }
+ d2 = (3 * ax * t2 + 2 * bx) * t2 + cx;
+ if (Math.abs(d2) < 1e-6) {
+ break;
+ }
+ t2 = t2 - x2 / d2;
+ }
+ t0 = 0;
+ t1 = 1;
+ t2 = x;
+ if (t2 < t0) {
+ return t0;
+ }
+ if (t2 > t1) {
+ return t1;
+ }
+ while (t0 < t1) {
+ x2 = sampleCurveX(t2);
+ if (Math.abs(x2 - x) < epsilon) {
+ return t2;
+ }
+ if (x > x2) {
+ t0 = t2;
+ } else {
+ t1 = t2;
+ }
+ t2 = (t1 - t0) / 2 + t0;
+ }
+ return t2;
+ }
+ return solve(t, 1 / (200 * duration));
+ },
+
+ cubicBezier: function(x1, y1, x2, y2) {
+ var fn = function(pos) {
+ return Ext.fx.CubicBezier.cubicBezierAtTime(pos, x1, y1, x2, y2, 1);
+ };
+ fn.toCSS3 = function() {
+ return 'cubic-bezier(' + [x1, y1, x2, y2].join(',') + ')';
+ };
+ fn.reverse = function() {
+ return Ext.fx.CubicBezier.cubicBezier(1 - x2, 1 - y2, 1 - x1, 1 - y1);
+ };
+ return fn;
+ }
+});
+
+Ext.define('Ext.draw.Color', {
+
+
+
+
+
+ colorToHexRe: /(.*?)rgb\((\d+),\s*(\d+),\s*(\d+)\)/,
+ rgbRe: /\s*rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)\s*/,
+ hexRe: /\s*#([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)([0-9a-fA-F][0-9a-fA-F]?)\s*/,
+
+
+ lightnessFactor: 0.2,
+
+
+ constructor : function(red, green, blue) {
+ var me = this,
+ clamp = Ext.Number.constrain;
+ me.r = clamp(red, 0, 255);
+ me.g = clamp(green, 0, 255);
+ me.b = clamp(blue, 0, 255);
+ },
+
+
+ getRed: function() {
+ return this.r;
+ },
+
+
+ getGreen: function() {
+ return this.g;
+ },
+
+
+ getBlue: function() {
+ return this.b;
+ },
+
+
+ getRGB: function() {
+ var me = this;
+ return [me.r, me.g, me.b];
+ },
+
+
+ getHSL: function() {
+ var me = this,
+ r = me.r / 255,
+ g = me.g / 255,
+ b = me.b / 255,
+ max = Math.max(r, g, b),
+ min = Math.min(r, g, b),
+ delta = max - min,
+ h,
+ s = 0,
+ l = 0.5 * (max + min);
+
+
+ if (min != max) {
+ s = (l < 0.5) ? delta / (max + min) : delta / (2 - max - min);
+ if (r == max) {
+ h = 60 * (g - b) / delta;
+ } else if (g == max) {
+ h = 120 + 60 * (b - r) / delta;
+ } else {
+ h = 240 + 60 * (r - g) / delta;
+ }
+ if (h < 0) {
+ h += 360;
+ }
+ if (h >= 360) {
+ h -= 360;
+ }
+ }
+ return [h, s, l];
+ },
+
+
+ getLighter: function(factor) {
+ var hsl = this.getHSL();
+ factor = factor || this.lightnessFactor;
+ hsl[2] = Ext.Number.constrain(hsl[2] + factor, 0, 1);
+ return this.fromHSL(hsl[0], hsl[1], hsl[2]);
+ },
+
+
+ getDarker: function(factor) {
+ factor = factor || this.lightnessFactor;
+ return this.getLighter(-factor);
+ },
+
+
+ toString: function() {
+ var me = this,
+ round = Math.round,
+ r = round(me.r).toString(16),
+ g = round(me.g).toString(16),
+ b = round(me.b).toString(16);
+ r = (r.length == 1) ? '0' + r : r;
+ g = (g.length == 1) ? '0' + g : g;
+ b = (b.length == 1) ? '0' + b : b;
+ return ['#', r, g, b].join('');
+ },
+
+
+ toHex: function(color) {
+ if (Ext.isArray(color)) {
+ color = color[0];
+ }
+ if (!Ext.isString(color)) {
+ return '';
+ }
+ if (color.substr(0, 1) === '#') {
+ return color;
+ }
+ var digits = this.colorToHexRe.exec(color);
+
+ if (Ext.isArray(digits)) {
+ var red = parseInt(digits[2], 10),
+ green = parseInt(digits[3], 10),
+ blue = parseInt(digits[4], 10),
+ rgb = blue | (green << 8) | (red << 16);
+ return digits[1] + '#' + ("000000" + rgb.toString(16)).slice(-6);
+ }
+ else {
+ return '';
+ }
+ },
+
+
+ fromString: function(str) {
+ var values, r, g, b,
+ parse = parseInt;
+
+ if ((str.length == 4 || str.length == 7) && str.substr(0, 1) === '#') {
+ values = str.match(this.hexRe);
+ if (values) {
+ r = parse(values[1], 16) >> 0;
+ g = parse(values[2], 16) >> 0;
+ b = parse(values[3], 16) >> 0;
+ if (str.length == 4) {
+ r += (r * 16);
+ g += (g * 16);
+ b += (b * 16);
+ }
+ }
+ }
+ else {
+ values = str.match(this.rgbRe);
+ if (values) {
+ r = values[1];
+ g = values[2];
+ b = values[3];
+ }
+ }
+
+ return (typeof r == 'undefined') ? undefined : Ext.create('Ext.draw.Color', r, g, b);
+ },
+
+
+ getGrayscale: function() {
+
+ return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
+ },
+
+
+ fromHSL: function(h, s, l) {
+ var C, X, m, i, rgb = [],
+ abs = Math.abs,
+ floor = Math.floor;
+
+ if (s == 0 || h == null) {
+
+ rgb = [l, l, l];
+ }
+ else {
+
+
+
+
+ h /= 60;
+ C = s * (1 - abs(2 * l - 1));
+ X = C * (1 - abs(h - 2 * floor(h / 2) - 1));
+ m = l - C / 2;
+ switch (floor(h)) {
+ case 0:
+ rgb = [C, X, 0];
+ break;
+ case 1:
+ rgb = [X, C, 0];
+ break;
+ case 2:
+ rgb = [0, C, X];
+ break;
+ case 3:
+ rgb = [0, X, C];
+ break;
+ case 4:
+ rgb = [X, 0, C];
+ break;
+ case 5:
+ rgb = [C, 0, X];
+ break;
+ }
+ rgb = [rgb[0] + m, rgb[1] + m, rgb[2] + m];
+ }
+ return Ext.create('Ext.draw.Color', rgb[0] * 255, rgb[1] * 255, rgb[2] * 255);
+ }
+}, function() {
+ var prototype = this.prototype;
+
+
+ this.addStatics({
+ fromHSL: function() {
+ return prototype.fromHSL.apply(prototype, arguments);
+ },
+ fromString: function() {
+ return prototype.fromString.apply(prototype, arguments);
+ },
+ toHex: function() {
+ return prototype.toHex.apply(prototype, arguments);
+ }
+ });
+});
+
+
+Ext.define('Ext.dd.StatusProxy', {
+ animRepair: false,
+
+
+ constructor: function(config){
+ Ext.apply(this, config);
+ this.id = this.id || Ext.id();
+ this.proxy = Ext.createWidget('component', {
+ floating: true,
+ stateful: false,
+ id: this.id,
+ html: '<div class="' + Ext.baseCSSPrefix + 'dd-drop-icon"></div>' +
+ '<div class="' + Ext.baseCSSPrefix + 'dd-drag-ghost"></div>',
+ cls: Ext.baseCSSPrefix + 'dd-drag-proxy ' + this.dropNotAllowed,
+ shadow: !config || config.shadow !== false,
+ renderTo: document.body
+ });
+
+ this.el = this.proxy.el;
+ this.el.show();
+ this.el.setVisibilityMode(Ext.Element.VISIBILITY);
+ this.el.hide();
+
+ this.ghost = Ext.get(this.el.dom.childNodes[1]);
+ this.dropStatus = this.dropNotAllowed;
+ },
+
+ dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',
+
+ dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',
+
+
+ setStatus : function(cssClass){
+ cssClass = cssClass || this.dropNotAllowed;
+ if(this.dropStatus != cssClass){
+ this.el.replaceCls(this.dropStatus, cssClass);
+ this.dropStatus = cssClass;
+ }
+ },
+
+
+ reset : function(clearGhost){
+ this.el.dom.className = Ext.baseCSSPrefix + '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.proxy.hide();
+ if (clear) {
+ this.reset(true);
+ }
+ },
+
+
+ stop : function(){
+ if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
+ this.anim.stop();
+ }
+ },
+
+
+ show : function() {
+ this.proxy.show();
+ this.proxy.toFront();
+ },
+
+
+ sync : function(){
+ this.proxy.el.sync();
+ },
+
+
+ repair : function(xy, callback, scope){
+ this.callback = callback;
+ this.scope = scope;
+ if (xy && this.animRepair !== false) {
+ this.el.addCls(Ext.baseCSSPrefix + 'dd-drag-repair');
+ this.el.hideUnders(true);
+ this.anim = this.el.animate({
+ duration: this.repairDuration || 500,
+ easing: 'ease-out',
+ to: {
+ x: xy[0],
+ y: xy[1]
+ },
+ stopAnimation: 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.proxy, this.el);
+ }
+});
+
+Ext.define('Ext.panel.Proxy', {
+
+ alternateClassName: 'Ext.dd.PanelProxy',
+
+
+ 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.el;
+ },
+
+
+ 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.unghost(null, false);
+ delete this.ghost;
+ }
+ },
+
+
+ show: function(){
+ if (!this.ghost) {
+ var panelSize = this.panel.getSize();
+ this.panel.el.setVisibilityMode(Ext.Element.DISPLAY);
+ this.ghost = this.panel.ghost();
+ if (this.insertProxy) {
+
+
+ this.proxy = this.panel.el.insertSibling({cls: Ext.baseCSSPrefix + 'panel-dd-spacer'});
+ this.proxy.setSize(panelSize);
+ }
+ }
+ },
+
+
+ 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.define('Ext.layout.component.AbstractDock', {
+
+
+
+ extend: 'Ext.layout.component.Component',
+
+
+
+ type: 'dock',
+
+
+ autoSizing: true,
+
+ beforeLayout: function() {
+ var returnValue = this.callParent(arguments);
+ if (returnValue !== false && (!this.initializedBorders || this.childrenChanged) && (!this.owner.border || this.owner.manageBodyBorders)) {
+ this.handleItemBorders();
+ this.initializedBorders = true;
+ }
+ return returnValue;
+ },
+
+ handleItemBorders: function() {
+ var owner = this.owner,
+ body = owner.body,
+ docked = this.getLayoutItems(),
+ borders = {
+ top: [],
+ right: [],
+ bottom: [],
+ left: []
+ },
+ oldBorders = this.borders,
+ opposites = {
+ top: 'bottom',
+ right: 'left',
+ bottom: 'top',
+ left: 'right'
+ },
+ i, ln, item, dock, side;
+
+ for (i = 0, ln = docked.length; i < ln; i++) {
+ item = docked[i];
+ dock = item.dock;
+
+ if (item.ignoreBorderManagement) {
+ continue;
+ }
+
+ if (!borders[dock].satisfied) {
+ borders[dock].push(item);
+ borders[dock].satisfied = true;
+ }
+
+ if (!borders.top.satisfied && opposites[dock] !== 'top') {
+ borders.top.push(item);
+ }
+ if (!borders.right.satisfied && opposites[dock] !== 'right') {
+ borders.right.push(item);
+ }
+ if (!borders.bottom.satisfied && opposites[dock] !== 'bottom') {
+ borders.bottom.push(item);
+ }
+ if (!borders.left.satisfied && opposites[dock] !== 'left') {
+ borders.left.push(item);
+ }
+ }
+
+ if (oldBorders) {
+ for (side in oldBorders) {
+ if (oldBorders.hasOwnProperty(side)) {
+ ln = oldBorders[side].length;
+ if (!owner.manageBodyBorders) {
+ for (i = 0; i < ln; i++) {
+ oldBorders[side][i].removeCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);
+ }
+ if (!oldBorders[side].satisfied && !owner.bodyBorder) {
+ body.removeCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);
+ }
+ }
+ else if (oldBorders[side].satisfied) {
+ body.setStyle('border-' + side + '-width', '');
+ }
+ }
+ }
+ }
+
+ for (side in borders) {
+ if (borders.hasOwnProperty(side)) {
+ ln = borders[side].length;
+ if (!owner.manageBodyBorders) {
+ for (i = 0; i < ln; i++) {
+ borders[side][i].addCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);
+ }
+ if ((!borders[side].satisfied && !owner.bodyBorder) || owner.bodyBorder === false) {
+ body.addCls(Ext.baseCSSPrefix + 'docked-noborder-' + side);
+ }
+ }
+ else if (borders[side].satisfied) {
+ body.setStyle('border-' + side + '-width', '1px');
+ }
+ }
+ }
+
+ this.borders = borders;
+ },
+
+
+ onLayout: function(width, height) {
+ if (this.onLayout_running) {
+ return;
+ }
+ this.onLayout_running = true;
+ var me = this,
+ owner = me.owner,
+ body = owner.body,
+ layout = owner.layout,
+ target = me.getTarget(),
+ autoWidth = false,
+ autoHeight = false,
+ padding, border, frameSize;
+
+
+ var info = me.info = {
+ boxes: [],
+ size: {
+ width: width,
+ height: height
+ },
+ bodyBox: {}
+ };
+
+ delete layout.isAutoDock;
+
+ Ext.applyIf(info, me.getTargetInfo());
+
+
+ if (owner && owner.ownerCt && owner.ownerCt.layout && owner.ownerCt.layout.isLayout) {
+ if (!Ext.isNumber(owner.height) || !Ext.isNumber(owner.width)) {
+ owner.ownerCt.layout.bindToOwnerCtComponent = true;
+ }
+ else {
+ owner.ownerCt.layout.bindToOwnerCtComponent = false;
+ }
+ }
+
+
+ if (height == null || width == null) {
+ padding = info.padding;
+ border = info.border;
+ frameSize = me.frameSize;
+
+
+ if ((height == null) && (width == null)) {
+ autoHeight = true;
+ autoWidth = true;
+ me.setTargetSize(null);
+ me.setBodyBox({width: null, height: null});
+ }
+
+ else if (height == null) {
+ autoHeight = true;
+
+ me.setTargetSize(width);
+ me.setBodyBox({width: width - padding.left - border.left - padding.right - border.right - frameSize.left - frameSize.right, height: null});
+
+ }
+ else {
+ autoWidth = true;
+
+ me.setTargetSize(null, height);
+ me.setBodyBox({width: null, height: height - padding.top - padding.bottom - border.top - border.bottom - frameSize.top - frameSize.bottom});
+ }
+
+
+ if (layout && layout.isLayout) {
+
+ layout.bindToOwnerCtComponent = true;
+
+ layout.isAutoDock = layout.autoSize !== true;
+ layout.layout();
+
+
+
+
+
+
+
+
+
+
+
+
+
+ info.autoSizedCtLayout = layout.autoSize === true;
+ info.autoHeight = autoHeight;
+ info.autoWidth = autoWidth;
+ }
+
+
+
+
+
+
+ me.dockItems();
+ me.setTargetSize(info.size.width, info.size.height);
+ }
+ else {
+ me.setTargetSize(width, height);
+ me.dockItems();
+ }
+ me.callParent(arguments);
+ this.onLayout_running = false;
+ },
+
+
+ dockItems : function() {
+ this.calculateDockBoxes();
+
+
+
+
+ var info = this.info,
+ autoWidth = info.autoWidth,
+ autoHeight = info.autoHeight,
+ boxes = info.boxes,
+ ln = boxes.length,
+ dock, i, item;
+
+
+
+ for (i = 0; i < ln; i++) {
+ dock = boxes[i];
+ item = dock.item;
+ item.setPosition(dock.x, dock.y);
+ if ((autoWidth || autoHeight) && item.layout && item.layout.isLayout) {
+
+ item.layout.bindToOwnerCtComponent = true;
+ }
+ }
+
+
+
+ if (!info.autoSizedCtLayout) {
+ if (autoWidth) {
+ info.bodyBox.width = null;
+ }
+ if (autoHeight) {
+ info.bodyBox.height = null;
+ }
+ }
+
+
+
+ this.setBodyBox(info.bodyBox);
+ },
+
+
+ calculateDockBoxes : function() {
+ if (this.calculateDockBoxes_running) {
+
+ return;
+ }
+ this.calculateDockBoxes_running = true;
+
+
+
+ var me = this,
+ target = me.getTarget(),
+ items = me.getLayoutItems(),
+ owner = me.owner,
+ bodyEl = owner.body,
+ info = me.info,
+ autoWidth = info.autoWidth,
+ autoHeight = info.autoHeight,
+ size = info.size,
+ ln = items.length,
+ padding = info.padding,
+ border = info.border,
+ frameSize = me.frameSize,
+ item, i, box, rect;
+
+
+
+ if (autoHeight) {
+ size.height = bodyEl.getHeight() + padding.top + border.top + padding.bottom + border.bottom + frameSize.top + frameSize.bottom;
+ }
+ else {
+ size.height = target.getHeight();
+ }
+ if (autoWidth) {
+ size.width = bodyEl.getWidth() + padding.left + border.left + padding.right + border.right + frameSize.left + frameSize.right;
+ }
+ else {
+ size.width = target.getWidth();
+ }
+
+ info.bodyBox = {
+ x: padding.left + frameSize.left,
+ y: padding.top + frameSize.top,
+ width: size.width - padding.left - border.left - padding.right - border.right - frameSize.left - frameSize.right,
+ height: size.height - border.top - padding.top - border.bottom - padding.bottom - frameSize.top - frameSize.bottom
+ };
+
+
+ for (i = 0; i < ln; i++) {
+ item = items[i];
+
+
+
+ box = me.initBox(item);
+
+ if (autoHeight === true) {
+ box = me.adjustAutoBox(box, i);
+ }
+ else {
+ box = me.adjustSizedBox(box, i);
+ }
+
+
+
+
+ info.boxes.push(box);
+ }
+ this.calculateDockBoxes_running = false;
+ },
+
+
+ adjustSizedBox : function(box, index) {
+ var bodyBox = this.info.bodyBox,
+ frameSize = this.frameSize,
+ info = this.info,
+ padding = info.padding,
+ pos = box.type,
+ border = info.border;
+
+ switch (pos) {
+ case 'top':
+ box.y = bodyBox.y;
+ break;
+
+ case 'left':
+ box.x = bodyBox.x;
+ break;
+
+ case 'bottom':
+ box.y = (bodyBox.y + bodyBox.height) - box.height;
+ break;
+
+ case 'right':
+ box.x = (bodyBox.x + bodyBox.width) - box.width;
+ break;
+ }
+
+ if (box.ignoreFrame) {
+ if (pos == 'bottom') {
+ box.y += (frameSize.bottom + padding.bottom + border.bottom);
+ }
+ else {
+ box.y -= (frameSize.top + padding.top + border.top);
+ }
+ if (pos == 'right') {
+ box.x += (frameSize.right + padding.right + border.right);
+ }
+ else {
+ box.x -= (frameSize.left + padding.left + border.left);
+ }
+ }
+
+
+ if (!box.overlay) {
+ switch (pos) {
+ case 'top':
+ bodyBox.y += box.height;
+ bodyBox.height -= box.height;
+ break;
+
+ case 'left':
+ bodyBox.x += box.width;
+ bodyBox.width -= box.width;
+ break;
+
+ case 'bottom':
+ bodyBox.height -= box.height;
+ break;
+
+ case 'right':
+ bodyBox.width -= box.width;
+ break;
+ }
+ }
+ return box;
+ },
+
+
+ adjustAutoBox : function (box, index) {
+ var info = this.info,
+ owner = this.owner,
+ bodyBox = info.bodyBox,
+ size = info.size,
+ boxes = info.boxes,
+ boxesLn = boxes.length,
+ pos = box.type,
+ frameSize = this.frameSize,
+ padding = info.padding,
+ border = info.border,
+ autoSizedCtLayout = info.autoSizedCtLayout,
+ ln = (boxesLn < index) ? boxesLn : index,
+ i, adjustBox;
+
+ if (pos == 'top' || pos == 'bottom') {
+
+ for (i = 0; i < ln; i++) {
+ adjustBox = boxes[i];
+ if (adjustBox.stretched && adjustBox.type == 'left' || adjustBox.type == 'right') {
+ adjustBox.height += box.height;
+ }
+ else if (adjustBox.type == 'bottom') {
+ adjustBox.y += box.height;
+ }
+ }
+ }
+
+ switch (pos) {
+ case 'top':
+ box.y = bodyBox.y;
+ if (!box.overlay) {
+ bodyBox.y += box.height;
+ if (info.autoHeight) {
+ size.height += box.height;
+ } else {
+ bodyBox.height -= box.height;
+ }
+ }
+ break;
+
+ case 'bottom':
+ if (!box.overlay) {
+ if (info.autoHeight) {
+ size.height += box.height;
+ } else {
+ bodyBox.height -= box.height;
+ }
+ }
+ box.y = (bodyBox.y + bodyBox.height);
+ break;
+
+ case 'left':
+ box.x = bodyBox.x;
+ if (!box.overlay) {
+ bodyBox.x += box.width;
+ if (info.autoWidth) {
+ size.width += box.width;
+ } else {
+ bodyBox.width -= box.width;
+ }
+ }
+ break;
+
+ case 'right':
+ if (!box.overlay) {
+ if (info.autoWidth) {
+ size.width += box.width;
+ } else {
+ bodyBox.width -= box.width;
+ }
+ }
+ box.x = (bodyBox.x + bodyBox.width);
+ break;
+ }
+
+ if (box.ignoreFrame) {
+ if (pos == 'bottom') {
+ box.y += (frameSize.bottom + padding.bottom + border.bottom);
+ }
+ else {
+ box.y -= (frameSize.top + padding.top + border.top);
+ }
+ if (pos == 'right') {
+ box.x += (frameSize.right + padding.right + border.right);
+ }
+ else {
+ box.x -= (frameSize.left + padding.left + border.left);
+ }
+ }
+ return box;
+ },
+
+
+ initBox : function(item) {
+ var me = this,
+ bodyBox = me.info.bodyBox,
+ horizontal = (item.dock == 'top' || item.dock == 'bottom'),
+ owner = me.owner,
+ frameSize = me.frameSize,
+ info = me.info,
+ padding = info.padding,
+ border = info.border,
+ box = {
+ item: item,
+ overlay: item.overlay,
+ type: item.dock,
+ offsets: Ext.Element.parseBox(item.offsets || {}),
+ ignoreFrame: item.ignoreParentFrame
+ };
+
+ if (item.stretch !== false) {
+ box.stretched = true;
+ if (horizontal) {
+ box.x = bodyBox.x + box.offsets.left;
+ box.width = bodyBox.width - (box.offsets.left + box.offsets.right);
+ if (box.ignoreFrame) {
+ box.width += (frameSize.left + frameSize.right + border.left + border.right + padding.left + padding.right);
+ }
+ item.setCalculatedSize(box.width - item.el.getMargin('lr'), undefined, owner);
+ }
+ else {
+ box.y = bodyBox.y + box.offsets.top;
+ box.height = bodyBox.height - (box.offsets.bottom + box.offsets.top);
+ if (box.ignoreFrame) {
+ box.height += (frameSize.top + frameSize.bottom + border.top + border.bottom + padding.top + padding.bottom);
+ }
+ item.setCalculatedSize(undefined, box.height - item.el.getMargin('tb'), owner);
+
+
+
+ if (!Ext.supports.ComputedStyle) {
+ item.el.repaint();
+ }
+ }
+ }
+ else {
+ item.doComponentLayout();
+ box.width = item.getWidth() - (box.offsets.left + box.offsets.right);
+ box.height = item.getHeight() - (box.offsets.bottom + box.offsets.top);
+ box.y += box.offsets.top;
+ if (horizontal) {
+ box.x = (item.align == 'right') ? bodyBox.width - box.width : bodyBox.x;
+ box.x += box.offsets.left;
+ }
+ }
+
+
+
+ if (box.width === undefined) {
+ box.width = item.getWidth() + item.el.getMargin('lr');
+ }
+ if (box.height === undefined) {
+ box.height = item.getHeight() + item.el.getMargin('tb');
+ }
+
+ return box;
+ },
+
+
+ getLayoutItems : function() {
+ var it = this.owner.getDockedItems(),
+ ln = it.length,
+ i = 0,
+ result = [];
+ for (; i < ln; i++) {
+ if (it[i].isVisible(true)) {
+ result.push(it[i]);
+ }
+ }
+ return result;
+ },
+
+
+ renderItems: function(items, target) {
+ var cns = target.dom.childNodes,
+ cnsLn = cns.length,
+ ln = items.length,
+ domLn = 0,
+ i, j, cn, item;
+
+
+ for (i = 0; i < cnsLn; i++) {
+ cn = Ext.get(cns[i]);
+ for (j = 0; j < ln; j++) {
+ item = items[j];
+ if (item.rendered && (cn.id == item.el.id || cn.contains(item.el.id))) {
+ break;
+ }
+ }
+
+ if (j === ln) {
+ domLn++;
+ }
+ }
+
+
+ for (i = 0, j = 0; i < ln; i++, j++) {
+ item = items[i];
+
+
+
+
+
+
+
+
+
+ if (i === j && (item.dock === 'right' || item.dock === 'bottom')) {
+ j += domLn;
+ }
+
+
+ if (item && !item.rendered) {
+ this.renderItem(item, target, j);
+ }
+ else if (!this.isValidParent(item, target, j)) {
+ this.moveItem(item, target, j);
+ }
+ }
+ },
+
+
+ setBodyBox : function(box) {
+ var me = this,
+ owner = me.owner,
+ body = owner.body,
+ info = me.info,
+ bodyMargin = info.bodyMargin,
+ padding = info.padding,
+ border = info.border,
+ frameSize = me.frameSize;
+
+
+ if (owner.collapsed) {
+ return;
+ }
+
+ if (Ext.isNumber(box.width)) {
+ box.width -= bodyMargin.left + bodyMargin.right;
+ }
+
+ if (Ext.isNumber(box.height)) {
+ box.height -= bodyMargin.top + bodyMargin.bottom;
+ }
+
+ me.setElementSize(body, box.width, box.height);
+ if (Ext.isNumber(box.x)) {
+ body.setLeft(box.x - padding.left - frameSize.left);
+ }
+ if (Ext.isNumber(box.y)) {
+ body.setTop(box.y - padding.top - frameSize.top);
+ }
+ },
+
+
+ configureItem : function(item, pos) {
+ this.callParent(arguments);
+ if (item.dock == 'top' || item.dock == 'bottom') {
+ item.layoutManagedWidth = 1;
+ item.layoutManagedHeight = 2;
+ } else {
+ item.layoutManagedWidth = 2;
+ item.layoutManagedHeight = 1;
+ }
+
+ item.addCls(Ext.baseCSSPrefix + 'docked');
+ item.addClsWithUI('docked-' + item.dock);
+ },
+
+ afterRemove : function(item) {
+ this.callParent(arguments);
+ if (this.itemCls) {
+ item.el.removeCls(this.itemCls + '-' + item.dock);
+ }
+ var dom = item.el.dom;
+
+ if (!item.destroying && dom) {
+ dom.parentNode.removeChild(dom);
+ }
+ this.childrenChanged = true;
+ }
+});
+
+Ext.define('Ext.util.Memento', function () {
+
+ function captureOne (src, target, prop) {
+ src[prop] = target[prop];
+ }
+
+ function removeOne (src, target, prop) {
+ delete src[prop];
+ }
+
+ function restoreOne (src, target, prop) {
+ var value = src[prop];
+ if (value || src.hasOwnProperty(prop)) {
+ restoreValue(target, prop, value);
+ }
+ }
+
+ function restoreValue (target, prop, value) {
+ if (Ext.isDefined(value)) {
+ target[prop] = value;
+ } else {
+ delete target[prop];
+ }
+ }
+
+ function doMany (doOne, src, target, props) {
+ if (src) {
+ if (Ext.isArray(props)) {
+ Ext.each(props, function (prop) {
+ doOne(src, target, prop);
+ });
+ } else {
+ doOne(src, target, props);
+ }
+ }
+ }
+
+ return {
+
+ data: null,
+
+
+ target: null,
+
+
+ constructor: function (target, props) {
+ if (target) {
+ this.target = target;
+ if (props) {
+ this.capture(props);
+ }
+ }
+ },
+
+
+ capture: function (props, target) {
+ doMany(captureOne, this.data || (this.data = {}), target || this.target, props);
+ },
+
+
+ remove: function (props) {
+ doMany(removeOne, this.data, null, props);
+ },
+
+
+ restore: function (props, clear, target) {
+ doMany(restoreOne, this.data, target || this.target, props);
+ if (clear !== false) {
+ this.remove(props);
+ }
+ },
+
+
+ restoreAll: function (clear, target) {
+ var me = this,
+ t = target || this.target;
+
+ Ext.Object.each(me.data, function (prop, value) {
+ restoreValue(t, prop, value);
+ });
+
+ if (clear !== false) {
+ delete me.data;
+ }
+ }
+ };
+}());
+
+
+Ext.define('Ext.app.EventBus', {
+ requires: [
+ 'Ext.util.Event'
+ ],
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ constructor: function() {
+ this.mixins.observable.constructor.call(this);
+
+ this.bus = {};
+
+ var me = this;
+ Ext.override(Ext.Component, {
+ fireEvent: function(ev) {
+ if (Ext.util.Observable.prototype.fireEvent.apply(this, arguments) !== false) {
+ return me.dispatch.call(me, ev, this, arguments);
+ }
+ return false;
+ }
+ });
+ },
+
+ dispatch: function(ev, target, args) {
+ var bus = this.bus,
+ selectors = bus[ev],
+ selector, controllers, id, events, event, i, ln;
+
+ if (selectors) {
+
+ for (selector in selectors) {
+
+ if (target.is(selector)) {
+
+ controllers = selectors[selector];
+ for (id in controllers) {
+
+ events = controllers[id];
+ for (i = 0, ln = events.length; i < ln; i++) {
+ event = events[i];
+
+ if (event.fire.apply(event, Array.prototype.slice.call(args, 1)) === false) {
+ return false;
+ };
+ }
+ }
+ }
+ }
+ }
+ },
+
+ control: function(selectors, listeners, controller) {
+ var bus = this.bus,
+ selector, fn;
+
+ if (Ext.isString(selectors)) {
+ selector = selectors;
+ selectors = {};
+ selectors[selector] = listeners;
+ this.control(selectors, null, controller);
+ return;
+ }
+
+ Ext.Object.each(selectors, function(selector, listeners) {
+ Ext.Object.each(listeners, function(ev, listener) {
+ var options = {},
+ scope = controller,
+ event = Ext.create('Ext.util.Event', controller, ev);
+
+
+ if (Ext.isObject(listener)) {
+ options = listener;
+ listener = options.fn;
+ scope = options.scope || controller;
+ delete options.fn;
+ delete options.scope;
+ }
+
+ event.addListener(listener, scope, options);
+
+
+ bus[ev] = bus[ev] || {};
+ bus[ev][selector] = bus[ev][selector] || {};
+ bus[ev][selector][controller.id] = bus[ev][selector][controller.id] || [];
+
+
+ bus[ev][selector][controller.id].push(event);
+ });
+ });
+ }
+});
+
+Ext.define('Ext.data.Types', {
+ singleton: true,
+ requires: ['Ext.data.SortTypes']
+}, function() {
+ var st = Ext.data.SortTypes;
+
+ Ext.apply(Ext.data.Types, {
+
+ stripRe: /[\$,%]/g,
+
+
+ AUTO: {
+ convert: function(v) {
+ return v;
+ },
+ sortType: st.none,
+ type: 'auto'
+ },
+
+
+ STRING: {
+ convert: function(v) {
+ var defaultValue = this.useNull ? null : '';
+ return (v === undefined || v === null) ? defaultValue : 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) {
+ if (this.useNull && (v === undefined || v === null || v === '')) {
+ return null;
+ }
+ return v === true || v === 'true' || v == 1;
+ },
+ sortType: st.none,
+ type: 'bool'
+ },
+
+
+ DATE: {
+ convert: function(v) {
+ var df = this.dateFormat,
+ parsed;
+
+ 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 Ext.Date.parse(v, df);
+ }
+
+ parsed = Date.parse(v);
+ return parsed ? new Date(parsed) : null;
+ },
+ sortType: st.asDate,
+ type: 'date'
+ }
+ });
+
+ Ext.apply(Ext.data.Types, {
+
+ BOOLEAN: this.BOOL,
+
+
+ INTEGER: this.INT,
+
+
+ NUMBER: this.FLOAT
+ });
+});
+
+
+Ext.define('Ext.data.Field', {
+ requires: ['Ext.data.Types', 'Ext.data.SortTypes'],
+ alias: 'data.field',
+
+ 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 = 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,
+
+
+ persist: true
+});
+
+
+Ext.define('Ext.util.AbstractMixedCollection', {
+ requires: ['Ext.util.Filter'],
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ constructor: function(allowFunctions, keyFn) {
+ var me = this;
+
+ me.items = [];
+ me.map = {};
+ me.keys = [];
+ me.length = 0;
+
+ me.addEvents(
+
+ 'clear',
+
+
+ 'add',
+
+
+ 'replace',
+
+
+ 'remove'
+ );
+
+ me.allowFunctions = allowFunctions === true;
+
+ if (keyFn) {
+ me.getKey = keyFn;
+ }
+
+ me.mixins.observable.constructor.call(me);
+ },
+
+
+ allowFunctions : false,
+
+
+ add : function(key, obj){
+ var me = this,
+ myObj = obj,
+ myKey = key,
+ old;
+
+ if (arguments.length == 1) {
+ myObj = myKey;
+ myKey = me.getKey(myObj);
+ }
+ if (typeof myKey != 'undefined' && myKey !== null) {
+ old = me.map[myKey];
+ if (typeof old != 'undefined') {
+ return me.replace(myKey, myObj);
+ }
+ me.map[myKey] = myObj;
+ }
+ me.length++;
+ me.items.push(myObj);
+ me.keys.push(myKey);
+ me.fireEvent('add', me.length - 1, myObj, myKey);
+ return myObj;
+ },
+
+
+ getKey : function(o){
+ return o.id;
+ },
+
+
+ replace : function(key, o){
+ var me = this,
+ old,
+ index;
+
+ if (arguments.length == 1) {
+ o = arguments[0];
+ key = me.getKey(o);
+ }
+ old = me.map[key];
+ if (typeof key == 'undefined' || key === null || typeof old == 'undefined') {
+ return me.add(key, o);
+ }
+ index = me.indexOfKey(key);
+ me.items[index] = o;
+ me.map[key] = o;
+ me.fireEvent('replace', key, old, o);
+ return o;
+ },
+
+
+ addAll : function(objs){
+ var me = this,
+ i = 0,
+ args,
+ len,
+ key;
+
+ if (arguments.length > 1 || Ext.isArray(objs)) {
+ args = arguments.length > 1 ? arguments : objs;
+ for (len = args.length; i < len; i++) {
+ me.add(args[i]);
+ }
+ } else {
+ for (key in objs) {
+ if (objs.hasOwnProperty(key)) {
+ if (me.allowFunctions || typeof objs[key] != 'function') {
+ me.add(key, objs[key]);
+ }
+ }
+ }
+ }
+ },
+
+
+ each : function(fn, scope){
+ var items = [].concat(this.items),
+ i = 0,
+ len = items.length,
+ item;
+
+ for (; i < len; i++) {
+ item = items[i];
+ if (fn.call(scope || item, item, i, len) === false) {
+ break;
+ }
+ }
+ },
+
+
+ eachKey : function(fn, scope){
+ var keys = this.keys,
+ items = this.items,
+ i = 0,
+ len = keys.length;
+
+ for (; i < len; i++) {
+ fn.call(scope || window, keys[i], items[i], i, len);
+ }
+ },
+
+
+ findBy : function(fn, scope) {
+ var keys = this.keys,
+ items = this.items,
+ i = 0,
+ len = items.length;
+
+ for (; i < len; i++) {
+ if (fn.call(scope || window, items[i], keys[i])) {
+ return items[i];
+ }
+ }
+ return null;
+ },
+
+ find : function() {
+ if (Ext.isDefined(Ext.global.console)) {
+ Ext.global.console.warn('Ext.util.MixedCollection: find has been deprecated. Use findBy instead.');
+ }
+ return this.findBy.apply(this, arguments);
+ },
+
+
+ insert : function(index, key, obj){
+ var me = this,
+ myKey = key,
+ myObj = obj;
+
+ if (arguments.length == 2) {
+ myObj = myKey;
+ myKey = me.getKey(myObj);
+ }
+ if (me.containsKey(myKey)) {
+ me.suspendEvents();
+ me.removeAtKey(myKey);
+ me.resumeEvents();
+ }
+ if (index >= me.length) {
+ return me.add(myKey, myObj);
+ }
+ me.length++;
+ Ext.Array.splice(me.items, index, 0, myObj);
+ if (typeof myKey != 'undefined' && myKey !== null) {
+ me.map[myKey] = myObj;
+ }
+ Ext.Array.splice(me.keys, index, 0, myKey);
+ me.fireEvent('add', index, myObj, myKey);
+ return myObj;
+ },
+
+
+ remove : function(o){
+ return this.removeAt(this.indexOf(o));
+ },
+
+
+ removeAll : function(items){
+ Ext.each(items || [], function(item) {
+ this.remove(item);
+ }, this);
+
+ return this;
+ },
+
+
+ removeAt : function(index){
+ var me = this,
+ o,
+ key;
+
+ if (index < me.length && index >= 0) {
+ me.length--;
+ o = me.items[index];
+ Ext.Array.erase(me.items, index, 1);
+ key = me.keys[index];
+ if (typeof key != 'undefined') {
+ delete me.map[key];
+ }
+ Ext.Array.erase(me.keys, index, 1);
+ me.fireEvent('remove', o, key);
+ return o;
+ }
+ return false;
+ },
+
+
+ removeAtKey : function(key){
+ return this.removeAt(this.indexOfKey(key));
+ },
+
+
+ getCount : function(){
+ return this.length;
+ },
+
+
+ indexOf : function(o){
+ return Ext.Array.indexOf(this.items, o);
+ },
+
+
+ indexOfKey : function(key){
+ return Ext.Array.indexOf(this.keys, key);
+ },
+
+
+ get : function(key) {
+ var me = this,
+ mk = me.map[key],
+ item = mk !== undefined ? mk : (typeof key == 'number') ? me.items[key] : undefined;
+ return typeof item != 'function' || me.allowFunctions ? item : null;
+ },
+
+
+ getAt : function(index) {
+ return this.items[index];
+ },
+
+
+ getByKey : function(key) {
+ return this.map[key];
+ },
+
+
+ contains : function(o){
+ return Ext.Array.contains(this.items, o);
+ },
+
+
+ containsKey : function(key){
+ return typeof this.map[key] != 'undefined';
+ },
+
+
+ clear : function(){
+ var me = this;
+
+ me.length = 0;
+ me.items = [];
+ me.keys = [];
+ me.map = {};
+ me.fireEvent('clear');
+ },
+
+
+ first : function() {
+ return this.items[0];
+ },
+
+
+ last : function() {
+ return this.items[this.length - 1];
+ },
+
+
+ sum: function(property, root, start, end) {
+ var values = this.extractValues(property, root),
+ length = values.length,
+ sum = 0,
+ i;
+
+ start = start || 0;
+ end = (end || end === 0) ? end : length - 1;
+
+ for (i = start; i <= end; i++) {
+ sum += values[i];
+ }
+
+ return sum;
+ },
+
+
+ collect: function(property, root, allowNull) {
+ var values = this.extractValues(property, root),
+ length = values.length,
+ hits = {},
+ unique = [],
+ value, strValue, i;
+
+ for (i = 0; i < length; i++) {
+ value = values[i];
+ strValue = String(value);
+
+ if ((allowNull || !Ext.isEmpty(value)) && !hits[strValue]) {
+ hits[strValue] = true;
+ unique.push(value);
+ }
+ }
+
+ return unique;
+ },
+
+
+ extractValues: function(property, root) {
+ var values = this.items;
+
+ if (root) {
+ values = Ext.Array.pluck(values, root);
+ }
+
+ return Ext.Array.pluck(values, property);
+ },
+
+
+ getRange : function(start, end){
+ var me = this,
+ items = me.items,
+ range = [],
+ i;
+
+ if (items.length < 1) {
+ return range;
+ }
+
+ start = start || 0;
+ end = Math.min(typeof end == 'undefined' ? me.length - 1 : end, me.length - 1);
+ if (start <= end) {
+ for (i = start; i <= end; i++) {
+ range[range.length] = items[i];
+ }
+ } else {
+ for (i = start; i >= end; i--) {
+ range[range.length] = items[i];
+ }
+ }
+ return range;
+ },
+
+
+ filter : function(property, value, anyMatch, caseSensitive) {
+ var filters = [],
+ filterFn;
+
+
+ if (Ext.isString(property)) {
+ filters.push(Ext.create('Ext.util.Filter', {
+ property : property,
+ value : value,
+ anyMatch : anyMatch,
+ caseSensitive: caseSensitive
+ }));
+ } else if (Ext.isArray(property) || property instanceof Ext.util.Filter) {
+ filters = filters.concat(property);
+ }
+
+
+
+ filterFn = function(record) {
+ var isMatch = true,
+ length = filters.length,
+ i;
+
+ for (i = 0; i < length; i++) {
+ var filter = filters[i],
+ fn = filter.filterFn,
+ scope = filter.scope;
+
+ isMatch = isMatch && fn.call(scope, record);
+ }
+
+ return isMatch;
+ };
+
+ return this.filterBy(filterFn);
+ },
+
+
+ filterBy : function(fn, scope) {
+ var me = this,
+ newMC = new this.self(),
+ keys = me.keys,
+ items = me.items,
+ length = items.length,
+ i;
+
+ newMC.getKey = me.getKey;
+
+ for (i = 0; i < length; i++) {
+ if (fn.call(scope || me, items[i], keys[i])) {
+ newMC.add(keys[i], items[i]);
+ }
+ }
+
+ return newMC;
+ },
+
+
+ findIndex : function(property, value, start, anyMatch, caseSensitive){
+ if(Ext.isEmpty(value, false)){
+ return -1;
+ }
+ value = this.createValueMatcher(value, anyMatch, caseSensitive);
+ return this.findIndexBy(function(o){
+ return o && value.test(o[property]);
+ }, null, start);
+ },
+
+
+ findIndexBy : function(fn, scope, start){
+ var me = this,
+ keys = me.keys,
+ items = me.items,
+ i = start || 0,
+ len = items.length;
+
+ for (; i < len; i++) {
+ if (fn.call(scope || me, items[i], keys[i])) {
+ return i;
+ }
+ }
+ return -1;
+ },
+
+
+ createValueMatcher : function(value, anyMatch, caseSensitive, exactMatch) {
+ if (!value.exec) {
+ var er = Ext.String.escapeRegex;
+ value = String(value);
+
+ if (anyMatch === true) {
+ value = er(value);
+ } else {
+ value = '^' + er(value);
+ if (exactMatch === true) {
+ value += '$';
+ }
+ }
+ value = new RegExp(value, caseSensitive ? '' : 'i');
+ }
+ return value;
+ },
+
+
+ clone : function() {
+ var me = this,
+ copy = new this.self(),
+ keys = me.keys,
+ items = me.items,
+ i = 0,
+ len = items.length;
+
+ for(; i < len; i++){
+ copy.add(keys[i], items[i]);
+ }
+ copy.getKey = me.getKey;
+ return copy;
+ }
+});
+
+
+Ext.define("Ext.util.Sortable", {
+
+ isSortable: true,
+
+
+ defaultSortDirection: "ASC",
+
+ requires: [
+ 'Ext.util.Sorter'
+ ],
+
+
+
+
+ initSortable: function() {
+ var me = this,
+ sorters = me.sorters;
+
+
+ me.sorters = Ext.create('Ext.util.AbstractMixedCollection', false, function(item) {
+ return item.id || item.property;
+ });
+
+ if (sorters) {
+ me.sorters.addAll(me.decodeSorters(sorters));
+ }
+ },
+
+
+ sort: function(sorters, direction, where, doSort) {
+ var me = this,
+ sorter, sorterFn,
+ newSorters;
+
+ if (Ext.isArray(sorters)) {
+ doSort = where;
+ where = direction;
+ newSorters = sorters;
+ }
+ else if (Ext.isObject(sorters)) {
+ doSort = where;
+ where = direction;
+ newSorters = [sorters];
+ }
+ else if (Ext.isString(sorters)) {
+ sorter = me.sorters.get(sorters);
+
+ if (!sorter) {
+ sorter = {
+ property : sorters,
+ direction: direction
+ };
+ newSorters = [sorter];
+ }
+ else if (direction === undefined) {
+ sorter.toggle();
+ }
+ else {
+ sorter.setDirection(direction);
+ }
+ }
+
+ if (newSorters && newSorters.length) {
+ newSorters = me.decodeSorters(newSorters);
+ if (Ext.isString(where)) {
+ if (where === 'prepend') {
+ sorters = me.sorters.clone().items;
+
+ me.sorters.clear();
+ me.sorters.addAll(newSorters);
+ me.sorters.addAll(sorters);
+ }
+ else {
+ me.sorters.addAll(newSorters);
+ }
+ }
+ else {
+ me.sorters.clear();
+ me.sorters.addAll(newSorters);
+ }
+ }
+
+ if (doSort !== false) {
+ me.onBeforeSort(newSorters);
+
+ sorters = me.sorters.items;
+ if (sorters.length) {
+
+ sorterFn = function(r1, r2) {
+ var result = sorters[0].sort(r1, r2),
+ length = sorters.length,
+ i;
+
+
+ for (i = 1; i < length; i++) {
+ result = result || sorters[i].sort.call(this, r1, r2);
+ }
+
+ return result;
+ };
+
+ me.doSort(sorterFn);
+ }
+ }
+
+ return sorters;
+ },
+
+ onBeforeSort: Ext.emptyFn,
+
+
+ decodeSorters: function(sorters) {
+ if (!Ext.isArray(sorters)) {
+ if (sorters === undefined) {
+ sorters = [];
+ } else {
+ sorters = [sorters];
+ }
+ }
+
+ var length = sorters.length,
+ Sorter = Ext.util.Sorter,
+ fields = this.model ? this.model.prototype.fields : null,
+ field,
+ config, i;
+
+ for (i = 0; i < length; i++) {
+ config = sorters[i];
+
+ if (!(config instanceof Sorter)) {
+ if (Ext.isString(config)) {
+ config = {
+ property: config
+ };
+ }
+
+ Ext.applyIf(config, {
+ root : this.sortRoot,
+ direction: "ASC"
+ });
+
+
+ if (config.fn) {
+ config.sorterFn = config.fn;
+ }
+
+
+ if (typeof config == 'function') {
+ config = {
+ sorterFn: config
+ };
+ }
+
+
+ if (fields && !config.transform) {
+ field = fields.get(config.property);
+ config.transform = field ? field.sortType : undefined;
+ }
+ sorters[i] = Ext.create('Ext.util.Sorter', config);
+ }
+ }
+
+ return sorters;
+ },
+
+ getSorters: function() {
+ return this.sorters.items;
+ }
+});
+
+Ext.define('Ext.util.MixedCollection', {
+ extend: 'Ext.util.AbstractMixedCollection',
+ mixins: {
+ sortable: 'Ext.util.Sortable'
+ },
+
+
+ constructor: function() {
+ var me = this;
+ me.callParent(arguments);
+ me.addEvents('sort');
+ me.mixins.sortable.initSortable.call(me);
+ },
+
+ doSort: function(sorterFn) {
+ this.sortBy(sorterFn);
+ },
+
+
+ _sort : function(property, dir, fn){
+ var me = this,
+ i, len,
+ dsc = String(dir).toUpperCase() == 'DESC' ? -1 : 1,
+
+
+ c = [],
+ keys = me.keys,
+ items = me.items;
+
+
+ fn = fn || function(a, b) {
+ return a - b;
+ };
+
+
+ for(i = 0, len = items.length; i < len; i++){
+ c[c.length] = {
+ key : keys[i],
+ value: items[i],
+ index: i
+ };
+ }
+
+
+ Ext.Array.sort(c, function(a, b){
+ var v = fn(a[property], b[property]) * dsc;
+ if(v === 0){
+ v = (a.index < b.index ? -1 : 1);
+ }
+ return v;
+ });
+
+
+ for(i = 0, len = c.length; i < len; i++){
+ items[i] = c[i].value;
+ keys[i] = c[i].key;
+ }
+
+ me.fireEvent('sort', me);
+ },
+
+
+ sortBy: function(sorterFn) {
+ var me = this,
+ items = me.items,
+ keys = me.keys,
+ length = items.length,
+ temp = [],
+ i;
+
+
+ for (i = 0; i < length; i++) {
+ temp[i] = {
+ key : keys[i],
+ value: items[i],
+ index: i
+ };
+ }
+
+ Ext.Array.sort(temp, function(a, b) {
+ var v = sorterFn(a.value, b.value);
+ if (v === 0) {
+ v = (a.index < b.index ? -1 : 1);
+ }
+
+ return v;
+ });
+
+
+ for (i = 0; i < length; i++) {
+ items[i] = temp[i].value;
+ keys[i] = temp[i].key;
+ }
+
+ me.fireEvent('sort', me, items, keys);
+ },
+
+
+ reorder: function(mapping) {
+ var me = this,
+ items = me.items,
+ index = 0,
+ length = items.length,
+ order = [],
+ remaining = [],
+ oldIndex;
+
+ me.suspendEvents();
+
+
+ for (oldIndex in mapping) {
+ order[mapping[oldIndex]] = items[oldIndex];
+ }
+
+ for (index = 0; index < length; index++) {
+ if (mapping[index] == undefined) {
+ remaining.push(items[index]);
+ }
+ }
+
+ for (index = 0; index < length; index++) {
+ if (order[index] == undefined) {
+ order[index] = remaining.shift();
+ }
+ }
+
+ me.clear();
+ me.addAll(order);
+
+ me.resumeEvents();
+ me.fireEvent('sort', me);
+ },
+
+
+ sortByKey : function(dir, fn){
+ this._sort('key', dir, fn || function(a, b){
+ var v1 = String(a).toUpperCase(), v2 = String(b).toUpperCase();
+ return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
+ });
+ }
+});
+
+
+Ext.define('Ext.data.Errors', {
+ extend: 'Ext.util.MixedCollection',
+
+
+ isValid: function() {
+ return this.length === 0;
+ },
+
+
+ getByField: function(fieldName) {
+ var errors = [],
+ error, field, i;
+
+ for (i = 0; i < this.length; i++) {
+ error = this.items[i];
+
+ if (error.field == fieldName) {
+ errors.push(error);
+ }
+ }
+
+ return errors;
+ }
+});
+
+
+Ext.define('Ext.data.reader.Reader', {
+ requires: ['Ext.data.ResultSet'],
+ alternateClassName: ['Ext.data.Reader', 'Ext.data.DataReader'],
+
+
+
+
+ totalProperty: 'total',
+
+
+ successProperty: 'success',
+
+
+ root: '',
+
+
+
+
+ implicitIncludes: true,
+
+ isReader: true,
+
+
+ constructor: function(config) {
+ var me = this;
+
+ Ext.apply(me, config || {});
+ me.fieldCount = 0;
+ me.model = Ext.ModelManager.getModel(config.model);
+ if (me.model) {
+ me.buildExtractors();
+ }
+ },
+
+
+ setModel: function(model, setOnProxy) {
+ var me = this;
+
+ me.model = Ext.ModelManager.getModel(model);
+ me.buildExtractors(true);
+
+ if (setOnProxy && me.proxy) {
+ me.proxy.setModel(me.model, true);
+ }
+ },
+
+
+ read: function(response) {
+ var data = response;
+
+ if (response && response.responseText) {
+ data = this.getResponseData(response);
+ }
+
+ if (data) {
+ return this.readRecords(data);
+ } else {
+ return this.nullResultSet;
+ }
+ },
+
+
+ readRecords: function(data) {
+ var me = this;
+
+
+ if (me.fieldCount !== me.getFields().length) {
+ me.buildExtractors(true);
+ }
+
+
+ me.rawData = data;
+
+ data = me.getData(data);
+
+
+
+ var root = Ext.isArray(data) ? data : me.getRoot(data),
+ success = true,
+ recordCount = 0,
+ total, value, records, message;
+
+ if (root) {
+ total = root.length;
+ }
+
+ if (me.totalProperty) {
+ value = parseInt(me.getTotal(data), 10);
+ if (!isNaN(value)) {
+ total = value;
+ }
+ }
+
+ if (me.successProperty) {
+ value = me.getSuccess(data);
+ if (value === false || value === 'false') {
+ success = false;
+ }
+ }
+
+ if (me.messageProperty) {
+ message = me.getMessage(data);
+ }
+
+ if (root) {
+ records = me.extractData(root);
+ recordCount = records.length;
+ } else {
+ recordCount = 0;
+ records = [];
+ }
+
+ return Ext.create('Ext.data.ResultSet', {
+ total : total || recordCount,
+ count : recordCount,
+ records: records,
+ success: success,
+ message: message
+ });
+ },
+
+
+ extractData : function(root) {
+ var me = this,
+ values = [],
+ records = [],
+ Model = me.model,
+ i = 0,
+ length = root.length,
+ idProp = me.getIdProperty(),
+ node, id, record;
+
+ if (!root.length && Ext.isObject(root)) {
+ root = [root];
+ length = 1;
+ }
+
+ for (; i < length; i++) {
+ node = root[i];
+ values = me.extractValues(node);
+ id = me.getId(node);
+
+
+ record = new Model(values, id, node);
+ records.push(record);
+
+ if (me.implicitIncludes) {
+ me.readAssociated(record, node);
+ }
+ }
+
+ return records;
+ },
+
+
+ readAssociated: function(record, data) {
+ var associations = record.associations.items,
+ i = 0,
+ length = associations.length,
+ association, associationData, proxy, reader;
+
+ for (; i < length; i++) {
+ association = associations[i];
+ associationData = this.getAssociatedDataRoot(data, association.associationKey || association.name);
+
+ if (associationData) {
+ reader = association.getReader();
+ if (!reader) {
+ proxy = association.associatedModel.proxy;
+
+ if (proxy) {
+ reader = proxy.getReader();
+ } else {
+ reader = new this.constructor({
+ model: association.associatedName
+ });
+ }
+ }
+ association.read(record, reader, associationData);
+ }
+ }
+ },
+
+
+ getAssociatedDataRoot: function(data, associationName) {
+ return data[associationName];
+ },
+
+ getFields: function() {
+ return this.model.prototype.fields.items;
+ },
+
+
+ extractValues: function(data) {
+ var fields = this.getFields(),
+ i = 0,
+ length = fields.length,
+ output = {},
+ field, value;
+
+ for (; i < length; i++) {
+ field = fields[i];
+ value = this.extractorFunctions[i](data);
+
+ output[field.name] = value;
+ }
+
+ return output;
+ },
+
+
+ getData: function(data) {
+ return data;
+ },
+
+
+ getRoot: function(data) {
+ return data;
+ },
+
+
+ getResponseData: function(response) {
+ },
+
+
+ onMetaChange : function(meta) {
+ var fields = meta.fields,
+ newModel;
+
+ Ext.apply(this, meta);
+
+ if (fields) {
+ newModel = Ext.define("Ext.data.reader.Json-Model" + Ext.id(), {
+ extend: 'Ext.data.Model',
+ fields: fields
+ });
+ this.setModel(newModel, true);
+ } else {
+ this.buildExtractors(true);
+ }
+ },
+
+
+ getIdProperty: function(){
+ var prop = this.idProperty;
+ if (Ext.isEmpty(prop)) {
+ prop = this.model.prototype.idProperty;
+ }
+ return prop;
+ },
+
+
+ buildExtractors: function(force) {
+ var me = this,
+ idProp = me.getIdProperty(),
+ totalProp = me.totalProperty,
+ successProp = me.successProperty,
+ messageProp = me.messageProperty,
+ accessor;
+
+ if (force === true) {
+ delete me.extractorFunctions;
+ }
+
+ if (me.extractorFunctions) {
+ return;
+ }
+
+
+ if (totalProp) {
+ me.getTotal = me.createAccessor(totalProp);
+ }
+
+ if (successProp) {
+ me.getSuccess = me.createAccessor(successProp);
+ }
+
+ if (messageProp) {
+ me.getMessage = me.createAccessor(messageProp);
+ }
+
+ if (idProp) {
+ accessor = me.createAccessor(idProp);
+
+ me.getId = function(record) {
+ var id = accessor.call(me, record);
+ return (id === undefined || id === '') ? null : id;
+ };
+ } else {
+ me.getId = function() {
+ return null;
+ };
+ }
+ me.buildFieldExtractors();
+ },
+
+
+ buildFieldExtractors: function() {
+
+ var me = this,
+ fields = me.getFields(),
+ ln = fields.length,
+ i = 0,
+ extractorFunctions = [],
+ field, map;
+
+ for (; i < ln; i++) {
+ field = fields[i];
+ map = (field.mapping !== undefined && field.mapping !== null) ? field.mapping : field.name;
+
+ extractorFunctions.push(me.createAccessor(map));
+ }
+ me.fieldCount = ln;
+
+ me.extractorFunctions = extractorFunctions;
+ }
+}, function() {
+ Ext.apply(this, {
+
+ nullResultSet: Ext.create('Ext.data.ResultSet', {
+ total : 0,
+ count : 0,
+ records: [],
+ success: true
+ })
+ });
+});
+
+Ext.define('Ext.data.reader.Json', {
+ extend: 'Ext.data.reader.Reader',
+ alternateClassName: 'Ext.data.JsonReader',
+ alias : 'reader.json',
+
+ root: '',
+
+
+
+
+ useSimpleAccessors: false,
+
+
+ readRecords: function(data) {
+
+ if (data.metaData) {
+ this.onMetaChange(data.metaData);
+ }
+
+
+ this.jsonData = data;
+ return this.callParent([data]);
+ },
+
+
+ getResponseData: function(response) {
+ var data;
+ try {
+ data = Ext.decode(response.responseText);
+ }
+ catch (ex) {
+ Ext.Error.raise({
+ response: response,
+ json: response.responseText,
+ parseError: ex,
+ msg: 'Unable to parse the JSON returned by the server: ' + ex.toString()
+ });
+ }
+
+ return data;
+ },
+
+
+ buildExtractors : function() {
+ var me = this;
+
+ me.callParent(arguments);
+
+ if (me.root) {
+ me.getRoot = me.createAccessor(me.root);
+ } else {
+ me.getRoot = function(root) {
+ return root;
+ };
+ }
+ },
+
+
+ extractData: function(root) {
+ var recordName = this.record,
+ data = [],
+ length, i;
+
+ if (recordName) {
+ length = root.length;
+
+ if (!length && Ext.isObject(root)) {
+ length = 1;
+ root = [root];
+ }
+
+ for (i = 0; i < length; i++) {
+ data[i] = root[i][recordName];
+ }
+ } else {
+ data = root;
+ }
+ return this.callParent([data]);
+ },
+
+
+ createAccessor: function() {
+ var re = /[\[\.]/;
+
+ return function(expr) {
+ if (Ext.isEmpty(expr)) {
+ return Ext.emptyFn;
+ }
+ if (Ext.isFunction(expr)) {
+ return expr;
+ }
+ if (this.useSimpleAccessors !== true) {
+ var i = String(expr).search(re);
+ if (i >= 0) {
+ return Ext.functionFactory('obj', 'return obj' + (i > 0 ? '.' : '') + expr);
+ }
+ }
+ return function(obj) {
+ return obj[expr];
+ };
+ };
+ }()
+});
+
+Ext.define('Ext.data.writer.Json', {
+ extend: 'Ext.data.writer.Writer',
+ alternateClassName: 'Ext.data.JsonWriter',
+ alias: 'writer.json',
+
+
+ root: undefined,
+
+
+ encode: false,
+
+
+ allowSingle: true,
+
+
+ writeRecords: function(request, data) {
+ var root = this.root;
+
+ if (this.allowSingle && data.length == 1) {
+
+ data = data[0];
+ }
+
+ if (this.encode) {
+ if (root) {
+
+ request.params[root] = Ext.encode(data);
+ } else {
+ }
+ } else {
+
+ request.jsonData = request.jsonData || {};
+ if (root) {
+ request.jsonData[root] = data;
+ } else {
+ request.jsonData = data;
+ }
+ }
+ return request;
+ }
+});
+
+
+Ext.define('Ext.data.proxy.Proxy', {
+ alias: 'proxy.proxy',
+ alternateClassName: ['Ext.data.DataProxy', 'Ext.data.Proxy'],
+ requires: [
+ 'Ext.data.reader.Json',
+ 'Ext.data.writer.Json'
+ ],
+ uses: [
+ 'Ext.data.Batch',
+ 'Ext.data.Operation',
+ 'Ext.data.Model'
+ ],
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+
+ batchOrder: 'create,update,destroy',
+
+
+ batchActions: true,
+
+
+ defaultReaderType: 'json',
+
+
+ defaultWriterType: 'json',
+
+
+
+
+
+
+
+ isProxy: true,
+
+
+ constructor: function(config) {
+ config = config || {};
+
+ if (config.model === undefined) {
+ delete config.model;
+ }
+
+ this.mixins.observable.constructor.call(this, config);
+
+ if (this.model !== undefined && !(this.model instanceof Ext.data.Model)) {
+ this.setModel(this.model);
+ }
+ },
+
+
+ setModel: function(model, setOnStore) {
+ this.model = Ext.ModelManager.getModel(model);
+
+ var reader = this.reader,
+ writer = this.writer;
+
+ this.setReader(reader);
+ this.setWriter(writer);
+
+ if (setOnStore && this.store) {
+ this.store.setModel(this.model);
+ }
+ },
+
+
+ getModel: function() {
+ return this.model;
+ },
+
+
+ setReader: function(reader) {
+ var me = this;
+
+ if (reader === undefined || typeof reader == 'string') {
+ reader = {
+ type: reader
+ };
+ }
+
+ if (reader.isReader) {
+ reader.setModel(me.model);
+ } else {
+ Ext.applyIf(reader, {
+ proxy: me,
+ model: me.model,
+ type : me.defaultReaderType
+ });
+
+ reader = Ext.createByAlias('reader.' + reader.type, reader);
+ }
+
+ me.reader = reader;
+ return me.reader;
+ },
+
+
+ getReader: function() {
+ return this.reader;
+ },
+
+
+ setWriter: function(writer) {
+ if (writer === undefined || typeof writer == 'string') {
+ writer = {
+ type: writer
+ };
+ }
+
+ if (!(writer instanceof Ext.data.writer.Writer)) {
+ Ext.applyIf(writer, {
+ model: this.model,
+ type : this.defaultWriterType
+ });
+
+ writer = Ext.createByAlias('writer.' + writer.type, writer);
+ }
+
+ this.writer = writer;
+
+ return this.writer;
+ },
+
+
+ getWriter: function() {
+ return this.writer;
+ },
+
+
+ create: Ext.emptyFn,
+
+
+ read: Ext.emptyFn,
+
+
+ update: Ext.emptyFn,
+
+
+ destroy: Ext.emptyFn,
+
+
+ batch: function(operations, listeners) {
+ var me = this,
+ batch = Ext.create('Ext.data.Batch', {
+ proxy: me,
+ listeners: listeners || {}
+ }),
+ useBatch = me.batchActions,
+ records;
+
+ Ext.each(me.batchOrder.split(','), function(action) {
+ records = operations[action];
+ if (records) {
+ if (useBatch) {
+ batch.add(Ext.create('Ext.data.Operation', {
+ action: action,
+ records: records
+ }));
+ } else {
+ Ext.each(records, function(record){
+ batch.add(Ext.create('Ext.data.Operation', {
+ action : action,
+ records: [record]
+ }));
+ });
+ }
+ }
+ }, me);
+
+ batch.start();
+ return batch;
+ }
+}, function() {
+
+
+
+ Ext.data.DataProxy = this;
+
+
+
+});
+
+
+Ext.define('Ext.data.proxy.Server', {
+ extend: 'Ext.data.proxy.Proxy',
+ alias : 'proxy.server',
+ alternateClassName: 'Ext.data.ServerProxy',
+ uses : ['Ext.data.Request'],
+
+
+
+
+ pageParam: 'page',
+
+
+ startParam: 'start',
+
+
+ limitParam: 'limit',
+
+
+ groupParam: 'group',
+
+
+ sortParam: 'sort',
+
+
+ filterParam: 'filter',
+
+
+ directionParam: 'dir',
+
+
+ simpleSortMode: false,
+
+
+ noCache : true,
+
+
+ cacheString: "_dc",
+
+
+ timeout : 30000,
+
+
+
+ constructor: function(config) {
+ var me = this;
+
+ config = config || {};
+ this.addEvents(
+
+ 'exception'
+ );
+ me.callParent([config]);
+
+
+ me.extraParams = config.extraParams || {};
+
+ me.api = config.api || {};
+
+
+ me.nocache = me.noCache;
+ },
+
+
+ create: function() {
+ return this.doRequest.apply(this, arguments);
+ },
+
+ read: function() {
+ return this.doRequest.apply(this, arguments);
+ },
+
+ update: function() {
+ return this.doRequest.apply(this, arguments);
+ },
+
+ destroy: function() {
+ return this.doRequest.apply(this, arguments);
+ },
+
+
+ buildRequest: function(operation) {
+ var params = Ext.applyIf(operation.params || {}, this.extraParams || {}),
+ request;
+
+
+ params = Ext.applyIf(params, this.getParams(operation));
+
+ if (operation.id && !params.id) {
+ params.id = operation.id;
+ }
+
+ request = Ext.create('Ext.data.Request', {
+ params : params,
+ action : operation.action,
+ records : operation.records,
+ operation: operation,
+ url : operation.url
+ });
+
+ request.url = this.buildUrl(request);
+
+
+ operation.request = request;
+
+ return request;
+ },
+
+
+ processResponse: function(success, operation, request, response, callback, scope){
+ var me = this,
+ reader,
+ result;
+
+ if (success === true) {
+ reader = me.getReader();
+ result = reader.read(me.extractResponseData(response));
+
+ if (result.success !== false) {
+
+ Ext.apply(operation, {
+ response: response,
+ resultSet: result
+ });
+
+ operation.commitRecords(result.records);
+ operation.setCompleted();
+ operation.setSuccessful();
+ } else {
+ operation.setException(result.message);
+ me.fireEvent('exception', this, response, operation);
+ }
+ } else {
+ me.setException(operation, response);
+ me.fireEvent('exception', this, response, operation);
+ }
+
+
+ if (typeof callback == 'function') {
+ callback.call(scope || me, operation);
+ }
+
+ me.afterRequest(request, success);
+ },
+
+
+ setException: function(operation, response){
+ operation.setException({
+ status: response.status,
+ statusText: response.statusText
+ });
+ },
+
+
+ extractResponseData: function(response){
+ return response;
+ },
+
+
+ applyEncoding: function(value){
+ return Ext.encode(value);
+ },
+
+
+ encodeSorters: function(sorters) {
+ var min = [],
+ length = sorters.length,
+ i = 0;
+
+ for (; i < length; i++) {
+ min[i] = {
+ property : sorters[i].property,
+ direction: sorters[i].direction
+ };
+ }
+ return this.applyEncoding(min);
+
+ },
+
+
+ encodeFilters: function(filters) {
+ var min = [],
+ length = filters.length,
+ i = 0;
+
+ for (; i < length; i++) {
+ min[i] = {
+ property: filters[i].property,
+ value : filters[i].value
+ };
+ }
+ return this.applyEncoding(min);
+ },
+
+
+ getParams: function(operation) {
+ var me = this,
+ params = {},
+ isDef = Ext.isDefined,
+ groupers = operation.groupers,
+ sorters = operation.sorters,
+ filters = operation.filters,
+ page = operation.page,
+ start = operation.start,
+ limit = operation.limit,
+
+ simpleSortMode = me.simpleSortMode,
+
+ pageParam = me.pageParam,
+ startParam = me.startParam,
+ limitParam = me.limitParam,
+ groupParam = me.groupParam,
+ sortParam = me.sortParam,
+ filterParam = me.filterParam,
+ directionParam = me.directionParam;
+
+ if (pageParam && isDef(page)) {
+ params[pageParam] = page;
+ }
+
+ if (startParam && isDef(start)) {
+ params[startParam] = start;
+ }
+
+ if (limitParam && isDef(limit)) {
+ params[limitParam] = limit;
+ }
+
+ if (groupParam && groupers && groupers.length > 0) {
+
+ params[groupParam] = me.encodeSorters(groupers);
+ }
+
+ if (sortParam && sorters && sorters.length > 0) {
+ if (simpleSortMode) {
+ params[sortParam] = sorters[0].property;
+ params[directionParam] = sorters[0].direction;
+ } else {
+ params[sortParam] = me.encodeSorters(sorters);
+ }
+
+ }
+
+ if (filterParam && filters && filters.length > 0) {
+ params[filterParam] = me.encodeFilters(filters);
+ }
+
+ return params;
+ },
+
+
+ buildUrl: function(request) {
+ var me = this,
+ url = me.getUrl(request);
+
+
+ if (me.noCache) {
+ url = Ext.urlAppend(url, Ext.String.format("{0}={1}", me.cacheString, Ext.Date.now()));
+ }
+
+ return url;
+ },
+
+
+ getUrl: function(request){
+ return request.url || this.api[request.action] || this.url;
+ },
+
+
+ doRequest: function(operation, callback, scope) {
+ },
+
+
+ afterRequest: Ext.emptyFn,
+
+ onDestroy: function() {
+ Ext.destroy(this.reader, this.writer);
+ }
+});
+
+
+Ext.define('Ext.data.proxy.Ajax', {
+ requires: ['Ext.util.MixedCollection', 'Ext.Ajax'],
+ extend: 'Ext.data.proxy.Server',
+ alias: 'proxy.ajax',
+ alternateClassName: ['Ext.data.HttpProxy', 'Ext.data.AjaxProxy'],
+
+
+ actionMethods: {
+ create : 'POST',
+ read : 'GET',
+ update : 'POST',
+ destroy: 'POST'
+ },
+
+
+
+
+ doRequest: function(operation, callback, scope) {
+ var writer = this.getWriter(),
+ request = this.buildRequest(operation, callback, scope);
+
+ if (operation.allowWrite()) {
+ request = writer.write(request);
+ }
+
+ Ext.apply(request, {
+ headers : this.headers,
+ timeout : this.timeout,
+ scope : this,
+ callback : this.createRequestCallback(request, operation, callback, scope),
+ method : this.getMethod(request),
+ disableCaching: false
+ });
+
+ Ext.Ajax.request(request);
+
+ return request;
+ },
+
+
+ getMethod: function(request) {
+ return this.actionMethods[request.action];
+ },
+
+
+ createRequestCallback: function(request, operation, callback, scope) {
+ var me = this;
+
+ return function(options, success, response) {
+ me.processResponse(success, operation, request, response, callback, scope);
+ };
+ }
+}, function() {
+
+ Ext.data.HttpProxy = this;
+});
+
+
+Ext.define('Ext.data.Model', {
+ alternateClassName: 'Ext.data.Record',
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ requires: [
+ 'Ext.ModelManager',
+ 'Ext.data.IdGenerator',
+ 'Ext.data.Field',
+ 'Ext.data.Errors',
+ 'Ext.data.Operation',
+ 'Ext.data.validations',
+ 'Ext.data.proxy.Ajax',
+ 'Ext.util.MixedCollection'
+ ],
+
+ onClassExtended: function(cls, data) {
+ var onBeforeClassCreated = data.onBeforeClassCreated;
+
+ data.onBeforeClassCreated = function(cls, data) {
+ var me = this,
+ name = Ext.getClassName(cls),
+ prototype = cls.prototype,
+ superCls = cls.prototype.superclass,
+
+ validations = data.validations || [],
+ fields = data.fields || [],
+ associations = data.associations || [],
+ belongsTo = data.belongsTo,
+ hasMany = data.hasMany,
+ idgen = data.idgen,
+
+ fieldsMixedCollection = new Ext.util.MixedCollection(false, function(field) {
+ return field.name;
+ }),
+
+ associationsMixedCollection = new Ext.util.MixedCollection(false, function(association) {
+ return association.name;
+ }),
+
+ superValidations = superCls.validations,
+ superFields = superCls.fields,
+ superAssociations = superCls.associations,
+
+ association, i, ln,
+ dependencies = [];
+
+
+ cls.modelName = name;
+ prototype.modelName = name;
+
+
+ if (superValidations) {
+ validations = superValidations.concat(validations);
+ }
+
+ data.validations = validations;
+
+
+ if (superFields) {
+ fields = superFields.items.concat(fields);
+ }
+
+ for (i = 0, ln = fields.length; i < ln; ++i) {
+ fieldsMixedCollection.add(new Ext.data.Field(fields[i]));
+ }
+
+ data.fields = fieldsMixedCollection;
+
+ if (idgen) {
+ data.idgen = Ext.data.IdGenerator.get(idgen);
+ }
+
+
+
+ if (belongsTo) {
+ belongsTo = Ext.Array.from(belongsTo);
+
+ for (i = 0, ln = belongsTo.length; i < ln; ++i) {
+ association = belongsTo[i];
+
+ if (!Ext.isObject(association)) {
+ association = {model: association};
+ }
+
+ association.type = 'belongsTo';
+ associations.push(association);
+ }
+
+ delete data.belongsTo;
+ }
+
+ if (hasMany) {
+ hasMany = Ext.Array.from(hasMany);
+ for (i = 0, ln = hasMany.length; i < ln; ++i) {
+ association = hasMany[i];
+
+ if (!Ext.isObject(association)) {
+ association = {model: association};
+ }
+
+ association.type = 'hasMany';
+ associations.push(association);
+ }
+
+ delete data.hasMany;
+ }
+
+ if (superAssociations) {
+ associations = superAssociations.items.concat(associations);
+ }
+
+ for (i = 0, ln = associations.length; i < ln; ++i) {
+ dependencies.push('association.' + associations[i].type.toLowerCase());
+ }
+
+ if (data.proxy) {
+ if (typeof data.proxy === 'string') {
+ dependencies.push('proxy.' + data.proxy);
+ }
+ else if (typeof data.proxy.type === 'string') {
+ dependencies.push('proxy.' + data.proxy.type);
+ }
+ }
+
+ Ext.require(dependencies, function() {
+ Ext.ModelManager.registerType(name, cls);
+
+ for (i = 0, ln = associations.length; i < ln; ++i) {
+ association = associations[i];
+
+ Ext.apply(association, {
+ ownerModel: name,
+ associatedModel: association.model
+ });
+
+ if (Ext.ModelManager.getModel(association.model) === undefined) {
+ Ext.ModelManager.registerDeferredAssociation(association);
+ } else {
+ associationsMixedCollection.add(Ext.data.Association.create(association));
+ }
+ }
+
+ data.associations = associationsMixedCollection;
+
+ onBeforeClassCreated.call(me, cls, data);
+
+ cls.setProxy(cls.prototype.proxy || cls.prototype.defaultProxyType);
+
+
+ Ext.ModelManager.onModelDefined(cls);
+ });
+ };
+ },
+
+ inheritableStatics: {
+
+ setProxy: function(proxy) {
+
+ if (!proxy.isProxy) {
+ if (typeof proxy == "string") {
+ proxy = {
+ type: proxy
+ };
+ }
+ proxy = Ext.createByAlias("proxy." + proxy.type, proxy);
+ }
+ proxy.setModel(this);
+ this.proxy = this.prototype.proxy = proxy;
+
+ return proxy;
+ },
+
+
+ getProxy: function() {
+ return this.proxy;
+ },
+
+
+ load: function(id, config) {
+ config = Ext.apply({}, config);
+ config = Ext.applyIf(config, {
+ action: 'read',
+ id : id
+ });
+
+ var operation = Ext.create('Ext.data.Operation', config),
+ scope = config.scope || this,
+ record = null,
+ callback;
+
+ callback = function(operation) {
+ if (operation.wasSuccessful()) {
+ record = operation.getRecords()[0];
+ Ext.callback(config.success, scope, [record, operation]);
+ } else {
+ Ext.callback(config.failure, scope, [record, operation]);
+ }
+ Ext.callback(config.callback, scope, [record, operation]);
+ };
+
+ this.proxy.read(operation, callback, this);
+ }
+ },
+
+ statics: {
+ PREFIX : 'ext-record',
+ AUTO_ID: 1,
+ EDIT : 'edit',
+ REJECT : 'reject',
+ COMMIT : 'commit',
+
+
+ id: function(rec) {
+ var id = [this.PREFIX, '-', this.AUTO_ID++].join('');
+ rec.phantom = true;
+ rec.internalId = id;
+ return id;
+ }
+ },
+
+
+ idgen: {
+ isGenerator: true,
+ type: 'default',
+
+ generate: function () {
+ return null;
+ },
+ getRecId: function (rec) {
+ return rec.modelName + '-' + rec.internalId;
+ }
+ },
+
+
+ editing : false,
+
+
+ dirty : false,
+
+
+ persistenceProperty: 'data',
+
+ evented: false,
+ isModel: true,
+
+
+ phantom : false,
+
+
+ idProperty: 'id',
+
+
+ defaultProxyType: 'ajax',
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ constructor: function(data, id, raw) {
+ data = data || {};
+
+ var me = this,
+ fields,
+ length,
+ field,
+ name,
+ i,
+ newId,
+ isArray = Ext.isArray(data),
+ newData = isArray ? {} : null;
+
+
+ me.internalId = (id || id === 0) ? id : Ext.data.Model.id(me);
+
+
+ me.raw = raw;
+
+ Ext.applyIf(me, {
+ data: {}
+ });
+
+
+ me.modified = {};
+
+
+ if (me.persistanceProperty) {
+ me.persistenceProperty = me.persistanceProperty;
+ }
+ me[me.persistenceProperty] = {};
+
+ me.mixins.observable.constructor.call(me);
+
+
+ fields = me.fields.items;
+ length = fields.length;
+
+ for (i = 0; i < length; i++) {
+ field = fields[i];
+ name = field.name;
+
+ if (isArray){
+
+
+ newData[name] = data[i];
+ }
+ else if (data[name] === undefined) {
+ data[name] = field.defaultValue;
+ }
+ }
+
+ me.set(newData || data);
+
+ if (me.getId()) {
+ me.phantom = false;
+ } else if (me.phantom) {
+ newId = me.idgen.generate();
+ if (newId !== null) {
+ me.setId(newId);
+ }
+ }
+
+
+ me.dirty = false;
+ me.modified = {};
+
+ if (typeof me.init == 'function') {
+ me.init();
+ }
+
+ me.id = me.idgen.getRecId(me);
+ },
+
+
+ get: function(field) {
+ return this[this.persistenceProperty][field];
+ },
+
+
+ set: function(fieldName, value) {
+ var me = this,
+ fields = me.fields,
+ modified = me.modified,
+ convertFields = [],
+ field, key, i, currentValue, notEditing, count, length;
+
+
+ if (arguments.length == 1 && Ext.isObject(fieldName)) {
+ notEditing = !me.editing;
+ count = 0;
+ for (key in fieldName) {
+ if (fieldName.hasOwnProperty(key)) {
+
+
+
+ field = fields.get(key);
+ if (field && field.convert !== field.type.convert) {
+ convertFields.push(key);
+ continue;
+ }
+
+ if (!count && notEditing) {
+ me.beginEdit();
+ }
+ ++count;
+ me.set(key, fieldName[key]);
+ }
+ }
+
+ length = convertFields.length;
+ if (length) {
+ if (!count && notEditing) {
+ me.beginEdit();
+ }
+ count += length;
+ for (i = 0; i < length; i++) {
+ field = convertFields[i];
+ me.set(field, fieldName[field]);
+ }
+ }
+
+ if (notEditing && count) {
+ me.endEdit();
+ }
+ } else {
+ if (fields) {
+ field = fields.get(fieldName);
+
+ if (field && field.convert) {
+ value = field.convert(value, me);
+ }
+ }
+ currentValue = me.get(fieldName);
+ me[me.persistenceProperty][fieldName] = value;
+
+ if (field && field.persist && !me.isEqual(currentValue, value)) {
+ if (me.isModified(fieldName)) {
+ if (me.isEqual(modified[fieldName], value)) {
+
+
+ delete modified[fieldName];
+
+
+ me.dirty = false;
+ for (key in modified) {
+ if (modified.hasOwnProperty(key)){
+ me.dirty = true;
+ break;
+ }
+ }
+ }
+ } else {
+ me.dirty = true;
+ modified[fieldName] = currentValue;
+ }
+ }
+
+ if (!me.editing) {
+ me.afterEdit();
+ }
+ }
+ },
+
+
+ isEqual: function(a, b){
+ if (Ext.isDate(a) && Ext.isDate(b)) {
+ return a.getTime() === b.getTime();
+ }
+ return a === b;
+ },
+
+
+ beginEdit : function(){
+ var me = this;
+ if (!me.editing) {
+ me.editing = true;
+ me.dirtySave = me.dirty;
+ me.dataSave = Ext.apply({}, me[me.persistenceProperty]);
+ me.modifiedSave = Ext.apply({}, me.modified);
+ }
+ },
+
+
+ cancelEdit : function(){
+ var me = this;
+ if (me.editing) {
+ me.editing = false;
+
+ me.modified = me.modifiedSave;
+ me[me.persistenceProperty] = me.dataSave;
+ me.dirty = me.dirtySave;
+ delete me.modifiedSave;
+ delete me.dataSave;
+ delete me.dirtySave;
+ }
+ },
+
+
+ endEdit : function(silent){
+ var me = this,
+ didChange;
+
+ if (me.editing) {
+ me.editing = false;
+ didChange = me.dirty || me.changedWhileEditing();
+ delete me.modifiedSave;
+ delete me.dataSave;
+ delete me.dirtySave;
+ if (silent !== true && didChange) {
+ me.afterEdit();
+ }
+ }
+ },
+
+
+ changedWhileEditing: function(){
+ var me = this,
+ saved = me.dataSave,
+ data = me[me.persistenceProperty],
+ key;
+
+ for (key in data) {
+ if (data.hasOwnProperty(key)) {
+ if (!me.isEqual(data[key], saved[key])) {
+ return true;
+ }
+ }
+ }
+ return false;
+ },
+
+
+ getChanges : function(){
+ var modified = this.modified,
+ changes = {},
+ field;
+
+ for (field in modified) {
+ if (modified.hasOwnProperty(field)){
+ changes[field] = this.get(field);
+ }
+ }
+
+ return changes;
+ },
+
+
+ isModified : function(fieldName) {
+ return this.modified.hasOwnProperty(fieldName);
+ },
+
+
+ setDirty : function() {
+ var me = this,
+ name;
+
+ me.dirty = true;
+
+ me.fields.each(function(field) {
+ if (field.persist) {
+ name = field.name;
+ me.modified[name] = me.get(name);
+ }
+ }, me);
+ },
+
+
+
+ reject : function(silent) {
+ var me = this,
+ modified = me.modified,
+ field;
+
+ for (field in modified) {
+ if (modified.hasOwnProperty(field)) {
+ if (typeof modified[field] != "function") {
+ me[me.persistenceProperty][field] = modified[field];
+ }
+ }
+ }
+
+ me.dirty = false;
+ me.editing = false;
+ me.modified = {};
+
+ if (silent !== true) {
+ me.afterReject();
+ }
+ },
+
+
+ commit : function(silent) {
+ var me = this;
+
+ me.phantom = me.dirty = me.editing = false;
+ me.modified = {};
+
+ if (silent !== true) {
+ me.afterCommit();
+ }
+ },
+
+
+ copy : function(newId) {
+ var me = this;
+
+ return new me.self(Ext.apply({}, me[me.persistenceProperty]), newId || me.internalId);
+ },
+
+
+ setProxy: function(proxy) {
+
+ if (!proxy.isProxy) {
+ if (typeof proxy === "string") {
+ proxy = {
+ type: proxy
+ };
+ }
+ proxy = Ext.createByAlias("proxy." + proxy.type, proxy);
+ }
+ proxy.setModel(this.self);
+ this.proxy = proxy;
+
+ return proxy;
+ },
+
+
+ getProxy: function() {
+ return this.proxy;
+ },
+
+
+ validate: function() {
+ var errors = Ext.create('Ext.data.Errors'),
+ validations = this.validations,
+ validators = Ext.data.validations,
+ length, validation, field, valid, type, i;
+
+ if (validations) {
+ length = validations.length;
+
+ for (i = 0; i < length; i++) {
+ validation = validations[i];
+ field = validation.field || validation.name;
+ type = validation.type;
+ valid = validators[type](validation, this.get(field));
+
+ if (!valid) {
+ errors.add({
+ field : field,
+ message: validation.message || validators[type + 'Message']
+ });
+ }
+ }
+ }
+
+ return errors;
+ },
+
+
+ isValid: function(){
+ return this.validate().isValid();
+ },
+
+
+ save: function(options) {
+ options = Ext.apply({}, options);
+
+ var me = this,
+ action = me.phantom ? 'create' : 'update',
+ record = null,
+ scope = options.scope || me,
+ operation,
+ callback;
+
+ Ext.apply(options, {
+ records: [me],
+ action : action
+ });
+
+ operation = Ext.create('Ext.data.Operation', options);
+
+ callback = function(operation) {
+ if (operation.wasSuccessful()) {
+ record = operation.getRecords()[0];
+
+
+ me.set(record.data);
+ record.dirty = false;
+
+ Ext.callback(options.success, scope, [record, operation]);
+ } else {
+ Ext.callback(options.failure, scope, [record, operation]);
+ }
+
+ Ext.callback(options.callback, scope, [record, operation]);
+ };
+
+ me.getProxy()[action](operation, callback, me);
+
+ return me;
+ },
+
+
+ destroy: function(options){
+ options = Ext.apply({}, options);
+
+ var me = this,
+ record = null,
+ scope = options.scope || me,
+ operation,
+ callback;
+
+ Ext.apply(options, {
+ records: [me],
+ action : 'destroy'
+ });
+
+ operation = Ext.create('Ext.data.Operation', options);
+ callback = function(operation) {
+ if (operation.wasSuccessful()) {
+ Ext.callback(options.success, scope, [record, operation]);
+ } else {
+ Ext.callback(options.failure, scope, [record, operation]);
+ }
+ Ext.callback(options.callback, scope, [record, operation]);
+ };
+
+ me.getProxy().destroy(operation, callback, me);
+ return me;
+ },
+
+
+ getId: function() {
+ return this.get(this.idProperty);
+ },
+
+
+ setId: function(id) {
+ this.set(this.idProperty, id);
+ },
+
+
+ join : function(store) {
+
+ this.store = store;
+ },
+
+
+ unjoin: function(store) {
+ delete this.store;
+ },
+
+
+ afterEdit : function() {
+ this.callStore('afterEdit');
+ },
+
+
+ afterReject : function() {
+ this.callStore("afterReject");
+ },
+
+
+ afterCommit: function() {
+ this.callStore('afterCommit');
+ },
+
+
+ callStore: function(fn) {
+ var store = this.store;
+
+ if (store !== undefined && typeof store[fn] == "function") {
+ store[fn](this);
+ }
+ },
+
+
+ getAssociatedData: function(){
+ return this.prepareAssociatedData(this, [], null);
+ },
+
+
+ prepareAssociatedData: function(record, ids, associationType) {
+
+ var associations = record.associations.items,
+ associationCount = associations.length,
+ associationData = {},
+ associatedStore, associatedName, associatedRecords, associatedRecord,
+ associatedRecordCount, association, id, i, j, type, allow;
+
+ for (i = 0; i < associationCount; i++) {
+ association = associations[i];
+ type = association.type;
+ allow = true;
+ if (associationType) {
+ allow = type == associationType;
+ }
+ if (allow && type == 'hasMany') {
+
+
+ associatedStore = record[association.storeName];
+
+
+ associationData[association.name] = [];
+
+
+ if (associatedStore && associatedStore.data.length > 0) {
+ associatedRecords = associatedStore.data.items;
+ associatedRecordCount = associatedRecords.length;
+
+
+ for (j = 0; j < associatedRecordCount; j++) {
+ associatedRecord = associatedRecords[j];
+
+ id = associatedRecord.id;
+
+
+
+ if (Ext.Array.indexOf(ids, id) == -1) {
+ ids.push(id);
+
+ associationData[association.name][j] = associatedRecord.data;
+ Ext.apply(associationData[association.name][j], this.prepareAssociatedData(associatedRecord, ids, type));
+ }
+ }
+ }
+ } else if (allow && type == 'belongsTo') {
+ associatedRecord = record[association.instanceName];
+ if (associatedRecord !== undefined) {
+ id = associatedRecord.id;
+ if (Ext.Array.indexOf(ids, id) == -1) {
+ ids.push(id);
+ associationData[association.name] = associatedRecord.data;
+ Ext.apply(associationData[association.name], this.prepareAssociatedData(associatedRecord, ids, type));
+ }
+ }
+ }
+ }
+
+ return associationData;
+ }
+});
+
+
+Ext.define('Ext.data.StoreManager', {
+ extend: 'Ext.util.MixedCollection',
+ alternateClassName: ['Ext.StoreMgr', 'Ext.data.StoreMgr', 'Ext.StoreManager'],
+ singleton: true,
+ uses: ['Ext.data.ArrayStore'],
+
+
+
+
+ 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(store) {
+
+ if (Ext.isArray(store)) {
+ var fields = ['field1'],
+ expand = !Ext.isArray(store[0]),
+ data = store,
+ i,
+ len;
+
+ if(expand){
+ data = [];
+ for (i = 0, len = store.length; i < len; ++i) {
+ data.push([store[i]]);
+ }
+ } else {
+ for(i = 2, len = store[0].length; i <= len; ++i){
+ fields.push('field' + i);
+ }
+ }
+ return Ext.create('Ext.data.ArrayStore', {
+ data : data,
+ fields: fields,
+ autoDestroy: true,
+ autoCreated: true,
+ expanded: expand
+ });
+ }
+
+ if (Ext.isString(store)) {
+
+ return this.get(store);
+ } else {
+
+ return Ext.data.AbstractStore.create(store);
+ }
+ },
+
+
+ getKey : function(o) {
+ return o.storeId;
+ }
+}, function() {
+
+ Ext.regStore = function(name, config) {
+ var store;
+
+ if (Ext.isObject(name)) {
+ config = name;
+ } else {
+ config.storeId = name;
+ }
+
+ if (config instanceof Ext.data.Store) {
+ store = config;
+ } else {
+ store = Ext.create('Ext.data.Store', config);
+ }
+
+ return Ext.data.StoreManager.register(store);
+ };
+
+
+ Ext.getStore = function(name) {
+ return Ext.data.StoreManager.lookup(name);
+ };
+});
+
+
+Ext.define('Ext.Component', {
+
+
+
+ alias: ['widget.component', 'widget.box'],
+
+ extend: 'Ext.AbstractComponent',
+
+ requires: [
+ 'Ext.util.DelayedTask'
+ ],
+
+ uses: [
+ 'Ext.Layer',
+ 'Ext.resizer.Resizer',
+ 'Ext.util.ComponentDragger'
+ ],
+
+ mixins: {
+ floating: 'Ext.util.Floating'
+ },
+
+ statics: {
+
+ DIRECTION_TOP: 'top',
+ DIRECTION_RIGHT: 'right',
+ DIRECTION_BOTTOM: 'bottom',
+ DIRECTION_LEFT: 'left',
+
+ VERTICAL_DIRECTION_Re: /^(?:top|bottom)$/,
+
+
+
+ INVALID_ID_CHARS_Re: /[\.,\s]/g
+ },
+
+
+
+
+
+
+ resizeHandles: 'all',
+
+
+
+
+ floating: false,
+
+
+ toFrontOnShow: true,
+
+
+
+
+
+
+
+
+
+ hideMode: 'display',
+
+ hideParent: false,
+
+ ariaRole: 'presentation',
+
+ bubbleEvents: [],
+
+ actionMode: 'el',
+ monPropRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/,
+
+
+
+
+
+
+
+
+
+ constructor: function(config) {
+ var me = this;
+
+ config = config || {};
+ if (config.initialConfig) {
+
+
+ if (config.isAction) {
+ me.baseAction = config;
+ }
+ config = config.initialConfig;
+
+ }
+ else if (config.tagName || config.dom || Ext.isString(config)) {
+
+ config = {
+ applyTo: config,
+ id: config.id || config
+ };
+ }
+
+ me.callParent([config]);
+
+
+
+ if (me.baseAction){
+ me.baseAction.addComponent(me);
+ }
+ },
+
+
+ initComponent: function() {
+ var me = this;
+
+ me.callParent();
+
+ if (me.listeners) {
+ me.on(me.listeners);
+ delete me.listeners;
+ }
+ me.enableBubble(me.bubbleEvents);
+ me.mons = [];
+ },
+
+
+ afterRender: function() {
+ var me = this,
+ resizable = me.resizable;
+
+ if (me.floating) {
+ me.makeFloating(me.floating);
+ } else {
+ me.el.setVisibilityMode(Ext.Element[me.hideMode.toUpperCase()]);
+ }
+
+ if (Ext.isDefined(me.autoScroll)) {
+ me.setAutoScroll(me.autoScroll);
+ }
+ me.callParent();
+
+ if (!(me.x && me.y) && (me.pageX || me.pageY)) {
+ me.setPagePosition(me.pageX, me.pageY);
+ }
+
+ if (resizable) {
+ me.initResizable(resizable);
+ }
+
+ if (me.draggable) {
+ me.initDraggable();
+ }
+
+ me.initAria();
+ },
+
+ initAria: function() {
+ var actionEl = this.getActionEl(),
+ role = this.ariaRole;
+ if (role) {
+ actionEl.dom.setAttribute('role', role);
+ }
+ },
+
+
+ setAutoScroll : function(scroll){
+ var me = this,
+ targetEl;
+ scroll = !!scroll;
+ if (me.rendered) {
+ targetEl = me.getTargetEl();
+ targetEl.setStyle('overflow', scroll ? 'auto' : '');
+ if (scroll && (Ext.isIE6 || Ext.isIE7)) {
+
+
+ targetEl.position();
+ }
+ }
+ me.autoScroll = scroll;
+ return me;
+ },
+
+
+ makeFloating : function(cfg){
+ this.mixins.floating.constructor.call(this, cfg);
+ },
+
+ initResizable: function(resizable) {
+ var me = this;
+
+ resizable = Ext.apply({
+ target: me,
+ dynamic: false,
+ constrainTo: me.constrainTo || (me.floatParent ? me.floatParent.getTargetEl() : me.el.getScopeParent()),
+ handles: me.resizeHandles
+ }, resizable);
+ resizable.target = me;
+ me.resizer = Ext.create('Ext.resizer.Resizer', resizable);
+ },
+
+ getDragEl: function() {
+ return this.el;
+ },
+
+ initDraggable: function() {
+ var me = this,
+ ddConfig = Ext.applyIf({
+ el: me.getDragEl(),
+ constrainTo: me.constrain ? (me.constrainTo || (me.floatParent ? me.floatParent.getTargetEl() : me.el.getScopeParent())) : undefined
+ }, me.draggable);
+
+
+ if (me.constrain || me.constrainDelegate) {
+ ddConfig.constrain = me.constrain;
+ ddConfig.constrainDelegate = me.constrainDelegate;
+ }
+
+ me.dd = Ext.create('Ext.util.ComponentDragger', me, ddConfig);
+ },
+
+
+ setPosition: function(x, y, animate) {
+ var me = this,
+ el = me.el,
+ to = {},
+ adj, adjX, adjY, xIsNumber, yIsNumber;
+
+ if (Ext.isArray(x)) {
+ animate = y;
+ y = x[1];
+ x = x[0];
+ }
+ me.x = x;
+ me.y = y;
+
+ if (!me.rendered) {
+ return me;
+ }
+
+ adj = me.adjustPosition(x, y);
+ adjX = adj.x;
+ adjY = adj.y;
+ xIsNumber = Ext.isNumber(adjX);
+ yIsNumber = Ext.isNumber(adjY);
+
+ if (xIsNumber || yIsNumber) {
+ if (animate) {
+ if (xIsNumber) {
+ to.left = adjX;
+ }
+ if (yIsNumber) {
+ to.top = adjY;
+ }
+
+ me.stopAnimation();
+ me.animate(Ext.apply({
+ duration: 1000,
+ listeners: {
+ afteranimate: Ext.Function.bind(me.afterSetPosition, me, [adjX, adjY])
+ },
+ to: to
+ }, animate));
+ }
+ else {
+ if (!xIsNumber) {
+ el.setTop(adjY);
+ }
+ else if (!yIsNumber) {
+ el.setLeft(adjX);
+ }
+ else {
+ el.setLeftTop(adjX, adjY);
+ }
+ me.afterSetPosition(adjX, adjY);
+ }
+ }
+ return me;
+ },
+
+
+ afterSetPosition: function(ax, ay) {
+ this.onPosition(ax, ay);
+ this.fireEvent('move', this, ax, ay);
+ },
+
+
+ showAt: function(x, y, animate) {
+ var me = this;
+
+ if (me.floating) {
+ me.setPosition(x, y, animate);
+ } else {
+ me.setPagePosition(x, y, animate);
+ }
+ me.show();
+ },
+
+
+ setPagePosition: function(x, y, animate) {
+ var me = this,
+ p;
+
+ if (Ext.isArray(x)) {
+ y = x[1];
+ x = x[0];
+ }
+ me.pageX = x;
+ me.pageY = y;
+ if (me.floating && me.floatParent) {
+
+ p = me.floatParent.getTargetEl().getViewRegion();
+ if (Ext.isNumber(x) && Ext.isNumber(p.left)) {
+ x -= p.left;
+ }
+ if (Ext.isNumber(y) && Ext.isNumber(p.top)) {
+ y -= p.top;
+ }
+ me.setPosition(x, y, animate);
+ }
+ else {
+ p = me.el.translatePoints(x, y);
+ me.setPosition(p.left, p.top, animate);
+ }
+ return me;
+ },
+
+
+ getBox : function(local){
+ var pos = this.getPosition(local),
+ size = this.getSize();
+
+ size.x = pos[0];
+ size.y = pos[1];
+ return size;
+ },
+
+
+ updateBox : function(box){
+ this.setSize(box.width, box.height);
+ this.setPagePosition(box.x, box.y);
+ return this;
+ },
+
+
+ getOuterSize: function() {
+ var el = this.el;
+ return {
+ width: el.getWidth() + el.getMargin('lr'),
+ height: el.getHeight() + el.getMargin('tb')
+ };
+ },
+
+
+ adjustPosition: function(x, y) {
+
+
+ if (this.floating && this.floatParent) {
+ var o = this.floatParent.getTargetEl().getViewRegion();
+ x += o.left;
+ y += o.top;
+ }
+
+ return {
+ x: x,
+ y: y
+ };
+ },
+
+
+ getPosition: function(local) {
+ var me = this,
+ el = me.el,
+ xy,
+ o;
+
+
+ if ((local === true) || (me.floating && !me.floatParent)) {
+ return [el.getLeft(true), el.getTop(true)];
+ }
+ xy = me.xy || el.getXY();
+
+
+ if (me.floating) {
+ o = me.floatParent.getTargetEl().getViewRegion();
+ xy[0] -= o.left;
+ xy[1] -= o.top;
+ }
+ return xy;
+ },
+
+ getId: function() {
+ var me = this,
+ xtype;
+
+ if (!me.id) {
+ xtype = me.getXType();
+ xtype = xtype ? xtype.replace(Ext.Component.INVALID_ID_CHARS_Re, '-') : 'ext-comp';
+ me.id = xtype + '-' + me.getAutoId();
+ }
+ return me.id;
+ },
+
+ onEnable: function() {
+ var actionEl = this.getActionEl();
+ actionEl.dom.removeAttribute('aria-disabled');
+ actionEl.dom.disabled = false;
+ this.callParent();
+ },
+
+ onDisable: function() {
+ var actionEl = this.getActionEl();
+ actionEl.dom.setAttribute('aria-disabled', true);
+ actionEl.dom.disabled = true;
+ this.callParent();
+ },
+
+
+ show: function(animateTarget, cb, scope) {
+ var me = this;
+
+ if (me.rendered && me.isVisible()) {
+ if (me.toFrontOnShow && me.floating) {
+ me.toFront();
+ }
+ } else if (me.fireEvent('beforeshow', me) !== false) {
+ me.hidden = false;
+
+
+ if (!me.rendered && (me.autoRender || me.floating)) {
+ me.doAutoRender();
+ }
+ if (me.rendered) {
+ me.beforeShow();
+ me.onShow.apply(me, arguments);
+
+
+
+ if (me.ownerCt && !me.floating && !(me.ownerCt.suspendLayout || me.ownerCt.layout.layoutBusy)) {
+ me.ownerCt.doLayout();
+ }
+ me.afterShow.apply(me, arguments);
+ }
+ }
+ return me;
+ },
+
+ beforeShow: Ext.emptyFn,
+
+
+ onShow: function() {
+ var me = this;
+
+ me.el.show();
+ me.callParent(arguments);
+ if (me.floating && me.constrain) {
+ me.doConstrain();
+ }
+ },
+
+ afterShow: function(animateTarget, cb, scope) {
+ var me = this,
+ fromBox,
+ toBox,
+ ghostPanel;
+
+
+ animateTarget = animateTarget || me.animateTarget;
+
+
+ if (!me.ghost) {
+ animateTarget = null;
+ }
+
+ if (animateTarget) {
+ animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);
+ toBox = me.el.getBox();
+ fromBox = animateTarget.getBox();
+ me.el.addCls(Ext.baseCSSPrefix + 'hide-offsets');
+ ghostPanel = me.ghost();
+ ghostPanel.el.stopAnimation();
+
+
+ ghostPanel.el.setX(-10000);
+
+ ghostPanel.el.animate({
+ from: fromBox,
+ to: toBox,
+ listeners: {
+ afteranimate: function() {
+ delete ghostPanel.componentLayout.lastComponentSize;
+ me.unghost();
+ me.el.removeCls(Ext.baseCSSPrefix + 'hide-offsets');
+ me.onShowComplete(cb, scope);
+ }
+ }
+ });
+ }
+ else {
+ me.onShowComplete(cb, scope);
+ }
+ },
+
+ onShowComplete: function(cb, scope) {
+ var me = this;
+ if (me.floating) {
+ me.toFront();
+ }
+ Ext.callback(cb, scope || me);
+ me.fireEvent('show', me);
+ },
+
+
+ hide: function() {
+ var me = this;
+
+
+
+ me.showOnParentShow = false;
+
+ if (!(me.rendered && !me.isVisible()) && me.fireEvent('beforehide', me) !== false) {
+ me.hidden = true;
+ if (me.rendered) {
+ me.onHide.apply(me, arguments);
+
+
+
+ if (me.ownerCt && !me.floating && !(me.ownerCt.suspendLayout || me.ownerCt.layout.layoutBusy)) {
+ me.ownerCt.doLayout();
+ }
+ }
+ }
+ return me;
+ },
+
+
+ onHide: function(animateTarget, cb, scope) {
+ var me = this,
+ ghostPanel,
+ toBox;
+
+
+ animateTarget = animateTarget || me.animateTarget;
+
+
+ if (!me.ghost) {
+ animateTarget = null;
+ }
+
+ if (animateTarget) {
+ animateTarget = animateTarget.el ? animateTarget.el : Ext.get(animateTarget);
+ ghostPanel = me.ghost();
+ ghostPanel.el.stopAnimation();
+ toBox = animateTarget.getBox();
+ toBox.width += 'px';
+ toBox.height += 'px';
+ ghostPanel.el.animate({
+ to: toBox,
+ listeners: {
+ afteranimate: function() {
+ delete ghostPanel.componentLayout.lastComponentSize;
+ ghostPanel.el.hide();
+ me.afterHide(cb, scope);
+ }
+ }
+ });
+ }
+ me.el.hide();
+ if (!animateTarget) {
+ me.afterHide(cb, scope);
+ }
+ },
+
+ afterHide: function(cb, scope) {
+ Ext.callback(cb, scope || this);
+ this.fireEvent('hide', this);
+ },
+
+
+ onDestroy: function() {
+ var me = this;
+
+
+ if (me.rendered) {
+ Ext.destroy(
+ me.proxy,
+ me.proxyWrap,
+ me.resizer
+ );
+
+ if (me.actionMode == 'container' || me.removeMode == 'container') {
+ me.container.remove();
+ }
+ }
+ delete me.focusTask;
+ me.callParent();
+ },
+
+ deleteMembers: function() {
+ var args = arguments,
+ len = args.length,
+ i = 0;
+ for (; i < len; ++i) {
+ delete this[args[i]];
+ }
+ },
+
+
+ focus: function(selectText, delay) {
+ var me = this,
+ focusEl;
+
+ if (delay) {
+ if (!me.focusTask) {
+ me.focusTask = Ext.create('Ext.util.DelayedTask', me.focus);
+ }
+ me.focusTask.delay(Ext.isNumber(delay) ? delay : 10, null, me, [selectText, false]);
+ return me;
+ }
+
+ if (me.rendered && !me.isDestroyed) {
+
+ focusEl = me.getFocusEl();
+ focusEl.focus();
+ if (focusEl.dom && selectText === true) {
+ focusEl.dom.select();
+ }
+
+
+
+ if (me.floating) {
+ me.toFront(true);
+ }
+ }
+ return me;
+ },
+
+
+ getFocusEl: function() {
+ return this.el;
+ },
+
+
+ blur: function() {
+ if (this.rendered) {
+ this.getFocusEl().blur();
+ }
+ return this;
+ },
+
+ getEl: function() {
+ return this.el;
+ },
+
+
+ getResizeEl: function() {
+ return this.el;
+ },
+
+
+ getPositionEl: function() {
+ return this.el;
+ },
+
+
+ getActionEl: function() {
+ return this.el;
+ },
+
+
+ getVisibilityEl: function() {
+ return this.el;
+ },
+
+
+ onResize: Ext.emptyFn,
+
+
+ getBubbleTarget: function() {
+ return this.ownerCt;
+ },
+
+
+ getContentTarget: function() {
+ return this.el;
+ },
+
+
+ cloneConfig: function(overrides) {
+ overrides = overrides || {};
+ var id = overrides.id || Ext.id(),
+ cfg = Ext.applyIf(overrides, this.initialConfig),
+ self;
+
+ cfg.id = id;
+
+ self = Ext.getClass(this);
+
+
+ return new self(cfg);
+ },
+
+
+ getXType: function() {
+ return this.self.xtype;
+ },
+
+
+ findParentBy: function(fn) {
+ var p;
+
+
+ for (p = this.ownerCt; p && !fn(p, this); p = p.ownerCt);
+ return p || null;
+ },
+
+
+ findParentByType: function(xtype) {
+ return Ext.isFunction(xtype) ?
+ this.findParentBy(function(p) {
+ return p.constructor === xtype;
+ })
+ :
+ this.up(xtype);
+ },
+
+
+ bubble: function(fn, scope, args) {
+ var p = this;
+ while (p) {
+ if (fn.apply(scope || p, args || [p]) === false) {
+ break;
+ }
+ p = p.ownerCt;
+ }
+ return this;
+ },
+
+ getProxy: function() {
+ var me = this,
+ target;
+
+ if (!me.proxy) {
+ target = Ext.getBody();
+ if (Ext.scopeResetCSS) {
+ me.proxyWrap = target = Ext.getBody().createChild({
+ cls: Ext.baseCSSPrefix + 'reset'
+ });
+ }
+ me.proxy = me.el.createProxy(Ext.baseCSSPrefix + 'proxy-el', target, true);
+ }
+ return me.proxy;
+ }
+
+});
+
+
+Ext.define('Ext.layout.container.AbstractContainer', {
+
+
+
+ extend: 'Ext.layout.Layout',
+
+
+
+ type: 'container',
+
+
+ bindToOwnerCtComponent: false,
+
+
+ bindToOwnerCtContainer: false,
+
+
+
+
+ setItemSize: function(item, width, height) {
+ if (Ext.isObject(width)) {
+ height = width.height;
+ width = width.width;
+ }
+ item.setCalculatedSize(width, height, this.owner);
+ },
+
+
+ getLayoutItems: function() {
+ return this.owner && this.owner.items && this.owner.items.items || [];
+ },
+
+
+ beforeLayout: function() {
+ return !this.owner.collapsed && this.callParent(arguments);
+ },
+
+ afterLayout: function() {
+ this.owner.afterLayout(this);
+ },
+
+ getTarget: function() {
+ return this.owner.getTargetEl();
+ },
+
+ getRenderTarget: function() {
+ return this.owner.getTargetEl();
+ }
+});
+
+
+Ext.define('Ext.layout.container.Container', {
+
+
+
+ extend: 'Ext.layout.container.AbstractContainer',
+ alternateClassName: 'Ext.layout.ContainerLayout',
+
+
+
+ layoutItem: function(item, box) {
+ if (box) {
+ item.doComponentLayout(box.width, box.height);
+ } else {
+ item.doComponentLayout();
+ }
+ },
+
+ getLayoutTargetSize : function() {
+ var target = this.getTarget(),
+ ret;
+
+ if (target) {
+ ret = target.getViewSize();
+
+
+
+
+ if (Ext.isIE && ret.width == 0){
+ ret = target.getStyleSize();
+ }
+
+ ret.width -= target.getPadding('lr');
+ ret.height -= target.getPadding('tb');
+ }
+ return ret;
+ },
+
+ beforeLayout: function() {
+ if (this.owner.beforeLayout(arguments) !== false) {
+ return this.callParent(arguments);
+ }
+ else {
+ return false;
+ }
+ },
+
+
+ getRenderedItems: function() {
+ var me = this,
+ target = me.getTarget(),
+ items = me.getLayoutItems(),
+ ln = items.length,
+ renderedItems = [],
+ i, item;
+
+ for (i = 0; i < ln; i++) {
+ item = items[i];
+ if (item.rendered && me.isValidParent(item, target, i)) {
+ renderedItems.push(item);
+ }
+ }
+
+ return renderedItems;
+ },
+
+
+ getVisibleItems: function() {
+ var target = this.getTarget(),
+ items = this.getLayoutItems(),
+ ln = items.length,
+ visibleItems = [],
+ i, item;
+
+ for (i = 0; i < ln; i++) {
+ item = items[i];
+ if (item.rendered && this.isValidParent(item, target, i) && item.hidden !== true) {
+ visibleItems.push(item);
+ }
+ }
+
+ return visibleItems;
+ }
+});
+
+Ext.define('Ext.layout.container.Auto', {
+
+
+
+ alias: ['layout.auto', 'layout.autocontainer'],
+
+ extend: 'Ext.layout.container.Container',
+
+
+
+ type: 'autocontainer',
+
+ bindToOwnerCtComponent: true,
+
+
+ onLayout : function(owner, target) {
+ var me = this,
+ items = me.getLayoutItems(),
+ ln = items.length,
+ i;
+
+
+ if (ln) {
+
+
+
+ if (!me.clearEl) {
+ me.clearEl = me.getRenderTarget().createChild({
+ cls: Ext.baseCSSPrefix + 'clear',
+ role: 'presentation'
+ });
+ }
+
+
+ for (i = 0; i < ln; i++) {
+ me.setItemSize(items[i]);
+ }
+ }
+ },
+
+ configureItem: function(item) {
+ this.callParent(arguments);
+
+
+ item.layoutManagedHeight = 2;
+ item.layoutManagedWidth = 2;
+ }
+});
+
+Ext.define('Ext.container.AbstractContainer', {
+
+
+
+ extend: 'Ext.Component',
+
+ requires: [
+ 'Ext.util.MixedCollection',
+ 'Ext.layout.container.Auto',
+ 'Ext.ZIndexManager'
+ ],
+
+
+
+
+
+
+
+
+
+ suspendLayout : false,
+
+
+ autoDestroy : true,
+
+
+ defaultType: 'panel',
+
+ isContainer : true,
+
+
+ layoutCounter : 0,
+
+ baseCls: Ext.baseCSSPrefix + 'container',
+
+
+ bubbleEvents: ['add', 'remove'],
+
+
+ initComponent : function(){
+ var me = this;
+ me.addEvents(
+
+ 'afterlayout',
+
+ 'beforeadd',
+
+ 'beforeremove',
+
+ 'add',
+
+ 'remove'
+ );
+
+
+ me.layoutOnShow = Ext.create('Ext.util.MixedCollection');
+ me.callParent();
+ me.initItems();
+ },
+
+
+ initItems : function() {
+ var me = this,
+ items = me.items;
+
+
+ me.items = Ext.create('Ext.util.MixedCollection', false, me.getComponentId);
+
+ if (items) {
+ if (!Ext.isArray(items)) {
+ items = [items];
+ }
+
+ me.add(items);
+ }
+ },
+
+
+ afterRender : function() {
+ this.getLayout();
+ this.callParent();
+ },
+
+ renderChildren: function () {
+ var me = this,
+ layout = me.getLayout();
+
+ me.callParent();
+
+
+ if (layout) {
+ me.suspendLayout = true;
+ layout.renderChildren();
+ delete me.suspendLayout;
+ }
+ },
+
+
+ setLayout : function(layout) {
+ var currentLayout = this.layout;
+
+ if (currentLayout && currentLayout.isLayout && currentLayout != layout) {
+ currentLayout.setOwner(null);
+ }
+
+ this.layout = layout;
+ layout.setOwner(this);
+ },
+
+
+ getLayout : function() {
+ var me = this;
+ if (!me.layout || !me.layout.isLayout) {
+ me.setLayout(Ext.layout.Layout.create(me.layout, 'autocontainer'));
+ }
+
+ return me.layout;
+ },
+
+
+ doLayout : function() {
+ var me = this,
+ layout = me.getLayout();
+
+ if (me.rendered && layout && !me.suspendLayout) {
+
+ if (!me.isFixedWidth() || !me.isFixedHeight()) {
+
+ if (me.componentLayout.layoutBusy !== true) {
+ me.doComponentLayout();
+ if (me.componentLayout.layoutCancelled === true) {
+ layout.layout();
+ }
+ }
+ }
+
+ else {
+
+ if (layout.layoutBusy !== true) {
+ layout.layout();
+ }
+ }
+ }
+
+ return me;
+ },
+
+
+ afterLayout : function(layout) {
+ ++this.layoutCounter;
+ this.fireEvent('afterlayout', this, layout);
+ },
+
+
+ prepareItems : function(items, applyDefaults) {
+ if (!Ext.isArray(items)) {
+ items = [items];
+ }
+
+
+ var i = 0,
+ len = items.length,
+ item;
+
+ for (; i < len; i++) {
+ item = items[i];
+ if (applyDefaults) {
+ item = this.applyDefaults(item);
+ }
+ items[i] = this.lookupComponent(item);
+ }
+ return items;
+ },
+
+
+ applyDefaults : function(config) {
+ var defaults = this.defaults;
+
+ if (defaults) {
+ if (Ext.isFunction(defaults)) {
+ defaults = defaults.call(this, config);
+ }
+
+ if (Ext.isString(config)) {
+ config = Ext.ComponentManager.get(config);
+ }
+ Ext.applyIf(config, defaults);
+ }
+
+ return config;
+ },
+
+
+ lookupComponent : function(comp) {
+ return Ext.isString(comp) ? Ext.ComponentManager.get(comp) : this.createComponent(comp);
+ },
+
+
+ createComponent : function(config, defaultType) {
+
+
+
+
+
+
+
+ return Ext.ComponentManager.create(config, defaultType || this.defaultType);
+ },
+
+
+ getComponentId : function(comp) {
+ return comp.getItemId();
+ },
+
+
+ add : function() {
+ var me = this,
+ args = Array.prototype.slice.call(arguments),
+ hasMultipleArgs,
+ items,
+ results = [],
+ i,
+ ln,
+ item,
+ index = -1,
+ cmp;
+
+ if (typeof args[0] == 'number') {
+ index = args.shift();
+ }
+
+ hasMultipleArgs = args.length > 1;
+ if (hasMultipleArgs || Ext.isArray(args[0])) {
+
+ items = hasMultipleArgs ? args : args[0];
+
+ me.suspendLayout = true;
+ for (i = 0, ln = items.length; i < ln; i++) {
+ item = items[i];
+
+
+ if (index != -1) {
+ item = me.add(index + i, item);
+ } else {
+ item = me.add(item);
+ }
+ results.push(item);
+ }
+
+ me.suspendLayout = false;
+ me.doLayout();
+ return results;
+ }
+
+ cmp = me.prepareItems(args[0], true)[0];
+
+
+
+
+ if (cmp.floating) {
+ cmp.onAdded(me, index);
+ } else {
+ index = (index !== -1) ? index : me.items.length;
+ if (me.fireEvent('beforeadd', me, cmp, index) !== false && me.onBeforeAdd(cmp) !== false) {
+ me.items.insert(index, cmp);
+ cmp.onAdded(me, index);
+ me.onAdd(cmp, index);
+ me.fireEvent('add', me, cmp, index);
+ }
+ me.doLayout();
+ }
+ return cmp;
+ },
+
+ onAdd : Ext.emptyFn,
+ onRemove : Ext.emptyFn,
+
+
+ insert : function(index, comp) {
+ return this.add(index, comp);
+ },
+
+
+ move : function(fromIdx, toIdx) {
+ var items = this.items,
+ item;
+ item = items.removeAt(fromIdx);
+ if (item === false) {
+ return false;
+ }
+ items.insert(toIdx, item);
+ this.doLayout();
+ return item;
+ },
+
+
+ onBeforeAdd : function(item) {
+ var me = this;
+
+ if (item.ownerCt) {
+ item.ownerCt.remove(item, false);
+ }
+
+ if (me.border === false || me.border === 0) {
+ item.border = (item.border === true);
+ }
+ },
+
+
+ remove : function(comp, autoDestroy) {
+ var me = this,
+ c = me.getComponent(comp);
+
+ if (c && me.fireEvent('beforeremove', me, c) !== false) {
+ me.doRemove(c, autoDestroy);
+ me.fireEvent('remove', me, c);
+ }
+
+ return c;
+ },
+
+
+ doRemove : function(component, autoDestroy) {
+ var me = this,
+ layout = me.layout,
+ hasLayout = layout && me.rendered;
+
+ me.items.remove(component);
+ component.onRemoved();
+
+ if (hasLayout) {
+ layout.onRemove(component);
+ }
+
+ me.onRemove(component, autoDestroy);
+
+ if (autoDestroy === true || (autoDestroy !== false && me.autoDestroy)) {
+ component.destroy();
+ }
+
+ if (hasLayout && !autoDestroy) {
+ layout.afterRemove(component);
+ }
+
+ if (!me.destroying) {
+ me.doLayout();
+ }
+ },
+
+
+ removeAll : function(autoDestroy) {
+ var me = this,
+ removeItems = me.items.items.slice(),
+ items = [],
+ i = 0,
+ len = removeItems.length,
+ item;
+
+
+ me.suspendLayout = true;
+ for (; i < len; i++) {
+ item = removeItems[i];
+ me.remove(item, autoDestroy);
+
+ if (item.ownerCt !== me) {
+ items.push(item);
+ }
+ }
+
+
+ me.suspendLayout = false;
+ if (len) {
+ me.doLayout();
+ }
+ return items;
+ },
+
+
+
+
+
+
+
+
+
+ getRefItems : function(deep) {
+ var me = this,
+ items = me.items.items,
+ len = items.length,
+ i = 0,
+ item,
+ result = [];
+
+ for (; i < len; i++) {
+ item = items[i];
+ result.push(item);
+ if (deep && item.getRefItems) {
+ result.push.apply(result, item.getRefItems(true));
+ }
+ }
+
+
+
+ if (me.floatingItems && me.floatingItems.accessList) {
+ result.push.apply(result, me.floatingItems.accessList);
+ }
+
+ return result;
+ },
+
+
+ cascade : function(fn, scope, origArgs){
+ var me = this,
+ cs = me.items ? me.items.items : [],
+ len = cs.length,
+ i = 0,
+ c,
+ args = origArgs ? origArgs.concat(me) : [me],
+ componentIndex = args.length - 1;
+
+ if (fn.apply(scope || me, args) !== false) {
+ for(; i < len; i++){
+ c = cs[i];
+ if (c.cascade) {
+ c.cascade(fn, scope, origArgs);
+ } else {
+ args[componentIndex] = c;
+ fn.apply(scope || cs, args);
+ }
+ }
+ }
+ return this;
+ },
+
+
+ getComponent : function(comp) {
+ if (Ext.isObject(comp)) {
+ comp = comp.getItemId();
+ }
+
+ return this.items.get(comp);
+ },
+
+
+ query : function(selector) {
+ selector = selector || '*';
+ return Ext.ComponentQuery.query(selector, this);
+ },
+
+
+ child : function(selector) {
+ selector = selector || '';
+ return this.query('> ' + selector)[0] || null;
+ },
+
+
+ down : function(selector) {
+ return this.query(selector)[0] || null;
+ },
+
+
+ show : function() {
+ this.callParent(arguments);
+ this.performDeferredLayouts();
+ return this;
+ },
+
+
+
+ performDeferredLayouts: function() {
+ var layoutCollection = this.layoutOnShow,
+ ln = layoutCollection.getCount(),
+ i = 0,
+ needsLayout,
+ item;
+
+ for (; i < ln; i++) {
+ item = layoutCollection.get(i);
+ needsLayout = item.needsLayout;
+
+ if (Ext.isObject(needsLayout)) {
+ item.doComponentLayout(needsLayout.width, needsLayout.height, needsLayout.isSetSize, needsLayout.ownerCt);
+ }
+ }
+ layoutCollection.clear();
+ },
+
+ //@private
+
+
+ onEnable: function() {
+ Ext.Array.each(this.query('[isFormField]'), function(item) {
+ if (item.resetDisable) {
+ item.enable();
+ delete item.resetDisable;
+ }
+ });
+ this.callParent();
+ },
+
+
+
+ onDisable: function() {
+ Ext.Array.each(this.query('[isFormField]'), function(item) {
+ if (item.resetDisable !== false && !item.disabled) {
+ item.disable();
+ item.resetDisable = true;
+ }
+ });
+ this.callParent();
+ },
+
+
+ beforeLayout: function() {
+ return true;
+ },
+
+
+ beforeDestroy : function() {
+ var me = this,
+ items = me.items,
+ c;
+
+ if (items) {
+ while ((c = items.first())) {
+ me.doRemove(c, true);
+ }
+ }
+
+ Ext.destroy(
+ me.layout
+ );
+ me.callParent();
+ }
+});
+
+
+Ext.define('Ext.container.Container', {
+ extend: 'Ext.container.AbstractContainer',
+ alias: 'widget.container',
+ alternateClassName: 'Ext.Container',
+
+
+ getChildByElement: function(el) {
+ var item,
+ itemEl,
+ i = 0,
+ it = this.items.items,
+ ln = it.length;
+
+ el = Ext.getDom(el);
+ for (; i < ln; i++) {
+ item = it[i];
+ itemEl = item.getEl();
+ if ((itemEl.dom === el) || itemEl.contains(el)) {
+ return item;
+ }
+ }
+ return null;
+ }
+});
+
+
+Ext.define('Ext.toolbar.Fill', {
+ extend: 'Ext.Component',
+ alias: 'widget.tbfill',
+ alternateClassName: 'Ext.Toolbar.Fill',
+ isFill : true,
+ flex: 1
+});
+
+Ext.define('Ext.toolbar.Item', {
+ extend: 'Ext.Component',
+ alias: 'widget.tbitem',
+ alternateClassName: 'Ext.Toolbar.Item',
+ enable:Ext.emptyFn,
+ disable:Ext.emptyFn,
+ focus:Ext.emptyFn
+
+});
+
+Ext.define('Ext.toolbar.Separator', {
+ extend: 'Ext.toolbar.Item',
+ alias: 'widget.tbseparator',
+ alternateClassName: 'Ext.Toolbar.Separator',
+ baseCls: Ext.baseCSSPrefix + 'toolbar-separator',
+ focusable: false
+});
+
+Ext.define('Ext.menu.Manager', {
+ singleton: true,
+ requires: [
+ 'Ext.util.MixedCollection',
+ 'Ext.util.KeyMap'
+ ],
+ alternateClassName: 'Ext.menu.MenuMgr',
+
+ uses: ['Ext.menu.Menu'],
+
+ menus: {},
+ groups: {},
+ attached: false,
+ lastShow: new Date(),
+
+ init: function() {
+ var me = this;
+
+ me.active = Ext.create('Ext.util.MixedCollection');
+ Ext.getDoc().addKeyListener(27, function() {
+ if (me.active.length > 0) {
+ me.hideAll();
+ }
+ }, me);
+ },
+
+
+ hideAll: function() {
+ var active = this.active,
+ c;
+ if (active && active.length > 0) {
+ c = active.clone();
+ c.each(function(m) {
+ m.hide();
+ });
+ return true;
+ }
+ return false;
+ },
+
+ onHide: function(m) {
+ var me = this,
+ active = me.active;
+ active.remove(m);
+ if (active.length < 1) {
+ Ext.getDoc().un('mousedown', me.onMouseDown, me);
+ me.attached = false;
+ }
+ },
+
+ onShow: function(m) {
+ var me = this,
+ active = me.active,
+ last = active.last(),
+ attached = me.attached,
+ menuEl = m.getEl(),
+ zIndex;
+
+ me.lastShow = new Date();
+ active.add(m);
+ if (!attached) {
+ Ext.getDoc().on('mousedown', me.onMouseDown, me);
+ me.attached = true;
+ }
+ m.toFront();
+ },
+
+ onBeforeHide: function(m) {
+ if (m.activeChild) {
+ m.activeChild.hide();
+ }
+ if (m.autoHideTimer) {
+ clearTimeout(m.autoHideTimer);
+ delete m.autoHideTimer;
+ }
+ },
+
+ onBeforeShow: function(m) {
+ var active = this.active,
+ parentMenu = m.parentMenu;
+
+ active.remove(m);
+ if (!parentMenu && !m.allowOtherMenus) {
+ this.hideAll();
+ }
+ else if (parentMenu && parentMenu.activeChild && m != parentMenu.activeChild) {
+ parentMenu.activeChild.hide();
+ }
+ },
+
+
+ onMouseDown: function(e) {
+ var me = this,
+ active = me.active,
+ lastShow = me.lastShow,
+ target = e.target;
+
+ if (Ext.Date.getElapsed(lastShow) > 50 && active.length > 0 && !e.getTarget('.' + Ext.baseCSSPrefix + 'menu')) {
+ me.hideAll();
+
+
+ if (Ext.isIE && Ext.fly(target).focusable()) {
+ target.focus();
+ }
+ }
+ },
+
+
+ register: function(menu) {
+ var me = this;
+
+ if (!me.active) {
+ me.init();
+ }
+
+ if (menu.floating) {
+ me.menus[menu.id] = menu;
+ menu.on({
+ beforehide: me.onBeforeHide,
+ hide: me.onHide,
+ beforeshow: me.onBeforeShow,
+ show: me.onShow,
+ scope: me
+ });
+ }
+ },
+
+
+ get: function(menu) {
+ var menus = this.menus;
+
+ if (typeof menu == 'string') {
+ if (!menus) {
+ return null;
+ }
+ return menus[menu];
+ } else if (menu.isMenu) {
+ return menu;
+ } else if (Ext.isArray(menu)) {
+ return Ext.create('Ext.menu.Menu', {items:menu});
+ } else {
+ return Ext.ComponentManager.create(menu, 'menu');
+ }
+ },
+
+
+ unregister: function(menu) {
+ var me = this,
+ menus = me.menus,
+ active = me.active;
+
+ delete menus[menu.id];
+ active.remove(menu);
+ menu.un({
+ beforehide: me.onBeforeHide,
+ hide: me.onHide,
+ beforeshow: me.onBeforeShow,
+ show: me.onShow,
+ scope: me
+ });
+ },
+
+
+ registerCheckable: function(menuItem) {
+ var groups = this.groups,
+ groupId = menuItem.group;
+
+ if (groupId) {
+ if (!groups[groupId]) {
+ groups[groupId] = [];
+ }
+
+ groups[groupId].push(menuItem);
+ }
+ },
+
+
+ unregisterCheckable: function(menuItem) {
+ var groups = this.groups,
+ groupId = menuItem.group;
+
+ if (groupId) {
+ Ext.Array.remove(groups[groupId], menuItem);
+ }
+ },
+
+ onCheckChange: function(menuItem, state) {
+ var groups = this.groups,
+ groupId = menuItem.group,
+ i = 0,
+ group, ln, curr;
+
+ if (groupId && state) {
+ group = groups[groupId];
+ ln = group.length;
+ for (; i < ln; i++) {
+ curr = group[i];
+ if (curr != menuItem) {
+ curr.setChecked(false);
+ }
+ }
+ }
+ }
+});
+
+Ext.define('Ext.layout.component.Button', {
+
+
+
+ alias: ['layout.button'],
+
+ extend: 'Ext.layout.component.Component',
+
+
+
+ type: 'button',
+
+ cellClsRE: /-btn-(tl|br)\b/,
+ htmlRE: /<.*>/,
+
+ beforeLayout: function() {
+ return this.callParent(arguments) || this.lastText !== this.owner.text;
+ },
+
+
+ onLayout: function(width, height) {
+ var me = this,
+ isNum = Ext.isNumber,
+ owner = me.owner,
+ ownerEl = owner.el,
+ btnEl = owner.btnEl,
+ btnInnerEl = owner.btnInnerEl,
+ btnIconEl = owner.btnIconEl,
+ sizeIconEl = (owner.icon || owner.iconCls) && (owner.iconAlign == "top" || owner.iconAlign == "bottom"),
+ minWidth = owner.minWidth,
+ maxWidth = owner.maxWidth,
+ ownerWidth, btnFrameWidth, metrics;
+
+ me.getTargetInfo();
+ me.callParent(arguments);
+
+ btnInnerEl.unclip();
+ me.setTargetSize(width, height);
+
+ if (!isNum(width)) {
+
+
+
+ if (owner.text && (Ext.isIE6 || Ext.isIE7) && Ext.isStrict && btnEl && btnEl.getWidth() > 20) {
+ btnFrameWidth = me.btnFrameWidth;
+ metrics = Ext.util.TextMetrics.measure(btnInnerEl, owner.text);
+ ownerEl.setWidth(metrics.width + btnFrameWidth + me.adjWidth);
+ btnEl.setWidth(metrics.width + btnFrameWidth);
+ btnInnerEl.setWidth(metrics.width + btnFrameWidth);
+
+ if (sizeIconEl) {
+ btnIconEl.setWidth(metrics.width + btnFrameWidth);
+ }
+ } else {
+
+ ownerEl.setWidth(null);
+ btnEl.setWidth(null);
+ btnInnerEl.setWidth(null);
+ btnIconEl.setWidth(null);
+ }
+
+
+ if (minWidth || maxWidth) {
+ ownerWidth = ownerEl.getWidth();
+ if (minWidth && (ownerWidth < minWidth)) {
+ me.setTargetSize(minWidth, height);
+ }
+ else if (maxWidth && (ownerWidth > maxWidth)) {
+ btnInnerEl.clip();
+ me.setTargetSize(maxWidth, height);
+ }
+ }
+ }
+
+ this.lastText = owner.text;
+ },
+
+ setTargetSize: function(width, height) {
+ var me = this,
+ owner = me.owner,
+ isNum = Ext.isNumber,
+ btnInnerEl = owner.btnInnerEl,
+ btnWidth = (isNum(width) ? width - me.adjWidth : width),
+ btnHeight = (isNum(height) ? height - me.adjHeight : height),
+ btnFrameHeight = me.btnFrameHeight,
+ text = owner.getText(),
+ textHeight;
+
+ me.callParent(arguments);
+ me.setElementSize(owner.btnEl, btnWidth, btnHeight);
+ me.setElementSize(btnInnerEl, btnWidth, btnHeight);
+ if (btnHeight >= 0) {
+ btnInnerEl.setStyle('line-height', btnHeight - btnFrameHeight + 'px');
+ }
+
+
+
+
+
+
+ if (text && this.htmlRE.test(text)) {
+ btnInnerEl.setStyle('line-height', 'normal');
+ textHeight = Ext.util.TextMetrics.measure(btnInnerEl, text).height;
+ btnInnerEl.setStyle('padding-top', me.btnFrameTop + Math.max(btnInnerEl.getHeight() - btnFrameHeight - textHeight, 0) / 2 + 'px');
+ me.setElementSize(btnInnerEl, btnWidth, btnHeight);
+ }
+ },
+
+ getTargetInfo: function() {
+ var me = this,
+ owner = me.owner,
+ ownerEl = owner.el,
+ frameSize = me.frameSize,
+ frameBody = owner.frameBody,
+ btnWrap = owner.btnWrap,
+ innerEl = owner.btnInnerEl;
+
+ if (!('adjWidth' in me)) {
+ Ext.apply(me, {
+
+ adjWidth: frameSize.left + frameSize.right + ownerEl.getBorderWidth('lr') + ownerEl.getPadding('lr') +
+ btnWrap.getPadding('lr') + (frameBody ? frameBody.getFrameWidth('lr') : 0),
+ adjHeight: frameSize.top + frameSize.bottom + ownerEl.getBorderWidth('tb') + ownerEl.getPadding('tb') +
+ btnWrap.getPadding('tb') + (frameBody ? frameBody.getFrameWidth('tb') : 0),
+ btnFrameWidth: innerEl.getFrameWidth('lr'),
+ btnFrameHeight: innerEl.getFrameWidth('tb'),
+ btnFrameTop: innerEl.getFrameWidth('t')
+ });
+ }
+
+ return me.callParent();
+ }
+});
+
+Ext.define('Ext.button.Button', {
+
+
+ alias: 'widget.button',
+ extend: 'Ext.Component',
+
+ requires: [
+ 'Ext.menu.Manager',
+ 'Ext.util.ClickRepeater',
+ 'Ext.layout.component.Button',
+ 'Ext.util.TextMetrics',
+ 'Ext.util.KeyMap'
+ ],
+
+ alternateClassName: 'Ext.Button',
+
+
+ isButton: true,
+ componentLayout: 'button',
+
+
+ hidden: false,
+
+
+ disabled: false,
+
+
+ pressed: false,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ enableToggle: false,
+
+
+
+
+
+
+ menuAlign: 'tl-bl?',
+
+
+ textAlign: 'center',
+
+
+
+
+
+
+ type: 'button',
+
+
+ clickEvent: 'click',
+
+
+ preventDefault: true,
+
+
+ handleMouseEvents: true,
+
+
+ tooltipType: 'qtip',
+
+
+ baseCls: Ext.baseCSSPrefix + 'btn',
+
+
+ pressedCls: 'pressed',
+
+
+ overCls: 'over',
+
+
+ focusCls: 'focus',
+
+
+ menuActiveCls: 'menu-active',
+
+
+
+
+
+
+
+ ariaRole: 'button',
+
+
+ renderTpl:
+ '<em id="{id}-btnWrap" class="{splitCls}">' +
+ '<tpl if="href">' +
+ '<a id="{id}-btnEl" href="{href}" target="{target}"<tpl if="tabIndex"> tabIndex="{tabIndex}"</tpl> role="link">' +
+ '<span id="{id}-btnInnerEl" class="{baseCls}-inner">' +
+ '{text}' +
+ '</span>' +
+ '<span id="{id}-btnIconEl" class="{baseCls}-icon"></span>' +
+ '</a>' +
+ '</tpl>' +
+ '<tpl if="!href">' +
+ '<button id="{id}-btnEl" type="{type}" hidefocus="true"' +
+
+
+ '<tpl if="tabIndex"> tabIndex="{tabIndex}"</tpl> role="button" autocomplete="off">' +
+ '<span id="{id}-btnInnerEl" class="{baseCls}-inner" style="{innerSpanStyle}">' +
+ '{text}' +
+ '</span>' +
+ '<span id="{id}-btnIconEl" class="{baseCls}-icon {iconCls}"> </span>' +
+ '</button>' +
+ '</tpl>' +
+ '</em>' ,
+
+
+ scale: 'small',
+
+
+ allowedScales: ['small', 'medium', 'large'],
+
+
+
+
+ iconAlign: 'left',
+
+
+ arrowAlign: 'right',
+
+
+ arrowCls: 'arrow',
+
+
+
+
+
+
+
+
+
+ maskOnDisable: false,
+
+
+ initComponent: function() {
+ var me = this;
+ me.callParent(arguments);
+
+ me.addEvents(
+
+ 'click',
+
+
+ 'toggle',
+
+
+ 'mouseover',
+
+
+ 'mouseout',
+
+
+ 'menushow',
+
+
+ 'menuhide',
+
+
+ 'menutriggerover',
+
+
+ 'menutriggerout'
+ );
+
+ if (me.menu) {
+
+ me.split = true;
+
+
+ me.menu = Ext.menu.Manager.get(me.menu);
+ me.menu.ownerCt = me;
+ }
+
+
+ if (me.url) {
+ me.href = me.url;
+ }
+
+
+ if (me.href && !me.hasOwnProperty('preventDefault')) {
+ me.preventDefault = false;
+ }
+
+ if (Ext.isString(me.toggleGroup)) {
+ me.enableToggle = true;
+ }
+
+ },
+
+
+ initAria: function() {
+ this.callParent();
+ var actionEl = this.getActionEl();
+ if (this.menu) {
+ actionEl.dom.setAttribute('aria-haspopup', true);
+ }
+ },
+
+
+ getActionEl: function() {
+ return this.btnEl;
+ },
+
+
+ getFocusEl: function() {
+ return this.btnEl;
+ },
+
+
+ setButtonCls: function() {
+ var me = this,
+ cls = [],
+ btnIconEl = me.btnIconEl,
+ hide = 'x-hide-display';
+
+ if (me.useSetClass) {
+ if (!Ext.isEmpty(me.oldCls)) {
+ me.removeClsWithUI(me.oldCls);
+ me.removeClsWithUI(me.pressedCls);
+ }
+
+
+ if (me.iconCls || me.icon) {
+ if (me.text) {
+ cls.push('icon-text-' + me.iconAlign);
+ } else {
+ cls.push('icon');
+ }
+ if (btnIconEl) {
+ btnIconEl.removeCls(hide);
+ }
+ } else {
+ if (me.text) {
+ cls.push('noicon');
+ }
+ if (btnIconEl) {
+ btnIconEl.addCls(hide);
+ }
+ }
+
+ me.oldCls = cls;
+ me.addClsWithUI(cls);
+ me.addClsWithUI(me.pressed ? me.pressedCls : null);
+ }
+ },
+
+
+ onRender: function(ct, position) {
+
+ var me = this,
+ repeater, btn;
+
+
+ Ext.applyIf(me.renderData, me.getTemplateArgs());
+
+ me.addChildEls('btnEl', 'btnWrap', 'btnInnerEl', 'btnIconEl');
+
+ if (me.scale) {
+ me.ui = me.ui + '-' + me.scale;
+ }
+
+
+ me.callParent(arguments);
+
+
+ if (me.split && me.arrowTooltip) {
+ me.arrowEl.dom.setAttribute(me.getTipAttr(), me.arrowTooltip);
+ }
+
+
+ me.mon(me.btnEl, {
+ scope: me,
+ focus: me.onFocus,
+ blur : me.onBlur
+ });
+
+
+ btn = me.el;
+
+ if (me.icon) {
+ me.setIcon(me.icon);
+ }
+
+ if (me.iconCls) {
+ me.setIconCls(me.iconCls);
+ }
+
+ if (me.tooltip) {
+ me.setTooltip(me.tooltip, true);
+ }
+
+ if (me.textAlign) {
+ me.setTextAlign(me.textAlign);
+ }
+
+
+ if (me.handleMouseEvents) {
+ me.mon(btn, {
+ scope: me,
+ mouseover: me.onMouseOver,
+ mouseout: me.onMouseOut,
+ mousedown: me.onMouseDown
+ });
+
+ if (me.split) {
+ me.mon(btn, {
+ mousemove: me.onMouseMove,
+ scope: me
+ });
+ }
+ }
+
+
+ if (me.menu) {
+ me.mon(me.menu, {
+ scope: me,
+ show: me.onMenuShow,
+ hide: me.onMenuHide
+ });
+
+ me.keyMap = Ext.create('Ext.util.KeyMap', me.el, {
+ key: Ext.EventObject.DOWN,
+ handler: me.onDownKey,
+ scope: me
+ });
+ }
+
+
+ if (me.repeat) {
+ repeater = Ext.create('Ext.util.ClickRepeater', btn, Ext.isObject(me.repeat) ? me.repeat: {});
+ me.mon(repeater, 'click', me.onRepeatClick, me);
+ } else {
+ me.mon(btn, me.clickEvent, me.onClick, me);
+ }
+
+
+ Ext.ButtonToggleManager.register(me);
+ },
+
+
+ getTemplateArgs: function() {
+ var me = this,
+ persistentPadding = me.getPersistentBtnPadding(),
+ innerSpanStyle = '';
+
+
+ if (Math.max.apply(Math, persistentPadding) > 0) {
+ innerSpanStyle = 'margin:' + Ext.Array.map(persistentPadding, function(pad) {
+ return -pad + 'px';
+ }).join(' ');
+ }
+
+ return {
+ href : me.getHref(),
+ target : me.target || '_blank',
+ type : me.type,
+ splitCls : me.getSplitCls(),
+ cls : me.cls,
+ iconCls : me.iconCls || '',
+ text : me.text || ' ',
+ tabIndex : me.tabIndex,
+ innerSpanStyle: innerSpanStyle
+ };
+ },
+
+
+ getHref: function() {
+ var me = this,
+ params = Ext.apply({}, me.baseParams);
+
+
+ params = Ext.apply(params, me.params);
+ return me.href ? Ext.urlAppend(me.href, Ext.Object.toQueryString(params)) : false;
+ },
+
+
+ setParams: function(params) {
+ this.params = params;
+ this.btnEl.dom.href = this.getHref();
+ },
+
+ getSplitCls: function() {
+ var me = this;
+ return me.split ? (me.baseCls + '-' + me.arrowCls) + ' ' + (me.baseCls + '-' + me.arrowCls + '-' + me.arrowAlign) : '';
+ },
+
+
+ afterRender: function() {
+ var me = this;
+ me.useSetClass = true;
+ me.setButtonCls();
+ me.doc = Ext.getDoc();
+ this.callParent(arguments);
+ },
+
+
+ setIconCls: function(cls) {
+ var me = this,
+ btnIconEl = me.btnIconEl,
+ oldCls = me.iconCls;
+
+ me.iconCls = cls;
+ if (btnIconEl) {
+
+ btnIconEl.removeCls(oldCls);
+ btnIconEl.addCls(cls || '');
+ me.setButtonCls();
+ }
+ return me;
+ },
+
+
+ setTooltip: function(tooltip, initial) {
+ var me = this;
+
+ if (me.rendered) {
+ if (!initial) {
+ me.clearTip();
+ }
+ if (Ext.isObject(tooltip)) {
+ Ext.tip.QuickTipManager.register(Ext.apply({
+ target: me.btnEl.id
+ },
+ tooltip));
+ me.tooltip = tooltip;
+ } else {
+ me.btnEl.dom.setAttribute(me.getTipAttr(), tooltip);
+ }
+ } else {
+ me.tooltip = tooltip;
+ }
+ return me;
+ },
+
+
+ setTextAlign: function(align) {
+ var me = this,
+ btnEl = me.btnEl;
+
+ if (btnEl) {
+ btnEl.removeCls(me.baseCls + '-' + me.textAlign);
+ btnEl.addCls(me.baseCls + '-' + align);
+ }
+ me.textAlign = align;
+ return me;
+ },
+
+ getTipAttr: function(){
+ return this.tooltipType == 'qtip' ? 'data-qtip' : 'title';
+ },
+
+
+ getRefItems: function(deep){
+ var menu = this.menu,
+ items;
+
+ if (menu) {
+ items = menu.getRefItems(deep);
+ items.unshift(menu);
+ }
+ return items || [];
+ },
+
+
+ clearTip: function() {
+ if (Ext.isObject(this.tooltip)) {
+ Ext.tip.QuickTipManager.unregister(this.btnEl);
+ }
+ },
+
+
+ beforeDestroy: function() {
+ var me = this;
+ if (me.rendered) {
+ me.clearTip();
+ }
+ if (me.menu && me.destroyMenu !== false) {
+ Ext.destroy(me.menu);
+ }
+ Ext.destroy(me.btnInnerEl, me.repeater);
+ me.callParent();
+ },
+
+
+ onDestroy: function() {
+ var me = this;
+ if (me.rendered) {
+ me.doc.un('mouseover', me.monitorMouseOver, me);
+ me.doc.un('mouseup', me.onMouseUp, me);
+ delete me.doc;
+ Ext.ButtonToggleManager.unregister(me);
+
+ Ext.destroy(me.keyMap);
+ delete me.keyMap;
+ }
+ me.callParent();
+ },
+
+
+ setHandler: function(handler, scope) {
+ this.handler = handler;
+ this.scope = scope;
+ return this;
+ },
+
+
+ setText: function(text) {
+ var me = this;
+ me.text = text;
+ if (me.el) {
+ me.btnInnerEl.update(text || ' ');
+ me.setButtonCls();
+ }
+ me.doComponentLayout();
+ return me;
+ },
+
+
+ setIcon: function(icon) {
+ var me = this,
+ iconEl = me.btnIconEl;
+
+ me.icon = icon;
+ if (iconEl) {
+ iconEl.setStyle('background-image', icon ? 'url(' + icon + ')': '');
+ me.setButtonCls();
+ }
+ return me;
+ },
+
+
+ getText: function() {
+ return this.text;
+ },
+
+
+ toggle: function(state, suppressEvent) {
+ var me = this;
+ state = state === undefined ? !me.pressed : !!state;
+ if (state !== me.pressed) {
+ if (me.rendered) {
+ me[state ? 'addClsWithUI': 'removeClsWithUI'](me.pressedCls);
+ }
+ me.btnEl.dom.setAttribute('aria-pressed', state);
+ me.pressed = state;
+ if (!suppressEvent) {
+ me.fireEvent('toggle', me, state);
+ Ext.callback(me.toggleHandler, me.scope || me, [me, state]);
+ }
+ }
+ return me;
+ },
+
+ maybeShowMenu: function(){
+ var me = this;
+ if (me.menu && !me.hasVisibleMenu() && !me.ignoreNextClick) {
+ me.showMenu();
+ }
+ },
+
+
+ showMenu: function() {
+ var me = this;
+ if (me.rendered && me.menu) {
+ if (me.tooltip && me.getTipAttr() != 'title') {
+ Ext.tip.QuickTipManager.getQuickTip().cancelShow(me.btnEl);
+ }
+ if (me.menu.isVisible()) {
+ me.menu.hide();
+ }
+
+ me.menu.showBy(me.el, me.menuAlign);
+ }
+ return me;
+ },
+
+
+ hideMenu: function() {
+ if (this.hasVisibleMenu()) {
+ this.menu.hide();
+ }
+ return this;
+ },
+
+
+ hasVisibleMenu: function() {
+ var menu = this.menu;
+ return menu && menu.rendered && menu.isVisible();
+ },
+
+
+ onRepeatClick: function(repeat, e) {
+ this.onClick(e);
+ },
+
+
+ onClick: function(e) {
+ var me = this;
+ if (me.preventDefault || (me.disabled && me.getHref()) && e) {
+ e.preventDefault();
+ }
+ if (e.button !== 0) {
+ return;
+ }
+ if (!me.disabled) {
+ me.doToggle();
+ me.maybeShowMenu();
+ me.fireHandler(e);
+ }
+ },
+
+ fireHandler: function(e){
+ var me = this,
+ handler = me.handler;
+
+ me.fireEvent('click', me, e);
+ if (handler) {
+ handler.call(me.scope || me, me, e);
+ }
+ me.onBlur();
+ },
+
+ doToggle: function(){
+ var me = this;
+ if (me.enableToggle && (me.allowDepress !== false || !me.pressed)) {
+ me.toggle();
+ }
+ },
+
+
+ onMouseOver: function(e) {
+ var me = this;
+ if (!me.disabled && !e.within(me.el, true, true)) {
+ me.onMouseEnter(e);
+ }
+ },
+
+
+ onMouseOut: function(e) {
+ var me = this;
+ if (!e.within(me.el, true, true)) {
+ if (me.overMenuTrigger) {
+ me.onMenuTriggerOut(e);
+ }
+ me.onMouseLeave(e);
+ }
+ },
+
+
+ onMouseMove: function(e) {
+ var me = this,
+ el = me.el,
+ over = me.overMenuTrigger,
+ overlap, btnSize;
+
+ if (me.split) {
+ if (me.arrowAlign === 'right') {
+ overlap = e.getX() - el.getX();
+ btnSize = el.getWidth();
+ } else {
+ overlap = e.getY() - el.getY();
+ btnSize = el.getHeight();
+ }
+
+ if (overlap > (btnSize - me.getTriggerSize())) {
+ if (!over) {
+ me.onMenuTriggerOver(e);
+ }
+ } else {
+ if (over) {
+ me.onMenuTriggerOut(e);
+ }
+ }
+ }
+ },
+
+
+ getTriggerSize: function() {
+ var me = this,
+ size = me.triggerSize,
+ side, sideFirstLetter, undef;
+
+ if (size === undef) {
+ side = me.arrowAlign;
+ sideFirstLetter = side.charAt(0);
+ size = me.triggerSize = me.el.getFrameWidth(sideFirstLetter) + me.btnWrap.getFrameWidth(sideFirstLetter) + (me.frameSize && me.frameSize[side] || 0);
+ }
+ return size;
+ },
+
+
+ onMouseEnter: function(e) {
+ var me = this;
+ me.addClsWithUI(me.overCls);
+ me.fireEvent('mouseover', me, e);
+ },
+
+
+ onMouseLeave: function(e) {
+ var me = this;
+ me.removeClsWithUI(me.overCls);
+ me.fireEvent('mouseout', me, e);
+ },
+
+
+ onMenuTriggerOver: function(e) {
+ var me = this;
+ me.overMenuTrigger = true;
+ me.fireEvent('menutriggerover', me, me.menu, e);
+ },
+
+
+ onMenuTriggerOut: function(e) {
+ var me = this;
+ delete me.overMenuTrigger;
+ me.fireEvent('menutriggerout', me, me.menu, e);
+ },
+
+
+ enable : function(silent) {
+ var me = this;
+
+ me.callParent(arguments);
+
+ me.removeClsWithUI('disabled');
+
+ return me;
+ },
+
+
+ disable : function(silent) {
+ var me = this;
+
+ me.callParent(arguments);
+
+ me.addClsWithUI('disabled');
+ me.removeClsWithUI(me.overCls);
+
+ return me;
+ },
+
+
+ setScale: function(scale) {
+ var me = this,
+ ui = me.ui.replace('-' + me.scale, '');
+
+
+ if (!Ext.Array.contains(me.allowedScales, scale)) {
+ throw('#setScale: scale must be an allowed scale (' + me.allowedScales.join(', ') + ')');
+ }
+
+ me.scale = scale;
+ me.setUI(ui);
+ },
+
+
+ setUI: function(ui) {
+ var me = this;
+
+
+ if (me.scale && !ui.match(me.scale)) {
+ ui = ui + '-' + me.scale;
+ }
+
+ me.callParent([ui]);
+
+
+
+ },
+
+
+ onFocus: function(e) {
+ var me = this;
+ if (!me.disabled) {
+ me.addClsWithUI(me.focusCls);
+ }
+ },
+
+
+ onBlur: function(e) {
+ var me = this;
+ me.removeClsWithUI(me.focusCls);
+ },
+
+
+ onMouseDown: function(e) {
+ var me = this;
+ if (!me.disabled && e.button === 0) {
+ me.addClsWithUI(me.pressedCls);
+ me.doc.on('mouseup', me.onMouseUp, me);
+ }
+ },
+
+ onMouseUp: function(e) {
+ var me = this;
+ if (e.button === 0) {
+ if (!me.pressed) {
+ me.removeClsWithUI(me.pressedCls);
+ }
+ me.doc.un('mouseup', me.onMouseUp, me);
+ }
+ },
+
+ onMenuShow: function(e) {
+ var me = this;
+ me.ignoreNextClick = 0;
+ me.addClsWithUI(me.menuActiveCls);
+ me.fireEvent('menushow', me, me.menu);
+ },
+
+
+ onMenuHide: function(e) {
+ var me = this;
+ me.removeClsWithUI(me.menuActiveCls);
+ me.ignoreNextClick = Ext.defer(me.restoreClick, 250, me);
+ me.fireEvent('menuhide', me, me.menu);
+ },
+
+
+ restoreClick: function() {
+ this.ignoreNextClick = 0;
+ },
+
+
+ onDownKey: function() {
+ var me = this;
+
+ if (!me.disabled) {
+ if (me.menu) {
+ me.showMenu();
+ }
+ }
+ },
+
+
+ getPersistentBtnPadding: function() {
+ var cls = Ext.button.Button,
+ padding = cls.persistentPadding,
+ btn, leftTop, btnEl, btnInnerEl;
+
+ if (!padding) {
+ padding = cls.persistentPadding = [0, 0, 0, 0];
+
+ if (!Ext.isIE) {
+
+ btn = Ext.create('Ext.button.Button', {
+ renderTo: Ext.getBody(),
+ text: 'test',
+ style: 'position:absolute;top:-999px;'
+ });
+ btnEl = btn.btnEl;
+ btnInnerEl = btn.btnInnerEl;
+ btnEl.setSize(null, null);
+
+ leftTop = btnInnerEl.getOffsetsTo(btnEl);
+ padding[0] = leftTop[1];
+ padding[1] = btnEl.getWidth() - btnInnerEl.getWidth() - leftTop[0];
+ padding[2] = btnEl.getHeight() - btnInnerEl.getHeight() - leftTop[1];
+ padding[3] = leftTop[0];
+
+ btn.destroy();
+ }
+ }
+
+ return padding;
+ }
+
+}, function() {
+ var groups = {};
+
+ function toggleGroup(btn, state) {
+ var g, i, l;
+ if (state) {
+ g = groups[btn.toggleGroup];
+ for (i = 0, l = g.length; i < l; i++) {
+ if (g[i] !== btn) {
+ g[i].toggle(false);
+ }
+ }
+ }
+ }
+
+
+ Ext.ButtonToggleManager = {
+ register: function(btn) {
+ if (!btn.toggleGroup) {
+ return;
+ }
+ var group = groups[btn.toggleGroup];
+ if (!group) {
+ group = groups[btn.toggleGroup] = [];
+ }
+ group.push(btn);
+ btn.on('toggle', toggleGroup);
+ },
+
+ unregister: function(btn) {
+ if (!btn.toggleGroup) {
+ return;
+ }
+ var group = groups[btn.toggleGroup];
+ if (group) {
+ Ext.Array.remove(group, btn);
+ btn.un('toggle', toggleGroup);
+ }
+ },
+
+
+ getPressed: function(group) {
+ var g = groups[group],
+ i = 0,
+ len;
+ if (g) {
+ for (len = g.length; i < len; i++) {
+ if (g[i].pressed === true) {
+ return g[i];
+ }
+ }
+ }
+ return null;
+ }
+ };
+});
+
+
+Ext.define('Ext.layout.container.boxOverflow.Menu', {
+
+
+
+ extend: 'Ext.layout.container.boxOverflow.None',
+ requires: ['Ext.toolbar.Separator', 'Ext.button.Button'],
+ alternateClassName: 'Ext.layout.boxOverflow.Menu',
+
+
+
+
+
+
+ noItemsMenuText : '<div class="' + Ext.baseCSSPrefix + 'toolbar-no-items">(None)</div>',
+
+ constructor: function(layout) {
+ var me = this;
+
+ me.callParent(arguments);
+
+
+ layout.beforeLayout = Ext.Function.createInterceptor(layout.beforeLayout, this.clearOverflow, this);
+
+ me.afterCtCls = me.afterCtCls || Ext.baseCSSPrefix + 'box-menu-' + layout.parallelAfter;
+
+ me.menuItems = [];
+ },
+
+ onRemove: function(comp){
+ Ext.Array.remove(this.menuItems, comp);
+ },
+
+ handleOverflow: function(calculations, targetSize) {
+ var me = this,
+ layout = me.layout,
+ methodName = 'get' + layout.parallelPrefixCap,
+ newSize = {},
+ posArgs = [null, null];
+
+ me.callParent(arguments);
+ this.createMenu(calculations, targetSize);
+ newSize[layout.perpendicularPrefix] = targetSize[layout.perpendicularPrefix];
+ newSize[layout.parallelPrefix] = targetSize[layout.parallelPrefix] - me.afterCt[methodName]();
+
+
+
+ posArgs[layout.perpendicularSizeIndex] = (calculations.meta.maxSize - me.menuTrigger['get' + layout.perpendicularPrefixCap]()) / 2;
+ me.menuTrigger.setPosition.apply(me.menuTrigger, posArgs);
+
+ return { targetSize: newSize };
+ },
+
+
+ clearOverflow: function(calculations, targetSize) {
+ var me = this,
+ newWidth = targetSize ? targetSize.width + (me.afterCt ? me.afterCt.getWidth() : 0) : 0,
+ items = me.menuItems,
+ i = 0,
+ length = items.length,
+ item;
+
+ me.hideTrigger();
+ for (; i < length; i++) {
+ items[i].show();
+ }
+ items.length = 0;
+
+ return targetSize ? {
+ targetSize: {
+ height: targetSize.height,
+ width : newWidth
+ }
+ } : null;
+ },
+
+
+ showTrigger: function() {
+ this.menuTrigger.show();
+ },
+
+
+ hideTrigger: function() {
+ if (this.menuTrigger !== undefined) {
+ this.menuTrigger.hide();
+ }
+ },
+
+
+ beforeMenuShow: function(menu) {
+ var me = this,
+ items = me.menuItems,
+ i = 0,
+ len = items.length,
+ item,
+ prev;
+
+ var needsSep = function(group, prev){
+ return group.isXType('buttongroup') && !(prev instanceof Ext.toolbar.Separator);
+ };
+
+ me.clearMenu();
+ menu.removeAll();
+
+ for (; i < len; i++) {
+ item = items[i];
+
+
+ if (!i && (item instanceof Ext.toolbar.Separator)) {
+ continue;
+ }
+ if (prev && (needsSep(item, prev) || needsSep(prev, item))) {
+ menu.add('-');
+ }
+
+ me.addComponentToMenu(menu, item);
+ prev = item;
+ }
+
+
+ if (menu.items.length < 1) {
+ menu.add(me.noItemsMenuText);
+ }
+ },
+
+
+ createMenuConfig : function(component, hideOnClick) {
+ var config = Ext.apply({}, component.initialConfig),
+ group = component.toggleGroup;
+
+ Ext.copyTo(config, component, [
+ 'iconCls', 'icon', 'itemId', 'disabled', 'handler', 'scope', 'menu'
+ ]);
+
+ Ext.apply(config, {
+ text : component.overflowText || component.text,
+ hideOnClick: hideOnClick,
+ destroyMenu: false
+ });
+
+ if (group || component.enableToggle) {
+ Ext.apply(config, {
+ group : group,
+ checked: component.pressed,
+ listeners: {
+ checkchange: function(item, checked){
+ component.toggle(checked);
+ }
+ }
+ });
+ }
+
+ delete config.ownerCt;
+ delete config.xtype;
+ delete config.id;
+ return config;
+ },
+
+
+ addComponentToMenu : function(menu, component) {
+ var me = this;
+ if (component instanceof Ext.toolbar.Separator) {
+ menu.add('-');
+ } else if (component.isComponent) {
+ if (component.isXType('splitbutton')) {
+ menu.add(me.createMenuConfig(component, true));
+
+ } else if (component.isXType('button')) {
+ menu.add(me.createMenuConfig(component, !component.menu));
+
+ } else if (component.isXType('buttongroup')) {
+ component.items.each(function(item){
+ me.addComponentToMenu(menu, item);
+ });
+ } else {
+ menu.add(Ext.create(Ext.getClassName(component), me.createMenuConfig(component)));
+ }
+ }
+ },
+
+
+ clearMenu : function() {
+ var menu = this.moreMenu;
+ if (menu && menu.items) {
+ menu.items.each(function(item) {
+ if (item.menu) {
+ delete item.menu;
+ }
+ });
+ }
+ },
+
+
+ createMenu: function(calculations, targetSize) {
+ var me = this,
+ layout = me.layout,
+ startProp = layout.parallelBefore,
+ sizeProp = layout.parallelPrefix,
+ available = targetSize[sizeProp],
+ boxes = calculations.boxes,
+ i = 0,
+ len = boxes.length,
+ box;
+
+ if (!me.menuTrigger) {
+ me.createInnerElements();
+
+
+ me.menu = Ext.create('Ext.menu.Menu', {
+ listeners: {
+ scope: me,
+ beforeshow: me.beforeMenuShow
+ }
+ });
+
+
+ me.menuTrigger = Ext.create('Ext.button.Button', {
+ ownerCt : me.layout.owner,
+ iconCls : me.layout.owner.menuTriggerCls,
+ ui : layout.owner instanceof Ext.toolbar.Toolbar ? 'default-toolbar' : 'default',
+ menu : me.menu,
+ getSplitCls: function() { return '';},
+ renderTo: me.afterCt
+ });
+ }
+ me.showTrigger();
+ available -= me.afterCt.getWidth();
+
+
+
+ me.menuItems.length = 0;
+ for (; i < len; i++) {
+ box = boxes[i];
+ if (box[startProp] + box[sizeProp] > available) {
+ me.menuItems.push(box.component);
+ box.component.hide();
+ }
+ }
+ },
+
+
+ createInnerElements: function() {
+ var me = this,
+ target = me.layout.getRenderTarget();
+
+ if (!this.afterCt) {
+ target.addCls(Ext.baseCSSPrefix + me.layout.direction + '-box-overflow-body');
+ this.afterCt = target.insertSibling({cls: Ext.layout.container.Box.prototype.innerCls + ' ' + this.afterCtCls}, 'before');
+ }
+ },
+
+
+ destroy: function() {
+ Ext.destroy(this.menu, this.menuTrigger);
+ }
+});
+
+Ext.define('Ext.util.Region', {
+
+
+
+ requires: ['Ext.util.Offset'],
+
+ statics: {
+
+ getRegion: function(el) {
+ return Ext.fly(el).getPageBox(true);
+ },
+
+
+ from: function(o) {
+ return new this(o.top, o.right, o.bottom, o.left);
+ }
+ },
+
+
+
+
+ constructor : function(t, r, b, l) {
+ var me = this;
+ me.y = me.top = me[1] = t;
+ me.right = r;
+ me.bottom = b;
+ me.x = me.left = me[0] = l;
+ },
+
+
+ contains : function(region) {
+ var me = this;
+ return (region.x >= me.x &&
+ region.right <= me.right &&
+ region.y >= me.y &&
+ region.bottom <= me.bottom);
+
+ },
+
+
+ intersect : function(region) {
+ var me = this,
+ t = Math.max(me.y, region.y),
+ r = Math.min(me.right, region.right),
+ b = Math.min(me.bottom, region.bottom),
+ l = Math.max(me.x, region.x);
+
+ if (b > t && r > l) {
+ return new this.self(t, r, b, l);
+ }
+ else {
+ return false;
+ }
+ },
+
+
+ union : function(region) {
+ var me = this,
+ t = Math.min(me.y, region.y),
+ r = Math.max(me.right, region.right),
+ b = Math.max(me.bottom, region.bottom),
+ l = Math.min(me.x, region.x);
+
+ return new this.self(t, r, b, l);
+ },
+
+
+ constrainTo : function(r) {
+ var me = this,
+ constrain = Ext.Number.constrain;
+ me.top = me.y = constrain(me.top, r.y, r.bottom);
+ me.bottom = constrain(me.bottom, r.y, r.bottom);
+ me.left = me.x = constrain(me.left, r.x, r.right);
+ me.right = constrain(me.right, r.x, r.right);
+ return me;
+ },
+
+
+ adjust : function(t, r, b, l) {
+ var me = this;
+ me.top = me.y += t;
+ me.left = me.x += l;
+ me.right += r;
+ me.bottom += b;
+ return me;
+ },
+
+
+ getOutOfBoundOffset: function(axis, p) {
+ if (!Ext.isObject(axis)) {
+ if (axis == 'x') {
+ return this.getOutOfBoundOffsetX(p);
+ } else {
+ return this.getOutOfBoundOffsetY(p);
+ }
+ } else {
+ p = axis;
+ var d = Ext.create('Ext.util.Offset');
+ d.x = this.getOutOfBoundOffsetX(p.x);
+ d.y = this.getOutOfBoundOffsetY(p.y);
+ return d;
+ }
+
+ },
+
+
+ getOutOfBoundOffsetX: function(p) {
+ if (p <= this.x) {
+ return this.x - p;
+ } else if (p >= this.right) {
+ return this.right - p;
+ }
+
+ return 0;
+ },
+
+
+ getOutOfBoundOffsetY: function(p) {
+ if (p <= this.y) {
+ return this.y - p;
+ } else if (p >= this.bottom) {
+ return this.bottom - p;
+ }
+
+ return 0;
+ },
+
+
+ isOutOfBound: function(axis, p) {
+ if (!Ext.isObject(axis)) {
+ if (axis == 'x') {
+ return this.isOutOfBoundX(p);
+ } else {
+ return this.isOutOfBoundY(p);
+ }
+ } else {
+ p = axis;
+ return (this.isOutOfBoundX(p.x) || this.isOutOfBoundY(p.y));
+ }
+ },
+
+
+ isOutOfBoundX: function(p) {
+ return (p < this.x || p > this.right);
+ },
+
+
+ isOutOfBoundY: function(p) {
+ return (p < this.y || p > this.bottom);
+ },
+
+
+ restrict: function(axis, p, factor) {
+ if (Ext.isObject(axis)) {
+ var newP;
+
+ factor = p;
+ p = axis;
+
+ if (p.copy) {
+ newP = p.copy();
+ }
+ else {
+ newP = {
+ x: p.x,
+ y: p.y
+ };
+ }
+
+ newP.x = this.restrictX(p.x, factor);
+ newP.y = this.restrictY(p.y, factor);
+ return newP;
+ } else {
+ if (axis == 'x') {
+ return this.restrictX(p, factor);
+ } else {
+ return this.restrictY(p, factor);
+ }
+ }
+ },
+
+
+ restrictX : function(p, factor) {
+ if (!factor) {
+ factor = 1;
+ }
+
+ if (p <= this.x) {
+ p -= (p - this.x) * factor;
+ }
+ else if (p >= this.right) {
+ p -= (p - this.right) * factor;
+ }
+ return p;
+ },
+
+
+ restrictY : function(p, factor) {
+ if (!factor) {
+ factor = 1;
+ }
+
+ if (p <= this.y) {
+ p -= (p - this.y) * factor;
+ }
+ else if (p >= this.bottom) {
+ p -= (p - this.bottom) * factor;
+ }
+ return p;
+ },
+
+
+ getSize: function() {
+ return {
+ width: this.right - this.x,
+ height: this.bottom - this.y
+ };
+ },
+
+
+ copy: function() {
+ return new this.self(this.y, this.right, this.bottom, this.x);
+ },
+
+
+ copyFrom: function(p) {
+ var me = this;
+ me.top = me.y = me[1] = p.y;
+ me.right = p.right;
+ me.bottom = p.bottom;
+ me.left = me.x = me[0] = p.x;
+
+ return this;
+ },
+
+
+ toString: function() {
+ return "Region[" + this.top + "," + this.right + "," + this.bottom + "," + this.left + "]";
+ },
+
+
+ translateBy: function(x, y) {
+ if (arguments.length == 1) {
+ y = x.y;
+ x = x.x;
+ }
+ var me = this;
+ me.top = me.y += y;
+ me.right += x;
+ me.bottom += y;
+ me.left = me.x += x;
+
+ return me;
+ },
+
+
+ round: function() {
+ var me = this;
+ me.top = me.y = Math.round(me.y);
+ me.right = Math.round(me.right);
+ me.bottom = Math.round(me.bottom);
+ me.left = me.x = Math.round(me.x);
+
+ return me;
+ },
+
+
+ equals: function(region) {
+ return (this.top == region.top && this.right == region.right && this.bottom == region.bottom && this.left == region.left);
+ }
+});
+
+
+
+
+
+Ext.define('Ext.dd.DragDropManager', {
+ singleton: true,
+
+ requires: ['Ext.util.Region'],
+
+ uses: ['Ext.tip.QuickTipManager'],
+
+
+ alternateClassName: ['Ext.dd.DragDropMgr', 'Ext.dd.DDM'],
+
+
+ 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();
+
+ var Event = Ext.EventManager;
+ 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.tip.QuickTipManager){
+ Ext.tip.QuickTipManager.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.DragDropManager;
+ 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.tip && Ext.tip.QuickTipManager){
+ Ext.tip.QuickTipManager.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;
+ }
+
+
+
+ if (oDD.getRegion) {
+ return oDD.getRegion();
+ }
+
+ var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
+
+ try {
+ pos= Ext.Element.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 Ext.create('Ext.util.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 = Ext.create('Ext.util.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.DragDropManager.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.Element.getX(el);
+ },
+
+
+ getPosY: function(el) {
+ return Ext.Element.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 doc = window.document,
+ docEl = doc.documentElement,
+ body = doc.body,
+ top = 0,
+ left = 0;
+
+ if (Ext.isGecko4) {
+ top = window.scrollYOffset;
+ left = window.scrollXOffset;
+ } else {
+ if (docEl && (docEl.scrollTop || docEl.scrollLeft)) {
+ top = docEl.scrollTop;
+ left = docEl.scrollLeft;
+ } else if (body) {
+ top = body.scrollTop;
+ left = body.scrollLeft;
+ }
+ }
+ return {
+ top: top,
+ left: left
+ };
+ },
+
+
+ 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.Element.getXY(targetEl);
+ Ext.Element.setXY(moveEl, aCoord);
+ },
+
+
+ numericSort: function(a, b) {
+ return (a - b);
+ },
+
+
+ _timeoutCount: 0,
+
+
+ _addListeners: function() {
+ if ( document ) {
+ this._onLoad();
+ } else {
+ if (this._timeoutCount > 2000) {
+ } else {
+ setTimeout(this._addListeners, 10);
+ if (document && document.body) {
+ this._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;
+ }
+}, function() {
+ this._addListeners();
+});
+
+
+
+Ext.define('Ext.layout.container.Box', {
+
+
+
+ alias: ['layout.box'],
+ extend: 'Ext.layout.container.Container',
+ alternateClassName: 'Ext.layout.BoxLayout',
+
+ requires: [
+ 'Ext.layout.container.boxOverflow.None',
+ 'Ext.layout.container.boxOverflow.Menu',
+ 'Ext.layout.container.boxOverflow.Scroller',
+ 'Ext.util.Format',
+ 'Ext.dd.DragDropManager'
+ ],
+
+
+
+
+
+
+ defaultMargins: {
+ top: 0,
+ right: 0,
+ bottom: 0,
+ left: 0
+ },
+
+
+ padding: '0',
+
+ pack: 'start',
+
+
+
+
+ type: 'box',
+ scrollOffset: 0,
+ itemCls: Ext.baseCSSPrefix + 'box-item',
+ targetCls: Ext.baseCSSPrefix + 'box-layout-ct',
+ innerCls: Ext.baseCSSPrefix + 'box-inner',
+
+ bindToOwnerCtContainer: true,
+
+
+
+ availableSpaceOffset: 0,
+
+
+ reserveOffset: true,
+
+
+ shrinkToFit: true,
+
+
+ clearInnerCtOnLayout: false,
+
+ flexSortFn: function (a, b) {
+ var maxParallelPrefix = 'max' + this.parallelPrefixCap,
+ infiniteValue = Infinity;
+ a = a.component[maxParallelPrefix] || infiniteValue;
+ b = b.component[maxParallelPrefix] || infiniteValue;
+
+ if (!isFinite(a) && !isFinite(b)) {
+ return false;
+ }
+ return a - b;
+ },
+
+
+ minSizeSortFn: function(a, b) {
+ return b.available - a.available;
+ },
+
+ constructor: function(config) {
+ var me = this;
+
+ me.callParent(arguments);
+
+
+ me.flexSortFn = Ext.Function.bind(me.flexSortFn, me);
+
+ me.initOverflowHandler();
+ },
+
+
+ getChildBox: function(child) {
+ child = child.el || this.owner.getComponent(child).el;
+ var size = child.getBox(false, true);
+ return {
+ left: size.left,
+ top: size.top,
+ width: size.width,
+ height: size.height
+ };
+ },
+
+
+ calculateChildBox: function(child) {
+ var me = this,
+ boxes = me.calculateChildBoxes(me.getVisibleItems(), me.getLayoutTargetSize()).boxes,
+ ln = boxes.length,
+ i = 0;
+
+ child = me.owner.getComponent(child);
+ for (; i < ln; i++) {
+ if (boxes[i].component === child) {
+ return boxes[i];
+ }
+ }
+ },
+
+
+ calculateChildBoxes: function(visibleItems, targetSize) {
+ var me = this,
+ math = Math,
+ mmax = math.max,
+ infiniteValue = Infinity,
+ undefinedValue,
+
+ parallelPrefix = me.parallelPrefix,
+ parallelPrefixCap = me.parallelPrefixCap,
+ perpendicularPrefix = me.perpendicularPrefix,
+ perpendicularPrefixCap = me.perpendicularPrefixCap,
+ parallelMinString = 'min' + parallelPrefixCap,
+ perpendicularMinString = 'min' + perpendicularPrefixCap,
+ perpendicularMaxString = 'max' + perpendicularPrefixCap,
+
+ parallelSize = targetSize[parallelPrefix] - me.scrollOffset,
+ perpendicularSize = targetSize[perpendicularPrefix],
+ padding = me.padding,
+ parallelOffset = padding[me.parallelBefore],
+ paddingParallel = parallelOffset + padding[me.parallelAfter],
+ perpendicularOffset = padding[me.perpendicularLeftTop],
+ paddingPerpendicular = perpendicularOffset + padding[me.perpendicularRightBottom],
+ availPerpendicularSize = mmax(0, perpendicularSize - paddingPerpendicular),
+
+ innerCtBorderWidth = me.innerCt.getBorderWidth(me.perpendicularLT + me.perpendicularRB),
+
+ isStart = me.pack == 'start',
+ isCenter = me.pack == 'center',
+ isEnd = me.pack == 'end',
+
+ constrain = Ext.Number.constrain,
+ visibleCount = visibleItems.length,
+ nonFlexSize = 0,
+ totalFlex = 0,
+ desiredSize = 0,
+ minimumSize = 0,
+ maxSize = 0,
+ boxes = [],
+ minSizes = [],
+ calculatedWidth,
+
+ i, child, childParallel, childPerpendicular, childMargins, childSize, minParallel, tmpObj, shortfall,
+ tooNarrow, availableSpace, minSize, item, length, itemIndex, box, oldSize, newSize, reduction, diff,
+ flexedBoxes, remainingSpace, remainingFlex, flexedSize, parallelMargins, calcs, offset,
+ perpendicularMargins, stretchSize;
+
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ childPerpendicular = child[perpendicularPrefix];
+ if (!child.flex || !(me.align == 'stretch' || me.align == 'stretchmax')) {
+ if (child.componentLayout.initialized !== true) {
+ me.layoutItem(child);
+ }
+ }
+
+ childMargins = child.margins;
+ parallelMargins = childMargins[me.parallelBefore] + childMargins[me.parallelAfter];
+
+
+ tmpObj = {
+ component: child,
+ margins: childMargins
+ };
+
+
+ if (child.flex) {
+ totalFlex += child.flex;
+ childParallel = undefinedValue;
+ }
+
+ else {
+ if (!(child[parallelPrefix] && childPerpendicular)) {
+ childSize = child.getSize();
+ }
+ childParallel = child[parallelPrefix] || childSize[parallelPrefix];
+ childPerpendicular = childPerpendicular || childSize[perpendicularPrefix];
+ }
+
+ nonFlexSize += parallelMargins + (childParallel || 0);
+ desiredSize += parallelMargins + (child.flex ? child[parallelMinString] || 0 : childParallel);
+ minimumSize += parallelMargins + (child[parallelMinString] || childParallel || 0);
+
+
+ if (typeof childPerpendicular != 'number') {
+
+
+ childPerpendicular = child['get' + perpendicularPrefixCap]();
+ }
+
+
+
+ maxSize = mmax(maxSize, mmax(childPerpendicular, child[perpendicularMinString]||0) + childMargins[me.perpendicularLeftTop] + childMargins[me.perpendicularRightBottom]);
+
+ tmpObj[parallelPrefix] = childParallel || undefinedValue;
+ tmpObj.dirtySize = child.componentLayout.lastComponentSize ? (tmpObj[parallelPrefix] !== child.componentLayout.lastComponentSize[parallelPrefix]) : false;
+ tmpObj[perpendicularPrefix] = childPerpendicular || undefinedValue;
+ boxes.push(tmpObj);
+ }
+
+
+ if (!me.autoSize) {
+ shortfall = desiredSize - parallelSize;
+ tooNarrow = minimumSize > parallelSize;
+ }
+
+
+ availableSpace = mmax(0, parallelSize - nonFlexSize - paddingParallel - (me.reserveOffset ? me.availableSpaceOffset : 0));
+
+ if (tooNarrow) {
+ for (i = 0; i < visibleCount; i++) {
+ box = boxes[i];
+ minSize = visibleItems[i][parallelMinString] || visibleItems[i][parallelPrefix] || box[parallelPrefix];
+ box.dirtySize = box.dirtySize || box[parallelPrefix] != minSize;
+ box[parallelPrefix] = minSize;
+ }
+ }
+ else {
+
+
+ if (shortfall > 0) {
+
+ for (i = 0; i < visibleCount; i++) {
+ item = visibleItems[i];
+ minSize = item[parallelMinString] || 0;
+
+
+
+ if (item.flex) {
+ box = boxes[i];
+ box.dirtySize = box.dirtySize || box[parallelPrefix] != minSize;
+ box[parallelPrefix] = minSize;
+ } else if (me.shrinkToFit) {
+ minSizes.push({
+ minSize: minSize,
+ available: boxes[i][parallelPrefix] - minSize,
+ index: i
+ });
+ }
+ }
+
+
+ Ext.Array.sort(minSizes, me.minSizeSortFn);
+
+
+ for (i = 0, length = minSizes.length; i < length; i++) {
+ itemIndex = minSizes[i].index;
+
+ if (itemIndex == undefinedValue) {
+ continue;
+ }
+ item = visibleItems[itemIndex];
+ minSize = minSizes[i].minSize;
+
+ box = boxes[itemIndex];
+ oldSize = box[parallelPrefix];
+ newSize = mmax(minSize, oldSize - math.ceil(shortfall / (length - i)));
+ reduction = oldSize - newSize;
+
+ box.dirtySize = box.dirtySize || box[parallelPrefix] != newSize;
+ box[parallelPrefix] = newSize;
+ shortfall -= reduction;
+ }
+ tooNarrow = (shortfall > 0);
+ }
+ else {
+ remainingSpace = availableSpace;
+ remainingFlex = totalFlex;
+ flexedBoxes = [];
+
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ if (isStart && child.flex) {
+ flexedBoxes.push(boxes[Ext.Array.indexOf(visibleItems, child)]);
+ }
+ }
+
+
+
+ Ext.Array.sort(flexedBoxes, me.flexSortFn);
+
+
+ for (i = 0; i < flexedBoxes.length; i++) {
+ calcs = flexedBoxes[i];
+ child = calcs.component;
+ childMargins = calcs.margins;
+
+ flexedSize = math.ceil((child.flex / remainingFlex) * remainingSpace);
+
+
+ flexedSize = Math.max(child['min' + parallelPrefixCap] || 0, math.min(child['max' + parallelPrefixCap] || infiniteValue, flexedSize));
+
+
+ remainingSpace -= flexedSize;
+ remainingFlex -= child.flex;
+
+ calcs.dirtySize = calcs.dirtySize || calcs[parallelPrefix] != flexedSize;
+ calcs[parallelPrefix] = flexedSize;
+ }
+ }
+ }
+
+ if (isCenter) {
+ parallelOffset += availableSpace / 2;
+ }
+ else if (isEnd) {
+ parallelOffset += availableSpace;
+ }
+
+
+
+
+
+ if (me.owner.dock && (Ext.isIE6 || Ext.isIE7 || Ext.isIEQuirks) && !me.owner.width && me.direction == 'vertical') {
+
+ calculatedWidth = maxSize + me.owner.el.getPadding('lr') + me.owner.el.getBorderWidth('lr');
+ if (me.owner.frameSize) {
+ calculatedWidth += me.owner.frameSize.left + me.owner.frameSize.right;
+ }
+
+ availPerpendicularSize = Math.min(availPerpendicularSize, targetSize.width = maxSize + padding.left + padding.right);
+ }
+
+
+ for (i = 0; i < visibleCount; i++) {
+ child = visibleItems[i];
+ calcs = boxes[i];
+
+ childMargins = calcs.margins;
+
+ perpendicularMargins = childMargins[me.perpendicularLeftTop] + childMargins[me.perpendicularRightBottom];
+
+
+ parallelOffset += childMargins[me.parallelBefore];
+
+ calcs[me.parallelBefore] = parallelOffset;
+ calcs[me.perpendicularLeftTop] = perpendicularOffset + childMargins[me.perpendicularLeftTop];
+
+ if (me.align == 'stretch') {
+ stretchSize = constrain(availPerpendicularSize - perpendicularMargins, child[perpendicularMinString] || 0, child[perpendicularMaxString] || infiniteValue);
+ calcs.dirtySize = calcs.dirtySize || calcs[perpendicularPrefix] != stretchSize;
+ calcs[perpendicularPrefix] = stretchSize;
+ }
+ else if (me.align == 'stretchmax') {
+ stretchSize = constrain(maxSize - perpendicularMargins, child[perpendicularMinString] || 0, child[perpendicularMaxString] || infiniteValue);
+ calcs.dirtySize = calcs.dirtySize || calcs[perpendicularPrefix] != stretchSize;
+ calcs[perpendicularPrefix] = stretchSize;
+ }
+ else if (me.align == me.alignCenteringString) {
+
+
+
+ diff = mmax(availPerpendicularSize, maxSize) - innerCtBorderWidth - calcs[perpendicularPrefix];
+ if (diff > 0) {
+ calcs[me.perpendicularLeftTop] = perpendicularOffset + Math.round(diff / 2);
+ }
+ }
+
+
+ parallelOffset += (calcs[parallelPrefix] || 0) + childMargins[me.parallelAfter];
+ }
+
+ return {
+ boxes: boxes,
+ meta : {
+ calculatedWidth: calculatedWidth,
+ maxSize: maxSize,
+ nonFlexSize: nonFlexSize,
+ desiredSize: desiredSize,
+ minimumSize: minimumSize,
+ shortfall: shortfall,
+ tooNarrow: tooNarrow
+ }
+ };
+ },
+
+ onRemove: function(comp){
+ this.callParent(arguments);
+ if (this.overflowHandler) {
+ this.overflowHandler.onRemove(comp);
+ }
+ },
+
+
+ initOverflowHandler: function() {
+ var handler = this.overflowHandler;
+
+ if (typeof handler == 'string') {
+ handler = {
+ type: handler
+ };
+ }
+
+ var handlerType = 'None';
+ if (handler && handler.type !== undefined) {
+ handlerType = handler.type;
+ }
+
+ var constructor = Ext.layout.container.boxOverflow[handlerType];
+ if (constructor[this.type]) {
+ constructor = constructor[this.type];
+ }
+
+ this.overflowHandler = Ext.create('Ext.layout.container.boxOverflow.' + handlerType, this, handler);
+ },
+
+
+ onLayout: function() {
+ this.callParent();
+
+ if (this.clearInnerCtOnLayout === true && this.adjustmentPass !== true) {
+ this.innerCt.setSize(null, null);
+ }
+
+ var me = this,
+ targetSize = me.getLayoutTargetSize(),
+ items = me.getVisibleItems(),
+ calcs = me.calculateChildBoxes(items, targetSize),
+ boxes = calcs.boxes,
+ meta = calcs.meta,
+ handler, method, results;
+
+ if (me.autoSize && calcs.meta.desiredSize) {
+ targetSize[me.parallelPrefix] = calcs.meta.desiredSize;
+ }
+
+
+ if (meta.shortfall > 0) {
+ handler = me.overflowHandler;
+ method = meta.tooNarrow ? 'handleOverflow': 'clearOverflow';
+
+ results = handler[method](calcs, targetSize);
+
+ if (results) {
+ if (results.targetSize) {
+ targetSize = results.targetSize;
+ }
+
+ if (results.recalculate) {
+ items = me.getVisibleItems();
+ calcs = me.calculateChildBoxes(items, targetSize);
+ boxes = calcs.boxes;
+ }
+ }
+ } else {
+ me.overflowHandler.clearOverflow();
+ }
+
+
+ me.layoutTargetLastSize = targetSize;
+
+
+ me.childBoxCache = calcs;
+
+ me.updateInnerCtSize(targetSize, calcs);
+ me.updateChildBoxes(boxes);
+ me.handleTargetOverflow(targetSize);
+ },
+
+ animCallback: Ext.emptyFn,
+
+
+ updateChildBoxes: function(boxes) {
+ var me = this,
+ i = 0,
+ length = boxes.length,
+ animQueue = [],
+ dd = Ext.dd.DDM.getDDById(me.innerCt.id),
+ oldBox, newBox, changed, comp, boxAnim, animCallback;
+
+ for (; i < length; i++) {
+ newBox = boxes[i];
+ comp = newBox.component;
+
+
+
+ if (dd && (dd.getDragEl() === comp.el.dom)) {
+ continue;
+ }
+
+ changed = false;
+
+ oldBox = me.getChildBox(comp);
+
+
+
+
+ if (me.animate) {
+
+ animCallback = me.animate.callback || me.animate;
+ boxAnim = {
+ layoutAnimation: true,
+ target: comp,
+ from: {},
+ to: {},
+ listeners: {}
+ };
+
+
+
+
+ if (!isNaN(newBox.width) && (newBox.width != oldBox.width)) {
+ changed = true;
+
+ boxAnim.to.width = newBox.width;
+ }
+ if (!isNaN(newBox.height) && (newBox.height != oldBox.height)) {
+ changed = true;
+
+ boxAnim.to.height = newBox.height;
+ }
+ if (!isNaN(newBox.left) && (newBox.left != oldBox.left)) {
+ changed = true;
+
+ boxAnim.to.left = newBox.left;
+ }
+ if (!isNaN(newBox.top) && (newBox.top != oldBox.top)) {
+ changed = true;
+
+ boxAnim.to.top = newBox.top;
+ }
+ if (changed) {
+ animQueue.push(boxAnim);
+ }
+ } else {
+ if (newBox.dirtySize) {
+ if (newBox.width !== oldBox.width || newBox.height !== oldBox.height) {
+ me.setItemSize(comp, newBox.width, newBox.height);
+ }
+ }
+
+ if (isNaN(newBox.left) || isNaN(newBox.top)) {
+ continue;
+ }
+ comp.setPosition(newBox.left, newBox.top);
+ }
+ }
+
+
+ length = animQueue.length;
+ if (length) {
+
+
+
+ var afterAnimate = function(anim) {
+
+ length -= 1;
+ if (!length) {
+ me.animCallback(anim);
+ me.layoutBusy = false;
+ if (Ext.isFunction(animCallback)) {
+ animCallback();
+ }
+ }
+ };
+
+ var beforeAnimate = function() {
+ me.layoutBusy = true;
+ };
+
+
+ for (i = 0, length = animQueue.length; i < length; i++) {
+ boxAnim = animQueue[i];
+
+
+ boxAnim.listeners.afteranimate = afterAnimate;
+
+
+ if (!i) {
+ boxAnim.listeners.beforeanimate = beforeAnimate;
+ }
+ if (me.animate.duration) {
+ boxAnim.duration = me.animate.duration;
+ }
+ comp = boxAnim.target;
+ delete boxAnim.target;
+
+ comp.stopAnimation();
+ comp.animate(boxAnim);
+ }
+ }
+ },
+
+
+ updateInnerCtSize: function(tSize, calcs) {
+ var me = this,
+ mmax = Math.max,
+ align = me.align,
+ padding = me.padding,
+ width = tSize.width,
+ height = tSize.height,
+ meta = calcs.meta,
+ innerCtWidth,
+ innerCtHeight;
+
+ if (me.direction == 'horizontal') {
+ innerCtWidth = width;
+ innerCtHeight = meta.maxSize + padding.top + padding.bottom + me.innerCt.getBorderWidth('tb');
+
+ if (align == 'stretch') {
+ innerCtHeight = height;
+ }
+ else if (align == 'middle') {
+ innerCtHeight = mmax(height, innerCtHeight);
+ }
+ } else {
+ innerCtHeight = height;
+ innerCtWidth = meta.maxSize + padding.left + padding.right + me.innerCt.getBorderWidth('lr');
+
+ if (align == 'stretch') {
+ innerCtWidth = width;
+ }
+ else if (align == 'center') {
+ innerCtWidth = mmax(width, innerCtWidth);
+ }
+ }
+ me.getRenderTarget().setSize(innerCtWidth || undefined, innerCtHeight || undefined);
+
+
+
+ if (meta.calculatedWidth && me.owner.el.getWidth() > meta.calculatedWidth) {
+ me.owner.el.setWidth(meta.calculatedWidth);
+ }
+
+ if (me.innerCt.dom.scrollTop) {
+ me.innerCt.dom.scrollTop = 0;
+ }
+ },
+
+
+ handleTargetOverflow: function(previousTargetSize) {
+ var target = this.getTarget(),
+ overflow = target.getStyle('overflow'),
+ newTargetSize;
+
+ if (overflow && overflow != 'hidden' && !this.adjustmentPass) {
+ newTargetSize = this.getLayoutTargetSize();
+ if (newTargetSize.width != previousTargetSize.width || newTargetSize.height != previousTargetSize.height) {
+ this.adjustmentPass = true;
+ this.onLayout();
+ return true;
+ }
+ }
+
+ delete this.adjustmentPass;
+ },
+
+
+ isValidParent : function(item, target, position) {
+
+
+ var itemEl = item.el ? item.el.dom : Ext.getDom(item);
+ return (itemEl && this.innerCt && itemEl.parentNode === this.innerCt.dom) || false;
+ },
+
+
+
+ getRenderTarget: function() {
+ if (!this.innerCt) {
+
+ this.innerCt = this.getTarget().createChild({
+ cls: this.innerCls,
+ role: 'presentation'
+ });
+ this.padding = Ext.util.Format.parseBox(this.padding);
+ }
+ return this.innerCt;
+ },
+
+
+ renderItem: function(item, target) {
+ this.callParent(arguments);
+ var me = this,
+ itemEl = item.getEl(),
+ style = itemEl.dom.style,
+ margins = item.margins || item.margin;
+
+
+ if (margins) {
+ if (Ext.isString(margins) || Ext.isNumber(margins)) {
+ margins = Ext.util.Format.parseBox(margins);
+ } else {
+ Ext.applyIf(margins, {top: 0, right: 0, bottom: 0, left: 0});
+ }
+ } else {
+ margins = Ext.apply({}, me.defaultMargins);
+ }
+
+
+ margins.top += itemEl.getMargin('t');
+ margins.right += itemEl.getMargin('r');
+ margins.bottom += itemEl.getMargin('b');
+ margins.left += itemEl.getMargin('l');
+ margins.height = margins.top + margins.bottom;
+ margins.width = margins.left + margins.right;
+ style.marginTop = style.marginRight = style.marginBottom = style.marginLeft = '0';
+
+
+ item.margins = margins;
+ },
+
+
+ destroy: function() {
+ Ext.destroy(this.innerCt, this.overflowHandler);
+ this.callParent(arguments);
+ }
+});
+
+Ext.define('Ext.layout.container.HBox', {
+
+
+
+ alias: ['layout.hbox'],
+ extend: 'Ext.layout.container.Box',
+ alternateClassName: 'Ext.layout.HBoxLayout',
+
+
+
+
+ align: 'top',
+
+ //@private
+
+ alignCenteringString: 'middle',
+
+ type : 'hbox',
+
+ direction: 'horizontal',
+
+
+ parallelSizeIndex: 0,
+ perpendicularSizeIndex: 1,
+
+ parallelPrefix: 'width',
+ parallelPrefixCap: 'Width',
+ parallelLT: 'l',
+ parallelRB: 'r',
+ parallelBefore: 'left',
+ parallelBeforeCap: 'Left',
+ parallelAfter: 'right',
+ parallelPosition: 'x',
+
+ perpendicularPrefix: 'height',
+ perpendicularPrefixCap: 'Height',
+ perpendicularLT: 't',
+ perpendicularRB: 'b',
+ perpendicularLeftTop: 'top',
+ perpendicularRightBottom: 'bottom',
+ perpendicularPosition: 'y',
+ configureItem: function(item) {
+ if (item.flex) {
+ item.layoutManagedWidth = 1;
+ } else {
+ item.layoutManagedWidth = 2;
+ }
+
+ if (this.align === 'stretch' || this.align === 'stretchmax') {
+ item.layoutManagedHeight = 1;
+ } else {
+ item.layoutManagedHeight = 2;
+ }
+ this.callParent(arguments);
+ }
+});
+
+Ext.define('Ext.layout.container.VBox', {
+
+
+
+ alias: ['layout.vbox'],
+ extend: 'Ext.layout.container.Box',
+ alternateClassName: 'Ext.layout.VBoxLayout',
+
+
+
+
+ align : 'left',
+
+ //@private
+
+ alignCenteringString: 'center',
+
+ type: 'vbox',
+
+ direction: 'vertical',
+
+
+ parallelSizeIndex: 1,
+ perpendicularSizeIndex: 0,
+
+ parallelPrefix: 'height',
+ parallelPrefixCap: 'Height',
+ parallelLT: 't',
+ parallelRB: 'b',
+ parallelBefore: 'top',
+ parallelBeforeCap: 'Top',
+ parallelAfter: 'bottom',
+ parallelPosition: 'y',
+
+ perpendicularPrefix: 'width',
+ perpendicularPrefixCap: 'Width',
+ perpendicularLT: 'l',
+ perpendicularRB: 'r',
+ perpendicularLeftTop: 'left',
+ perpendicularRightBottom: 'right',
+ perpendicularPosition: 'x',
+ configureItem: function(item) {
+ if (item.flex) {
+ item.layoutManagedHeight = 1;
+ } else {
+ item.layoutManagedHeight = 2;
+ }
+
+ if (this.align === 'stretch' || this.align === 'stretchmax') {
+ item.layoutManagedWidth = 1;
+ } else {
+ item.layoutManagedWidth = 2;
+ }
+ this.callParent(arguments);
+ }
+});
+
+Ext.define('Ext.FocusManager', {
+ singleton: true,
+ alternateClassName: 'Ext.FocusMgr',
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ requires: [
+ 'Ext.ComponentManager',
+ 'Ext.ComponentQuery',
+ 'Ext.util.HashMap',
+ 'Ext.util.KeyNav'
+ ],
+
+
+ enabled: false,
+
+
+
+ focusElementCls: Ext.baseCSSPrefix + 'focus-element',
+
+ focusFrameCls: Ext.baseCSSPrefix + 'focus-frame',
+
+
+ whitelist: [
+ 'textfield'
+ ],
+
+ tabIndexWhitelist: [
+ 'a',
+ 'button',
+ 'embed',
+ 'frame',
+ 'iframe',
+ 'img',
+ 'input',
+ 'object',
+ 'select',
+ 'textarea'
+ ],
+
+ constructor: function() {
+ var me = this,
+ CQ = Ext.ComponentQuery;
+
+ me.addEvents(
+
+ 'beforecomponentfocus',
+
+
+ 'componentfocus',
+
+
+ 'disable',
+
+
+ 'enable'
+ );
+
+
+
+ me.keyNav = Ext.create('Ext.util.KeyNav', Ext.getDoc(), {
+ disabled: true,
+ scope: me,
+
+ backspace: me.focusLast,
+ enter: me.navigateIn,
+ esc: me.navigateOut,
+ tab: me.navigateSiblings
+
+
+
+
+
+
+
+ });
+
+ me.focusData = {};
+ me.subscribers = Ext.create('Ext.util.HashMap');
+ me.focusChain = {};
+
+
+ Ext.apply(CQ.pseudos, {
+ focusable: function(cmps) {
+ var len = cmps.length,
+ results = [],
+ i = 0,
+ c,
+
+ isFocusable = function(x) {
+ return x && x.focusable !== false && CQ.is(x, '[rendered]:not([destroying]):not([isDestroyed]):not([disabled]){isVisible(true)}{el && c.el.dom && c.el.isVisible()}');
+ };
+
+ for (; i < len; i++) {
+ c = cmps[i];
+ if (isFocusable(c)) {
+ results.push(c);
+ }
+ }
+
+ return results;
+ },
+
+ nextFocus: function(cmps, idx, step) {
+ step = step || 1;
+ idx = parseInt(idx, 10);
+
+ var len = cmps.length,
+ i = idx + step,
+ c;
+
+ for (; i != idx; i += step) {
+ if (i >= len) {
+ i = 0;
+ } else if (i < 0) {
+ i = len - 1;
+ }
+
+ c = cmps[i];
+ if (CQ.is(c, ':focusable')) {
+ return [c];
+ } else if (c.placeholder && CQ.is(c.placeholder, ':focusable')) {
+ return [c.placeholder];
+ }
+ }
+
+ return [];
+ },
+
+ prevFocus: function(cmps, idx) {
+ return this.nextFocus(cmps, idx, -1);
+ },
+
+ root: function(cmps) {
+ var len = cmps.length,
+ results = [],
+ i = 0,
+ c;
+
+ for (; i < len; i++) {
+ c = cmps[i];
+ if (!c.ownerCt) {
+ results.push(c);
+ }
+ }
+
+ return results;
+ }
+ });
+ },
+
+
+ addXTypeToWhitelist: function(xtype) {
+ var me = this;
+
+ if (Ext.isArray(xtype)) {
+ Ext.Array.forEach(xtype, me.addXTypeToWhitelist, me);
+ return;
+ }
+
+ if (!Ext.Array.contains(me.whitelist, xtype)) {
+ me.whitelist.push(xtype);
+ }
+ },
+
+ clearComponent: function(cmp) {
+ clearTimeout(this.cmpFocusDelay);
+ if (!cmp.isDestroyed) {
+ cmp.blur();
+ }
+ },
+
+
+ disable: function() {
+ var me = this;
+
+ if (!me.enabled) {
+ return;
+ }
+
+ delete me.options;
+ me.enabled = false;
+
+ Ext.ComponentManager.all.un('add', me.onComponentCreated, me);
+
+ me.removeDOM();
+
+
+ me.keyNav.disable();
+
+
+ me.setFocusAll(false);
+
+ me.fireEvent('disable', me);
+ },
+
+
+ enable: function(options) {
+ var me = this;
+
+ if (options === true) {
+ options = { focusFrame: true };
+ }
+ me.options = options = options || {};
+
+ if (me.enabled) {
+ return;
+ }
+
+
+ Ext.ComponentManager.all.on('add', me.onComponentCreated, me);
+
+ me.initDOM(options);
+
+
+ me.keyNav.enable();
+
+
+ me.setFocusAll(true, options);
+
+
+ me.focusEl.focus();
+ delete me.focusedCmp;
+
+ me.enabled = true;
+ me.fireEvent('enable', me);
+ },
+
+ focusLast: function(e) {
+ var me = this;
+
+ if (me.isWhitelisted(me.focusedCmp)) {
+ return true;
+ }
+
+
+ if (me.previousFocusedCmp) {
+ me.previousFocusedCmp.focus();
+ }
+ },
+
+ getRootComponents: function() {
+ var me = this,
+ CQ = Ext.ComponentQuery,
+ inline = CQ.query(':focusable:root:not([floating])'),
+ floating = CQ.query(':focusable:root[floating]');
+
+
+
+ floating.sort(function(a, b) {
+ return a.el.getZIndex() > b.el.getZIndex();
+ });
+
+ return floating.concat(inline);
+ },
+
+ initDOM: function(options) {
+ var me = this,
+ sp = ' ',
+ cls = me.focusFrameCls;
+
+ if (!Ext.isReady) {
+ Ext.onReady(me.initDOM, me);
+ return;
+ }
+
+
+ if (!me.focusEl) {
+ me.focusEl = Ext.getBody().createChild({
+ tabIndex: '-1',
+ cls: me.focusElementCls,
+ html: sp
+ });
+ }
+
+
+ if (!me.focusFrame && options.focusFrame) {
+ me.focusFrame = Ext.getBody().createChild({
+ cls: cls,
+ children: [
+ { cls: cls + '-top' },
+ { cls: cls + '-bottom' },
+ { cls: cls + '-left' },
+ { cls: cls + '-right' }
+ ],
+ style: 'top: -100px; left: -100px;'
+ });
+ me.focusFrame.setVisibilityMode(Ext.Element.DISPLAY);
+ me.focusFrameWidth = 2;
+ me.focusFrame.hide().setLeftTop(0, 0);
+ }
+ },
+
+ isWhitelisted: function(cmp) {
+ return cmp && Ext.Array.some(this.whitelist, function(x) {
+ return cmp.isXType(x);
+ });
+ },
+
+ navigateIn: function(e) {
+ var me = this,
+ focusedCmp = me.focusedCmp,
+ rootCmps,
+ firstChild;
+
+ if (!focusedCmp) {
+
+ rootCmps = me.getRootComponents();
+ if (rootCmps.length) {
+ rootCmps[0].focus();
+ }
+ } else {
+
+
+ firstChild = Ext.ComponentQuery.query('>:focusable', focusedCmp)[0];
+ if (firstChild) {
+ firstChild.focus();
+ } else {
+
+ if (Ext.isFunction(focusedCmp.onClick)) {
+ e.button = 0;
+ focusedCmp.onClick(e);
+ focusedCmp.focus();
+ }
+ }
+ }
+ },
+
+ navigateOut: function(e) {
+ var me = this,
+ parent;
+
+ if (!me.focusedCmp || !(parent = me.focusedCmp.up(':focusable'))) {
+ me.focusEl.focus();
+ } else {
+ parent.focus();
+ }
+
+
+
+
+ return true;
+ },
+
+ navigateSiblings: function(e, source, parent) {
+ var me = this,
+ src = source || me,
+ key = e.getKey(),
+ EO = Ext.EventObject,
+ goBack = e.shiftKey || key == EO.LEFT || key == EO.UP,
+ checkWhitelist = key == EO.LEFT || key == EO.RIGHT || key == EO.UP || key == EO.DOWN,
+ nextSelector = goBack ? 'prev' : 'next',
+ idx, next, focusedCmp;
+
+ focusedCmp = (src.focusedCmp && src.focusedCmp.comp) || src.focusedCmp;
+ if (!focusedCmp && !parent) {
+ return;
+ }
+
+ if (checkWhitelist && me.isWhitelisted(focusedCmp)) {
+ return true;
+ }
+
+ parent = parent || focusedCmp.up();
+ if (parent) {
+ idx = focusedCmp ? Ext.Array.indexOf(parent.getRefItems(), focusedCmp) : -1;
+ next = Ext.ComponentQuery.query('>:' + nextSelector + 'Focus(' + idx + ')', parent)[0];
+ if (next && focusedCmp !== next) {
+ next.focus();
+ return next;
+ }
+ }
+ },
+
+ onComponentBlur: function(cmp, e) {
+ var me = this;
+
+ if (me.focusedCmp === cmp) {
+ me.previousFocusedCmp = cmp;
+ delete me.focusedCmp;
+ }
+
+ if (me.focusFrame) {
+ me.focusFrame.hide();
+ }
+ },
+
+ onComponentCreated: function(hash, id, cmp) {
+ this.setFocus(cmp, true, this.options);
+ },
+
+ onComponentDestroy: function(cmp) {
+ this.setFocus(cmp, false);
+ },
+
+ onComponentFocus: function(cmp, e) {
+ var me = this,
+ chain = me.focusChain;
+
+ if (!Ext.ComponentQuery.is(cmp, ':focusable')) {
+ me.clearComponent(cmp);
+
+
+
+
+
+ if (chain[cmp.id]) {
+ return;
+ }
+
+
+ var parent = cmp.up();
+ if (parent) {
+
+
+
+ chain[cmp.id] = true;
+ parent.focus();
+ }
+
+ return;
+ }
+
+
+ me.focusChain = {};
+
+
+
+ clearTimeout(me.cmpFocusDelay);
+ if (arguments.length !== 2) {
+ me.cmpFocusDelay = Ext.defer(me.onComponentFocus, 90, me, [cmp, e]);
+ return;
+ }
+
+ if (me.fireEvent('beforecomponentfocus', me, cmp, me.previousFocusedCmp) === false) {
+ me.clearComponent(cmp);
+ return;
+ }
+
+ me.focusedCmp = cmp;
+
+
+ if (me.shouldShowFocusFrame(cmp)) {
+ var cls = '.' + me.focusFrameCls + '-',
+ ff = me.focusFrame,
+ fw = me.focusFrameWidth,
+ box = cmp.el.getPageBox(),
+
+
+
+
+ bt = box.top,
+ bl = box.left,
+ bw = box.width,
+ bh = box.height,
+ ft = ff.child(cls + 'top'),
+ fb = ff.child(cls + 'bottom'),
+ fl = ff.child(cls + 'left'),
+ fr = ff.child(cls + 'right');
+
+ ft.setWidth(bw).setLeftTop(bl, bt);
+ fb.setWidth(bw).setLeftTop(bl, bt + bh - fw);
+ fl.setHeight(bh - fw - fw).setLeftTop(bl, bt + fw);
+ fr.setHeight(bh - fw - fw).setLeftTop(bl + bw - fw, bt + fw);
+
+ ff.show();
+ }
+
+ me.fireEvent('componentfocus', me, cmp, me.previousFocusedCmp);
+ },
+
+ onComponentHide: function(cmp) {
+ var me = this,
+ CQ = Ext.ComponentQuery,
+ cmpHadFocus = false,
+ focusedCmp,
+ parent;
+
+ if (me.focusedCmp) {
+ focusedCmp = CQ.query('[id=' + me.focusedCmp.id + ']', cmp)[0];
+ cmpHadFocus = me.focusedCmp.id === cmp.id || focusedCmp;
+
+ if (focusedCmp) {
+ me.clearComponent(focusedCmp);
+ }
+ }
+
+ me.clearComponent(cmp);
+
+ if (cmpHadFocus) {
+ parent = CQ.query('^:focusable', cmp)[0];
+ if (parent) {
+ parent.focus();
+ }
+ }
+ },
+
+ removeDOM: function() {
+ var me = this;
+
+
+
+ if (me.enabled || me.subscribers.length) {
+ return;
+ }
+
+ Ext.destroy(
+ me.focusEl,
+ me.focusFrame
+ );
+ delete me.focusEl;
+ delete me.focusFrame;
+ delete me.focusFrameWidth;
+ },
+
+
+ removeXTypeFromWhitelist: function(xtype) {
+ var me = this;
+
+ if (Ext.isArray(xtype)) {
+ Ext.Array.forEach(xtype, me.removeXTypeFromWhitelist, me);
+ return;
+ }
+
+ Ext.Array.remove(me.whitelist, xtype);
+ },
+
+ setFocus: function(cmp, focusable, options) {
+ var me = this,
+ el, dom, data,
+
+ needsTabIndex = function(n) {
+ return !Ext.Array.contains(me.tabIndexWhitelist, n.tagName.toLowerCase())
+ && n.tabIndex <= 0;
+ };
+
+ options = options || {};
+
+
+ if (!cmp.rendered) {
+ cmp.on('afterrender', Ext.pass(me.setFocus, arguments, me), me, { single: true });
+ return;
+ }
+
+ el = cmp.getFocusEl();
+ dom = el.dom;
+
+
+ if ((focusable && !me.focusData[cmp.id]) || (!focusable && me.focusData[cmp.id])) {
+ if (focusable) {
+ data = {
+ focusFrame: options.focusFrame
+ };
+
+
+
+
+
+ if (needsTabIndex(dom)) {
+ data.tabIndex = dom.tabIndex;
+ dom.tabIndex = -1;
+ }
+
+ el.on({
+ focus: data.focusFn = Ext.bind(me.onComponentFocus, me, [cmp], 0),
+ blur: data.blurFn = Ext.bind(me.onComponentBlur, me, [cmp], 0),
+ scope: me
+ });
+ cmp.on({
+ hide: me.onComponentHide,
+ close: me.onComponentHide,
+ beforedestroy: me.onComponentDestroy,
+ scope: me
+ });
+
+ me.focusData[cmp.id] = data;
+ } else {
+ data = me.focusData[cmp.id];
+ if ('tabIndex' in data) {
+ dom.tabIndex = data.tabIndex;
+ }
+ el.un('focus', data.focusFn, me);
+ el.un('blur', data.blurFn, me);
+ cmp.un('hide', me.onComponentHide, me);
+ cmp.un('close', me.onComponentHide, me);
+ cmp.un('beforedestroy', me.onComponentDestroy, me);
+
+ delete me.focusData[cmp.id];
+ }
+ }
+ },
+
+ setFocusAll: function(focusable, options) {
+ var me = this,
+ cmps = Ext.ComponentManager.all.getArray(),
+ len = cmps.length,
+ cmp,
+ i = 0;
+
+ for (; i < len; i++) {
+ me.setFocus(cmps[i], focusable, options);
+ }
+ },
+
+ setupSubscriberKeys: function(container, keys) {
+ var me = this,
+ el = container.getFocusEl(),
+ scope = keys.scope,
+ handlers = {
+ backspace: me.focusLast,
+ enter: me.navigateIn,
+ esc: me.navigateOut,
+ scope: me
+ },
+
+ navSiblings = function(e) {
+ if (me.focusedCmp === container) {
+
+
+
+ return me.navigateSiblings(e, me, container);
+ } else {
+ return me.navigateSiblings(e);
+ }
+ };
+
+ Ext.iterate(keys, function(key, cb) {
+ handlers[key] = function(e) {
+ var ret = navSiblings(e);
+
+ if (Ext.isFunction(cb) && cb.call(scope || container, e, ret) === true) {
+ return true;
+ }
+
+ return ret;
+ };
+ }, me);
+
+ return Ext.create('Ext.util.KeyNav', el, handlers);
+ },
+
+ shouldShowFocusFrame: function(cmp) {
+ var me = this,
+ opts = me.options || {};
+
+ if (!me.focusFrame || !cmp) {
+ return false;
+ }
+
+
+ if (opts.focusFrame) {
+ return true;
+ }
+
+ if (me.focusData[cmp.id].focusFrame) {
+ return true;
+ }
+
+ return false;
+ },
+
+
+ subscribe: function(container, options) {
+ var me = this,
+ EA = Ext.Array,
+ data = {},
+ subs = me.subscribers,
+
+
+
+
+ safeSetFocus = function(cmp) {
+ if (cmp.isContainer && !subs.containsKey(cmp.id)) {
+ EA.forEach(cmp.query('>'), safeSetFocus);
+ me.setFocus(cmp, true, options);
+ cmp.on('add', data.onAdd, me);
+ } else if (!cmp.isContainer) {
+ me.setFocus(cmp, true, options);
+ }
+ };
+
+
+ if (!container || !container.isContainer) {
+ return;
+ }
+
+ if (!container.rendered) {
+ container.on('afterrender', Ext.pass(me.subscribe, arguments, me), me, { single: true });
+ return;
+ }
+
+
+ me.initDOM(options);
+
+
+ data.keyNav = me.setupSubscriberKeys(container, options.keys);
+
+
+
+
+
+ data.onAdd = function(ct, cmp, idx) {
+ safeSetFocus(cmp);
+ };
+ container.on('beforedestroy', me.unsubscribe, me);
+
+
+ safeSetFocus(container);
+
+
+ subs.add(container.id, data);
+ },
+
+
+ unsubscribe: function(container) {
+ var me = this,
+ EA = Ext.Array,
+ subs = me.subscribers,
+ data,
+
+
+
+
+ safeSetFocus = function(cmp) {
+ if (cmp.isContainer && !subs.containsKey(cmp.id)) {
+ EA.forEach(cmp.query('>'), safeSetFocus);
+ me.setFocus(cmp, false);
+ cmp.un('add', data.onAdd, me);
+ } else if (!cmp.isContainer) {
+ me.setFocus(cmp, false);
+ }
+ };
+
+ if (!container || !subs.containsKey(container.id)) {
+ return;
+ }
+
+ data = subs.get(container.id);
+ data.keyNav.destroy();
+ container.un('beforedestroy', me.unsubscribe, me);
+ subs.removeAtKey(container.id);
+ safeSetFocus(container);
+ me.removeDOM();
+ }
+});
+
+Ext.define('Ext.toolbar.Toolbar', {
+ extend: 'Ext.container.Container',
+ requires: [
+ 'Ext.toolbar.Fill',
+ 'Ext.layout.container.HBox',
+ 'Ext.layout.container.VBox',
+ 'Ext.FocusManager'
+ ],
+ uses: [
+ 'Ext.toolbar.Separator'
+ ],
+ alias: 'widget.toolbar',
+ alternateClassName: 'Ext.Toolbar',
+
+ isToolbar: true,
+ baseCls : Ext.baseCSSPrefix + 'toolbar',
+ ariaRole : 'toolbar',
+
+ defaultType: 'button',
+
+
+ vertical: false,
+
+
+
+
+ enableOverflow: false,
+
+
+ menuTriggerCls: Ext.baseCSSPrefix + 'toolbar-more-icon',
+
+
+ trackMenus: true,
+
+ itemCls: Ext.baseCSSPrefix + 'toolbar-item',
+
+ initComponent: function() {
+ var me = this,
+ keys;
+
+
+ if (!me.layout && me.enableOverflow) {
+ me.layout = { overflowHandler: 'Menu' };
+ }
+
+ if (me.dock === 'right' || me.dock === 'left') {
+ me.vertical = true;
+ }
+
+ me.layout = Ext.applyIf(Ext.isString(me.layout) ? {
+ type: me.layout
+ } : me.layout || {}, {
+ type: me.vertical ? 'vbox' : 'hbox',
+ align: me.vertical ? 'stretchmax' : 'middle',
+ clearInnerCtOnLayout: true
+ });
+
+ if (me.vertical) {
+ me.addClsWithUI('vertical');
+ }
+
+
+ if (me.ui === 'footer') {
+ me.ignoreBorderManagement = true;
+ }
+
+ me.callParent();
+
+
+ me.addEvents('overflowchange');
+
+
+ keys = me.vertical ? ['up', 'down'] : ['left', 'right'];
+ Ext.FocusManager.subscribe(me, {
+ keys: keys
+ });
+ },
+
+ getRefItems: function(deep) {
+ var me = this,
+ items = me.callParent(arguments),
+ layout = me.layout,
+ handler;
+
+ if (deep && me.enableOverflow) {
+ handler = layout.overflowHandler;
+ if (handler && handler.menu) {
+ items = items.concat(handler.menu.getRefItems(deep));
+ }
+ }
+ return items;
+ },
+
+
+
+
+ lookupComponent: function(c) {
+ if (Ext.isString(c)) {
+ var shortcut = Ext.toolbar.Toolbar.shortcuts[c];
+ if (shortcut) {
+ c = {
+ xtype: shortcut
+ };
+ } else {
+ c = {
+ xtype: 'tbtext',
+ text: c
+ };
+ }
+ this.applyDefaults(c);
+ }
+ return this.callParent(arguments);
+ },
+
+
+ applyDefaults: function(c) {
+ if (!Ext.isString(c)) {
+ c = this.callParent(arguments);
+ var d = this.internalDefaults;
+ if (c.events) {
+ Ext.applyIf(c.initialConfig, d);
+ Ext.apply(c, d);
+ } else {
+ Ext.applyIf(c, d);
+ }
+ }
+ return c;
+ },
+
+
+ trackMenu: function(item, remove) {
+ if (this.trackMenus && item.menu) {
+ var method = remove ? 'mun' : 'mon',
+ me = this;
+
+ me[method](item, 'mouseover', me.onButtonOver, me);
+ me[method](item, 'menushow', me.onButtonMenuShow, me);
+ me[method](item, 'menuhide', me.onButtonMenuHide, me);
+ }
+ },
+
+
+ constructButton: function(item) {
+ return item.events ? item : this.createComponent(item, item.split ? 'splitbutton' : this.defaultType);
+ },
+
+
+ onBeforeAdd: function(component) {
+ if (component.is('field') || (component.is('button') && this.ui != 'footer')) {
+ component.ui = component.ui + '-toolbar';
+ }
+
+
+ if (component instanceof Ext.toolbar.Separator) {
+ component.setUI((this.vertical) ? 'vertical' : 'horizontal');
+ }
+
+ this.callParent(arguments);
+ },
+
+
+ onAdd: function(component) {
+ this.callParent(arguments);
+
+ this.trackMenu(component);
+ if (this.disabled) {
+ component.disable();
+ }
+ },
+
+
+ onRemove: function(c) {
+ this.callParent(arguments);
+ this.trackMenu(c, true);
+ },
+
+
+ onButtonOver: 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;
+ }
+}, function() {
+ this.shortcuts = {
+ '-' : 'tbseparator',
+ ' ' : 'tbspacer',
+ '->': 'tbfill'
+ };
+});
+
+Ext.define('Ext.panel.AbstractPanel', {
+
+
+
+ extend: 'Ext.container.Container',
+
+ requires: ['Ext.util.MixedCollection', 'Ext.Element', 'Ext.toolbar.Toolbar'],
+
+
+
+
+ baseCls : Ext.baseCSSPrefix + 'panel',
+
+
+
+
+
+
+
+
+
+ isPanel: true,
+
+ componentLayout: 'dock',
+
+
+ defaultDockWeights: { top: 1, left: 3, right: 5, bottom: 7 },
+
+ renderTpl: [
+ '<div id="{id}-body" class="{baseCls}-body<tpl if="bodyCls"> {bodyCls}</tpl>',
+ ' {baseCls}-body-{ui}<tpl if="uiCls">',
+ '<tpl for="uiCls"> {parent.baseCls}-body-{parent.ui}-{.}</tpl>',
+ '</tpl>"<tpl if="bodyStyle"> style="{bodyStyle}"</tpl>>',
+ '</div>'
+ ],
+
+
+
+
+ border: true,
+
+ initComponent : function() {
+ var me = this;
+
+ me.addEvents(
+
+ 'bodyresize'
+
+
+
+
+ );
+
+ me.addChildEls('body');
+
+
+
+
+ if (me.frame && me.border && me.bodyBorder === undefined) {
+ me.bodyBorder = false;
+ }
+ if (me.frame && me.border && (me.bodyBorder === false || me.bodyBorder === 0)) {
+ me.manageBodyBorders = true;
+ }
+
+ me.callParent();
+ },
+
+
+ initItems : function() {
+ var me = this,
+ items = me.dockedItems;
+
+ me.callParent();
+ me.dockedItems = Ext.create('Ext.util.MixedCollection', false, me.getComponentId);
+ if (items) {
+ me.addDocked(items);
+ }
+ },
+
+
+ getDockedComponent: function(comp) {
+ if (Ext.isObject(comp)) {
+ comp = comp.getItemId();
+ }
+ return this.dockedItems.get(comp);
+ },
+
+
+ getComponent: function(comp) {
+ var component = this.callParent(arguments);
+ if (component === undefined && !Ext.isNumber(comp)) {
+
+ component = this.getDockedComponent(comp);
+ }
+ return component;
+ },
+
+
+ initBodyStyles: function() {
+ var me = this,
+ bodyStyle = me.bodyStyle,
+ styles = [],
+ Element = Ext.Element,
+ prop;
+
+ if (Ext.isFunction(bodyStyle)) {
+ bodyStyle = bodyStyle();
+ }
+ if (Ext.isString(bodyStyle)) {
+ styles = bodyStyle.split(';');
+ } else {
+ for (prop in bodyStyle) {
+ if (bodyStyle.hasOwnProperty(prop)) {
+ styles.push(prop + ':' + bodyStyle[prop]);
+ }
+ }
+ }
+
+ if (me.bodyPadding !== undefined) {
+ styles.push('padding: ' + Element.unitizeBox((me.bodyPadding === true) ? 5 : me.bodyPadding));
+ }
+ if (me.frame && me.bodyBorder) {
+ if (!Ext.isNumber(me.bodyBorder)) {
+ me.bodyBorder = 1;
+ }
+ styles.push('border-width: ' + Element.unitizeBox(me.bodyBorder));
+ }
+ delete me.bodyStyle;
+ return styles.length ? styles.join(';') : undefined;
+ },
+
+
+ initBodyCls: function() {
+ var me = this,
+ cls = '',
+ bodyCls = me.bodyCls;
+
+ if (bodyCls) {
+ Ext.each(bodyCls, function(v) {
+ cls += " " + v;
+ });
+ delete me.bodyCls;
+ }
+ return cls.length > 0 ? cls : undefined;
+ },
+
+
+ initRenderData: function() {
+ return Ext.applyIf(this.callParent(), {
+ bodyStyle: this.initBodyStyles(),
+ bodyCls: this.initBodyCls()
+ });
+ },
+
+
+ addDocked : function(items, pos) {
+ var me = this,
+ i = 0,
+ item, length;
+
+ items = me.prepareItems(items);
+ length = items.length;
+
+ for (; i < length; i++) {
+ item = items[i];
+ item.dock = item.dock || 'top';
+
+
+ if (me.border === false) {
+
+ }
+
+ if (pos !== undefined) {
+ me.dockedItems.insert(pos + i, item);
+ }
+ else {
+ me.dockedItems.add(item);
+ }
+ item.onAdded(me, i);
+ me.onDockedAdd(item);
+ }
+
+
+ me.componentLayout.childrenChanged = true;
+ if (me.rendered && !me.suspendLayout) {
+ me.doComponentLayout();
+ }
+ return items;
+ },
+
+
+ onDockedAdd : Ext.emptyFn,
+ onDockedRemove : Ext.emptyFn,
+
+
+ insertDocked : function(pos, items) {
+ this.addDocked(items, pos);
+ },
+
+
+ removeDocked : function(item, autoDestroy) {
+ var me = this,
+ layout,
+ hasLayout;
+
+ if (!me.dockedItems.contains(item)) {
+ return item;
+ }
+
+ layout = me.componentLayout;
+ hasLayout = layout && me.rendered;
+
+ if (hasLayout) {
+ layout.onRemove(item);
+ }
+
+ me.dockedItems.remove(item);
+ item.onRemoved();
+ me.onDockedRemove(item);
+
+ if (autoDestroy === true || (autoDestroy !== false && me.autoDestroy)) {
+ item.destroy();
+ } else if (hasLayout) {
+
+ layout.afterRemove(item);
+ }
+
+
+
+ me.componentLayout.childrenChanged = true;
+ if (!me.destroying && !me.suspendLayout) {
+ me.doComponentLayout();
+ }
+
+ return item;
+ },
+
+
+ getDockedItems : function(cqSelector) {
+ var me = this,
+ defaultWeight = me.defaultDockWeights,
+ dockedItems;
+
+ if (me.dockedItems && me.dockedItems.items.length) {
+
+ if (cqSelector) {
+ dockedItems = Ext.ComponentQuery.query(cqSelector, me.dockedItems.items);
+ } else {
+ dockedItems = me.dockedItems.items.slice();
+ }
+
+ Ext.Array.sort(dockedItems, function(a, b) {
+
+ var aw = a.weight || defaultWeight[a.dock],
+ bw = b.weight || defaultWeight[b.dock];
+ if (Ext.isNumber(aw) && Ext.isNumber(bw)) {
+ return aw - bw;
+ }
+ return 0;
+ });
+
+ return dockedItems;
+ }
+ return [];
+ },
+
+
+ addUIClsToElement: function(cls, force) {
+ var me = this,
+ result = me.callParent(arguments),
+ classes = [Ext.baseCSSPrefix + cls, me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls],
+ array, i;
+
+ if (!force && me.rendered) {
+ if (me.bodyCls) {
+ me.body.addCls(me.bodyCls);
+ } else {
+ me.body.addCls(classes);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+
+ for (i = 0; i < classes.length; i++) {
+ if (!Ext.Array.contains(array, classes[i])) {
+ array.push(classes[i]);
+ }
+ }
+
+ me.bodyCls = array.join(' ');
+ } else {
+ me.bodyCls = classes.join(' ');
+ }
+ }
+
+ return result;
+ },
+
+
+ removeUIClsFromElement: function(cls, force) {
+ var me = this,
+ result = me.callParent(arguments),
+ classes = [Ext.baseCSSPrefix + cls, me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls],
+ array, i;
+
+ if (!force && me.rendered) {
+ if (me.bodyCls) {
+ me.body.removeCls(me.bodyCls);
+ } else {
+ me.body.removeCls(classes);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+
+ for (i = 0; i < classes.length; i++) {
+ Ext.Array.remove(array, classes[i]);
+ }
+
+ me.bodyCls = array.join(' ');
+ }
+ }
+
+ return result;
+ },
+
+
+ addUIToElement: function(force) {
+ var me = this,
+ cls = me.baseCls + '-body-' + me.ui,
+ array;
+
+ me.callParent(arguments);
+
+ if (!force && me.rendered) {
+ if (me.bodyCls) {
+ me.body.addCls(me.bodyCls);
+ } else {
+ me.body.addCls(cls);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+
+ if (!Ext.Array.contains(array, cls)) {
+ array.push(cls);
+ }
+
+ me.bodyCls = array.join(' ');
+ } else {
+ me.bodyCls = cls;
+ }
+ }
+ },
+
+
+ removeUIFromElement: function() {
+ var me = this,
+ cls = me.baseCls + '-body-' + me.ui,
+ array;
+
+ me.callParent(arguments);
+
+ if (me.rendered) {
+ if (me.bodyCls) {
+ me.body.removeCls(me.bodyCls);
+ } else {
+ me.body.removeCls(cls);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+ Ext.Array.remove(array, cls);
+ me.bodyCls = array.join(' ');
+ } else {
+ me.bodyCls = cls;
+ }
+ }
+ },
+
+
+ getTargetEl : function() {
+ return this.body;
+ },
+
+ getRefItems: function(deep) {
+ var items = this.callParent(arguments),
+
+ dockedItems = this.getDockedItems(deep ? '*,* *' : undefined),
+ ln = dockedItems.length,
+ i = 0,
+ item;
+
+
+ for (; i < ln; i++) {
+ item = dockedItems[i];
+ if (item.dock === 'right' || item.dock === 'bottom') {
+ break;
+ }
+ }
+
+
+
+
+ return Ext.Array.splice(dockedItems, 0, i).concat(items).concat(dockedItems);
+ },
+
+ beforeDestroy: function(){
+ var docked = this.dockedItems,
+ c;
+
+ if (docked) {
+ while ((c = docked.first())) {
+ this.removeDocked(c, true);
+ }
+ }
+ this.callParent();
+ },
+
+ setBorder: function(border) {
+ var me = this;
+ me.border = (border !== undefined) ? border : true;
+ if (me.rendered) {
+ me.doComponentLayout();
+ }
+ }
+});
+
+Ext.define('Ext.panel.Header', {
+ extend: 'Ext.container.Container',
+ uses: ['Ext.panel.Tool', 'Ext.draw.Component', 'Ext.util.CSS'],
+ alias: 'widget.header',
+
+ isHeader : true,
+ defaultType : 'tool',
+ indicateDrag : false,
+ weight : -1,
+
+ renderTpl: [
+ '<div id="{id}-body" class="{baseCls}-body<tpl if="bodyCls"> {bodyCls}</tpl>',
+ '<tpl if="uiCls">',
+ '<tpl for="uiCls"> {parent.baseCls}-body-{parent.ui}-{.}</tpl>',
+ '</tpl>"',
+ '<tpl if="bodyStyle"> style="{bodyStyle}"</tpl>></div>'],
+
+
+
+
+
+ initComponent: function() {
+ var me = this,
+ ruleStyle,
+ rule,
+ style,
+ titleTextEl,
+ ui;
+
+ me.indicateDragCls = me.baseCls + '-draggable';
+ me.title = me.title || ' ';
+ me.tools = me.tools || [];
+ me.items = me.items || [];
+ me.orientation = me.orientation || 'horizontal';
+ me.dock = (me.dock) ? me.dock : (me.orientation == 'horizontal') ? 'top' : 'left';
+
+
+
+ me.addClsWithUI(me.orientation);
+ me.addClsWithUI(me.dock);
+
+ me.addChildEls('body');
+
+
+ if (!Ext.isEmpty(me.iconCls)) {
+ me.initIconCmp();
+ me.items.push(me.iconCmp);
+ }
+
+
+ if (me.orientation == 'vertical') {
+
+ if (Ext.isIE6 || Ext.isIE7) {
+ me.width = this.width || 24;
+ } else if (Ext.isIEQuirks) {
+ me.width = this.width || 25;
+ }
+
+ me.layout = {
+ type : 'vbox',
+ align: 'center',
+ clearInnerCtOnLayout: true,
+ bindToOwnerCtContainer: false
+ };
+ me.textConfig = {
+ cls: me.baseCls + '-text',
+ type: 'text',
+ text: me.title,
+ rotate: {
+ degrees: 90
+ }
+ };
+ ui = me.ui;
+ if (Ext.isArray(ui)) {
+ ui = ui[0];
+ }
+ ruleStyle = '.' + me.baseCls + '-text-' + ui;
+ if (Ext.scopeResetCSS) {
+ ruleStyle = '.' + Ext.baseCSSPrefix + 'reset ' + ruleStyle;
+ }
+ rule = Ext.util.CSS.getRule(ruleStyle);
+ if (rule) {
+ style = rule.style;
+ }
+ if (style) {
+ Ext.apply(me.textConfig, {
+ 'font-family': style.fontFamily,
+ 'font-weight': style.fontWeight,
+ 'font-size': style.fontSize,
+ fill: style.color
+ });
+ }
+ me.titleCmp = Ext.create('Ext.draw.Component', {
+ ariaRole : 'heading',
+ focusable: false,
+ viewBox: false,
+ flex : 1,
+ autoSize: true,
+ margins: '5 0 0 0',
+ items: [ me.textConfig ],
+
+
+ renderSelectors: {
+ textEl: '.' + me.baseCls + '-text'
+ }
+ });
+ } else {
+ me.layout = {
+ type : 'hbox',
+ align: 'middle',
+ clearInnerCtOnLayout: true,
+ bindToOwnerCtContainer: false
+ };
+ me.titleCmp = Ext.create('Ext.Component', {
+ xtype : 'component',
+ ariaRole : 'heading',
+ focusable: false,
+ flex : 1,
+ cls: me.baseCls + '-text-container',
+ renderTpl : [
+ '<span id="{id}-textEl" class="{cls}-text {cls}-text-{ui}">{title}</span>'
+ ],
+ renderData: {
+ title: me.title,
+ cls : me.baseCls,
+ ui : me.ui
+ },
+ childEls: ['textEl']
+ });
+ }
+ me.items.push(me.titleCmp);
+
+
+ me.items = me.items.concat(me.tools);
+ this.callParent();
+ },
+
+ initIconCmp: function() {
+ this.iconCmp = Ext.create('Ext.Component', {
+ focusable: false,
+ renderTpl : [
+ '<img id="{id}-iconEl" alt="" src="{blank}" class="{cls}-icon {iconCls}"/>'
+ ],
+ renderData: {
+ blank : Ext.BLANK_IMAGE_URL,
+ cls : this.baseCls,
+ iconCls: this.iconCls,
+ orientation: this.orientation
+ },
+ childEls: ['iconEl'],
+ iconCls: this.iconCls
+ });
+ },
+
+ afterRender: function() {
+ var me = this;
+
+ me.el.unselectable();
+ if (me.indicateDrag) {
+ me.el.addCls(me.indicateDragCls);
+ }
+ me.mon(me.el, {
+ click: me.onClick,
+ scope: me
+ });
+ me.callParent();
+ },
+
+ afterLayout: function() {
+ var me = this;
+ me.callParent(arguments);
+
+
+ if (Ext.isIE7) {
+ me.el.repaint();
+ }
+ },
+
+
+ addUIClsToElement: function(cls, force) {
+ var me = this,
+ result = me.callParent(arguments),
+ classes = [me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls],
+ array, i;
+
+ if (!force && me.rendered) {
+ if (me.bodyCls) {
+ me.body.addCls(me.bodyCls);
+ } else {
+ me.body.addCls(classes);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+
+ for (i = 0; i < classes.length; i++) {
+ if (!Ext.Array.contains(array, classes[i])) {
+ array.push(classes[i]);
+ }
+ }
+
+ me.bodyCls = array.join(' ');
+ } else {
+ me.bodyCls = classes.join(' ');
+ }
+ }
+
+ return result;
+ },
+
+
+ removeUIClsFromElement: function(cls, force) {
+ var me = this,
+ result = me.callParent(arguments),
+ classes = [me.baseCls + '-body-' + cls, me.baseCls + '-body-' + me.ui + '-' + cls],
+ array, i;
+
+ if (!force && me.rendered) {
+ if (me.bodyCls) {
+ me.body.removeCls(me.bodyCls);
+ } else {
+ me.body.removeCls(classes);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+
+ for (i = 0; i < classes.length; i++) {
+ Ext.Array.remove(array, classes[i]);
+ }
+
+ me.bodyCls = array.join(' ');
+ }
+ }
+
+ return result;
+ },
+
+
+ addUIToElement: function(force) {
+ var me = this,
+ array, cls;
+
+ me.callParent(arguments);
+
+ cls = me.baseCls + '-body-' + me.ui;
+ if (!force && me.rendered) {
+ if (me.bodyCls) {
+ me.body.addCls(me.bodyCls);
+ } else {
+ me.body.addCls(cls);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+
+ if (!Ext.Array.contains(array, cls)) {
+ array.push(cls);
+ }
+
+ me.bodyCls = array.join(' ');
+ } else {
+ me.bodyCls = cls;
+ }
+ }
+
+ if (!force && me.titleCmp && me.titleCmp.rendered && me.titleCmp.textEl) {
+ me.titleCmp.textEl.addCls(me.baseCls + '-text-' + me.ui);
+ }
+ },
+
+
+ removeUIFromElement: function() {
+ var me = this,
+ array, cls;
+
+ me.callParent(arguments);
+
+ cls = me.baseCls + '-body-' + me.ui;
+ if (me.rendered) {
+ if (me.bodyCls) {
+ me.body.removeCls(me.bodyCls);
+ } else {
+ me.body.removeCls(cls);
+ }
+ } else {
+ if (me.bodyCls) {
+ array = me.bodyCls.split(' ');
+ Ext.Array.remove(array, cls);
+ me.bodyCls = array.join(' ');
+ } else {
+ me.bodyCls = cls;
+ }
+ }
+
+ if (me.titleCmp && me.titleCmp.rendered && me.titleCmp.textEl) {
+ me.titleCmp.textEl.removeCls(me.baseCls + '-text-' + me.ui);
+ }
+ },
+
+ onClick: function(e) {
+ if (!e.getTarget(Ext.baseCSSPrefix + 'tool')) {
+ this.fireEvent('click', e);
+ }
+ },
+
+ getTargetEl: function() {
+ return this.body || this.frameBody || this.el;
+ },
+
+
+ setTitle: function(title) {
+ var me = this;
+ if (me.rendered) {
+ if (me.titleCmp.rendered) {
+ if (me.titleCmp.surface) {
+ me.title = title || '';
+ var sprite = me.titleCmp.surface.items.items[0],
+ surface = me.titleCmp.surface;
+
+ surface.remove(sprite);
+ me.textConfig.type = 'text';
+ me.textConfig.text = title;
+ sprite = surface.add(me.textConfig);
+ sprite.setAttributes({
+ rotate: {
+ degrees: 90
+ }
+ }, true);
+ me.titleCmp.autoSizeSurface();
+ } else {
+ me.title = title || ' ';
+ me.titleCmp.textEl.update(me.title);
+ }
+ } else {
+ me.titleCmp.on({
+ render: function() {
+ me.setTitle(title);
+ },
+ single: true
+ });
+ }
+ } else {
+ me.on({
+ render: function() {
+ me.layout.layout();
+ me.setTitle(title);
+ },
+ single: true
+ });
+ }
+ },
+
+
+ setIconCls: function(cls) {
+ var me = this,
+ isEmpty = !cls || !cls.length,
+ iconCmp = me.iconCmp,
+ el;
+
+ me.iconCls = cls;
+ if (!me.iconCmp && !isEmpty) {
+ me.initIconCmp();
+ me.insert(0, me.iconCmp);
+ } else if (iconCmp) {
+ if (isEmpty) {
+ me.iconCmp.destroy();
+ } else {
+ el = iconCmp.iconEl;
+ el.removeCls(iconCmp.iconCls);
+ el.addCls(cls);
+ iconCmp.iconCls = cls;
+ }
+ }
+ },
+
+
+ addTool: function(tool) {
+ this.tools.push(this.add(tool));
+ },
+
+
+ onAdd: function(component, index) {
+ this.callParent([arguments]);
+ if (component instanceof Ext.panel.Tool) {
+ component.bindTo(this.ownerCt);
+ this.tools[component.type] = component;
+ }
+ }
+});
+
+
+Ext.define('Ext.fx.target.Element', {
+
+
+
+ extend: 'Ext.fx.target.Target',
+
+
+
+ type: 'element',
+
+ getElVal: function(el, attr, val) {
+ if (val == undefined) {
+ if (attr === 'x') {
+ val = el.getX();
+ }
+ else if (attr === 'y') {
+ val = el.getY();
+ }
+ else if (attr === 'scrollTop') {
+ val = el.getScroll().top;
+ }
+ else if (attr === 'scrollLeft') {
+ val = el.getScroll().left;
+ }
+ else if (attr === 'height') {
+ val = el.getHeight();
+ }
+ else if (attr === 'width') {
+ val = el.getWidth();
+ }
+ else {
+ val = el.getStyle(attr);
+ }
+ }
+ return val;
+ },
+
+ getAttr: function(attr, val) {
+ var el = this.target;
+ return [[ el, this.getElVal(el, attr, val)]];
+ },
+
+ setAttr: function(targetData) {
+ var target = this.target,
+ ln = targetData.length,
+ attrs, attr, o, i, j, ln2, element, value;
+ for (i = 0; i < ln; i++) {
+ attrs = targetData[i].attrs;
+ for (attr in attrs) {
+ if (attrs.hasOwnProperty(attr)) {
+ ln2 = attrs[attr].length;
+ for (j = 0; j < ln2; j++) {
+ o = attrs[attr][j];
+ element = o[0];
+ value = o[1];
+ if (attr === 'x') {
+ element.setX(value);
+ }
+ else if (attr === 'y') {
+ element.setY(value);
+ }
+ else if (attr === 'scrollTop') {
+ element.scrollTo('top', value);
+ }
+ else if (attr === 'scrollLeft') {
+ element.scrollTo('left',value);
+ }
+ else {
+ element.setStyle(attr, value);
+ }
+ }
+ }
+ }
+ }
+ }
+});
+
+
+Ext.define('Ext.fx.target.CompositeElement', {
+
+
+
+ extend: 'Ext.fx.target.Element',
+
+
+
+ isComposite: true,
+
+ constructor: function(target) {
+ target.id = target.id || Ext.id(null, 'ext-composite-');
+ this.callParent([target]);
+ },
+
+ getAttr: function(attr, val) {
+ var out = [],
+ target = this.target;
+ target.each(function(el) {
+ out.push([el, this.getElVal(el, attr, val)]);
+ }, this);
+ return out;
+ }
+});
+
+
+
+Ext.define('Ext.fx.Manager', {
+
+
+
+ singleton: true,
+
+ requires: ['Ext.util.MixedCollection',
+ 'Ext.fx.target.Element',
+ 'Ext.fx.target.CompositeElement',
+ 'Ext.fx.target.Sprite',
+ 'Ext.fx.target.CompositeSprite',
+ 'Ext.fx.target.Component'],
+
+ mixins: {
+ queue: 'Ext.fx.Queue'
+ },
+
+
+
+ constructor: function() {
+ this.items = Ext.create('Ext.util.MixedCollection');
+ this.mixins.queue.constructor.call(this);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ },
+
+
+ interval: 16,
+
+
+ forceJS: true,
+
+
+ createTarget: function(target) {
+ var me = this,
+ useCSS3 = !me.forceJS && Ext.supports.Transitions,
+ targetObj;
+
+ me.useCSS3 = useCSS3;
+
+
+ if (Ext.isString(target)) {
+ target = Ext.get(target);
+ }
+
+ if (target && target.tagName) {
+ target = Ext.get(target);
+ targetObj = Ext.create('Ext.fx.target.' + 'Element' + (useCSS3 ? 'CSS' : ''), target);
+ me.targets.add(targetObj);
+ return targetObj;
+ }
+ if (Ext.isObject(target)) {
+
+ if (target.dom) {
+ targetObj = Ext.create('Ext.fx.target.' + 'Element' + (useCSS3 ? 'CSS' : ''), target);
+ }
+
+ else if (target.isComposite) {
+ targetObj = Ext.create('Ext.fx.target.' + 'CompositeElement' + (useCSS3 ? 'CSS' : ''), target);
+ }
+
+ else if (target.isSprite) {
+ targetObj = Ext.create('Ext.fx.target.Sprite', target);
+ }
+
+ else if (target.isCompositeSprite) {
+ targetObj = Ext.create('Ext.fx.target.CompositeSprite', target);
+ }
+
+ else if (target.isComponent) {
+ targetObj = Ext.create('Ext.fx.target.Component', target);
+ }
+ else if (target.isAnimTarget) {
+ return target;
+ }
+ else {
+ return null;
+ }
+ me.targets.add(targetObj);
+ return targetObj;
+ }
+ else {
+ return null;
+ }
+ },
+
+
+ addAnim: function(anim) {
+ var items = this.items,
+ task = this.task;
+
+
+
+
+
+
+
+
+
+
+
+
+
+ items.add(anim);
+
+
+ if (!task && items.length) {
+ task = this.task = {
+ run: this.runner,
+ interval: this.interval,
+ scope: this
+ };
+ Ext.TaskManager.start(task);
+ }
+
+
+
+
+
+ },
+
+
+ removeAnim: function(anim) {
+
+ var items = this.items,
+ task = this.task;
+ items.remove(anim);
+
+ if (task && !items.length) {
+ Ext.TaskManager.stop(task);
+ delete this.task;
+ }
+ },
+
+
+ startingFilter: function(o) {
+ return o.paused === false && o.running === false && o.iterations > 0;
+ },
+
+
+ runningFilter: function(o) {
+ return o.paused === false && o.running === true && o.isAnimator !== true;
+ },
+
+
+ runner: function() {
+ var me = this,
+ items = me.items;
+
+ me.targetData = {};
+ me.targetArr = {};
+
+
+ me.timestamp = new Date();
+
+
+ items.filterBy(me.startingFilter).each(me.startAnim, me);
+
+
+ items.filterBy(me.runningFilter).each(me.runAnim, me);
+
+
+ me.applyPendingAttrs();
+ },
+
+
+ startAnim: function(anim) {
+ anim.start(this.timestamp);
+ },
+
+
+ runAnim: function(anim) {
+ if (!anim) {
+ return;
+ }
+ var me = this,
+ targetId = anim.target.getId(),
+ useCSS3 = me.useCSS3 && anim.target.type == 'element',
+ elapsedTime = me.timestamp - anim.startTime,
+ target, o;
+
+ this.collectTargetData(anim, elapsedTime, useCSS3);
+
+
+
+ if (useCSS3) {
+
+ anim.target.setAttr(me.targetData[targetId], true);
+
+
+ me.targetData[targetId] = [];
+ me.collectTargetData(anim, anim.duration, useCSS3);
+
+
+ anim.paused = true;
+
+ target = anim.target.target;
+
+ if (anim.target.isComposite) {
+ target = anim.target.target.last();
+ }
+
+
+ o = {};
+ o[Ext.supports.CSS3TransitionEnd] = anim.lastFrame;
+ o.scope = anim;
+ o.single = true;
+ target.on(o);
+ }
+
+ else if (elapsedTime >= anim.duration) {
+ me.applyPendingAttrs(true);
+ delete me.targetData[targetId];
+ delete me.targetArr[targetId];
+ anim.lastFrame();
+ }
+ },
+
+
+ collectTargetData: function(anim, elapsedTime, useCSS3) {
+ var targetId = anim.target.getId(),
+ targetData = this.targetData[targetId],
+ data;
+
+ if (!targetData) {
+ targetData = this.targetData[targetId] = [];
+ this.targetArr[targetId] = anim.target;
+ }
+
+ data = {
+ duration: anim.duration,
+ easing: (useCSS3 && anim.reverse) ? anim.easingFn.reverse().toCSS3() : anim.easing,
+ attrs: {}
+ };
+ Ext.apply(data.attrs, anim.runAnim(elapsedTime));
+ targetData.push(data);
+ },
+
+
+ applyPendingAttrs: function(isLastFrame) {
+ var targetData = this.targetData,
+ targetArr = this.targetArr,
+ targetId;
+ for (targetId in targetData) {
+ if (targetData.hasOwnProperty(targetId)) {
+ targetArr[targetId].setAttr(targetData[targetId], false, isLastFrame);
+ }
+ }
+ }
+});
+
+
+Ext.define('Ext.fx.Animator', {
+
+
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ requires: ['Ext.fx.Manager'],
+
+
+
+ isAnimator: true,
+
+
+ duration: 250,
+
+
+ delay: 0,
+
+
+ delayStart: 0,
+
+
+ dynamic: false,
+
+
+ easing: 'ease',
+
+
+ running: false,
+
+
+ paused: false,
+
+
+ damper: 1,
+
+
+ iterations: 1,
+
+
+ currentIteration: 0,
+
+
+ keyframeStep: 0,
+
+
+ animKeyFramesRE: /^(from|to|\d+%?)$/,
+
+
+
+
+ constructor: function(config) {
+ var me = this;
+ config = Ext.apply(me, config || {});
+ me.config = config;
+ me.id = Ext.id(null, 'ext-animator-');
+ me.addEvents(
+
+ 'beforeanimate',
+
+ 'keyframe',
+
+ 'afteranimate'
+ );
+ me.mixins.observable.constructor.call(me, config);
+ me.timeline = [];
+ me.createTimeline(me.keyframes);
+ if (me.target) {
+ me.applyAnimator(me.target);
+ Ext.fx.Manager.addAnim(me);
+ }
+ },
+
+
+ sorter: function (a, b) {
+ return a.pct - b.pct;
+ },
+
+
+ createTimeline: function(keyframes) {
+ var me = this,
+ attrs = [],
+ to = me.to || {},
+ duration = me.duration,
+ prevMs, ms, i, ln, pct, anim, nextAnim, attr;
+
+ for (pct in keyframes) {
+ if (keyframes.hasOwnProperty(pct) && me.animKeyFramesRE.test(pct)) {
+ attr = {attrs: Ext.apply(keyframes[pct], to)};
+
+ if (pct == "from") {
+ pct = 0;
+ }
+ else if (pct == "to") {
+ pct = 100;
+ }
+
+ attr.pct = parseInt(pct, 10);
+ attrs.push(attr);
+ }
+ }
+
+ Ext.Array.sort(attrs, me.sorter);
+
+
+
+
+
+ ln = attrs.length;
+ for (i = 0; i < ln; i++) {
+ prevMs = (attrs[i - 1]) ? duration * (attrs[i - 1].pct / 100) : 0;
+ ms = duration * (attrs[i].pct / 100);
+ me.timeline.push({
+ duration: ms - prevMs,
+ attrs: attrs[i].attrs
+ });
+ }
+ },
+
+
+ applyAnimator: function(target) {
+ var me = this,
+ anims = [],
+ timeline = me.timeline,
+ reverse = me.reverse,
+ ln = timeline.length,
+ anim, easing, damper, initial, attrs, lastAttrs, i;
+
+ if (me.fireEvent('beforeanimate', me) !== false) {
+ for (i = 0; i < ln; i++) {
+ anim = timeline[i];
+ attrs = anim.attrs;
+ easing = attrs.easing || me.easing;
+ damper = attrs.damper || me.damper;
+ delete attrs.easing;
+ delete attrs.damper;
+ anim = Ext.create('Ext.fx.Anim', {
+ target: target,
+ easing: easing,
+ damper: damper,
+ duration: anim.duration,
+ paused: true,
+ to: attrs
+ });
+ anims.push(anim);
+ }
+ me.animations = anims;
+ me.target = anim.target;
+ for (i = 0; i < ln - 1; i++) {
+ anim = anims[i];
+ anim.nextAnim = anims[i + 1];
+ anim.on('afteranimate', function() {
+ this.nextAnim.paused = false;
+ });
+ anim.on('afteranimate', function() {
+ this.fireEvent('keyframe', this, ++this.keyframeStep);
+ }, me);
+ }
+ anims[ln - 1].on('afteranimate', function() {
+ this.lastFrame();
+ }, me);
+ }
+ },
+
+
+ start: function(startTime) {
+ var me = this,
+ delay = me.delay,
+ delayStart = me.delayStart,
+ delayDelta;
+ if (delay) {
+ if (!delayStart) {
+ me.delayStart = startTime;
+ return;
+ }
+ else {
+ delayDelta = startTime - delayStart;
+ if (delayDelta < delay) {
+ return;
+ }
+ else {
+
+ startTime = new Date(delayStart.getTime() + delay);
+ }
+ }
+ }
+ if (me.fireEvent('beforeanimate', me) !== false) {
+ me.startTime = startTime;
+ me.running = true;
+ me.animations[me.keyframeStep].paused = false;
+ }
+ },
+
+
+ lastFrame: function() {
+ var me = this,
+ iter = me.iterations,
+ iterCount = me.currentIteration;
+
+ iterCount++;
+ if (iterCount < iter) {
+ me.startTime = new Date();
+ me.currentIteration = iterCount;
+ me.keyframeStep = 0;
+ me.applyAnimator(me.target);
+ me.animations[me.keyframeStep].paused = false;
+ }
+ else {
+ me.currentIteration = 0;
+ me.end();
+ }
+ },
+
+
+ end: function() {
+ var me = this;
+ me.fireEvent('afteranimate', me, me.startTime, new Date() - me.startTime);
+ }
+});
+
+Ext.ns('Ext.fx');
+
+Ext.require('Ext.fx.CubicBezier', function() {
+ var math = Math,
+ pi = math.PI,
+ pow = math.pow,
+ sin = math.sin,
+ sqrt = math.sqrt,
+ abs = math.abs,
+ backInSeed = 1.70158;
+ Ext.fx.Easing = {
+
+
+
+
+
+
+
+
+ };
+
+ Ext.apply(Ext.fx.Easing, {
+ linear: function(n) {
+ return n;
+ },
+ ease: function(n) {
+ var q = 0.07813 - n / 2,
+ alpha = -0.25,
+ Q = sqrt(0.0066 + q * q),
+ x = Q - q,
+ X = pow(abs(x), 1/3) * (x < 0 ? -1 : 1),
+ y = -Q - q,
+ Y = pow(abs(y), 1/3) * (y < 0 ? -1 : 1),
+ t = X + Y + 0.25;
+ return pow(1 - t, 2) * 3 * t * 0.1 + (1 - t) * 3 * t * t + t * t * t;
+ },
+ easeIn: function (n) {
+ return pow(n, 1.7);
+ },
+ easeOut: function (n) {
+ return pow(n, 0.48);
+ },
+ easeInOut: function(n) {
+ var q = 0.48 - n / 1.04,
+ Q = sqrt(0.1734 + q * q),
+ x = Q - q,
+ X = pow(abs(x), 1/3) * (x < 0 ? -1 : 1),
+ y = -Q - q,
+ Y = pow(abs(y), 1/3) * (y < 0 ? -1 : 1),
+ t = X + Y + 0.5;
+ return (1 - t) * 3 * t * t + t * t * t;
+ },
+ backIn: function (n) {
+ return n * n * ((backInSeed + 1) * n - backInSeed);
+ },
+ backOut: function (n) {
+ n = n - 1;
+ return n * n * ((backInSeed + 1) * n + backInSeed) + 1;
+ },
+ elasticIn: function (n) {
+ if (n === 0 || n === 1) {
+ return n;
+ }
+ var p = 0.3,
+ s = p / 4;
+ return pow(2, -10 * n) * sin((n - s) * (2 * pi) / p) + 1;
+ },
+ elasticOut: function (n) {
+ return 1 - Ext.fx.Easing.elasticIn(1 - n);
+ },
+ bounceIn: function (n) {
+ return 1 - Ext.fx.Easing.bounceOut(1 - n);
+ },
+ bounceOut: function (n) {
+ var s = 7.5625,
+ p = 2.75,
+ l;
+ if (n < (1 / p)) {
+ l = s * n * n;
+ } else {
+ if (n < (2 / p)) {
+ n -= (1.5 / p);
+ l = s * n * n + 0.75;
+ } else {
+ if (n < (2.5 / p)) {
+ n -= (2.25 / p);
+ l = s * n * n + 0.9375;
+ } else {
+ n -= (2.625 / p);
+ l = s * n * n + 0.984375;
+ }
+ }
+ }
+ return l;
+ }
+ });
+ Ext.apply(Ext.fx.Easing, {
+ 'back-in': Ext.fx.Easing.backIn,
+ 'back-out': Ext.fx.Easing.backOut,
+ 'ease-in': Ext.fx.Easing.easeIn,
+ 'ease-out': Ext.fx.Easing.easeOut,
+ 'elastic-in': Ext.fx.Easing.elasticIn,
+ 'elastic-out': Ext.fx.Easing.elasticIn,
+ 'bounce-in': Ext.fx.Easing.bounceIn,
+ 'bounce-out': Ext.fx.Easing.bounceOut,
+ 'ease-in-out': Ext.fx.Easing.easeInOut
+ });
+});
+
+Ext.define('Ext.draw.Draw', {
+
+
+ singleton: true,
+
+ requires: ['Ext.draw.Color'],
+
+
+
+ pathToStringRE: /,?([achlmqrstvxz]),?/gi,
+ pathCommandRE: /([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,
+ pathValuesRE: /(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig,
+ stopsRE: /^(\d+%?)$/,
+ radian: Math.PI / 180,
+
+ availableAnimAttrs: {
+ along: "along",
+ blur: null,
+ "clip-rect": "csv",
+ cx: null,
+ cy: null,
+ fill: "color",
+ "fill-opacity": null,
+ "font-size": null,
+ height: null,
+ opacity: null,
+ path: "path",
+ r: null,
+ rotation: "csv",
+ rx: null,
+ ry: null,
+ scale: "csv",
+ stroke: "color",
+ "stroke-opacity": null,
+ "stroke-width": null,
+ translation: "csv",
+ width: null,
+ x: null,
+ y: null
+ },
+
+ is: function(o, type) {
+ type = String(type).toLowerCase();
+ return (type == "object" && o === Object(o)) ||
+ (type == "undefined" && typeof o == type) ||
+ (type == "null" && o === null) ||
+ (type == "array" && Array.isArray && Array.isArray(o)) ||
+ (Object.prototype.toString.call(o).toLowerCase().slice(8, -1)) == type;
+ },
+
+ ellipsePath: function(sprite) {
+ var attr = sprite.attr;
+ return Ext.String.format("M{0},{1}A{2},{3},0,1,1,{0},{4}A{2},{3},0,1,1,{0},{1}z", attr.x, attr.y - attr.ry, attr.rx, attr.ry, attr.y + attr.ry);
+ },
+
+ rectPath: function(sprite) {
+ var attr = sprite.attr;
+ if (attr.radius) {
+ return Ext.String.format("M{0},{1}l{2},0a{3},{3},0,0,1,{3},{3}l0,{5}a{3},{3},0,0,1,{4},{3}l{6},0a{3},{3},0,0,1,{4},{4}l0,{7}a{3},{3},0,0,1,{3},{4}z", attr.x + attr.radius, attr.y, attr.width - attr.radius * 2, attr.radius, -attr.radius, attr.height - attr.radius * 2, attr.radius * 2 - attr.width, attr.radius * 2 - attr.height);
+ }
+ else {
+ return Ext.String.format("M{0},{1}l{2},0,0,{3},{4},0z", attr.x, attr.y, attr.width, attr.height, -attr.width);
+ }
+ },
+
+
+ path2string: function () {
+ return this.join(",").replace(Ext.draw.Draw.pathToStringRE, "$1");
+ },
+
+
+ pathToString: function(arrayPath) {
+ return arrayPath.join(",").replace(Ext.draw.Draw.pathToStringRE, "$1");
+ },
+
+ parsePathString: function (pathString) {
+ if (!pathString) {
+ return null;
+ }
+ var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0},
+ data = [],
+ me = this;
+ if (me.is(pathString, "array") && me.is(pathString[0], "array")) {
+ data = me.pathClone(pathString);
+ }
+ if (!data.length) {
+ String(pathString).replace(me.pathCommandRE, function (a, b, c) {
+ var params = [],
+ name = b.toLowerCase();
+ c.replace(me.pathValuesRE, function (a, b) {
+ b && params.push(+b);
+ });
+ if (name == "m" && params.length > 2) {
+ data.push([b].concat(Ext.Array.splice(params, 0, 2)));
+ name = "l";
+ b = (b == "m") ? "l" : "L";
+ }
+ while (params.length >= paramCounts[name]) {
+ data.push([b].concat(Ext.Array.splice(params, 0, paramCounts[name])));
+ if (!paramCounts[name]) {
+ break;
+ }
+ }
+ });
+ }
+ data.toString = me.path2string;
+ return data;
+ },
+
+ mapPath: function (path, matrix) {
+ if (!matrix) {
+ return path;
+ }
+ var x, y, i, ii, j, jj, pathi;
+ path = this.path2curve(path);
+ for (i = 0, ii = path.length; i < ii; i++) {
+ pathi = path[i];
+ for (j = 1, jj = pathi.length; j < jj-1; j += 2) {
+ x = matrix.x(pathi[j], pathi[j + 1]);
+ y = matrix.y(pathi[j], pathi[j + 1]);
+ pathi[j] = x;
+ pathi[j + 1] = y;
+ }
+ }
+ return path;
+ },
+
+ pathClone: function(pathArray) {
+ var res = [],
+ j, jj, i, ii;
+ if (!this.is(pathArray, "array") || !this.is(pathArray && pathArray[0], "array")) {
+ pathArray = this.parsePathString(pathArray);
+ }
+ for (i = 0, ii = pathArray.length; i < ii; i++) {
+ res[i] = [];
+ for (j = 0, jj = pathArray[i].length; j < jj; j++) {
+ res[i][j] = pathArray[i][j];
+ }
+ }
+ res.toString = this.path2string;
+ return res;
+ },
+
+ pathToAbsolute: function (pathArray) {
+ if (!this.is(pathArray, "array") || !this.is(pathArray && pathArray[0], "array")) {
+ pathArray = this.parsePathString(pathArray);
+ }
+ var res = [],
+ x = 0,
+ y = 0,
+ mx = 0,
+ my = 0,
+ i = 0,
+ ln = pathArray.length,
+ r, pathSegment, j, ln2;
+
+ if (ln && pathArray[0][0] == "M") {
+ x = +pathArray[0][1];
+ y = +pathArray[0][2];
+ mx = x;
+ my = y;
+ i++;
+ res[0] = ["M", x, y];
+ }
+ for (; i < ln; i++) {
+ r = res[i] = [];
+ pathSegment = pathArray[i];
+ if (pathSegment[0] != pathSegment[0].toUpperCase()) {
+ r[0] = pathSegment[0].toUpperCase();
+ switch (r[0]) {
+
+ case "A":
+ r[1] = pathSegment[1];
+ r[2] = pathSegment[2];
+ r[3] = pathSegment[3];
+ r[4] = pathSegment[4];
+ r[5] = pathSegment[5];
+ r[6] = +(pathSegment[6] + x);
+ r[7] = +(pathSegment[7] + y);
+ break;
+
+ case "V":
+ r[1] = +pathSegment[1] + y;
+ break;
+
+ case "H":
+ r[1] = +pathSegment[1] + x;
+ break;
+ case "M":
+
+ mx = +pathSegment[1] + x;
+ my = +pathSegment[2] + y;
+ default:
+ j = 1;
+ ln2 = pathSegment.length;
+ for (; j < ln2; j++) {
+ r[j] = +pathSegment[j] + ((j % 2) ? x : y);
+ }
+ }
+ }
+ else {
+ j = 0;
+ ln2 = pathSegment.length;
+ for (; j < ln2; j++) {
+ res[i][j] = pathSegment[j];
+ }
+ }
+ switch (r[0]) {
+
+ case "Z":
+ x = mx;
+ y = my;
+ break;
+
+ case "H":
+ x = r[1];
+ break;
+
+ case "V":
+ y = r[1];
+ break;
+
+ case "M":
+ pathSegment = res[i];
+ ln2 = pathSegment.length;
+ mx = pathSegment[ln2 - 2];
+ my = pathSegment[ln2 - 1];
+ default:
+ pathSegment = res[i];
+ ln2 = pathSegment.length;
+ x = pathSegment[ln2 - 2];
+ y = pathSegment[ln2 - 1];
+ }
+ }
+ res.toString = this.path2string;
+ return res;
+ },
+
+
+ pathToRelative: function (pathArray) {
+ if (!this.is(pathArray, "array") || !this.is(pathArray && pathArray[0], "array")) {
+ pathArray = this.parsePathString(pathArray);
+ }
+ var res = [],
+ x = 0,
+ y = 0,
+ mx = 0,
+ my = 0,
+ start = 0;
+ if (pathArray[0][0] == "M") {
+ x = pathArray[0][1];
+ y = pathArray[0][2];
+ mx = x;
+ my = y;
+ start++;
+ res.push(["M", x, y]);
+ }
+ for (var i = start, ii = pathArray.length; i < ii; i++) {
+ var r = res[i] = [],
+ pa = pathArray[i];
+ if (pa[0] != pa[0].toLowerCase()) {
+ r[0] = pa[0].toLowerCase();
+ switch (r[0]) {
+ case "a":
+ r[1] = pa[1];
+ r[2] = pa[2];
+ r[3] = pa[3];
+ r[4] = pa[4];
+ r[5] = pa[5];
+ r[6] = +(pa[6] - x).toFixed(3);
+ r[7] = +(pa[7] - y).toFixed(3);
+ break;
+ case "v":
+ r[1] = +(pa[1] - y).toFixed(3);
+ break;
+ case "m":
+ mx = pa[1];
+ my = pa[2];
+ default:
+ for (var j = 1, jj = pa.length; j < jj; j++) {
+ r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);
+ }
+ }
+ } else {
+ r = res[i] = [];
+ if (pa[0] == "m") {
+ mx = pa[1] + x;
+ my = pa[2] + y;
+ }
+ for (var k = 0, kk = pa.length; k < kk; k++) {
+ res[i][k] = pa[k];
+ }
+ }
+ var len = res[i].length;
+ switch (res[i][0]) {
+ case "z":
+ x = mx;
+ y = my;
+ break;
+ case "h":
+ x += +res[i][len - 1];
+ break;
+ case "v":
+ y += +res[i][len - 1];
+ break;
+ default:
+ x += +res[i][len - 2];
+ y += +res[i][len - 1];
+ }
+ }
+ res.toString = this.path2string;
+ return res;
+ },
+
+
+ path2curve: function (path) {
+ var me = this,
+ points = me.pathToAbsolute(path),
+ ln = points.length,
+ attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
+ i, seg, segLn, point;
+
+ for (i = 0; i < ln; i++) {
+ points[i] = me.command2curve(points[i], attrs);
+ if (points[i].length > 7) {
+ points[i].shift();
+ point = points[i];
+ while (point.length) {
+ Ext.Array.splice(points, i++, 0, ["C"].concat(Ext.Array.splice(point, 0, 6)));
+ }
+ Ext.Array.erase(points, i, 1);
+ ln = points.length;
+ }
+ seg = points[i];
+ segLn = seg.length;
+ attrs.x = seg[segLn - 2];
+ attrs.y = seg[segLn - 1];
+ attrs.bx = parseFloat(seg[segLn - 4]) || attrs.x;
+ attrs.by = parseFloat(seg[segLn - 3]) || attrs.y;
+ }
+ return points;
+ },
+
+ interpolatePaths: function (path, path2) {
+ var me = this,
+ p = me.pathToAbsolute(path),
+ p2 = me.pathToAbsolute(path2),
+ attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
+ attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
+ fixArc = function (pp, i) {
+ if (pp[i].length > 7) {
+ pp[i].shift();
+ var pi = pp[i];
+ while (pi.length) {
+ Ext.Array.splice(pp, i++, 0, ["C"].concat(Ext.Array.splice(pi, 0, 6)));
+ }
+ Ext.Array.erase(pp, i, 1);
+ ii = Math.max(p.length, p2.length || 0);
+ }
+ },
+ fixM = function (path1, path2, a1, a2, i) {
+ if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {
+ Ext.Array.splice(path2, i, 0, ["M", a2.x, a2.y]);
+ a1.bx = 0;
+ a1.by = 0;
+ a1.x = path1[i][1];
+ a1.y = path1[i][2];
+ ii = Math.max(p.length, p2.length || 0);
+ }
+ };
+ for (var i = 0, ii = Math.max(p.length, p2.length || 0); i < ii; i++) {
+ p[i] = me.command2curve(p[i], attrs);
+ fixArc(p, i);
+ (p2[i] = me.command2curve(p2[i], attrs2));
+ fixArc(p2, i);
+ fixM(p, p2, attrs, attrs2, i);
+ fixM(p2, p, attrs2, attrs, i);
+ var seg = p[i],
+ seg2 = p2[i],
+ seglen = seg.length,
+ seg2len = seg2.length;
+ attrs.x = seg[seglen - 2];
+ attrs.y = seg[seglen - 1];
+ attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
+ attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
+ attrs2.bx = (parseFloat(seg2[seg2len - 4]) || attrs2.x);
+ attrs2.by = (parseFloat(seg2[seg2len - 3]) || attrs2.y);
+ attrs2.x = seg2[seg2len - 2];
+ attrs2.y = seg2[seg2len - 1];
+ }
+ return [p, p2];
+ },
+
+
+ command2curve: function (pathCommand, d) {
+ var me = this;
+ if (!pathCommand) {
+ return ["C", d.x, d.y, d.x, d.y, d.x, d.y];
+ }
+ if (pathCommand[0] != "T" && pathCommand[0] != "Q") {
+ d.qx = d.qy = null;
+ }
+ switch (pathCommand[0]) {
+ case "M":
+ d.X = pathCommand[1];
+ d.Y = pathCommand[2];
+ break;
+ case "A":
+ pathCommand = ["C"].concat(me.arc2curve.apply(me, [d.x, d.y].concat(pathCommand.slice(1))));
+ break;
+ case "S":
+ pathCommand = ["C", d.x + (d.x - (d.bx || d.x)), d.y + (d.y - (d.by || d.y))].concat(pathCommand.slice(1));
+ break;
+ case "T":
+ d.qx = d.x + (d.x - (d.qx || d.x));
+ d.qy = d.y + (d.y - (d.qy || d.y));
+ pathCommand = ["C"].concat(me.quadratic2curve(d.x, d.y, d.qx, d.qy, pathCommand[1], pathCommand[2]));
+ break;
+ case "Q":
+ d.qx = pathCommand[1];
+ d.qy = pathCommand[2];
+ pathCommand = ["C"].concat(me.quadratic2curve(d.x, d.y, pathCommand[1], pathCommand[2], pathCommand[3], pathCommand[4]));
+ break;
+ case "L":
+ pathCommand = ["C"].concat(d.x, d.y, pathCommand[1], pathCommand[2], pathCommand[1], pathCommand[2]);
+ break;
+ case "H":
+ pathCommand = ["C"].concat(d.x, d.y, pathCommand[1], d.y, pathCommand[1], d.y);
+ break;
+ case "V":
+ pathCommand = ["C"].concat(d.x, d.y, d.x, pathCommand[1], d.x, pathCommand[1]);
+ break;
+ case "Z":
+ pathCommand = ["C"].concat(d.x, d.y, d.X, d.Y, d.X, d.Y);
+ break;
+ }
+ return pathCommand;
+ },
+
+ quadratic2curve: function (x1, y1, ax, ay, x2, y2) {
+ var _13 = 1 / 3,
+ _23 = 2 / 3;
+ return [
+ _13 * x1 + _23 * ax,
+ _13 * y1 + _23 * ay,
+ _13 * x2 + _23 * ax,
+ _13 * y2 + _23 * ay,
+ x2,
+ y2
+ ];
+ },
+
+ rotate: function (x, y, rad) {
+ var cos = Math.cos(rad),
+ sin = Math.sin(rad),
+ X = x * cos - y * sin,
+ Y = x * sin + y * cos;
+ return {x: X, y: Y};
+ },
+
+ arc2curve: function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
+
+
+ var me = this,
+ PI = Math.PI,
+ radian = me.radian,
+ _120 = PI * 120 / 180,
+ rad = radian * (+angle || 0),
+ res = [],
+ math = Math,
+ mcos = math.cos,
+ msin = math.sin,
+ msqrt = math.sqrt,
+ mabs = math.abs,
+ masin = math.asin,
+ xy, cos, sin, x, y, h, rx2, ry2, k, cx, cy, f1, f2, df, c1, s1, c2, s2,
+ t, hx, hy, m1, m2, m3, m4, newres, i, ln, f2old, x2old, y2old;
+ if (!recursive) {
+ xy = me.rotate(x1, y1, -rad);
+ x1 = xy.x;
+ y1 = xy.y;
+ xy = me.rotate(x2, y2, -rad);
+ x2 = xy.x;
+ y2 = xy.y;
+ cos = mcos(radian * angle);
+ sin = msin(radian * angle);
+ x = (x1 - x2) / 2;
+ y = (y1 - y2) / 2;
+ h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
+ if (h > 1) {
+ h = msqrt(h);
+ rx = h * rx;
+ ry = h * ry;
+ }
+ rx2 = rx * rx;
+ ry2 = ry * ry;
+ k = (large_arc_flag == sweep_flag ? -1 : 1) *
+ msqrt(mabs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
+ cx = k * rx * y / ry + (x1 + x2) / 2;
+ cy = k * -ry * x / rx + (y1 + y2) / 2;
+ f1 = masin(((y1 - cy) / ry).toFixed(7));
+ f2 = masin(((y2 - cy) / ry).toFixed(7));
+
+ f1 = x1 < cx ? PI - f1 : f1;
+ f2 = x2 < cx ? PI - f2 : f2;
+ if (f1 < 0) {
+ f1 = PI * 2 + f1;
+ }
+ if (f2 < 0) {
+ f2 = PI * 2 + f2;
+ }
+ if (sweep_flag && f1 > f2) {
+ f1 = f1 - PI * 2;
+ }
+ if (!sweep_flag && f2 > f1) {
+ f2 = f2 - PI * 2;
+ }
+ }
+ else {
+ f1 = recursive[0];
+ f2 = recursive[1];
+ cx = recursive[2];
+ cy = recursive[3];
+ }
+ df = f2 - f1;
+ if (mabs(df) > _120) {
+ f2old = f2;
+ x2old = x2;
+ y2old = y2;
+ f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
+ x2 = cx + rx * mcos(f2);
+ y2 = cy + ry * msin(f2);
+ res = me.arc2curve(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
+ }
+ df = f2 - f1;
+ c1 = mcos(f1);
+ s1 = msin(f1);
+ c2 = mcos(f2);
+ s2 = msin(f2);
+ t = math.tan(df / 4);
+ hx = 4 / 3 * rx * t;
+ hy = 4 / 3 * ry * t;
+ m1 = [x1, y1];
+ m2 = [x1 + hx * s1, y1 - hy * c1];
+ m3 = [x2 + hx * s2, y2 - hy * c2];
+ m4 = [x2, y2];
+ m2[0] = 2 * m1[0] - m2[0];
+ m2[1] = 2 * m1[1] - m2[1];
+ if (recursive) {
+ return [m2, m3, m4].concat(res);
+ }
+ else {
+ res = [m2, m3, m4].concat(res).join().split(",");
+ newres = [];
+ ln = res.length;
+ for (i = 0; i < ln; i++) {
+ newres[i] = i % 2 ? me.rotate(res[i - 1], res[i], rad).y : me.rotate(res[i], res[i + 1], rad).x;
+ }
+ return newres;
+ }
+ },
+
+
+ rotateAndTranslatePath: function (sprite) {
+ var alpha = sprite.rotation.degrees,
+ cx = sprite.rotation.x,
+ cy = sprite.rotation.y,
+ dx = sprite.translation.x,
+ dy = sprite.translation.y,
+ path,
+ i,
+ p,
+ xy,
+ j,
+ res = [];
+ if (!alpha && !dx && !dy) {
+ return this.pathToAbsolute(sprite.attr.path);
+ }
+ dx = dx || 0;
+ dy = dy || 0;
+ path = this.pathToAbsolute(sprite.attr.path);
+ for (i = path.length; i--;) {
+ p = res[i] = path[i].slice();
+ if (p[0] == "A") {
+ xy = this.rotatePoint(p[6], p[7], alpha, cx, cy);
+ p[6] = xy.x + dx;
+ p[7] = xy.y + dy;
+ } else {
+ j = 1;
+ while (p[j + 1] != null) {
+ xy = this.rotatePoint(p[j], p[j + 1], alpha, cx, cy);
+ p[j] = xy.x + dx;
+ p[j + 1] = xy.y + dy;
+ j += 2;
+ }
+ }
+ }
+ return res;
+ },
+
+
+ rotatePoint: function (x, y, alpha, cx, cy) {
+ if (!alpha) {
+ return {
+ x: x,
+ y: y
+ };
+ }
+ cx = cx || 0;
+ cy = cy || 0;
+ x = x - cx;
+ y = y - cy;
+ alpha = alpha * this.radian;
+ var cos = Math.cos(alpha),
+ sin = Math.sin(alpha);
+ return {
+ x: x * cos - y * sin + cx,
+ y: x * sin + y * cos + cy
+ };
+ },
+
+ pathDimensions: function (path) {
+ if (!path || !(path + "")) {
+ return {x: 0, y: 0, width: 0, height: 0};
+ }
+ path = this.path2curve(path);
+ var x = 0,
+ y = 0,
+ X = [],
+ Y = [],
+ i = 0,
+ ln = path.length,
+ p, xmin, ymin, dim;
+ for (; i < ln; i++) {
+ p = path[i];
+ if (p[0] == "M") {
+ x = p[1];
+ y = p[2];
+ X.push(x);
+ Y.push(y);
+ }
+ else {
+ dim = this.curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
+ X = X.concat(dim.min.x, dim.max.x);
+ Y = Y.concat(dim.min.y, dim.max.y);
+ x = p[5];
+ y = p[6];
+ }
+ }
+ xmin = Math.min.apply(0, X);
+ ymin = Math.min.apply(0, Y);
+ return {
+ x: xmin,
+ y: ymin,
+ path: path,
+ width: Math.max.apply(0, X) - xmin,
+ height: Math.max.apply(0, Y) - ymin
+ };
+ },
+
+ intersectInside: function(path, cp1, cp2) {
+ return (cp2[0] - cp1[0]) * (path[1] - cp1[1]) > (cp2[1] - cp1[1]) * (path[0] - cp1[0]);
+ },
+
+ intersectIntersection: function(s, e, cp1, cp2) {
+ var p = [],
+ dcx = cp1[0] - cp2[0],
+ dcy = cp1[1] - cp2[1],
+ dpx = s[0] - e[0],
+ dpy = s[1] - e[1],
+ n1 = cp1[0] * cp2[1] - cp1[1] * cp2[0],
+ n2 = s[0] * e[1] - s[1] * e[0],
+ n3 = 1 / (dcx * dpy - dcy * dpx);
+
+ p[0] = (n1 * dpx - n2 * dcx) * n3;
+ p[1] = (n1 * dpy - n2 * dcy) * n3;
+ return p;
+ },
+
+ intersect: function(subjectPolygon, clipPolygon) {
+ var me = this,
+ i = 0,
+ ln = clipPolygon.length,
+ cp1 = clipPolygon[ln - 1],
+ outputList = subjectPolygon,
+ cp2, s, e, point, ln2, inputList, j;
+ for (; i < ln; ++i) {
+ cp2 = clipPolygon[i];
+ inputList = outputList;
+ outputList = [];
+ s = inputList[inputList.length - 1];
+ j = 0;
+ ln2 = inputList.length;
+ for (; j < ln2; j++) {
+ e = inputList[j];
+ if (me.intersectInside(e, cp1, cp2)) {
+ if (!me.intersectInside(s, cp1, cp2)) {
+ outputList.push(me.intersectIntersection(s, e, cp1, cp2));
+ }
+ outputList.push(e);
+ }
+ else if (me.intersectInside(s, cp1, cp2)) {
+ outputList.push(me.intersectIntersection(s, e, cp1, cp2));
+ }
+ s = e;
+ }
+ cp1 = cp2;
+ }
+ return outputList;
+ },
+
+ curveDim: function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
+ var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x),
+ b = 2 * (c1x - p1x) - 2 * (c2x - c1x),
+ c = p1x - c1x,
+ t1 = (-b + Math.sqrt(b * b - 4 * a * c)) / 2 / a,
+ t2 = (-b - Math.sqrt(b * b - 4 * a * c)) / 2 / a,
+ y = [p1y, p2y],
+ x = [p1x, p2x],
+ dot;
+ if (Math.abs(t1) > 1e12) {
+ t1 = 0.5;
+ }
+ if (Math.abs(t2) > 1e12) {
+ t2 = 0.5;
+ }
+ if (t1 > 0 && t1 < 1) {
+ dot = this.findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
+ x.push(dot.x);
+ y.push(dot.y);
+ }
+ if (t2 > 0 && t2 < 1) {
+ dot = this.findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
+ x.push(dot.x);
+ y.push(dot.y);
+ }
+ a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y);
+ b = 2 * (c1y - p1y) - 2 * (c2y - c1y);
+ c = p1y - c1y;
+ t1 = (-b + Math.sqrt(b * b - 4 * a * c)) / 2 / a;
+ t2 = (-b - Math.sqrt(b * b - 4 * a * c)) / 2 / a;
+ if (Math.abs(t1) > 1e12) {
+ t1 = 0.5;
+ }
+ if (Math.abs(t2) > 1e12) {
+ t2 = 0.5;
+ }
+ if (t1 > 0 && t1 < 1) {
+ dot = this.findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1);
+ x.push(dot.x);
+ y.push(dot.y);
+ }
+ if (t2 > 0 && t2 < 1) {
+ dot = this.findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2);
+ x.push(dot.x);
+ y.push(dot.y);
+ }
+ return {
+ min: {x: Math.min.apply(0, x), y: Math.min.apply(0, y)},
+ max: {x: Math.max.apply(0, x), y: Math.max.apply(0, y)}
+ };
+ },
+
+
+ getAnchors: function (prevX, prevY, curX, curY, nextX, nextY, value) {
+ value = value || 4;
+ var M = Math,
+ PI = M.PI,
+ halfPI = PI / 2,
+ abs = M.abs,
+ sin = M.sin,
+ cos = M.cos,
+ atan = M.atan,
+ control1Length, control2Length, control1Angle, control2Angle,
+ control1X, control1Y, control2X, control2Y, alpha;
+
+
+
+ control1Length = (curX - prevX) / value;
+ control2Length = (nextX - curX) / value;
+
+
+
+
+
+ if ((curY >= prevY && curY >= nextY) || (curY <= prevY && curY <= nextY)) {
+ control1Angle = control2Angle = halfPI;
+ } else {
+ control1Angle = atan((curX - prevX) / abs(curY - prevY));
+ if (prevY < curY) {
+ control1Angle = PI - control1Angle;
+ }
+ control2Angle = atan((nextX - curX) / abs(curY - nextY));
+ if (nextY < curY) {
+ control2Angle = PI - control2Angle;
+ }
+ }
+
+
+ alpha = halfPI - ((control1Angle + control2Angle) % (PI * 2)) / 2;
+ if (alpha > halfPI) {
+ alpha -= PI;
+ }
+ control1Angle += alpha;
+ control2Angle += alpha;
+
+
+ control1X = curX - control1Length * sin(control1Angle);
+ control1Y = curY + control1Length * cos(control1Angle);
+ control2X = curX + control2Length * sin(control2Angle);
+ control2Y = curY + control2Length * cos(control2Angle);
+
+
+
+
+
+ if ((curY > prevY && control1Y < prevY) || (curY < prevY && control1Y > prevY)) {
+ control1X += abs(prevY - control1Y) * (control1X - curX) / (control1Y - curY);
+ control1Y = prevY;
+ }
+ if ((curY > nextY && control2Y < nextY) || (curY < nextY && control2Y > nextY)) {
+ control2X -= abs(nextY - control2Y) * (control2X - curX) / (control2Y - curY);
+ control2Y = nextY;
+ }
+
+ return {
+ x1: control1X,
+ y1: control1Y,
+ x2: control2X,
+ y2: control2Y
+ };
+ },
+
+
+ smooth: function (originalPath, value) {
+ var path = this.path2curve(originalPath),
+ newp = [path[0]],
+ x = path[0][1],
+ y = path[0][2],
+ j,
+ points,
+ i = 1,
+ ii = path.length,
+ beg = 1,
+ mx = x,
+ my = y,
+ cx = 0,
+ cy = 0;
+ for (; i < ii; i++) {
+ var pathi = path[i],
+ pathil = pathi.length,
+ pathim = path[i - 1],
+ pathiml = pathim.length,
+ pathip = path[i + 1],
+ pathipl = pathip && pathip.length;
+ if (pathi[0] == "M") {
+ mx = pathi[1];
+ my = pathi[2];
+ j = i + 1;
+ while (path[j][0] != "C") {
+ j++;
+ }
+ cx = path[j][5];
+ cy = path[j][6];
+ newp.push(["M", mx, my]);
+ beg = newp.length;
+ x = mx;
+ y = my;
+ continue;
+ }
+ if (pathi[pathil - 2] == mx && pathi[pathil - 1] == my && (!pathip || pathip[0] == "M")) {
+ var begl = newp[beg].length;
+ points = this.getAnchors(pathim[pathiml - 2], pathim[pathiml - 1], mx, my, newp[beg][begl - 2], newp[beg][begl - 1], value);
+ newp[beg][1] = points.x2;
+ newp[beg][2] = points.y2;
+ }
+ else if (!pathip || pathip[0] == "M") {
+ points = {
+ x1: pathi[pathil - 2],
+ y1: pathi[pathil - 1]
+ };
+ } else {
+ points = this.getAnchors(pathim[pathiml - 2], pathim[pathiml - 1], pathi[pathil - 2], pathi[pathil - 1], pathip[pathipl - 2], pathip[pathipl - 1], value);
+ }
+ newp.push(["C", x, y, points.x1, points.y1, pathi[pathil - 2], pathi[pathil - 1]]);
+ x = points.x2;
+ y = points.y2;
+ }
+ return newp;
+ },
+
+ findDotAtSegment: function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
+ var t1 = 1 - t;
+ return {
+ x: Math.pow(t1, 3) * p1x + Math.pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + Math.pow(t, 3) * p2x,
+ y: Math.pow(t1, 3) * p1y + Math.pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + Math.pow(t, 3) * p2y
+ };
+ },
+
+
+ snapEnds: function (from, to, stepsMax) {
+ if (Ext.isDate(from)) {
+ return this.snapEndsByDate(from, to, stepsMax);
+ }
+ var step = (to - from) / stepsMax,
+ level = Math.floor(Math.log(step) / Math.LN10) + 1,
+ m = Math.pow(10, level),
+ cur,
+ modulo = Math.round((step % m) * Math.pow(10, 2 - level)),
+ interval = [[0, 15], [20, 4], [30, 2], [40, 4], [50, 9], [60, 4], [70, 2], [80, 4], [100, 15]],
+ stepCount = 0,
+ value,
+ weight,
+ i,
+ topValue,
+ topWeight = 1e9,
+ ln = interval.length;
+ cur = from = Math.floor(from / m) * m;
+ for (i = 0; i < ln; i++) {
+ value = interval[i][0];
+ weight = (value - modulo) < 0 ? 1e6 : (value - modulo) / interval[i][1];
+ if (weight < topWeight) {
+ topValue = value;
+ topWeight = weight;
+ }
+ }
+ step = Math.floor(step * Math.pow(10, -level)) * Math.pow(10, level) + topValue * Math.pow(10, level - 2);
+ while (cur < to) {
+ cur += step;
+ stepCount++;
+ }
+ to = +cur.toFixed(10);
+ return {
+ from: from,
+ to: to,
+ power: level,
+ step: step,
+ steps: stepCount
+ };
+ },
+
+
+ snapEndsByDate: function (from, to, stepsMax, lockEnds) {
+ var selectedStep = false, scales = [
+ [Ext.Date.MILLI, [1, 2, 3, 5, 10, 20, 30, 50, 100, 200, 300, 500]],
+ [Ext.Date.SECOND, [1, 2, 3, 5, 10, 15, 30]],
+ [Ext.Date.MINUTE, [1, 2, 3, 5, 10, 20, 30]],
+ [Ext.Date.HOUR, [1, 2, 3, 4, 6, 12]],
+ [Ext.Date.DAY, [1, 2, 3, 7, 14]],
+ [Ext.Date.MONTH, [1, 2, 3, 4, 6]]
+ ], j, yearDiff;
+
+
+ Ext.each(scales, function(scale, i) {
+ for (j = 0; j < scale[1].length; j++) {
+ if (to < Ext.Date.add(from, scale[0], scale[1][j] * stepsMax)) {
+ selectedStep = [scale[0], scale[1][j]];
+ return false;
+ }
+ }
+ });
+ if (!selectedStep) {
+ yearDiff = this.snapEnds(from.getFullYear(), to.getFullYear() + 1, stepsMax, lockEnds);
+ selectedStep = [Date.YEAR, Math.round(yearDiff.step)];
+ }
+ return this.snapEndsByDateAndStep(from, to, selectedStep, lockEnds);
+ },
+
+
+
+ snapEndsByDateAndStep: function(from, to, step, lockEnds) {
+ var fromStat = [from.getFullYear(), from.getMonth(), from.getDate(),
+ from.getHours(), from.getMinutes(), from.getSeconds(), from.getMilliseconds()],
+ steps = 0, testFrom, testTo;
+ if (lockEnds) {
+ testFrom = from;
+ } else {
+ switch (step[0]) {
+ case Ext.Date.MILLI:
+ testFrom = new Date(fromStat[0], fromStat[1], fromStat[2], fromStat[3],
+ fromStat[4], fromStat[5], Math.floor(fromStat[6] / step[1]) * step[1]);
+ break;
+ case Ext.Date.SECOND:
+ testFrom = new Date(fromStat[0], fromStat[1], fromStat[2], fromStat[3],
+ fromStat[4], Math.floor(fromStat[5] / step[1]) * step[1], 0);
+ break;
+ case Ext.Date.MINUTE:
+ testFrom = new Date(fromStat[0], fromStat[1], fromStat[2], fromStat[3],
+ Math.floor(fromStat[4] / step[1]) * step[1], 0, 0);
+ break;
+ case Ext.Date.HOUR:
+ testFrom = new Date(fromStat[0], fromStat[1], fromStat[2],
+ Math.floor(fromStat[3] / step[1]) * step[1], 0, 0, 0);
+ break;
+ case Ext.Date.DAY:
+ testFrom = new Date(fromStat[0], fromStat[1],
+ Math.floor(fromStat[2] - 1 / step[1]) * step[1] + 1, 0, 0, 0, 0);
+ break;
+ case Ext.Date.MONTH:
+ testFrom = new Date(fromStat[0], Math.floor(fromStat[1] / step[1]) * step[1], 1, 0, 0, 0, 0);
+ break;
+ default:
+ testFrom = new Date(Math.floor(fromStat[0] / step[1]) * step[1], 0, 1, 0, 0, 0, 0);
+ break;
+ }
+ }
+
+ testTo = testFrom;
+
+ while (testTo < to) {
+ testTo = Ext.Date.add(testTo, step[0], step[1]);
+ steps++;
+ }
+
+ if (lockEnds) {
+ testTo = to;
+ }
+ return {
+ from : +testFrom,
+ to : +testTo,
+ step : (testTo - testFrom) / steps,
+ steps : steps
+ };
+ },
+
+ sorter: function (a, b) {
+ return a.offset - b.offset;
+ },
+
+ rad: function(degrees) {
+ return degrees % 360 * Math.PI / 180;
+ },
+
+ degrees: function(radian) {
+ return radian * 180 / Math.PI % 360;
+ },
+
+ withinBox: function(x, y, bbox) {
+ bbox = bbox || {};
+ return (x >= bbox.x && x <= (bbox.x + bbox.width) && y >= bbox.y && y <= (bbox.y + bbox.height));
+ },
+
+ parseGradient: function(gradient) {
+ var me = this,
+ type = gradient.type || 'linear',
+ angle = gradient.angle || 0,
+ radian = me.radian,
+ stops = gradient.stops,
+ stopsArr = [],
+ stop,
+ vector,
+ max,
+ stopObj;
+
+ if (type == 'linear') {
+ vector = [0, 0, Math.cos(angle * radian), Math.sin(angle * radian)];
+ max = 1 / (Math.max(Math.abs(vector[2]), Math.abs(vector[3])) || 1);
+ vector[2] *= max;
+ vector[3] *= max;
+ if (vector[2] < 0) {
+ vector[0] = -vector[2];
+ vector[2] = 0;
+ }
+ if (vector[3] < 0) {
+ vector[1] = -vector[3];
+ vector[3] = 0;
+ }
+ }
+
+ for (stop in stops) {
+ if (stops.hasOwnProperty(stop) && me.stopsRE.test(stop)) {
+ stopObj = {
+ offset: parseInt(stop, 10),
+ color: Ext.draw.Color.toHex(stops[stop].color) || '#ffffff',
+ opacity: stops[stop].opacity || 1
+ };
+ stopsArr.push(stopObj);
+ }
+ }
+
+ Ext.Array.sort(stopsArr, me.sorter);
+ if (type == 'linear') {
+ return {
+ id: gradient.id,
+ type: type,
+ vector: vector,
+ stops: stopsArr
+ };
+ }
+ else {
+ return {
+ id: gradient.id,
+ type: type,
+ centerX: gradient.centerX,
+ centerY: gradient.centerY,
+ focalX: gradient.focalX,
+ focalY: gradient.focalY,
+ radius: gradient.radius,
+ vector: vector,
+ stops: stopsArr
+ };
+ }
+ }
+});
+
+
+
+Ext.define('Ext.fx.PropertyHandler', {
+
+
+
+ requires: ['Ext.draw.Draw'],
+
+ statics: {
+ defaultHandler: {
+ pixelDefaultsRE: /width|height|top$|bottom$|left$|right$/i,
+ unitRE: /^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/,
+ scrollRE: /^scroll/i,
+
+ computeDelta: function(from, end, damper, initial, attr) {
+ damper = (typeof damper == 'number') ? damper : 1;
+ var unitRE = this.unitRE,
+ match = unitRE.exec(from),
+ start, units;
+ if (match) {
+ from = match[1];
+ units = match[2];
+ if (!this.scrollRE.test(attr) && !units && this.pixelDefaultsRE.test(attr)) {
+ units = 'px';
+ }
+ }
+ from = +from || 0;
+
+ match = unitRE.exec(end);
+ if (match) {
+ end = match[1];
+ units = match[2] || units;
+ }
+ end = +end || 0;
+ start = (initial != null) ? initial : from;
+ return {
+ from: from,
+ delta: (end - start) * damper,
+ units: units
+ };
+ },
+
+ get: function(from, end, damper, initialFrom, attr) {
+ var ln = from.length,
+ out = [],
+ i, initial, res, j, len;
+ for (i = 0; i < ln; i++) {
+ if (initialFrom) {
+ initial = initialFrom[i][1].from;
+ }
+ if (Ext.isArray(from[i][1]) && Ext.isArray(end)) {
+ res = [];
+ j = 0;
+ len = from[i][1].length;
+ for (; j < len; j++) {
+ res.push(this.computeDelta(from[i][1][j], end[j], damper, initial, attr));
+ }
+ out.push([from[i][0], res]);
+ }
+ else {
+ out.push([from[i][0], this.computeDelta(from[i][1], end, damper, initial, attr)]);
+ }
+ }
+ return out;
+ },
+
+ set: function(values, easing) {
+ var ln = values.length,
+ out = [],
+ i, val, res, len, j;
+ for (i = 0; i < ln; i++) {
+ val = values[i][1];
+ if (Ext.isArray(val)) {
+ res = [];
+ j = 0;
+ len = val.length;
+ for (; j < len; j++) {
+ res.push(val[j].from + (val[j].delta * easing) + (val[j].units || 0));
+ }
+ out.push([values[i][0], res]);
+ } else {
+ out.push([values[i][0], val.from + (val.delta * easing) + (val.units || 0)]);
+ }
+ }
+ return out;
+ }
+ },
+ color: {
+ rgbRE: /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
+ hexRE: /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
+ hex3RE: /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
+
+ parseColor : function(color, damper) {
+ damper = (typeof damper == 'number') ? damper : 1;
+ var base,
+ out = false,
+ match;
+
+ Ext.each([this.hexRE, this.rgbRE, this.hex3RE], function(re, idx) {
+ base = (idx % 2 == 0) ? 16 : 10;
+ match = re.exec(color);
+ if (match && match.length == 4) {
+ if (idx == 2) {
+ match[1] += match[1];
+ match[2] += match[2];
+ match[3] += match[3];
+ }
+ out = {
+ red: parseInt(match[1], base),
+ green: parseInt(match[2], base),
+ blue: parseInt(match[3], base)
+ };
+ return false;
+ }
+ });
+ return out || color;
+ },
+
+ computeDelta: function(from, end, damper, initial) {
+ from = this.parseColor(from);
+ end = this.parseColor(end, damper);
+ var start = initial ? initial : from,
+ tfrom = typeof start,
+ tend = typeof end;
+
+ if (tfrom == 'string' || tfrom == 'undefined'
+ || tend == 'string' || tend == 'undefined') {
+ return end || start;
+ }
+ return {
+ from: from,
+ delta: {
+ red: Math.round((end.red - start.red) * damper),
+ green: Math.round((end.green - start.green) * damper),
+ blue: Math.round((end.blue - start.blue) * damper)
+ }
+ };
+ },
+
+ get: function(start, end, damper, initialFrom) {
+ var ln = start.length,
+ out = [],
+ i, initial;
+ for (i = 0; i < ln; i++) {
+ if (initialFrom) {
+ initial = initialFrom[i][1].from;
+ }
+ out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);
+ }
+ return out;
+ },
+
+ set: function(values, easing) {
+ var ln = values.length,
+ out = [],
+ i, val, parsedString, from, delta;
+ for (i = 0; i < ln; i++) {
+ val = values[i][1];
+ if (val) {
+ from = val.from;
+ delta = val.delta;
+
+ val = (typeof val == 'object' && 'red' in val)?
+ 'rgb(' + val.red + ', ' + val.green + ', ' + val.blue + ')' : val;
+ val = (typeof val == 'object' && val.length)? val[0] : val;
+ if (typeof val == 'undefined') {
+ return [];
+ }
+ parsedString = typeof val == 'string'? val :
+ 'rgb(' + [
+ (from.red + Math.round(delta.red * easing)) % 256,
+ (from.green + Math.round(delta.green * easing)) % 256,
+ (from.blue + Math.round(delta.blue * easing)) % 256
+ ].join(',') + ')';
+ out.push([
+ values[i][0],
+ parsedString
+ ]);
+ }
+ }
+ return out;
+ }
+ },
+ object: {
+ interpolate: function(prop, damper) {
+ damper = (typeof damper == 'number') ? damper : 1;
+ var out = {},
+ p;
+ for(p in prop) {
+ out[p] = parseInt(prop[p], 10) * damper;
+ }
+ return out;
+ },
+
+ computeDelta: function(from, end, damper, initial) {
+ from = this.interpolate(from);
+ end = this.interpolate(end, damper);
+ var start = initial ? initial : from,
+ delta = {},
+ p;
+
+ for(p in end) {
+ delta[p] = end[p] - start[p];
+ }
+ return {
+ from: from,
+ delta: delta
+ };
+ },
+
+ get: function(start, end, damper, initialFrom) {
+ var ln = start.length,
+ out = [],
+ i, initial;
+ for (i = 0; i < ln; i++) {
+ if (initialFrom) {
+ initial = initialFrom[i][1].from;
+ }
+ out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);
+ }
+ return out;
+ },
+
+ set: function(values, easing) {
+ var ln = values.length,
+ out = [],
+ outObject = {},
+ i, from, delta, val, p;
+ for (i = 0; i < ln; i++) {
+ val = values[i][1];
+ from = val.from;
+ delta = val.delta;
+ for (p in from) {
+ outObject[p] = Math.round(from[p] + delta[p] * easing);
+ }
+ out.push([
+ values[i][0],
+ outObject
+ ]);
+ }
+ return out;
+ }
+ },
+
+ path: {
+ computeDelta: function(from, end, damper, initial) {
+ damper = (typeof damper == 'number') ? damper : 1;
+ var start;
+ from = +from || 0;
+ end = +end || 0;
+ start = (initial != null) ? initial : from;
+ return {
+ from: from,
+ delta: (end - start) * damper
+ };
+ },
+
+ forcePath: function(path) {
+ if (!Ext.isArray(path) && !Ext.isArray(path[0])) {
+ path = Ext.draw.Draw.parsePathString(path);
+ }
+ return path;
+ },
+
+ get: function(start, end, damper, initialFrom) {
+ var endPath = this.forcePath(end),
+ out = [],
+ startLn = start.length,
+ startPathLn, pointsLn, i, deltaPath, initial, j, k, path, startPath;
+ for (i = 0; i < startLn; i++) {
+ startPath = this.forcePath(start[i][1]);
+
+ deltaPath = Ext.draw.Draw.interpolatePaths(startPath, endPath);
+ startPath = deltaPath[0];
+ endPath = deltaPath[1];
+
+ startPathLn = startPath.length;
+ path = [];
+ for (j = 0; j < startPathLn; j++) {
+ deltaPath = [startPath[j][0]];
+ pointsLn = startPath[j].length;
+ for (k = 1; k < pointsLn; k++) {
+ initial = initialFrom && initialFrom[0][1][j][k].from;
+ deltaPath.push(this.computeDelta(startPath[j][k], endPath[j][k], damper, initial));
+ }
+ path.push(deltaPath);
+ }
+ out.push([start[i][0], path]);
+ }
+ return out;
+ },
+
+ set: function(values, easing) {
+ var ln = values.length,
+ out = [],
+ i, j, k, newPath, calcPath, deltaPath, deltaPathLn, pointsLn;
+ for (i = 0; i < ln; i++) {
+ deltaPath = values[i][1];
+ newPath = [];
+ deltaPathLn = deltaPath.length;
+ for (j = 0; j < deltaPathLn; j++) {
+ calcPath = [deltaPath[j][0]];
+ pointsLn = deltaPath[j].length;
+ for (k = 1; k < pointsLn; k++) {
+ calcPath.push(deltaPath[j][k].from + deltaPath[j][k].delta * easing);
+ }
+ newPath.push(calcPath.join(','));
+ }
+ out.push([values[i][0], newPath.join(',')]);
+ }
+ return out;
+ }
+ }
+
+ }
+}, function() {
+ Ext.each([
+ 'outlineColor',
+ 'backgroundColor',
+ 'borderColor',
+ 'borderTopColor',
+ 'borderRightColor',
+ 'borderBottomColor',
+ 'borderLeftColor',
+ 'fill',
+ 'stroke'
+ ], function(prop) {
+ this[prop] = this.color;
+ }, this);
+});
+
+Ext.define('Ext.fx.Anim', {
+
+
+
+ mixins: {
+ observable: 'Ext.util.Observable'
+ },
+
+ requires: ['Ext.fx.Manager', 'Ext.fx.Animator', 'Ext.fx.Easing', 'Ext.fx.CubicBezier', 'Ext.fx.PropertyHandler'],
+
+
+
+ isAnimation: true,
+
+
+
+
+
+
+ duration: 250,
+
+
+ delay: 0,
+
+
+ delayStart: 0,
+
+
+ dynamic: false,
+
+
+ easing: 'ease',
+
+
+
+
+ damper: 1,
+
+
+ bezierRE: /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
+
+
+ reverse: false,
+
+
+ running: false,
+
+
+ paused: false,
+
+
+ iterations: 1,
+
+
+ alternate: false,
+
+
+ currentIteration: 0,
+
+
+ startTime: 0,
+
+
+
+
+
+
+
+
+
+
+ constructor: function(config) {
+ var me = this,
+ curve;
+
+ config = config || {};
+
+ if (config.keyframes) {
+ return Ext.create('Ext.fx.Animator', config);
+ }
+ config = Ext.apply(me, config);
+ if (me.from === undefined) {
+ me.from = {};
+ }
+ me.propHandlers = {};
+ me.config = config;
+ me.target = Ext.fx.Manager.createTarget(me.target);
+ me.easingFn = Ext.fx.Easing[me.easing];
+ me.target.dynamic = me.dynamic;
+
+
+ if (!me.easingFn) {
+ me.easingFn = String(me.easing).match(me.bezierRE);
+ if (me.easingFn && me.easingFn.length == 5) {
+ curve = me.easingFn;
+ me.easingFn = Ext.fx.CubicBezier.cubicBezier(+curve[1], +curve[2], +curve[3], +curve[4]);
+ }
+ }
+ me.id = Ext.id(null, 'ext-anim-');
+ Ext.fx.Manager.addAnim(me);
+ me.addEvents(
+
+ 'beforeanimate',
+
+ 'afteranimate',
+
+ 'lastframe'
+ );
+ me.mixins.observable.constructor.call(me, config);
+ if (config.callback) {
+ me.on('afteranimate', config.callback, config.scope);
+ }
+ return me;
+ },
+
+
+ setAttr: function(attr, value) {
+ return Ext.fx.Manager.items.get(this.id).setAttr(this.target, attr, value);
+ },
+
+
+ initAttrs: function() {
+ var me = this,
+ from = me.from,
+ to = me.to,
+ initialFrom = me.initialFrom || {},
+ out = {},
+ start, end, propHandler, attr;
+
+ for (attr in to) {
+ if (to.hasOwnProperty(attr)) {
+ start = me.target.getAttr(attr, from[attr]);
+ end = to[attr];
+
+ if (!Ext.fx.PropertyHandler[attr]) {
+ if (Ext.isObject(end)) {
+ propHandler = me.propHandlers[attr] = Ext.fx.PropertyHandler.object;
+ } else {
+ propHandler = me.propHandlers[attr] = Ext.fx.PropertyHandler.defaultHandler;
+ }
+ }
+
+ else {
+ propHandler = me.propHandlers[attr] = Ext.fx.PropertyHandler[attr];
+ }
+ out[attr] = propHandler.get(start, end, me.damper, initialFrom[attr], attr);
+ }
+ }
+ me.currentAttrs = out;
+ },
+
+
+ start: function(startTime) {
+ var me = this,
+ delay = me.delay,
+ delayStart = me.delayStart,
+ delayDelta;
+ if (delay) {
+ if (!delayStart) {
+ me.delayStart = startTime;
+ return;
+ }
+ else {
+ delayDelta = startTime - delayStart;
+ if (delayDelta < delay) {
+ return;
+ }
+ else {
+
+ startTime = new Date(delayStart.getTime() + delay);
+ }
+ }
+ }
+ if (me.fireEvent('beforeanimate', me) !== false) {
+ me.startTime = startTime;
+ if (!me.paused && !me.currentAttrs) {
+ me.initAttrs();
+ }
+ me.running = true;
+ }
+ },
+
+
+ runAnim: function(elapsedTime) {
+ var me = this,
+ attrs = me.currentAttrs,
+ duration = me.duration,
+ easingFn = me.easingFn,
+ propHandlers = me.propHandlers,
+ ret = {},
+ easing, values, attr, lastFrame;
+
+ if (elapsedTime >= duration) {
+ elapsedTime = duration;
+ lastFrame = true;
+ }
+ if (me.reverse) {
+ elapsedTime = duration - elapsedTime;
+ }
+
+ for (attr in attrs) {
+ if (attrs.hasOwnProperty(attr)) {
+ values = attrs[attr];
+ easing = lastFrame ? 1 : easingFn(elapsedTime / duration);
+ ret[attr] = propHandlers[attr].set(values, easing);
+ }
+ }
+ return ret;
+ },
+
+
+ lastFrame: function() {
+ var me = this,
+ iter = me.iterations,
+ iterCount = me.currentIteration;
+
+ iterCount++;
+ if (iterCount < iter) {
+ if (me.alternate) {
+ me.reverse = !me.reverse;
+ }
+ me.startTime = new Date();
+ me.currentIteration = iterCount;
+
+ me.paused = false;
+ }
+ else {
+ me.currentIteration = 0;
+ me.end();
+ me.fireEvent('lastframe', me, me.startTime);
+ }
+ },
+
+
+ end: function() {
+ var me = this;
+ me.startTime = 0;
+ me.paused = false;
+ me.running = false;
+ Ext.fx.Manager.removeAnim(me);
+ me.fireEvent('afteranimate', me, me.startTime);
+ }
+});
+
+Ext.enableFx = true;
+
+
+
+
+
+Ext.define('Ext.dd.DragDrop', {
+ requires: ['Ext.dd.DragDropManager'],
+
+
+ constructor: function(id, sGroup, config) {
+ if(id) {
+ this.init(id, sGroup, config);
+ }
+ },
+
+
+
+
+ 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.Element.getViewWidth(), height: Ext.Element.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);
+ Ext.EventManager.on(this.id, "mousedown", this.handleMouseDown, this);
+
+ },
+
+
+ initTarget: function(id, sGroup, config) {
+
+ this.config = config || {};
+
+
+ this.DDMInstance = Ext.dd.DragDropManager;
+
+ 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.DDMInstance.verifyEl(el)) {
+ return;
+ }
+
+ var dx = diffX || 0;
+ var dy = diffY || 0;
+
+ var p = Ext.Element.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 || Ext.Element.getXY( this.getEl() );
+ this.deltaSetXY = null;
+
+ this.startPageX = p[0];
+ this.startPageY = p[1];
+ },
+
+
+ addToGroup: function(sGroup) {
+ this.groups[sGroup] = true;
+ this.DDMInstance.regDragDrop(this, sGroup);
+ },
+
+
+ removeFromGroup: function(sGroup) {
+ if (this.groups[sGroup]) {
+ delete this.groups[sGroup];
+ }
+
+ this.DDMInstance.removeDDFromGroup(this, sGroup);
+ },
+
+
+ setDragElId: function(id) {
+ this.dragElId = id;
+ },
+
+
+ setHandleElId: function(id) {
+ if (typeof id !== "string") {
+ id = Ext.id(id);
+ }
+ this.handleElId = id;
+ this.DDMInstance.regHandle(this.id, id);
+ },
+
+
+ setOuterHandleElId: function(id) {
+ if (typeof id !== "string") {
+ id = Ext.id(id);
+ }
+ Ext.EventManager.on(id, "mousedown", this.handleMouseDown, this);
+ this.setHandleElId(id);
+
+ this.hasOuterHandles = true;
+ },
+
+
+ unreg: function() {
+ Ext.EventManager.un(this.id, "mousedown", this.handleMouseDown, this);
+ this._domRef = null;
+ this.DDMInstance._remove(this);
+ },
+
+ destroy : function(){
+ this.unreg();
+ },
+
+
+ isLocked: function() {
+ return (this.DDMInstance.isLocked() || this.locked);
+ },
+
+
+ handleMouseDown: function(e, oDD){
+ if (this.primaryButtonOnly && e.button != 0) {
+ return;
+ }
+
+ if (this.isLocked()) {
+ return;
+ }
+
+ this.DDMInstance.refreshCache(this.groups);
+
+ var pt = e.getPoint();
+ if (!this.hasOuterHandles && !this.DDMInstance.isOverTarget(pt, this) ) {
+ } else {
+ if (this.clickValidator(e)) {
+
+ this.setStartPosition();
+ this.b4MouseDown(e);
+ this.onMouseDown(e);
+
+ this.DDMInstance.handleMouseDown(e, this);
+
+ this.DDMInstance.stopEvent(e);
+ } else {
+
+
+ }
+ }
+ },
+
+ clickValidator: function(e) {
+ var target = e.getTarget();
+ return ( this.isValidHandleChild(target) &&
+ (this.id == this.handleElId ||
+ this.DDMInstance.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).hasCls(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;
+ }
+ }
+
+ Ext.Array.sort(this.xTicks, this.DDMInstance.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;
+ }
+ }
+
+ Ext.Array.sort(this.yTicks, this.DDMInstance.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);
+ }
+
+});
+
+
+
+
+
+Ext.define('Ext.dd.DD', {
+ extend: 'Ext.dd.DragDrop',
+ requires: ['Ext.dd.DragDropManager'],
+
+
+ constructor: function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+ },
+
+
+ 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),
+ fly = el.dom ? el : Ext.fly(el, '_dd'),
+ elSize = fly.getSize(),
+ EL = Ext.Element,
+ vpSize;
+
+ if (!this.deltaSetXY) {
+ vpSize = this.cachedViewportSize = { width: EL.getDocumentWidth(), height: EL.getDocumentHeight() };
+ var aCoord = [
+ Math.max(0, Math.min(oCoord.x, vpSize.width - elSize.width)),
+ Math.max(0, Math.min(oCoord.y, vpSize.height - elSize.height))
+ ];
+ fly.setXY(aCoord);
+ var newLeft = fly.getLeft(true);
+ var newTop = fly.getTop(true);
+ this.deltaSetXY = [newLeft - oCoord.x, newTop - oCoord.y];
+ } else {
+ vpSize = this.cachedViewportSize;
+ fly.setLeftTop(
+ Math.max(0, Math.min(oCoord.x + this.deltaSetXY[0], vpSize.width - elSize.width)),
+ Math.max(0, Math.min(oCoord.y + this.deltaSetXY[1], vpSize.height - elSize.height))
+ );
+ }
+
+ 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.Element.getXY(this.getEl());
+ this.lastPageX = aCoord[0];
+ this.lastPageY = aCoord[1];
+ }
+ },
+
+
+ autoScroll: function(x, y, h, w) {
+
+ if (this.scroll) {
+
+ var clientH = Ext.Element.getViewHeight();
+
+
+ var clientW = Ext.Element.getViewWidth();
+
+
+ var st = this.DDMInstance.getScrollTop();
+
+
+ var sl = this.DDMInstance.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() {
+ this.callParent();
+ 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.define('Ext.dd.DDProxy', {
+ extend: 'Ext.dd.DD',
+
+ statics: {
+
+ dragElId: "ygddfdiv"
+ },
+
+
+ constructor: function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ this.initFrame();
+ }
+ },
+
+
+ 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() {
+ this.callParent();
+
+ 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.define('Ext.dd.DragSource', {
+ extend: 'Ext.dd.DDProxy',
+ requires: [
+ 'Ext.dd.StatusProxy',
+ 'Ext.dd.DragDropManager'
+ ],
+
+
+
+
+ dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',
+
+ dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',
+
+
+ animRepair: true,
+
+
+ repairHighlightColor: 'c3daf9',
+
+
+ constructor: function(el, config) {
+ this.el = Ext.get(el);
+ if(!this.dragData){
+ this.dragData = {};
+ }
+
+ Ext.apply(this, config);
+
+ if(!this.proxy){
+ this.proxy = Ext.create('Ext.dd.StatusProxy', {
+ animRepair: this.animRepair
+ });
+ }
+ this.callParent([this.el.dom, this.ddGroup || this.group,
+ {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true}]);
+
+ this.dragging = false;
+ },
+
+
+ getDragData : function(e){
+ return this.dragData;
+ },
+
+
+ onDragEnter : function(e, id){
+ var target = Ext.dd.DragDropManager.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() {
+ this.callParent(arguments);
+ this.proxy.sync();
+ },
+
+
+ onDragOver: function(e, id) {
+ var target = this.cachedTarget || Ext.dd.DragDropManager.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.DragDropManager.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.DragDropManager.getDDById(id);
+ if (this.beforeDragDrop(target, e, id) !== false) {
+ if (target.isNotifyTarget) {
+ if (target.notifyDrop(this, e, this.dragData) !== false) {
+ 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() {
+ var me = this;
+ if (Ext.enableFx) {
+ me.el.highlight(me.repairHighlightColor);
+ }
+ me.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();
+ this.callParent(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(){
+ this.callParent();
+ Ext.destroy(this.proxy);
+ }
+});
+
+
+Ext.define('Ext.panel.DD', {
+ extend: 'Ext.dd.DragSource',
+ requires: ['Ext.panel.Proxy'],
+
+ constructor : function(panel, cfg){
+ this.panel = panel;
+ this.dragData = {panel: panel};
+ this.proxy = Ext.create('Ext.panel.Proxy', panel, cfg);
+
+ this.callParent([panel.el, cfg]);
+
+ Ext.defer(function() {
+ var header = panel.header,
+ el = panel.body;
+
+ if(header){
+ this.setHandleElId(header.id);
+ el = header.el;
+ }
+ el.setStyle('cursor', 'move');
+ this.scroll = false;
+ }, 200, this);
+ },
+
+ 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.el.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.define('Ext.layout.component.Dock', {
+
+
+
+ alias: ['layout.dock'],
+
+ extend: 'Ext.layout.component.AbstractDock'
+
+
+
+});
+
+Ext.define('Ext.panel.Panel', {
+ extend: 'Ext.panel.AbstractPanel',
+ requires: [
+ 'Ext.panel.Header',
+ 'Ext.fx.Anim',
+ 'Ext.util.KeyMap',
+ 'Ext.panel.DD',
+ 'Ext.XTemplate',
+ 'Ext.layout.component.Dock',
+ 'Ext.util.Memento'
+ ],
+ alias: 'widget.panel',
+ alternateClassName: 'Ext.Panel',
+
+
+ collapsedCls: 'collapsed',
+
+
+ animCollapse: Ext.enableFx,
+
+
+ minButtonWidth: 75,
+
+
+ collapsed: false,
+
+
+ collapseFirst: true,
+
+
+ hideCollapseTool: false,
+
+
+ titleCollapse: false,
+
+
+
+
+
+
+ floatable: true,
+
+
+
+
+ collapsible: false,
+
+
+
+
+ closable: false,
+
+
+ closeAction: 'destroy',
+
+
+
+
+ preventHeader: false,
+
+
+ headerPosition: 'top',
+
+
+ frame: false,
+
+
+ frameHeader: true,
+
+
+
+
+
+
+
+ initComponent: function() {
+ var me = this,
+ cls;
+
+ me.addEvents(
+
+
+ 'beforeclose',
+
+
+ "beforeexpand",
+
+
+ "beforecollapse",
+
+
+ "expand",
+
+
+ "collapse",
+
+
+ 'titlechange',
+
+
+ 'iconchange'
+ );
+
+
+ this.addStateEvents('expand', 'collapse');
+
+ if (me.unstyled) {
+ me.setUI('plain');
+ }
+
+ if (me.frame) {
+ me.setUI(me.ui + '-framed');
+ }
+
+
+ me.bridgeToolbars();
+
+ me.callParent();
+ me.collapseDirection = me.collapseDirection || me.headerPosition || Ext.Component.DIRECTION_TOP;
+ },
+
+ setBorder: function(border) {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ this.callParent(arguments);
+ },
+
+ beforeDestroy: function() {
+ Ext.destroy(
+ this.ghostPanel,
+ this.dd
+ );
+ this.callParent();
+ },
+
+ initAria: function() {
+ this.callParent();
+ this.initHeaderAria();
+ },
+
+ initHeaderAria: function() {
+ var me = this,
+ el = me.el,
+ header = me.header;
+ if (el && header) {
+ el.dom.setAttribute('aria-labelledby', header.titleCmp.id);
+ }
+ },
+
+ getHeader: function() {
+ return this.header;
+ },
+
+
+ setTitle: function(newTitle) {
+ var me = this,
+ oldTitle = this.title;
+
+ me.title = newTitle;
+ if (me.header) {
+ me.header.setTitle(newTitle);
+ } else {
+ me.updateHeader();
+ }
+
+ if (me.reExpander) {
+ me.reExpander.setTitle(newTitle);
+ }
+ me.fireEvent('titlechange', me, newTitle, oldTitle);
+ },
+
+
+ setIconCls: function(newIconCls) {
+ var me = this,
+ oldIconCls = me.iconCls;
+
+ me.iconCls = newIconCls;
+ var header = me.header;
+ if (header) {
+ header.setIconCls(newIconCls);
+ }
+ me.fireEvent('iconchange', me, newIconCls, oldIconCls);
+ },
+
+ bridgeToolbars: function() {
+ var me = this,
+ docked = [],
+ fbar,
+ fbarDefaults,
+ minButtonWidth = me.minButtonWidth;
+
+ function initToolbar (toolbar, pos, useButtonAlign) {
+ if (Ext.isArray(toolbar)) {
+ toolbar = {
+ xtype: 'toolbar',
+ items: toolbar
+ };
+ }
+ else if (!toolbar.xtype) {
+ toolbar.xtype = 'toolbar';
+ }
+ toolbar.dock = pos;
+ if (pos == 'left' || pos == 'right') {
+ toolbar.vertical = true;
+ }
+
+
+ if (useButtonAlign) {
+ toolbar.layout = Ext.applyIf(toolbar.layout || {}, {
+
+ pack: { left:'start', center:'center' }[me.buttonAlign] || 'end'
+ });
+ }
+ return toolbar;
+ }
+
+
+
+
+
+
+ if (me.tbar) {
+ docked.push(initToolbar(me.tbar, 'top'));
+ me.tbar = null;
+ }
+
+
+ if (me.bbar) {
+ docked.push(initToolbar(me.bbar, 'bottom'));
+ me.bbar = null;
+ }
+
+
+ if (me.buttons) {
+ me.fbar = me.buttons;
+ me.buttons = null;
+ }
+
+
+ if (me.fbar) {
+ fbar = initToolbar(me.fbar, 'bottom', true);
+ fbar.ui = 'footer';
+
+
+ if (minButtonWidth) {
+ fbarDefaults = fbar.defaults;
+ fbar.defaults = function(config) {
+ var defaults = fbarDefaults || {};
+ if ((!config.xtype || config.xtype === 'button' || (config.isComponent && config.isXType('button'))) &&
+ !('minWidth' in defaults)) {
+ defaults = Ext.apply({minWidth: minButtonWidth}, defaults);
+ }
+ return defaults;
+ };
+ }
+
+ docked.push(fbar);
+ me.fbar = null;
+ }
+
+
+ if (me.lbar) {
+ docked.push(initToolbar(me.lbar, 'left'));
+ me.lbar = null;
+ }
+
+
+ if (me.rbar) {
+ docked.push(initToolbar(me.rbar, 'right'));
+ me.rbar = null;
+ }
+
+ if (me.dockedItems) {
+ if (!Ext.isArray(me.dockedItems)) {
+ me.dockedItems = [me.dockedItems];
+ }
+ me.dockedItems = me.dockedItems.concat(docked);
+ } else {
+ me.dockedItems = docked;
+ }
+ },
+
+
+ initTools: function() {
+ var me = this;
+
+ me.tools = me.tools ? Ext.Array.clone(me.tools) : [];
+
+
+
+ if (me.collapsible && !(me.hideCollapseTool || me.header === false)) {
+ me.collapseDirection = me.collapseDirection || me.headerPosition || 'top';
+ me.collapseTool = me.expandTool = me.createComponent({
+ xtype: 'tool',
+ type: 'collapse-' + me.collapseDirection,
+ expandType: me.getOppositeDirection(me.collapseDirection),
+ handler: me.toggleCollapse,
+ scope: me
+ });
+
+
+ if (me.collapseFirst) {
+ me.tools.unshift(me.collapseTool);
+ }
+ }
+
+
+ me.addTools();
+
+
+ if (me.closable) {
+ me.addClsWithUI('closable');
+ me.addTool({
+ type: 'close',
+ handler: Ext.Function.bind(me.close, this, [])
+ });
+ }
+
+
+ if (me.collapseTool && !me.collapseFirst) {
+ me.tools.push(me.collapseTool);
+ }
+ },
+
+
+ addTools: Ext.emptyFn,
+
+
+ close: function() {
+ if (this.fireEvent('beforeclose', this) !== false) {
+ this.doClose();
+ }
+ },
+
+
+ doClose: function() {
+ this.fireEvent('close', this);
+ this[this.closeAction]();
+ },
+
+ onRender: function(ct, position) {
+ var me = this,
+ topContainer;
+
+
+
+ me.initTools();
+
+
+ me.updateHeader();
+
+
+ me.callParent(arguments);
+ },
+
+ afterRender: function() {
+ var me = this;
+
+ me.callParent(arguments);
+
+
+
+
+ if (me.collapsed) {
+ me.collapsed = false;
+ me.collapse(null, false, true);
+ }
+ },
+
+
+ updateHeader: function(force) {
+ var me = this,
+ header = me.header,
+ title = me.title,
+ tools = me.tools;
+
+ if (!me.preventHeader && (force || title || (tools && tools.length))) {
+ if (!header) {
+ header = me.header = Ext.create('Ext.panel.Header', {
+ title : title,
+ orientation : (me.headerPosition == 'left' || me.headerPosition == 'right') ? 'vertical' : 'horizontal',
+ dock : me.headerPosition || 'top',
+ textCls : me.headerTextCls,
+ iconCls : me.iconCls,
+ baseCls : me.baseCls + '-header',
+ tools : tools,
+ ui : me.ui,
+ indicateDrag: me.draggable,
+ border : me.border,
+ frame : me.frame && me.frameHeader,
+ ignoreParentFrame : me.frame || me.overlapHeader,
+ ignoreBorderManagement: me.frame || me.ignoreHeaderBorderManagement,
+ listeners : me.collapsible && me.titleCollapse ? {
+ click: me.toggleCollapse,
+ scope: me
+ } : null
+ });
+ me.addDocked(header, 0);
+
+
+
+ me.tools = header.tools;
+ }
+ header.show();
+ me.initHeaderAria();
+ } else if (header) {
+ header.hide();
+ }
+ },
+
+
+ setUI: function(ui) {
+ var me = this;
+
+ me.callParent(arguments);
+
+ if (me.header) {
+ me.header.setUI(ui);
+ }
+ },
+
+
+ getContentTarget: function() {
+ return this.body;
+ },
+
+ getTargetEl: function() {
+ return this.body || this.frameBody || this.el;
+ },
+
+
+
+
+ isVisible: function(deep){
+ var me = this;
+ if (me.collapsed && me.placeholder) {
+ return me.placeholder.isVisible(deep);
+ }
+ return me.callParent(arguments);
+ },
+
+
+ onHide: function(){
+ var me = this;
+ if (me.collapsed && me.placeholder) {
+ me.placeholder.hide();
+ } else {
+ me.callParent(arguments);
+ }
+ },
+
+
+ onShow: function(){
+ var me = this;
+ if (me.collapsed && me.placeholder) {
+
+ me.hidden = true;
+ me.placeholder.show();
+ } else {
+ me.callParent(arguments);
+ }
+ },
+
+ addTool: function(tool) {
+ var me = this,
+ header = me.header;
+
+ if (Ext.isArray(tool)) {
+ Ext.each(tool, me.addTool, me);
+ return;
+ }
+ me.tools.push(tool);
+ if (header) {
+ header.addTool(tool);
+ }
+ me.updateHeader();
+ },
+
+ getOppositeDirection: function(d) {
+ var c = Ext.Component;
+ switch (d) {
+ case c.DIRECTION_TOP:
+ return c.DIRECTION_BOTTOM;
+ case c.DIRECTION_RIGHT:
+ return c.DIRECTION_LEFT;
+ case c.DIRECTION_BOTTOM:
+ return c.DIRECTION_TOP;
+ case c.DIRECTION_LEFT:
+ return c.DIRECTION_RIGHT;
+ }
+ },
+
+
+ collapse: function(direction, animate, internal) {
+ var me = this,
+ c = Ext.Component,
+ height = me.getHeight(),
+ width = me.getWidth(),
+ frameInfo,
+ newSize = 0,
+ dockedItems = me.dockedItems.items,
+ dockedItemCount = dockedItems.length,
+ i = 0,
+ comp,
+ pos,
+ anim = {
+ from: {
+ height: height,
+ width: width
+ },
+ to: {
+ height: height,
+ width: width
+ },
+ listeners: {
+ afteranimate: me.afterCollapse,
+ scope: me
+ },
+ duration: Ext.Number.from(animate, Ext.fx.Anim.prototype.duration)
+ },
+ reExpander,
+ reExpanderOrientation,
+ reExpanderDock,
+ getDimension,
+ collapseDimension;
+
+ if (!direction) {
+ direction = me.collapseDirection;
+ }
+
+
+ if (internal) {
+ animate = false;
+ } else if (me.collapsed || me.fireEvent('beforecollapse', me, direction, animate) === false) {
+ return false;
+ }
+
+ reExpanderDock = direction;
+ me.expandDirection = me.getOppositeDirection(direction);
+
+
+ me.hiddenDocked = [];
+
+ switch (direction) {
+ case c.DIRECTION_TOP:
+ case c.DIRECTION_BOTTOM:
+ reExpanderOrientation = 'horizontal';
+ collapseDimension = 'height';
+ getDimension = 'getHeight';
+
+
+
+ for (; i < dockedItemCount; i++) {
+ comp = dockedItems[i];
+ if (comp.isVisible()) {
+ if (comp.isXType('header', true) && (!comp.dock || comp.dock == 'top' || comp.dock == 'bottom')) {
+ reExpander = comp;
+ } else {
+ me.hiddenDocked.push(comp);
+ }
+ } else if (comp === me.reExpander) {
+ reExpander = comp;
+ }
+ }
+
+ if (direction == Ext.Component.DIRECTION_BOTTOM) {
+ pos = me.getPosition()[1] - Ext.fly(me.el.dom.offsetParent).getRegion().top;
+ anim.from.top = pos;
+ }
+ break;
+
+ case c.DIRECTION_LEFT:
+ case c.DIRECTION_RIGHT:
+ reExpanderOrientation = 'vertical';
+ collapseDimension = 'width';
+ getDimension = 'getWidth';
+
+
+
+ for (; i < dockedItemCount; i++) {
+ comp = dockedItems[i];
+ if (comp.isVisible()) {
+ if (comp.isHeader && (comp.dock == 'left' || comp.dock == 'right')) {
+ reExpander = comp;
+ } else {
+ me.hiddenDocked.push(comp);
+ }
+ } else if (comp === me.reExpander) {
+ reExpander = comp;
+ }
+ }
+
+ if (direction == Ext.Component.DIRECTION_RIGHT) {
+ pos = me.getPosition()[0] - Ext.fly(me.el.dom.offsetParent).getRegion().left;
+ anim.from.left = pos;
+ }
+ break;
+
+ default:
+ throw('Panel collapse must be passed a valid Component collapse direction');
+ }
+
+
+ if (animate && me.collapseTool) {
+ me.collapseTool.disable();
+ }
+
+
+ me.addClsWithUI(me.collapsedCls);
+
+
+
+
+
+ if (reExpander && reExpander.rendered) {
+
+
+ reExpander.addClsWithUI(me.collapsedCls);
+ reExpander.addClsWithUI(me.collapsedCls + '-' + reExpander.dock);
+ if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
+ reExpander.addClsWithUI(me.collapsedCls + '-border-' + reExpander.dock);
+ }
+
+ frameInfo = reExpander.getFrameInfo();
+
+
+ newSize = reExpander[getDimension]() + (frameInfo ? frameInfo[direction] : 0);
+
+
+ reExpander.removeClsWithUI(me.collapsedCls);
+ reExpander.removeClsWithUI(me.collapsedCls + '-' + reExpander.dock);
+ if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
+ reExpander.removeClsWithUI(me.collapsedCls + '-border-' + reExpander.dock);
+ }
+ }
+
+ else {
+ reExpander = {
+ hideMode: 'offsets',
+ temporary: true,
+ title: me.title,
+ orientation: reExpanderOrientation,
+ dock: reExpanderDock,
+ textCls: me.headerTextCls,
+ iconCls: me.iconCls,
+ baseCls: me.baseCls + '-header',
+ ui: me.ui,
+ frame: me.frame && me.frameHeader,
+ ignoreParentFrame: me.frame || me.overlapHeader,
+ indicateDrag: me.draggable,
+ cls: me.baseCls + '-collapsed-placeholder ' + ' ' + Ext.baseCSSPrefix + 'docked ' + me.baseCls + '-' + me.ui + '-collapsed',
+ renderTo: me.el
+ };
+ if (!me.hideCollapseTool) {
+ reExpander[(reExpander.orientation == 'horizontal') ? 'tools' : 'items'] = [{
+ xtype: 'tool',
+ type: 'expand-' + me.expandDirection,
+ handler: me.toggleCollapse,
+ scope: me
+ }];
+ }
+
+
+
+ reExpander = me.reExpander = Ext.create('Ext.panel.Header', reExpander);
+ newSize = reExpander[getDimension]() + ((reExpander.frame) ? reExpander.frameSize[direction] : 0);
+ reExpander.hide();
+
+
+ me.insertDocked(0, reExpander);
+ }
+
+ me.reExpander = reExpander;
+ me.reExpander.addClsWithUI(me.collapsedCls);
+ me.reExpander.addClsWithUI(me.collapsedCls + '-' + reExpander.dock);
+ if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
+ me.reExpander.addClsWithUI(me.collapsedCls + '-border-' + me.reExpander.dock);
+ }
+
+
+ if (direction == Ext.Component.DIRECTION_RIGHT) {
+ anim.to.left = pos + (width - newSize);
+ } else if (direction == Ext.Component.DIRECTION_BOTTOM) {
+ anim.to.top = pos + (height - newSize);
+ }
+
+
+ anim.to[collapseDimension] = newSize;
+
+
+
+
+
+
+ if (!me.collapseMemento) {
+ me.collapseMemento = new Ext.util.Memento(me);
+ }
+ me.collapseMemento.capture(['width', 'height', 'minWidth', 'minHeight', 'layoutManagedHeight', 'layoutManagedWidth']);
+
+
+ me.savedFlex = me.flex;
+ me.minWidth = 0;
+ me.minHeight = 0;
+ delete me.flex;
+ me.suspendLayout = true;
+
+ if (animate) {
+ me.animate(anim);
+ } else {
+ me.setSize(anim.to.width, anim.to.height);
+ if (Ext.isDefined(anim.to.left) || Ext.isDefined(anim.to.top)) {
+ me.setPosition(anim.to.left, anim.to.top);
+ }
+ me.afterCollapse(false, internal);
+ }
+ return me;
+ },
+
+ afterCollapse: function(animated, internal) {
+ var me = this,
+ i = 0,
+ l = me.hiddenDocked.length;
+
+ me.collapseMemento.restore(['minWidth', 'minHeight']);
+
+
+
+
+ if (Ext.Component.VERTICAL_DIRECTION_Re.test(me.expandDirection)) {
+ me.layoutManagedHeight = 2;
+ me.collapseMemento.restore('width', false);
+ } else {
+ me.layoutManagedWidth = 2;
+ me.collapseMemento.restore('height', false);
+ }
+
+
+
+ me.saveScrollTop = me.body.dom.scrollTop;
+ me.body.setStyle('display', 'none');
+
+ for (; i < l; i++) {
+ me.hiddenDocked[i].hide();
+ }
+ if (me.reExpander) {
+ me.reExpander.updateFrame();
+ me.reExpander.show();
+ }
+ me.collapsed = true;
+ me.suspendLayout = false;
+
+ if (!internal) {
+ if (me.ownerCt) {
+
+
+ if (animated) {
+ me.ownerCt.layout.layout();
+ }
+ } else if (me.reExpander.temporary) {
+ me.doComponentLayout();
+ }
+ }
+
+ if (me.resizer) {
+ me.resizer.disable();
+ }
+
+
+ if (me.collapseTool) {
+ me.collapseTool.setType('expand-' + me.expandDirection);
+ }
+ if (!internal) {
+ me.fireEvent('collapse', me);
+ }
+
+
+ if (animated && me.collapseTool) {
+ me.collapseTool.enable();
+ }
+ },
+
+
+ expand: function(animate) {
+ var me = this;
+ if (!me.collapsed || me.fireEvent('beforeexpand', me, animate) === false) {
+ return false;
+ }
+
+ var i = 0,
+ l = me.hiddenDocked.length,
+ direction = me.expandDirection,
+ height = me.getHeight(),
+ width = me.getWidth(),
+ pos, anim;
+
+
+ if (animate && me.collapseTool) {
+ me.collapseTool.disable();
+ }
+
+
+
+ for (; i < l; i++) {
+ me.hiddenDocked[i].hidden = false;
+ me.hiddenDocked[i].el.show();
+ }
+ if (me.reExpander) {
+ if (me.reExpander.temporary) {
+ me.reExpander.hide();
+ } else {
+ me.reExpander.removeClsWithUI(me.collapsedCls);
+ me.reExpander.removeClsWithUI(me.collapsedCls + '-' + me.reExpander.dock);
+ if (me.border && (!me.frame || (me.frame && Ext.supports.CSS3BorderRadius))) {
+ me.reExpander.removeClsWithUI(me.collapsedCls + '-border-' + me.reExpander.dock);
+ }
+ me.reExpander.updateFrame();
+ }
+ }
+
+
+ if (me.collapseTool) {
+ me.collapseTool.setType('collapse-' + me.collapseDirection);
+ }
+
+
+ me.body.setStyle('display', '');
+ me.body.dom.scrollTop = me.saveScrollTop;
+
+
+ me.collapsed = false;
+
+
+ me.removeClsWithUI(me.collapsedCls);
+
+
+
+
+ anim = {
+ to: {
+ },
+ from: {
+ height: height,
+ width: width
+ },
+ listeners: {
+ afteranimate: me.afterExpand,
+ scope: me
+ }
+ };
+
+ if ((direction == Ext.Component.DIRECTION_TOP) || (direction == Ext.Component.DIRECTION_BOTTOM)) {
+
+
+
+ me.collapseMemento.restore('height', false);
+
+
+ if (me.height === undefined) {
+ me.setCalculatedSize(me.width, null);
+ anim.to.height = me.getHeight();
+
+
+ me.setCalculatedSize(me.width, anim.from.height);
+ }
+
+
+ else if (me.savedFlex) {
+ me.flex = me.savedFlex;
+ anim.to.height = me.ownerCt.layout.calculateChildBox(me).height;
+ delete me.flex;
+ }
+
+ else {
+ anim.to.height = me.height;
+ }
+
+
+ if (direction == Ext.Component.DIRECTION_TOP) {
+ pos = me.getPosition()[1] - Ext.fly(me.el.dom.offsetParent).getRegion().top;
+ anim.from.top = pos;
+ anim.to.top = pos - (anim.to.height - height);
+ }
+ } else if ((direction == Ext.Component.DIRECTION_LEFT) || (direction == Ext.Component.DIRECTION_RIGHT)) {
+
+
+
+ me.collapseMemento.restore('width', false);
+
+
+ if (me.width === undefined) {
+ me.setCalculatedSize(null, me.height);
+ anim.to.width = me.getWidth();
+
+
+ me.setCalculatedSize(anim.from.width, me.height);
+ }
+
+
+ else if (me.savedFlex) {
+ me.flex = me.savedFlex;
+ anim.to.width = me.ownerCt.layout.calculateChildBox(me).width;
+ delete me.flex;
+ }
+
+ else {
+ anim.to.width = me.width;
+ }
+
+
+ if (direction == Ext.Component.DIRECTION_LEFT) {
+ pos = me.getPosition()[0] - Ext.fly(me.el.dom.offsetParent).getRegion().left;
+ anim.from.left = pos;
+ anim.to.left = pos - (anim.to.width - width);
+ }
+ }
+
+ if (animate) {
+ me.animate(anim);
+ } else {
+ me.setCalculatedSize(anim.to.width, anim.to.height);
+ if (anim.to.x) {
+ me.setLeft(anim.to.x);
+ }
+ if (anim.to.y) {
+ me.setTop(anim.to.y);
+ }
+ me.afterExpand(false);
+ }
+
+ return me;
+ },
+
+ afterExpand: function(animated) {
+ var me = this;
+
+
+ if (me.savedFlex) {
+ me.flex = me.savedFlex;
+ delete me.savedFlex;
+ delete me.width;
+ delete me.height;
+ }
+
+
+ if (me.collapseMemento) {
+ me.collapseMemento.restoreAll();
+ }
+
+ if (animated && me.ownerCt) {
+
+
+ Ext.defer(me.ownerCt.doLayout, Ext.isIE6 ? 1 : 0, me);
+ }
+
+ if (me.resizer) {
+ me.resizer.enable();
+ }
+
+ me.fireEvent('expand', me);
+
+
+ if (animated && me.collapseTool) {
+ me.collapseTool.enable();
+ }
+ },
+
+
+ toggleCollapse: function() {
+ if (this.collapsed) {
+ this.expand(this.animCollapse);
+ } else {
+ this.collapse(this.collapseDirection, this.animCollapse);
+ }
+ return this;
+ },
+
+
+ getKeyMap : function(){
+ if(!this.keyMap){
+ this.keyMap = Ext.create('Ext.util.KeyMap', this.el, this.keys);
+ }
+ return this.keyMap;
+ },
+
+
+ initDraggable : function(){
+
+ this.dd = Ext.create('Ext.panel.DD', this, Ext.isBoolean(this.draggable) ? null : this.draggable);
+ },
+
+
+ ghostTools : function() {
+ var tools = [],
+ headerTools = this.header.query('tool[hidden=false]');
+
+ if (headerTools.length) {
+ Ext.each(headerTools, function(tool) {
+
+
+
+
+ tools.push({
+ type: tool.type
+ });
+ });
+ } else {
+ tools = [{
+ type: 'placeholder'
+ }];
+ }
+ return tools;
+ },
+
+
+ ghost: function(cls) {
+ var me = this,
+ ghostPanel = me.ghostPanel,
+ box = me.getBox(),
+ header;
+
+ if (!ghostPanel) {
+ ghostPanel = Ext.create('Ext.panel.Panel', {
+ renderTo: me.floating ? me.el.dom.parentNode : document.body,
+ floating: {
+ shadow: false
+ },
+ frame: Ext.supports.CSS3BorderRadius ? me.frame : false,
+ overlapHeader: me.overlapHeader,
+ headerPosition: me.headerPosition,
+ baseCls: me.baseCls,
+ cls: me.baseCls + '-ghost ' + (cls ||'')
+ });
+ me.ghostPanel = ghostPanel;
+ }
+ ghostPanel.floatParent = me.floatParent;
+ if (me.floating) {
+ ghostPanel.setZIndex(Ext.Number.from(me.el.getStyle('zIndex'), 0));
+ } else {
+ ghostPanel.toFront();
+ }
+ header = ghostPanel.header;
+
+ if (header) {
+ header.suspendLayout = true;
+ Ext.Array.forEach(header.query('tool'), function(tool){
+ header.remove(tool);
+ });
+ header.suspendLayout = false;
+ }
+ ghostPanel.addTool(me.ghostTools());
+ ghostPanel.setTitle(me.title);
+ ghostPanel.setIconCls(me.iconCls);
+
+ ghostPanel.el.show();
+ ghostPanel.setPosition(box.x, box.y);
+ ghostPanel.setSize(box.width, box.height);
+ me.el.hide();
+ if (me.floatingItems) {
+ me.floatingItems.hide();
+ }
+ return ghostPanel;
+ },
+
+
+ unghost: function(show, matchPosition) {
+ var me = this;
+ if (!me.ghostPanel) {
+ return;
+ }
+ if (show !== false) {
+ me.el.show();
+ if (matchPosition !== false) {
+ me.setPosition(me.ghostPanel.getPosition());
+ }
+ if (me.floatingItems) {
+ me.floatingItems.show();
+ }
+ Ext.defer(me.focus, 10, me);
+ }
+ me.ghostPanel.el.hide();
+ },
+
+ initResizable: function(resizable) {
+ if (this.collapsed) {
+ resizable.disabled = true;
+ }
+ this.callParent([resizable]);
+ }
+}, function(){
+ this.prototype.animCollapse = Ext.enableFx;
+});
+
+
+
+Ext.define('Ext.layout.component.Tip', {
+
+
+
+ alias: ['layout.tip'],
+
+ extend: 'Ext.layout.component.Dock',
+
+
+
+ type: 'tip',
+
+ onLayout: function(width, height) {
+ var me = this,
+ owner = me.owner,
+ el = owner.el,
+ minWidth,
+ maxWidth,
+ naturalWidth,
+ constrainedWidth,
+ xy = el.getXY();
+
+
+ el.setXY([-9999,-9999]);
+
+
+ this.callParent(arguments);
+
+
+ if (!Ext.isNumber(width)) {
+ minWidth = owner.minWidth;
+ maxWidth = owner.maxWidth;
+
+ if (Ext.isStrict && (Ext.isIE6 || Ext.isIE7)) {
+ constrainedWidth = me.doAutoWidth();
+ } else {
+ naturalWidth = el.getWidth();
+ }
+ if (naturalWidth < minWidth) {
+ constrainedWidth = minWidth;
+ }
+ else if (naturalWidth > maxWidth) {
+ constrainedWidth = maxWidth;
+ }
+ if (constrainedWidth) {
+ this.callParent([constrainedWidth, height]);
+ }
+ }
+
+
+ el.setXY(xy);
+ },
+
+ doAutoWidth: function(){
+ var me = this,
+ owner = me.owner,
+ body = owner.body,
+ width = body.getTextWidth();
+
+ if (owner.header) {
+ width = Math.max(width, owner.header.getWidth());
+ }
+ if (!Ext.isDefined(me.frameWidth)) {
+ me.frameWidth = owner.el.getWidth() - body.getWidth();
+ }
+ width += me.frameWidth + body.getPadding('lr');
+ return width;
+ }
+});
+
+
+Ext.define('Ext.tip.Tip', {
+ extend: 'Ext.panel.Panel',
+ requires: [ 'Ext.layout.component.Tip' ],
+ alternateClassName: 'Ext.Tip',
+
+
+
+ minWidth : 40,
+
+ maxWidth : 300,
+
+ shadow : "sides",
+
+
+ defaultAlign : "tl-bl?",
+
+ constrainPosition : true,
+
+
+ frame: false,
+
+
+ autoRender: true,
+ hidden: true,
+ baseCls: Ext.baseCSSPrefix + 'tip',
+ floating: {
+ shadow: true,
+ shim: true,
+ constrain: true
+ },
+ focusOnToFront: false,
+ componentLayout: 'tip',
+
+
+ closeAction: 'hide',
+
+ ariaRole: 'tooltip',
+
+ initComponent: function() {
+ var me = this;
+
+ me.floating = Ext.apply({}, {shadow: me.shadow}, me.self.prototype.floating);
+ me.callParent(arguments);
+
+
+ me.constrain = me.constrain || me.constrainPosition;
+ },
+
+
+ showAt : function(xy){
+ var me = this;
+ this.callParent(arguments);
+
+ if (me.isVisible()) {
+ me.setPagePosition(xy[0], xy[1]);
+ if (me.constrainPosition || me.constrain) {
+ me.doConstrain();
+ }
+ me.toFront(true);
+ }
+ },
+
+
+ showBy : function(el, pos) {
+ this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
+ },
+
+
+ initDraggable : function(){
+ var me = this;
+ me.draggable = {
+ el: me.getDragEl(),
+ delegate: me.header.el,
+ constrain: me,
+ constrainTo: me.el.getScopeParent()
+ };
+
+ Ext.Component.prototype.initDraggable.call(me);
+ },
+
+
+ ghost: undefined,
+ unghost: undefined
+});
+
+
+Ext.define('Ext.tip.ToolTip', {
+ extend: 'Ext.tip.Tip',
+ alias: 'widget.tooltip',
+ alternateClassName: 'Ext.ToolTip',
+
+
+
+
+ showDelay: 500,
+
+ hideDelay: 200,
+
+ dismissDelay: 5000,
+
+
+ trackMouse: false,
+
+
+ anchorToTarget: true,
+
+ anchorOffset: 0,
+
+
+
+ targetCounter: 0,
+ quickShowInterval: 250,
+
+
+ initComponent: function() {
+ var me = this;
+ me.callParent(arguments);
+ me.lastActive = new Date();
+ me.setTarget(me.target);
+ me.origAnchor = me.anchor;
+ },
+
+
+ onRender: function(ct, position) {
+ var me = this;
+ me.callParent(arguments);
+ me.anchorCls = Ext.baseCSSPrefix + 'tip-anchor-' + me.getAnchorPosition();
+ me.anchorEl = me.el.createChild({
+ cls: Ext.baseCSSPrefix + 'tip-anchor ' + me.anchorCls
+ });
+ },
+
+
+ afterRender: function() {
+ var me = this,
+ zIndex;
+
+ me.callParent(arguments);
+ zIndex = parseInt(me.el.getZIndex(), 10) || 0;
+ me.anchorEl.setStyle('z-index', zIndex + 1).setVisibilityMode(Ext.Element.DISPLAY);
+ },
+
+
+ setTarget: function(target) {
+ var me = this,
+ t = Ext.get(target),
+ tg;
+
+ if (me.target) {
+ tg = Ext.get(me.target);
+ me.mun(tg, 'mouseover', me.onTargetOver, me);
+ me.mun(tg, 'mouseout', me.onTargetOut, me);
+ me.mun(tg, 'mousemove', me.onMouseMove, me);
+ }
+
+ me.target = t;
+ if (t) {
+
+ me.mon(t, {
+
+
+ freezeEvent: true,
+
+ mouseover: me.onTargetOver,
+ mouseout: me.onTargetOut,
+ mousemove: me.onMouseMove,
+ scope: me
+ });
+ }
+ if (me.anchor) {
+ me.anchorTarget = me.target;
+ }
+ },
+
+
+ onMouseMove: function(e) {
+ var me = this,
+ t = me.delegate ? e.getTarget(me.delegate) : me.triggerElement = true,
+ xy;
+ if (t) {
+ me.targetXY = e.getXY();
+ if (t === me.triggerElement) {
+ if (!me.hidden && me.trackMouse) {
+ xy = me.getTargetXY();
+ if (me.constrainPosition) {
+ xy = me.el.adjustForConstraints(xy, me.el.getScopeParent());
+ }
+ me.setPagePosition(xy);
+ }
+ } else {
+ me.hide();
+ me.lastActive = new Date(0);
+ me.onTargetOver(e);
+ }
+ } else if ((!me.closable && me.isVisible()) && me.autoHide !== false) {
+ me.hide();
+ }
+ },
+
+
+ getTargetXY: function() {
+ var me = this,
+ mouseOffset;
+ if (me.delegate) {
+ me.anchorTarget = me.triggerElement;
+ }
+ if (me.anchor) {
+ me.targetCounter++;
+ var offsets = me.getOffsets(),
+ xy = (me.anchorToTarget && !me.trackMouse) ? me.el.getAlignToXY(me.anchorTarget, me.getAnchorAlign()) : me.targetXY,
+ dw = Ext.Element.getViewWidth() - 5,
+ dh = Ext.Element.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 = me.getSize(),
+ constrainPosition = me.constrainPosition;
+
+ me.anchorEl.removeCls(me.anchorCls);
+
+ if (me.targetCounter < 2 && constrainPosition) {
+ if (axy[0] < scrollX) {
+ if (me.anchorToTarget) {
+ me.defaultAlign = 'l-r';
+ if (me.mouseOffset) {
+ me.mouseOffset[0] *= -1;
+ }
+ }
+ me.anchor = 'left';
+ return me.getTargetXY();
+ }
+ if (axy[0] + sz.width > dw) {
+ if (me.anchorToTarget) {
+ me.defaultAlign = 'r-l';
+ if (me.mouseOffset) {
+ me.mouseOffset[0] *= -1;
+ }
+ }
+ me.anchor = 'right';
+ return me.getTargetXY();
+ }
+ if (axy[1] < scrollY) {
+ if (me.anchorToTarget) {
+ me.defaultAlign = 't-b';
+ if (me.mouseOffset) {
+ me.mouseOffset[1] *= -1;
+ }
+ }
+ me.anchor = 'top';
+ return me.getTargetXY();
+ }
+ if (axy[1] + sz.height > dh) {
+ if (me.anchorToTarget) {
+ me.defaultAlign = 'b-t';
+ if (me.mouseOffset) {
+ me.mouseOffset[1] *= -1;
+ }
+ }
+ me.anchor = 'bottom';
+ return me.getTargetXY();
+ }
+ }
+
+ me.anchorCls = Ext.baseCSSPrefix + 'tip-anchor-' + me.getAnchorPosition();
+ me.anchorEl.addCls(me.anchorCls);
+ me.targetCounter = 0;
+ return axy;
+ } else {
+ mouseOffset = me.getMouseOffset();
+ return (me.targetXY) ? [me.targetXY[0] + mouseOffset[0], me.targetXY[1] + mouseOffset[1]] : mouseOffset;
+ }
+ },
+
+ getMouseOffset: function() {
+ var me = this,
+ offset = me.anchor ? [0, 0] : [15, 18];
+ if (me.mouseOffset) {
+ offset[0] += me.mouseOffset[0];
+ offset[1] += me.mouseOffset[1];
+ }
+ return offset;
+ },
+
+
+ getAnchorPosition: function() {
+ var me = this,
+ m;
+ if (me.anchor) {
+ me.tipAnchor = me.anchor.charAt(0);
+ } else {
+ m = me.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);
+ me.tipAnchor = m[1].charAt(0);
+ }
+
+ switch (me.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 me = this,
+ mouseOffset,
+ offsets,
+ ap = me.getAnchorPosition().charAt(0);
+ if (me.anchorToTarget && !me.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 - me.anchorOffset, 30];
+ break;
+ case 'b':
+ offsets = [ - 19 - me.anchorOffset, -13 - me.el.dom.offsetHeight];
+ break;
+ case 'r':
+ offsets = [ - 15 - me.el.dom.offsetWidth, -13 - me.anchorOffset];
+ break;
+ default:
+ offsets = [25, -13 - me.anchorOffset];
+ break;
+ }
+ }
+ mouseOffset = me.getMouseOffset();
+ offsets[0] += mouseOffset[0];
+ offsets[1] += mouseOffset[1];
+
+ return offsets;
+ },
+
+
+ onTargetOver: function(e) {
+ var me = this,
+ t;
+
+ if (me.disabled || e.within(me.target.dom, true)) {
+ return;
+ }
+ t = e.getTarget(me.delegate);
+ if (t) {
+ me.triggerElement = t;
+ me.clearTimer('hide');
+ me.targetXY = e.getXY();
+ me.delayShow();
+ }
+ },
+
+
+ delayShow: function() {
+ var me = this;
+ if (me.hidden && !me.showTimer) {
+ if (Ext.Date.getElapsed(me.lastActive) < me.quickShowInterval) {
+ me.show();
+ } else {
+ me.showTimer = Ext.defer(me.show, me.showDelay, me);
+ }
+ }
+ else if (!me.hidden && me.autoHide !== false) {
+ me.show();
+ }
+ },
+
+
+ onTargetOut: function(e) {
+ var me = this;
+ if (me.disabled || e.within(me.target.dom, true)) {
+ return;
+ }
+ me.clearTimer('show');
+ if (me.autoHide !== false) {
+ me.delayHide();
+ }
+ },
+
+
+ delayHide: function() {
+ var me = this;
+ if (!me.hidden && !me.hideTimer) {
+ me.hideTimer = Ext.defer(me.hide, me.hideDelay, me);
+ }
+ },
+
+
+ hide: function() {
+ var me = this;
+ me.clearTimer('dismiss');
+ me.lastActive = new Date();
+ if (me.anchorEl) {
+ me.anchorEl.hide();
+ }
+ me.callParent(arguments);
+ delete me.triggerElement;
+ },
+
+
+ show: function() {
+ var me = this;
+
+
+
+ this.callParent();
+ if (this.hidden === false) {
+ me.setPagePosition(-10000, -10000);
+
+ if (me.anchor) {
+ me.anchor = me.origAnchor;
+ }
+ me.showAt(me.getTargetXY());
+
+ if (me.anchor) {
+ me.syncAnchor();
+ me.anchorEl.show();
+ } else {
+ me.anchorEl.hide();
+ }
+ }
+ },
+
+
+ showAt: function(xy) {
+ var me = this;
+ me.lastActive = new Date();
+ me.clearTimers();
+
+
+ if (!me.isVisible()) {
+ this.callParent(arguments);
+ }
+
+
+ if (me.isVisible()) {
+ me.setPagePosition(xy[0], xy[1]);
+ if (me.constrainPosition || me.constrain) {
+ me.doConstrain();
+ }
+ me.toFront(true);
+ }
+
+ if (me.dismissDelay && me.autoHide !== false) {
+ me.dismissTimer = Ext.defer(me.hide, me.dismissDelay, me);
+ }
+ if (me.anchor) {
+ me.syncAnchor();
+ if (!me.anchorEl.isVisible()) {
+ me.anchorEl.show();
+ }
+ } else {
+ me.anchorEl.hide();
+ }
+ },
+
+
+ syncAnchor: function() {
+ var me = this,
+ anchorPos,
+ targetPos,
+ offset;
+ switch (me.tipAnchor.charAt(0)) {
+ case 't':
+ anchorPos = 'b';
+ targetPos = 'tl';
+ offset = [20 + me.anchorOffset, 1];
+ break;
+ case 'r':
+ anchorPos = 'l';
+ targetPos = 'tr';
+ offset = [ - 1, 12 + me.anchorOffset];
+ break;
+ case 'b':
+ anchorPos = 't';
+ targetPos = 'bl';
+ offset = [20 + me.anchorOffset, -1];
+ break;
+ default:
+ anchorPos = 'r';
+ targetPos = 'tl';
+ offset = [1, 12 + me.anchorOffset];
+ break;
+ }
+ me.anchorEl.alignTo(me.el, anchorPos + '-' + targetPos, offset);
+ },
+
+
+ setPagePosition: function(x, y) {
+ var me = this;
+ me.callParent(arguments);
+ if (me.anchor) {
+ me.syncAnchor();
+ }
+ },
+
+
+ clearTimer: function(name) {
+ name = name + 'Timer';
+ clearTimeout(this[name]);
+ delete this[name];
+ },
+
+
+ clearTimers: function() {
+ var me = this;
+ me.clearTimer('show');
+ me.clearTimer('dismiss');
+ me.clearTimer('hide');
+ },
+
+
+ onShow: function() {
+ var me = this;
+ me.callParent();
+ me.mon(Ext.getDoc(), 'mousedown', me.onDocMouseDown, me);
+ },
+
+
+ onHide: function() {
+ var me = this;
+ me.callParent();
+ me.mun(Ext.getDoc(), 'mousedown', me.onDocMouseDown, me);
+ },
+
+
+ onDocMouseDown: function(e) {
+ var me = this;
+ if (me.autoHide !== true && !me.closable && !e.within(me.el.dom)) {
+ me.disable();
+ Ext.defer(me.doEnable, 100, me);
+ }
+ },
+
+
+ doEnable: function() {
+ if (!this.isDestroyed) {
+ this.enable();
+ }
+ },
+
+
+ onDisable: function() {
+ this.callParent();
+ this.clearTimers();
+ this.hide();
+ },
+
+ beforeDestroy: function() {
+ var me = this;
+ me.clearTimers();
+ Ext.destroy(me.anchorEl);
+ delete me.anchorEl;
+ delete me.target;
+ delete me.anchorTarget;
+ delete me.triggerElement;
+ me.callParent();
+ },
+
+
+ onDestroy: function() {
+ Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
+ this.callParent();
+ }
+});
+
+
+Ext.define('Ext.tip.QuickTip', {
+ extend: 'Ext.tip.ToolTip',
+ alternateClassName: 'Ext.QuickTip',
+
+
+ interceptTitles : false,
+
+
+ title: ' ',
+
+
+ tagConfig : {
+ namespace : "data-",
+ attribute : "qtip",
+ width : "qwidth",
+ target : "target",
+ title : "qtitle",
+ hide : "hide",
+ cls : "qclass",
+ align : "qalign",
+ anchor : "anchor"
+ },
+
+
+ initComponent : function(){
+ var me = this;
+
+ me.target = me.target || Ext.getDoc();
+ me.targets = me.targets || {};
+ me.callParent();
+ },
+
+
+ register : function(config){
+ var configs = Ext.isArray(config) ? config : arguments,
+ i = 0,
+ len = configs.length,
+ target, j, targetLen;
+
+ for (; i < len; i++) {
+ config = configs[i];
+ target = config.target;
+ if (target) {
+ if (Ext.isArray(target)) {
+ for (j = 0, targetLen = target.length; j < targetLen; j++) {
+ this.targets[Ext.id(target[j])] = config;
+ }
+ } else{
+ this.targets[Ext.id(target)] = config;
+ }
+ }
+ }
+ },
+
+
+ unregister : function(el){
+ delete this.targets[Ext.id(el)];
+ },
+
+
+ cancelShow: function(el){
+ var me = this,
+ activeTarget = me.activeTarget;
+
+ el = Ext.get(el).dom;
+ if (me.isVisible()) {
+ if (activeTarget && activeTarget.el == el) {
+ me.hide();
+ }
+ } else if (activeTarget && activeTarget.el == el) {
+ me.clearTimer('show');
+ }
+ },
+
+
+ getTipCfg: function(e) {
+ var t = e.getTarget(),
+ titleText = t.title,
+ cfg;
+
+ if (this.interceptTitles && titleText && Ext.isString(titleText)) {
+ t.qtip = titleText;
+ t.removeAttribute("title");
+ e.preventDefault();
+ return {
+ text: titleText
+ };
+ }
+ else {
+ cfg = this.tagConfig;
+ t = e.getTarget('[' + cfg.namespace + cfg.attribute + ']');
+ if (t) {
+ return {
+ target: t,
+ text: t.getAttribute(cfg.namespace + cfg.attribute)
+ };
+ }
+ }
+ },
+
+
+ onTargetOver : function(e){
+ var me = this,
+ target = e.getTarget(),
+ elTarget,
+ cfg,
+ ns,
+ tipConfig,
+ autoHide;
+
+ if (me.disabled) {
+ return;
+ }
+
+
+
+
+ me.targetXY = e.getXY();
+
+ if(!target || target.nodeType !== 1 || target == document || target == document.body){
+ return;
+ }
+
+ if (me.activeTarget && ((target == me.activeTarget.el) || Ext.fly(me.activeTarget.el).contains(target))) {
+ me.clearTimer('hide');
+ me.show();
+ return;
+ }
+
+ if (target) {
+ Ext.Object.each(me.targets, function(key, value) {
+ var targetEl = Ext.fly(value.target);
+ if (targetEl && (targetEl.dom === target || targetEl.contains(target))) {
+ elTarget = targetEl.dom;
+ return false;
+ }
+ });
+ if (elTarget) {
+ me.activeTarget = me.targets[elTarget.id];
+ me.activeTarget.el = target;
+ me.anchor = me.activeTarget.anchor;
+ if (me.anchor) {
+ me.anchorTarget = target;
+ }
+ me.delayShow();
+ return;
+ }
+ }
+
+ elTarget = Ext.get(target);
+ cfg = me.tagConfig;
+ ns = cfg.namespace;
+ tipConfig = me.getTipCfg(e);
+
+ if (tipConfig) {
+
+
+
+ if (tipConfig.target) {
+ target = tipConfig.target;
+ elTarget = Ext.get(target);
+ }
+ autoHide = elTarget.getAttribute(ns + cfg.hide);
+
+ me.activeTarget = {
+ el: target,
+ text: tipConfig.text,
+ width: +elTarget.getAttribute(ns + cfg.width) || null,
+ autoHide: autoHide != "user" && autoHide !== 'false',
+ title: elTarget.getAttribute(ns + cfg.title),
+ cls: elTarget.getAttribute(ns + cfg.cls),
+ align: elTarget.getAttribute(ns + cfg.align)
+
+ };
+ me.anchor = elTarget.getAttribute(ns + cfg.anchor);
+ if (me.anchor) {
+ me.anchorTarget = target;
+ }
+ me.delayShow();
+ }
+ },
+
+
+ onTargetOut : function(e){
+ var me = this;
+
+
+ if (me.activeTarget && e.within(me.activeTarget.el) && !me.getTipCfg(e)) {
+ return;
+ }
+
+ me.clearTimer('show');
+ if (me.autoHide !== false) {
+ me.delayHide();
+ }
+ },
+
+
+ showAt : function(xy){
+ var me = this,
+ target = me.activeTarget;
+
+ if (target) {
+ if (!me.rendered) {
+ me.render(Ext.getBody());
+ me.activeTarget = target;
+ }
+ if (target.title) {
+ me.setTitle(target.title || '');
+ me.header.show();
+ } else {
+ me.header.hide();
+ }
+ me.body.update(target.text);
+ me.autoHide = target.autoHide;
+ me.dismissDelay = target.dismissDelay || me.dismissDelay;
+ if (me.lastCls) {
+ me.el.removeCls(me.lastCls);
+ delete me.lastCls;
+ }
+ if (target.cls) {
+ me.el.addCls(target.cls);
+ me.lastCls = target.cls;
+ }
+
+ me.setWidth(target.width);
+
+ if (me.anchor) {
+ me.constrainPosition = false;
+ } else if (target.align) {
+ xy = me.el.getAlignToXY(target.el, target.align);
+ me.constrainPosition = false;
+ }else{
+ me.constrainPosition = true;
+ }
+ }
+ me.callParent([xy]);
+ },
+
+
+ hide: function(){
+ delete this.activeTarget;
+ this.callParent();
+ }
+});
+
+
+Ext.define('Ext.tip.QuickTipManager', function() {
+ var tip,
+ disabled = false;
+
+ return {
+ requires: ['Ext.tip.QuickTip'],
+ singleton: true,
+ alternateClassName: 'Ext.QuickTips',
+
+
+ init : function (autoRender, config) {
+ if (!tip) {
+ if (!Ext.isReady) {
+ Ext.onReady(function(){
+ Ext.tip.QuickTipManager.init(autoRender);
+ });
+ return;
+ }
+
+ var tipConfig = Ext.apply({ disabled: disabled }, config),
+ className = tipConfig.className,
+ xtype = tipConfig.xtype;
+
+ if (className) {
+ delete tipConfig.className;
+ } else if (xtype) {
+ className = 'widget.' + xtype;
+ delete tipConfig.xtype;
+ }
+
+ if (autoRender !== false) {
+ tipConfig.renderTo = document.body;
+
+ }
+
+ tip = Ext.create(className || 'Ext.tip.QuickTip', tipConfig);
+ }
+ },
+
+
+ destroy: function() {
+ if (tip) {
+ var undef;
+ tip.destroy();
+ tip = undef;
+ }
+ },
+
+
+ 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.define('Ext.app.Application', {
+ extend: 'Ext.app.Controller',
+
+ requires: [
+ 'Ext.ModelManager',
+ 'Ext.data.Model',
+ 'Ext.data.StoreManager',
+ 'Ext.tip.QuickTipManager',
+ 'Ext.ComponentManager',
+ 'Ext.app.EventBus'
+ ],
+
+
+
+
+ scope: undefined,
+
+
+ enableQuickTips: true,
+
+
+
+
+ appFolder: 'app',
+
+
+ autoCreateViewport: false,
+
+
+ constructor: function(config) {
+ config = config || {};
+ Ext.apply(this, config);
+
+ var requires = config.requires || [];
+
+ Ext.Loader.setPath(this.name, this.appFolder);
+
+ if (this.paths) {
+ Ext.Object.each(this.paths, function(key, value) {
+ Ext.Loader.setPath(key, value);
+ });
+ }
+
+ this.callParent(arguments);
+
+ this.eventbus = Ext.create('Ext.app.EventBus');
+
+ var controllers = Ext.Array.from(this.controllers),
+ ln = controllers && controllers.length,
+ i, controller;
+
+ this.controllers = Ext.create('Ext.util.MixedCollection');
+
+ if (this.autoCreateViewport) {
+ requires.push(this.getModuleClassName('Viewport', 'view'));
+ }
+
+ for (i = 0; i < ln; i++) {
+ requires.push(this.getModuleClassName(controllers[i], 'controller'));
+ }
+
+ Ext.require(requires);
+
+ Ext.onReady(function() {
+ for (i = 0; i < ln; i++) {
+ controller = this.getController(controllers[i]);
+ controller.init(this);
+ }
+
+ this.onBeforeLaunch.call(this);
+ }, this);
+ },
+
+ control: function(selectors, listeners, controller) {
+ this.eventbus.control(selectors, listeners, controller);
+ },
+
+
+ launch: Ext.emptyFn,
+
+
+ onBeforeLaunch: function() {
+ if (this.enableQuickTips) {
+ Ext.tip.QuickTipManager.init();
+ }
+
+ if (this.autoCreateViewport) {
+ this.getView('Viewport').create();
+ }
+
+ this.launch.call(this.scope || this);
+ this.launched = true;
+ this.fireEvent('launch', this);
+
+ this.controllers.each(function(controller) {
+ controller.onLaunch(this);
+ }, this);
+ },
+
+ getModuleClassName: function(name, type) {
+ var namespace = Ext.Loader.getPrefix(name);
+
+ if (namespace.length > 0 && namespace !== name) {
+ return name;
+ }
+
+ return this.name + '.' + type + '.' + name;
+ },
+
+ getController: function(name) {
+ var controller = this.controllers.get(name);
+
+ if (!controller) {
+ controller = Ext.create(this.getModuleClassName(name, 'controller'), {
+ application: this,
+ id: name
+ });
+
+ this.controllers.add(controller);
+ }
+
+ return controller;
+ },
+
+ getStore: function(name) {
+ var store = Ext.StoreManager.get(name);
+
+ if (!store) {
+ store = Ext.create(this.getModuleClassName(name, 'store'), {
+ storeId: name
+ });
+ }
+
+ return store;
+ },
+
+ getModel: function(model) {
+ model = this.getModuleClassName(model, 'model');
+
+ return Ext.ModelManager.getModel(model);
+ },
+
+ getView: function(view) {
+ view = this.getModuleClassName(view, 'view');
+
+ return Ext.ClassManager.get(view);
+ }
+});
+
+
+Ext.define('Ext.chart.Callout', {
+
+
+
+
+
+ constructor: function(config) {
+ if (config.callouts) {
+ config.callouts.styles = Ext.applyIf(config.callouts.styles || {}, {
+ color: "#000",
+ font: "11px Helvetica, sans-serif"
+ });
+ this.callouts = Ext.apply(this.callouts || {}, config.callouts);
+ this.calloutsArray = [];
+ }
+ },
+
+ renderCallouts: function() {
+ if (!this.callouts) {
+ return;
+ }
+
+ var me = this,
+ items = me.items,
+ animate = me.chart.animate,
+ config = me.callouts,
+ styles = config.styles,
+ group = me.calloutsArray,
+ store = me.chart.store,
+ len = store.getCount(),
+ ratio = items.length / len,
+ previouslyPlacedCallouts = [],
+ i,
+ count,
+ j,
+ p;
+
+ for (i = 0, count = 0; i < len; i++) {
+ for (j = 0; j < ratio; j++) {
+ var item = items[count],
+ label = group[count],
+ storeItem = store.getAt(i),
+ display;
+
+ display = config.filter(storeItem);
+
+ if (!display && !label) {
+ count++;
+ continue;
+ }
+
+ if (!label) {
+ group[count] = label = me.onCreateCallout(storeItem, item, i, display, j, count);
+ }
+ for (p in label) {
+ if (label[p] && label[p].setAttributes) {
+ label[p].setAttributes(styles, true);
+ }
+ }
+ if (!display) {
+ for (p in label) {
+ if (label[p]) {
+ if (label[p].setAttributes) {
+ label[p].setAttributes({
+ hidden: true
+ }, true);
+ } else if(label[p].setVisible) {
+ label[p].setVisible(false);
+ }
+ }
+ }
+ }
+ config.renderer(label, storeItem);
+ me.onPlaceCallout(label, storeItem, item, i, display, animate,
+ j, count, previouslyPlacedCallouts);
+ previouslyPlacedCallouts.push(label);
+ count++;
+ }
+ }
+ this.hideCallouts(count);
+ },
+
+ onCreateCallout: function(storeItem, item, i, display) {
+ var me = this,
+ group = me.calloutsGroup,
+ config = me.callouts,
+ styles = config.styles,
+ width = styles.width,
+ height = styles.height,
+ chart = me.chart,
+ surface = chart.surface,
+ calloutObj = {
+
+
+ lines: false
+ };
+
+ calloutObj.lines = surface.add(Ext.apply({},
+ {
+ type: 'path',
+ path: 'M0,0',
+ stroke: me.getLegendColor() || '#555'
+ },
+ styles));
+
+ if (config.items) {
+ calloutObj.panel = Ext.create('widget.panel', {
+ style: "position: absolute;",
+ width: width,
+ height: height,
+ items: config.items,
+ renderTo: chart.el
+ });
+ }
+
+ return calloutObj;
+ },
+
+ hideCallouts: function(index) {
+ var calloutsArray = this.calloutsArray,
+ len = calloutsArray.length,
+ co,
+ p;
+ while (len-->index) {
+ co = calloutsArray[len];
+ for (p in co) {
+ if (co[p]) {
+ co[p].hide(true);
+ }
+ }
+ }
+ }
+});
+
+
+Ext.define('Ext.draw.CompositeSprite', {
+
+
+
+ extend: 'Ext.util.MixedCollection',
+ mixins: {
+ animate: 'Ext.util.Animate'
+ },
+
+
+ isCompositeSprite: true,
+ constructor: function(config) {
+ var me = this;
+
+ config = config || {};
+ Ext.apply(me, config);
+
+ me.addEvents(
+ 'mousedown',
+ 'mouseup',
+ 'mouseover',
+ 'mouseout',
+ 'click'
+ );
+ me.id = Ext.id(null, 'ext-sprite-group-');
+ me.callParent();
+ },
+
+
+ onClick: function(e) {
+ this.fireEvent('click', e);
+ },
+
+
+ onMouseUp: function(e) {
+ this.fireEvent('mouseup', e);
+ },
+
+
+ onMouseDown: function(e) {
+ this.fireEvent('mousedown', e);
+ },
+
+
+ onMouseOver: function(e) {
+ this.fireEvent('mouseover', e);
+ },
+
+
+ onMouseOut: function(e) {
+ this.fireEvent('mouseout', e);
+ },
+
+ attachEvents: function(o) {
+ var me = this;
+
+ o.on({
+ scope: me,
+ mousedown: me.onMouseDown,
+ mouseup: me.onMouseUp,
+ mouseover: me.onMouseOver,
+ mouseout: me.onMouseOut,
+ click: me.onClick
+ });
+ },
+
+
+ add: function(key, o) {
+ var result = this.callParent(arguments);
+ this.attachEvents(result);
+ return result;
+ },
+
+ insert: function(index, key, o) {
+ return this.callParent(arguments);
+ },
+
+
+ remove: function(o) {
+ var me = this;
+
+ o.un({
+ scope: me,
+ mousedown: me.onMouseDown,
+ mouseup: me.onMouseUp,
+ mouseover: me.onMouseOver,
+ mouseout: me.onMouseOut,
+ click: me.onClick
+ });
+ return me.callParent(arguments);
+ },
+
+
+ getBBox: function() {
+ var i = 0,
+ sprite,
+ bb,
+ items = this.items,
+ len = this.length,
+ infinity = Infinity,
+ minX = infinity,
+ maxHeight = -infinity,
+ minY = infinity,
+ maxWidth = -infinity,
+ maxWidthBBox, maxHeightBBox;
+
+ for (; i < len; i++) {
+ sprite = items[i];
+ if (sprite.el) {
+ bb = sprite.getBBox();
+ minX = Math.min(minX, bb.x);
+ minY = Math.min(minY, bb.y);
+ maxHeight = Math.max(maxHeight, bb.height + bb.y);
+ maxWidth = Math.max(maxWidth, bb.width + bb.x);
+ }
+ }
+
+ return {
+ x: minX,
+ y: minY,
+ height: maxHeight - minY,
+ width: maxWidth - minX
+ };
+ },
+
+
+ setAttributes: function(attrs, redraw) {
+ var i = 0,
+ items = this.items,
+ len = this.length;
+
+ for (; i < len; i++) {
+ items[i].setAttributes(attrs, redraw);
+ }
+ return this;
+ },
+
+
+ hide: function(redraw) {
+ var i = 0,
+ items = this.items,
+ len = this.length;
+
+ for (; i < len; i++) {
+ items[i].hide(redraw);
+ }
+ return this;
+ },
+
+
+ show: function(redraw) {
+ var i = 0,
+ items = this.items,
+ len = this.length;
+
+ for (; i < len; i++) {
+ items[i].show(redraw);
+ }
+ return this;
+ },
+
+ redraw: function() {
+ var me = this,
+ i = 0,
+ items = me.items,
+ surface = me.getSurface(),
+ len = me.length;
+
+ if (surface) {
+ for (; i < len; i++) {
+ surface.renderItem(items[i]);
+ }
+ }
+ return me;
+ },
+
+ setStyle: function(obj) {
+ var i = 0,
+ items = this.items,
+ len = this.length,
+ item, el;
+
+ for (; i < len; i++) {
+ item = items[i];
+ el = item.el;
+ if (el) {
+ el.setStyle(obj);
+ }
+ }
+ },
+
+ addCls: function(obj) {
+ var i = 0,
+ items = this.items,
+ surface = this.getSurface(),
+ len = this.length;
+
+ if (surface) {
+ for (; i < len; i++) {
+ surface.addCls(items[i], obj);
+ }
+ }
+ },
+
+ removeCls: function(obj) {
+ var i = 0,
+ items = this.items,
+ surface = this.getSurface(),
+ len = this.length;
+
+ if (surface) {
+ for (; i < len; i++) {
+ surface.removeCls(items[i], obj);
+ }
+ }
+ },
+
+
+ getSurface: function(){
+ var first = this.first();
+ if (first) {
+ return first.surface;
+ }
+ return null;
+ },
+
+
+ destroy: function(){
+ var me = this,
+ surface = me.getSurface(),
+ item;
+
+ if (surface) {
+ while (me.getCount() > 0) {
+ item = me.first();
+ me.remove(item);
+ surface.remove(item);
+ }
+ }
+ me.clearListeners();
+ }
+});
+
+
+
+Ext.define('Ext.layout.component.Auto', {
+
+
+
+ alias: 'layout.autocomponent',
+
+ extend: 'Ext.layout.component.Component',
+
+
+
+ type: 'autocomponent',
+
+ onLayout : function(width, height) {
+ this.setTargetSize(width, height);
+ }
+});
+
+Ext.define('Ext.chart.theme.Theme', {
+
+
+
+ requires: ['Ext.draw.Color'],
+
+
+
+ theme: 'Base',
+ themeAttrs: false,
+
+ initTheme: function(theme) {
+ var me = this,
+ themes = Ext.chart.theme,
+ key, gradients;
+ if (theme) {
+ theme = theme.split(':');
+ for (key in themes) {
+ if (key == theme[0]) {
+ gradients = theme[1] == 'gradients';
+ me.themeAttrs = new themes[key]({
+ useGradients: gradients
+ });
+ if (gradients) {
+ me.gradients = me.themeAttrs.gradients;
+ }
+ if (me.themeAttrs.background) {
+ me.background = me.themeAttrs.background;
+ }
+ return;
+ }
+ }
+ }
+ }
+},
+
+function() {
+
+
+(function() {
+ Ext.chart.theme = function(config, base) {
+ config = config || {};
+ var i = 0, l, colors, color,
+ seriesThemes, markerThemes,
+ seriesTheme, markerTheme,
+ key, gradients = [],
+ midColor, midL;
+
+ if (config.baseColor) {
+ midColor = Ext.draw.Color.fromString(config.baseColor);
+ midL = midColor.getHSL()[2];
+ if (midL < 0.15) {
+ midColor = midColor.getLighter(0.3);
+ } else if (midL < 0.3) {
+ midColor = midColor.getLighter(0.15);
+ } else if (midL > 0.85) {
+ midColor = midColor.getDarker(0.3);
+ } else if (midL > 0.7) {
+ midColor = midColor.getDarker(0.15);
+ }
+ config.colors = [ midColor.getDarker(0.3).toString(),
+ midColor.getDarker(0.15).toString(),
+ midColor.toString(),
+ midColor.getLighter(0.15).toString(),
+ midColor.getLighter(0.3).toString()];
+
+ delete config.baseColor;
+ }
+ if (config.colors) {
+ colors = config.colors.slice();
+ markerThemes = base.markerThemes;
+ seriesThemes = base.seriesThemes;
+ l = colors.length;
+ base.colors = colors;
+ for (; i < l; i++) {
+ color = colors[i];
+ markerTheme = markerThemes[i] || {};
+ seriesTheme = seriesThemes[i] || {};
+ markerTheme.fill = seriesTheme.fill = markerTheme.stroke = seriesTheme.stroke = color;
+ markerThemes[i] = markerTheme;
+ seriesThemes[i] = seriesTheme;
+ }
+ base.markerThemes = markerThemes.slice(0, l);
+ base.seriesThemes = seriesThemes.slice(0, l);
+
+ }
+ for (key in base) {
+ if (key in config) {
+ if (Ext.isObject(config[key]) && Ext.isObject(base[key])) {
+ Ext.apply(base[key], config[key]);
+ } else {
+ base[key] = config[key];
+ }
+ }
+ }
+ if (config.useGradients) {
+ colors = base.colors || (function () {
+ var ans = [];
+ for (i = 0, seriesThemes = base.seriesThemes, l = seriesThemes.length; i < l; i++) {
+ ans.push(seriesThemes[i].fill || seriesThemes[i].stroke);
+ }
+ return ans;
+ })();
+ for (i = 0, l = colors.length; i < l; i++) {
+ midColor = Ext.draw.Color.fromString(colors[i]);
+ if (midColor) {
+ color = midColor.getDarker(0.1).toString();
+ midColor = midColor.toString();
+ key = 'theme-' + midColor.substr(1) + '-' + color.substr(1);
+ gradients.push({
+ id: key,
+ angle: 45,
+ stops: {
+ 0: {
+ color: midColor.toString()
+ },
+ 100: {
+ color: color.toString()
+ }
+ }
+ });
+ colors[i] = 'url(#' + key + ')';
+ }
+ }
+ base.gradients = gradients;
+ base.colors = colors;
+ }
+
+ Ext.apply(this, base);
+ };
+})();
+});
+
+
+Ext.define('Ext.chart.Mask', {
+ require: ['Ext.chart.MaskLayer'],
+
+ constructor: function(config) {
+ var me = this;
+
+ me.addEvents('select');
+
+ if (config) {
+ Ext.apply(me, config);
+ }
+ if (me.mask) {
+ me.on('afterrender', function() {
+
+ var comp = Ext.create('Ext.chart.MaskLayer', {
+ renderTo: me.el
+ });
+ comp.el.on({
+ 'mousemove': function(e) {
+ me.onMouseMove(e);
+ },
+ 'mouseup': function(e) {
+ me.resized(e);
+ }
+ });
+
+ var resizeHandler = Ext.create('Ext.resizer.Resizer', {
+ el: comp.el,
+ handles: 'all',
+ pinned: true
+ });
+ resizeHandler.on({
+ 'resize': function(e) {
+ me.resized(e);
+ }
+ });
+ comp.initDraggable();
+ me.maskType = me.mask;
+ me.mask = comp;
+ me.maskSprite = me.surface.add({
+ type: 'path',
+ path: ['M', 0, 0],
+ zIndex: 1001,
+ opacity: 0.7,
+ hidden: true,
+ stroke: '#444'
+ });
+ }, me, { single: true });
+ }
+ },
+
+ resized: function(e) {
+ var me = this,
+ bbox = me.bbox || me.chartBBox,
+ x = bbox.x,
+ y = bbox.y,
+ width = bbox.width,
+ height = bbox.height,
+ box = me.mask.getBox(true),
+ max = Math.max,
+ min = Math.min,
+ staticX = box.x - x,
+ staticY = box.y - y;
+
+ staticX = max(staticX, x);
+ staticY = max(staticY, y);
+ staticX = min(staticX, width);
+ staticY = min(staticY, height);
+ box.x = staticX;
+ box.y = staticY;
+ me.fireEvent('select', me, box);
+ },
+
+ onMouseUp: function(e) {
+ var me = this,
+ bbox = me.bbox || me.chartBBox,
+ sel = me.maskSelection;
+ me.maskMouseDown = false;
+ me.mouseDown = false;
+ if (me.mouseMoved) {
+ me.onMouseMove(e);
+ me.mouseMoved = false;
+ me.fireEvent('select', me, {
+ x: sel.x - bbox.x,
+ y: sel.y - bbox.y,
+ width: sel.width,
+ height: sel.height
+ });
+ }
+ },
+
+ onMouseDown: function(e) {
+ var me = this;
+ me.mouseDown = true;
+ me.mouseMoved = false;
+ me.maskMouseDown = {
+ x: e.getPageX() - me.el.getX(),
+ y: e.getPageY() - me.el.getY()