]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/plugins/textcolor/plugin.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / plugins / textcolor / plugin.js
1 /**
2  * plugin.js
3  *
4  * Copyright, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://www.tinymce.com/license
8  * Contributing: http://www.tinymce.com/contributing
9  */
10
11 /*global tinymce:true */
12
13 tinymce.PluginManager.add('textcolor', function(editor) {
14         function mapColors() {
15                 var i, colors = [], colorMap;
16
17                 colorMap = editor.settings.textcolor_map || [
18                         "000000", "Black",
19                         "993300", "Burnt orange",
20                         "333300", "Dark olive",
21                         "003300", "Dark green",
22                         "003366", "Dark azure",
23                         "000080", "Navy Blue",
24                         "333399", "Indigo",
25                         "333333", "Very dark gray",
26                         "800000", "Maroon",
27                         "FF6600", "Orange",
28                         "808000", "Olive",
29                         "008000", "Green",
30                         "008080", "Teal",
31                         "0000FF", "Blue",
32                         "666699", "Grayish blue",
33                         "808080", "Gray",
34                         "FF0000", "Red",
35                         "FF9900", "Amber",
36                         "99CC00", "Yellow green",
37                         "339966", "Sea green",
38                         "33CCCC", "Turquoise",
39                         "3366FF", "Royal blue",
40                         "800080", "Purple",
41                         "999999", "Medium gray",
42                         "FF00FF", "Magenta",
43                         "FFCC00", "Gold",
44                         "FFFF00", "Yellow",
45                         "00FF00", "Lime",
46                         "00FFFF", "Aqua",
47                         "00CCFF", "Sky blue",
48                         "993366", "Brown",
49                         "C0C0C0", "Silver",
50                         "FF99CC", "Pink",
51                         "FFCC99", "Peach",
52                         "FFFF99", "Light yellow",
53                         "CCFFCC", "Pale green",
54                         "CCFFFF", "Pale cyan",
55                         "99CCFF", "Light sky blue",
56                         "CC99FF", "Plum",
57                         "FFFFFF", "White"
58                 ];
59
60                 for (i = 0; i < colorMap.length; i += 2) {
61                         colors.push({
62                                 text: colorMap[i + 1],
63                                 color: colorMap[i]
64                         });
65                 }
66
67                 return colors;
68         }
69
70         function renderColorPicker() {
71                 var ctrl = this, colors, color, html, last, rows, cols, x, y, i;
72
73                 colors = mapColors();
74
75                 html = '<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="presentation" cellspacing="0"><tbody>';
76                 last = colors.length - 1;
77                 rows = editor.settings.textcolor_rows || 5;
78                 cols = editor.settings.textcolor_cols || 8;
79
80                 for (y = 0; y < rows; y++) {
81                         html += '<tr>';
82
83                         for (x = 0; x < cols; x++) {
84                                 i = y * cols + x;
85
86                                 if (i > last) {
87                                         html += '<td></td>';
88                                 } else {
89                                         color = colors[i];
90                                         html += (
91                                                 '<td>' +
92                                                         '<div id="' + ctrl._id + '-' + i + '"' +
93                                                                 ' data-mce-color="' + color.color + '"' +
94                                                                 ' role="option"' +
95                                                                 ' tabIndex="-1"' +
96                                                                 ' style="' + (color ? 'background-color: #' + color.color : '') + '"' +
97                                                                 ' title="' + color.text + '">' +
98                                                         '</div>' +
99                                                 '</td>'
100                                         );
101                                 }
102                         }
103
104                         html += '</tr>';
105                 }
106
107                 html += '</tbody></table>';
108
109                 return html;
110         }
111
112         function onPanelClick(e) {
113                 var buttonCtrl = this.parent(), value;
114
115                 if ((value = e.target.getAttribute('data-mce-color'))) {
116                         buttonCtrl.hidePanel();
117                         value = '#' + value;
118                         buttonCtrl.color(value);
119                         editor.execCommand(buttonCtrl.settings.selectcmd, false, value);
120                 }
121         }
122
123         function onButtonClick() {
124                 var self = this;
125
126                 if (self._color) {
127                         editor.execCommand(self.settings.selectcmd, false, self._color);
128                 }
129         }
130
131         editor.addButton('forecolor', {
132                 type: 'colorbutton',
133                 tooltip: 'Text color',
134                 popoverAlign: 'bc-tl',
135                 selectcmd: 'ForeColor',
136                 panel: {
137                         html: renderColorPicker,
138                         onclick: onPanelClick
139                 },
140                 onclick: onButtonClick
141         });
142
143         editor.addButton('backcolor', {
144                 type: 'colorbutton',
145                 tooltip: 'Background color',
146                 popoverAlign: 'bc-tl',
147                 selectcmd: 'HiliteColor',
148                 panel: {
149                         html: renderColorPicker,
150                         onclick: onPanelClick
151                 },
152                 onclick: onButtonClick
153         });
154 });