]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/tiny_mce/classes/ui/Toolbar.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / tiny_mce / classes / ui / Toolbar.js
1 /**
2  * Toolbar.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 // Shorten class names
13 var dom = tinymce.DOM, each = tinymce.each;
14 /**
15  * This class is used to create toolbars a toolbar is a container for other controls like buttons etc.
16  *
17  * @class tinymce.ui.Toolbar
18  * @extends tinymce.ui.Container
19  */
20 tinymce.create('tinymce.ui.Toolbar:tinymce.ui.Container', {
21         /**
22          * Renders the toolbar as a HTML string. This method is much faster than using the DOM and when
23          * creating a whole toolbar with buttons it does make a lot of difference.
24          *
25          * @method renderHTML
26          * @return {String} HTML for the toolbar control.
27          */
28         renderHTML : function() {
29                 var t = this, h = '', c, co, s = t.settings, i, pr, nx, cl;
30
31                 cl = t.controls;
32                 for (i=0; i<cl.length; i++) {
33                         // Get current control, prev control, next control and if the control is a list box or not
34                         co = cl[i];
35                         pr = cl[i - 1];
36                         nx = cl[i + 1];
37
38                         // Add toolbar start
39                         if (i === 0) {
40                                 c = 'mceToolbarStart';
41
42                                 if (co.Button)
43                                         c += ' mceToolbarStartButton';
44                                 else if (co.SplitButton)
45                                         c += ' mceToolbarStartSplitButton';
46                                 else if (co.ListBox)
47                                         c += ' mceToolbarStartListBox';
48
49                                 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
50                         }
51
52                         // Add toolbar end before list box and after the previous button
53                         // This is to fix the o2k7 editor skins
54                         if (pr && co.ListBox) {
55                                 if (pr.Button || pr.SplitButton)
56                                         h += dom.createHTML('td', {'class' : 'mceToolbarEnd'}, dom.createHTML('span', null, '<!-- IE -->'));
57                         }
58
59                         // Render control HTML
60
61                         // IE 8 quick fix, needed to propertly generate a hit area for anchors
62                         if (dom.stdMode)
63                                 h += '<td style="position: relative">' + co.renderHTML() + '</td>';
64                         else
65                                 h += '<td>' + co.renderHTML() + '</td>';
66
67                         // Add toolbar start after list box and before the next button
68                         // This is to fix the o2k7 editor skins
69                         if (nx && co.ListBox) {
70                                 if (nx.Button || nx.SplitButton)
71                                         h += dom.createHTML('td', {'class' : 'mceToolbarStart'}, dom.createHTML('span', null, '<!-- IE -->'));
72                         }
73                 }
74
75                 c = 'mceToolbarEnd';
76
77                 if (co.Button)
78                         c += ' mceToolbarEndButton';
79                 else if (co.SplitButton)
80                         c += ' mceToolbarEndSplitButton';
81                 else if (co.ListBox)
82                         c += ' mceToolbarEndListBox';
83
84                 h += dom.createHTML('td', {'class' : c}, dom.createHTML('span', null, '<!-- IE -->'));
85
86                 return dom.createHTML('table', {id : t.id, 'class' : 'mceToolbar' + (s['class'] ? ' ' + s['class'] : ''), cellpadding : '0', cellspacing : '0', align : t.settings.align || '', role: 'presentation', tabindex: '-1'}, '<tbody><tr>' + h + '</tr></tbody>');
87         }
88 });
89 })(tinymce);