?? grids.js
字號:
this._gridBodyElement.scrollTop=n;};_p.getScrollTop=function(n){if(this.getCreated())
return this._gridBodyElement.scrollTop;};_p.getScrollWidth=function(n){if(this.getCreated())
return this._gridBodyElement.scrollWidth;};_p.getScrollHeight=function(n){if(this.getCreated())
return this._gridBodyElement.scrollHeight;};_p.getClientWidth=function(){if(!this._created)
throw new Error("Visual property on non created component");return this._gridBodyElement.clientWidth;};_p.getClientHeight=function(){if(!this._created)
throw new Error("Visual property on non created component");return this._gridBodyElement.clientHeight;};_p.setOverflowX=function(sOverflowX){if(this._overflowX!=sOverflowX){this._overflowX=sOverflowX;if(this._created)
this._gridBodyElement.style.overflowX=sOverflowX;}};_p.setOverflowY=function(sOverflowY){if(this._overflowY!=sOverflowY){this._overflowY=sOverflowY;if(this._created)
this._gridBodyElement.style.overflowY=sOverflowY;}};BiAbstractGrid.prototype.getOverflowX=function(){return this._overflowX;};BiAbstractGrid.prototype.getOverflowY=function(){return this._overflowY;};_p.sort=function(nCol,bAscending)
{if(!this.dispatchEvent(new BiEvent("beforesort")))
return;if(nCol!= -1){var f=this._columns[nCol].getSortFunction();}
this._sortColumn=nCol;this._ascending=Boolean(bAscending);this._headers.setSortColumn(nCol);this._headers.setAscending(bAscending);if(nCol!= -1){this._sort(f,bAscending);this.updateData();}
this.dispatchEvent(new BiEvent("sort"));};_p._sort=function(fCompare,bAscending){this._rows.sort(fCompare);if(!bAscending)
this._rows.reverse();};_p._onFocusChange=function(e){var items=this.getSelectedRows();for(var i=0;i<items.length;i++)
items[i]._updateClassName();if(this._selectionModel._leadItem)
this._selectionModel._leadItem._updateClassName();};_p._onKeyPress=function(e){if(new Date-this._lastKeyPress>1000){this._accumulatedKeys="";}
this._accumulatedKeys+=String.fromCharCode(e.getKeyCode());var item=this._findItem(this._accumulatedKeys,null,"String");if(item){var oldVal=this._selectionModel._getChangeValue();var oldFireChange=this._selectionModel._fireChange;this._selectionModel._fireChange=false;this._selectionModel._deselectAll();this._selectionModel.setItemSelected(item,true);this._selectionModel.setAnchorItem(item);this._selectionModel.setLeadItem(item);item.scrollIntoView();this._selectionModel._fireChange=oldFireChange;if(this._selectionModel._fireChange&&this._selectionModel._hasChanged(oldVal))
this._selectionModel._dispatchChange();}
this._lastKeyPress=(new Date).valueOf();};function BiAbstractGridRow(){BiObject.call(this);}
var _p=BiAbstractGridRow.prototype=new BiObject;_p._className="BiAbstractGridRow";_p._grid=null;_p._icon=null;_p._selected=false;_p._anchor=false;_p._lead=false;BiAbstractGridRow.prototype.getIcon=function(){return this._icon;};BiAbstractGridRow.prototype.getBackColor=function(){return this._backColor;};BiAbstractGridRow.prototype.setBackColor=function(v){this._backColor=v;};BiAbstractGridRow.prototype.getForeColor=function(){return this._foreColor;};BiAbstractGridRow.prototype.setForeColor=function(v){this._foreColor=v;};_p._getStyle=function(){if(!this._backColor&&!this._foreColor)
return"";return" style=\""+(this._backColor?"background-color:"+this._backColor+";":"")+(this._foreColor?"color:"+this._foreColor+";":"")+"\"";};_p.setIcon=function(oIcon)
{if(oIcon==null||oIcon.getIconHtml||oImage instanceof BiUri)
this._icon=oIcon;else this._icon=new BiUri(application.getAdfPath(),oIcon);};_p.setSelected=function(bSelected){if(this._selected!=bSelected){var g=this.getGrid();if(g!=null){g._selectionModel.setItemSelected(this,bSelected);}
this._setSelected(bSelected);}};BiAbstractGridRow.prototype.getSelected=function(){return this._selected;};_p._setSelected=function(bSelected){this._selected=bSelected;this._updateClassName();};_p._setAnchor=function(bAnchor){this._anchor=bAnchor;this._updateClassName();};_p._setLead=function(bLead){this._lead=bLead;this._updateClassName();};_p.getCreated=function(){var t=this.getGrid();if(!t||!t._gridCreated)return false;this._element=t._getGridElement(this);return this._element!=null;};_p._updateClassName=function(){if(!this.getCreated())return;this._element.firstChild.className=this.getCssClassName();};_p.update=function(){var g=this.getGrid()
if(!this.getCreated()||!g)return;if(BiBrowserCheck.ie)
this._element.outerHTML=this.getHtml();else {var dummy=g._document.createElement("DIV");dummy.innerHTML=this.getHtml();this._element.parentNode.replaceChild(dummy.firstChild,this._element);}
g._clearCache();};_p.scrollIntoView=function(bTopLeft){this.scrollIntoViewY(bTopLeft);};_p.getHeight=function(){return this.getGrid().getRowHeight();};_p.getTop=function(){if(this.getCreated()){var grid=this.getGrid();if(BiBrowserCheck.ie)
{return this._element.getBoundingClientRect().top-grid.getClientTop()+grid.getScrollTop()-grid.getInsetTop();}
else {var sum=0;var p=this._element.parentNode;while(p.nodeType==1)
{sum+=p.scrollTop;p=p.parentNode;}
return grid._document.getBoxObjectFor(this._element).y-sum-grid.getClientTop()+grid.getScrollTop()-grid.getInsetTop();}}};_p.scrollIntoViewY=function(bTop){if(!this.getCreated()){return;}
var p=this.getGrid();if(!p)return;var t=this.getTop();var h=this.getHeight();var st=p.getScrollTop();var ch=p.getClientHeight();var fh=p._getFillerHeight();if(bTop)
p.setScrollTop(t-fh);else if(bTop==false)
p.setScrollTop(t+h-ch);else if(h>ch||t-fh<st)
{p.setScrollTop(t-fh);}
else if(t+h>st+ch)
{p.setScrollTop(t+h-ch);}};_p.matchesString=function(sText){return false;};_p.matchesStringExact=function(sText){return false;};_p.dispose=function()
{if(this._disposed)return;this._grid=null;this._icon=null;};function BiGridColumn(sName){BiObject.call(this);if(sName)this._name=sName;this._header=new this._gridHeaderConstructor(this._name);};var _p=BiGridColumn.prototype=new BiObject;_p._className="BiGridColumn";_p._gridHeaderConstructor=BiGridHeader;_p._name="Untitled";_p._width=200;_p._align="left";_p._indentColumn=false;_p._iconColumn=false;_p._orderIndex= -1;_p._columnIndex= -1;_p._grid=null;_p._sortType="string";BiGridColumn.prototype.getHeader=function(){return this._header;};BiGridColumn.prototype.getGrid=function(){return this._grid;};BiGridColumn.prototype.getIndentColumn=function(){return this._indentColumn;};BiGridColumn.prototype.getIconColumn=function(){return this._iconColumn;};BiGridColumn.prototype.getOrderIndex=function(){return this._orderIndex;};BiGridColumn.prototype.getName=function(){return this._name;};BiGridColumn.prototype.getWidth=function(){return this._width;};BiGridColumn.prototype.getColumnIndex=function(){return this._columnIndex;};_p.getTree=_p.getGrid;_p.setAlign=function(s){this._align=s;this._grid._columnAligns[this._columnIndex]=s;this._header.setAlign(s);};_p.getAlign=function(){return this._align||"left";};_p.setName=function(s){this._name=s;this._grid._columnNames[this._columnIndex]=s;this._header.setText(s);};_p.setWidth=function(n){this._width=n;this._grid._columnWidths[this._columnIndex]=n;};_p.setIndentColumn=function(b){if(this._indentColumn!=b);{this._indentColumn=b;if(b)this._grid.setIndentColumn(this._columnIndex);}};_p.setIconColumn=function(b){if(this._iconColumn!=b);{this._iconColumn=b;if(b)this._grid.setIconColumn(this._columnIndex);}};_p.dispose=function(){if(this._disposed)return;BiObject.prototype.dispose.call(this);this._header.dispose();this._header=null;this._grid=null;};BiGridColumn.prototype.getSortType=function(){return this._sortType;};_p.setSortType=function(sType){this._sortType=sType;};_p.getSortFunction=function(){var f;switch(this._sortType.toLowerCase()){case"string":f=BiGridColumn.stringCompare;break;case"caseinsensitivestring":f=BiGridColumn.caseInsensitiveStringCompare;break;case"number":f=BiGridColumn.numberCompare;break;case"date":f=BiGridColumn.dateCompare;break;default:f=BiGridColumn.lessThanCompare;}
var index=this._columnIndex;return function(r1,r2){return f(r1.getData(index),r2.getData(index));};};BiGridColumn.numberCompare=function(n1,n2){return n1-n2;};BiGridColumn.dateCompare=BiGridColumn.numberCompare;BiGridColumn.lessThanCompare=function(v1,v2){if(v1<v2)
return-1;if(v2<v1)
return 1;return 0;};BiGridColumn.stringCompare=BiGridColumn.lessThanCompare;BiGridColumn.caseInsensitiveStringCompare=function(s1,s2){return BiGridColumn.stringCompare(s1.toLowerCase(),s2.toLowerCase());};function BiTree(){BiAbstractGrid.call(this);this.setCssClassName("bi-tree");this._selectionModel=new BiTreeSelectionModel(this);this._selectionModel.setMultipleSelection(false);this._headers=new this._gridHeadersConstructor;this.addEventListener("mousedown",this._onMouseEvent);this.addEventListener("mouseup",this._onMouseEvent);this.addEventListener("click",this._onMouseEvent);this.addEventListener("dblclick",this._onMouseEvent);this.addEventListener("keydown",this._onKeyDown);this.addEventListener("keypress",this._onKeyPress);this.addEventListener("focus",this._onFocusChange);this.addEventListener("blur",this._onFocusChange);this._selectionModel.addEventListener("change",function(e){this.dispatchEvent(new BiEvent("change"));},this);this.add(this._headers);this._headers.addEventListener("columnwidthschanged",this.updateColumns,this);this._headers.addEventListener("columnorderschanged",function(e){this.setColumnOrders(this._headers.getColumnOrders());this.updateColumns();this.updateData();},this);this._headers.addEventListener("sortcolumnchanged",function(e){this.sort(this._headers.getSortColumn(),this._headers.getAscending());},this);this._headers.addEventListener("ascendingchanged",function(e){this.sort(this._headers.getSortColumn(),this._headers.getAscending());},this);this.addEventListener("scroll",function(e){this._headers.setScrollLeft(this.getScrollLeft());});}
var _p=BiTree.prototype=new BiAbstractGrid;_p._className="BiTree";BiTree.I_ICON=application.getPath()+"images/I.gif";BiTree.L_ICON=application.getPath()+"images/L.gif";BiTree.T_ICON=application.getPath()+"images/T.gif";BiTree.I_PLUS_ICON=application.getPath()+"images/Iplus.gif";BiTree.L_PLUS_ICON=application.getPath()+"images/Lplus.gif";BiTree.T_PLUS_ICON=application.getPath()+"images/Tplus.gif";BiTree.I_MINUS_ICON=application.getPath()+"images/Iminus.gif";BiTree.L_MINUS_ICON=application.getPath()+"images/Lminus.gif";BiTree.T_MINUS_ICON=application.getPath()+"images/Tminus.gif";BiTree.MINUS_ICON=application.getPath()+"images/minus.gif";BiTree.PLUS_ICON=application.getPath()+"images/plus.gif";BiTree.DEFAULT_ICON=application.getPath()+"images/file.gif";BiTree.BLANK_ICON=application.getPath()+"images/blank.gif";new BiImagePreloader(BiTree.I_ICON);new BiImagePreloader(BiTree.L_ICON);new BiImagePreloader(BiTree.T_ICON);new BiImagePreloader(BiTree.I_PLUS_ICON);new BiImagePreloader(BiTree.L_PLUS_ICON);new BiImagePreloader(BiTree.T_PLUS_ICON);new BiImagePreloader(BiTree.I_MINUS_ICON);new BiImagePreloader(BiTree.L_MINUS_ICON);new BiImagePreloader(BiTree.T_MINUS_ICON);new BiImagePreloader(BiTree.MINUS_ICON);new BiImagePreloader(BiTree.PLUS_ICON);new BiImagePreloader(BiTree.DEFAULT_ICON);new BiImagePreloader(BiTree.BLANK_ICON);_p._indentColumn= -1;_p._indentWidth=19;_p._showLines=true;_p._showRootLines=false;_p._showPlusMinus=true;_p._parentNode=null;_p._rowHeight=16;BiTree.prototype.getIndentWidth=function(){return this._indentWidth;};BiTree.prototype.setIndentWidth=function(v){this._indentWidth=v;};BiTree.prototype.getShowPlusMinus=function(){return this._showPlusMinus;};BiTree.prototype.setShowPlusMinus=function(v){this._showPlusMinus=v;};BiTree.prototype.getShowRootLines=function(){return this._showRootLines;};BiTree.prototype.setShowRootLines=function(v){this._showRootLines=v;};_p._layoutHeadersX=function(){this._gridBodyElement.style.width=this._element.clientWidth+"px";this.updateHeadersWidth();};_p._layoutHeadersY=function(){this._gridBodyElement.style.height=this._element.clientHeight+"px";};_p.addNode=function(oChild,oBefore){var p=oChild._parentNode;if(oBefore==null){if(p!=null)
p.removeNode(oChild);this._nodes.push(oChild);}
else{if(oBefore._parentNode!=this)
throw new Error("Can only add components before siblings");if(p!=null)
p.removeNode(oChild);this._nodes.insertBefore(oChild,oBefore);this._rows=this._nodes;}
oChild._parentNode=this;oChild._grid=this;oChild._level=1;this._clearCache();};_p.removeNode=function(oChild){if(oChild._parentNode!=this)
throw new Error("Can only remove children");this._nodes.remove(oChild);this._rows=this._nodes;oChild._parentNode=null;oChild._grid=null;this._clearCache();return oChild;};_p.getGrid=_p.getTree=function(){return this;};_p.getLevel=function(){return-1;};_p.containsNode=function(oDescendant){if(oDescendant==null)return false;if(oDescendant==this)return true;var p=oDescendant._parentNode;return this.containsNode(p);};_p.getFirstNode=function(){return this._nodes[0];};_p.getLastNode=function(){return this._nodes[this._nodes.length-1];};BiTree.prototype.getNodes=function(){return this._nodes;};_p.hasNodes=function(){return this._nodes.length>0;};_p.isLeaf=function(){return!this.hasNodes();};_p.getNextSiblingNode=function(){return null;};_p.getPreviousSiblingNode=function(){return null;};_p.isLastSiblingNode=function(){return true;};_p.getParentNode=function(){return null;};_p.removeAll=function(){this._selectionModel.deselectAll();for(var i=this._nodes.length-1;i>=0;i--){var n=this._nodes[i];this.removeNode(n);n.dispose();}};BiTree.prototype.getIndentColumn=function(){return this._indentColumn;};_p.setIndentColumn=function(n){if(this._columns[this._indentColumn])
this._columns[this._indentColumn]._indentColumn=false;this._indentColumn=n;if(this._columns[this._indentColumn])
this._columns[this._indentColumn]._indentColumn=true;};BiTree.prototype.setShowLines=function(v){this._showLines=v;};_p.getShowLines=function(){return this._showLines&&this._indentColumn>=0&&this._indentColumn<this._columnCount;};_p._getStyleRules=function(){var rs=[];var id=this.getHtmlProperty("id");var align;var widthSum=0;for(var i=0;i<this._columnCount;i++){align=this._columnAligns[i];rs.push({selector:"#"+id+" .col-"+i,style:"width:"+this._columnWidths[i]+"px"+(align!="left"?";text-align:"+align:"")});widthSum+=this._columnWidths[i];}
if(this._indentColumn!= -1&&this._indentColumn<this._columnCount){if(this._showPlusMinus||this._showLines)
rs.push({selector:"#"+id+" .col-"+this._indentColumn,style:"padding-left:0"});var indentColumnLeft=0;var visIndex=this._columns[this._indentColumn].getOrderIndex();for(var i=0;i<this._columnCount;i++){if(this._columns[i].getOrderIndex()<visIndex)
indentColumnLeft+=this._columnWidths[i];}
var accumSelector="#"+id+" .bi-tree-children ";var accumPadding=this._indentWidth+(this._showPlusMinus||this._showLines?0:5);var d=this.getDepth();for(var i=1;i<d;i++){rs.push({selector:accumSelector+".col-"+this._indentColumn,style:"padding-left:"+accumPadding+"px"});if(accumPadding-Math.ceil(this._indentWidth/2)>this._columnWidths[this._indentColumn])
break;rs.push({selector:accumSelector,style:"background-position:"+(accumPadding+indentColumnLeft-this._indentWidth)+"px 0"});accumPadding+=this._indentWidth;accumSelector+=".bi-tree-children ";}}
var val="height:"+this._rowHeight+"px;"+"line-height:"+(this._rowHeight-2)+"px;"+"font-size:"+this._fontSize+"px;";rs.push({selector:"#"+id+" .bi-tree-cell",style:val});rs.push({selector:"#"+id+" .bi-tree-row",style:val});rs.push({selector:"#"+id+" .bi-tree-row",style:"width:"+widthSum+"px;"});return rs;};_p.getDepth=function(){if(this._depth!=null)
return this._depth;var d=0;var cs=this._nodes;var l=cs.length;for(var i=0;i<l;i++)
d=Math.max(d,cs[i].getDepth()+1);return this._depth=d;};_p._findItem=function(oValue,nStartIndex,sType){var i;var items=BiTreeHelper.getPreorderShownNodes(this);if(nStartIndex==null){var si=this.getSelectedNode();nStartIndex=items.indexOf(si);if(nStartIndex== -1)
nStartIndex=0;}
var methodName="matches"+sType;for(i=nStartIndex;i<items.length;i++){if(items[i][methodName](oValue))
return items[i];}
for(i=0;i<nStartIndex;i++){if(items[i][methodName](oValue))
return items[i];}
return null;};_p._getMouseEventInfo=function(e,inEl){var el=inEl||e._event.srcElement||e._event.target;if(el==null)return null;var res={};res.expandIconClicked=el.tagName=="IMG"&&el.className=="bi-tree-expand-icon";var cellRe= /bi-tree-cell/;var cellEl=el;while(cellEl!=null&&!cellRe.test(cellEl.className))
cellEl=cellEl.parentNode;if(cellEl!=null){if(cellRe.test(cellEl.className)){res.cellIndex=Number(cellEl.className.replace(/.*col-(\d+).*/,"$1"));}
el=cellEl;}
else{res.cellIndex= -1;}
while(el!=null&&el.className!="bi-tree-node")
el=el.parentNode;if(el==null)return null;res.treeNode=this._getAllNodes()[el.id];return res;};_p._onMouseEvent=function(e){var info=this._getMouseEventInfo(e);if(info==null||info.treeNode==null)return;var node=info.treeNode;switch(e.getType()){case"mousedown":if(info.expandIconClicked&&node.hasNodes()){node.toggle();if(node.getExpanded())
node._scrollSubtreeIntoView();}
else this._selectionModel.handleMouseDown(node,e);break;case"mouseup":if(!info.expandIconClicked||!node.hasNodes())
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -