/*
	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.charting.widget.SelectableLegend"],["require","dojox.charting.widget.Legend"],["require","dijit.form.CheckBox"],["require","dojox.charting.action2d.Highlight"]],defineResource:function(_4,_5,_6){if(!_4._hasResource["dojox.charting.widget.SelectableLegend"]){_4._hasResource["dojox.charting.widget.SelectableLegend"]=true;_4.provide("dojox.charting.widget.SelectableLegend");_4.require("dojox.charting.widget.Legend");_4.require("dijit.form.CheckBox");_4.require("dojox.charting.action2d.Highlight");(function(){var df=_6.lang.functional;_4.declare("dojox.charting.widget.SelectableLegend",[_6.charting.widget.Legend],{outline:false,transitionFill:null,transitionStroke:null,postCreate:function(){this.legends=[];this.legendAnim={};this.inherited(arguments);},refresh:function(){this.legends=[];this.inherited(arguments);this._applyEvents();new _6.charting.widget._FocusManager(this);},_addLabel:function(_7,_8){this.inherited(arguments);var _9=_4.query("td",this.legendBody);var _a=_9[_9.length-1];this.legends.push(_a);var _b=new _5.form.CheckBox({checked:true});_4.place(_b.domNode,_a,"first");var _8=_4.query("label",_a)[0];_4.attr(_8,"for",_b.id);},_applyEvents:function(){_4.forEach(this.legends,function(_c,i){var _d,_e=[],_f,_10;if(this._isPie()){_d=this.chart.stack[0];_e.push(_d.group.children[i]);_f=_d.name;_10=this.chart.series[0].name;}else{_d=this.chart.series[i];_e=_d.group.children;_f=_d.plot;_10=_d.name;}var _11={fills:df.map(_e,"x.getFill()"),strokes:df.map(_e,"x.getStroke()")};var _12=_4.query(".dijitCheckBox",_c)[0];_4.connect(_12,"onclick",this,function(e){this._toggle(_e,i,_c.vanished,_11,_10,_f);_c.vanished=!_c.vanished;e.stopPropagation();});var _13=_4.query(".dojoxLegendIcon",_c)[0],_14=this._getFilledShape(this._surfaces[i].children);_4.forEach(["onmouseenter","onmouseleave"],function(_15){_4.connect(_13,_15,this,function(e){this._highlight(e,_14,_e,i,_c.vanished,_11,_10,_f);});},this);},this);},_toggle:function(_16,_17,_18,dyn,_19,_1a){_4.forEach(_16,function(_1b,i){var _1c=dyn.fills[i],_1d=this._getTransitionFill(_1a),_1e=dyn.strokes[i],_1f=this.transitionStroke;if(_1c){if(_1d&&(typeof _1c=="string"||_1c instanceof _4.Color)){_6.gfx.fx.animateFill({shape:_1b,color:{start:_18?_1d:_1c,end:_18?_1c:_1d}}).play();}else{_1b.setFill(_18?_1c:_1d);}}if(_1e&&!this.outline){_1b.setStroke(_18?_1e:_1f);}},this);},_highlight:function(e,_20,_21,_22,_23,dyn,_24,_25){if(!_23){var _26=this._getAnim(_25),_27=this._isPie(),_28=_29(e.type);var _2a={shape:_20,index:_27?"legend"+_22:"legend",run:{name:_24},type:_28};_26.process(_2a);_4.forEach(_21,function(_2b,i){_2b.setFill(dyn.fills[i]);var o={shape:_2b,index:_27?_22:i,run:{name:_24},type:_28};_26.duration=100;_26.process(o);});}},_getAnim:function(_2c){if(!this.legendAnim[_2c]){this.legendAnim[_2c]=new _6.charting.action2d.Highlight(this.chart,_2c);}return this.legendAnim[_2c];},_getTransitionFill:function(_2d){if(this.chart.stack[this.chart.plots[_2d]].declaredClass.indexOf("dojox.charting.plot2d.Stacked")!=-1){return this.chart.theme.plotarea.fill;}return null;},_getFilledShape:function(_2e){var i=0;while(_2e[i]){if(_2e[i].getFill()){return _2e[i];}i++;}},_isPie:function(){return this.chart.stack[0].declaredClass=="dojox.charting.plot2d.Pie";}});function _29(_2f){if(_2f=="mouseenter"){return "onmouseover";}if(_2f=="mouseleave"){return "onmouseout";}return "on"+_2f;};_4.declare("dojox.charting.widget._FocusManager",null,{constructor:function(_30){this.legend=_30;this.index=0;this.horizontalLength=this._getHrizontalLength();_4.forEach(_30.legends,function(_31,i){if(i>0){_4.query("input",_31).attr("tabindex",-1);}});this.firstLabel=_4.query("input",_30.legends[0])[0];_4.connect(this.firstLabel,"focus",this,function(){this.legend.active=true;});_4.connect(this.legend.legendNode,"keydown",this,"_onKeyEvent");},_getHrizontalLength:function(){var _32=this.legend.horizontal;if(typeof _32=="number"){return Math.min(_32,this.legend.legends.length);}else{if(!_32){return 1;}else{return this.legend.legends.length;}}},_onKeyEvent:function(e){if(!this.legend.active){return;}if(e.keyCode==_4.keys.TAB){this.legend.active=false;return;}var max=this.legend.legends.length;switch(e.keyCode){case _4.keys.LEFT_ARROW:this.index--;if(this.index<0){this.index+=max;}break;case _4.keys.RIGHT_ARROW:this.index++;if(this.index>=max){this.index-=max;}break;case _4.keys.UP_ARROW:if(this.index-this.horizontalLength>=0){this.index-=this.horizontalLength;}break;case _4.keys.DOWN_ARROW:if(this.index+this.horizontalLength<max){this.index+=this.horizontalLength;}break;default:return;}this._moveToFocus();_4.stopEvent(e);},_moveToFocus:function(){_4.query("input",this.legend.legends[this.index])[0].focus();}});})();}}};});