📄 view-min.js
字号:
/*
* Ext JS Library 1.0.1
* Copyright(c) 2006-2007, Ext JS, LLC.
* licensing@extjs.com
*
* http://www.extjs.com/license
*/
Ext.View=function(_1,_2,_3){this.el=Ext.get(_1,true);if(typeof _2=="string"){_2=new Ext.Template(_2);}_2.compile();this.tpl=_2;Ext.apply(this,_3);this.addEvents({"beforeclick":true,"click":true,"dblclick":true,"contextmenu":true,"selectionchange":true,"beforeselect":true});this.el.on({"click":this.onClick,"dblclick":this.onDblClick,"contextmenu":this.onContextMenu,scope:this});this.selections=[];this.nodes=[];this.cmp=new Ext.CompositeElementLite([]);if(this.store){this.setStore(this.store,true);}Ext.View.superclass.constructor.call(this);};Ext.extend(Ext.View,Ext.util.Observable,{selectedClass:"x-view-selected",emptyText:"",getEl:function(){return this.el;},refresh:function(){var t=this.tpl;this.clearSelections();this.el.update("");var _5=[];var _6=this.store.getRange();if(_6.length<1){this.el.update(this.emptyText);return;}for(var i=0,_8=_6.length;i<_8;i++){var _9=this.prepareData(_6[i].data,i,_6[i]);_5[_5.length]=t.apply(_9);}this.el.update(_5.join(""));this.nodes=this.el.dom.childNodes;this.updateIndexes(0);},prepareData:function(_a){return _a;},onUpdate:function(ds,_c){this.clearSelections();var _d=this.store.indexOf(_c);var n=this.nodes[_d];this.tpl.insertBefore(n,this.prepareData(_c.data));n.parentNode.removeChild(n);this.updateIndexes(_d,_d);},onAdd:function(ds,_10,_11){this.clearSelections();if(this.nodes.length==0){this.refresh();return;}var n=this.nodes[_11];for(var i=0,len=_10.length;i<len;i++){var d=this.prepareData(_10[i].data);if(n){this.tpl.insertBefore(n,d);}else{this.tpl.append(this.el,d);}}this.updateIndexes(_11);},onRemove:function(ds,_17,_18){this.clearSelections();this.el.dom.removeChild(this.nodes[_18]);this.updateIndexes(_18);},refreshNode:function(_19){this.onUpdate(this.store,this.store.getAt(_19));},updateIndexes:function(_1a,_1b){var ns=this.nodes;_1a=_1a||0;_1b=_1b||ns.length-1;for(var i=_1a;i<=_1b;i++){ns[i].nodeIndex=i;}},setStore:function(_1e,_1f){if(!_1f&&this.store){this.store.un("datachanged",this.refresh);this.store.un("add",this.onAdd);this.store.un("remove",this.onRemove);this.store.un("update",this.onUpdate);this.store.un("clear",this.refresh);}if(_1e){_1e.on("datachanged",this.refresh,this);_1e.on("add",this.onAdd,this);_1e.on("remove",this.onRemove,this);_1e.on("update",this.onUpdate,this);_1e.on("clear",this.refresh,this);}this.store=_1e;this.refresh();},findItemFromChild:function(_20){var el=this.el.dom;if(!_20||_20.parentNode==el){return _20;}var p=_20.parentNode;while(p&&p!=el){if(p.parentNode==el){return p;}p=p.parentNode;}return null;},onClick:function(e){var _24=this.findItemFromChild(e.getTarget());if(_24){var _25=this.indexOf(_24);if(this.onItemClick(_24,_25,e)!==false){this.fireEvent("click",this,_25,_24,e);}}else{this.clearSelections();}},onContextMenu:function(e){var _27=this.findItemFromChild(e.getTarget());if(_27){this.fireEvent("contextmenu",this,this.indexOf(_27),_27,e);}},onDblClick:function(e){var _29=this.findItemFromChild(e.getTarget());if(_29){this.fireEvent("dblclick",this,this.indexOf(_29),_29,e);}},onItemClick:function(_2a,_2b,e){if(this.fireEvent("beforeclick",this,_2b,_2a,e)===false){return false;}if(this.multiSelect||this.singleSelect){if(this.multiSelect&&e.shiftKey&&this.lastSelection){this.select(this.getNodes(this.indexOf(this.lastSelection),_2b),false);}else{this.select(_2a,this.multiSelect&&e.ctrlKey);this.lastSelection=_2a;}e.preventDefault();}return true;},getSelectionCount:function(){return this.selections.length;},getSelectedNodes:function(){return this.selections;},getSelectedIndexes:function(){var _2d=[],s=this.selections;for(var i=0,len=s.length;i<len;i++){_2d.push(s[i].nodeIndex);}return _2d;},clearSelections:function(_31){if(this.nodes&&(this.multiSelect||this.singleSelect)&&this.selections.length>0){this.cmp.elements=this.selections;this.cmp.removeClass(this.selectedClass);this.selections=[];if(!_31){this.fireEvent("selectionchange",this,this.selections);}}},isSelected:function(_32){var s=this.selections;if(s.length<1){return false;}_32=this.getNode(_32);return s.indexOf(_32)!==-1;},select:function(_34,_35,_36){if(_34 instanceof Array){if(!_35){this.clearSelections(true);}for(var i=0,len=_34.length;i<len;i++){this.select(_34[i],true,true);}}else{var _39=this.getNode(_34);if(_39&&!this.isSelected(_39)){if(!_35){this.clearSelections(true);}if(this.fireEvent("beforeselect",this,_39,this.selections)!==false){Ext.fly(_39).addClass(this.selectedClass);this.selections.push(_39);if(!_36){this.fireEvent("selectionchange",this,this.selections);}}}}},getNode:function(_3a){if(typeof _3a=="string"){return document.getElementById(_3a);}else{if(typeof _3a=="number"){return this.nodes[_3a];}}return _3a;},getNodes:function(_3b,end){var ns=this.nodes;_3b=_3b||0;end=typeof end=="undefined"?ns.length-1:end;var _3e=[];if(_3b<=end){for(var i=_3b;i<=end;i++){_3e.push(ns[i]);}}else{for(var i=_3b;i>=end;i--){_3e.push(ns[i]);}}return _3e;},indexOf:function(_40){_40=this.getNode(_40);if(typeof _40.nodeIndex=="number"){return _40.nodeIndex;}var ns=this.nodes;for(var i=0,len=ns.length;i<len;i++){if(ns[i]==_40){return i;}}return -1;}});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -