PageSourceSearch

https://gecs.galfar.com/SupplyChainPortal/htmlEditor/trumbowyg.colors.js

js galfar.com collected 2026-10-02 16:29:24 UTC 6,201 bytes, 172 lines download raw bytes

vendor: 3,249 bytes, lines 1-97
1/* ===========================================================
2 * trumbowyg.colors.js v1.2
3 * Colors picker plugin for Trumbowyg
4 * http://alex-d.github.com/Trumbowyg
5 * ===========================================================
6 * Author : Alexandre Demode (Alex-D)
7 *          Twitter : @AlexandreDemode
8 *          Website : alex-d.fr
9 */
10
11(function ($) {
12    'use strict';
13
14    $.extend(true, $.trumbowyg, {
15        langs: {
16            // jshint camelcase:false
17            cs: {
18                foreColor: 'Barva textu',
19                backColor: 'Barva pozadí'
20            },
21            en: {
22                foreColor: 'Text color',
23                backColor: 'Background color'
24            },
25            fr: {
26                foreColor: 'Couleur du texte',
27                backColor: 'Couleur de fond'
28            },
29            sk: {
30                foreColor: 'Farba textu',
31                backColor: 'Farba pozadia'
32            },
33            zh_cn: {
34                foreColor: '文字颜色',
35                backColor: '背景颜色'
36            },
37            ja: {
38                foreColor: '文字色',
39                backColor: '背景色'
40            }
41        }
42    });
43    // jshint camelcase:true
44
45
46    function hex(x) {
47        return ('0' + parseInt(x).toString(16)).slice(-2);
48    }
49
50    function colorToHex(rgb) {
51        if (rgb.search('rgb') === -1) {
52            return rgb.replace('#', '');
53        } else if (rgb === 'rgba(0, 0, 0, 0)') {
54            return 'transparent';
55        } else {
56            rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
57            return hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
58        }
59    }
60
61    function colorTagHandler(element, trumbowyg) {
62        var tags = [];
63
64        if(!element.style){
65            return tags;
66        }
67
68        // background color
69        if (element.style.backgroundColor !== '') {
70            var backColor = colorToHex(element.style.backgroundColor);
71            if (trumbowyg.o.plugins.colors.colorList.indexOf(backColor) >= 0) {
72                tags.push('backColor' + backColor);
73            } else {
74                tags.push('backColorFree');
75            }
76        }
77
78        // text color
79        var foreColor;
80        if (element.style.color !== '') {
81            foreColor = colorToHex(element.style.color);
82        } else if (element.hasAttribute('color')) {
83            foreColor = colorToHex(element.getAttribute('color'));
84        }
85        if (foreColor) {
86            if (trumbowyg.o.plugins.colors.colorList.indexOf(foreColor) >= 0) {
87                tags.push('foreColor' + foreColor);
88            } else {
89                tags.push('foreColorFree');
90            }
91        }
92
93        return tags;
94    }
95
96    var defaultOptions = {
97        colorList: ['ffffff', '000000', 'eeece1', '1f497d', '4f81bd', 'c0504d', '9bbb59', '8064a2', '4bacc6', 'f79646', 'ffff00', 'f2f2f2', '7f7f7f', 'ddd9c3', 'c6d9f0', 'dbe5f1', 'f2dcdb', 'ebf1dd', 'e5e0ec', 'dbeef3', 'fdeada', 'fff2ca', 'd8d8d8', '595959', 'c4bd97', '8db3e2', 'b8cce4', 'e5b9b7', 'd7e3bc', 'ccc1d9', 'b7dde8', 'fbd5b5', 'ffe694', 'bfbfbf', '3f3f3f', '938953', '548dd4', '95b3d7', 'd99694', 'c3d69b', 'b2a2c7', 'b7dde8', 'fac08f', 'f2c314', 'a5a5a5', '262
97626', '494429', '17365d', '366092', '953734', '76923c', '5f497a', '92cddc', 'e36c09', 'c09100', '7f7f7f', '0c0c0c', '1d1b10', '0f243e', '244061', '632423', '4f6128', '3f3151', '31859b', '974806', '7f6000']
98    };
99
100    // Add all colors in two dropdowns
101    $.extend(true, $.trumbowyg, {
102        plugins: {
103            color: {
104                init: function (trumbowyg) {
105                    trumbowyg.o.plugins.colors = trumbowyg.o.plugins.colors || defaultOptions;
106                    var foreColorBtnDef = {
107                            dropdown: buildDropdown('foreColor', trumbowyg)
108                        },
109                        backColorBtnDef = {
110                            dropdown: buildDropdown('backColor', trumbowyg)
111                        };
112
113                    trumbowyg.addBtnDef('foreColor', foreColorBtnDef);
114                    trumbowyg.addBtnDef('backColor', backColorBtnDef);
115                },
116                tagHandler: colorTagHandler
117            }
118        }
119    });
120
121    function buildDropdown(fn, trumbowyg) {
122        var dropdown = [];
123
124        $.each(trumbowyg.o.plugins.colors.colorList, function (i, color) {
125            var btn = fn + color,
126                btnDef = {
127                    fn: fn,
128                    forceCss: true,
129                    param: '#' + color,
130                    style: 'background-color: #' + color + ';'
131                };
132            trumbowyg.addBtnDef(btn, btnDef);
133            dropdown.push(btn);
134        });
135
136        var removeColorButtonName = fn + 'Remove',
137            removeColorBtnDef = {
138                fn: 'removeFormat',
139                param: fn,
140                style: 'background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAG0lEQVQIW2NkQAAfEJMRmwBYhoGBYQtMBYoAADziAp0jtJTgAAAAAElFTkSuQmCC);'
141            };
142        trumbowyg.addBtnDef(removeColorButtonName, removeColorBtnDef);
143        dropdown.push(removeColorButtonName);
144
145        // add free color btn
146        var freeColorButtonName = fn + 'Free',
147            freeColorBtnDef = {
148                fn: function () {
149                    trumbowyg.openModalInsert(trumbowyg.lang[fn],
150                        {
151                            color: {
152                                label: fn,
153                                value: '#FFFFFF'
154                            }
155                        },
156                        // callback
157                        function (values) {
158                            trumbowyg.execCmd(fn, values.color);
159                            return true;
160                        }
161                    );
162                },
163                text: '#',
164                // style adjust for displaying the text
165                style: 'text-indent: 0;line-height: 20px;padding: 0 5px;'
166            };
167        trumbowyg.addBtnDef(freeColorButtonName, freeColorBtnDef);
168        dropdown.push(freeColorButtonName);
169
170        return dropdown;
171    }
172})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.