source: trunk/expressoMail1_2/js/color_palette.js @ 2

Revision 2, 3.4 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1// Inicializa palheta de cores;
2function cColorPalette(){
3        this.editor;
4        this.div;
5        this.parentDiv;
6        this.colors = new Array(        new Array("#FFFFFF","#FFCCCC","#FFCC99","#FFFF99","#FFFFCC","#99FF99","#99FFFF","#CCFFFF","#CCCCFF","#FFCCFF"),
7                                                new Array("#CCCCCC","#FF6666","#FF9966","#FFFF66","#FFFF33","#66FF99","#33FFFF","#66FFFF","#9999FF","#FF99FF"),
8                                                new Array("#C0C0C0","#FF0000","#FF9900","#FFCC66","#FFFF00","#33FF33","#66CCCC","#33CCFF","#6666CC","#CC66CC"),
9                                                new Array("#999999","#CC0000","#ff6600","#FFCC33","#FFCC00","#33CC00","#00CCCC","#3366FF","#6633FF","#CC33CC"),
10                                                new Array("#666666","#990000","#CC6600","#CC9933","#999900","#009900","#339999","#3333FF","#6600CC","#993399"),
11                                                new Array("#333333","#660000","#993300","#996633","#666600","#006600","#336666","#000099","#333399","#663366"),
12                                                new Array("#000000","#330000","#663300","#663333","#333300","#003300","#003333","#000066","#330099","#330033"));
13        this.buildPalette();
14}
15
16// funçoes
17cColorPalette.prototype.changeFontColor = function (color){     
18        var mainField = this.editor.contentWindow;
19        mainField.document.execCommand("forecolor", false, color);     
20        document.getElementById("palettecolor").style.visibility="hidden";
21        mainField.focus();
22}
23
24cColorPalette.prototype.repos = function (intElemScrollTop)
25{
26        var new_pos = findPosY(Element("forecolor")) - intElemScrollTop + 20;
27        this.div.style.top = new_pos;
28}
29
30cColorPalette.prototype.loadPalette = function (id)
31{
32        this.parentDiv = document.getElementById("body_position_"+id);
33        this.editor = document.getElementById("body_"+id);
34        if(this.div.parentNode)
35                this.div.parentNode.removeChild(this.div);     
36
37        this.parentDiv.appendChild(this.div);   
38        this.div.style.position = "absolute";
39
40        if(is_ie)
41        {
42                this.div.style.top = findPosY(Element("forecolor")) - 100;
43                this.div.style.left = findPosX(Element("forecolor"))- 200;
44        }
45        else
46        {
47                this.div.style.top = ColorPalette.repos(Element("div_message_scroll_"+id).scrollTop);
48                this.div.style.left = findPosY(Element("forecolor"))+ 227;
49        }
50}
51
52cColorPalette.prototype.buildPalette = function (){
53       
54        this.div = document.createElement("DIV");
55        this.div.style.visibility="hidden";
56        this.div.id= "palettecolor";
57        this.div.style.top = "0px";
58        this.div.style.left = "0px";
59        this.div.style.width    = "auto";
60        this.div.style.height= "auto";
61        var t1 = document.createElement("TABLE");
62        var tb1 = document.createElement("TBODY");
63        t1.appendChild(tb1);
64        t1.border ="1px";
65        t1.cellPadding ="0px";
66        t1.cellSpacing ="0px";
67        t1.style.width = "100px";
68        t1.bgcolor = "WHITE";
69        this.div.appendChild(t1);
70        _this = this;
71        for( i = 0; i < 10; i++) {
72                var _tr = document.createElement("TR");
73                tb1.appendChild(_tr);           
74                for( j = 0; j < 7; j++) {
75                        var _td = document.createElement("TD");
76                        _td.style.background =  this.colors[j][i];
77                        _td.unselectable = "on";
78                        _td.style.width = "15px";
79                        _td.style.height = "15px";
80                        _td.title =   this.colors[j][i];
81                        _td.id =   this.colors[j][i];
82                        _td.className = "unsel_color";
83                        _td.onclick= function(){ document.getElementById("palettecolor").style.visibility="hidden";ColorPalette.changeFontColor(this.id);};
84                        _td.onmouseover = function(){ this.className = "sel_color";};
85                        _td.onmouseout = function(){ this.className = "unsel_color";}
86                        var p = new Image();
87                        p.style.width='1px';
88                        p.style.height='1px';
89                        _td.appendChild(p);
90                        _tr.appendChild(_td);
91                }
92        }
93}
94
95/* Build the Object */
96var ColorPalette = new cColorPalette();
Note: See TracBrowser for help on using the repository browser.