1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* MenuItem.js
*
* Copyright 2009, Moxiecode Systems AB
* Released under LGPL License.
*
* License: http://tinymce.moxiecode.com/license
* Contributing: http://tinymce.moxiecode.com/contributing
*/
(function(tinymce) {
var is = tinymce.is, DOM = tinymce.DOM, each = tinymce.each, walk = tinymce.walk;
/**
* This class is base class for all menu item types like DropMenus items etc. This class should not
* be instantiated directly other menu items should inherit from this one.
*
* @class tinymce.ui.MenuItem
* @extends tinymce.ui.Control
*/
tinymce.create('tinymce.ui.MenuItem:tinymce.ui.Control', {
/**
* Constructs a new button control instance.
*
* @constructor
* @method MenuItem
* @param {String} id Button control id for the button.
* @param {Object} s Optional name/value settings object.
*/
MenuItem : function(id, s) {
this.parent(id, s);
this.classPrefix = 'mceMenuItem';
},
/**
* Sets the selected state for the control. This will add CSS classes to the
* element that contains the control. So that it can be selected visually.
*
* @method setSelected
* @param {Boolean} s Boolean state if the control should be selected or not.
*/
setSelected : function(s) {
this.setState('Selected', s);
this.setAriaProperty('checked', !!s);
this.selected = s;
},
/**
* Returns true/false if the control is selected or not.
*
* @method isSelected
* @return {Boolean} true/false if the control is selected or not.
*/
isSelected : function() {
return this.selected;
},
/**
* Post render handler. This function will be called after the UI has been
* rendered so that events can be added.
*
* @method postRender
*/
postRender : function() {
var t = this;
t.parent();
// Set pending state
if (is(t.selected))
t.setSelected(t.selected);
}
});
})(tinymce);