//>>built
define("dojox/grid/_Builder","../main dojo/_base/array dojo/_base/lang dojo/_base/window dojo/_base/event dojo/_base/sniff dojo/_base/connect dojo/dnd/Moveable dojox/html/metrics ./util dojo/_base/html dojo/dom-geometry".split(" "),function(w,y,n,p,z,q,D,E,F,u,h,G){var r=w.grid,H=function(a,b){return a&&((a.rows||0)[b]||a.childNodes[b])},A=function(a){for(;a&&"TABLE"!=a.tagName;a=a.parentNode);return a},I=function(a){var b=a.toUpperCase();return function(c){return c.tagName!=b}},B=u.rowIndexTag,v=
u.gridViewTag,t=r._Builder=n.extend(function(a){a&&(this.view=a,this.grid=a.grid)},{view:null,_table:'\x3ctable class\x3d"dojoxGridRowTable" border\x3d"0" cellspacing\x3d"0" cellpadding\x3d"0" role\x3d"presentation"',getTableArray:function(){var a=[this._table];this.view.viewWidth&&a.push([' style\x3d"width:',this.view.viewWidth,';"'].join(""));a.push("\x3e");return a},generateCellMarkup:function(a,b,c,d){var f=[];if(d){var e=a.index!=a.grid.getSortIndex()?"":0<a.grid.sortInfo?'aria-sort\x3d"ascending"':
'aria-sort\x3d"descending"';a.id||(a.id=this.grid.id+"Hdr"+a.index);e=['\x3cth tabIndex\x3d"-1" aria-readonly\x3d"true" role\x3d"columnheader"',e,' id\x3d"',a.id,'"']}else e=['\x3ctd tabIndex\x3d"-1" role\x3d"gridcell"',this.grid.editable&&!a.editable?'aria-readonly\x3d"true"':""];a.colSpan&&e.push(' colspan\x3d"',a.colSpan,'"');a.rowSpan&&e.push(' rowspan\x3d"',a.rowSpan,'"');e.push(' class\x3d"dojoxGridCell ');a.classes&&e.push(a.classes," ");c&&e.push(c," ");f.push(e.join(""));f.push("");e=['" idx\x3d"',
a.index,'" style\x3d"'];b&&";"!=b[b.length-1]&&(b+=";");e.push(a.styles,b||"",a.hidden?"display:none;":"");a.unitWidth&&e.push("width:",a.unitWidth,";");f.push(e.join(""));f.push("");e=['"'];a.attrs&&e.push(" ",a.attrs);e.push("\x3e");f.push(e.join(""));f.push("");f.push(d?"\x3c/th\x3e":"\x3c/td\x3e");return f},isCellNode:function(a){return!(!a||a==p.doc||!h.attr(a,"idx"))},getCellNodeIndex:function(a){return a?Number(h.attr(a,"idx")):-1},getCellNode:function(a,b){for(var c=0,d;(d=H(a.firstChild,
c))&&d.cells;c++)for(var f=0,e;e=d.cells[f];f++)if(this.getCellNodeIndex(e)==b)return e;return null},findCellTarget:function(a,b){for(var c=a;c&&(!this.isCellNode(c)||c.offsetParent&&v in c.offsetParent.parentNode&&c.offsetParent.parentNode[v]!=this.view.id)&&c!=b;)c=c.parentNode;return c!=b?c:null},baseDecorateEvent:function(a){a.dispatch="do"+a.type;a.grid=this.grid;a.sourceView=this.view;a.cellNode=this.findCellTarget(a.target,a.rowNode);a.cellIndex=this.getCellNodeIndex(a.cellNode);a.cell=0<=
a.cellIndex?this.grid.getCell(a.cellIndex):null},findTarget:function(a,b){for(var c=a;c&&c!=this.domNode&&(!(b in c)||v in c&&c[v]!=this.view.id);)c=c.parentNode;return c!=this.domNode?c:null},findRowTarget:function(a){return this.findTarget(a,B)},isIntraNodeEvent:function(a){try{return a.cellNode&&a.relatedTarget&&h.isDescendant(a.relatedTarget,a.cellNode)}catch(b){return!1}},isIntraRowEvent:function(a){try{var b=a.relatedTarget&&this.findRowTarget(a.relatedTarget);return!b&&-1==a.rowIndex||b&&a.rowIndex==
b.gridRowIndex}catch(c){return!1}},dispatchEvent:function(a){return a.dispatch in this?this[a.dispatch](a):!1},domouseover:function(a){a.cellNode&&a.cellNode!=this.lastOverCellNode&&(this.lastOverCellNode=a.cellNode,this.grid.onMouseOver(a));this.grid.onMouseOverRow(a)},domouseout:function(a){if(a.cellNode&&a.cellNode==this.lastOverCellNode&&!this.isIntraNodeEvent(a,this.lastOverCellNode)&&(this.lastOverCellNode=null,this.grid.onMouseOut(a),!this.isIntraRowEvent(a)))this.grid.onMouseOutRow(a)},domousedown:function(a){if(a.cellNode)this.grid.onMouseDown(a);
this.grid.onMouseDownRow(a)},_getTextDirStyle:function(a,b,c){return""}});w=r._ContentBuilder=n.extend(function(a){t.call(this,a)},t.prototype,{update:function(){this.prepareHtml()},prepareHtml:function(){for(var a=this.grid.get,b=this.view.structure.cells,c=0,d;d=b[c];c++)for(var f=0,e;e=d[f];f++)e.get=e.get||void 0==e.value&&a,e.markup=this.generateCellMarkup(e,e.cellStyles,e.cellClasses,!1),!this.grid.editable&&e.editable&&(this.grid.editable=!0)},generateHtml:function(a,b){var c=this.getTableArray(),
d=this.view.structure.cells,f=this.grid.getItem(b);u.fire(this.view,"onBeforeRow",[b,d]);for(var e=0,k;k=d[e];e++)if(!k.hidden&&!k.header){c.push(k.invisible?'\x3ctr class\x3d"dojoxGridInvisible"\x3e':"\x3ctr\x3e");for(var m=0,g,l,C;g=k[m];m++){l=g.markup;var x=g.customClasses=[];C=g.customStyles=[];l[5]=g.format(b,f);l[1]=x.join(" ");l[3]=C.join(";");(x=g.textDir||this.grid.textDir)&&(l[3]+=this._getTextDirStyle(x,g,b));c.push.apply(c,l)}c.push("\x3c/tr\x3e")}c.push("\x3c/table\x3e");return c.join("")},
decorateEvent:function(a){a.rowNode=this.findRowTarget(a.target);if(!a.rowNode)return!1;a.rowIndex=a.rowNode[B];this.baseDecorateEvent(a);a.cell=this.grid.getCell(a.cellIndex);return!0}});var J=r._HeaderBuilder=n.extend(function(a){this.moveable=null;t.call(this,a)},t.prototype,{_skipBogusClicks:!1,overResizeWidth:4,minColWidth:1,update:function(){this.tableMap?this.tableMap.mapRows(this.view.structure.cells):this.tableMap=new r._TableMap(this.view.structure.cells)},generateHtml:function(a,b){var c,
d=this.getTableArray(),f=this.view.structure.cells;u.fire(this.view,"onBeforeRow",[-1,f]);for(var e=0,k;k=f[e];e++)if(!k.hidden){d.push(k.invisible?'\x3ctr class\x3d"dojoxGridInvisible"\x3e':"\x3ctr\x3e");for(var m=0,g,l;g=k[m];m++)g.customClasses=[],g.customStyles=[],this.view.simpleStructure&&(g.draggable&&(g.headerClasses?-1==g.headerClasses.indexOf("dojoDndItem")&&(g.headerClasses+=" dojoDndItem"):g.headerClasses="dojoDndItem"),g.attrs?-1==g.attrs.indexOf("dndType\x3d'gridColumn_")&&(g.attrs+=
" dndType\x3d'gridColumn_"+this.grid.id+"'"):g.attrs="dndType\x3d'gridColumn_"+this.grid.id+"'"),l=this.generateCellMarkup(g,g.headerStyles,g.headerClasses,!0),l[5]=void 0!=b?b:a(g),l[3]=g.customStyles.join(";"),(c=g.textDir||this.grid.textDir)&&(l[3]+=this._getTextDirStyle(c,g,b)),l[1]=g.customClasses.join(" "),d.push(l.join(""));d.push("\x3c/tr\x3e")}d.push("\x3c/table\x3e");return d.join("")},getCellX:function(a){var b=I("th");for(var c=a.target;c&&b(c);c=c.parentNode);(b=c)?(b=G.position(b),a=
a.clientX-b.x):a=a.layerX;return a},decorateEvent:function(a){this.baseDecorateEvent(a);a.rowIndex=-1;a.cellX=this.getCellX(a);return!0},prepareResize:function(a,b){do{var c=a.cellIndex;a.cellNode=c?a.cellNode.parentNode.cells[c+b]:null;a.cellIndex=a.cellNode?this.getCellNodeIndex(a.cellNode):-1}while(a.cellNode&&"none"==a.cellNode.style.display);return!!a.cellNode},canResize:function(a){if(!a.cellNode||1<a.cellNode.colSpan)return!1;a=this.grid.getCell(a.cellIndex);return!a.noresize&&a.canResize()},
overLeftResizeArea:function(a){if(h.hasClass(p.body(),"dojoDndMove"))return!1;if(q("ie")){var b=a.target;if(h.hasClass(b,"dojoxGridArrowButtonNode")||h.hasClass(b,"dojoxGridArrowButtonChar")||h.hasClass(b,"dojoxGridColCaption"))return!1}return this.grid.isLeftToRight()?0<a.cellIndex&&0<a.cellX&&a.cellX<this.overResizeWidth&&this.prepareResize(a,-1):a.cellNode&&0<a.cellX&&a.cellX<this.overResizeWidth},overRightResizeArea:function(a){if(h.hasClass(p.body(),"dojoDndMove"))return!1;if(q("ie")){var b=
a.target;if(h.hasClass(b,"dojoxGridArrowButtonNode")||h.hasClass(b,"dojoxGridArrowButtonChar")||h.hasClass(b,"dojoxGridColCaption"))return!1}return this.grid.isLeftToRight()?a.cellNode&&a.cellX>=a.cellNode.offsetWidth-this.overResizeWidth:0<a.cellIndex&&a.cellX>=a.cellNode.offsetWidth-this.overResizeWidth&&this.prepareResize(a,-1)},domousemove:function(a){if(!this.moveable){var b=this.overRightResizeArea(a)?"dojoxGridColResize":this.overLeftResizeArea(a)?"dojoxGridColResize":"";b&&!this.canResize(a)&&
(b="dojoxGridColNoResize");h.toggleClass(a.sourceView.headerNode,"dojoxGridColNoResize","dojoxGridColNoResize"==b);h.toggleClass(a.sourceView.headerNode,"dojoxGridColResize","dojoxGridColResize"==b);b&&z.stop(a)}},domousedown:function(a){this.moveable||((this.overRightResizeArea(a)||this.overLeftResizeArea(a))&&this.canResize(a)?this.beginColumnResize(a):(this.grid.onMouseDown(a),this.grid.onMouseOverRow(a)))},doclick:function(a){return this._skipBogusClicks?(z.stop(a),!0):!1},colResizeSetup:function(a,
b){var c=h.contentBox(a.sourceView.headerNode);if(b){this.lineDiv=document.createElement("div");var d=h.position(a.sourceView.headerNode,!0),f=h.contentBox(a.sourceView.domNode),e=a.pageX;!this.grid.isLeftToRight()&&8>q("ie")&&(e-=F.getScrollbar().w);h.style(this.lineDiv,{top:d.y+"px",left:e+"px",height:f.h+c.h+"px"});h.addClass(this.lineDiv,"dojoxGridResizeColLine");this.lineDiv._origLeft=e;p.body().appendChild(this.lineDiv)}d=[];f=this.tableMap.findOverlappingNodes(a.cellNode);e=0;for(var k;k=f[e];e++)d.push({node:k,
index:this.getCellNodeIndex(k),width:k.offsetWidth});f=a.sourceView;k=this.grid.isLeftToRight()?1:-1;var m=a.grid.views.views;e=[];for(var g=f.idx+k,l;l=m[g];g+=k)e.push({node:l.headerNode,left:window.parseInt(l.headerNode.style.left)});k=f.headerContentNode.firstChild;return{scrollLeft:a.sourceView.headerNode.scrollLeft,view:f,node:a.cellNode,index:a.cellIndex,w:h.contentBox(a.cellNode).w,vw:c.w,table:k,tw:h.contentBox(k).w,spanners:d,followers:e}},beginColumnResize:function(a){this.moverDiv=document.createElement("div");
h.style(this.moverDiv,{position:"absolute",left:0});p.body().appendChild(this.moverDiv);h.addClass(this.grid.domNode,"dojoxGridColumnResizing");var b=this.moveable=new E(this.moverDiv),c=this.colResizeSetup(a,!0);b.onMove=n.hitch(this,"doResizeColumn",c);D.connect(b,"onMoveStop",n.hitch(this,function(){this.endResizeColumn(c);c.node.releaseCapture&&c.node.releaseCapture();this.moveable.destroy();delete this.moveable;this.moveable=null;h.removeClass(this.grid.domNode,"dojoxGridColumnResizing")}));
a.cellNode.setCapture&&a.cellNode.setCapture();b.onMouseDown(a)},doResizeColumn:function(a,b,c){var d=c.l;d={deltaX:d,w:a.w+(this.grid.isLeftToRight()?d:-d),vw:a.vw+d,tw:a.tw+d};this.dragRecord={inDrag:a,mover:b,leftTop:c};d.w>=this.minColWidth&&(b?h.style(this.lineDiv,"left",this.lineDiv._origLeft+d.deltaX+"px"):this.doResizeNow(a,d))},endResizeColumn:function(a){if(this.dragRecord){var b=this.dragRecord.leftTop;b=this.grid.isLeftToRight()?b.l:-b.l;b+=Math.max(a.w+b,this.minColWidth)-(a.w+b);q("webkit")&&
a.spanners.length&&(b+=h._getPadBorderExtents(a.spanners[0].node).w);this.doResizeNow(a,{deltaX:b,w:a.w+b,vw:a.vw+b,tw:a.tw+b});delete this.dragRecord}h.destroy(this.lineDiv);h.destroy(this.moverDiv);h.destroy(this.moverDiv);delete this.moverDiv;this._skipBogusClicks=!0;a.view.update();this._skipBogusClicks=!1;this.grid.onResizeColumn(a.index)},doResizeNow:function(a,b){a.view.convertColPctToFixed();if(a.view.flexCells&&!a.view.testFlexCells()){var c=A(a.node);c&&(c.style.width="")}var d;for(c=0;d=
a.spanners[c];c++){var f=d.width+b.deltaX;0<f&&(d.node.style.width=f+"px",a.view.setColWidth(d.index,f))}if(this.grid.isLeftToRight()||!q("ie"))for(c=0;d=a.followers[c];c++)f=d.left+b.deltaX,d.node.style.left=f+"px";a.node.style.width=b.w+"px";a.view.setColWidth(a.index,b.w);a.view.headerNode.style.width=b.vw+"px";a.view.setColumnsWidth(b.tw);this.grid.isLeftToRight()||(a.view.headerNode.scrollLeft=a.scrollLeft+b.deltaX)}});r._TableMap=n.extend(function(a){this.mapRows(a)},{map:null,mapRows:function(a){if(a.length){this.map=
[];for(var b,c=0;b=a[c];c++)this.map[c]=[];for(c=0;b=a[c];c++)for(var d=0,f=0,e,k;e=b[d];d++){for(;this.map[c][f];)f++;this.map[c][f]={c:d,r:c};k=e.rowSpan||1;e=e.colSpan||1;for(var m=0;m<k;m++)for(var g=0;g<e;g++)this.map[c+m][f+g]=this.map[c][f];f+=e}}},dumpMap:function(){for(var a=0,b;b=this.map[a];a++)for(var c=0;b[c];c++);},getMapCoords:function(a,b){for(var c=0,d;d=this.map[c];c++)for(var f=0,e;e=d[f];f++)if(e.c==b&&e.r==a)return{j:c,i:f};return{j:-1,i:-1}},getNode:function(a,b,c){return(a=
a&&a.rows[b])&&a.cells[c]},_findOverlappingNodes:function(a,b,c){var d=[];b=this.getMapCoords(b,c);c=0;for(var f;f=this.map[c];c++)c!=b.j&&(f=(f=f[b.i])?this.getNode(a,f.r,f.c):null)&&d.push(f);return d},findOverlappingNodes:function(a){var b=this._findOverlappingNodes,c=A(a);var d=a.parentNode;d=0<=d.rowIndex?d.rowIndex:y.indexOf(d.parentNode.childNodes,d);return b.call(this,c,d,0<=a.cellIndex?a.cellIndex:y.indexOf(a.parentNode.cells,a))}});return{_Builder:t,_HeaderBuilder:J,_ContentBuilder:w}});