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

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

* empty log message *

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