/*
	Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


window[esri._dojoScopeName||"dojo"]._xdResourceLoaded(function(_1,_2,_3){return {depends:[["provide","dojox.grid.enhanced.plugins.Search"],["require","dojox.grid.enhanced._Plugin"],["require","dojo.data.util.filter"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.grid.enhanced.plugins.Search"]){_4._hasResource["dojox.grid.enhanced.plugins.Search"]=true;_4.provide("dojox.grid.enhanced.plugins.Search");_4.require("dojox.grid.enhanced._Plugin");_4.require("dojo.data.util.filter");_4.declare("dojox.grid.enhanced.plugins.Search",_6.grid.enhanced._Plugin,{name:"search",constructor:function(_7,_8){this.grid=_7;_8=(_8&&_4.isObject(_8))?_8:{};this._cacheSize=_8.cacheSize||-1;_7.searchRow=_4.hitch(this,"searchRow");},searchRow:function(_9,_a){if(!_4.isFunction(_a)){return;}if(_4.isString(_9)){_9=_4.data.util.filter.patternToRegExp(_9);}var _b=false;if(_9 instanceof RegExp){_b=true;}else{if(_4.isObject(_9)){var _c=true;for(var _d in _9){if(_4.isString(_9[_d])){_9[_d]=_4.data.util.filter.patternToRegExp(_9[_d]);}_c=false;}if(_c){return;}}else{return;}}this._search(_9,0,_a,_b);},_search:function(_e,_f,_10,_11){var _12=this,cnt=this._cacheSize,_13={"start":_f,"onBegin":function(_14){_12._storeSize=_14;},"onComplete":function(_15){if(!_4.some(_15,function(_16,i){if(_12._checkRow(_16,_e,_11)){_10(_f+i,_16);return true;}return false;})){if(cnt>0&&_f+cnt<_12._storeSize){_12._search(_e,_f+cnt,_10,_11);}else{_10(-1,null);}}}};if(cnt>0){_13.count=cnt;}this.grid._storeLayerFetch(_13);},_checkRow:function(_17,_18,_19){var g=this.grid,s=g.store,i,_1a,_1b=_4.filter(g.layout.cells,function(_1c){return !_1c.hidden;});if(_19){return _4.some(_1b,function(_1d){try{if(_1d.field){return String(s.getValue(_17,_1d.field)).search(_18)>=0;}}catch(e){console.log("Search._checkRow() error: ",e);}return false;});}else{for(_1a in _18){if(_18[_1a] instanceof RegExp){for(i=_1b.length-1;i>=0;--i){if(_1b[i].field==_1a){try{if(String(s.getValue(_17,_1a)).search(_18[_1a])<0){return false;}break;}catch(e){return false;}}}if(i<0){return false;}}}return true;}}});_6.grid.EnhancedGrid.registerPlugin(_6.grid.enhanced.plugins.Search);}}};});