//>>built
define("dgrid/extensions/ColumnHider",["dojo/_base/declare","dojo/has","dojo/on","put-selector/put","xstyle/css!../css/extensions/ColumnHider.css"],function(_1,_2,_3,_4){var _5,_6,_7=_2("ie"),_8=_7&&_2("quirks"),_9=_7<8||_8?"htmlFor":"for";function _a(cb,_b){return cb.id.substr(_b.id.length+18);};return _1("dgrid.extensions.ColumnHider",null,{hiderMenuNode:null,hiderToggleNode:null,_hiderMenuOpened:false,_columnHiderRules:null,_columnHiderCheckboxes:null,_renderHiderMenuEntries:function(){var _c=this.subRows,_d,_e,sr,c;for(sr=0,_d=_c.length;sr<_d;sr++){for(c=0,_e=_c[sr].length;c<_e;c++){this._renderHiderMenuEntry(_c[sr][c]);}}},_renderHiderMenuEntry:function(_f){var id=_f.id,div,_10,_11;if(_f.hidden){this._columnHiderRules[id]=this.styleColumn(id,"display: none");}if(_f.unhidable){return;}div=_4("div.dgrid-hider-menu-row");_10=this.domNode.id+"-hider-menu-check-"+id;this._columnHiderCheckboxes[id]=_11=_4(div,"input#"+_10+".dgrid-hider-menu-check.hider-menu-check-"+id+"[type=checkbox]");_4(div,"label.dgrid-hider-menu-label.hider-menu-label"+id+"["+_9+"="+_10+"]",_f.label||_f.field||"");_4(this.hiderMenuNode,div);if(!_f.hidden){_11.checked=true;}},renderHeader:function(){var _12=this,_13=this.hiderMenuNode,_14=this.hiderToggleNode,id;this.inherited(arguments);if(!_13){_14=this.hiderToggleNode=_4(this.headerScrollNode,"div.dgrid-hider-toggle.dgrid-cell-padding","+");this._listeners.push(_3(_14,"click",function(e){_12._toggleColumnHiderMenu(e);}));_13=this.hiderMenuNode=_4("div#dgrid-hider-menu-"+this.id+".dgrid-hider-menu");_13.style.display="none";_4(this.domNode,_13);this._listeners.push(_3(_13,".dgrid-hider-menu-check:"+(_7<9||_8?"click":"change"),function(e){_12._updateColumnHiddenState(_a(e.target,_12),!e.target.checked);}));this._listeners.push(_3(_13,"mousedown",function(e){e.stopPropagation();}));if(!_6){_6=_3.pausable(document,"mousedown",function(e){_5&&_5._toggleColumnHiderMenu(e);});_6.pause();}}else{for(id in this._columnHiderRules){this._columnHiderRules[id].remove();}_13.innerHTML="";}this._columnHiderCheckboxes={};this._columnHiderRules={};this._renderHiderMenuEntries();},isColumnHidden:function(id){return !!this._columnHiderRules[id];},_toggleColumnHiderMenu:function(){var _15=this._hiderMenuOpened,_16=this.hiderMenuNode,_17=this.domNode;_16.style.display=(_15?"none":"");if(_15){_16.style.height="";}else{if(_16.offsetHeight>_17.offsetHeight-12){_16.style.height=(_17.offsetHeight-12)+"px";}}_6[_15?"pause":"resume"]();_5=_15?null:this;this._hiderMenuOpened=!_15;},_updateColumnHiddenState:function(id,_18){if(!_18){this._columnHiderRules[id].remove();delete this._columnHiderRules[id];}else{this._columnHiderRules[id]=this.styleColumn(id,"display: none;");}_3.emit(this.domNode,"dgrid-columnstatechange",{grid:this,column:this.columns[id],hidden:_18,bubbles:true});this.resize();},toggleColumnHiddenState:function(id,_19){if(typeof _19==="undefined"){_19=!this._columnHiderRules[id];}this._updateColumnHiddenState(id,_19);this._columnHiderCheckboxes[id].checked=!_19;}});});