ext-all-debug.js
资源名称:demo.zip [点击查看]
上传用户:chliyg
上传日期:2016-05-15
资源大小:3196k
文件大小:951k
源码类别:
Jsp/Servlet
开发平台:
Java
- update : function(date, forceRefresh){
- var vd = this.activeDate;
- this.activeDate = date;
- if(!forceRefresh && vd && this.el){
- var t = date.getTime();
- if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
- this.cells.removeClass("x-date-selected");
- this.cells.each(function(c){
- if(c.dom.firstChild.dateValue == t){
- c.addClass("x-date-selected");
- setTimeout(function(){
- try{c.dom.firstChild.focus();}catch(e){}
- }, 50);
- return false;
- }
- });
- return;
- }
- }
- var days = date.getDaysInMonth();
- var firstOfMonth = date.getFirstDateOfMonth();
- var startingPos = firstOfMonth.getDay()-this.startDay;
- if(startingPos <= this.startDay){
- startingPos += 7;
- }
- var pm = date.add("mo", -1);
- var prevStart = pm.getDaysInMonth()-startingPos;
- var cells = this.cells.elements;
- var textEls = this.textNodes;
- days += startingPos;
- var day = 86400000;
- var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
- var today = new Date().clearTime().getTime();
- var sel = date.clearTime().getTime();
- var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
- var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
- var ddMatch = this.disabledDatesRE;
- var ddText = this.disabledDatesText;
- var ddays = this.disabledDays ? this.disabledDays.join("") : false;
- var ddaysText = this.disabledDaysText;
- var format = this.format;
- if(this.showToday){
- var td = new Date().clearTime();
- var disable = (td < min || td > max ||
- (ddMatch && format && ddMatch.test(td.dateFormat(format))) ||
- (ddays && ddays.indexOf(td.getDay()) != -1));
- this.todayBtn.setDisabled(disable);
- this.todayKeyListener[disable ? 'disable' : 'enable']();
- }
- var setCellClass = function(cal, cell){
- cell.title = "";
- var t = d.getTime();
- cell.firstChild.dateValue = t;
- if(t == today){
- cell.className += " x-date-today";
- cell.title = cal.todayText;
- }
- if(t == sel){
- cell.className += " x-date-selected";
- setTimeout(function(){
- try{cell.firstChild.focus();}catch(e){}
- }, 50);
- }
- if(t < min) {
- cell.className = " x-date-disabled";
- cell.title = cal.minText;
- return;
- }
- if(t > max) {
- cell.className = " x-date-disabled";
- cell.title = cal.maxText;
- return;
- }
- if(ddays){
- if(ddays.indexOf(d.getDay()) != -1){
- cell.title = ddaysText;
- cell.className = " x-date-disabled";
- }
- }
- if(ddMatch && format){
- var fvalue = d.dateFormat(format);
- if(ddMatch.test(fvalue)){
- cell.title = ddText.replace("%0", fvalue);
- cell.className = " x-date-disabled";
- }
- }
- };
- var i = 0;
- for(; i < startingPos; i++) {
- textEls[i].innerHTML = (++prevStart);
- d.setDate(d.getDate()+1);
- cells[i].className = "x-date-prevday";
- setCellClass(this, cells[i]);
- }
- for(; i < days; i++){
- intDay = i - startingPos + 1;
- textEls[i].innerHTML = (intDay);
- d.setDate(d.getDate()+1);
- cells[i].className = "x-date-active";
- setCellClass(this, cells[i]);
- }
- var extraDays = 0;
- for(; i < 42; i++) {
- textEls[i].innerHTML = (++extraDays);
- d.setDate(d.getDate()+1);
- cells[i].className = "x-date-nextday";
- setCellClass(this, cells[i]);
- }
- this.mbtn.setText(this.monthNames[date.getMonth()] + " " + date.getFullYear());
- if(!this.internalRender){
- var main = this.el.dom.firstChild;
- var w = main.offsetWidth;
- this.el.setWidth(w + this.el.getBorderWidth("lr"));
- Ext.fly(main).setWidth(w);
- this.internalRender = true;
- if(Ext.isOpera && !this.secondPass){
- main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
- this.secondPass = true;
- this.update.defer(10, this, [date]);
- }
- }
- },
- beforeDestroy : function() {
- if(this.rendered){
- Ext.destroy(this.mbtn, this.todayBtn);
- }
- }
- });
- Ext.reg('datepicker', Ext.DatePicker); Ext.TabPanel = Ext.extend(Ext.Panel, { monitorResize : true, deferredRender : true, tabWidth: 120, minTabWidth: 30, resizeTabs:false, enableTabScroll: false, scrollIncrement : 0, scrollRepeatInterval : 400, scrollDuration : .35, animScroll : true, tabPosition: 'top', baseCls: 'x-tab-panel', autoTabs : false, autoTabSelector:'div.x-tab', activeTab : null, tabMargin : 2, plain: false, wheelIncrement : 20, idDelimiter : '__', itemCls : 'x-tab-item', elements: 'body', headerAsText: false, frame: false, hideBorders:true, initComponent : function(){ this.frame = false; Ext.TabPanel.superclass.initComponent.call(this); this.addEvents( 'beforetabchange', 'tabchange', 'contextmenu' ); this.setLayout(new Ext.layout.CardLayout({ deferredRender: this.deferredRender })); if(this.tabPosition == 'top'){ this.elements += ',header'; this.stripTarget = 'header'; }else { this.elements += ',footer'; this.stripTarget = 'footer'; } if(!this.stack){ this.stack = Ext.TabPanel.AccessStack(); } this.initItems(); }, render : function(){ Ext.TabPanel.superclass.render.apply(this, arguments); if(this.activeTab !== undefined){ var item = this.activeTab; delete this.activeTab; this.setActiveTab(item); } }, onRender : function(ct, position){ Ext.TabPanel.superclass.onRender.call(this, ct, position); if(this.plain){ var pos = this.tabPosition == 'top' ? 'header' : 'footer'; this[pos].addClass('x-tab-panel-'+pos+'-plain'); } var st = this[this.stripTarget]; this.stripWrap = st.createChild({cls:'x-tab-strip-wrap', cn:{ tag:'ul', cls:'x-tab-strip x-tab-strip-'+this.tabPosition}}); var beforeEl = (this.tabPosition=='bottom' ? this.stripWrap : null); this.stripSpacer = st.createChild({cls:'x-tab-strip-spacer'}, beforeEl); this.strip = new Ext.Element(this.stripWrap.dom.firstChild); this.edge = this.strip.createChild({tag:'li', cls:'x-tab-edge'}); this.strip.createChild({cls:'x-clear'}); this.body.addClass('x-tab-panel-body-'+this.tabPosition); if(!this.itemTpl){ var tt = new Ext.Template( '<li class="{cls}" id="{id}"><a class="x-tab-strip-close" onclick="return false;"></a>', '<a class="x-tab-right" href="#" onclick="return false;"><em class="x-tab-left">', '<span class="x-tab-strip-inner"><span class="x-tab-strip-text {iconCls}">{text}</span></span>', '</em></a></li>' ); tt.disableFormats = true; tt.compile(); Ext.TabPanel.prototype.itemTpl = tt; } this.items.each(this.initTab, this); }, afterRender : function(){ Ext.TabPanel.superclass.afterRender.call(this); if(this.autoTabs){ this.readTabs(false); } }, initEvents : function(){ Ext.TabPanel.superclass.initEvents.call(this); this.on('add', this.onAdd, this); this.on('remove', this.onRemove, this); this.strip.on('mousedown', this.onStripMouseDown, this); this.strip.on('contextmenu', this.onStripContextMenu, this); if(this.enableTabScroll){ this.strip.on('mousewheel', this.onWheel, this); } }, findTargets : function(e){ var item = null; var itemEl = e.getTarget('li', this.strip); if(itemEl){ item = this.getComponent(itemEl.id.split(this.idDelimiter)[1]); if(item.disabled){ return { close : null, item : null, el : null }; } } return { close : e.getTarget('.x-tab-strip-close', this.strip), item : item, el : itemEl }; }, onStripMouseDown : function(e){ if(e.button != 0){ return; } e.preventDefault(); var t = this.findTargets(e); if(t.close){ this.remove(t.item); return; } if(t.item && t.item != this.activeTab){ this.setActiveTab(t.item); } }, onStripContextMenu : function(e){ e.preventDefault(); var t = this.findTargets(e); if(t.item){ this.fireEvent('contextmenu', this, t.item, e); } }, readTabs : function(removeExisting){ if(removeExisting === true){ this.items.each(function(item){ this.remove(item); }, this); } var tabs = this.el.query(this.autoTabSelector); for(var i = 0, len = tabs.length; i < len; i++){ var tab = tabs[i]; var title = tab.getAttribute('title'); tab.removeAttribute('title'); this.add({ title: title, el: tab }); } }, initTab : function(item, index){ var before = this.strip.dom.childNodes[index]; var cls = item.closable ? 'x-tab-strip-closable' : ''; if(item.disabled){ cls += ' x-item-disabled'; } if(item.iconCls){ cls += ' x-tab-with-icon'; } if(item.tabCls){ cls += ' ' + item.tabCls; } var p = { id: this.id + this.idDelimiter + item.getItemId(), text: item.title, cls: cls, iconCls: item.iconCls || '' }; var el = before ? this.itemTpl.insertBefore(before, p) : this.itemTpl.append(this.strip, p); Ext.fly(el).addClassOnOver('x-tab-strip-over'); if(item.tabTip){ Ext.fly(el).child('span.x-tab-strip-text', true).qtip = item.tabTip; } item.on('disable', this.onItemDisabled, this); item.on('enable', this.onItemEnabled, this); item.on('titlechange', this.onItemTitleChanged, this); item.on('beforeshow', this.onBeforeShowItem, this); }, onAdd : function(tp, item, index){ this.initTab(item, index); if(this.items.getCount() == 1){ this.syncSize(); } this.delegateUpdates(); }, onBeforeAdd : function(item){ var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item); if(existing){ this.setActiveTab(item); return false; } Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments); var es = item.elements; item.elements = es ? es.replace(',header', '') : es; item.border = (item.border === true); }, onRemove : function(tp, item){ Ext.removeNode(this.getTabEl(item)); this.stack.remove(item); item.un('disable', this.onItemDisabled, this); item.un('enable', this.onItemEnabled, this); item.un('titlechange', this.onItemTitleChanged, this); item.un('beforeshow', this.onBeforeShowItem, this); if(item == this.activeTab){ var next = this.stack.next(); if(next){ this.setActiveTab(next); }else{ this.setActiveTab(0); } } this.delegateUpdates(); }, onBeforeShowItem : function(item){ if(item != this.activeTab){ this.setActiveTab(item); return false; } }, onItemDisabled : function(item){ var el = this.getTabEl(item); if(el){ Ext.fly(el).addClass('x-item-disabled'); } this.stack.remove(item); }, onItemEnabled : function(item){ var el = this.getTabEl(item); if(el){ Ext.fly(el).removeClass('x-item-disabled'); } }, onItemTitleChanged : function(item){ var el = this.getTabEl(item); if(el){ Ext.fly(el).child('span.x-tab-strip-text', true).innerHTML = item.title; } }, getTabEl : function(item){ var itemId = (typeof item === 'number')?this.items.items[item].getItemId() : item.getItemId(); return document.getElementById(this.id+this.idDelimiter+itemId); }, onResize : function(){ Ext.TabPanel.superclass.onResize.apply(this, arguments); this.delegateUpdates(); }, beginUpdate : function(){ this.suspendUpdates = true; }, endUpdate : function(){ this.suspendUpdates = false; this.delegateUpdates(); }, hideTabStripItem : function(item){ item = this.getComponent(item); var el = this.getTabEl(item); if(el){ el.style.display = 'none'; this.delegateUpdates(); } this.stack.remove(item); }, unhideTabStripItem : function(item){ item = this.getComponent(item); var el = this.getTabEl(item); if(el){ el.style.display = ''; this.delegateUpdates(); } }, delegateUpdates : function(){ if(this.suspendUpdates){ return; } if(this.resizeTabs && this.rendered){ this.autoSizeTabs(); } if(this.enableTabScroll && this.rendered){ this.autoScrollTabs(); } }, autoSizeTabs : function(){ var count = this.items.length; var ce = this.tabPosition != 'bottom' ? 'header' : 'footer'; var ow = this[ce].dom.offsetWidth; var aw = this[ce].dom.clientWidth; if(!this.resizeTabs || count < 1 || !aw){ return; } var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.tabMargin, this.tabWidth), this.minTabWidth); this.lastTabWidth = each; var lis = this.stripWrap.dom.getElementsByTagName('li'); for(var i = 0, len = lis.length-1; i < len; i++) { var li = lis[i]; var inner = li.childNodes[1].firstChild.firstChild; var tw = li.offsetWidth; var iw = inner.offsetWidth; inner.style.width = (each - (tw-iw)) + 'px'; } }, adjustBodyWidth : function(w){ if(this.header){ this.header.setWidth(w); } if(this.footer){ this.footer.setWidth(w); } return w; }, setActiveTab : function(item){ item = this.getComponent(item); if(!item || this.fireEvent('beforetabchange', this, item, this.activeTab) === false){ return; } if(!this.rendered){ this.activeTab = item; return; } if(this.activeTab != item){ if(this.activeTab){ var oldEl = this.getTabEl(this.activeTab); if(oldEl){ Ext.fly(oldEl).removeClass('x-tab-strip-active'); } this.activeTab.fireEvent('deactivate', this.activeTab); } var el = this.getTabEl(item); Ext.fly(el).addClass('x-tab-strip-active'); this.activeTab = item; this.stack.add(item); this.layout.setActiveItem(item); if(this.layoutOnTabChange && item.doLayout){ item.doLayout(); } if(this.scrolling){ this.scrollToTab(item, this.animScroll); } item.fireEvent('activate', item); this.fireEvent('tabchange', this, item); } }, getActiveTab : function(){ return this.activeTab || null; }, getItem : function(item){ return this.getComponent(item); }, autoScrollTabs : function(){ var count = this.items.length; var ow = this.header.dom.offsetWidth; var tw = this.header.dom.clientWidth; var wrap = this.stripWrap; var wd = wrap.dom; var cw = wd.offsetWidth; var pos = this.getScrollPos(); var l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos; if(!this.enableTabScroll || count < 1 || cw < 20){ return; } if(l <= tw){ wd.scrollLeft = 0; wrap.setWidth(tw); if(this.scrolling){ this.scrolling = false; this.header.removeClass('x-tab-scrolling'); this.scrollLeft.hide(); this.scrollRight.hide(); if(Ext.isAir){ wd.style.marginLeft = ''; wd.style.marginRight = ''; } } }else{ if(!this.scrolling){ this.header.addClass('x-tab-scrolling'); if(Ext.isAir){ wd.style.marginLeft = '18px'; wd.style.marginRight = '18px'; } } tw -= wrap.getMargins('lr'); wrap.setWidth(tw > 20 ? tw : 20); if(!this.scrolling){ if(!this.scrollLeft){ this.createScrollers(); }else{ this.scrollLeft.show(); this.scrollRight.show(); } } this.scrolling = true; if(pos > (l-tw)){ wd.scrollLeft = l-tw; }else{ this.scrollToTab(this.activeTab, false); } this.updateScrollButtons(); } }, createScrollers : function(){ var h = this.stripWrap.dom.offsetHeight; var sl = this.header.insertFirst({ cls:'x-tab-scroller-left' }); sl.setHeight(h); sl.addClassOnOver('x-tab-scroller-left-over'); this.leftRepeater = new Ext.util.ClickRepeater(sl, { interval : this.scrollRepeatInterval, handler: this.onScrollLeft, scope: this }); this.scrollLeft = sl; var sr = this.header.insertFirst({ cls:'x-tab-scroller-right' }); sr.setHeight(h); sr.addClassOnOver('x-tab-scroller-right-over'); this.rightRepeater = new Ext.util.ClickRepeater(sr, { interval : this.scrollRepeatInterval, handler: this.onScrollRight, scope: this }); this.scrollRight = sr; }, getScrollWidth : function(){ return this.edge.getOffsetsTo(this.stripWrap)[0] + this.getScrollPos(); }, getScrollPos : function(){ return parseInt(this.stripWrap.dom.scrollLeft, 10) || 0; }, getScrollArea : function(){ return parseInt(this.stripWrap.dom.clientWidth, 10) || 0; }, getScrollAnim : function(){ return {duration:this.scrollDuration, callback: this.updateScrollButtons, scope: this}; }, getScrollIncrement : function(){ return this.scrollIncrement || (this.resizeTabs ? this.lastTabWidth+2 : 100); }, scrollToTab : function(item, animate){ if(!item){ return; } var el = this.getTabEl(item); var pos = this.getScrollPos(), area = this.getScrollArea(); var left = Ext.fly(el).getOffsetsTo(this.stripWrap)[0] + pos; var right = left + el.offsetWidth; if(left < pos){ this.scrollTo(left, animate); }else if(right > (pos + area)){ this.scrollTo(right - area, animate); } }, scrollTo : function(pos, animate){ this.stripWrap.scrollTo('left', pos, animate ? this.getScrollAnim() : false); if(!animate){ this.updateScrollButtons(); } }, onWheel : function(e){ var d = e.getWheelDelta()*this.wheelIncrement*-1; e.stopEvent(); var pos = this.getScrollPos(); var newpos = pos + d; var sw = this.getScrollWidth()-this.getScrollArea(); var s = Math.max(0, Math.min(sw, newpos)); if(s != pos){ this.scrollTo(s, false); } }, onScrollRight : function(){ var sw = this.getScrollWidth()-this.getScrollArea(); var pos = this.getScrollPos(); var s = Math.min(sw, pos + this.getScrollIncrement()); if(s != pos){ this.scrollTo(s, this.animScroll); } }, onScrollLeft : function(){ var pos = this.getScrollPos(); var s = Math.max(0, pos - this.getScrollIncrement()); if(s != pos){ this.scrollTo(s, this.animScroll); } }, updateScrollButtons : function(){ var pos = this.getScrollPos(); this.scrollLeft[pos == 0 ? 'addClass' : 'removeClass']('x-tab-scroller-left-disabled'); this.scrollRight[pos >= (this.getScrollWidth()-this.getScrollArea()) ? 'addClass' : 'removeClass']('x-tab-scroller-right-disabled'); } }); Ext.reg('tabpanel', Ext.TabPanel); Ext.TabPanel.prototype.activate = Ext.TabPanel.prototype.setActiveTab; Ext.TabPanel.AccessStack = function(){ var items = []; return { add : function(item){ items.push(item); if(items.length > 10){ items.shift(); } }, remove : function(item){ var s = []; for(var i = 0, len = items.length; i < len; i++) { if(items[i] != item){ s.push(items[i]); } } items = s; }, next : function(){ return items.pop(); } }; }; Ext.Button = Ext.extend(Ext.Component, { hidden : false, disabled : false, pressed : false, enableToggle: false, menuAlign : "tl-bl?", type : 'button', menuClassTarget: 'tr', clickEvent : 'click', handleMouseEvents : true, tooltipType : 'qtip', buttonSelector : "button:first", initComponent : function(){ Ext.Button.superclass.initComponent.call(this); this.addEvents( "click", "toggle", 'mouseover', 'mouseout', 'menushow', 'menuhide', 'menutriggerover', 'menutriggerout' ); if(this.menu){ this.menu = Ext.menu.MenuMgr.get(this.menu); } if(typeof this.toggleGroup === 'string'){ this.enableToggle = true; } }, onRender : function(ct, position){ if(!this.template){ if(!Ext.Button.buttonTemplate){ Ext.Button.buttonTemplate = new Ext.Template( '<table border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr>', '<td class="x-btn-left"><i> </i></td><td class="x-btn-center"><em unselectable="on"><button class="x-btn-text" type="{1}">{0}</button></em></td><td class="x-btn-right"><i> </i></td>', "</tr></tbody></table>"); } this.template = Ext.Button.buttonTemplate; } var btn, targs = [this.text || ' ', this.type]; if(position){ btn = this.template.insertBefore(position, targs, true); }else{ btn = this.template.append(ct, targs, true); } var btnEl = btn.child(this.buttonSelector); btnEl.on('focus', this.onFocus, this); btnEl.on('blur', this.onBlur, this); this.initButtonEl(btn, btnEl); if(this.menu){ this.el.child(this.menuClassTarget).addClass("x-btn-with-menu"); } Ext.ButtonToggleMgr.register(this); }, initButtonEl : function(btn, btnEl){ this.el = btn; btn.addClass("x-btn"); if(this.icon){ btnEl.setStyle('background-image', 'url(' +this.icon +')'); } if(this.iconCls){ btnEl.addClass(this.iconCls); if(!this.cls){ btn.addClass(this.text ? 'x-btn-text-icon' : 'x-btn-icon'); } } if(this.tabIndex !== undefined){ btnEl.dom.tabIndex = this.tabIndex; } if(this.tooltip){ if(typeof this.tooltip == 'object'){ Ext.QuickTips.register(Ext.apply({ target: btnEl.id }, this.tooltip)); } else { btnEl.dom[this.tooltipType] = this.tooltip; } } if(this.pressed){ this.el.addClass("x-btn-pressed"); } if(this.handleMouseEvents){ btn.on("mouseover", this.onMouseOver, this); btn.on("mousedown", this.onMouseDown, this); } if(this.menu){ this.menu.on("show", this.onMenuShow, this); this.menu.on("hide", this.onMenuHide, this); } if(this.id){ this.el.dom.id = this.el.id = this.id; } if(this.repeat){ var repeater = new Ext.util.ClickRepeater(btn, typeof this.repeat == "object" ? this.repeat : {} ); repeater.on("click", this.onClick, this); } btn.on(this.clickEvent, this.onClick, this); }, afterRender : function(){ Ext.Button.superclass.afterRender.call(this); if(Ext.isIE6){ this.autoWidth.defer(1, this); }else{ this.autoWidth(); } }, setIconClass : function(cls){ if(this.el){ this.el.child(this.buttonSelector).replaceClass(this.iconCls, cls); } this.iconCls = cls; }, beforeDestroy: function(){ if(this.rendered){ var btn = this.el.child(this.buttonSelector); if(btn){ btn.removeAllListeners(); } } if(this.menu){ Ext.destroy(this.menu); } }, onDestroy : function(){ if(this.rendered){ Ext.ButtonToggleMgr.unregister(this); } }, autoWidth : function(){ if(this.el){ this.el.setWidth("auto"); if(Ext.isIE7 && Ext.isStrict){ var ib = this.el.child(this.buttonSelector); if(ib && ib.getWidth() > 20){ ib.clip(); ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr')); } } if(this.minWidth){ if(this.el.getWidth() < this.minWidth){ this.el.setWidth(this.minWidth); } } } }, setHandler : function(handler, scope){ this.handler = handler; this.scope = scope; }, setText : function(text){ this.text = text; if(this.el){ this.el.child("td.x-btn-center " + this.buttonSelector).update(text); } this.autoWidth(); }, getText : function(){ return this.text; }, toggle : function(state){ state = state === undefined ? !this.pressed : state; if(state != this.pressed){ if(state){ this.el.addClass("x-btn-pressed"); this.pressed = true; this.fireEvent("toggle", this, true); }else{ this.el.removeClass("x-btn-pressed"); this.pressed = false; this.fireEvent("toggle", this, false); } if(this.toggleHandler){ this.toggleHandler.call(this.scope || this, this, state); } } }, focus : function(){ this.el.child(this.buttonSelector).focus(); }, onDisable : function(){ if(this.el){ if(!Ext.isIE6 || !this.text){ this.el.addClass(this.disabledClass); } this.el.dom.disabled = true; } this.disabled = true; }, onEnable : function(){ if(this.el){ if(!Ext.isIE6 || !this.text){ this.el.removeClass(this.disabledClass); } this.el.dom.disabled = false; } this.disabled = false; }, showMenu : function(){ if(this.menu){ this.menu.show(this.el, this.menuAlign); } return this; }, hideMenu : function(){ if(this.menu){ this.menu.hide(); } return this; }, hasVisibleMenu : function(){ return this.menu && this.menu.isVisible(); }, onClick : function(e){ if(e){ e.preventDefault(); } if(e.button != 0){ return; } if(!this.disabled){ if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){ this.toggle(); } if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){ this.showMenu(); } this.fireEvent("click", this, e); if(this.handler){ this.handler.call(this.scope || this, this, e); } } }, isMenuTriggerOver : function(e, internal){ return this.menu && !internal; }, isMenuTriggerOut : function(e, internal){ return this.menu && !internal; }, onMouseOver : function(e){ if(!this.disabled){ var internal = e.within(this.el, true); if(!internal){ this.el.addClass("x-btn-over"); if(!this.monitoringMouseOver){ Ext.getDoc().on('mouseover', this.monitorMouseOver, this); this.monitoringMouseOver = true; } this.fireEvent('mouseover', this, e); } if(this.isMenuTriggerOver(e, internal)){ this.fireEvent('menutriggerover', this, this.menu, e); } } }, monitorMouseOver : function(e){ if(e.target != this.el.dom && !e.within(this.el)){ if(this.monitoringMouseOver){ Ext.getDoc().un('mouseover', this.monitorMouseOver, this); this.monitoringMouseOver = false; } this.onMouseOut(e); } }, onMouseOut : function(e){ var internal = e.within(this.el) && e.target != this.el.dom; this.el.removeClass("x-btn-over"); this.fireEvent('mouseout', this, e); if(this.isMenuTriggerOut(e, internal)){ this.fireEvent('menutriggerout', this, this.menu, e); } }, onFocus : function(e){ if(!this.disabled){ this.el.addClass("x-btn-focus"); } }, onBlur : function(e){ this.el.removeClass("x-btn-focus"); }, getClickEl : function(e, isUp){ return this.el; }, onMouseDown : function(e){ if(!this.disabled && e.button == 0){ this.getClickEl(e).addClass("x-btn-click"); Ext.getDoc().on('mouseup', this.onMouseUp, this); } }, onMouseUp : function(e){ if(e.button == 0){ this.getClickEl(e, true).removeClass("x-btn-click"); Ext.getDoc().un('mouseup', this.onMouseUp, this); } }, onMenuShow : function(e){ this.ignoreNextClick = 0; this.el.addClass("x-btn-menu-active"); this.fireEvent('menushow', this, this.menu); }, onMenuHide : function(e){ this.el.removeClass("x-btn-menu-active"); this.ignoreNextClick = this.restoreClick.defer(250, this); this.fireEvent('menuhide', this, this.menu); }, restoreClick : function(){ this.ignoreNextClick = 0; } }); Ext.reg('button', Ext.Button); Ext.ButtonToggleMgr = function(){ var groups = {}; function toggleGroup(btn, state){ if(state){ var g = groups[btn.toggleGroup]; for(var i = 0, l = g.length; i < l; i++){ if(g[i] != btn){ g[i].toggle(false); } } } } return { register : function(btn){ if(!btn.toggleGroup){ return; } var g = groups[btn.toggleGroup]; if(!g){ g = groups[btn.toggleGroup] = []; } g.push(btn); btn.on("toggle", toggleGroup); }, unregister : function(btn){ if(!btn.toggleGroup){ return; } var g = groups[btn.toggleGroup]; if(g){ g.remove(btn); btn.un("toggle", toggleGroup); } } }; }();
- Ext.SplitButton = Ext.extend(Ext.Button, {
- arrowSelector : 'button:last',
- initComponent : function(){
- Ext.SplitButton.superclass.initComponent.call(this);
- this.addEvents("arrowclick");
- },
- onRender : function(ct, position){
- var tpl = new Ext.Template(
- '<table cellspacing="0" class="x-btn-menu-wrap x-btn"><tr><td>',
- '<table cellspacing="0" class="x-btn-wrap x-btn-menu-text-wrap"><tbody>',
- '<tr><td class="x-btn-left"><i> </i></td><td class="x-btn-center"><button class="x-btn-text" type="{1}">{0}</button></td></tr>',
- "</tbody></table></td><td>",
- '<table cellspacing="0" class="x-btn-wrap x-btn-menu-arrow-wrap"><tbody>',
- '<tr><td class="x-btn-center"><button class="x-btn-menu-arrow-el" type="button"> </button></td><td class="x-btn-right"><i> </i></td></tr>',
- "</tbody></table></td></tr></table>"
- );
- var btn, targs = [this.text || ' ', this.type];
- if(position){
- btn = tpl.insertBefore(position, targs, true);
- }else{
- btn = tpl.append(ct, targs, true);
- }
- var btnEl = btn.child(this.buttonSelector);
- this.initButtonEl(btn, btnEl);
- this.arrowBtnTable = btn.child("table:last");
- if(this.arrowTooltip){
- btn.child(this.arrowSelector).dom[this.tooltipType] = this.arrowTooltip;
- }
- },
- autoWidth : function(){
- if(this.el){
- var tbl = this.el.child("table:first");
- var tbl2 = this.el.child("table:last");
- this.el.setWidth("auto");
- tbl.setWidth("auto");
- if(Ext.isIE7 && Ext.isStrict){
- var ib = this.el.child(this.buttonSelector);
- if(ib && ib.getWidth() > 20){
- ib.clip();
- ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
- }
- }
- if(this.minWidth){
- if((tbl.getWidth()+tbl2.getWidth()) < this.minWidth){
- tbl.setWidth(this.minWidth-tbl2.getWidth());
- }
- }
- this.el.setWidth(tbl.getWidth()+tbl2.getWidth());
- }
- },
- setArrowHandler : function(handler, scope){
- this.arrowHandler = handler;
- this.scope = scope;
- },
- onClick : function(e){
- e.preventDefault();
- if(!this.disabled){
- if(e.getTarget(".x-btn-menu-arrow-wrap")){
- if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
- this.showMenu();
- }
- this.fireEvent("arrowclick", this, e);
- if(this.arrowHandler){
- this.arrowHandler.call(this.scope || this, this, e);
- }
- }else{
- if(this.enableToggle){
- this.toggle();
- }
- this.fireEvent("click", this, e);
- if(this.handler){
- this.handler.call(this.scope || this, this, e);
- }
- }
- }
- },
- getClickEl : function(e, isUp){
- if(!isUp){
- return (this.lastClickEl = e.getTarget("table", 10, true));
- }
- return this.lastClickEl;
- },
- onDisable : function(){
- if(this.el){
- if(!Ext.isIE6){
- this.el.addClass("x-item-disabled");
- }
- this.el.child(this.buttonSelector).dom.disabled = true;
- this.el.child(this.arrowSelector).dom.disabled = true;
- }
- this.disabled = true;
- },
- onEnable : function(){
- if(this.el){
- if(!Ext.isIE6){
- this.el.removeClass("x-item-disabled");
- }
- this.el.child(this.buttonSelector).dom.disabled = false;
- this.el.child(this.arrowSelector).dom.disabled = false;
- }
- this.disabled = false;
- },
- isMenuTriggerOver : function(e){
- return this.menu && e.within(this.arrowBtnTable) && !e.within(this.arrowBtnTable, true);
- },
- isMenuTriggerOut : function(e, internal){
- return this.menu && !e.within(this.arrowBtnTable);
- },
- onDestroy : function(){
- Ext.destroy(this.arrowBtnTable);
- Ext.SplitButton.superclass.onDestroy.call(this);
- }
- });
- Ext.MenuButton = Ext.SplitButton;
- Ext.reg('splitbutton', Ext.SplitButton);
- Ext.CycleButton = Ext.extend(Ext.SplitButton, {
- getItemText : function(item){
- if(item && this.showText === true){
- var text = '';
- if(this.prependText){
- text += this.prependText;
- }
- text += item.text;
- return text;
- }
- return undefined;
- },
- setActiveItem : function(item, suppressEvent){
- if(typeof item != 'object'){
- item = this.menu.items.get(item);
- }
- if(item){
- if(!this.rendered){
- this.text = this.getItemText(item);
- this.iconCls = item.iconCls;
- }else{
- var t = this.getItemText(item);
- if(t){
- this.setText(t);
- }
- this.setIconClass(item.iconCls);
- }
- this.activeItem = item;
- if(!item.checked){
- item.setChecked(true, true);
- }
- if(this.forceIcon){
- this.setIconClass(this.forceIcon);
- }
- if(!suppressEvent){
- this.fireEvent('change', this, item);
- }
- }
- },
- getActiveItem : function(){
- return this.activeItem;
- },
- initComponent : function(){
- this.addEvents(
- "change"
- );
- if(this.changeHandler){
- this.on('change', this.changeHandler, this.scope||this);
- delete this.changeHandler;
- }
- this.itemCount = this.items.length;
- this.menu = {cls:'x-cycle-menu', items:[]};
- var checked;
- for(var i = 0, len = this.itemCount; i < len; i++){
- var item = this.items[i];
- item.group = item.group || this.id;
- item.itemIndex = i;
- item.checkHandler = this.checkHandler;
- item.scope = this;
- item.checked = item.checked || false;
- this.menu.items.push(item);
- if(item.checked){
- checked = item;
- }
- }
- this.setActiveItem(checked, true);
- Ext.CycleButton.superclass.initComponent.call(this);
- this.on('click', this.toggleSelected, this);
- },
- checkHandler : function(item, pressed){
- if(pressed){
- this.setActiveItem(item);
- }
- },
- toggleSelected : function(){
- this.menu.render();
- var nextIdx, checkItem;
- for (var i = 1; i < this.itemCount; i++) {
- nextIdx = (this.activeItem.itemIndex + i) % this.itemCount;
- checkItem = this.menu.items.itemAt(nextIdx);
- if (!checkItem.disabled) {
- checkItem.setChecked(true);
- break;
- }
- }
- }
- });
- Ext.reg('cycle', Ext.CycleButton);
- Ext.Toolbar = function(config){
- if(Ext.isArray(config)){
- config = {buttons:config};
- }
- Ext.Toolbar.superclass.constructor.call(this, config);
- };
- (function(){
- var T = Ext.Toolbar;
- Ext.extend(T, Ext.BoxComponent, {
- trackMenus : true,
- initComponent : function(){
- T.superclass.initComponent.call(this);
- if(this.items){
- this.buttons = this.items;
- }
- this.items = new Ext.util.MixedCollection(false, function(o){
- return o.itemId || o.id || Ext.id();
- });
- },
- autoCreate: {
- cls:'x-toolbar x-small-editor',
- html:'<table cellspacing="0"><tr></tr></table>'
- },
- onRender : function(ct, position){
- this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
- this.tr = this.el.child("tr", true);
- },
- afterRender : function(){
- T.superclass.afterRender.call(this);
- if(this.buttons){
- this.add.apply(this, this.buttons);
- delete this.buttons;
- }
- },
- add : function(){
- var a = arguments, l = a.length;
- for(var i = 0; i < l; i++){
- var el = a[i];
- if(el.isFormField){ this.addField(el);
- }else if(el.render){ this.addItem(el);
- }else if(typeof el == "string"){ if(el == "separator" || el == "-"){
- this.addSeparator();
- }else if(el == " "){
- this.addSpacer();
- }else if(el == "->"){
- this.addFill();
- }else{
- this.addText(el);
- }
- }else if(el.tagName){ this.addElement(el);
- }else if(typeof el == "object"){ if(el.xtype){
- this.addField(Ext.ComponentMgr.create(el, 'button'));
- }else{
- this.addButton(el);
- }
- }
- }
- },
- addSeparator : function(){
- return this.addItem(new T.Separator());
- },
- addSpacer : function(){
- return this.addItem(new T.Spacer());
- },
- addFill : function(){
- return this.addItem(new T.Fill());
- },
- addElement : function(el){
- return this.addItem(new T.Item(el));
- },
- addItem : function(item){
- var td = this.nextBlock();
- this.initMenuTracking(item);
- item.render(td);
- this.items.add(item);
- return item;
- },
- addButton : function(config){
- if(Ext.isArray(config)){
- var buttons = [];
- for(var i = 0, len = config.length; i < len; i++) {
- buttons.push(this.addButton(config[i]));
- }
- return buttons;
- }
- var b = config;
- if(!(config instanceof T.Button)){
- b = config.split ?
- new T.SplitButton(config) :
- new T.Button(config);
- }
- var td = this.nextBlock();
- this.initMenuTracking(b);
- b.render(td);
- this.items.add(b);
- return b;
- },
- initMenuTracking : function(item){
- if(this.trackMenus && item.menu){
- item.on({
- 'menutriggerover' : this.onButtonTriggerOver,
- 'menushow' : this.onButtonMenuShow,
- 'menuhide' : this.onButtonMenuHide,
- scope: this
- })
- }
- },
- addText : function(text){
- return this.addItem(new T.TextItem(text));
- },
- insertButton : function(index, item){
- if(Ext.isArray(item)){
- var buttons = [];
- for(var i = 0, len = item.length; i < len; i++) {
- buttons.push(this.insertButton(index + i, item[i]));
- }
- return buttons;
- }
- if (!(item instanceof T.Button)){
- item = new T.Button(item);
- }
- var td = document.createElement("td");
- this.tr.insertBefore(td, this.tr.childNodes[index]);
- this.initMenuTracking(item);
- item.render(td);
- this.items.insert(index, item);
- return item;
- },
- addDom : function(config, returnEl){
- var td = this.nextBlock();
- Ext.DomHelper.overwrite(td, config);
- var ti = new T.Item(td.firstChild);
- ti.render(td);
- this.items.add(ti);
- return ti;
- },
- addField : function(field){
- var td = this.nextBlock();
- field.render(td);
- var ti = new T.Item(td.firstChild);
- ti.render(td);
- this.items.add(field);
- return ti;
- },
- nextBlock : function(){
- var td = document.createElement("td");
- this.tr.appendChild(td);
- return td;
- },
- onDestroy : function(){
- Ext.Toolbar.superclass.onDestroy.call(this);
- if(this.rendered){
- if(this.items){ Ext.destroy.apply(Ext, this.items.items);
- }
- Ext.Element.uncache(this.tr);
- }
- },
- onDisable : function(){
- this.items.each(function(item){
- if(item.disable){
- item.disable();
- }
- });
- },
- onEnable : function(){
- this.items.each(function(item){
- if(item.enable){
- item.enable();
- }
- });
- },
- onButtonTriggerOver : function(btn){
- if(this.activeMenuBtn && this.activeMenuBtn != btn){
- this.activeMenuBtn.hideMenu();
- btn.showMenu();
- this.activeMenuBtn = btn;
- }
- },
- onButtonMenuShow : function(btn){
- this.activeMenuBtn = btn;
- },
- onButtonMenuHide : function(btn){
- delete this.activeMenuBtn;
- }
- });
- Ext.reg('toolbar', Ext.Toolbar);
- T.Item = function(el){
- this.el = Ext.getDom(el);
- this.id = Ext.id(this.el);
- this.hidden = false;
- };
- T.Item.prototype = {
- getEl : function(){
- return this.el;
- },
- render : function(td){
- this.td = td;
- td.appendChild(this.el);
- },
- destroy : function(){
- if(this.td && this.td.parentNode){
- this.td.parentNode.removeChild(this.td);
- }
- },
- show: function(){
- this.hidden = false;
- this.td.style.display = "";
- },
- hide: function(){
- this.hidden = true;
- this.td.style.display = "none";
- },
- setVisible: function(visible){
- if(visible) {
- this.show();
- }else{
- this.hide();
- }
- },
- focus : function(){
- Ext.fly(this.el).focus();
- },
- disable : function(){
- Ext.fly(this.td).addClass("x-item-disabled");
- this.disabled = true;
- this.el.disabled = true;
- },
- enable : function(){
- Ext.fly(this.td).removeClass("x-item-disabled");
- this.disabled = false;
- this.el.disabled = false;
- }
- };
- Ext.reg('tbitem', T.Item);
- T.Separator = function(){
- var s = document.createElement("span");
- s.className = "ytb-sep";
- T.Separator.superclass.constructor.call(this, s);
- };
- Ext.extend(T.Separator, T.Item, {
- enable:Ext.emptyFn,
- disable:Ext.emptyFn,
- focus:Ext.emptyFn
- });
- Ext.reg('tbseparator', T.Separator);
- T.Spacer = function(){
- var s = document.createElement("div");
- s.className = "ytb-spacer";
- T.Spacer.superclass.constructor.call(this, s);
- };
- Ext.extend(T.Spacer, T.Item, {
- enable:Ext.emptyFn,
- disable:Ext.emptyFn,
- focus:Ext.emptyFn
- });
- Ext.reg('tbspacer', T.Spacer);
- T.Fill = Ext.extend(T.Spacer, {
- render : function(td){
- td.style.width = '100%';
- T.Fill.superclass.render.call(this, td);
- }
- });
- Ext.reg('tbfill', T.Fill);
- T.TextItem = function(t){
- var s = document.createElement("span");
- s.className = "ytb-text";
- s.innerHTML = t.text ? t.text : t;
- T.TextItem.superclass.constructor.call(this, s);
- };
- Ext.extend(T.TextItem, T.Item, {
- enable:Ext.emptyFn,
- disable:Ext.emptyFn,
- focus:Ext.emptyFn
- });
- Ext.reg('tbtext', T.TextItem);
- T.Button = Ext.extend(Ext.Button, {
- hideParent : true,
- onDestroy : function(){
- T.Button.superclass.onDestroy.call(this);
- if(this.container){
- this.container.remove();
- }
- }
- });
- Ext.reg('tbbutton', T.Button);
- T.SplitButton = Ext.extend(Ext.SplitButton, {
- hideParent : true,
- onDestroy : function(){
- T.SplitButton.superclass.onDestroy.call(this);
- if(this.container){
- this.container.remove();
- }
- }
- });
- Ext.reg('tbsplit', T.SplitButton);
- T.MenuButton = T.SplitButton;
- })();
- Ext.PagingToolbar = Ext.extend(Ext.Toolbar, { pageSize: 20, displayMsg : 'Displaying {0} - {1} of {2}', emptyMsg : 'No data to display', beforePageText : "Page", afterPageText : "of {0}", firstText : "First Page", prevText : "Previous Page", nextText : "Next Page", lastText : "Last Page", refreshText : "Refresh", paramNames : {start: 'start', limit: 'limit'}, initComponent : function(){ this.addEvents('change', 'beforechange'); Ext.PagingToolbar.superclass.initComponent.call(this); this.cursor = 0; this.bind(this.store); }, onRender : function(ct, position){ Ext.PagingToolbar.superclass.onRender.call(this, ct, position); this.first = this.addButton({ tooltip: this.firstText, iconCls: "x-tbar-page-first", disabled: true, handler: this.onClick.createDelegate(this, ["first"]) }); this.prev = this.addButton({ tooltip: this.prevText, iconCls: "x-tbar-page-prev", disabled: true, handler: this.onClick.createDelegate(this, ["prev"]) }); this.addSeparator(); this.add(this.beforePageText); this.field = Ext.get(this.addDom({ tag: "input", type: "text", size: "3", value: "1", cls: "x-tbar-page-number" }).el); this.field.on("keydown", this.onPagingKeydown, this); this.field.on("focus", function(){this.dom.select();}); this.afterTextEl = this.addText(String.format(this.afterPageText, 1)); this.field.setHeight(18); this.addSeparator(); this.next = this.addButton({ tooltip: this.nextText, iconCls: "x-tbar-page-next", disabled: true, handler: this.onClick.createDelegate(this, ["next"]) }); this.last = this.addButton({ tooltip: this.lastText, iconCls: "x-tbar-page-last", disabled: true, handler: this.onClick.createDelegate(this, ["last"]) }); this.addSeparator(); this.loading = this.addButton({ tooltip: this.refreshText, iconCls: "x-tbar-loading", handler: this.onClick.createDelegate(this, ["refresh"]) }); if(this.displayInfo){ this.displayEl = Ext.fly(this.el.dom).createChild({cls:'x-paging-info'}); } if(this.dsLoaded){ this.onLoad.apply(this, this.dsLoaded); } }, updateInfo : function(){ if(this.displayEl){ var count = this.store.getCount(); var msg = count == 0 ? this.emptyMsg : String.format( this.displayMsg, this.cursor+1, this.cursor+count, this.store.getTotalCount() ); this.displayEl.update(msg); } }, onLoad : function(store, r, o){ if(!this.rendered){ this.dsLoaded = [store, r, o]; return; } this.cursor = o.params ? o.params[this.paramNames.start] : 0; var d = this.getPageData(), ap = d.activePage, ps = d.pages; this.afterTextEl.el.innerHTML = String.format(this.afterPageText, d.pages); this.field.dom.value = ap; this.first.setDisabled(ap == 1); this.prev.setDisabled(ap == 1); this.next.setDisabled(ap == ps); this.last.setDisabled(ap == ps); this.loading.enable(); this.updateInfo(); this.fireEvent('change', this, d); }, getPageData : function(){ var total = this.store.getTotalCount(); return { total : total, activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize), pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize) }; }, onLoadError : function(){ if(!this.rendered){ return; } this.loading.enable(); }, readPage : function(d){ var v = this.field.dom.value, pageNum; if (!v || isNaN(pageNum = parseInt(v, 10))) { this.field.dom.value = d.activePage; return false; } return pageNum; }, onPagingKeydown : function(e){ var k = e.getKey(), d = this.getPageData(), pageNum; if (k == e.RETURN) { e.stopEvent(); pageNum = this.readPage(d); if(pageNum !== false){ pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1; this.doLoad(pageNum * this.pageSize); } }else if (k == e.HOME || k == e.END){ e.stopEvent(); pageNum = k == e.HOME ? 1 : d.pages; this.field.dom.value = pageNum; }else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN){ e.stopEvent(); if(pageNum = this.readPage(d)){ var increment = e.shiftKey ? 10 : 1; if(k == e.DOWN || k == e.PAGEDOWN){ increment *= -1; } pageNum += increment; if(pageNum >= 1 & pageNum <= d.pages){ this.field.dom.value = pageNum; } } } }, beforeLoad : function(){ if(this.rendered && this.loading){ this.loading.disable(); } }, doLoad : function(start){ var o = {}, pn = this.paramNames; o[pn.start] = start; o[pn.limit] = this.pageSize; if(this.fireEvent('beforechange', this, o) !== false){ this.store.load({params:o}); } }, changePage: function(page){ this.doLoad(((page-1) * this.pageSize).constrain(0, this.store.getTotalCount())); }, onClick : function(which){ var store = this.store; switch(which){ case "first": this.doLoad(0); break; case "prev": this.doLoad(Math.max(0, this.cursor-this.pageSize)); break; case "next": this.doLoad(this.cursor+this.pageSize); break; case "last": var total = store.getTotalCount(); var extra = total % this.pageSize; var lastStart = extra ? (total - extra) : total-this.pageSize; this.doLoad(lastStart); break; case "refresh": this.doLoad(this.cursor); break; } }, unbind : function(store){ store = Ext.StoreMgr.lookup(store); store.un("beforeload", this.beforeLoad, this); store.un("load", this.onLoad, this); store.un("loadexception", this.onLoadError, this); this.store = undefined; }, bind : function(store){ store = Ext.StoreMgr.lookup(store); store.on("beforeload", this.beforeLoad, this); store.on("load", this.onLoad, this); store.on("loadexception", this.onLoadError, this); this.store = store; } }); Ext.reg('paging', Ext.PagingToolbar);
- Ext.Resizable = function(el, config){
- this.el = Ext.get(el);
- if(config && config.wrap){
- config.resizeChild = this.el;
- this.el = this.el.wrap(typeof config.wrap == "object" ? config.wrap : {cls:"xresizable-wrap"});
- this.el.id = this.el.dom.id = config.resizeChild.id + "-rzwrap";
- this.el.setStyle("overflow", "hidden");
- this.el.setPositioning(config.resizeChild.getPositioning());
- config.resizeChild.clearPositioning();
- if(!config.width || !config.height){
- var csize = config.resizeChild.getSize();
- this.el.setSize(csize.width, csize.height);
- }
- if(config.pinned && !config.adjustments){
- config.adjustments = "auto";
- }
- }
- this.proxy = this.el.createProxy({tag: "div", cls: "x-resizable-proxy", id: this.el.id + "-rzproxy"}, Ext.getBody());
- this.proxy.unselectable();
- this.proxy.enableDisplayMode('block');
- Ext.apply(this, config);
- if(this.pinned){
- this.disableTrackOver = true;
- this.el.addClass("x-resizable-pinned");
- }
- var position = this.el.getStyle("position");
- if(position != "absolute" && position != "fixed"){
- this.el.setStyle("position", "relative");
- }
- if(!this.handles){ this.handles = 's,e,se';
- if(this.multiDirectional){
- this.handles += ',n,w';
- }
- }
- if(this.handles == "all"){
- this.handles = "n s e w ne nw se sw";
- }
- var hs = this.handles.split(/s*?[,;]s*?| /);
- var ps = Ext.Resizable.positions;
- for(var i = 0, len = hs.length; i < len; i++){
- if(hs[i] && ps[hs[i]]){
- var pos = ps[hs[i]];
- this[pos] = new Ext.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);
- }
- }
- this.corner = this.southeast;
- if(this.handles.indexOf("n") != -1 || this.handles.indexOf("w") != -1){
- this.updateBox = true;
- }
- this.activeHandle = null;
- if(this.resizeChild){
- if(typeof this.resizeChild == "boolean"){
- this.resizeChild = Ext.get(this.el.dom.firstChild, true);
- }else{
- this.resizeChild = Ext.get(this.resizeChild, true);
- }
- }
- if(this.adjustments == "auto"){
- var rc = this.resizeChild;
- var hw = this.west, he = this.east, hn = this.north, hs = this.south;
- if(rc && (hw || hn)){
- rc.position("relative");
- rc.setLeft(hw ? hw.el.getWidth() : 0);
- rc.setTop(hn ? hn.el.getHeight() : 0);
- }
- this.adjustments = [
- (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
- (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
- ];
- }
- if(this.draggable){
- this.dd = this.dynamic ?
- this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
- this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
- }
- this.addEvents(
- "beforeresize",
- "resize"
- );
- if(this.width !== null && this.height !== null){
- this.resizeTo(this.width, this.height);
- }else{
- this.updateChildSize();
- }
- if(Ext.isIE){
- this.el.dom.style.zoom = 1;
- }
- Ext.Resizable.superclass.constructor.call(this);
- };
- Ext.extend(Ext.Resizable, Ext.util.Observable, {
- resizeChild : false,
- adjustments : [0, 0],
- minWidth : 5,
- minHeight : 5,
- maxWidth : 10000,
- maxHeight : 10000,
- enabled : true,
- animate : false,
- duration : .35,
- dynamic : false,
- handles : false,
- multiDirectional : false,
- disableTrackOver : false,
- easing : 'easeOutStrong',
- widthIncrement : 0,
- heightIncrement : 0,
- pinned : false,
- width : null,
- height : null,
- preserveRatio : false,
- transparent: false,
- minX: 0,
- minY: 0,
- draggable: false,
- resizeTo : function(width, height){
- this.el.setSize(width, height);
- this.updateChildSize();
- this.fireEvent("resize", this, width, height, null);
- },
- startSizing : function(e, handle){
- this.fireEvent("beforeresize", this, e);
- if(this.enabled){
- if(!this.overlay){
- this.overlay = this.el.createProxy({tag: "div", cls: "x-resizable-overlay", html: " "}, Ext.getBody());
- this.overlay.unselectable();
- this.overlay.enableDisplayMode("block");
- this.overlay.on("mousemove", this.onMouseMove, this);
- this.overlay.on("mouseup", this.onMouseUp, this);
- }
- this.overlay.setStyle("cursor", handle.el.getStyle("cursor"));
- this.resizing = true;
- this.startBox = this.el.getBox();
- this.startPoint = e.getXY();
- this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
- (this.startBox.y + this.startBox.height) - this.startPoint[1]];
- this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
- this.overlay.show();
- if(this.constrainTo) {
- var ct = Ext.get(this.constrainTo);
- this.resizeRegion = ct.getRegion().adjust(
- ct.getFrameWidth('t'),
- ct.getFrameWidth('l'),
- -ct.getFrameWidth('b'),
- -ct.getFrameWidth('r')
- );
- }
- this.proxy.setStyle('visibility', 'hidden'); this.proxy.show();
- this.proxy.setBox(this.startBox);
- if(!this.dynamic){
- this.proxy.setStyle('visibility', 'visible');
- }
- }
- },
- onMouseDown : function(handle, e){
- if(this.enabled){
- e.stopEvent();
- this.activeHandle = handle;
- this.startSizing(e, handle);
- }
- },
- onMouseUp : function(e){
- var size = this.resizeElement();
- this.resizing = false;
- this.handleOut();
- this.overlay.hide();
- this.proxy.hide();
- this.fireEvent("resize", this, size.width, size.height, e);
- },
- updateChildSize : function(){
- if(this.resizeChild){
- var el = this.el;
- var child = this.resizeChild;
- var adj = this.adjustments;
- if(el.dom.offsetWidth){
- var b = el.getSize(true);
- child.setSize(b.width+adj[0], b.height+adj[1]);
- }
- if(Ext.isIE){
- setTimeout(function(){
- if(el.dom.offsetWidth){
- var b = el.getSize(true);
- child.setSize(b.width+adj[0], b.height+adj[1]);
- }
- }, 10);
- }
- }
- },
- snap : function(value, inc, min){
- if(!inc || !value) return value;
- var newValue = value;
- var m = value % inc;
- if(m > 0){
- if(m > (inc/2)){
- newValue = value + (inc-m);
- }else{
- newValue = value - m;
- }
- }
- return Math.max(min, newValue);
- },
- resizeElement : function(){
- var box = this.proxy.getBox();
- if(this.updateBox){
- this.el.setBox(box, false, this.animate, this.duration, null, this.easing);
- }else{
- this.el.setSize(box.width, box.height, this.animate, this.duration, null, this.easing);
- }
- this.updateChildSize();
- if(!this.dynamic){
- this.proxy.hide();
- }
- return box;
- },
- constrain : function(v, diff, m, mx){
- if(v - diff < m){
- diff = v - m;
- }else if(v - diff > mx){
- diff = mx - v;
- }
- return diff;
- },
- onMouseMove : function(e){
- if(this.enabled){
- try{
- if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {
- return;
- }
- var curSize = this.curSize || this.startBox;
- var x = this.startBox.x, y = this.startBox.y;
- var ox = x, oy = y;
- var w = curSize.width, h = curSize.height;
- var ow = w, oh = h;
- var mw = this.minWidth, mh = this.minHeight;
- var mxw = this.maxWidth, mxh = this.maxHeight;
- var wi = this.widthIncrement;
- var hi = this.heightIncrement;
- var eventXY = e.getXY();
- var diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0]));
- var diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1]));
- var pos = this.activeHandle.position;
- switch(pos){
- case "east":
- w += diffX;
- w = Math.min(Math.max(mw, w), mxw);
- break;
- case "south":
- h += diffY;
- h = Math.min(Math.max(mh, h), mxh);
- break;
- case "southeast":
- w += diffX;
- h += diffY;
- w = Math.min(Math.max(mw, w), mxw);
- h = Math.min(Math.max(mh, h), mxh);
- break;
- case "north":
- diffY = this.constrain(h, diffY, mh, mxh);
- y += diffY;
- h -= diffY;
- break;
- case "west":
- diffX = this.constrain(w, diffX, mw, mxw);
- x += diffX;
- w -= diffX;
- break;
- case "northeast":
- w += diffX;
- w = Math.min(Math.max(mw, w), mxw);
- diffY = this.constrain(h, diffY, mh, mxh);
- y += diffY;
- h -= diffY;
- break;
- case "northwest":
- diffX = this.constrain(w, diffX, mw, mxw);
- diffY = this.constrain(h, diffY, mh, mxh);
- y += diffY;
- h -= diffY;
- x += diffX;
- w -= diffX;
- break;
- case "southwest":
- diffX = this.constrain(w, diffX, mw, mxw);
- h += diffY;
- h = Math.min(Math.max(mh, h), mxh);
- x += diffX;
- w -= diffX;
- break;
- }
- var sw = this.snap(w, wi, mw);
- var sh = this.snap(h, hi, mh);
- if(sw != w || sh != h){
- switch(pos){
- case "northeast":
- y -= sh - h;
- break;
- case "north":
- y -= sh - h;
- break;
- case "southwest":
- x -= sw - w;
- break;
- case "west":
- x -= sw - w;
- break;
- case "northwest":
- x -= sw - w;
- y -= sh - h;
- break;
- }
- w = sw;
- h = sh;
- }
- if(this.preserveRatio){
- switch(pos){
- case "southeast":
- case "east":
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- w = ow * (h/oh);
- break;
- case "south":
- w = ow * (h/oh);
- w = Math.min(Math.max(mw, w), mxw);
- h = oh * (w/ow);
- break;
- case "northeast":
- w = ow * (h/oh);
- w = Math.min(Math.max(mw, w), mxw);
- h = oh * (w/ow);
- break;
- case "north":
- var tw = w;
- w = ow * (h/oh);
- w = Math.min(Math.max(mw, w), mxw);
- h = oh * (w/ow);
- x += (tw - w) / 2;
- break;
- case "southwest":
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- var tw = w;
- w = ow * (h/oh);
- x += tw - w;
- break;
- case "west":
- var th = h;
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- y += (th - h) / 2;
- var tw = w;
- w = ow * (h/oh);
- x += tw - w;
- break;
- case "northwest":
- var tw = w;
- var th = h;
- h = oh * (w/ow);
- h = Math.min(Math.max(mh, h), mxh);
- w = ow * (h/oh);
- y += th - h;
- x += tw - w;
- break;
- }
- }
- this.proxy.setBounds(x, y, w, h);
- if(this.dynamic){
- this.resizeElement();
- }
- }catch(e){}
- }
- },
- handleOver : function(){
- if(this.enabled){
- this.el.addClass("x-resizable-over");
- }
- },
- handleOut : function(){
- if(!this.resizing){
- this.el.removeClass("x-resizable-over");
- }
- },
- getEl : function(){
- return this.el;
- },
- getResizeChild : function(){
- return this.resizeChild;
- },
- destroy : function(removeEl){
- this.proxy.remove();
- if(this.overlay){
- this.overlay.removeAllListeners();
- this.overlay.remove();
- }
- var ps = Ext.Resizable.positions;
- for(var k in ps){
- if(typeof ps[k] != "function" && this[ps[k]]){
- var h = this[ps[k]];
- h.el.removeAllListeners();
- h.el.remove();
- }
- }
- if(removeEl){
- this.el.update("");
- this.el.remove();
- }
- },
- syncHandleHeight : function(){
- var h = this.el.getHeight(true);
- if(this.west){
- this.west.el.setHeight(h);
- }
- if(this.east){
- this.east.el.setHeight(h);
- }
- }
- });
- Ext.Resizable.positions = {
- n: "north", s: "south", e: "east", w: "west", se: "southeast", sw: "southwest", nw: "northwest", ne: "northeast"
- };
- Ext.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){
- if(!this.tpl){
- var tpl = Ext.DomHelper.createTemplate(
- {tag: "div", cls: "x-resizable-handle x-resizable-handle-{0}"}
- );
- tpl.compile();
- Ext.Resizable.Handle.prototype.tpl = tpl;
- }
- this.position = pos;
- this.rz = rz;
- this.el = this.tpl.append(rz.el.dom, [this.position], true);
- this.el.unselectable();
- if(transparent){
- this.el.setOpacity(0);
- }
- this.el.on("mousedown", this.onMouseDown, this);
- if(!disableTrackOver){
- this.el.on("mouseover", this.onMouseOver, this);
- this.el.on("mouseout", this.onMouseOut, this);
- }
- };
- Ext.Resizable.Handle.prototype = {
- afterResize : function(rz){
- },
- onMouseDown : function(e){
- this.rz.onMouseDown(this, e);
- },
- onMouseOver : function(e){
- this.rz.handleOver(this, e);
- },
- onMouseOut : function(e){
- this.rz.handleOut(this, e);
- }
- };
- Ext.Editor = function(field, config){ this.field = field; Ext.Editor.superclass.constructor.call(this, config); }; Ext.extend(Ext.Editor, Ext.Component, { value : "", alignment: "c-c?", shadow : "frame", constrain : false, swallowKeys : true, completeOnEnter : false, cancelOnEsc : false, updateEl : false, initComponent : function(){ Ext.Editor.superclass.initComponent.call(this); this.addEvents( "beforestartedit", "startedit", "beforecomplete", "complete", "canceledit", "specialkey" ); }, onRender : function(ct, position){ this.el = new Ext.Layer({ shadow: this.shadow, cls: "x-editor", parentEl : ct, shim : this.shim, shadowOffset:4, id: this.id, constrain: this.constrain }); this.el.setStyle("overflow", Ext.isGecko ? "auto" : "hidden"); if(this.field.msgTarget != 'title'){ this.field.msgTarget = 'qtip'; } this.field.inEditor = true; this.field.render(this.el); if(Ext.isGecko){ this.field.el.dom.setAttribute('autocomplete', 'off'); } this.field.on("specialkey", this.onSpecialKey, this); if(this.swallowKeys){ this.field.el.swallowEvent(['keydown','keypress']); } this.field.show(); this.field.on("blur", this.onBlur, this); if(this.field.grow){ this.field.on("autosize", this.el.sync, this.el, {delay:1}); } }, onSpecialKey : function(field, e){ var key = e.getKey(); if(this.completeOnEnter && key == e.ENTER){ e.stopEvent(); this.completeEdit(); }else if(this.cancelOnEsc && key == e.ESC){ this.cancelEdit(); }else{ this.fireEvent('specialkey', field, e); } if(this.field.triggerBlur && (key == e.ENTER || key == e.ESC || key == e.TAB)){ this.field.triggerBlur(); } }, startEdit : function(el, value){ if(this.editing){ this.completeEdit(); } this.boundEl = Ext.get(el); var v = value !== undefined ? value : this.boundEl.dom.innerHTML; if(!this.rendered){ this.render(this.parentEl || document.body); } if(this.fireEvent("beforestartedit", this, this.boundEl, v) === false){ return; } this.startValue = v; this.field.setValue(v); this.doAutoSize(); this.el.alignTo(this.boundEl, this.alignment); this.editing = true; this.show(); }, doAutoSize : function(){ if(this.autoSize){ var sz = this.boundEl.getSize(); switch(this.autoSize){ case "width": this.setSize(sz.width, ""); break; case "height": this.setSize("", sz.height); break; default: this.setSize(sz.width, sz.height); } } }, setSize : function(w, h){ delete this.field.lastSize; this.field.setSize(w, h); if(this.el){ if(Ext.isGecko2 || Ext.isOpera){ this.el.setSize(w, h); } this.el.sync(); } }, realign : function(){ this.el.alignTo(this.boundEl, this.alignment); }, completeEdit : function(remainVisible){ if(!this.editing){ return; } var v = this.getValue(); if(this.revertInvalid !== false && !this.field.isValid()){ v = this.startValue; this.cancelEdit(true); } if(String(v) === String(this.startValue) && this.ignoreNoChange){ this.editing = false; this.hide(); return; } if(this.fireEvent("beforecomplete", this, v, this.startValue) !== false){ this.editing = false; if(this.updateEl && this.boundEl){ this.boundEl.update(v); } if(remainVisible !== true){ this.hide(); } this.fireEvent("complete", this, v, this.startValue); } }, onShow : function(){ this.el.show(); if(this.hideEl !== false){ this.boundEl.hide(); } this.field.show(); if(Ext.isIE && !this.fixIEFocus){ this.fixIEFocus = true; this.deferredFocus.defer(50, this); }else{ this.field.focus(); } this.fireEvent("startedit", this.boundEl, this.startValue); }, deferredFocus : function(){ if(this.editing){ this.field.focus(); } }, cancelEdit : function(remainVisible){ if(this.editing){ var v = this.getValue(); this.setValue(this.startValue); if(remainVisible !== true){ this.hide(); } this.fireEvent("canceledit", this, v, this.startValue); } }, onBlur : function(){ if(this.allowBlur !== true && this.editing){ this.completeEdit(); } }, onHide : function(){ if(this.editing){ this.completeEdit(); return; } this.field.blur(); if(this.field.collapse){ this.field.collapse(); } this.el.hide(); if(this.hideEl !== false){ this.boundEl.show(); } }, setValue : function(v){ this.field.setValue(v); }, getValue : function(){ return this.field.getValue(); }, beforeDestroy : function(){ this.field.destroy(); this.field = null; } }); Ext.reg('editor', Ext.Editor); Ext.MessageBox = function(){ var dlg, opt, mask, waitTimer; var bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl; var buttons, activeTextEl, bwidth, iconCls = ''; var handleButton = function(button){ if(dlg.isVisible()){ dlg.hide(); Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1); } }; var handleHide = function(){ if(opt && opt.cls){ dlg.el.removeClass(opt.cls); } progressBar.reset(); }; var handleEsc = function(d, k, e){ if(opt && opt.closable !== false){ dlg.hide(); } if(e){ e.stopEvent(); } }; var updateButtons = function(b){ var width = 0; if(!b){ buttons["ok"].hide(); buttons["cancel"].hide(); buttons["yes"].hide(); buttons["no"].hide(); return width; } dlg.footer.dom.style.display = ''; for(var k in buttons){ if(typeof buttons[k] != "function"){ if(b[k]){ buttons[k].show(); buttons[k].setText(typeof b[k] == "string" ? b[k] : Ext.MessageBox.buttonText[k]); width += buttons[k].el.getWidth()+15; }else{ buttons[k].hide(); } } } return width; }; return { getDialog : function(titleText){ if(!dlg){ dlg = new Ext.Window({ autoCreate : true, title:titleText, resizable:false, constrain:true, constrainHeader:true, minimizable : false, maximizable : false, stateful: false, modal: true, shim:true, buttonAlign:"center", width:400, height:100, minHeight: 80, plain:true, footer:true, closable:true, close : function(){ if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){ handleButton("no"); }else{ handleButton("cancel"); } } }); buttons = {}; var bt = this.buttonText; buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok")); buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes")); buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no")); buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel")); buttons["ok"].hideMode = buttons["yes"].hideMode = buttons["no"].hideMode = buttons["cancel"].hideMode = 'offsets'; dlg.render(document.body); dlg.getEl().addClass('x-window-dlg'); mask = dlg.mask; bodyEl = dlg.body.createChild({ html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><div class="ext-mb-fix-cursor"><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div></div>' }); iconEl = Ext.get(bodyEl.dom.firstChild); var contentEl = bodyEl.dom.childNodes[1]; msgEl = Ext.get(contentEl.firstChild); textboxEl = Ext.get(contentEl.childNodes[2].firstChild); textboxEl.enableDisplayMode(); textboxEl.addKeyListener([10,13], function(){ if(dlg.isVisible() && opt && opt.buttons){ if(opt.buttons.ok){ handleButton("ok"); }else if(opt.buttons.yes){ handleButton("yes"); } } }); textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]); textareaEl.enableDisplayMode(); progressBar = new Ext.ProgressBar({ renderTo:bodyEl }); bodyEl.createChild({cls:'x-clear'}); } return dlg; }, updateText : function(text){ if(!dlg.isVisible() && !opt.width){ dlg.setSize(this.maxWidth, 100); } msgEl.update(text || ' '); var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0; var mw = msgEl.getWidth() + msgEl.getMargins('lr'); var fw = dlg.getFrameWidth('lr'); var bw = dlg.body.getFrameWidth('lr'); if (Ext.isIE && iw > 0){ iw += 3; } var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth), Math.max(opt.minWidth || this.minWidth, bwidth || 0)); if(opt.prompt === true){ activeTextEl.setWidth(w-iw-fw-bw); } if(opt.progress === true || opt.wait === true){ progressBar.setSize(w-iw-fw-bw); } dlg.setSize(w, 'auto').center(); return this; }, updateProgress : function(value, progressText, msg){ progressBar.updateProgress(value, progressText); if(msg){ this.updateText(msg); } return this; }, isVisible : function(){ return dlg && dlg.isVisible(); }, hide : function(){ if(this.isVisible()){ dlg.hide(); handleHide(); } return this; }, show : function(options){ if(this.isVisible()){ this.hide(); } opt = options; var d = this.getDialog(opt.title || " "); d.setTitle(opt.title || " "); var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true); d.tools.close.setDisplayed(allowClose); activeTextEl = textboxEl; opt.prompt = opt.prompt || (opt.multiline ? true : false); if(opt.prompt){ if(opt.multiline){ textboxEl.hide(); textareaEl.show(); textareaEl.setHeight(typeof opt.multiline == "number" ? opt.multiline : this.defaultTextHeight); activeTextEl = textareaEl; }else{ textboxEl.show(); textareaEl.hide(); } }else{ textboxEl.hide(); textareaEl.hide(); } activeTextEl.dom.value = opt.value || ""; if(opt.prompt){ d.focusEl = activeTextEl; }else{ var bs = opt.buttons; var db = null; if(bs && bs.ok){ db = buttons["ok"]; }else if(bs && bs.yes){ db = buttons["yes"]; } if (db){ d.focusEl = db; } } if(opt.iconCls){ d.setIconClass(opt.iconCls); } this.setIcon(opt.icon); bwidth = updateButtons(opt.buttons); progressBar.setVisible(opt.progress === true || opt.wait === true); this.updateProgress(0, opt.progressText); this.updateText(opt.msg); if(opt.cls){ d.el.addClass(opt.cls); } d.proxyDrag = opt.proxyDrag === true; d.modal = opt.modal !== false; d.mask = opt.modal !== false ? mask : false; if(!d.isVisible()){ document.body.appendChild(dlg.el.dom); d.setAnimateTarget(opt.animEl); d.show(opt.animEl); } d.on('show', function(){ if(allowClose === true){ d.keyMap.enable(); }else{ d.keyMap.disable(); } }, this, {single:true}); if(opt.wait === true){ progressBar.wait(opt.waitConfig); } return this; }, setIcon : function(icon){ if(icon && icon != ''){ iconEl.removeClass('x-hidden'); iconEl.replaceClass(iconCls, icon); iconCls = icon; }else{ iconEl.replaceClass(iconCls, 'x-hidden'); iconCls = ''; } return this; }, progress : function(title, msg, progressText){ this.show({ title : title, msg : msg, buttons: false, progress:true, closable:false, minWidth: this.minProgressWidth, progressText: progressText }); return this; }, wait : function(msg, title, config){ this.show({ title : title, msg : msg, buttons: false, closable:false, wait:true, modal:true, minWidth: this.minProgressWidth, waitConfig: config }); return this; }, alert : function(title, msg, fn, scope){ this.show({ title : title, msg : msg, buttons: this.OK, fn: fn, scope : scope }); return this; }, confirm : function(title, msg, fn, scope){ this.show({ title : title, msg : msg, buttons: this.YESNO, fn: fn, scope : scope, icon: this.QUESTION }); return this; }, prompt : function(title, msg, fn, scope, multiline, value){ this.show({ title : title, msg : msg, buttons: this.OKCANCEL, fn: fn, minWidth:250, scope : scope, prompt:true, multiline: multiline, value: value }); return this; }, OK : {ok:true}, CANCEL : {cancel:true}, OKCANCEL : {ok:true, cancel:true}, YESNO : {yes:true, no:true}, YESNOCANCEL : {yes:true, no:true, cancel:true}, INFO : 'ext-mb-info', WARNING : 'ext-mb-warning', QUESTION : 'ext-mb-question', ERROR : 'ext-mb-error', defaultTextHeight : 75, maxWidth : 600, minWidth : 100, minProgressWidth : 250, buttonText : { ok : "OK", cancel : "Cancel", yes : "Yes", no : "No" } }; }(); Ext.Msg = Ext.MessageBox;
- Ext.Tip = Ext.extend(Ext.Panel, {
- minWidth : 40,
- maxWidth : 300,
- shadow : "sides",
- defaultAlign : "tl-bl?",
- autoRender: true,
- quickShowInterval : 250,
- frame:true,
- hidden:true,
- baseCls: 'x-tip',
- floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
- autoHeight:true,
- initComponent : function(){
- Ext.Tip.superclass.initComponent.call(this);
- if(this.closable && !this.title){
- this.elements += ',header';
- }
- },
- afterRender : function(){
- Ext.Tip.superclass.afterRender.call(this);
- if(this.closable){
- this.addTool({
- id: 'close',
- handler: this.hide,
- scope: this
- });
- }
- },
- showAt : function(xy){
- Ext.Tip.superclass.show.call(this);
- if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
- this.doAutoWidth();
- }
- if(this.constrainPosition){
- xy = this.el.adjustForConstraints(xy);
- }
- this.setPagePosition(xy[0], xy[1]);
- },
- doAutoWidth : function(){
- var bw = this.body.getTextWidth();
- if(this.title){
- bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
- }
- bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");
- this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
- if(Ext.isIE7 && !this.repainted){
- this.el.repaint();
- this.repainted = true;
- }
- },
- showBy : function(el, pos){
- if(!this.rendered){
- this.render(Ext.getBody());
- }
- this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
- },
- initDraggable : function(){
- this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
- this.header.addClass('x-tip-draggable');
- }
- });
- Ext.Tip.DD = function(tip, config){
- Ext.apply(this, config);
- this.tip = tip;
- Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
- this.setHandleElId(tip.header.id);
- this.scroll = false;
- };
- Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
- moveOnly:true,
- scroll:false,
- headerOffsets:[100, 25],
- startDrag : function(){
- this.tip.el.disableShadow();
- },
- endDrag : function(e){
- this.tip.el.enableShadow(true);
- }
- });
- Ext.ToolTip = Ext.extend(Ext.Tip, {
- showDelay: 500,
- hideDelay: 200,
- dismissDelay: 5000,
- mouseOffset: [15,18],
- trackMouse : false,
- constrainPosition: true,
- initComponent: function(){
- Ext.ToolTip.superclass.initComponent.call(this);
- this.lastActive = new Date();
- this.initTarget();
- },
- initTarget : function(){
- if(this.target){
- this.target = Ext.get(this.target);
- this.target.on('mouseover', this.onTargetOver, this);
- this.target.on('mouseout', this.onTargetOut, this);
- this.target.on('mousemove', this.onMouseMove, this);
- }
- },
- onMouseMove : function(e){
- this.targetXY = e.getXY();
- if(!this.hidden && this.trackMouse){
- this.setPagePosition(this.getTargetXY());
- }
- },
- getTargetXY : function(){
- return [this.targetXY[0]+this.mouseOffset[0], this.targetXY[1]+this.mouseOffset[1]];
- },
- onTargetOver : function(e){
- if(this.disabled || e.within(this.target.dom, true)){
- return;
- }
- this.clearTimer('hide');
- this.targetXY = e.getXY();
- this.delayShow();
- },
- delayShow : function(){
- if(this.hidden && !this.showTimer){
- if(this.lastActive.getElapsed() < this.quickShowInterval){
- this.show();
- }else{
- this.showTimer = this.show.defer(this.showDelay, this);
- }
- }else if(!this.hidden && this.autoHide !== false){
- this.show();
- }
- },
- onTargetOut : function(e){
- if(this.disabled || e.within(this.target.dom, true)){
- return;
- }
- this.clearTimer('show');
- if(this.autoHide !== false){
- this.delayHide();
- }
- },
- delayHide : function(){
- if(!this.hidden && !this.hideTimer){
- this.hideTimer = this.hide.defer(this.hideDelay, this);
- }
- },
- hide: function(){
- this.clearTimer('dismiss');
- this.lastActive = new Date();
- Ext.ToolTip.superclass.hide.call(this);
- },
- show : function(){
- this.showAt(this.getTargetXY());
- },
- showAt : function(xy){
- this.lastActive = new Date();
- this.clearTimers();
- Ext.ToolTip.superclass.showAt.call(this, xy);
- if(this.dismissDelay && this.autoHide !== false){
- this.dismissTimer = this.hide.defer(this.dismissDelay, this);
- }
- },
- clearTimer : function(name){
- name = name + 'Timer';
- clearTimeout(this[name]);
- delete this[name];
- },
- clearTimers : function(){
- this.clearTimer('show');
- this.clearTimer('dismiss');
- this.clearTimer('hide');
- },
- onShow : function(){
- Ext.ToolTip.superclass.onShow.call(this);
- Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
- },
- onHide : function(){
- Ext.ToolTip.superclass.onHide.call(this);
- Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
- },
- onDocMouseDown : function(e){
- if(this.autoHide !== false && !e.within(this.el.dom)){
- this.disable();
- this.enable.defer(100, this);
- }
- },
- onDisable : function(){
- this.clearTimers();
- this.hide();
- },
- adjustPosition : function(x, y){
- var ay = this.targetXY[1], h = this.getSize().height;
- if(this.constrainPosition && y <= ay && (y+h) >= ay){
- y = ay-h-5;
- }
- return {x : x, y: y};
- },
- onDestroy : function(){
- Ext.ToolTip.superclass.onDestroy.call(this);
- if(this.target){
- this.target.un('mouseover', this.onTargetOver, this);
- this.target.un('mouseout', this.onTargetOut, this);
- this.target.un('mousemove', this.onMouseMove, this);
- }
- }
- });
- Ext.QuickTip = Ext.extend(Ext.ToolTip, {
- interceptTitles : false,
- tagConfig : {
- namespace : "ext",
- attribute : "qtip",
- width : "qwidth",
- target : "target",
- title : "qtitle",
- hide : "hide",
- cls : "qclass",
- align : "qalign"
- },
- initComponent : function(){
- this.target = this.target || Ext.getDoc();
- this.targets = this.targets || {};
- Ext.QuickTip.superclass.initComponent.call(this);
- },
- register : function(config){
- var cs = Ext.isArray(config) ? config : arguments;
- for(var i = 0, len = cs.length; i < len; i++){
- var c = cs[i];
- var target = c.target;
- if(target){
- if(Ext.isArray(target)){
- for(var j = 0, jlen = target.length; j < jlen; j++){
- this.targets[Ext.id(target[j])] = c;
- }
- } else{
- this.targets[Ext.id(target)] = c;
- }
- }
- }
- },
- unregister : function(el){
- delete this.targets[Ext.id(el)];
- },
- onTargetOver : function(e){
- if(this.disabled){
- return;
- }
- this.targetXY = e.getXY();
- var t = e.getTarget();
- if(!t || t.nodeType !== 1 || t == document || t == document.body){
- return;
- }
- if(this.activeTarget && t == this.activeTarget.el){
- this.clearTimer('hide');
- this.show();
- return;
- }
- if(t && this.targets[t.id]){
- this.activeTarget = this.targets[t.id];
- this.activeTarget.el = t;
- this.delayShow();
- return;
- }
- var ttp, et = Ext.fly(t), cfg = this.tagConfig;
- var ns = cfg.namespace;
- if(this.interceptTitles && t.title){
- ttp = t.title;
- t.qtip = ttp;
- t.removeAttribute("title");
- e.preventDefault();
- } else{
- ttp = t.qtip || et.getAttributeNS(ns, cfg.attribute);
- }
- if(ttp){
- var autoHide = et.getAttributeNS(ns, cfg.hide);
- this.activeTarget = {
- el: t,
- text: ttp,
- width: et.getAttributeNS(ns, cfg.width),
- autoHide: autoHide != "user" && autoHide !== 'false',
- title: et.getAttributeNS(ns, cfg.title),
- cls: et.getAttributeNS(ns, cfg.cls),
- align: et.getAttributeNS(ns, cfg.align)
- };
- this.delayShow();
- }
- },
- onTargetOut : function(e){
- this.clearTimer('show');
- if(this.autoHide !== false){
- this.delayHide();
- }
- },
- showAt : function(xy){
- var t = this.activeTarget;
- if(t){
- if(!this.rendered){
- this.render(Ext.getBody());
- this.activeTarget = t;
- }
- if(t.width){
- this.setWidth(t.width);
- this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
- this.measureWidth = false;
- } else{
- this.measureWidth = true;
- }
- this.setTitle(t.title || '');
- this.body.update(t.text);
- this.autoHide = t.autoHide;
- this.dismissDelay = t.dismissDelay || this.dismissDelay;
- if(this.lastCls){
- this.el.removeClass(this.lastCls);
- delete this.lastCls;
- }
- if(t.cls){
- this.el.addClass(t.cls);
- this.lastCls = t.cls;
- }
- if(t.align){ xy = this.el.getAlignToXY(t.el, t.align);
- this.constrainPosition = false;
- } else{
- this.constrainPosition = true;
- }
- }
- Ext.QuickTip.superclass.showAt.call(this, xy);
- },
- hide: function(){
- delete this.activeTarget;
- Ext.QuickTip.superclass.hide.call(this);
- }
- });
- Ext.QuickTips = function(){
- var tip, locks = [];
- return {
- init : function(autoRender){
- if(!tip){
- if(!Ext.isReady){
- Ext.onReady(function(){
- Ext.QuickTips.init(autoRender);
- });
- return;
- }
- tip = new Ext.QuickTip({elements:'header,body'});
- if(autoRender !== false){
- tip.render(Ext.getBody());
- }
- }
- },
- enable : function(){
- if(tip){
- locks.pop();
- if(locks.length < 1){
- tip.enable();
- }
- }
- },