]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/_editor/plugins/TextColor.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dijit / _editor / plugins / TextColor.js
1 /*
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
5 */
6
7
8 if(!dojo._hasResource["dijit._editor.plugins.TextColor"]){
9 dojo._hasResource["dijit._editor.plugins.TextColor"]=true;
10 dojo.provide("dijit._editor.plugins.TextColor");
11 dojo.require("dijit._editor._Plugin");
12 dojo.require("dijit.ColorPalette");
13 dojo.declare("dijit._editor.plugins.TextColor",dijit._editor._Plugin,{buttonClass:dijit.form.DropDownButton,useDefaultCommand:false,constructor:function(){
14 this.dropDown=new dijit.ColorPalette();
15 this.connect(this.dropDown,"onChange",function(_1){
16 this.editor.execCommand(this.command,_1);
17 });
18 },updateState:function(){
19 var _2=this.editor;
20 var _3=this.command;
21 if(!_2||!_2.isLoaded||!_3.length){
22 return;
23 }
24 if(this.button){
25 var _4;
26 try{
27 _4=_2.queryCommandValue(_3)||"";
28 }
29 catch(e){
30 _4="";
31 }
32 }
33 if(_4==""){
34 _4="#000000";
35 }
36 if(_4=="transparent"){
37 _4="#ffffff";
38 }
39 if(typeof _4=="string"){
40 if(_4.indexOf("rgb")>-1){
41 _4=dojo.colorFromRgb(_4).toHex();
42 }
43 }else{
44 _4=((_4&255)<<16)|(_4&65280)|((_4&16711680)>>>16);
45 _4=_4.toString(16);
46 _4="#000000".slice(0,7-_4.length)+_4;
47 }
48 if(_4!==this.dropDown.get("value")){
49 this.dropDown.set("value",_4,false);
50 }
51 }});
52 dojo.subscribe(dijit._scopeName+".Editor.getPlugin",null,function(o){
53 if(o.plugin){
54 return;
55 }
56 switch(o.args.name){
57 case "foreColor":
58 case "hiliteColor":
59 o.plugin=new dijit._editor.plugins.TextColor({command:o.args.name});
60 }
61 });
62 }