]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/classes/ui/ColorButton.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / classes / ui / ColorButton.js
1 /**
2  * ColorButton.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 class creates a color button control. This is a split button in which the main
13  * button has a visual representation of the currently selected color. When clicked 
14  * the caret button displays a color picker, allowing the user to select a new color.
15  *
16  * @-x-less ColorButton.less
17  * @class tinymce.ui.ColorButton
18  * @extends tinymce.ui.PanelButton
19  */
20 define("tinymce/ui/ColorButton", [
21         "tinymce/ui/PanelButton",
22         "tinymce/dom/DOMUtils"
23 ], function(PanelButton, DomUtils) {
24         "use strict";
25         
26         var DOM = DomUtils.DOM;
27
28         return PanelButton.extend({
29                 /**
30                  * Constructs a new ColorButton instance with the specified settings.
31                  *
32                  * @constructor
33                  * @param {Object} settings Name/value object with settings.
34                  */
35                 init: function(settings) {
36                         this._super(settings);
37                         this.addClass('colorbutton');
38                 },
39
40                 /**
41                  * Getter/setter for the current color.
42                  *
43                  * @method color
44                  * @param {String} [color] Color to set.
45                  * @return {String|tinymce.ui.ColorButton} Current color or current instance.
46                  */
47                 color: function(color) {
48                         if (color) {
49                                 this._color = color;
50                                 this.getEl('preview').style.backgroundColor = color;
51                                 return this;
52                         }
53
54                         return this._color;
55                 },
56
57                 /**
58                  * Renders the control as a HTML string.
59                  *
60                  * @method renderHtml
61                  * @return {String} HTML representing the control.
62                  */
63                 renderHtml: function() {
64                         var self = this, id = self._id, prefix = self.classPrefix;
65                         var icon = self.settings.icon ? prefix + 'ico ' + prefix + 'i-' + self.settings.icon : '';
66                         var image = self.settings.image ? ' style="background-image: url(\'' + self.settings.image + '\')"' : '';
67
68                         return (
69                                 '<div id="' + id + '" class="' + self.classes() + '">' +
70                                         '<button role="presentation" hidefocus type="button" tabindex="-1">' +
71                                                 (icon ? '<i class="' + icon + '"' + image + '></i>' : '') +
72                                                 '<span id="' + id + '-preview" class="' + prefix + 'preview"></span>' +
73                                                 (self._text ? (icon ? ' ' : '') + (self._text) : '') +
74                                         '</button>' +
75                                         '<button type="button" class="' + prefix + 'open" hidefocus tabindex="-1">' +
76                                                 ' <i class="' + prefix + 'caret"></i>' +
77                                         '</button>' +
78                                 '</div>'
79                         );
80                 },
81                 
82                 /**
83                  * Called after the control has been rendered.
84                  *
85                  * @method postRender
86                  */
87                 postRender: function() {
88                         var self = this, onClickHandler = self.settings.onclick;
89
90                         self.on('click', function(e) {
91                                 if (e.control == self && !DOM.getParent(e.target, '.' + self.classPrefix + 'open')) {
92                                         e.stopImmediatePropagation();
93                                         onClickHandler.call(self, e);
94                                 }
95                         });
96
97                         delete self.settings.onclick;
98
99                         return self._super();
100                 }
101                 
102         });
103 });