]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/classes/ui/Label.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 / Label.js
1 /**
2  * Label.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 label element. A label is a simple text control
13  * that can be bound to other controls.
14  *
15  * @-x-less Label.less
16  * @class tinymce.ui.Label
17  * @extends tinymce.ui.Widget
18  */
19 define("tinymce/ui/Label", [
20         "tinymce/ui/Widget"
21 ], function(Widget) {
22         "use strict";
23
24         return Widget.extend({
25                 /**
26                  * Constructs a instance with the specified settings.
27                  *
28                  * @constructor
29                  * @param {Object} settings Name/value object with settings.
30                  * @param {Boolean} multiline Multiline label.
31                  */
32                 init: function(settings) {
33                         var self = this;
34
35                         self._super(settings);
36                         self.addClass('widget');
37                         self.addClass('label');
38                         self.canFocus = false;
39
40                         if (settings.multiline) {
41                                 self.addClass('autoscroll');
42                         }
43
44                         if (settings.strong) {
45                                 self.addClass('strong');
46                         }
47                 },
48
49                 /**
50                  * Initializes the current controls layout rect.
51                  * This will be executed by the layout managers to determine the
52                  * default minWidth/minHeight etc.
53                  *
54                  * @method initLayoutRect
55                  * @return {Object} Layout rect instance.
56                  */
57                 initLayoutRect: function() {
58                         var self = this, layoutRect = self._super();
59
60                         if (self.settings.multiline) {
61                                 // Check if the text fits within maxW if not then try word wrapping it
62                                 if (self.getEl().offsetWidth > layoutRect.maxW) {
63                                         layoutRect.minW = layoutRect.maxW;
64                                         self.addClass('multiline');
65                                 }
66
67                                 self.getEl().style.width = layoutRect.minW + 'px';
68                                 layoutRect.startMinH = layoutRect.h = layoutRect.minH = Math.min(layoutRect.maxH, self.getEl().offsetHeight);
69                         }
70
71                         return layoutRect;
72                 },
73
74                 /**
75                  * Sets/gets the disabled state on the control.
76                  *
77                  * @method disabled
78                  * @param {Boolean} state Value to set to control.
79                  * @return {Boolean/tinymce.ui.Label} Current control on a set operation or current state on a get.
80                  */
81                 disabled: function(state) {
82                         var self = this, undef;
83
84                         if (state !== undef) {
85                                 self.toggleClass('label-disabled', state);
86
87                                 if (self._rendered) {
88                                         self.getEl()[0].className = self.classes();
89                                 }
90                         }
91
92                         return self._super(state);
93                 },
94
95                 /**
96                  * Repaints the control after a layout operation.
97                  *
98                  * @method repaint
99                  */
100                 repaint: function() {
101                         var self = this;
102
103                         if (!self.settings.multiline) {
104                                 self.getEl().style.lineHeight = self.layoutRect().h + 'px';
105                         }
106
107                         return self._super();
108                 },
109
110                 /**
111                  * Sets/gets the current label text.
112                  *
113                  * @method text
114                  * @param {String} [text] New label text.
115                  * @return {String|tinymce.ui.Label} Current text or current label instance.
116                  */
117                 text: function(text) {
118                         var self = this;
119
120                         if (self._rendered && text) {
121                                 this.innerHtml(self.encode(text));
122                         }
123
124                         return self._super(text);
125                 },
126
127                 /**
128                  * Renders the control as a HTML string.
129                  *
130                  * @method renderHtml
131                  * @return {String} HTML representing the control.
132                  */
133                 renderHtml: function() {
134                         var self = this, forId = self.settings.forId;
135
136                         return (
137                                 '<label id="' + self._id + '" class="' + self.classes() + '"' + (forId ? ' for="' + forId : '') + '">' +
138                                         self.encode(self._text) +
139                                 '</label>'
140                         );
141                 }
142         });
143 });