//>>built
define("dgrid/extensions/ColumnResizer","dojo/_base/declare dojo/_base/array dojo/on dojo/query dojo/_base/lang dojo/dom dojo/dom-construct dojo/dom-geometry dojo/has ../util/misc dojo/_base/html".split(" "),function(C,D,v,r,y,z,n,E,w,m){function A(a,b,c,d,g){for(var e=1;e<b;e++)a[c+e][d]=g}function B(a){for(var b=a.length,c=b,d=D.filter(a[0],function(a){return!a.hidden}).length,g=Array(b);b--;)g[b]=Array(d);for(var e={},b=0;b<c;b++)for(var f=g[b],k=a[b],p=0,m=0;p<d;p++){var l=k[m],h;if("undefined"===
typeof f[p]){f[p]=l.id;l.rowSpan&&1<l.rowSpan&&A(g,l.rowSpan,b,p,l.id);if(0<b&&l.colSpan&&1<l.colSpan)for(h=1;h<l.colSpan;h++)f[++p]=l.id,l.rowSpan&&1<l.rowSpan&&A(g,l.rowSpan,b,p,l.id);e[l.id]=a[0][p].id;m++}}return e}function t(a,b,c,d,g){if(!(0>=c)){var e=a.columns[b],f;if(e&&(f={grid:a,columnId:b,width:c,bubbles:!0,cancelable:!0},d&&(f.parentType=d),!a._resizedColumns||v.emit(a.headerNode,"dgrid-columnresize",f)))return"auto"===c?delete e.width:(e.width=c,c+="px"),(d=a._columnSizes[b])?d.set("width",
c):d=m.addCssRule("#"+m.escapeCssIdentifier(a.domNode.id)+" .dgrid-column-"+m.escapeCssIdentifier(b,"-"),"width: "+c+";"),a._columnSizes[b]=d,!1!==g&&a.resize(),!0}}var h,q,x=0,u={create:function(){h=n.create("div",{className:"dgrid-column-resizer"});q=n.create("div",{className:"dgrid-resize-guard"})},destroy:function(){n.destroy(h);n.destroy(q);h=q=null},show:function(a){var b=E.position(a.domNode,!0);h.style.top=b.y+"px";h.style.height=b.h+"px";document.body.appendChild(h);a.domNode.appendChild(q)},
move:function(a){h.style.left=a+"px"},hide:function(){h.parentNode.removeChild(h);q.parentNode.removeChild(q)}};return C(null,{resizeNode:null,minWidth:40,adjustLastColumn:!0,_resizedColumns:!1,buildRendering:function(){this.inherited(arguments);x||u.create();x++},destroy:function(){this.inherited(arguments);for(var a in this._columnSizes)this._columnSizes[a].remove();--x||u.destroy()},resizeColumnWidth:function(a,b){return t(this,a,b)},configStructure:function(){var a=this._oldColumnSizes=y.mixin({},
this._columnSizes),b;this._resizedColumns=!1;this._columnSizes={};this.inherited(arguments);for(b in a)b in this._columnSizes||a[b].remove();delete this._oldColumnSizes},_configColumn:function(a){this.inherited(arguments);var b=a.id,c;"width"in a&&((c=this._oldColumnSizes[b])?c.set("width",a.width+"px"):c=m.addCssRule("#"+m.escapeCssIdentifier(this.domNode.id)+" .dgrid-column-"+m.escapeCssIdentifier(b,"-"),"width: "+a.width+"px;"),this._columnSizes[b]=c)},renderHeader:function(){this.inherited(arguments);
var a=this,b;if(this.columnSets&&this.columnSets.length)for(var c=this.columnSets.length;c--;)b=y.mixin(b||{},B(this.columnSets[c]));else this.subRows&&1<this.subRows.length&&(b=B(this.subRows));for(var c=r(".dgrid-cell",a.headerNode),d=c.length;d--;){var g=c[d],e=g.columnId,f=a.columns[e],k=g.childNodes;if(f&&!1!==f.resizable){f=n.create("div",{className:"dgrid-resize-header-container"});for(g.contents=f;0<k.length;)f.appendChild(k[0]);k=n.create("div",{className:"dgrid-resize-handle resizeNode-"+
m.escapeCssIdentifier(e,"-")},f);g.appendChild(f);k.columnId=b&&b[e]||e}}a.mouseMoveListen||(v(a.headerNode,".dgrid-resize-handle:mousedown"+(w("touch")?",.dgrid-resize-handle:touchstart":""),function(b){a._resizeMouseDown(b,this);a.mouseMoveListen.resume();a.mouseUpListen.resume()}),a._listeners.push(a.mouseMoveListen=v.pausable(document,"mousemove"+(w("touch")?",touchmove":""),m.throttleDelayed(function(b){a._updateResizerPosition(b)}))),a._listeners.push(a.mouseUpListen=v.pausable(document,"mouseup"+
(w("touch")?",touchend":""),function(b){a._resizeMouseUp(b);a.mouseMoveListen.pause();a.mouseUpListen.pause()})),a.mouseMoveListen.pause(),a.mouseUpListen.pause())},_resizeMouseDown:function(a,b){a.preventDefault();z.setSelectable(this.domNode,!1);this._startX=this._getResizeMouseLocation(a);this._targetCell=r(".dgrid-column-"+m.escapeCssIdentifier(b.columnId,"-"),this.headerNode)[0];this._updateResizerPosition(a);u.show(this)},_resizeMouseUp:function(a){var b=this._columnSizes,c,d,g;this.adjustLastColumn&&
(g=this.headerNode.clientWidth-1);this._resizedColumns||(c=r(".dgrid-cell",this.headerNode),this.columnSets&&this.columnSets.length?c=c.filter(function(a){return"0"===a.columnId.split("-")[0]&&!(a.columnId in b)}):this.subRows&&1<this.subRows.length&&(c=c.filter(function(a){return"0"===a.columnId.charAt(0)&&!(a.columnId in b)})),d=c.map(function(a){return a.offsetWidth}),c.forEach(function(a,b){t(this,a.columnId,d[b],null,!1)},this),this._resizedColumns=!0);z.setSelectable(this.domNode,!0);c=this._targetCell;
var e=this._getResizeMouseLocation(a)-this._startX,f=c.offsetWidth+e,k=this._getResizedColumnWidths(),h=k.totalWidth,k=k.lastColId,n=r(".dgrid-column-"+m.escapeCssIdentifier(k,"-"),this.headerNode)[0].offsetWidth;f<this.minWidth&&(f=this.minWidth);t(this,c.columnId,f,a.type)&&c.columnId!==k&&this.adjustLastColumn&&(h+e<g?t(this,k,"auto",a.type):n-e<=this.minWidth&&t(this,k,this.minWidth,a.type));u.hide();delete this._startX;delete this._targetCell},_updateResizerPosition:function(a){if(this._targetCell){a=
this._getResizeMouseLocation(a);var b=this._targetCell.offsetWidth,c=a;b+(a-this._startX)<this.minWidth&&(c=this._startX-(b-this.minWidth));u.move(c)}},_getResizeMouseLocation:function(a){var b=0;a.pageX?b=a.pageX:a.clientX&&(b=a.clientX+document.body.scrollLeft+document.documentElement.scrollLeft);return b},_getResizedColumnWidths:function(){var a=0,b=r((this.columnSets?".dgrid-column-set-cell ":"")+"tr:first-child .dgrid-cell",this.headerNode),c=b.length;if(!c)return{};for(var d=b[c-1].columnId;c--;)a+=
b[c].offsetWidth;return{totalWidth:a,lastColId:d}}})});
//# sourceMappingURL=ColumnResizer.js.map