//>>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(x,y,n,q,z,r,C,D,E,v,g,F){var t=x.grid,G=function(a){return 0<=a.rowIndex?a.rowIndex:y.indexOf(a.parentNode.childNodes,a)},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(a){return a.tagName!=b}},B=v.rowIndexTag,w=v.gridViewTag,u=t._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,f){var e=[],d;f?(d=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),d=['\x3cth tabIndex\x3d"-1" aria-readonly\x3d"true" role\x3d"columnheader"',d,' id\x3d"',a.id,'"']):d=['\x3ctd tabIndex\x3d"-1" role\x3d"gridcell"',this.grid.editable&&!a.editable?'aria-readonly\x3d"true"':""];a.colSpan&&d.push(' colspan\x3d"',a.colSpan,'"');a.rowSpan&&d.push(' rowspan\x3d"',a.rowSpan,'"');d.push(' class\x3d"dojoxGridCell ');a.classes&&d.push(a.classes,
" ");c&&d.push(c," ");e.push(d.join(""));e.push("");d=['" idx\x3d"',a.index,'" style\x3d"'];b&&";"!=b[b.length-1]&&(b+=";");d.push(a.styles,b||"",a.hidden?"display:none;":"");a.unitWidth&&d.push("width:",a.unitWidth,";");e.push(d.join(""));e.push("");d=['"'];a.attrs&&d.push(" ",a.attrs);d.push("\x3e");e.push(d.join(""));e.push("");e.push(f?"\x3c/th\x3e":"\x3c/td\x3e");return e},isCellNode:function(a){return!(!a||a==q.doc||!g.attr(a,"idx"))},getCellNodeIndex:function(a){return a?Number(g.attr(a,"idx")):
-1},getCellNode:function(a,b){for(var c=0,f;(f=H(a.firstChild,c))&&f.cells;c++)for(var e=0,d;d=f.cells[e];e++)if(this.getCellNodeIndex(d)==b)return d;return null},findCellTarget:function(a,b){for(var c=a;c&&(!this.isCellNode(c)||c.offsetParent&&w in c.offsetParent.parentNode&&c.offsetParent.parentNode[w]!=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)||w in c&&c[w]!=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&&g.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""}});x=t._ContentBuilder=n.extend(function(a){u.call(this,a)},u.prototype,{update:function(){this.prepareHtml()},prepareHtml:function(){for(var a=this.grid.get,b=this.view.structure.cells,c=0,f;f=b[c];c++)for(var e=0,d;d=f[e];e++)d.get=d.get||void 0==d.value&&a,d.markup=this.generateCellMarkup(d,d.cellStyles,d.cellClasses,!1),!this.grid.editable&&d.editable&&(this.grid.editable=
!0)},generateHtml:function(a,b){var c=this.getTableArray(),f,e=this.view.structure.cells,d=this.grid.getItem(b);v.fire(this.view,"onBeforeRow",[b,e]);for(var g=0,l;l=e[g];g++)if(!l.hidden&&!l.header){c.push(l.invisible?'\x3ctr class\x3d"dojoxGridInvisible"\x3e':"\x3ctr\x3e");for(var h=0,k,p,n;k=l[h];h++)p=k.markup,f=k.customClasses=[],n=k.customStyles=[],p[5]=k.format(b,d),p[1]=f.join(" "),p[3]=n.join(";"),(f=k.textDir||this.grid.textDir)&&(p[3]+=this._getTextDirStyle(f,k,b)),c.push.apply(c,p);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=t._HeaderBuilder=n.extend(function(a){this.moveable=null;u.call(this,a)},u.prototype,{_skipBogusClicks:!1,overResizeWidth:4,minColWidth:1,update:function(){this.tableMap?this.tableMap.mapRows(this.view.structure.cells):this.tableMap=new t._TableMap(this.view.structure.cells)},generateHtml:function(a,
b){var c,f=this.getTableArray(),e=this.view.structure.cells;v.fire(this.view,"onBeforeRow",[-1,e]);for(var d=0,g;g=e[d];d++)if(!g.hidden){f.push(g.invisible?'\x3ctr class\x3d"dojoxGridInvisible"\x3e':"\x3ctr\x3e");for(var l=0,h,k;h=g[l];l++)h.customClasses=[],h.customStyles=[],this.view.simpleStructure&&(h.draggable&&(h.headerClasses?-1==h.headerClasses.indexOf("dojoDndItem")&&(h.headerClasses+=" dojoDndItem"):h.headerClasses="dojoDndItem"),h.attrs?-1==h.attrs.indexOf("dndType\x3d'gridColumn_")&&
(h.attrs+=" dndType\x3d'gridColumn_"+this.grid.id+"'"):h.attrs="dndType\x3d'gridColumn_"+this.grid.id+"'"),k=this.generateCellMarkup(h,h.headerStyles,h.headerClasses,!0),k[5]=void 0!=b?b:a(h),k[3]=h.customStyles.join(";"),(c=h.textDir||this.grid.textDir)&&(k[3]+=this._getTextDirStyle(c,h,b)),k[1]=h.customClasses.join(" "),f.push(k.join(""));f.push("\x3c/tr\x3e")}f.push("\x3c/table\x3e");return f.join("")},getCellX:function(a){var b;b=I("th");for(var c=a.target;c&&b(c);c=c.parentNode);(b=c)?(b=F.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(g.hasClass(q.body(),"dojoDndMove"))return!1;if(r("ie")){var b=a.target;if(g.hasClass(b,"dojoxGridArrowButtonNode")||g.hasClass(b,"dojoxGridArrowButtonChar")||g.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(g.hasClass(q.body(),"dojoDndMove"))return!1;if(r("ie")){var b=
a.target;if(g.hasClass(b,"dojoxGridArrowButtonNode")||g.hasClass(b,"dojoxGridArrowButtonChar")||g.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");g.toggleClass(a.sourceView.headerNode,"dojoxGridColNoResize","dojoxGridColNoResize"==b);g.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=g.contentBox(a.sourceView.headerNode);if(b){this.lineDiv=document.createElement("div");var f=g.position(a.sourceView.headerNode,!0),e=g.contentBox(a.sourceView.domNode),d=a.pageX;!this.grid.isLeftToRight()&&8>r("ie")&&(d-=E.getScrollbar().w);g.style(this.lineDiv,{top:f.y+"px",left:d+"px",height:e.h+c.h+"px"});g.addClass(this.lineDiv,"dojoxGridResizeColLine");this.lineDiv._origLeft=d;q.body().appendChild(this.lineDiv)}for(var f=[],e=this.tableMap.findOverlappingNodes(a.cellNode),d=0,m;m=e[d];d++)f.push({node:m,
index:this.getCellNodeIndex(m),width:m.offsetWidth});e=a.sourceView;m=this.grid.isLeftToRight()?1:-1;for(var l=a.grid.views.views,d=[],h=e.idx+m,k;k=l[h];h+=m)d.push({node:k.headerNode,left:window.parseInt(k.headerNode.style.left)});m=e.headerContentNode.firstChild;return{scrollLeft:a.sourceView.headerNode.scrollLeft,view:e,node:a.cellNode,index:a.cellIndex,w:g.contentBox(a.cellNode).w,vw:c.w,table:m,tw:g.contentBox(m).w,spanners:f,followers:d}},beginColumnResize:function(a){this.moverDiv=document.createElement("div");
g.style(this.moverDiv,{position:"absolute",left:0});q.body().appendChild(this.moverDiv);g.addClass(this.grid.domNode,"dojoxGridColumnResizing");var b=this.moveable=new D(this.moverDiv),c=this.colResizeSetup(a,!0);b.onMove=n.hitch(this,"doResizeColumn",c);C.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;g.removeClass(this.grid.domNode,"dojoxGridColumnResizing")}));
a.cellNode.setCapture&&a.cellNode.setCapture();b.onMouseDown(a)},doResizeColumn:function(a,b,c){var f=c.l,f={deltaX:f,w:a.w+(this.grid.isLeftToRight()?f:-f),vw:a.vw+f,tw:a.tw+f};this.dragRecord={inDrag:a,mover:b,leftTop:c};f.w>=this.minColWidth&&(b?g.style(this.lineDiv,"left",this.lineDiv._origLeft+f.deltaX+"px"):this.doResizeNow(a,f))},endResizeColumn:function(a){if(this.dragRecord){var b=this.dragRecord.leftTop,b=this.grid.isLeftToRight()?b.l:-b.l,b=b+(Math.max(a.w+b,this.minColWidth)-(a.w+b));
r("webkit")&&a.spanners.length&&(b+=g._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}g.destroy(this.lineDiv);g.destroy(this.moverDiv);g.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="")}for(var f,
e,c=0;f=a.spanners[c];c++)e=f.width+b.deltaX,0<e&&(f.node.style.width=e+"px",a.view.setColWidth(f.index,e));if(this.grid.isLeftToRight()||!r("ie"))for(c=0;f=a.followers[c];c++)e=f.left+b.deltaX,f.node.style.left=e+"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)}});t._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 f=0,e=0,d,g;d=b[f];f++){for(;this.map[c][e];)e++;this.map[c][e]={c:f,r:c};g=d.rowSpan||1;d=d.colSpan||1;for(var l=0;l<g;l++)for(var h=0;h<d;h++)this.map[c+l][e+h]=this.map[c][e];e+=d}}},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,f;f=this.map[c];c++)for(var e=0,d;d=f[e];e++)if(d.c==b&&d.r==a)return{j:c,i:e};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 f=[];b=this.getMapCoords(b,c);c=0;for(var e;e=this.map[c];c++)c!=b.j&&(e=(e=e[b.i])?this.getNode(a,e.r,e.c):null)&&f.push(e);return f},findOverlappingNodes:function(a){return this._findOverlappingNodes(A(a),G(a.parentNode),0<=a.cellIndex?a.cellIndex:y.indexOf(a.parentNode.cells,a))}});return{_Builder:u,_HeaderBuilder:J,_ContentBuilder:x}});