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