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

Revision 4291, 3.5 KB checked in by airton, 13 years ago (diff)

Ticket #1820 - Permitindo o envio de email em texto puro - r4252

  • 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    if ( Element("forecolor") )
27    {
28        var new_pos = findPosY(Element("forecolor")) - intElemScrollTop + 20;
29        this.div.style.top = new_pos;
30    }
31}
32
33cColorPalette.prototype.loadPalette = function (id)
34{
35        this.parentDiv = document.getElementById("body_position_"+id);
36        this.editor = document.getElementById("body_"+id);
37        if(this.div.parentNode)
38                this.div.parentNode.removeChild(this.div);     
39
40        this.parentDiv.appendChild(this.div);   
41        this.div.style.position = "absolute";
42
43        if(is_ie)
44        {
45                this.div.style.top = findPosY(Element("forecolor")) - 100;
46                this.div.style.left = findPosX(Element("forecolor"))- 200;
47        }
48        else
49        {
50                this.div.style.top = ColorPalette.repos(Element("div_message_scroll_"+id).scrollTop);
51                this.div.style.left = findPosY(Element("forecolor"))+ 227;
52        }
53}
54
55cColorPalette.prototype.buildPalette = function (){
56       
57        this.div = document.createElement("DIV");
58        this.div.style.visibility="hidden";
59        this.div.id= "palettecolor";
60        this.div.style.top = "0px";
61        this.div.style.left = "0px";
62        this.div.style.width    = "auto";
63        this.div.style.height= "auto";
64        var t1 = document.createElement("TABLE");
65        var tb1 = document.createElement("TBODY");
66        t1.appendChild(tb1);
67        t1.border ="1px";
68        t1.cellPadding ="0px";
69        t1.cellSpacing ="0px";
70        t1.style.width = "100px";
71        t1.bgcolor = "WHITE";
72        this.div.appendChild(t1);
73        _this = this;
74        for( i = 0; i < 10; i++) {
75                var _tr = document.createElement("TR");
76                tb1.appendChild(_tr);           
77                for( j = 0; j < 7; j++) {
78                        var _td = document.createElement("TD");
79                        _td.style.background =  this.colors[j][i];
80                        _td.unselectable = "on";
81                        _td.style.width = "15px";
82                        _td.style.height = "15px";
83                        _td.title =   this.colors[j][i];
84                        _td.id =   this.colors[j][i];
85                        _td.className = "unsel_color";
86                        _td.onclick= function(){ document.getElementById("palettecolor").style.visibility="hidden";ColorPalette.changeFontColor(this.id);};
87                        _td.onmouseover = function(){ this.className = "sel_color";};
88                        _td.onmouseout = function(){ this.className = "unsel_color";}
89                        var p = new Image();
90                        p.style.width='1px';
91                        p.style.height='1px';
92                        _td.appendChild(p);
93                        _tr.appendChild(_td);
94                }
95        }
96}
97
98/* Build the Object */
99var ColorPalette = new cColorPalette();
Note: See TracBrowser for help on using the repository browser.