/*
	Copyright (c) 2004-2012, 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
*/


if(!dojo._hasResource["dijit._editor.plugins.TextColor"]){
dojo._hasResource["dijit._editor.plugins.TextColor"]=true;
dojo.provide("dijit._editor.plugins.TextColor");
dojo.require("dijit._editor._Plugin");
dojo.require("dijit.ColorPalette");
dojo.declare("dijit._editor.plugins.TextColor",dijit._editor._Plugin,{buttonClass:dijit.form.DropDownButton,useDefaultCommand:false,_initButton:function(){
this.inherited(arguments);
var _1=this;
this.button.loadDropDown=function(_2){
this.dropDown=new dijit.ColorPalette({value:_1.value,onChange:function(_3){
_1.editor.execCommand(_1.command,_3);
}});
_2();
};
},updateState:function(){
var _4=this.editor;
var _5=this.command;
if(!_4||!_4.isLoaded||!_5.length){
return;
}
if(this.button){
var _6;
try{
_6=_4.queryCommandValue(_5)||"";
}
catch(e){
_6="";
}
}
if(_6==""){
_6="#000000";
}
if(_6=="transparent"){
_6="#ffffff";
}
if(typeof _6=="string"){
if(_6.indexOf("rgb")>-1){
_6=dojo.colorFromRgb(_6).toHex();
}
}else{
_6=((_6&255)<<16)|(_6&65280)|((_6&16711680)>>>16);
_6=_6.toString(16);
_6="#000000".slice(0,7-_6.length)+_6;
}
if(this.dropDown&&_6!==this.dropDown.get("value")){
this.dropDown.set("value",_6,false);
}
}});
dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
if(o.plugin){
return;
}
switch(o.args.name){
case "foreColor":
case "hiliteColor":
o.plugin=new dijit._editor.plugins.TextColor({command:o.args.name});
}
});
}
