~canonical-sysadmins/wordpress/4.7.2

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/plugins/textcolor/plugin.js

  • Committer: Barry Price
  • Date: 2016-04-27 04:42:45 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: barry.price@canonical.com-20160427044245-ob1jzpeq2ex7jv07
Merge WP 4.5.1 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
tinymce.PluginManager.add('textcolor', function(editor) {
15
15
        var cols, rows;
16
16
 
17
 
        rows = editor.settings.textcolor_rows || 5;
18
 
        cols = editor.settings.textcolor_cols || 8;
 
17
        rows = {
 
18
                forecolor: editor.settings.forecolor_rows || editor.settings.textcolor_rows || 5,
 
19
                backcolor: editor.settings.backcolor_rows || editor.settings.textcolor_rows || 5
 
20
        };
 
21
        cols = {
 
22
                forecolor: editor.settings.forecolor_cols || editor.settings.textcolor_cols || 8,
 
23
                backcolor: editor.settings.backcolor_cols || editor.settings.textcolor_cols || 8
 
24
        };
19
25
 
20
26
        function getCurrentColor(format) {
21
27
                var color;
31
37
                return color;
32
38
        }
33
39
 
34
 
        function mapColors() {
 
40
        function mapColors(type) {
35
41
                var i, colors = [], colorMap;
36
42
 
37
 
                colorMap = editor.settings.textcolor_map || [
 
43
                colorMap = [
38
44
                        "000000", "Black",
39
45
                        "993300", "Burnt orange",
40
46
                        "333300", "Dark olive",
76
82
                        "CC99FF", "Plum"
77
83
                ];
78
84
 
 
85
                colorMap = editor.settings.textcolor_map || colorMap;
 
86
                colorMap = editor.settings[type + '_map'] || colorMap;
 
87
 
79
88
                for (i = 0; i < colorMap.length; i += 2) {
80
89
                        colors.push({
81
90
                                text: colorMap[i + 1],
87
96
        }
88
97
 
89
98
        function renderColorPicker() {
90
 
                var ctrl = this, colors, color, html, last, x, y, i, id = ctrl._id, count = 0;
 
99
                var ctrl = this, colors, color, html, last, x, y, i, id = ctrl._id, count = 0, type;
 
100
 
 
101
                type = ctrl.settings.origin;
91
102
 
92
103
                function getColorCellHtml(color, title) {
93
104
                        var isNoColor = color == 'transparent';
106
117
                        );
107
118
                }
108
119
 
109
 
                colors = mapColors();
 
120
                colors = mapColors(type);
110
121
                colors.push({
111
122
                        text: tinymce.translate("No color"),
112
123
                        color: "transparent"
115
126
                html = '<table class="mce-grid mce-grid-border mce-colorbutton-grid" role="list" cellspacing="0"><tbody>';
116
127
                last = colors.length - 1;
117
128
 
118
 
                for (y = 0; y < rows; y++) {
 
129
                for (y = 0; y < rows[type]; y++) {
119
130
                        html += '<tr>';
120
131
 
121
 
                        for (x = 0; x < cols; x++) {
122
 
                                i = y * cols + x;
 
132
                        for (x = 0; x < cols[type]; x++) {
 
133
                                i = y * cols[type] + x;
123
134
 
124
135
                                if (i > last) {
125
136
                                        html += '<td></td>';
135
146
                if (editor.settings.color_picker_callback) {
136
147
                        html += (
137
148
                                '<tr>' +
138
 
                                        '<td colspan="' + cols + '" class="mce-custom-color-btn">' +
 
149
                                        '<td colspan="' + cols[type] + '" class="mce-custom-color-btn">' +
139
150
                                                '<div id="' + id + '-c" class="mce-widget mce-btn mce-btn-small mce-btn-flat" ' +
140
151
                                                        'role="button" tabindex="-1" aria-labelledby="' + id + '-c" style="width: 100%">' +
141
152
                                                        '<button type="button" role="presentation" tabindex="-1">' + tinymce.translate('Custom...') + '</button>' +
146
157
 
147
158
                        html += '<tr>';
148
159
 
149
 
                        for (x = 0; x < cols; x++) {
 
160
                        for (x = 0; x < cols[type]; x++) {
150
161
                                html += getColorCellHtml('', 'Custom color');
151
162
                        }
152
163
 
175
186
        }
176
187
 
177
188
        function onPanelClick(e) {
178
 
                var buttonCtrl = this.parent(), value;
 
189
                var buttonCtrl = this.parent(), value, type;
 
190
 
 
191
                type = buttonCtrl.settings.origin;
179
192
 
180
193
                function selectColor(value) {
181
194
                        buttonCtrl.hidePanel();
214
227
 
215
228
                                // Shift colors to the right
216
229
                                // TODO: Might need to be the left on RTL
217
 
                                if (i == cols) {
218
 
                                        for (i = 0; i < cols - 1; i++) {
 
230
                                if (i == cols[type]) {
 
231
                                        for (i = 0; i < cols[type] - 1; i++) {
219
232
                                                setDivColor(customColorCells[i], customColorCells[i + 1].getAttribute('data-mce-color'));
220
233
                                        }
221
234
                                }
259
272
                tooltip: 'Text color',
260
273
                format: 'forecolor',
261
274
                panel: {
 
275
                        origin: 'forecolor',
262
276
                        role: 'application',
263
277
                        ariaRemember: true,
264
278
                        html: renderColorPicker,
272
286
                tooltip: 'Background color',
273
287
                format: 'hilitecolor',
274
288
                panel: {
 
289
                        origin: 'backcolor',
275
290
                        role: 'application',
276
291
                        ariaRemember: true,
277
292
                        html: renderColorPicker,