]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/plugins/advlist/plugin.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / plugins / advlist / plugin.js
1 /**
2  * plugin.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 /*global tinymce:true */
12
13 tinymce.PluginManager.add('advlist', function(editor) {
14         var olMenuItems, ulMenuItems, lastStyles = {};
15
16         function buildMenuItems(listName, styleValues) {
17                 var items = [];
18
19                 tinymce.each(styleValues.split(/[ ,]/), function(styleValue) {
20                         items.push({
21                                 text: styleValue.replace(/\-/g, ' ').replace(/\b\w/g, function(chr) {return chr.toUpperCase();}),
22                                 data: styleValue == 'default' ? '' : styleValue
23                         });
24                 });
25
26                 return items;
27         }
28
29         olMenuItems = buildMenuItems('OL', editor.getParam(
30                 "advlist_number_styles",
31                 "default,lower-alpha,lower-greek,lower-roman,upper-alpha,upper-roman"
32         ));
33
34         ulMenuItems = buildMenuItems('UL', editor.getParam("advlist_bullet_styles", "default,circle,disc,square"));
35
36         function applyListFormat(listName, styleValue) {
37                 var list, dom = editor.dom, sel = editor.selection;
38
39                 // Check for existing list element
40                 list = dom.getParent(sel.getNode(), 'ol,ul');
41
42                 // Switch/add list type if needed
43                 if (!list || list.nodeName != listName || styleValue === false) {
44                         editor.execCommand(listName == 'UL' ? 'InsertUnorderedList' : 'InsertOrderedList');
45                 }
46
47                 // Set style
48                 styleValue = styleValue === false ? lastStyles[listName] : styleValue;
49                 lastStyles[listName] = styleValue;
50
51                 list = dom.getParent(sel.getNode(), 'ol,ul');
52                 if (list) {
53                         dom.setStyle(list, 'listStyleType', styleValue);
54                         list.removeAttribute('data-mce-style');
55                 }
56
57                 editor.focus();
58         }
59
60         function updateSelection(e) {
61                 var listStyleType = editor.dom.getStyle(editor.dom.getParent(editor.selection.getNode(), 'ol,ul'), 'listStyleType') || '';
62
63                 e.control.items().each(function(ctrl) {
64                         ctrl.active(ctrl.settings.data === listStyleType);
65                 });
66         }
67
68         editor.addButton('numlist', {
69                 type: 'splitbutton',
70                 tooltip: 'Numbered list',
71                 menu: olMenuItems,
72                 onshow: updateSelection,
73                 onselect: function(e) {
74                         applyListFormat('OL', e.control.settings.data);
75                 },
76                 onclick: function() {
77                         applyListFormat('OL', false);
78                 }
79         });
80
81         editor.addButton('bullist', {
82                 type: 'splitbutton',
83                 tooltip: 'Bullet list',
84                 menu: ulMenuItems,
85                 onshow: updateSelection,
86                 onselect: function(e) {
87                         applyListFormat('UL', e.control.settings.data);
88                 },
89                 onclick: function() {
90                         applyListFormat('UL', false);
91                 }
92         });
93 });