📄 _view.js
字号:
this.content=new _38(this);this.header=new _4f(this);if(!dojo._isBodyLtr()){this.headerNodeContainer.style.width="";}},destroy:function(){dojo._destroyElement(this.headerNode);delete this.headerNode;dojo.forEach(this.rowNodes,dojo._destroyElement);this.rowNodes=[];if(this.source){this.source.destroy();}this.inherited(arguments);},focus:function(){if(dojo.isSafari||dojo.isOpera){this.hiddenFocusNode.focus();}else{this.scrollboxNode.focus();}},setStructure:function(_af){var vs=this.structure=_af;if(vs.width&&!isNaN(vs.width)){this.viewWidth=vs.width+"em";}else{this.viewWidth=vs.width||(vs.noscroll?"auto":this.viewWidth);}this.onBeforeRow=vs.onBeforeRow;this.noscroll=vs.noscroll;if(this.noscroll){this.scrollboxNode.style.overflow="hidden";}this.simpleStructure=Boolean(vs.cells.length==1);this.testFlexCells();this.updateStructure();},testFlexCells:function(){this.flexCells=false;for(var j=0,row;(row=this.structure.cells[j]);j++){for(var i=0,_b4;(_b4=row[i]);i++){_b4.view=this;this.flexCells=this.flexCells||_b4.isFlex();}}return this.flexCells;},updateStructure:function(){this.header.update();this.content.update();},getScrollbarWidth:function(){var _b5=this.hasVScrollbar();var _b6=dojo.style(this.scrollboxNode,"overflow");if(this.noscroll||!_b6||_b6=="hidden"){_b5=false;}else{if(_b6=="scroll"){_b5=true;}}return (_b5?dojox.html.metrics.getScrollbar().w:0);},getColumnsWidth:function(){return this.headerContentNode.firstChild.offsetWidth;},setColumnsWidth:function(_b7){this.headerContentNode.firstChild.style.width=_b7+"px";if(this.viewWidth){this.viewWidth=_b7+"px";}},getWidth:function(){return this.viewWidth||(this.getColumnsWidth()+this.getScrollbarWidth())+"px";},getContentWidth:function(){return Math.max(0,dojo._getContentBox(this.domNode).w-this.getScrollbarWidth())+"px";},render:function(){this.scrollboxNode.style.height="";this.renderHeader();if(this._togglingColumn>=0){this.setColumnsWidth(this.getColumnsWidth()-this._togglingColumn);this._togglingColumn=-1;}var _b8=this.grid.layout.cells;var _b9=dojo.hitch(this,function(_ba,_bb){var inc=_bb?-1:1;var idx=this.header.getCellNodeIndex(_ba)+inc;var _be=_b8[idx];while(_be&&_be.getHeaderNode()&&_be.getHeaderNode().style.display=="none"){idx+=inc;_be=_b8[idx];}if(_be){return _be.getHeaderNode();}return null;});if(this.grid.columnReordering&&this.simpleStructure){if(this.source){this.source.destroy();}this.source=new dojo.dnd.Source(this.headerContentNode.firstChild.rows[0],{horizontal:true,accept:["gridColumn_"+this.grid.id],viewIndex:this.index,onMouseDown:dojo.hitch(this,function(e){this.header.decorateEvent(e);if((this.header.overRightResizeArea(e)||this.header.overLeftResizeArea(e))&&this.header.canResize(e)&&!_4e){this.header.beginColumnResize(e);}else{if(this.grid.headerMenu){this.grid.headerMenu.onCancel(true);}if(e.button===(dojo.isIE?1:0)){dojo.dnd.Source.prototype.onMouseDown.call(this.source,e);}}}),_markTargetAnchor:dojo.hitch(this,function(_c0){var src=this.source;if(src.current==src.targetAnchor&&src.before==_c0){return;}if(src.targetAnchor&&_b9(src.targetAnchor,src.before)){src._removeItemClass(_b9(src.targetAnchor,src.before),src.before?"After":"Before");}dojo.dnd.Source.prototype._markTargetAnchor.call(src,_c0);if(src.targetAnchor&&_b9(src.targetAnchor,src.before)){src._addItemClass(_b9(src.targetAnchor,src.before),src.before?"After":"Before");}}),_unmarkTargetAnchor:dojo.hitch(this,function(){var src=this.source;if(!src.targetAnchor){return;}if(src.targetAnchor&&_b9(src.targetAnchor,src.before)){src._removeItemClass(_b9(src.targetAnchor,src.before),src.before?"After":"Before");}dojo.dnd.Source.prototype._unmarkTargetAnchor.call(src);}),destroy:dojo.hitch(this,function(){dojo.disconnect(this._source_conn);dojo.unsubscribe(this._source_sub);dojo.dnd.Source.prototype.destroy.call(this.source);})});this._source_conn=dojo.connect(this.source,"onDndDrop",this,"_onDndDrop");this._source_sub=dojo.subscribe("/dnd/drop/before",this,"_onDndDropBefore");this.source.startup();}},_onDndDropBefore:function(_c3,_c4,_c5){if(dojo.dnd.manager().target!==this.source){return;}this.source._targetNode=this.source.targetAnchor;this.source._beforeTarget=this.source.before;var _c6=this.grid.views.views;var _c7=_c6[_c3.viewIndex];var _c8=_c6[this.index];if(_c8!=_c7){var s=_c7.convertColPctToFixed();var t=_c8.convertColPctToFixed();if(s||t){setTimeout(function(){_c7.update();_c8.update();},50);}}},_onDndDrop:function(_cb,_cc,_cd){if(dojo.dnd.manager().target!==this.source){if(dojo.dnd.manager().source===this.source){this._removingColumn=true;}return;}var _ce=function(n){return n?dojo.attr(n,"idx"):null;};var w=dojo.marginBox(_cc[0]).w;if(_cb.viewIndex!==this.index){var _d1=this.grid.views.views;var _d2=_d1[_cb.viewIndex];var _d3=_d1[this.index];if(_d2.viewWidth&&_d2.viewWidth!="auto"){_d2.setColumnsWidth(_d2.getColumnsWidth()-w);}if(_d3.viewWidth&&_d3.viewWidth!="auto"){_d3.setColumnsWidth(_d3.getColumnsWidth());}}var stn=this.source._targetNode;var stb=this.source._beforeTarget;var _d6=this.grid.layout;var idx=this.index;delete this.source._targetNode;delete this.source._beforeTarget;window.setTimeout(function(){_d6.moveColumn(_cb.viewIndex,idx,_ce(_cc[0]),_ce(stn),stb);},1);},renderHeader:function(){this.headerContentNode.innerHTML=this.header.generateHtml(this._getHeaderContent);if(this.flexCells){this.contentWidth=this.getContentWidth();this.headerContentNode.firstChild.style.width=this.contentWidth;}},_getHeaderContent:function(_d8){var n=_d8.name||_d8.grid.getCellName(_d8);var ret=["<div class=\"dojoxGridSortNode"];if(_d8.index!=_d8.grid.getSortIndex()){ret.push("\">");}else{ret=ret.concat([" ",_d8.grid.sortInfo>0?"dojoxGridSortUp":"dojoxGridSortDown","\"><div class=\"dojoxGridArrowButtonChar\">",_d8.grid.sortInfo>0?"▲":"▼","</div><div class=\"dojoxGridArrowButtonNode\"></div>"]);}ret=ret.concat([n,"</div>"]);return ret.join("");},resize:function(){this.adaptHeight();this.adaptWidth();},hasHScrollbar:function(_db){if(this._hasHScroll==undefined||_db){if(this.noscroll){this._hasHScroll=false;}else{var _dc=dojo.style(this.scrollboxNode,"overflow");if(_dc=="hidden"){this._hasHScroll=false;}else{if(_dc=="scroll"){this._hasHScroll=true;}else{this._hasHScroll=(this.scrollboxNode.offsetWidth<this.contentNode.offsetWidth);}}}}return this._hasHScroll;},hasVScrollbar:function(_dd){if(this._hasVScroll==undefined||_dd){if(this.noscroll){this._hasVScroll=false;}else{var _de=dojo.style(this.scrollboxNode,"overflow");if(_de=="hidden"){this._hasVScroll=false;}else{if(_de=="scroll"){this._hasVScroll=true;}else{this._hasVScroll=(this.scrollboxNode.offsetHeight<this.contentNode.offsetHeight);}}}}return this._hasVScroll;},convertColPctToFixed:function(){var _df=false;var _e0=dojo.query("th",this.headerContentNode);var _e1=dojo.map(_e0,function(c){var w=c.style.width;if(w&&w.slice(-1)=="%"){_df=true;return dojo.contentBox(c).w;}else{if(w&&w.slice(-2)=="px"){return window.parseInt(w,10);}}return -1;});if(_df){dojo.forEach(this.grid.layout.cells,function(_e4,idx){if(_e4.view==this){var _e6=_e4.layoutIndex;this.setColWidth(idx,_e1[_e6]);_e0[_e6].style.width=_e4.unitWidth;}},this);return true;}return false;},adaptHeight:function(_e7){if(!this.grid._autoHeight){var h=this.domNode.clientHeight;if(_e7){h-=dojox.html.metrics.getScrollbar().h;}dojox.grid.util.setStyleHeightPx(this.scrollboxNode,h);}this.hasVScrollbar(true);},adaptWidth:function(){if(this.flexCells){this.contentWidth=this.getContentWidth();this.headerContentNode.firstChild.style.width=this.contentWidth;}var w=this.scrollboxNode.offsetWidth-this.getScrollbarWidth();if(!this._removingColumn){w=Math.max(w,this.getColumnsWidth())+"px";}else{w=Math.min(w,this.getColumnsWidth())+"px";this._removingColumn=false;}var cn=this.contentNode;cn.style.width=w;this.hasHScrollbar(true);},setSize:function(w,h){var ds=this.domNode.style;var hs=this.headerNode.style;if(w){ds.width=w;hs.width=w;}ds.height=(h>=0?h+"px":"");},renderRow:function(_ef){var _f0=this.createRowNode(_ef);this.buildRow(_ef,_f0);this.grid.edit.restore(this,_ef);if(this._pendingUpdate){window.clearTimeout(this._pendingUpdate);}this._pendingUpdate=window.setTimeout(dojo.hitch(this,function(){window.clearTimeout(this._pendingUpdate);delete this._pendingUpdate;this.grid._resize();}),50);return _f0;},createRowNode:function(_f1){var _f2=document.createElement("div");_f2.className=this.classTag+"Row";_f2[_2]=this.id;_f2[_1]=_f1;this.rowNodes[_f1]=_f2;return _f2;},buildRow:function(_f3,_f4){this.buildRowContent(_f3,_f4);this.styleRow(_f3,_f4);},buildRowContent:function(_f5,_f6){_f6.innerHTML=this.content.generateHtml(_f5,_f5);if(this.flexCells&&this.contentWidth){_f6.firstChild.style.width=this.contentWidth;}},rowRemoved:function(_f7){this.grid.edit.save(this,_f7);delete this.rowNodes[_f7];},getRowNode:function(_f8){return this.rowNodes[_f8];},getCellNode:function(_f9,_fa){var row=this.getRowNode(_f9);if(row){return this.content.getCellNode(row,_fa);}},getHeaderCellNode:function(_fc){if(this.headerContentNode){return this.header.getCellNode(this.headerContentNode,_fc);}},styleRow:function(_fd,_fe){_fe._style=_15(_fe);this.styleRowNode(_fd,_fe);},styleRowNode:function(_ff,_100){if(_100){this.doStyleRowNode(_ff,_100);}},doStyleRowNode:function(_101,_102){this.grid.styleRowNode(_101,_102);},updateRow:function(_103){var _104=this.getRowNode(_103);if(_104){_104.style.height="";this.buildRow(_103,_104);}return _104;},updateRowStyles:function(_105){this.styleRowNode(_105,this.getRowNode(_105));},lastTop:0,firstScroll:0,doscroll:function(_106){var _107=dojo._isBodyLtr();if(this.firstScroll<2){if((!_107&&this.firstScroll==1)||(_107&&this.firstScroll==0)){var s=dojo.marginBox(this.headerNodeContainer);if(dojo.isIE){this.headerNodeContainer.style.width=s.w+this.getScrollbarWidth()+"px";}else{if(dojo.isMoz){this.headerNodeContainer.style.width=s.w-this.getScrollbarWidth()+"px";this.scrollboxNode.scrollLeft=_107?this.scrollboxNode.clientWidth-this.scrollboxNode.scrollWidth:this.scrollboxNode.scrollWidth-this.scrollboxNode.clientWidth;}}}this.firstScroll++;}this.headerNode.scrollLeft=this.scrollboxNode.scrollLeft;var top=this.scrollboxNode.scrollTop;if(top!=this.lastTop){this.grid.scrollTo(top);}},setScrollTop:function(_10a){this.lastTop=_10a;this.scrollboxNode.scrollTop=_10a;return this.scrollboxNode.scrollTop;},doContentEvent:function(e){if(this.content.decorateEvent(e)){this.grid.onContentEvent(e);}},doHeaderEvent:function(e){if(this.header.decorateEvent(e)){this.grid.onHeaderEvent(e);}},dispatchContentEvent:function(e){return this.content.dispatchEvent(e);},dispatchHeaderEvent:function(e){return this.header.dispatchEvent(e);},setColWidth:function(_10f,_110){this.grid.setCellWidth(_10f,_110+"px");},update:function(){var left=this.scrollboxNode.scrollLeft;this.content.update();this.grid.update();this.scrollboxNode.scrollLeft=left;this.headerNode.scrollLeft=left;}});dojo.declare("dojox.grid._GridAvatar",dojo.dnd.Avatar,{construct:function(){var dd=dojo.doc;var a=dd.createElement("table");a.cellPadding=a.cellSpacing="0";a.className="dojoxGridDndAvatar";a.style.position="absolute";a.style.zIndex=1999;a.style.margin="0px";var b=dd.createElement("tbody");var tr=dd.createElement("tr");var td=dd.createElement("td");var img=dd.createElement("td");tr.className="dojoxGridDndAvatarItem";img.className="dojoxGridDndAvatarItemImage";img.style.width="16px";var _118=this.manager.source,node;if(_118.creator){node=_118._normailzedCreator(_118.getItem(this.manager.nodes[0].id).data,"avatar").node;}else{node=this.manager.nodes[0].cloneNode(true);if(node.tagName.toLowerCase()=="tr"){var _11a=dd.createElement("table"),_11b=dd.createElement("tbody");_11b.appendChild(node);_11a.appendChild(_11b);node=_11a;}else{if(node.tagName.toLowerCase()=="th"){var _11a=dd.createElement("table"),_11b=dd.createElement("tbody"),r=dd.createElement("tr");_11a.cellPadding=_11a.cellSpacing="0";r.appendChild(node);_11b.appendChild(r);_11a.appendChild(_11b);node=_11a;}}}node.id="";td.appendChild(node);tr.appendChild(img);tr.appendChild(td);dojo.style(tr,"opacity",0.9);b.appendChild(tr);a.appendChild(b);this.node=a;var m=dojo.dnd.manager();this.oldOffsetY=m.OFFSET_Y;m.OFFSET_Y=1;},destroy:function(){dojo.dnd.manager().OFFSET_Y=this.oldOffsetY;this.inherited(arguments);}});var _11e=dojo.dnd.manager().makeAvatar;dojo.dnd.manager().makeAvatar=function(){var src=this.source;if(src.viewIndex!==undefined){return new dojox.grid._GridAvatar(this);}return _11e.call(dojo.dnd.manager());};})();}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -