ext-all-debug.js
资源名称:EXT_study.rar [点击查看]
上传用户:zaktkj
上传日期:2022-08-08
资源大小:5770k
文件大小:910k
源码类别:
JavaScript
开发平台:
JavaScript
- var w = this.win;
- this.proxy = w.ghost();
- if(w.constrain !== false){
- var so = w.el.shadowOffset;
- this.constrainTo(w.container, {right: so, left: so, bottom: so});
- }else if(w.constrainHeader !== false){
- var s = this.proxy.getSize();
- this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
- }
- },
- b4Drag : Ext.emptyFn,
- onDrag : function(e){
- this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
- },
- endDrag : function(e){
- this.win.unghost();
- this.win.saveState();
- }
- });
- Ext.WindowGroup = function(){
- var list = {};
- var accessList = [];
- var front = null;
- var sortWindows = function(d1, d2){
- return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
- };
- var orderWindows = function(){
- var a = accessList, len = a.length;
- if(len > 0){
- a.sort(sortWindows);
- var seed = a[0].manager.zseed;
- for(var i = 0; i < len; i++){
- var win = a[i];
- if(win && !win.hidden){
- win.setZIndex(seed + (i*10));
- }
- }
- }
- activateLast();
- };
- var setActiveWin = function(win){
- if(win != front){
- if(front){
- front.setActive(false);
- }
- front = win;
- if(win){
- win.setActive(true);
- }
- }
- };
- var activateLast = function(){
- for(var i = accessList.length-1; i >=0; --i) {
- if(!accessList[i].hidden){
- setActiveWin(accessList[i]);
- return;
- }
- }
- setActiveWin(null);
- };
- return {
- zseed : 9000,
- register : function(win){
- list[win.id] = win;
- accessList.push(win);
- win.on('hide', activateLast);
- },
- unregister : function(win){
- delete list[win.id];
- win.un('hide', activateLast);
- accessList.remove(win);
- },
- get : function(id){
- return typeof id == "object" ? id : list[id];
- },
- bringToFront : function(win){
- win = this.get(win);
- if(win != front){
- win._lastAccess = new Date().getTime();
- orderWindows();
- return true;
- }
- return false;
- },
- sendToBack : function(win){
- win = this.get(win);
- win._lastAccess = -(new Date().getTime());
- orderWindows();
- return win;
- },
- hideAll : function(){
- for(var id in list){
- if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
- list[id].hide();
- }
- }
- },
- getActive : function(){
- return front;
- },
- getBy : function(fn, scope){
- var r = [];
- for(var i = accessList.length-1; i >=0; --i) {
- var win = accessList[i];
- if(fn.call(scope||win, win) !== false){
- r.push(win);
- }
- }
- return r;
- },
- each : function(fn, scope){
- for(var id in list){
- if(list[id] && typeof list[id] != "function"){
- if(fn.call(scope || list[id], list[id]) === false){
- return;
- }
- }
- }
- }
- };
- };
- Ext.WindowMgr = new Ext.WindowGroup();
- Ext.dd.PanelProxy = function(panel, config){
- this.panel = panel;
- this.id = this.panel.id +'-ddproxy';
- Ext.apply(this, config);
- };
- Ext.dd.PanelProxy.prototype = {
- insertProxy : true,
- setStatus : Ext.emptyFn,
- reset : Ext.emptyFn,
- update : Ext.emptyFn,
- stop : Ext.emptyFn,
- sync: Ext.emptyFn,
- getEl : function(){
- return this.ghost;
- },
- getGhost : function(){
- return this.ghost;
- },
- getProxy : function(){
- return this.proxy;
- },
- hide : function(){
- if(this.ghost){
- if(this.proxy){
- this.proxy.remove();
- delete this.proxy;
- }
- this.panel.el.dom.style.display = '';
- this.ghost.remove();
- delete this.ghost;
- }
- },
- show : function(){
- if(!this.ghost){
- this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
- this.ghost.setXY(this.panel.el.getXY())
- if(this.insertProxy){
- this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
- this.proxy.setSize(this.panel.getSize());
- }
- this.panel.el.dom.style.display = 'none';
- }
- },
- repair : function(xy, callback, scope){
- this.hide();
- if(typeof callback == "function"){
- callback.call(scope || this);
- }
- },
- moveProxy : function(parentNode, before){
- if(this.proxy){
- parentNode.insertBefore(this.proxy.dom, before);
- }
- }
- };
- Ext.Panel.DD = function(panel, cfg){
- this.panel = panel;
- this.dragData = {panel: panel};
- this.proxy = new Ext.dd.PanelProxy(panel, cfg);
- Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
- this.setHandleElId(panel.header.id);
- panel.header.setStyle('cursor', 'move');
- this.scroll = false;
- };
- Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
- showFrame: Ext.emptyFn,
- startDrag: Ext.emptyFn,
- b4StartDrag: function(x, y) {
- this.proxy.show();
- },
- b4MouseDown: function(e) {
- var x = e.getPageX();
- var y = e.getPageY();
- this.autoOffset(x, y);
- },
- onInitDrag : function(x, y){
- this.onStartDrag(x, y);
- return true;
- },
- createFrame : Ext.emptyFn,
- getDragEl : function(e){
- return this.proxy.ghost.dom;
- },
- endDrag : function(e){
- this.proxy.hide();
- this.panel.saveState();
- },
- autoOffset : function(x, y) {
- x -= this.startPageX;
- y -= this.startPageY;
- this.setDelta(x, y);
- }
- });
- Ext.state.Provider = function(){
- this.addEvents("statechange");
- this.state = {};
- Ext.state.Provider.superclass.constructor.call(this);
- };
- Ext.extend(Ext.state.Provider, Ext.util.Observable, {
- get : function(name, defaultValue){
- return typeof this.state[name] == "undefined" ?
- defaultValue : this.state[name];
- },
- clear : function(name){
- delete this.state[name];
- this.fireEvent("statechange", this, name, null);
- },
- set : function(name, value){
- this.state[name] = value;
- this.fireEvent("statechange", this, name, value);
- },
- decodeValue : function(cookie){
- var re = /^(a|n|d|b|s|o):(.*)$/;
- var matches = re.exec(unescape(cookie));
- if(!matches || !matches[1]) return;
- var type = matches[1];
- var v = matches[2];
- switch(type){
- case "n":
- return parseFloat(v);
- case "d":
- return new Date(Date.parse(v));
- case "b":
- return (v == "1");
- case "a":
- var all = [];
- var values = v.split("^");
- for(var i = 0, len = values.length; i < len; i++){
- all.push(this.decodeValue(values[i]));
- }
- return all;
- case "o":
- var all = {};
- var values = v.split("^");
- for(var i = 0, len = values.length; i < len; i++){
- var kv = values[i].split("=");
- all[kv[0]] = this.decodeValue(kv[1]);
- }
- return all;
- default:
- return v;
- }
- },
- encodeValue : function(v){
- var enc;
- if(typeof v == "number"){
- enc = "n:" + v;
- }else if(typeof v == "boolean"){
- enc = "b:" + (v ? "1" : "0");
- }else if(Ext.isDate(v)){
- enc = "d:" + v.toGMTString();
- }else if(Ext.isArray(v)){
- var flat = "";
- for(var i = 0, len = v.length; i < len; i++){
- flat += this.encodeValue(v[i]);
- if(i != len-1) flat += "^";
- }
- enc = "a:" + flat;
- }else if(typeof v == "object"){
- var flat = "";
- for(var key in v){
- if(typeof v[key] != "function" && v[key] !== undefined){
- flat += key + "=" + this.encodeValue(v[key]) + "^";
- }
- }
- enc = "o:" + flat.substring(0, flat.length-1);
- }else{
- enc = "s:" + v;
- }
- return escape(enc);
- }
- });
- Ext.state.Manager = function(){
- var provider = new Ext.state.Provider();
- return {
- setProvider : function(stateProvider){
- provider = stateProvider;
- },
- get : function(key, defaultValue){
- return provider.get(key, defaultValue);
- },
- set : function(key, value){
- provider.set(key, value);
- },
- clear : function(key){
- provider.clear(key);
- },
- getProvider : function(){
- return provider;
- }
- };
- }();
- Ext.state.CookieProvider = function(config){
- Ext.state.CookieProvider.superclass.constructor.call(this);
- this.path = "/";
- this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
- this.domain = null;
- this.secure = false;
- Ext.apply(this, config);
- this.state = this.readCookies();
- };
- Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
- set : function(name, value){
- if(typeof value == "undefined" || value === null){
- this.clear(name);
- return;
- }
- this.setCookie(name, value);
- Ext.state.CookieProvider.superclass.set.call(this, name, value);
- },
- clear : function(name){
- this.clearCookie(name);
- Ext.state.CookieProvider.superclass.clear.call(this, name);
- },
- readCookies : function(){
- var cookies = {};
- var c = document.cookie + ";";
- var re = /s?(.*?)=(.*?);/g;
- var matches;
- while((matches = re.exec(c)) != null){
- var name = matches[1];
- var value = matches[2];
- if(name && name.substring(0,3) == "ys-"){
- cookies[name.substr(3)] = this.decodeValue(value);
- }
- }
- return cookies;
- },
- setCookie : function(name, value){
- document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
- ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
- ((this.path == null) ? "" : ("; path=" + this.path)) +
- ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
- ((this.secure == true) ? "; secure" : "");
- },
- clearCookie : function(name){
- document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
- ((this.path == null) ? "" : ("; path=" + this.path)) +
- ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
- ((this.secure == true) ? "; secure" : "");
- }
- });
- Ext.DataView = Ext.extend(Ext.BoxComponent, {
- selectedClass : "x-view-selected",
- emptyText : "",
- last: false,
- initComponent : function(){
- Ext.DataView.superclass.initComponent.call(this);
- if(typeof this.tpl == "string"){
- this.tpl = new Ext.XTemplate(this.tpl);
- }
- this.addEvents(
- "beforeclick",
- "click",
- "containerclick",
- "dblclick",
- "contextmenu",
- "selectionchange",
- "beforeselect"
- );
- this.all = new Ext.CompositeElementLite();
- this.selected = new Ext.CompositeElementLite();
- },
- onRender : function(){
- if(!this.el){
- this.el = document.createElement('div');
- }
- Ext.DataView.superclass.onRender.apply(this, arguments);
- },
- afterRender : function(){
- Ext.DataView.superclass.afterRender.call(this);
- this.el.on({
- "click": this.onClick,
- "dblclick": this.onDblClick,
- "contextmenu": this.onContextMenu,
- scope:this
- });
- if(this.overClass){
- this.el.on({
- "mouseover": this.onMouseOver,
- "mouseout": this.onMouseOut,
- scope:this
- });
- }
- if(this.store){
- this.setStore(this.store, true);
- }
- },
- refresh : function(){
- this.clearSelections(false, true);
- this.el.update("");
- var html = [];
- var records = this.store.getRange();
- if(records.length < 1){
- this.el.update(this.emptyText);
- this.all.clear();
- return;
- }
- this.tpl.overwrite(this.el, this.collectData(records, 0));
- this.all.fill(Ext.query(this.itemSelector, this.el.dom));
- this.updateIndexes(0);
- },
- prepareData : function(data){
- return data;
- },
- collectData : function(records, startIndex){
- var r = [];
- for(var i = 0, len = records.length; i < len; i++){
- r[r.length] = this.prepareData(records[i].data, startIndex+i, records[i]);
- }
- return r;
- },
- bufferRender : function(records){
- var div = document.createElement('div');
- this.tpl.overwrite(div, this.collectData(records));
- return Ext.query(this.itemSelector, div);
- },
- onUpdate : function(ds, record){
- var index = this.store.indexOf(record);
- var sel = this.isSelected(index);
- var original = this.all.elements[index];
- var node = this.bufferRender([record], index)[0];
- this.all.replaceElement(index, node, true);
- if(sel){
- this.selected.replaceElement(original, node);
- this.all.item(index).addClass(this.selectedClass);
- }
- this.updateIndexes(index, index);
- },
- onAdd : function(ds, records, index){
- if(this.all.getCount() == 0){
- this.refresh();
- return;
- }
- var nodes = this.bufferRender(records, index), n;
- if(index < this.all.getCount()){
- n = this.all.item(index).insertSibling(nodes, 'before', true);
- this.all.elements.splice(index, 0, n);
- }else{
- n = this.all.last().insertSibling(nodes, 'after', true);
- this.all.elements.push(n);
- }
- this.updateIndexes(index);
- },
- onRemove : function(ds, record, index){
- this.deselect(index);
- this.all.removeElement(index, true);
- this.updateIndexes(index);
- },
- refreshNode : function(index){
- this.onUpdate(this.store, this.store.getAt(index));
- },
- updateIndexes : function(startIndex, endIndex){
- var ns = this.all.elements;
- startIndex = startIndex || 0;
- endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
- for(var i = startIndex; i <= endIndex; i++){
- ns[i].viewIndex = i;
- }
- },
- setStore : function(store, initial){
- if(!initial && this.store){
- this.store.un("beforeload", this.onBeforeLoad, this);
- this.store.un("datachanged", this.refresh, this);
- this.store.un("add", this.onAdd, this);
- this.store.un("remove", this.onRemove, this);
- this.store.un("update", this.onUpdate, this);
- this.store.un("clear", this.refresh, this);
- }
- if(store){
- store = Ext.StoreMgr.lookup(store);
- store.on("beforeload", this.onBeforeLoad, this);
- store.on("datachanged", this.refresh, this);
- store.on("add", this.onAdd, this);
- store.on("remove", this.onRemove, this);
- store.on("update", this.onUpdate, this);
- store.on("clear", this.refresh, this);
- }
- this.store = store;
- if(store){
- this.refresh();
- }
- },
- findItemFromChild : function(node){
- return Ext.fly(node).findParent(this.itemSelector, this.el);
- },
- onClick : function(e){
- var item = e.getTarget(this.itemSelector, this.el);
- if(item){
- var index = this.indexOf(item);
- if(this.onItemClick(item, index, e) !== false){
- this.fireEvent("click", this, index, item, e);
- }
- }else{
- if(this.fireEvent("containerclick", this, e) !== false){
- this.clearSelections();
- }
- }
- },
- onContextMenu : function(e){
- var item = e.getTarget(this.itemSelector, this.el);
- if(item){
- this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
- }
- },
- onDblClick : function(e){
- var item = e.getTarget(this.itemSelector, this.el);
- if(item){
- this.fireEvent("dblclick", this, this.indexOf(item), item, e);
- }
- },
- onMouseOver : function(e){
- var item = e.getTarget(this.itemSelector, this.el);
- if(item && item !== this.lastItem){
- this.lastItem = item;
- Ext.fly(item).addClass(this.overClass);
- }
- },
- onMouseOut : function(e){
- if(this.lastItem){
- if(!e.within(this.lastItem, true)){
- Ext.fly(this.lastItem).removeClass(this.overClass);
- delete this.lastItem;
- }
- }
- },
- onItemClick : function(item, index, e){
- if(this.fireEvent("beforeclick", this, index, item, e) === false){
- return false;
- }
- if(this.multiSelect){
- this.doMultiSelection(item, index, e);
- e.preventDefault();
- }else if(this.singleSelect){
- this.doSingleSelection(item, index, e);
- e.preventDefault();
- }
- return true;
- },
- doSingleSelection : function(item, index, e){
- if(e.ctrlKey && this.isSelected(index)){
- this.deselect(index);
- }else{
- this.select(index, false);
- }
- },
- doMultiSelection : function(item, index, e){
- if(e.shiftKey && this.last !== false){
- var last = this.last;
- this.selectRange(last, index, e.ctrlKey);
- this.last = last;
- }else{
- if((e.ctrlKey||this.simpleSelect) && this.isSelected(index)){
- this.deselect(index);
- }else{
- this.select(index, e.ctrlKey || e.shiftKey || this.simpleSelect);
- }
- }
- },
- getSelectionCount : function(){
- return this.selected.getCount()
- },
- getSelectedNodes : function(){
- return this.selected.elements;
- },
- getSelectedIndexes : function(){
- var indexes = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- indexes.push(s[i].viewIndex);
- }
- return indexes;
- },
- getSelectedRecords : function(){
- var r = [], s = this.selected.elements;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
- }
- return r;
- },
- getRecords : function(nodes){
- var r = [], s = nodes;
- for(var i = 0, len = s.length; i < len; i++){
- r[r.length] = this.store.getAt(s[i].viewIndex);
- }
- return r;
- },
- getRecord : function(node){
- return this.store.getAt(node.viewIndex);
- },
- clearSelections : function(suppressEvent, skipUpdate){
- if(this.multiSelect || this.singleSelect){
- if(!skipUpdate){
- this.selected.removeClass(this.selectedClass);
- }
- this.selected.clear();
- this.last = false;
- if(!suppressEvent){
- this.fireEvent("selectionchange", this, this.selected.elements);
- }
- }
- },
- isSelected : function(node){
- return this.selected.contains(this.getNode(node));
- },
- deselect : function(node){
- if(this.isSelected(node)){
- var node = this.getNode(node);
- this.selected.removeElement(node);
- if(this.last == node.viewIndex){
- this.last = false;
- }
- Ext.fly(node).removeClass(this.selectedClass);
- this.fireEvent("selectionchange", this, this.selected.elements);
- }
- },
- select : function(nodeInfo, keepExisting, suppressEvent){
- if(Ext.isArray(nodeInfo)){
- if(!keepExisting){
- this.clearSelections(true);
- }
- for(var i = 0, len = nodeInfo.length; i < len; i++){
- this.select(nodeInfo[i], true, true);
- }
- } else{
- var node = this.getNode(nodeInfo);
- if(!keepExisting){
- this.clearSelections(true);
- }
- if(node && !this.isSelected(node)){
- if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){
- Ext.fly(node).addClass(this.selectedClass);
- this.selected.add(node);
- this.last = node.viewIndex;
- if(!suppressEvent){
- this.fireEvent("selectionchange", this, this.selected.elements);
- }
- }
- }
- }
- },
- selectRange : function(start, end, keepExisting){
- if(!keepExisting){
- this.clearSelections(true);
- }
- this.select(this.getNodes(start, end), true);
- },
- getNode : function(nodeInfo){
- if(typeof nodeInfo == "string"){
- return document.getElementById(nodeInfo);
- }else if(typeof nodeInfo == "number"){
- return this.all.elements[nodeInfo];
- }
- return nodeInfo;
- },
- getNodes : function(start, end){
- var ns = this.all.elements;
- start = start || 0;
- end = typeof end == "undefined" ? ns.length - 1 : end;
- var nodes = [], i;
- if(start <= end){
- for(i = start; i <= end; i++){
- nodes.push(ns[i]);
- }
- } else{
- for(i = start; i >= end; i--){
- nodes.push(ns[i]);
- }
- }
- return nodes;
- },
- indexOf : function(node){
- node = this.getNode(node);
- if(typeof node.viewIndex == "number"){
- return node.viewIndex;
- }
- return this.all.indexOf(node);
- },
- onBeforeLoad : function(){
- if(this.loadingText){
- this.clearSelections(false, true);
- this.el.update('<div class="loading-indicator">'+this.loadingText+'</div>');
- this.all.clear();
- }
- }
- });
- Ext.reg('dataview', Ext.DataView);
- Ext.ColorPalette = function(config){
- Ext.ColorPalette.superclass.constructor.call(this, config);
- this.addEvents(
- 'select'
- );
- if(this.handler){
- this.on("select", this.handler, this.scope, true);
- }
- };
- Ext.extend(Ext.ColorPalette, Ext.Component, {
- itemCls : "x-color-palette",
- value : null,
- clickEvent:'click',
- ctype: "Ext.ColorPalette",
- allowReselect : false,
- colors : [
- "000000", "993300", "333300", "003300", "003366", "000080", "333399", "333333",
- "800000", "FF6600", "808000", "008000", "008080", "0000FF", "666699", "808080",
- "FF0000", "FF9900", "99CC00", "339966", "33CCCC", "3366FF", "800080", "969696",
- "FF00FF", "FFCC00", "FFFF00", "00FF00", "00FFFF", "00CCFF", "993366", "C0C0C0",
- "FF99CC", "FFCC99", "FFFF99", "CCFFCC", "CCFFFF", "99CCFF", "CC99FF", "FFFFFF"
- ],
- onRender : function(container, position){
- var t = this.tpl || new Ext.XTemplate(
- '<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on"> </span></em></a></tpl>'
- );
- var el = document.createElement("div");
- el.className = this.itemCls;
- t.overwrite(el, this.colors);
- container.dom.insertBefore(el, position);
- this.el = Ext.get(el);
- this.el.on(this.clickEvent, this.handleClick, this, {delegate: "a"});
- if(this.clickEvent != 'click'){
- this.el.on('click', Ext.emptyFn, this, {delegate: "a", preventDefault:true});
- }
- },
- afterRender : function(){
- Ext.ColorPalette.superclass.afterRender.call(this);
- if(this.value){
- var s = this.value;
- this.value = null;
- this.select(s);
- }
- },
- handleClick : function(e, t){
- e.preventDefault();
- if(!this.disabled){
- var c = t.className.match(/(?:^|s)color-(.{6})(?:s|$)/)[1];
- this.select(c.toUpperCase());
- }
- },
- select : function(color){
- color = color.replace("#", "");
- if(color != this.value || this.allowReselect){
- var el = this.el;
- if(this.value){
- el.child("a.color-"+this.value).removeClass("x-color-palette-sel");
- }
- el.child("a.color-"+color).addClass("x-color-palette-sel");
- this.value = color;
- this.fireEvent("select", this, color);
- }
- }
- });
- Ext.reg('colorpalette', Ext.ColorPalette);
- Ext.DatePicker = Ext.extend(Ext.Component, {
- todayText : "Today",
- okText : " OK ",
- cancelText : "Cancel",
- todayTip : "{0} (Spacebar)",
- minDate : null,
- maxDate : null,
- minText : "This date is before the minimum date",
- maxText : "This date is after the maximum date",
- format : "m/d/y",
- disabledDays : null,
- disabledDaysText : "",
- disabledDatesRE : null,
- disabledDatesText : "",
- constrainToViewport : true,
- monthNames : Date.monthNames,
- dayNames : Date.dayNames,
- nextText: 'Next Month (Control+Right)',
- prevText: 'Previous Month (Control+Left)',
- monthYearText: 'Choose a month (Control+Up/Down to move years)',
- startDay : 0,
- initComponent : function(){
- Ext.DatePicker.superclass.initComponent.call(this);
- this.value = this.value ?
- this.value.clearTime() : new Date().clearTime();
- this.addEvents(
- 'select'
- );
- if(this.handler){
- this.on("select", this.handler, this.scope || this);
- }
- this.initDisabledDays();
- },
- initDisabledDays : function(){
- if(!this.disabledDatesRE && this.disabledDates){
- var dd = this.disabledDates;
- var re = "(?:";
- for(var i = 0; i < dd.length; i++){
- re += dd[i];
- if(i != dd.length-1) re += "|";
- }
- this.disabledDatesRE = new RegExp(re + ")");
- }
- },
- setValue : function(value){
- var old = this.value;
- this.value = value.clearTime(true);
- if(this.el){
- this.update(this.value);
- }
- },
- getValue : function(){
- return this.value;
- },
- focus : function(){
- if(this.el){
- this.update(this.activeDate);
- }
- },
- onRender : function(container, position){
- var m = [
- '<table cellspacing="0">',
- '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'"> </a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'"> </a></td></tr>',
- '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
- var dn = this.dayNames;
- for(var i = 0; i < 7; i++){
- var d = this.startDay+i;
- if(d > 6){
- d = d-7;
- }
- m.push("<th><span>", dn[d].substr(0,1), "</span></th>");
- }
- m[m.length] = "</tr></thead><tbody><tr>";
- for(var i = 0; i < 42; i++) {
- if(i % 7 == 0 && i != 0){
- m[m.length] = "</tr><tr>";
- }
- m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
- }
- m[m.length] = '</tr></tbody></table></td></tr><tr><td colspan="3" class="x-date-bottom" align="center"></td></tr></table><div class="x-date-mp"></div>';
- var el = document.createElement("div");
- el.className = "x-date-picker";
- el.innerHTML = m.join("");
- container.dom.insertBefore(el, position);
- this.el = Ext.get(el);
- this.eventEl = Ext.get(el.firstChild);
- new Ext.util.ClickRepeater(this.el.child("td.x-date-left a"), {
- handler: this.showPrevMonth,
- scope: this,
- preventDefault:true,
- stopDefault:true
- });
- new Ext.util.ClickRepeater(this.el.child("td.x-date-right a"), {
- handler: this.showNextMonth,
- scope: this,
- preventDefault:true,
- stopDefault:true
- });
- this.eventEl.on("mousewheel", this.handleMouseWheel, this);
- this.monthPicker = this.el.down('div.x-date-mp');
- this.monthPicker.enableDisplayMode('block');
- var kn = new Ext.KeyNav(this.eventEl, {
- "left" : function(e){
- e.ctrlKey ?
- this.showPrevMonth() :
- this.update(this.activeDate.add("d", -1));
- },
- "right" : function(e){
- e.ctrlKey ?
- this.showNextMonth() :
- this.update(this.activeDate.add("d", 1));
- },
- "up" : function(e){
- e.ctrlKey ?
- this.showNextYear() :
- this.update(this.activeDate.add("d", -7));
- },
- "down" : function(e){
- e.ctrlKey ?
- this.showPrevYear() :
- this.update(this.activeDate.add("d", 7));
- },
- "pageUp" : function(e){
- this.showNextMonth();
- },
- "pageDown" : function(e){
- this.showPrevMonth();
- },
- "enter" : function(e){
- e.stopPropagation();
- return true;
- },
- scope : this
- });
- this.eventEl.on("click", this.handleDateClick, this, {delegate: "a.x-date-date"});
- this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
- this.el.unselectable();
- this.cells = this.el.select("table.x-date-inner tbody td");
- this.textNodes = this.el.query("table.x-date-inner tbody span");
- this.mbtn = new Ext.Button({
- text: " ",
- tooltip: this.monthYearText,
- renderTo: this.el.child("td.x-date-middle", true)
- });
- this.mbtn.on('click', this.showMonthPicker, this);
- this.mbtn.el.child(this.mbtn.menuClassTarget).addClass("x-btn-with-menu");
- var today = (new Date()).dateFormat(this.format);
- this.todayBtn = new Ext.Button({
- renderTo: this.el.child("td.x-date-bottom", true),
- text: String.format(this.todayText, today),
- tooltip: String.format(this.todayTip, today),
- handler: this.selectToday,
- scope: this
- });
- if(Ext.isIE){
- this.el.repaint();
- }
- this.update(this.value);
- },
- createMonthPicker : function(){
- if(!this.monthPicker.dom.firstChild){
- var buf = ['<table border="0" cellspacing="0">'];
- for(var i = 0; i < 6; i++){
- buf.push(
- '<tr><td class="x-date-mp-month"><a href="#">', this.monthNames[i].substr(0, 3), '</a></td>',
- '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', this.monthNames[i+6].substr(0, 3), '</a></td>',
- i == 0 ?
- '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
- '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
- );
- }
- buf.push(
- '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
- this.okText,
- '</button><button type="button" class="x-date-mp-cancel">',
- this.cancelText,
- '</button></td></tr>',
- '</table>'
- );
- this.monthPicker.update(buf.join(''));
- this.monthPicker.on('click', this.onMonthClick, this);
- this.monthPicker.on('dblclick', this.onMonthDblClick, this);
- this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
- this.mpYears = this.monthPicker.select('td.x-date-mp-year');
- this.mpMonths.each(function(m, a, i){
- i += 1;
- if((i%2) == 0){
- m.dom.xmonth = 5 + Math.round(i * .5);
- }else{
- m.dom.xmonth = Math.round((i-1) * .5);
- }
- });
- }
- },
- showMonthPicker : function(){
- this.createMonthPicker();
- var size = this.el.getSize();
- this.monthPicker.setSize(size);
- this.monthPicker.child('table').setSize(size);
- this.mpSelMonth = (this.activeDate || this.value).getMonth();
- this.updateMPMonth(this.mpSelMonth);
- this.mpSelYear = (this.activeDate || this.value).getFullYear();
- this.updateMPYear(this.mpSelYear);
- this.monthPicker.slideIn('t', {duration:.2});
- },
- updateMPYear : function(y){
- this.mpyear = y;
- var ys = this.mpYears.elements;
- for(var i = 1; i <= 10; i++){
- var td = ys[i-1], y2;
- if((i%2) == 0){
- y2 = y + Math.round(i * .5);
- td.firstChild.innerHTML = y2;
- td.xyear = y2;
- }else{
- y2 = y - (5-Math.round(i * .5));
- td.firstChild.innerHTML = y2;
- td.xyear = y2;
- }
- this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
- }
- },
- updateMPMonth : function(sm){
- this.mpMonths.each(function(m, a, i){
- m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
- });
- },
- selectMPMonth: function(m){
- },
- onMonthClick : function(e, t){
- e.stopEvent();
- var el = new Ext.Element(t), pn;
- if(el.is('button.x-date-mp-cancel')){
- this.hideMonthPicker();
- }
- else if(el.is('button.x-date-mp-ok')){
- this.update(new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
- this.hideMonthPicker();
- }
- else if(pn = el.up('td.x-date-mp-month', 2)){
- this.mpMonths.removeClass('x-date-mp-sel');
- pn.addClass('x-date-mp-sel');
- this.mpSelMonth = pn.dom.xmonth;
- }
- else if(pn = el.up('td.x-date-mp-year', 2)){
- this.mpYears.removeClass('x-date-mp-sel');
- pn.addClass('x-date-mp-sel');
- this.mpSelYear = pn.dom.xyear;
- }
- else if(el.is('a.x-date-mp-prev')){
- this.updateMPYear(this.mpyear-10);
- }
- else if(el.is('a.x-date-mp-next')){
- this.updateMPYear(this.mpyear+10);
- }
- },
- onMonthDblClick : function(e, t){
- e.stopEvent();
- var el = new Ext.Element(t), pn;
- if(pn = el.up('td.x-date-mp-month', 2)){
- this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
- this.hideMonthPicker();
- }
- else if(pn = el.up('td.x-date-mp-year', 2)){
- this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
- this.hideMonthPicker();
- }
- },
- hideMonthPicker : function(disableAnim){
- if(this.monthPicker){
- if(disableAnim === true){
- this.monthPicker.hide();
- }else{
- this.monthPicker.slideOut('t', {duration:.2});
- }
- }
- },
- showPrevMonth : function(e){
- this.update(this.activeDate.add("mo", -1));
- },
- showNextMonth : function(e){
- this.update(this.activeDate.add("mo", 1));
- },
- showPrevYear : function(){
- this.update(this.activeDate.add("y", -1));
- },
- showNextYear : function(){
- this.update(this.activeDate.add("y", 1));
- },
- handleMouseWheel : function(e){
- var delta = e.getWheelDelta();
- if(delta > 0){
- this.showPrevMonth();
- e.stopEvent();
- } else if(delta < 0){
- this.showNextMonth();
- e.stopEvent();
- }
- },
- handleDateClick : function(e, t){
- e.stopEvent();
- if(t.dateValue && !Ext.fly(t.parentNode).hasClass("x-date-disabled")){
- this.setValue(new Date(t.dateValue));
- this.fireEvent("select", this, this.value);
- }
- },
- selectToday : function(){
- this.setValue(new Date().clearTime());
- this.fireEvent("select", this, this.value);
- },
- update : function(date){
- var vd = this.activeDate;
- this.activeDate = date;
- if(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;
- 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() {
- this.mbtn.destroy();
- this.todayBtn.destroy();
- }
- });
- 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}});
- this.stripSpacer = st.createChild({cls:'x-tab-strip-spacer'});
- 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('click', this.onStripClick, 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){
- e.preventDefault();
- if(e.button != 0){
- return;
- }
- var t = this.findTargets(e);
- if(t.close){
- this.remove(t.item);
- return;
- }
- if(t.item && t.item != this.activeTab){
- this.setActiveTab(t.item);
- }
- },
- onStripClick : function(e){
- var t = this.findTargets(e);
- if(!t.close && 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);
- 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();
- }
- },
- 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");
- Ext.getDoc().on('mouseover', this.monitorMouseOver, this);
- 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)){
- Ext.getDoc().un('mouseover', this.monitorMouseOver, this);
- 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(ti);
- 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(){
- 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();
- },
- 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();
- if(pageNum = this.readPage(d)){
- 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;
- this.store.load({params:o});
- },
- 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"});
- 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",
- "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){
- if(this.completeOnEnter && e.getKey() == e.ENTER){
- e.stopEvent();
- this.completeEdit();
- }else if(this.cancelOnEsc && e.getKey() == e.ESC){
- this.cancelEdit();
- }else{
- this.fireEvent('specialkey', field, e);
- }
- },
- 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){
- 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){
- this.setValue(this.startValue);
- if(remainVisible !== true){
- this.hide();
- }
- }
- },
- 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();