/*
	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._PluginManager"],["require","dojox.grid.enhanced._Events"],["require","dojox.grid.enhanced._FocusManager"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.grid.enhanced._PluginManager"]){_4._hasResource["dojox.grid.enhanced._PluginManager"]=true;_4.provide("dojox.grid.enhanced._PluginManager");_4.require("dojox.grid.enhanced._Events");_4.require("dojox.grid.enhanced._FocusManager");_4.declare("dojox.grid.enhanced._PluginManager",null,{_options:null,_plugins:null,_connects:null,constructor:function(_7){this.grid=_7;this._store=_7.store;this._options={};this._plugins=[];this._connects=[];this._parseProps(this.grid.plugins);_7.connect(_7,"_setStore",_4.hitch(this,function(_8){if(this._store!==_8){this.forEach("onSetStore",[_8,this._store]);this._store=_8;}}));},startup:function(){this.forEach("onStartUp");},preInit:function(){this.grid.focus.destroy();this.grid.focus=new _6.grid.enhanced._FocusManager(this.grid);new _6.grid.enhanced._Events(this.grid);this._init(true);this.forEach("onPreInit");},postInit:function(){this._init(false);_4.forEach(this.grid.views.views,this._initView,this);this._connects.push(_4.connect(this.grid.views,"addView",_4.hitch(this,this._initView)));if(this._plugins.length>0){var _9=this.grid.edit;if(_9){_9.styleRow=function(_a){};}}this.forEach("onPostInit");},forEach:function(_b,_c){_4.forEach(this._plugins,function(p){if(!p||!p[_b]){return;}p[_b].apply(p,_c?_c:[]);});},_parseProps:function(_d){if(!_d){return;}var p,_e={},_f=this._options,_10=this.grid;var _11=_6.grid.enhanced._PluginManager.registry;for(p in _d){if(_d[p]){this._normalize(p,_d,_11,_e);}}if(_f.dnd||_f.indirectSelection){_f.columnReordering=false;}_4.mixin(_10,_f);},_normalize:function(p,_12,_13,_14){if(!_13[p]){throw new Error("Plugin "+p+" is required.");}if(_14[p]){throw new Error("Recursive cycle dependency is not supported.");}var _15=this._options;if(_15[p]){return _15[p];}_14[p]=true;_15[p]=_4.mixin({},_13[p],_4.isObject(_12[p])?_12[p]:{});var _16=_15[p]["dependency"];if(_16){if(!_4.isArray(_16)){_16=_15[p]["dependency"]=[_16];}_4.forEach(_16,function(_17){if(!this._normalize(_17,_12,_13,_14)){throw new Error("Plugin "+_17+" is required.");}},this);}delete _14[p];return _15[p];},_init:function(pre){var p,_18,_19=this._options;for(p in _19){_18=_19[p]["preInit"];if((pre?_18:!_18)&&_19[p]["class"]&&!this.pluginExisted(p)){this.loadPlugin(p);}}},loadPlugin:function(_1a){var _1b=this._options[_1a];if(!_1b){return null;}var _1c=this.getPlugin(_1a);if(_1c){return _1c;}var _1d=_1b["dependency"];_4.forEach(_1d,function(_1e){if(!this.loadPlugin(_1e)){throw new Error("Plugin "+_1e+" is required.");}},this);var cls=_1b["class"];delete _1b["class"];_1c=new this.getPluginClazz(cls)(this.grid,_1b);this._plugins.push(_1c);return _1c;},_initView:function(_1f){if(!_1f){return;}_6.grid.util.funnelEvents(_1f.contentNode,_1f,"doContentEvent",["mouseup","mousemove"]);_6.grid.util.funnelEvents(_1f.headerNode,_1f,"doHeaderEvent",["mouseup"]);},pluginExisted:function(_20){return !!this.getPlugin(_20);},getPlugin:function(_21){var _22=this._plugins;_21=_21.toLowerCase();for(var i=0,len=_22.length;i<len;i++){if(_21==_22[i]["name"].toLowerCase()){return _22[i];}}return null;},getPluginClazz:function(_23){if(_4.isFunction(_23)){return _23;}var _24="Please make sure Plugin \""+_23+"\" is existed.";try{var cls=_4.getObject(_23);if(!cls){throw new Error(_24);}return cls;}catch(e){throw new Error(_24);}},isFixedCell:function(_25){return _25&&(_25.isRowSelector||_25.fixedPos);},destroy:function(){_4.forEach(this._connects,_4.disconnect);this.forEach("destroy");if(this.grid.unwrap){this.grid.unwrap();}delete this._connects;delete this._plugins;delete this._options;}});_6.grid.enhanced._PluginManager.registerPlugin=function(_26,_27){if(!_26){console.warn("Failed to register plugin, class missed!");return;}var cls=_6.grid.enhanced._PluginManager;cls.registry=cls.registry||{};cls.registry[_26.prototype.name]=_4.mixin({"class":_26},(_27?_27:{}));};}}};});