mirador_rails 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -0
  3. data/app/controllers/mirador_rails/locales_controller.rb +10 -0
  4. data/config/routes.rb +7 -0
  5. data/lib/mirador_rails/exceptions.rb +6 -0
  6. data/lib/mirador_rails/locale.rb +24 -0
  7. data/lib/mirador_rails/version.rb +1 -1
  8. data/lib/mirador_rails.rb +9 -2
  9. data/mirador_rails.gemspec +3 -0
  10. data/tasks/mirador_rails.rake +44 -10
  11. data/vendor/assets/images/border_type_4.png +0 -0
  12. data/vendor/assets/images/border_type_5.png +0 -0
  13. data/vendor/assets/javascripts/mirador/mirador.js.erb +20105 -0
  14. data/vendor/assets/javascripts/mirador.js +4 -1
  15. data/vendor/assets/locales/de/translation.json +3 -0
  16. data/vendor/assets/locales/en/translation.json +11 -7
  17. data/vendor/assets/locales/ko/translation.json +18 -9
  18. data/vendor/assets/stylesheets/enhancements.scss +36 -0
  19. data/vendor/assets/stylesheets/mirador-combined.css +1488 -1642
  20. data/vendor/assets/stylesheets/mirador.css +1 -0
  21. metadata +52 -174
  22. data/vendor/assets/javascripts/mirador.min.js +0 -89
  23. data/vendor/assets/javascripts/mirador.min.js.map +0 -1
  24. data/vendor/assets/plugins/plugins/advlist/plugin.js +0 -97
  25. data/vendor/assets/plugins/plugins/advlist/plugin.min.js +0 -1
  26. data/vendor/assets/plugins/plugins/anchor/plugin.js +0 -45
  27. data/vendor/assets/plugins/plugins/anchor/plugin.min.js +0 -1
  28. data/vendor/assets/plugins/plugins/autolink/plugin.js +0 -194
  29. data/vendor/assets/plugins/plugins/autolink/plugin.min.js +0 -1
  30. data/vendor/assets/plugins/plugins/autoresize/plugin.js +0 -152
  31. data/vendor/assets/plugins/plugins/autoresize/plugin.min.js +0 -1
  32. data/vendor/assets/plugins/plugins/autosave/plugin.js +0 -165
  33. data/vendor/assets/plugins/plugins/autosave/plugin.min.js +0 -1
  34. data/vendor/assets/plugins/plugins/bbcode/plugin.js +0 -123
  35. data/vendor/assets/plugins/plugins/bbcode/plugin.min.js +0 -1
  36. data/vendor/assets/plugins/plugins/charmap/plugin.js +0 -370
  37. data/vendor/assets/plugins/plugins/charmap/plugin.min.js +0 -1
  38. data/vendor/assets/plugins/plugins/code/plugin.js +0 -60
  39. data/vendor/assets/plugins/plugins/code/plugin.min.js +0 -1
  40. data/vendor/assets/plugins/plugins/colorpicker/plugin.js +0 -112
  41. data/vendor/assets/plugins/plugins/colorpicker/plugin.min.js +0 -1
  42. data/vendor/assets/plugins/plugins/compat3x/css/dialog.css +0 -118
  43. data/vendor/assets/plugins/plugins/compat3x/img/buttons.png +0 -0
  44. data/vendor/assets/plugins/plugins/compat3x/img/icons.gif +0 -0
  45. data/vendor/assets/plugins/plugins/compat3x/img/items.gif +0 -0
  46. data/vendor/assets/plugins/plugins/compat3x/img/menu_arrow.gif +0 -0
  47. data/vendor/assets/plugins/plugins/compat3x/img/menu_check.gif +0 -0
  48. data/vendor/assets/plugins/plugins/compat3x/img/progress.gif +0 -0
  49. data/vendor/assets/plugins/plugins/compat3x/img/tabs.gif +0 -0
  50. data/vendor/assets/plugins/plugins/compat3x/plugin.js +0 -297
  51. data/vendor/assets/plugins/plugins/compat3x/plugin.min.js +0 -1
  52. data/vendor/assets/plugins/plugins/compat3x/tiny_mce_popup.js +0 -542
  53. data/vendor/assets/plugins/plugins/compat3x/utils/editable_selects.js +0 -70
  54. data/vendor/assets/plugins/plugins/compat3x/utils/form_utils.js +0 -210
  55. data/vendor/assets/plugins/plugins/compat3x/utils/mctabs.js +0 -164
  56. data/vendor/assets/plugins/plugins/compat3x/utils/validate.js +0 -252
  57. data/vendor/assets/plugins/plugins/contextmenu/plugin.js +0 -87
  58. data/vendor/assets/plugins/plugins/contextmenu/plugin.min.js +0 -1
  59. data/vendor/assets/plugins/plugins/directionality/plugin.js +0 -64
  60. data/vendor/assets/plugins/plugins/directionality/plugin.min.js +0 -1
  61. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cool.gif +0 -0
  62. data/vendor/assets/plugins/plugins/emoticons/img/smiley-cry.gif +0 -0
  63. data/vendor/assets/plugins/plugins/emoticons/img/smiley-embarassed.gif +0 -0
  64. data/vendor/assets/plugins/plugins/emoticons/img/smiley-foot-in-mouth.gif +0 -0
  65. data/vendor/assets/plugins/plugins/emoticons/img/smiley-frown.gif +0 -0
  66. data/vendor/assets/plugins/plugins/emoticons/img/smiley-innocent.gif +0 -0
  67. data/vendor/assets/plugins/plugins/emoticons/img/smiley-kiss.gif +0 -0
  68. data/vendor/assets/plugins/plugins/emoticons/img/smiley-laughing.gif +0 -0
  69. data/vendor/assets/plugins/plugins/emoticons/img/smiley-money-mouth.gif +0 -0
  70. data/vendor/assets/plugins/plugins/emoticons/img/smiley-sealed.gif +0 -0
  71. data/vendor/assets/plugins/plugins/emoticons/img/smiley-smile.gif +0 -0
  72. data/vendor/assets/plugins/plugins/emoticons/img/smiley-surprised.gif +0 -0
  73. data/vendor/assets/plugins/plugins/emoticons/img/smiley-tongue-out.gif +0 -0
  74. data/vendor/assets/plugins/plugins/emoticons/img/smiley-undecided.gif +0 -0
  75. data/vendor/assets/plugins/plugins/emoticons/img/smiley-wink.gif +0 -0
  76. data/vendor/assets/plugins/plugins/emoticons/img/smiley-yell.gif +0 -0
  77. data/vendor/assets/plugins/plugins/emoticons/plugin.js +0 -65
  78. data/vendor/assets/plugins/plugins/emoticons/plugin.min.js +0 -1
  79. data/vendor/assets/plugins/plugins/example/dialog.html +0 -8
  80. data/vendor/assets/plugins/plugins/example/plugin.js +0 -68
  81. data/vendor/assets/plugins/plugins/example/plugin.min.js +0 -1
  82. data/vendor/assets/plugins/plugins/example_dependency/plugin.js +0 -22
  83. data/vendor/assets/plugins/plugins/example_dependency/plugin.min.js +0 -1
  84. data/vendor/assets/plugins/plugins/fullpage/plugin.js +0 -490
  85. data/vendor/assets/plugins/plugins/fullpage/plugin.min.js +0 -1
  86. data/vendor/assets/plugins/plugins/fullscreen/plugin.js +0 -136
  87. data/vendor/assets/plugins/plugins/fullscreen/plugin.min.js +0 -1
  88. data/vendor/assets/plugins/plugins/hr/plugin.js +0 -30
  89. data/vendor/assets/plugins/plugins/hr/plugin.min.js +0 -1
  90. data/vendor/assets/plugins/plugins/image/plugin.js +0 -439
  91. data/vendor/assets/plugins/plugins/image/plugin.min.js +0 -1
  92. data/vendor/assets/plugins/plugins/importcss/plugin.js +0 -195
  93. data/vendor/assets/plugins/plugins/importcss/plugin.min.js +0 -1
  94. data/vendor/assets/plugins/plugins/insertdatetime/plugin.js +0 -121
  95. data/vendor/assets/plugins/plugins/insertdatetime/plugin.min.js +0 -1
  96. data/vendor/assets/plugins/plugins/layer/plugin.js +0 -225
  97. data/vendor/assets/plugins/plugins/layer/plugin.min.js +0 -1
  98. data/vendor/assets/plugins/plugins/legacyoutput/plugin.js +0 -211
  99. data/vendor/assets/plugins/plugins/legacyoutput/plugin.min.js +0 -1
  100. data/vendor/assets/plugins/plugins/link/plugin.js +0 -400
  101. data/vendor/assets/plugins/plugins/link/plugin.min.js +0 -1
  102. data/vendor/assets/plugins/plugins/lists/plugin.js +0 -791
  103. data/vendor/assets/plugins/plugins/lists/plugin.min.js +0 -1
  104. data/vendor/assets/plugins/plugins/media/moxieplayer.swf +0 -0
  105. data/vendor/assets/plugins/plugins/media/plugin.js +0 -774
  106. data/vendor/assets/plugins/plugins/media/plugin.min.js +0 -1
  107. data/vendor/assets/plugins/plugins/nonbreaking/plugin.js +0 -53
  108. data/vendor/assets/plugins/plugins/nonbreaking/plugin.min.js +0 -1
  109. data/vendor/assets/plugins/plugins/noneditable/plugin.js +0 -540
  110. data/vendor/assets/plugins/plugins/noneditable/plugin.min.js +0 -1
  111. data/vendor/assets/plugins/plugins/pagebreak/plugin.js +0 -88
  112. data/vendor/assets/plugins/plugins/pagebreak/plugin.min.js +0 -1
  113. data/vendor/assets/plugins/plugins/paste/classes/Clipboard.js +0 -634
  114. data/vendor/assets/plugins/plugins/paste/classes/Plugin.js +0 -110
  115. data/vendor/assets/plugins/plugins/paste/classes/Quirks.js +0 -159
  116. data/vendor/assets/plugins/plugins/paste/classes/Utils.js +0 -130
  117. data/vendor/assets/plugins/plugins/paste/classes/WordFilter.js +0 -493
  118. data/vendor/assets/plugins/plugins/paste/plugin.dev.js +0 -120
  119. data/vendor/assets/plugins/plugins/paste/plugin.js +0 -1625
  120. data/vendor/assets/plugins/plugins/paste/plugin.min.js +0 -1
  121. data/vendor/assets/plugins/plugins/preview/plugin.js +0 -88
  122. data/vendor/assets/plugins/plugins/preview/plugin.min.js +0 -1
  123. data/vendor/assets/plugins/plugins/print/plugin.js +0 -32
  124. data/vendor/assets/plugins/plugins/print/plugin.min.js +0 -1
  125. data/vendor/assets/plugins/plugins/save/plugin.js +0 -94
  126. data/vendor/assets/plugins/plugins/save/plugin.min.js +0 -1
  127. data/vendor/assets/plugins/plugins/searchreplace/plugin.js +0 -594
  128. data/vendor/assets/plugins/plugins/searchreplace/plugin.min.js +0 -1
  129. data/vendor/assets/plugins/plugins/spellchecker/classes/DomTextMatcher.js +0 -470
  130. data/vendor/assets/plugins/plugins/spellchecker/classes/Plugin.js +0 -436
  131. data/vendor/assets/plugins/plugins/spellchecker/plugin.dev.js +0 -117
  132. data/vendor/assets/plugins/plugins/spellchecker/plugin.js +0 -996
  133. data/vendor/assets/plugins/plugins/spellchecker/plugin.min.js +0 -1
  134. data/vendor/assets/plugins/plugins/tabfocus/plugin.js +0 -120
  135. data/vendor/assets/plugins/plugins/tabfocus/plugin.min.js +0 -1
  136. data/vendor/assets/plugins/plugins/table/classes/CellSelection.js +0 -176
  137. data/vendor/assets/plugins/plugins/table/classes/Dialogs.js +0 -749
  138. data/vendor/assets/plugins/plugins/table/classes/Plugin.js +0 -422
  139. data/vendor/assets/plugins/plugins/table/classes/Quirks.js +0 -372
  140. data/vendor/assets/plugins/plugins/table/classes/TableGrid.js +0 -864
  141. data/vendor/assets/plugins/plugins/table/plugin.dev.js +0 -118
  142. data/vendor/assets/plugins/plugins/table/plugin.js +0 -2680
  143. data/vendor/assets/plugins/plugins/table/plugin.min.js +0 -1
  144. data/vendor/assets/plugins/plugins/template/plugin.js +0 -262
  145. data/vendor/assets/plugins/plugins/template/plugin.min.js +0 -1
  146. data/vendor/assets/plugins/plugins/textcolor/plugin.js +0 -272
  147. data/vendor/assets/plugins/plugins/textcolor/plugin.min.js +0 -1
  148. data/vendor/assets/plugins/plugins/textpattern/plugin.js +0 -268
  149. data/vendor/assets/plugins/plugins/textpattern/plugin.min.js +0 -1
  150. data/vendor/assets/plugins/plugins/visualblocks/css/visualblocks.css +0 -135
  151. data/vendor/assets/plugins/plugins/visualblocks/img/address.gif +0 -0
  152. data/vendor/assets/plugins/plugins/visualblocks/img/article.gif +0 -0
  153. data/vendor/assets/plugins/plugins/visualblocks/img/aside.gif +0 -0
  154. data/vendor/assets/plugins/plugins/visualblocks/img/blockquote.gif +0 -0
  155. data/vendor/assets/plugins/plugins/visualblocks/img/div.gif +0 -0
  156. data/vendor/assets/plugins/plugins/visualblocks/img/dl.gif +0 -0
  157. data/vendor/assets/plugins/plugins/visualblocks/img/figure.gif +0 -0
  158. data/vendor/assets/plugins/plugins/visualblocks/img/h1.gif +0 -0
  159. data/vendor/assets/plugins/plugins/visualblocks/img/h2.gif +0 -0
  160. data/vendor/assets/plugins/plugins/visualblocks/img/h3.gif +0 -0
  161. data/vendor/assets/plugins/plugins/visualblocks/img/h4.gif +0 -0
  162. data/vendor/assets/plugins/plugins/visualblocks/img/h5.gif +0 -0
  163. data/vendor/assets/plugins/plugins/visualblocks/img/h6.gif +0 -0
  164. data/vendor/assets/plugins/plugins/visualblocks/img/hgroup.gif +0 -0
  165. data/vendor/assets/plugins/plugins/visualblocks/img/ol.gif +0 -0
  166. data/vendor/assets/plugins/plugins/visualblocks/img/p.gif +0 -0
  167. data/vendor/assets/plugins/plugins/visualblocks/img/pre.gif +0 -0
  168. data/vendor/assets/plugins/plugins/visualblocks/img/section.gif +0 -0
  169. data/vendor/assets/plugins/plugins/visualblocks/img/ul.gif +0 -0
  170. data/vendor/assets/plugins/plugins/visualblocks/plugin.js +0 -86
  171. data/vendor/assets/plugins/plugins/visualblocks/plugin.min.js +0 -1
  172. data/vendor/assets/plugins/plugins/visualchars/plugin.js +0 -88
  173. data/vendor/assets/plugins/plugins/visualchars/plugin.min.js +0 -1
  174. data/vendor/assets/plugins/plugins/wordcount/plugin.js +0 -69
  175. data/vendor/assets/plugins/plugins/wordcount/plugin.min.js +0 -1
  176. data/vendor/assets/skins/skins/lightgray/content.inline.min.css +0 -1
  177. data/vendor/assets/skins/skins/lightgray/content.min.css +0 -1
  178. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.eot +0 -0
  179. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.svg +0 -62
  180. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.ttf +0 -0
  181. data/vendor/assets/skins/skins/lightgray/fonts/tinymce-small.woff +0 -0
  182. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.eot +0 -0
  183. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.svg +0 -63
  184. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.ttf +0 -0
  185. data/vendor/assets/skins/skins/lightgray/fonts/tinymce.woff +0 -0
  186. data/vendor/assets/skins/skins/lightgray/img/anchor.gif +0 -0
  187. data/vendor/assets/skins/skins/lightgray/img/loader.gif +0 -0
  188. data/vendor/assets/skins/skins/lightgray/img/object.gif +0 -0
  189. data/vendor/assets/skins/skins/lightgray/img/trans.gif +0 -0
  190. data/vendor/assets/skins/skins/lightgray/skin.ie7.min.css +0 -1
  191. data/vendor/assets/skins/skins/lightgray/skin.min.css +0 -1
  192. data/vendor/assets/themes/themes/modern/theme.js +0 -617
  193. data/vendor/assets/themes/themes/modern/theme.min.js +0 -1
@@ -1,791 +0,0 @@
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
- /*eslint consistent-this:0 */
13
-
14
- tinymce.PluginManager.add('lists', function(editor) {
15
- var self = this;
16
-
17
- function isListNode(node) {
18
- return node && (/^(OL|UL|DL)$/).test(node.nodeName);
19
- }
20
-
21
- function isFirstChild(node) {
22
- return node.parentNode.firstChild == node;
23
- }
24
-
25
- function isLastChild(node) {
26
- return node.parentNode.lastChild == node;
27
- }
28
-
29
- function isTextBlock(node) {
30
- return node && !!editor.schema.getTextBlockElements()[node.nodeName];
31
- }
32
-
33
- editor.on('init', function() {
34
- var dom = editor.dom, selection = editor.selection;
35
-
36
- /**
37
- * Returns a range bookmark. This will convert indexed bookmarks into temporary span elements with
38
- * index 0 so that they can be restored properly after the DOM has been modified. Text bookmarks will not have spans
39
- * added to them since they can be restored after a dom operation.
40
- *
41
- * So this: <p><b>|</b><b>|</b></p>
42
- * becomes: <p><b><span data-mce-type="bookmark">|</span></b><b data-mce-type="bookmark">|</span></b></p>
43
- *
44
- * @param {DOMRange} rng DOM Range to get bookmark on.
45
- * @return {Object} Bookmark object.
46
- */
47
- function createBookmark(rng) {
48
- var bookmark = {};
49
-
50
- function setupEndPoint(start) {
51
- var offsetNode, container, offset;
52
-
53
- container = rng[start ? 'startContainer' : 'endContainer'];
54
- offset = rng[start ? 'startOffset' : 'endOffset'];
55
-
56
- if (container.nodeType == 1) {
57
- offsetNode = dom.create('span', {'data-mce-type': 'bookmark'});
58
-
59
- if (container.hasChildNodes()) {
60
- offset = Math.min(offset, container.childNodes.length - 1);
61
-
62
- if (start) {
63
- container.insertBefore(offsetNode, container.childNodes[offset]);
64
- } else {
65
- dom.insertAfter(offsetNode, container.childNodes[offset]);
66
- }
67
- } else {
68
- container.appendChild(offsetNode);
69
- }
70
-
71
- container = offsetNode;
72
- offset = 0;
73
- }
74
-
75
- bookmark[start ? 'startContainer' : 'endContainer'] = container;
76
- bookmark[start ? 'startOffset' : 'endOffset'] = offset;
77
- }
78
-
79
- setupEndPoint(true);
80
-
81
- if (!rng.collapsed) {
82
- setupEndPoint();
83
- }
84
-
85
- return bookmark;
86
- }
87
-
88
- /**
89
- * Moves the selection to the current bookmark and removes any selection container wrappers.
90
- *
91
- * @param {Object} bookmark Bookmark object to move selection to.
92
- */
93
- function moveToBookmark(bookmark) {
94
- function restoreEndPoint(start) {
95
- var container, offset, node;
96
-
97
- function nodeIndex(container) {
98
- var node = container.parentNode.firstChild, idx = 0;
99
-
100
- while (node) {
101
- if (node == container) {
102
- return idx;
103
- }
104
-
105
- // Skip data-mce-type=bookmark nodes
106
- if (node.nodeType != 1 || node.getAttribute('data-mce-type') != 'bookmark') {
107
- idx++;
108
- }
109
-
110
- node = node.nextSibling;
111
- }
112
-
113
- return -1;
114
- }
115
-
116
- container = node = bookmark[start ? 'startContainer' : 'endContainer'];
117
- offset = bookmark[start ? 'startOffset' : 'endOffset'];
118
-
119
- if (!container) {
120
- return;
121
- }
122
-
123
- if (container.nodeType == 1) {
124
- offset = nodeIndex(container);
125
- container = container.parentNode;
126
- dom.remove(node);
127
- }
128
-
129
- bookmark[start ? 'startContainer' : 'endContainer'] = container;
130
- bookmark[start ? 'startOffset' : 'endOffset'] = offset;
131
- }
132
-
133
- restoreEndPoint(true);
134
- restoreEndPoint();
135
-
136
- var rng = dom.createRng();
137
-
138
- rng.setStart(bookmark.startContainer, bookmark.startOffset);
139
-
140
- if (bookmark.endContainer) {
141
- rng.setEnd(bookmark.endContainer, bookmark.endOffset);
142
- }
143
-
144
- selection.setRng(rng);
145
- }
146
-
147
- function createNewTextBlock(contentNode, blockName) {
148
- var node, textBlock, fragment = dom.createFragment(), hasContentNode;
149
- var blockElements = editor.schema.getBlockElements();
150
-
151
- if (editor.settings.forced_root_block) {
152
- blockName = blockName || editor.settings.forced_root_block;
153
- }
154
-
155
- if (blockName) {
156
- textBlock = dom.create(blockName);
157
-
158
- if (textBlock.tagName === editor.settings.forced_root_block) {
159
- dom.setAttribs(textBlock, editor.settings.forced_root_block_attrs);
160
- }
161
-
162
- fragment.appendChild(textBlock);
163
- }
164
-
165
- if (contentNode) {
166
- while ((node = contentNode.firstChild)) {
167
- var nodeName = node.nodeName;
168
-
169
- if (!hasContentNode && (nodeName != 'SPAN' || node.getAttribute('data-mce-type') != 'bookmark')) {
170
- hasContentNode = true;
171
- }
172
-
173
- if (blockElements[nodeName]) {
174
- fragment.appendChild(node);
175
- textBlock = null;
176
- } else {
177
- if (blockName) {
178
- if (!textBlock) {
179
- textBlock = dom.create(blockName);
180
- fragment.appendChild(textBlock);
181
- }
182
-
183
- textBlock.appendChild(node);
184
- } else {
185
- fragment.appendChild(node);
186
- }
187
- }
188
- }
189
- }
190
-
191
- if (!editor.settings.forced_root_block) {
192
- fragment.appendChild(dom.create('br'));
193
- } else {
194
- // BR is needed in empty blocks on non IE browsers
195
- if (!hasContentNode && (!tinymce.Env.ie || tinymce.Env.ie > 10)) {
196
- textBlock.appendChild(dom.create('br', {'data-mce-bogus': '1'}));
197
- }
198
- }
199
-
200
- return fragment;
201
- }
202
-
203
- function getSelectedListItems() {
204
- return tinymce.grep(selection.getSelectedBlocks(), function(block) {
205
- return /^(LI|DT|DD)$/.test(block.nodeName);
206
- });
207
- }
208
-
209
- function splitList(ul, li, newBlock) {
210
- var tmpRng, fragment;
211
-
212
- var bookmarks = dom.select('span[data-mce-type="bookmark"]', ul);
213
-
214
- newBlock = newBlock || createNewTextBlock(li);
215
- tmpRng = dom.createRng();
216
- tmpRng.setStartAfter(li);
217
- tmpRng.setEndAfter(ul);
218
- fragment = tmpRng.extractContents();
219
-
220
- if (!dom.isEmpty(fragment)) {
221
- dom.insertAfter(fragment, ul);
222
- }
223
-
224
- dom.insertAfter(newBlock, ul);
225
-
226
- if (dom.isEmpty(li.parentNode)) {
227
- tinymce.each(bookmarks, function(node) {
228
- li.parentNode.parentNode.insertBefore(node, li.parentNode);
229
- });
230
-
231
- dom.remove(li.parentNode);
232
- }
233
-
234
- dom.remove(li);
235
- }
236
-
237
- function mergeWithAdjacentLists(listBlock) {
238
- var sibling, node;
239
-
240
- sibling = listBlock.nextSibling;
241
- if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName) {
242
- while ((node = sibling.firstChild)) {
243
- listBlock.appendChild(node);
244
- }
245
-
246
- dom.remove(sibling);
247
- }
248
-
249
- sibling = listBlock.previousSibling;
250
- if (sibling && isListNode(sibling) && sibling.nodeName == listBlock.nodeName) {
251
- while ((node = sibling.firstChild)) {
252
- listBlock.insertBefore(node, listBlock.firstChild);
253
- }
254
-
255
- dom.remove(sibling);
256
- }
257
- }
258
-
259
- /**
260
- * Normalizes the all lists in the specified element.
261
- */
262
- function normalizeList(element) {
263
- tinymce.each(tinymce.grep(dom.select('ol,ul', element)), function(ul) {
264
- var sibling, parentNode = ul.parentNode;
265
-
266
- // Move UL/OL to previous LI if it's the only child of a LI
267
- if (parentNode.nodeName == 'LI' && parentNode.firstChild == ul) {
268
- sibling = parentNode.previousSibling;
269
- if (sibling && sibling.nodeName == 'LI') {
270
- sibling.appendChild(ul);
271
-
272
- if (dom.isEmpty(parentNode)) {
273
- dom.remove(parentNode);
274
- }
275
- }
276
- }
277
-
278
- // Append OL/UL to previous LI if it's in a parent OL/UL i.e. old HTML4
279
- if (isListNode(parentNode)) {
280
- sibling = parentNode.previousSibling;
281
- if (sibling && sibling.nodeName == 'LI') {
282
- sibling.appendChild(ul);
283
- }
284
- }
285
- });
286
- }
287
-
288
- function outdent(li) {
289
- var ul = li.parentNode, ulParent = ul.parentNode, newBlock;
290
-
291
- function removeEmptyLi(li) {
292
- if (dom.isEmpty(li)) {
293
- dom.remove(li);
294
- }
295
- }
296
-
297
- if (li.nodeName == 'DD') {
298
- dom.rename(li, 'DT');
299
- return true;
300
- }
301
-
302
- if (isFirstChild(li) && isLastChild(li)) {
303
- if (ulParent.nodeName == "LI") {
304
- dom.insertAfter(li, ulParent);
305
- removeEmptyLi(ulParent);
306
- dom.remove(ul);
307
- } else if (isListNode(ulParent)) {
308
- dom.remove(ul, true);
309
- } else {
310
- ulParent.insertBefore(createNewTextBlock(li), ul);
311
- dom.remove(ul);
312
- }
313
-
314
- return true;
315
- } else if (isFirstChild(li)) {
316
- if (ulParent.nodeName == "LI") {
317
- dom.insertAfter(li, ulParent);
318
- li.appendChild(ul);
319
- removeEmptyLi(ulParent);
320
- } else if (isListNode(ulParent)) {
321
- ulParent.insertBefore(li, ul);
322
- } else {
323
- ulParent.insertBefore(createNewTextBlock(li), ul);
324
- dom.remove(li);
325
- }
326
-
327
- return true;
328
- } else if (isLastChild(li)) {
329
- if (ulParent.nodeName == "LI") {
330
- dom.insertAfter(li, ulParent);
331
- } else if (isListNode(ulParent)) {
332
- dom.insertAfter(li, ul);
333
- } else {
334
- dom.insertAfter(createNewTextBlock(li), ul);
335
- dom.remove(li);
336
- }
337
-
338
- return true;
339
- } else {
340
- if (ulParent.nodeName == 'LI') {
341
- ul = ulParent;
342
- newBlock = createNewTextBlock(li, 'LI');
343
- } else if (isListNode(ulParent)) {
344
- newBlock = createNewTextBlock(li, 'LI');
345
- } else {
346
- newBlock = createNewTextBlock(li);
347
- }
348
-
349
- splitList(ul, li, newBlock);
350
- normalizeList(ul.parentNode);
351
-
352
- return true;
353
- }
354
-
355
- return false;
356
- }
357
-
358
- function indent(li) {
359
- var sibling, newList;
360
-
361
- function mergeLists(from, to) {
362
- var node;
363
-
364
- if (isListNode(from)) {
365
- while ((node = li.lastChild.firstChild)) {
366
- to.appendChild(node);
367
- }
368
-
369
- dom.remove(from);
370
- }
371
- }
372
-
373
- if (li.nodeName == 'DT') {
374
- dom.rename(li, 'DD');
375
- return true;
376
- }
377
-
378
- sibling = li.previousSibling;
379
-
380
- if (sibling && isListNode(sibling)) {
381
- sibling.appendChild(li);
382
- return true;
383
- }
384
-
385
- if (sibling && sibling.nodeName == 'LI' && isListNode(sibling.lastChild)) {
386
- sibling.lastChild.appendChild(li);
387
- mergeLists(li.lastChild, sibling.lastChild);
388
- return true;
389
- }
390
-
391
- sibling = li.nextSibling;
392
-
393
- if (sibling && isListNode(sibling)) {
394
- sibling.insertBefore(li, sibling.firstChild);
395
- return true;
396
- }
397
-
398
- if (sibling && sibling.nodeName == 'LI' && isListNode(li.lastChild)) {
399
- return false;
400
- }
401
-
402
- sibling = li.previousSibling;
403
- if (sibling && sibling.nodeName == 'LI') {
404
- newList = dom.create(li.parentNode.nodeName);
405
- sibling.appendChild(newList);
406
- newList.appendChild(li);
407
- mergeLists(li.lastChild, newList);
408
- return true;
409
- }
410
-
411
- return false;
412
- }
413
-
414
- function indentSelection() {
415
- var listElements = getSelectedListItems();
416
-
417
- if (listElements.length) {
418
- var bookmark = createBookmark(selection.getRng(true));
419
-
420
- for (var i = 0; i < listElements.length; i++) {
421
- if (!indent(listElements[i]) && i === 0) {
422
- break;
423
- }
424
- }
425
-
426
- moveToBookmark(bookmark);
427
- editor.nodeChanged();
428
-
429
- return true;
430
- }
431
- }
432
-
433
- function outdentSelection() {
434
- var listElements = getSelectedListItems();
435
-
436
- if (listElements.length) {
437
- var bookmark = createBookmark(selection.getRng(true));
438
- var i, y, root = editor.getBody();
439
-
440
- i = listElements.length;
441
- while (i--) {
442
- var node = listElements[i].parentNode;
443
-
444
- while (node && node != root) {
445
- y = listElements.length;
446
- while (y--) {
447
- if (listElements[y] === node) {
448
- listElements.splice(i, 1);
449
- break;
450
- }
451
- }
452
-
453
- node = node.parentNode;
454
- }
455
- }
456
-
457
- for (i = 0; i < listElements.length; i++) {
458
- if (!outdent(listElements[i]) && i === 0) {
459
- break;
460
- }
461
- }
462
-
463
- moveToBookmark(bookmark);
464
- editor.nodeChanged();
465
-
466
- return true;
467
- }
468
- }
469
-
470
- function applyList(listName) {
471
- var rng = selection.getRng(true), bookmark = createBookmark(rng), listItemName = 'LI';
472
-
473
- listName = listName.toUpperCase();
474
-
475
- if (listName == 'DL') {
476
- listItemName = 'DT';
477
- }
478
-
479
- function getSelectedTextBlocks() {
480
- var textBlocks = [], root = editor.getBody();
481
-
482
- function getEndPointNode(start) {
483
- var container, offset;
484
-
485
- container = rng[start ? 'startContainer' : 'endContainer'];
486
- offset = rng[start ? 'startOffset' : 'endOffset'];
487
-
488
- // Resolve node index
489
- if (container.nodeType == 1) {
490
- container = container.childNodes[Math.min(offset, container.childNodes.length - 1)] || container;
491
- }
492
-
493
- while (container.parentNode != root) {
494
- if (isTextBlock(container)) {
495
- return container;
496
- }
497
-
498
- if (/^(TD|TH)$/.test(container.parentNode.nodeName)) {
499
- return container;
500
- }
501
-
502
- container = container.parentNode;
503
- }
504
-
505
- return container;
506
- }
507
-
508
- var startNode = getEndPointNode(true);
509
- var endNode = getEndPointNode();
510
- var block, siblings = [];
511
-
512
- for (var node = startNode; node; node = node.nextSibling) {
513
- siblings.push(node);
514
-
515
- if (node == endNode) {
516
- break;
517
- }
518
- }
519
-
520
- tinymce.each(siblings, function(node) {
521
- if (isTextBlock(node)) {
522
- textBlocks.push(node);
523
- block = null;
524
- return;
525
- }
526
-
527
- if (dom.isBlock(node) || node.nodeName == 'BR') {
528
- if (node.nodeName == 'BR') {
529
- dom.remove(node);
530
- }
531
-
532
- block = null;
533
- return;
534
- }
535
-
536
- var nextSibling = node.nextSibling;
537
- if (tinymce.dom.BookmarkManager.isBookmarkNode(node)) {
538
- if (isTextBlock(nextSibling) || (!nextSibling && node.parentNode == root)) {
539
- block = null;
540
- return;
541
- }
542
- }
543
-
544
- if (!block) {
545
- block = dom.create('p');
546
- node.parentNode.insertBefore(block, node);
547
- textBlocks.push(block);
548
- }
549
-
550
- block.appendChild(node);
551
- });
552
-
553
- return textBlocks;
554
- }
555
-
556
- tinymce.each(getSelectedTextBlocks(), function(block) {
557
- var listBlock, sibling;
558
-
559
- sibling = block.previousSibling;
560
- if (sibling && isListNode(sibling) && sibling.nodeName == listName) {
561
- listBlock = sibling;
562
- block = dom.rename(block, listItemName);
563
- sibling.appendChild(block);
564
- } else {
565
- listBlock = dom.create(listName);
566
- block.parentNode.insertBefore(listBlock, block);
567
- listBlock.appendChild(block);
568
- block = dom.rename(block, listItemName);
569
- }
570
-
571
- mergeWithAdjacentLists(listBlock);
572
- });
573
-
574
- moveToBookmark(bookmark);
575
- }
576
-
577
- function removeList() {
578
- var bookmark = createBookmark(selection.getRng(true)), root = editor.getBody();
579
-
580
- tinymce.each(getSelectedListItems(), function(li) {
581
- var node, rootList;
582
-
583
- if (dom.isEmpty(li)) {
584
- outdent(li);
585
- return;
586
- }
587
-
588
- for (node = li; node && node != root; node = node.parentNode) {
589
- if (isListNode(node)) {
590
- rootList = node;
591
- }
592
- }
593
-
594
- splitList(rootList, li);
595
- });
596
-
597
- moveToBookmark(bookmark);
598
- }
599
-
600
- function toggleList(listName) {
601
- var parentList = dom.getParent(selection.getStart(), 'OL,UL,DL');
602
-
603
- if (parentList) {
604
- if (parentList.nodeName == listName) {
605
- removeList(listName);
606
- } else {
607
- var bookmark = createBookmark(selection.getRng(true));
608
- mergeWithAdjacentLists(dom.rename(parentList, listName));
609
- moveToBookmark(bookmark);
610
- }
611
- } else {
612
- applyList(listName);
613
- }
614
- }
615
-
616
- function queryListCommandState(listName) {
617
- return function() {
618
- var parentList = dom.getParent(editor.selection.getStart(), 'UL,OL,DL');
619
-
620
- return parentList && parentList.nodeName == listName;
621
- };
622
- }
623
-
624
- self.backspaceDelete = function(isForward) {
625
- function findNextCaretContainer(rng, isForward) {
626
- var node = rng.startContainer, offset = rng.startOffset;
627
- var nonEmptyBlocks, walker;
628
-
629
- if (node.nodeType == 3 && (isForward ? offset < node.data.length : offset > 0)) {
630
- return node;
631
- }
632
-
633
- nonEmptyBlocks = editor.schema.getNonEmptyElements();
634
- walker = new tinymce.dom.TreeWalker(rng.startContainer);
635
-
636
- while ((node = walker[isForward ? 'next' : 'prev']())) {
637
- if (node.nodeName == 'LI' && !node.hasChildNodes()) {
638
- return node;
639
- }
640
-
641
- if (nonEmptyBlocks[node.nodeName]) {
642
- return node;
643
- }
644
-
645
- if (node.nodeType == 3 && node.data.length > 0) {
646
- return node;
647
- }
648
- }
649
- }
650
-
651
- function mergeLiElements(fromElm, toElm) {
652
- var node, listNode, ul = fromElm.parentNode;
653
-
654
- if (isListNode(toElm.lastChild)) {
655
- listNode = toElm.lastChild;
656
- }
657
-
658
- node = toElm.lastChild;
659
- if (node && node.nodeName == 'BR' && fromElm.hasChildNodes()) {
660
- dom.remove(node);
661
- }
662
-
663
- if (dom.isEmpty(toElm)) {
664
- dom.$(toElm).empty();
665
- }
666
-
667
- if (!dom.isEmpty(fromElm)) {
668
- while ((node = fromElm.firstChild)) {
669
- toElm.appendChild(node);
670
- }
671
- }
672
-
673
- if (listNode) {
674
- toElm.appendChild(listNode);
675
- }
676
-
677
- dom.remove(fromElm);
678
-
679
- if (dom.isEmpty(ul)) {
680
- dom.remove(ul);
681
- }
682
- }
683
-
684
- if (selection.isCollapsed()) {
685
- var li = dom.getParent(selection.getStart(), 'LI');
686
-
687
- if (li) {
688
- var rng = selection.getRng(true);
689
- var otherLi = dom.getParent(findNextCaretContainer(rng, isForward), 'LI');
690
-
691
- if (otherLi && otherLi != li) {
692
- var bookmark = createBookmark(rng);
693
-
694
- if (isForward) {
695
- mergeLiElements(otherLi, li);
696
- } else {
697
- mergeLiElements(li, otherLi);
698
- }
699
-
700
- moveToBookmark(bookmark);
701
-
702
- return true;
703
- } else if (!otherLi) {
704
- if (!isForward && removeList(li.parentNode.nodeName)) {
705
- return true;
706
- }
707
- }
708
- }
709
- }
710
- };
711
-
712
- editor.addCommand('Indent', function() {
713
- if (!indentSelection()) {
714
- return true;
715
- }
716
- });
717
-
718
- editor.addCommand('Outdent', function() {
719
- if (!outdentSelection()) {
720
- return true;
721
- }
722
- });
723
-
724
- editor.addCommand('InsertUnorderedList', function() {
725
- toggleList('UL');
726
- });
727
-
728
- editor.addCommand('InsertOrderedList', function() {
729
- toggleList('OL');
730
- });
731
-
732
- editor.addCommand('InsertDefinitionList', function() {
733
- toggleList('DL');
734
- });
735
-
736
- editor.addQueryStateHandler('InsertUnorderedList', queryListCommandState('UL'));
737
- editor.addQueryStateHandler('InsertOrderedList', queryListCommandState('OL'));
738
- editor.addQueryStateHandler('InsertDefinitionList', queryListCommandState('DL'));
739
-
740
- editor.on('keydown', function(e) {
741
- // Check for tab but not ctrl/cmd+tab since it switches browser tabs
742
- if (e.keyCode != 9 || tinymce.util.VK.metaKeyPressed(e)) {
743
- return;
744
- }
745
-
746
- if (editor.dom.getParent(editor.selection.getStart(), 'LI,DT,DD')) {
747
- e.preventDefault();
748
-
749
- if (e.shiftKey) {
750
- outdentSelection();
751
- } else {
752
- indentSelection();
753
- }
754
- }
755
- });
756
- });
757
-
758
- editor.addButton('indent', {
759
- icon: 'indent',
760
- title: 'Increase indent',
761
- cmd: 'Indent',
762
- onPostRender: function() {
763
- var ctrl = this;
764
-
765
- editor.on('nodechange', function() {
766
- var blocks = editor.selection.getSelectedBlocks();
767
- var disable = false;
768
-
769
- for (var i = 0, l = blocks.length; !disable && i < l; i++) {
770
- var tag = blocks[i].nodeName;
771
-
772
- disable = (tag == 'LI' && isFirstChild(blocks[i]) || tag == 'UL' || tag == 'OL' || tag == 'DD');
773
- }
774
-
775
- ctrl.disabled(disable);
776
- });
777
- }
778
- });
779
-
780
- editor.on('keydown', function(e) {
781
- if (e.keyCode == tinymce.util.VK.BACKSPACE) {
782
- if (self.backspaceDelete()) {
783
- e.preventDefault();
784
- }
785
- } else if (e.keyCode == tinymce.util.VK.DELETE) {
786
- if (self.backspaceDelete(true)) {
787
- e.preventDefault();
788
- }
789
- }
790
- });
791
- });