|
1 /** |
|
2 * ColorBox.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 /** |
|
12 * This widget lets you enter colors and browse for colors by pressing the color button. It also displays |
|
13 * a preview of the current color. |
|
14 * |
|
15 * @-x-less ColorBox.less |
|
16 * @class tinymce.ui.ColorBox |
|
17 * @extends tinymce.ui.ComboBox |
|
18 */ |
|
19 define("tinymce/ui/ColorBox", [ |
|
20 "tinymce/ui/ComboBox" |
|
21 ], function(ComboBox) { |
|
22 "use strict"; |
|
23 |
|
24 return ComboBox.extend({ |
|
25 /** |
|
26 * Constructs a new control instance with the specified settings. |
|
27 * |
|
28 * @constructor |
|
29 * @param {Object} settings Name/value object with settings. |
|
30 */ |
|
31 init: function(settings) { |
|
32 var self = this; |
|
33 |
|
34 settings.spellcheck = false; |
|
35 |
|
36 if (settings.onaction) { |
|
37 settings.icon = 'none'; |
|
38 } |
|
39 |
|
40 self._super(settings); |
|
41 |
|
42 self.addClass('colorbox'); |
|
43 self.on('change keyup postrender', function() { |
|
44 self.repaintColor(self.value()); |
|
45 }); |
|
46 }, |
|
47 |
|
48 repaintColor: function(value) { |
|
49 var elm = this.getEl().getElementsByTagName('i')[0]; |
|
50 |
|
51 if (elm) { |
|
52 try { |
|
53 elm.style.background = value; |
|
54 } catch (ex) { |
|
55 // Ignore |
|
56 } |
|
57 } |
|
58 }, |
|
59 |
|
60 value: function(value) { |
|
61 var self = this; |
|
62 |
|
63 if (typeof value != "undefined") { |
|
64 if (self._rendered) { |
|
65 self.repaintColor(value); |
|
66 } |
|
67 } |
|
68 |
|
69 return self._super(value); |
|
70 } |
|
71 }); |
|
72 }); |