]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/tiny_mce/classes/ui/ToolbarGroup.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / tiny_mce / classes / ui / ToolbarGroup.js
1 /**
2  * ToolbarGroup.js
3  *
4  * Copyright 2010, 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 // Shorten class names
13 var dom = tinymce.DOM, each = tinymce.each, Event = tinymce.dom.Event;
14 /**
15  * This class is used to group a set of toolbars together and control the keyboard navigation and focus.
16  *
17  * @class tinymce.ui.ToolbarGroup
18  * @extends tinymce.ui.Container
19  */
20 tinymce.create('tinymce.ui.ToolbarGroup:tinymce.ui.Container', {
21         /**
22          * Renders the toolbar group as a HTML string.
23          *
24          * @method renderHTML
25          * @return {String} HTML for the toolbar control.
26          */
27         renderHTML : function() {
28                 var t = this, h = [], controls = t.controls, each = tinymce.each, settings = t.settings;
29
30                 h.push('<div id="' + t.id + '" role="group" aria-labelledby="' + t.id + '_voice">');
31                 //TODO: ACC test this out - adding a role = application for getting the landmarks working well.
32                 h.push("<span role='application'>");
33                 h.push('<span id="' + t.id + '_voice" class="mceVoiceLabel" style="display:none;">' + dom.encode(settings.name) + '</span>');
34                 each(controls, function(toolbar) {
35                         h.push(toolbar.renderHTML());
36                 });
37                 h.push("</span>");
38                 h.push('</div>');
39
40                 return h.join('');
41         },
42         
43         focus : function() {
44                 this.keyNav.focus();
45         },
46         
47         postRender : function() {
48                 var t = this, items = [];
49
50                 each(t.controls, function(toolbar) {
51                         each (toolbar.controls, function(control) {
52                                 if (control.id) {
53                                         items.push(control);
54                                 }
55                         });
56                 });
57
58                 t.keyNav = new tinymce.ui.KeyboardNavigation({
59                         root: t.id,
60                         items: items,
61                         onCancel: function() {
62                                 t.editor.focus();
63                         },
64                         excludeFromTabOrder: !t.settings.tab_focus_toolbar
65                 });
66         },
67         
68         destroy : function() {
69                 var self = this;
70
71                 self.parent();
72                 self.keyNav.destroy();
73                 Event.clear(self.id);
74         }
75 });
76 })(tinymce);