//>>built
define("mill/gridColumnsFilter","dijit/form/ComboBox dijit/form/CheckBox dojox/grid/EnhancedGrid dojox/grid/enhanced/_Plugin dojox/grid/enhanced/_PluginManager mill/mill".split(" "),function(){dojo.declare("dojox.grid.enhanced.plugins.millColumnsFilter",[dojox.grid.enhanced._Plugin],{name:"millColumnsFilter",visible:!0,_filterBarRows:null,_tables:null,_afterRowConnects:null,_widgets:null,searchAttr:"Description",labelAttr:"Description",init:function(){this.inherited(arguments);dojo.mixin(this,this.options);
this._widgets=[];this._filterBarRows=[];this._tables=[];this._afterRowConnects=[];var a=this,b=this._oldCreateView=dojo.hitch(this.grid,this.grid.createView);this.grid.createView=function(c,d){for(;a._filterBarRows.length<=d;)a._filterBarRows.push(null);for(;a._tables.length<=d;)a._tables.push(null);for(;a._afterRowConnects.length<=d;)a._afterRowConnects.push(null);a._cleanUp(d);var e=b.apply(a.grid,arguments);a._afterRowConnects[d]=dojo.connect(e,"onAfterRow",a,"_afterRow");return e};dojo.mixin(this.grid,
{showFilterBar:dojo.hitch(this,this.show),hideFilterBar:dojo.hitch(this,this.hide),getFilterBarVisible:dojo.hitch(this,function(){return this.visible})})},show:function(){this.visible=!0;this._render()},hide:function(){this.visible=!1;this._cleanUp()},_afterRow:function(a,b,c){if(-1==a&&b.length&&b[0].length){var d=b[0][0].view.index;dojo.query("table",c).forEach(dojo.hitch(this,function(e,f){this._cleanUpBar(d);this._tables[d]=e;this.visible&&this._render()}))}},_cleanUpEvent:function(a){this._tables[a]=
null;this._afterRowConnects[a]&&(dojo.disconnect(this._afterRowConnects[a]),this._afterRowConnects[a]=null)},_cleanUpBar:function(a){this._filterBarRows[a]&&(this._filterBarRows[a].parentNode&&this._filterBarRows[a].parentNode.removeChild(this._filterBarRows[a]),this._filterBarRows[a]=null,this._widgets&&dojo.forEach(this._widgets,dojo.hitch(this,function(b,c){b&&b.viewIdx==a&&(b.store&&b.store.close(),b.destroyRecursive());this._widgets[c]=null})))},_cleanUp:function(a){this._cleanUpEvent(a);this._cleanUpBar(a)},
_render:function(){for(var a=0;a<this._filterBarRows.length;a++)this._cleanUpBar(a),this._tables[a]&&(this._filterBarRows[a]=this._tables[a].insertRow(-1),this._filterBarRows[a].height="25",this._filterBarRows[a].style.height="25px",dojo.forEach(this._tables[a].rows[0].cells,dojo.hitch(this,function(b){var c=this._filterBarRows[a].insertCell(-1);c.className=b.className;c.style.display=b.style.display;c.style.padding="2px 5px 2px 0px"})),cells=this.grid.views.views[a]?this.grid.views.views[a].structure.cells[0]:
[],dojo.forEach(cells,dojo.hitch(this,function(b,c){if(b.field&&!b.hidden){var d=this._filterBarRows[a].cells[c];if(d){var e=document.createElement("input");d.appendChild(e);d=this.grid.onGetFilterStore(b);this._createComboBox(b,b.filterValue||b.filter,d,e,c)}}})))},_createComboBox:function(a,b,c,d,e){this._widgets.push(new dojox.grid.enhanced.millColumnsFilterCombobox({style:"width:100%",searchAttr:this.searchAttr,labelAttr:this.labelAttr,autoComplete:!1,grid:this.grid,column:a,value:b,store:c,viewIdx:e},
d))},destroy:function(){for(var a=0;a<this._filterBarRows.length;a++)this._cleanUp(a);this.grid.createView=this._oldCreateView;this.inherited(arguments)}});dojo.declare("dojox.grid.enhanced.millColumnsFilterCombobox",dijit.form.ComboBox,{grid:null,column:null,viewIdx:null,dropDownClass:"dojox.grid.enhanced.millColumnsFilterDropDown",_selected:null,_freeze:!1,_selectOption:function(a){var b=this.attr("value"),c=this.attr("label"),d=this.attr("item");this._selected=[];this.dropDown&&dojo.forEach(this.dropDown._checkboxes,
dojo.hitch(this,function(g){g.attr("checked")&&this._selected.push(g.item)}));this.inherited(arguments);var e=this.attr("item");if(e.onSelect){var f=e.onSelect;dojo.isArray(f)&&(f=f[0]);if(f(this)){this._freeze=!0;this.value=b;this.label=c;this.item=d;dijit.form.ValidationTextBox.prototype._setValueAttr.call(this,this.value,!0,this.label);return}}e&&-1==dojo.indexOf(this._selected,e)&&(this._selected=[e]);var h=[];dojo.forEach(this._selected,dojo.hitch(this,function(g){this.store.getIdentity(g)&&
h.push(this.store.getLabel(g))}));this.attr("value",h.join(";"))},onChange:function(){if(this._freeze)this._freeze=!1;else{var a=[];this._selected&&dojo.forEach(this._selected,dojo.hitch(this,function(c){a.push(this.store.getIdentity(c))}));var b=a.length?a.join(";"):this.attr("value");this.column.filter=b;this.column.filterValue=this.attr("value");this.grid.onFilterChanged(this.column,b,this.store,this._selected)}},_startSearchFromInput:function(){}});dojo.declare("dojox.grid.enhanced.millColumnsFilterDropDown",
dijit.form._ComboBoxMenu,{_onMouseUp:function(a){if("option"==a.target.getAttribute("role"))return this.inherited(arguments)},_checkboxes:null,_comboBox:null,postMixInProperties:function(){this.inherited(arguments);var a=this.id;a=a.substring(0,a.length-6);this._comboBox=dijit.byId(a)},_createOption:function(a,b){var c=this.inherited(arguments),d=(this._comboBox.attr("value")||"").split(";"),e=this._comboBox.store.getLabel(a);node=document.createElement("input");c.insertBefore(node,c.firstChild);
d=new dojox.grid.enhanced.millColumnsFilterCheckBox({item:a,dropDown:this,_comboBox:this._comboBox,checked:-1!=dojo.indexOf(d,e)},node);this._checkboxes||(this._checkboxes=[]);dojo.mixin(a,{dropDown:this});this._checkboxes.push(d);return c}});dojo.declare("dojox.grid.enhanced.millColumnsFilterCheckBox",dijit.form.CheckBox,{item:null,dropDown:null,_comboBox:null});dojo.extend(dojox.grid.EnhancedGrid,{onFilterChanged:function(a,b,c,d){},onGetFilterStore:function(a){}});dojo.extend(dojox.grid.cells.Cell,
{filter:null,filterValue:null})});