tinymce-rails 3.4.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (222) hide show
  1. data/README.md +57 -0
  2. data/Rakefile +52 -0
  3. data/assets/integration/tinymce.jquery.js +3 -0
  4. data/assets/integration/tinymce.js +2 -0
  5. data/assets/integration/tinymce.preinit.js.erb +1 -0
  6. data/assets/vendor/tinymce/jquery.tinymce.js +1 -0
  7. data/assets/vendor/tinymce/langs/en.js +223 -0
  8. data/assets/vendor/tinymce/license.txt +504 -0
  9. data/assets/vendor/tinymce/plugins/advhr/css/advhr.css +5 -0
  10. data/assets/vendor/tinymce/plugins/advhr/editor_plugin.js +57 -0
  11. data/assets/vendor/tinymce/plugins/advhr/js/rule.js +43 -0
  12. data/assets/vendor/tinymce/plugins/advhr/langs/en_dlg.js +7 -0
  13. data/assets/vendor/tinymce/plugins/advhr/rule.htm +58 -0
  14. data/assets/vendor/tinymce/plugins/advimage/css/advimage.css +13 -0
  15. data/assets/vendor/tinymce/plugins/advimage/editor_plugin.js +50 -0
  16. data/assets/vendor/tinymce/plugins/advimage/image.htm +235 -0
  17. data/assets/vendor/tinymce/plugins/advimage/img/sample.gif +0 -0
  18. data/assets/vendor/tinymce/plugins/advimage/js/image.js +458 -0
  19. data/assets/vendor/tinymce/plugins/advimage/langs/en_dlg.js +45 -0
  20. data/assets/vendor/tinymce/plugins/advlink/css/advlink.css +8 -0
  21. data/assets/vendor/tinymce/plugins/advlink/editor_plugin.js +61 -0
  22. data/assets/vendor/tinymce/plugins/advlink/js/advlink.js +532 -0
  23. data/assets/vendor/tinymce/plugins/advlink/langs/en_dlg.js +54 -0
  24. data/assets/vendor/tinymce/plugins/advlink/link.htm +338 -0
  25. data/assets/vendor/tinymce/plugins/advlist/editor_plugin.js +176 -0
  26. data/assets/vendor/tinymce/plugins/autolink/editor_plugin.js +172 -0
  27. data/assets/vendor/tinymce/plugins/autoresize/editor_plugin.js +137 -0
  28. data/assets/vendor/tinymce/plugins/autosave/editor_plugin.js +431 -0
  29. data/assets/vendor/tinymce/plugins/autosave/langs/en.js +4 -0
  30. data/assets/vendor/tinymce/plugins/bbcode/editor_plugin.js +120 -0
  31. data/assets/vendor/tinymce/plugins/contextmenu/editor_plugin.js +160 -0
  32. data/assets/vendor/tinymce/plugins/directionality/editor_plugin.js +82 -0
  33. data/assets/vendor/tinymce/plugins/emotions/editor_plugin.js +43 -0
  34. data/assets/vendor/tinymce/plugins/emotions/emotions.htm +41 -0
  35. data/assets/vendor/tinymce/plugins/emotions/img/smiley-cool.gif +0 -0
  36. data/assets/vendor/tinymce/plugins/emotions/img/smiley-cry.gif +0 -0
  37. data/assets/vendor/tinymce/plugins/emotions/img/smiley-embarassed.gif +0 -0
  38. data/assets/vendor/tinymce/plugins/emotions/img/smiley-foot-in-mouth.gif +0 -0
  39. data/assets/vendor/tinymce/plugins/emotions/img/smiley-frown.gif +0 -0
  40. data/assets/vendor/tinymce/plugins/emotions/img/smiley-innocent.gif +0 -0
  41. data/assets/vendor/tinymce/plugins/emotions/img/smiley-kiss.gif +0 -0
  42. data/assets/vendor/tinymce/plugins/emotions/img/smiley-laughing.gif +0 -0
  43. data/assets/vendor/tinymce/plugins/emotions/img/smiley-money-mouth.gif +0 -0
  44. data/assets/vendor/tinymce/plugins/emotions/img/smiley-sealed.gif +0 -0
  45. data/assets/vendor/tinymce/plugins/emotions/img/smiley-smile.gif +0 -0
  46. data/assets/vendor/tinymce/plugins/emotions/img/smiley-surprised.gif +0 -0
  47. data/assets/vendor/tinymce/plugins/emotions/img/smiley-tongue-out.gif +0 -0
  48. data/assets/vendor/tinymce/plugins/emotions/img/smiley-undecided.gif +0 -0
  49. data/assets/vendor/tinymce/plugins/emotions/img/smiley-wink.gif +0 -0
  50. data/assets/vendor/tinymce/plugins/emotions/img/smiley-yell.gif +0 -0
  51. data/assets/vendor/tinymce/plugins/emotions/js/emotions.js +22 -0
  52. data/assets/vendor/tinymce/plugins/emotions/langs/en_dlg.js +20 -0
  53. data/assets/vendor/tinymce/plugins/example/dialog.htm +22 -0
  54. data/assets/vendor/tinymce/plugins/example/editor_plugin.js +84 -0
  55. data/assets/vendor/tinymce/plugins/example/img/example.gif +0 -0
  56. data/assets/vendor/tinymce/plugins/example/js/dialog.js +19 -0
  57. data/assets/vendor/tinymce/plugins/example/langs/en.js +3 -0
  58. data/assets/vendor/tinymce/plugins/example/langs/en_dlg.js +3 -0
  59. data/assets/vendor/tinymce/plugins/example_dependency/editor_plugin.js +50 -0
  60. data/assets/vendor/tinymce/plugins/fullpage/css/fullpage.css +143 -0
  61. data/assets/vendor/tinymce/plugins/fullpage/editor_plugin.js +399 -0
  62. data/assets/vendor/tinymce/plugins/fullpage/fullpage.htm +259 -0
  63. data/assets/vendor/tinymce/plugins/fullpage/js/fullpage.js +232 -0
  64. data/assets/vendor/tinymce/plugins/fullpage/langs/en_dlg.js +85 -0
  65. data/assets/vendor/tinymce/plugins/fullscreen/editor_plugin.js +159 -0
  66. data/assets/vendor/tinymce/plugins/fullscreen/fullscreen.htm +109 -0
  67. data/assets/vendor/tinymce/plugins/iespell/editor_plugin.js +54 -0
  68. data/assets/vendor/tinymce/plugins/inlinepopups/editor_plugin.js +696 -0
  69. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/img/alert.gif +0 -0
  70. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/img/button.gif +0 -0
  71. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/img/buttons.gif +0 -0
  72. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/img/confirm.gif +0 -0
  73. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/img/corners.gif +0 -0
  74. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/img/horizontal.gif +0 -0
  75. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/img/vertical.gif +0 -0
  76. data/assets/vendor/tinymce/plugins/inlinepopups/skins/clearlooks2/window.css +90 -0
  77. data/assets/vendor/tinymce/plugins/inlinepopups/template.htm +387 -0
  78. data/assets/vendor/tinymce/plugins/insertdatetime/editor_plugin.js +83 -0
  79. data/assets/vendor/tinymce/plugins/layer/editor_plugin.js +214 -0
  80. data/assets/vendor/tinymce/plugins/legacyoutput/editor_plugin.js +139 -0
  81. data/assets/vendor/tinymce/plugins/lists/editor_plugin.js +688 -0
  82. data/assets/vendor/tinymce/plugins/media/css/media.css +17 -0
  83. data/assets/vendor/tinymce/plugins/media/editor_plugin.js +777 -0
  84. data/assets/vendor/tinymce/plugins/media/js/embed.js +73 -0
  85. data/assets/vendor/tinymce/plugins/media/js/media.js +355 -0
  86. data/assets/vendor/tinymce/plugins/media/langs/en_dlg.js +109 -0
  87. data/assets/vendor/tinymce/plugins/media/media.htm +812 -0
  88. data/assets/vendor/tinymce/plugins/media/moxieplayer.swf +0 -0
  89. data/assets/vendor/tinymce/plugins/nonbreaking/editor_plugin.js +53 -0
  90. data/assets/vendor/tinymce/plugins/noneditable/editor_plugin.js +95 -0
  91. data/assets/vendor/tinymce/plugins/pagebreak/editor_plugin.js +74 -0
  92. data/assets/vendor/tinymce/plugins/paste/editor_plugin.js +942 -0
  93. data/assets/vendor/tinymce/plugins/paste/js/pastetext.js +36 -0
  94. data/assets/vendor/tinymce/plugins/paste/js/pasteword.js +51 -0
  95. data/assets/vendor/tinymce/plugins/paste/langs/en_dlg.js +5 -0
  96. data/assets/vendor/tinymce/plugins/paste/pastetext.htm +27 -0
  97. data/assets/vendor/tinymce/plugins/paste/pasteword.htm +21 -0
  98. data/assets/vendor/tinymce/plugins/preview/editor_plugin.js +53 -0
  99. data/assets/vendor/tinymce/plugins/preview/example.html +28 -0
  100. data/assets/vendor/tinymce/plugins/preview/jscripts/embed.js +73 -0
  101. data/assets/vendor/tinymce/plugins/preview/preview.html +17 -0
  102. data/assets/vendor/tinymce/plugins/print/editor_plugin.js +34 -0
  103. data/assets/vendor/tinymce/plugins/save/editor_plugin.js +101 -0
  104. data/assets/vendor/tinymce/plugins/searchreplace/css/searchreplace.css +6 -0
  105. data/assets/vendor/tinymce/plugins/searchreplace/editor_plugin.js +61 -0
  106. data/assets/vendor/tinymce/plugins/searchreplace/js/searchreplace.js +142 -0
  107. data/assets/vendor/tinymce/plugins/searchreplace/langs/en_dlg.js +16 -0
  108. data/assets/vendor/tinymce/plugins/searchreplace/searchreplace.htm +100 -0
  109. data/assets/vendor/tinymce/plugins/spellchecker/css/content.css +1 -0
  110. data/assets/vendor/tinymce/plugins/spellchecker/editor_plugin.js +434 -0
  111. data/assets/vendor/tinymce/plugins/spellchecker/img/wline.gif +0 -0
  112. data/assets/vendor/tinymce/plugins/style/css/props.css +13 -0
  113. data/assets/vendor/tinymce/plugins/style/editor_plugin.js +55 -0
  114. data/assets/vendor/tinymce/plugins/style/js/props.js +635 -0
  115. data/assets/vendor/tinymce/plugins/style/langs/en_dlg.js +70 -0
  116. data/assets/vendor/tinymce/plugins/style/props.htm +838 -0
  117. data/assets/vendor/tinymce/plugins/tabfocus/editor_plugin.js +114 -0
  118. data/assets/vendor/tinymce/plugins/table/cell.htm +180 -0
  119. data/assets/vendor/tinymce/plugins/table/css/cell.css +17 -0
  120. data/assets/vendor/tinymce/plugins/table/css/row.css +25 -0
  121. data/assets/vendor/tinymce/plugins/table/css/table.css +13 -0
  122. data/assets/vendor/tinymce/plugins/table/editor_plugin.js +1263 -0
  123. data/assets/vendor/tinymce/plugins/table/js/cell.js +319 -0
  124. data/assets/vendor/tinymce/plugins/table/js/merge_cells.js +27 -0
  125. data/assets/vendor/tinymce/plugins/table/js/row.js +237 -0
  126. data/assets/vendor/tinymce/plugins/table/js/table.js +450 -0
  127. data/assets/vendor/tinymce/plugins/table/langs/en_dlg.js +75 -0
  128. data/assets/vendor/tinymce/plugins/table/merge_cells.htm +32 -0
  129. data/assets/vendor/tinymce/plugins/table/row.htm +158 -0
  130. data/assets/vendor/tinymce/plugins/table/table.htm +188 -0
  131. data/assets/vendor/tinymce/plugins/template/blank.htm +12 -0
  132. data/assets/vendor/tinymce/plugins/template/css/template.css +23 -0
  133. data/assets/vendor/tinymce/plugins/template/editor_plugin.js +159 -0
  134. data/assets/vendor/tinymce/plugins/template/js/template.js +106 -0
  135. data/assets/vendor/tinymce/plugins/template/langs/en_dlg.js +15 -0
  136. data/assets/vendor/tinymce/plugins/template/template.htm +31 -0
  137. data/assets/vendor/tinymce/plugins/visualchars/editor_plugin.js +83 -0
  138. data/assets/vendor/tinymce/plugins/wordcount/editor_plugin.js +114 -0
  139. data/assets/vendor/tinymce/plugins/xhtmlxtras/abbr.htm +142 -0
  140. data/assets/vendor/tinymce/plugins/xhtmlxtras/acronym.htm +142 -0
  141. data/assets/vendor/tinymce/plugins/xhtmlxtras/attributes.htm +149 -0
  142. data/assets/vendor/tinymce/plugins/xhtmlxtras/cite.htm +142 -0
  143. data/assets/vendor/tinymce/plugins/xhtmlxtras/css/attributes.css +11 -0
  144. data/assets/vendor/tinymce/plugins/xhtmlxtras/css/popup.css +9 -0
  145. data/assets/vendor/tinymce/plugins/xhtmlxtras/del.htm +162 -0
  146. data/assets/vendor/tinymce/plugins/xhtmlxtras/editor_plugin.js +132 -0
  147. data/assets/vendor/tinymce/plugins/xhtmlxtras/ins.htm +162 -0
  148. data/assets/vendor/tinymce/plugins/xhtmlxtras/js/abbr.js +28 -0
  149. data/assets/vendor/tinymce/plugins/xhtmlxtras/js/acronym.js +28 -0
  150. data/assets/vendor/tinymce/plugins/xhtmlxtras/js/attributes.js +111 -0
  151. data/assets/vendor/tinymce/plugins/xhtmlxtras/js/cite.js +28 -0
  152. data/assets/vendor/tinymce/plugins/xhtmlxtras/js/del.js +53 -0
  153. data/assets/vendor/tinymce/plugins/xhtmlxtras/js/element_common.js +229 -0
  154. data/assets/vendor/tinymce/plugins/xhtmlxtras/js/ins.js +53 -0
  155. data/assets/vendor/tinymce/plugins/xhtmlxtras/langs/en_dlg.js +32 -0
  156. data/assets/vendor/tinymce/themes/advanced/about.htm +52 -0
  157. data/assets/vendor/tinymce/themes/advanced/anchor.htm +26 -0
  158. data/assets/vendor/tinymce/themes/advanced/charmap.htm +51 -0
  159. data/assets/vendor/tinymce/themes/advanced/color_picker.htm +74 -0
  160. data/assets/vendor/tinymce/themes/advanced/editor_template.js +1358 -0
  161. data/assets/vendor/tinymce/themes/advanced/image.htm +80 -0
  162. data/assets/vendor/tinymce/themes/advanced/img/colorpicker.jpg +0 -0
  163. data/assets/vendor/tinymce/themes/advanced/img/flash.gif +0 -0
  164. data/assets/vendor/tinymce/themes/advanced/img/icons.gif +0 -0
  165. data/assets/vendor/tinymce/themes/advanced/img/iframe.gif +0 -0
  166. data/assets/vendor/tinymce/themes/advanced/img/pagebreak.gif +0 -0
  167. data/assets/vendor/tinymce/themes/advanced/img/quicktime.gif +0 -0
  168. data/assets/vendor/tinymce/themes/advanced/img/realmedia.gif +0 -0
  169. data/assets/vendor/tinymce/themes/advanced/img/shockwave.gif +0 -0
  170. data/assets/vendor/tinymce/themes/advanced/img/trans.gif +0 -0
  171. data/assets/vendor/tinymce/themes/advanced/img/video.gif +0 -0
  172. data/assets/vendor/tinymce/themes/advanced/img/windowsmedia.gif +0 -0
  173. data/assets/vendor/tinymce/themes/advanced/js/about.js +73 -0
  174. data/assets/vendor/tinymce/themes/advanced/js/anchor.js +42 -0
  175. data/assets/vendor/tinymce/themes/advanced/js/charmap.js +355 -0
  176. data/assets/vendor/tinymce/themes/advanced/js/color_picker.js +329 -0
  177. data/assets/vendor/tinymce/themes/advanced/js/image.js +247 -0
  178. data/assets/vendor/tinymce/themes/advanced/js/link.js +153 -0
  179. data/assets/vendor/tinymce/themes/advanced/js/source_editor.js +56 -0
  180. data/assets/vendor/tinymce/themes/advanced/langs/en.js +68 -0
  181. data/assets/vendor/tinymce/themes/advanced/langs/en_dlg.js +54 -0
  182. data/assets/vendor/tinymce/themes/advanced/link.htm +57 -0
  183. data/assets/vendor/tinymce/themes/advanced/shortcuts.htm +47 -0
  184. data/assets/vendor/tinymce/themes/advanced/skins/default/content.css +47 -0
  185. data/assets/vendor/tinymce/themes/advanced/skins/default/dialog.css +117 -0
  186. data/assets/vendor/tinymce/themes/advanced/skins/default/img/buttons.png +0 -0
  187. data/assets/vendor/tinymce/themes/advanced/skins/default/img/items.gif +0 -0
  188. data/assets/vendor/tinymce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  189. data/assets/vendor/tinymce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  190. data/assets/vendor/tinymce/themes/advanced/skins/default/img/progress.gif +0 -0
  191. data/assets/vendor/tinymce/themes/advanced/skins/default/img/tabs.gif +0 -0
  192. data/assets/vendor/tinymce/themes/advanced/skins/default/ui.css +214 -0
  193. data/assets/vendor/tinymce/themes/advanced/skins/highcontrast/content.css +23 -0
  194. data/assets/vendor/tinymce/themes/advanced/skins/highcontrast/dialog.css +105 -0
  195. data/assets/vendor/tinymce/themes/advanced/skins/highcontrast/ui.css +102 -0
  196. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/content.css +46 -0
  197. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/dialog.css +117 -0
  198. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/img/button_bg.png +0 -0
  199. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/img/button_bg_black.png +0 -0
  200. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/img/button_bg_silver.png +0 -0
  201. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/ui.css +217 -0
  202. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/ui_black.css +8 -0
  203. data/assets/vendor/tinymce/themes/advanced/skins/o2k7/ui_silver.css +5 -0
  204. data/assets/vendor/tinymce/themes/advanced/source_editor.htm +25 -0
  205. data/assets/vendor/tinymce/themes/simple/editor_template.js +84 -0
  206. data/assets/vendor/tinymce/themes/simple/img/icons.gif +0 -0
  207. data/assets/vendor/tinymce/themes/simple/langs/en.js +11 -0
  208. data/assets/vendor/tinymce/themes/simple/skins/default/content.css +25 -0
  209. data/assets/vendor/tinymce/themes/simple/skins/default/ui.css +32 -0
  210. data/assets/vendor/tinymce/themes/simple/skins/o2k7/content.css +17 -0
  211. data/assets/vendor/tinymce/themes/simple/skins/o2k7/img/button_bg.png +0 -0
  212. data/assets/vendor/tinymce/themes/simple/skins/o2k7/ui.css +35 -0
  213. data/assets/vendor/tinymce/tiny_mce.js +15338 -0
  214. data/assets/vendor/tinymce/tiny_mce_popup.js +5 -0
  215. data/assets/vendor/tinymce/utils/editable_selects.js +70 -0
  216. data/assets/vendor/tinymce/utils/form_utils.js +210 -0
  217. data/assets/vendor/tinymce/utils/mctabs.js +162 -0
  218. data/assets/vendor/tinymce/utils/validate.js +252 -0
  219. data/lib/tinymce-rails.rb +2 -0
  220. data/lib/tinymce/railtie.rb +17 -0
  221. data/lib/tinymce/version.rb +3 -0
  222. metadata +300 -0
@@ -0,0 +1,83 @@
1
+ /**
2
+ * editor_plugin_src.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() {
12
+ tinymce.create('tinymce.plugins.InsertDateTime', {
13
+ init : function(ed, url) {
14
+ var t = this;
15
+
16
+ t.editor = ed;
17
+
18
+ ed.addCommand('mceInsertDate', function() {
19
+ var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_dateFormat", ed.getLang('insertdatetime.date_fmt')));
20
+
21
+ ed.execCommand('mceInsertContent', false, str);
22
+ });
23
+
24
+ ed.addCommand('mceInsertTime', function() {
25
+ var str = t._getDateTime(new Date(), ed.getParam("plugin_insertdate_timeFormat", ed.getLang('insertdatetime.time_fmt')));
26
+
27
+ ed.execCommand('mceInsertContent', false, str);
28
+ });
29
+
30
+ ed.addButton('insertdate', {title : 'insertdatetime.insertdate_desc', cmd : 'mceInsertDate'});
31
+ ed.addButton('inserttime', {title : 'insertdatetime.inserttime_desc', cmd : 'mceInsertTime'});
32
+ },
33
+
34
+ getInfo : function() {
35
+ return {
36
+ longname : 'Insert date/time',
37
+ author : 'Moxiecode Systems AB',
38
+ authorurl : 'http://tinymce.moxiecode.com',
39
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',
40
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
41
+ };
42
+ },
43
+
44
+ // Private methods
45
+
46
+ _getDateTime : function(d, fmt) {
47
+ var ed = this.editor;
48
+
49
+ function addZeros(value, len) {
50
+ value = "" + value;
51
+
52
+ if (value.length < len) {
53
+ for (var i=0; i<(len-value.length); i++)
54
+ value = "0" + value;
55
+ }
56
+
57
+ return value;
58
+ };
59
+
60
+ fmt = fmt.replace("%D", "%m/%d/%y");
61
+ fmt = fmt.replace("%r", "%I:%M:%S %p");
62
+ fmt = fmt.replace("%Y", "" + d.getFullYear());
63
+ fmt = fmt.replace("%y", "" + d.getYear());
64
+ fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));
65
+ fmt = fmt.replace("%d", addZeros(d.getDate(), 2));
66
+ fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));
67
+ fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));
68
+ fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
69
+ fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
70
+ fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
71
+ fmt = fmt.replace("%B", "" + ed.getLang("insertdatetime.months_long").split(',')[d.getMonth()]);
72
+ fmt = fmt.replace("%b", "" + ed.getLang("insertdatetime.months_short").split(',')[d.getMonth()]);
73
+ fmt = fmt.replace("%A", "" + ed.getLang("insertdatetime.day_long").split(',')[d.getDay()]);
74
+ fmt = fmt.replace("%a", "" + ed.getLang("insertdatetime.day_short").split(',')[d.getDay()]);
75
+ fmt = fmt.replace("%%", "%");
76
+
77
+ return fmt;
78
+ }
79
+ });
80
+
81
+ // Register plugin
82
+ tinymce.PluginManager.add('insertdatetime', tinymce.plugins.InsertDateTime);
83
+ })();
@@ -0,0 +1,214 @@
1
+ /**
2
+ * editor_plugin_src.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() {
12
+ tinymce.create('tinymce.plugins.Layer', {
13
+ init : function(ed, url) {
14
+ var t = this;
15
+
16
+ t.editor = ed;
17
+
18
+ // Register commands
19
+ ed.addCommand('mceInsertLayer', t._insertLayer, t);
20
+
21
+ ed.addCommand('mceMoveForward', function() {
22
+ t._move(1);
23
+ });
24
+
25
+ ed.addCommand('mceMoveBackward', function() {
26
+ t._move(-1);
27
+ });
28
+
29
+ ed.addCommand('mceMakeAbsolute', function() {
30
+ t._toggleAbsolute();
31
+ });
32
+
33
+ // Register buttons
34
+ ed.addButton('moveforward', {title : 'layer.forward_desc', cmd : 'mceMoveForward'});
35
+ ed.addButton('movebackward', {title : 'layer.backward_desc', cmd : 'mceMoveBackward'});
36
+ ed.addButton('absolute', {title : 'layer.absolute_desc', cmd : 'mceMakeAbsolute'});
37
+ ed.addButton('insertlayer', {title : 'layer.insertlayer_desc', cmd : 'mceInsertLayer'});
38
+
39
+ ed.onInit.add(function() {
40
+ if (tinymce.isIE)
41
+ ed.getDoc().execCommand('2D-Position', false, true);
42
+ });
43
+
44
+ ed.onNodeChange.add(t._nodeChange, t);
45
+ ed.onVisualAid.add(t._visualAid, t);
46
+ },
47
+
48
+ getInfo : function() {
49
+ return {
50
+ longname : 'Layer',
51
+ author : 'Moxiecode Systems AB',
52
+ authorurl : 'http://tinymce.moxiecode.com',
53
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/layer',
54
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
55
+ };
56
+ },
57
+
58
+ // Private methods
59
+
60
+ _nodeChange : function(ed, cm, n) {
61
+ var le, p;
62
+
63
+ le = this._getParentLayer(n);
64
+ p = ed.dom.getParent(n, 'DIV,P,IMG');
65
+
66
+ if (!p) {
67
+ cm.setDisabled('absolute', 1);
68
+ cm.setDisabled('moveforward', 1);
69
+ cm.setDisabled('movebackward', 1);
70
+ } else {
71
+ cm.setDisabled('absolute', 0);
72
+ cm.setDisabled('moveforward', !le);
73
+ cm.setDisabled('movebackward', !le);
74
+ cm.setActive('absolute', le && le.style.position.toLowerCase() == "absolute");
75
+ }
76
+ },
77
+
78
+ // Private methods
79
+
80
+ _visualAid : function(ed, e, s) {
81
+ var dom = ed.dom;
82
+
83
+ tinymce.each(dom.select('div,p', e), function(e) {
84
+ if (/^(absolute|relative|static)$/i.test(e.style.position)) {
85
+ if (s)
86
+ dom.addClass(e, 'mceItemVisualAid');
87
+ else
88
+ dom.removeClass(e, 'mceItemVisualAid');
89
+ }
90
+ });
91
+ },
92
+
93
+ _move : function(d) {
94
+ var ed = this.editor, i, z = [], le = this._getParentLayer(ed.selection.getNode()), ci = -1, fi = -1, nl;
95
+
96
+ nl = [];
97
+ tinymce.walk(ed.getBody(), function(n) {
98
+ if (n.nodeType == 1 && /^(absolute|relative|static)$/i.test(n.style.position))
99
+ nl.push(n);
100
+ }, 'childNodes');
101
+
102
+ // Find z-indexes
103
+ for (i=0; i<nl.length; i++) {
104
+ z[i] = nl[i].style.zIndex ? parseInt(nl[i].style.zIndex) : 0;
105
+
106
+ if (ci < 0 && nl[i] == le)
107
+ ci = i;
108
+ }
109
+
110
+ if (d < 0) {
111
+ // Move back
112
+
113
+ // Try find a lower one
114
+ for (i=0; i<z.length; i++) {
115
+ if (z[i] < z[ci]) {
116
+ fi = i;
117
+ break;
118
+ }
119
+ }
120
+
121
+ if (fi > -1) {
122
+ nl[ci].style.zIndex = z[fi];
123
+ nl[fi].style.zIndex = z[ci];
124
+ } else {
125
+ if (z[ci] > 0)
126
+ nl[ci].style.zIndex = z[ci] - 1;
127
+ }
128
+ } else {
129
+ // Move forward
130
+
131
+ // Try find a higher one
132
+ for (i=0; i<z.length; i++) {
133
+ if (z[i] > z[ci]) {
134
+ fi = i;
135
+ break;
136
+ }
137
+ }
138
+
139
+ if (fi > -1) {
140
+ nl[ci].style.zIndex = z[fi];
141
+ nl[fi].style.zIndex = z[ci];
142
+ } else
143
+ nl[ci].style.zIndex = z[ci] + 1;
144
+ }
145
+
146
+ ed.execCommand('mceRepaint');
147
+ },
148
+
149
+ _getParentLayer : function(n) {
150
+ return this.editor.dom.getParent(n, function(n) {
151
+ return n.nodeType == 1 && /^(absolute|relative|static)$/i.test(n.style.position);
152
+ });
153
+ },
154
+
155
+ _insertLayer : function() {
156
+ var ed = this.editor, p = ed.dom.getPos(ed.dom.getParent(ed.selection.getNode(), '*'));
157
+
158
+ ed.dom.add(ed.getBody(), 'div', {
159
+ style : {
160
+ position : 'absolute',
161
+ left : p.x,
162
+ top : (p.y > 20 ? p.y : 20),
163
+ width : 100,
164
+ height : 100
165
+ },
166
+ 'class' : 'mceItemVisualAid'
167
+ }, ed.selection.getContent() || ed.getLang('layer.content'));
168
+ },
169
+
170
+ _toggleAbsolute : function() {
171
+ var ed = this.editor, le = this._getParentLayer(ed.selection.getNode());
172
+
173
+ if (!le)
174
+ le = ed.dom.getParent(ed.selection.getNode(), 'DIV,P,IMG');
175
+
176
+ if (le) {
177
+ if (le.style.position.toLowerCase() == "absolute") {
178
+ ed.dom.setStyles(le, {
179
+ position : '',
180
+ left : '',
181
+ top : '',
182
+ width : '',
183
+ height : ''
184
+ });
185
+
186
+ ed.dom.removeClass(le, 'mceItemVisualAid');
187
+ } else {
188
+ if (le.style.left == "")
189
+ le.style.left = 20 + 'px';
190
+
191
+ if (le.style.top == "")
192
+ le.style.top = 20 + 'px';
193
+
194
+ if (le.style.width == "")
195
+ le.style.width = le.width ? (le.width + 'px') : '100px';
196
+
197
+ if (le.style.height == "")
198
+ le.style.height = le.height ? (le.height + 'px') : '100px';
199
+
200
+ le.style.position = "absolute";
201
+
202
+ ed.dom.setAttrib(le, 'data-mce-style', '');
203
+ ed.addVisual(ed.getBody());
204
+ }
205
+
206
+ ed.execCommand('mceRepaint');
207
+ ed.nodeChanged();
208
+ }
209
+ }
210
+ });
211
+
212
+ // Register plugin
213
+ tinymce.PluginManager.add('layer', tinymce.plugins.Layer);
214
+ })();
@@ -0,0 +1,139 @@
1
+ /**
2
+ * editor_plugin_src.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
+ * This plugin will force TinyMCE to produce deprecated legacy output such as font elements, u elements, align
11
+ * attributes and so forth. There are a few cases where these old items might be needed for example in email applications or with Flash
12
+ *
13
+ * However you should NOT use this plugin if you are building some system that produces web contents such as a CMS. All these elements are
14
+ * not apart of the newer specifications for HTML and XHTML.
15
+ */
16
+
17
+ (function(tinymce) {
18
+ // Override inline_styles setting to force TinyMCE to produce deprecated contents
19
+ tinymce.onAddEditor.addToTop(function(tinymce, editor) {
20
+ editor.settings.inline_styles = false;
21
+ });
22
+
23
+ // Create the legacy ouput plugin
24
+ tinymce.create('tinymce.plugins.LegacyOutput', {
25
+ init : function(editor) {
26
+ editor.onInit.add(function() {
27
+ var alignElements = 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img',
28
+ fontSizes = tinymce.explode(editor.settings.font_size_style_values),
29
+ schema = editor.schema;
30
+
31
+ // Override some internal formats to produce legacy elements and attributes
32
+ editor.formatter.register({
33
+ // Change alignment formats to use the deprecated align attribute
34
+ alignleft : {selector : alignElements, attributes : {align : 'left'}},
35
+ aligncenter : {selector : alignElements, attributes : {align : 'center'}},
36
+ alignright : {selector : alignElements, attributes : {align : 'right'}},
37
+ alignfull : {selector : alignElements, attributes : {align : 'justify'}},
38
+
39
+ // Change the basic formatting elements to use deprecated element types
40
+ bold : [
41
+ {inline : 'b', remove : 'all'},
42
+ {inline : 'strong', remove : 'all'},
43
+ {inline : 'span', styles : {fontWeight : 'bold'}}
44
+ ],
45
+ italic : [
46
+ {inline : 'i', remove : 'all'},
47
+ {inline : 'em', remove : 'all'},
48
+ {inline : 'span', styles : {fontStyle : 'italic'}}
49
+ ],
50
+ underline : [
51
+ {inline : 'u', remove : 'all'},
52
+ {inline : 'span', styles : {textDecoration : 'underline'}, exact : true}
53
+ ],
54
+ strikethrough : [
55
+ {inline : 'strike', remove : 'all'},
56
+ {inline : 'span', styles : {textDecoration: 'line-through'}, exact : true}
57
+ ],
58
+
59
+ // Change font size and font family to use the deprecated font element
60
+ fontname : {inline : 'font', attributes : {face : '%value'}},
61
+ fontsize : {
62
+ inline : 'font',
63
+ attributes : {
64
+ size : function(vars) {
65
+ return tinymce.inArray(fontSizes, vars.value) + 1;
66
+ }
67
+ }
68
+ },
69
+
70
+ // Setup font elements for colors as well
71
+ forecolor : {inline : 'font', styles : {color : '%value'}},
72
+ hilitecolor : {inline : 'font', styles : {backgroundColor : '%value'}}
73
+ });
74
+
75
+ // Check that deprecated elements are allowed if not add them
76
+ tinymce.each('b,i,u,strike'.split(','), function(name) {
77
+ schema.addValidElements(name + '[*]');
78
+ });
79
+
80
+ // Add font element if it's missing
81
+ if (!schema.getElementRule("font"))
82
+ schema.addValidElements("font[face|size|color|style]");
83
+
84
+ // Add the missing and depreacted align attribute for the serialization engine
85
+ tinymce.each(alignElements.split(','), function(name) {
86
+ var rule = schema.getElementRule(name), found;
87
+
88
+ if (rule) {
89
+ if (!rule.attributes.align) {
90
+ rule.attributes.align = {};
91
+ rule.attributesOrder.push('align');
92
+ }
93
+ }
94
+ });
95
+
96
+ // Listen for the onNodeChange event so that we can do special logic for the font size and font name drop boxes
97
+ editor.onNodeChange.add(function(editor, control_manager) {
98
+ var control, fontElm, fontName, fontSize;
99
+
100
+ // Find font element get it's name and size
101
+ fontElm = editor.dom.getParent(editor.selection.getNode(), 'font');
102
+ if (fontElm) {
103
+ fontName = fontElm.face;
104
+ fontSize = fontElm.size;
105
+ }
106
+
107
+ // Select/unselect the font name in droplist
108
+ if (control = control_manager.get('fontselect')) {
109
+ control.select(function(value) {
110
+ return value == fontName;
111
+ });
112
+ }
113
+
114
+ // Select/unselect the font size in droplist
115
+ if (control = control_manager.get('fontsizeselect')) {
116
+ control.select(function(value) {
117
+ var index = tinymce.inArray(fontSizes, value.fontSize);
118
+
119
+ return index + 1 == fontSize;
120
+ });
121
+ }
122
+ });
123
+ });
124
+ },
125
+
126
+ getInfo : function() {
127
+ return {
128
+ longname : 'LegacyOutput',
129
+ author : 'Moxiecode Systems AB',
130
+ authorurl : 'http://tinymce.moxiecode.com',
131
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/legacyoutput',
132
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
133
+ };
134
+ }
135
+ });
136
+
137
+ // Register plugin
138
+ tinymce.PluginManager.add('legacyoutput', tinymce.plugins.LegacyOutput);
139
+ })(tinymce);
@@ -0,0 +1,688 @@
1
+ /**
2
+ * editor_plugin_src.js
3
+ *
4
+ * Copyright 2011, 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() {
12
+ var each = tinymce.each, Event = tinymce.dom.Event, bookmark;
13
+
14
+ // Skips text nodes that only contain whitespace since they aren't semantically important.
15
+ function skipWhitespaceNodes(e, next) {
16
+ while (e && (e.nodeType === 8 || (e.nodeType === 3 && /^[ \t\n\r]*$/.test(e.nodeValue)))) {
17
+ e = next(e);
18
+ }
19
+ return e;
20
+ }
21
+
22
+ function skipWhitespaceNodesBackwards(e) {
23
+ return skipWhitespaceNodes(e, function(e) { return e.previousSibling; });
24
+ }
25
+
26
+ function skipWhitespaceNodesForwards(e) {
27
+ return skipWhitespaceNodes(e, function(e) { return e.nextSibling; });
28
+ }
29
+
30
+ function hasParentInList(ed, e, list) {
31
+ return ed.dom.getParent(e, function(p) {
32
+ return tinymce.inArray(list, p) !== -1;
33
+ });
34
+ }
35
+
36
+ function isList(e) {
37
+ return e && (e.tagName === 'OL' || e.tagName === 'UL');
38
+ }
39
+
40
+ function splitNestedLists(element, dom) {
41
+ var tmp, nested, wrapItem;
42
+ tmp = skipWhitespaceNodesBackwards(element.lastChild);
43
+ while (isList(tmp)) {
44
+ nested = tmp;
45
+ tmp = skipWhitespaceNodesBackwards(nested.previousSibling);
46
+ }
47
+ if (nested) {
48
+ wrapItem = dom.create('li', { style: 'list-style-type: none;'});
49
+ dom.split(element, nested);
50
+ dom.insertAfter(wrapItem, nested);
51
+ wrapItem.appendChild(nested);
52
+ wrapItem.appendChild(nested);
53
+ element = wrapItem.previousSibling;
54
+ }
55
+ return element;
56
+ }
57
+
58
+ function attemptMergeWithAdjacent(e, allowDifferentListStyles, mergeParagraphs) {
59
+ e = attemptMergeWithPrevious(e, allowDifferentListStyles, mergeParagraphs);
60
+ return attemptMergeWithNext(e, allowDifferentListStyles, mergeParagraphs);
61
+ }
62
+
63
+ function attemptMergeWithPrevious(e, allowDifferentListStyles, mergeParagraphs) {
64
+ var prev = skipWhitespaceNodesBackwards(e.previousSibling);
65
+ if (prev) {
66
+ return attemptMerge(prev, e, allowDifferentListStyles ? prev : false, mergeParagraphs);
67
+ } else {
68
+ return e;
69
+ }
70
+ }
71
+
72
+ function attemptMergeWithNext(e, allowDifferentListStyles, mergeParagraphs) {
73
+ var next = skipWhitespaceNodesForwards(e.nextSibling);
74
+ if (next) {
75
+ return attemptMerge(e, next, allowDifferentListStyles ? next : false, mergeParagraphs);
76
+ } else {
77
+ return e;
78
+ }
79
+ }
80
+
81
+ function attemptMerge(e1, e2, differentStylesMasterElement, mergeParagraphs) {
82
+ if (canMerge(e1, e2, !!differentStylesMasterElement, mergeParagraphs)) {
83
+ return merge(e1, e2, differentStylesMasterElement);
84
+ } else if (e1 && e1.tagName === 'LI' && isList(e2)) {
85
+ // Fix invalidly nested lists.
86
+ e1.appendChild(e2);
87
+ }
88
+ return e2;
89
+ }
90
+
91
+ function canMerge(e1, e2, allowDifferentListStyles, mergeParagraphs) {
92
+ if (!e1 || !e2) {
93
+ return false;
94
+ } else if (e1.tagName === 'LI' && e2.tagName === 'LI') {
95
+ return e2.style.listStyleType === 'none' || containsOnlyAList(e2);
96
+ } else if (isList(e1)) {
97
+ return (e1.tagName === e2.tagName && (allowDifferentListStyles || e1.style.listStyleType === e2.style.listStyleType)) || isListForIndent(e2);
98
+ } else if (mergeParagraphs && e1.tagName === 'P' && e2.tagName === 'P') {
99
+ return true;
100
+ } else {
101
+ return false;
102
+ }
103
+ }
104
+
105
+ function isListForIndent(e) {
106
+ var firstLI = skipWhitespaceNodesForwards(e.firstChild), lastLI = skipWhitespaceNodesBackwards(e.lastChild);
107
+ return firstLI && lastLI && isList(e) && firstLI === lastLI && (isList(firstLI) || firstLI.style.listStyleType === 'none' || containsOnlyAList(firstLI));
108
+ }
109
+
110
+ function containsOnlyAList(e) {
111
+ var firstChild = skipWhitespaceNodesForwards(e.firstChild), lastChild = skipWhitespaceNodesBackwards(e.lastChild);
112
+ return firstChild && lastChild && firstChild === lastChild && isList(firstChild);
113
+ }
114
+
115
+ function merge(e1, e2, masterElement) {
116
+ var lastOriginal = skipWhitespaceNodesBackwards(e1.lastChild), firstNew = skipWhitespaceNodesForwards(e2.firstChild);
117
+ if (e1.tagName === 'P') {
118
+ e1.appendChild(e1.ownerDocument.createElement('br'));
119
+ }
120
+ while (e2.firstChild) {
121
+ e1.appendChild(e2.firstChild);
122
+ }
123
+ if (masterElement) {
124
+ e1.style.listStyleType = masterElement.style.listStyleType;
125
+ }
126
+ e2.parentNode.removeChild(e2);
127
+ attemptMerge(lastOriginal, firstNew, false);
128
+ return e1;
129
+ }
130
+
131
+ function findItemToOperateOn(e, dom) {
132
+ var item;
133
+ if (!dom.is(e, 'li,ol,ul')) {
134
+ item = dom.getParent(e, 'li');
135
+ if (item) {
136
+ e = item;
137
+ }
138
+ }
139
+ return e;
140
+ }
141
+
142
+ tinymce.create('tinymce.plugins.Lists', {
143
+ init: function(ed, url) {
144
+ var enterDownInEmptyList = false;
145
+
146
+ function isTriggerKey(e) {
147
+ return e.keyCode === 9 && (ed.queryCommandState('InsertUnorderedList') || ed.queryCommandState('InsertOrderedList'));
148
+ };
149
+
150
+ function isEnterInEmptyListItem(ed, e) {
151
+ var sel = ed.selection, n;
152
+ if (e.keyCode === 13) {
153
+ n = sel.getStart();
154
+
155
+ // Get start will return BR if the LI only contains a BR
156
+ if (n.tagName == 'BR' && n.parentNode.tagName == 'LI')
157
+ n = n.parentNode;
158
+
159
+ // Check for empty LI or a LI with just one BR since Gecko and WebKit uses BR elements to place the caret
160
+ enterDownInEmptyList = sel.isCollapsed() && n && n.tagName === 'LI' && (n.childNodes.length === 0 || (n.firstChild.nodeName == 'BR' && n.childNodes.length === 1));
161
+ return enterDownInEmptyList;
162
+ }
163
+ };
164
+
165
+ function cancelKeys(ed, e) {
166
+ if (isTriggerKey(e) || isEnterInEmptyListItem(ed, e)) {
167
+ return Event.cancel(e);
168
+ }
169
+ };
170
+
171
+ function imageJoiningListItem(ed, e) {
172
+ if (!tinymce.isGecko)
173
+ return;
174
+
175
+ var n = ed.selection.getStart();
176
+ if (e.keyCode != 8 || n.tagName !== 'IMG')
177
+ return;
178
+
179
+ function lastLI(node) {
180
+ var child = node.firstChild;
181
+ var li = null;
182
+ do {
183
+ if (!child)
184
+ break;
185
+
186
+ if (child.tagName === 'LI')
187
+ li = child;
188
+ } while (child = child.nextSibling);
189
+
190
+ return li;
191
+ }
192
+
193
+ function addChildren(parentNode, destination) {
194
+ while (parentNode.childNodes.length > 0)
195
+ destination.appendChild(parentNode.childNodes[0]);
196
+ }
197
+
198
+ var ul;
199
+ if (n.parentNode.previousSibling.tagName === 'UL' || n.parentNode.previousSibling.tagName === 'OL')
200
+ ul = n.parentNode.previousSibling;
201
+ else if (n.parentNode.previousSibling.previousSibling.tagName === 'UL' || n.parentNode.previousSibling.previousSibling.tagName === 'OL')
202
+ ul = n.parentNode.previousSibling.previousSibling;
203
+ else
204
+ return;
205
+
206
+ var li = lastLI(ul);
207
+
208
+ // move the caret to the end of the list item
209
+ var rng = ed.dom.createRng();
210
+ rng.setStart(li, 1);
211
+ rng.setEnd(li, 1);
212
+ ed.selection.setRng(rng);
213
+ ed.selection.collapse(true);
214
+
215
+ // save a bookmark at the end of the list item
216
+ var bookmark = ed.selection.getBookmark();
217
+
218
+ // copy the image an its text to the list item
219
+ var clone = n.parentNode.cloneNode(true);
220
+ if (clone.tagName === 'P' || clone.tagName === 'DIV')
221
+ addChildren(clone, li);
222
+ else
223
+ li.appendChild(clone);
224
+
225
+ // remove the old copy of the image
226
+ n.parentNode.parentNode.removeChild(n.parentNode);
227
+
228
+ // move the caret where we saved the bookmark
229
+ ed.selection.moveToBookmark(bookmark);
230
+ }
231
+
232
+ this.ed = ed;
233
+ ed.addCommand('Indent', this.indent, this);
234
+ ed.addCommand('Outdent', this.outdent, this);
235
+ ed.addCommand('InsertUnorderedList', function() {
236
+ this.applyList('UL', 'OL');
237
+ }, this);
238
+ ed.addCommand('InsertOrderedList', function() {
239
+ this.applyList('OL', 'UL');
240
+ }, this);
241
+
242
+ ed.onInit.add(function() {
243
+ ed.editorCommands.addCommands({
244
+ 'outdent': function() {
245
+ var sel = ed.selection, dom = ed.dom;
246
+ function hasStyleIndent(n) {
247
+ n = dom.getParent(n, dom.isBlock);
248
+ return n && (parseInt(ed.dom.getStyle(n, 'margin-left') || 0, 10) + parseInt(ed.dom.getStyle(n, 'padding-left') || 0, 10)) > 0;
249
+ }
250
+ return hasStyleIndent(sel.getStart()) || hasStyleIndent(sel.getEnd()) || ed.queryCommandState('InsertOrderedList') || ed.queryCommandState('InsertUnorderedList');
251
+ }
252
+ }, 'state');
253
+ });
254
+
255
+ ed.onKeyUp.add(function(ed, e) {
256
+ var n, rng;
257
+ if (isTriggerKey(e)) {
258
+ ed.execCommand(e.shiftKey ? 'Outdent' : 'Indent', true, null);
259
+ return Event.cancel(e);
260
+ } else if (enterDownInEmptyList && isEnterInEmptyListItem(ed, e)) {
261
+ if (ed.queryCommandState('InsertOrderedList')) {
262
+ ed.execCommand('InsertOrderedList');
263
+ } else {
264
+ ed.execCommand('InsertUnorderedList');
265
+ }
266
+ n = ed.selection.getStart();
267
+ if (n && n.tagName === 'LI') {
268
+ // Fix the caret position on IE since it jumps back up to the previous list item.
269
+ n = ed.dom.getParent(n, 'ol,ul').nextSibling;
270
+ if (n && n.tagName === 'P') {
271
+ if (!n.firstChild) {
272
+ n.appendChild(ed.getDoc().createTextNode(''));
273
+ }
274
+ rng = ed.dom.createRng();
275
+ rng.setStart(n.firstChild, 1);
276
+ rng.setEnd(n.firstChild, 1);
277
+ ed.selection.setRng(rng);
278
+ }
279
+ }
280
+ return Event.cancel(e);
281
+ }
282
+ });
283
+ ed.onKeyPress.add(cancelKeys);
284
+ ed.onKeyDown.add(cancelKeys);
285
+ ed.onKeyDown.add(imageJoiningListItem);
286
+ },
287
+
288
+ applyList: function(targetListType, oppositeListType) {
289
+ var t = this, ed = t.ed, dom = ed.dom, applied = [], hasSameType = false, hasOppositeType = false, hasNonList = false, actions,
290
+ selectedBlocks = ed.selection.getSelectedBlocks();
291
+
292
+ function cleanupBr(e) {
293
+ if (e && e.tagName === 'BR') {
294
+ dom.remove(e);
295
+ }
296
+ }
297
+
298
+ function makeList(element) {
299
+ var list = dom.create(targetListType), li;
300
+ function adjustIndentForNewList(element) {
301
+ // If there's a margin-left, outdent one level to account for the extra list margin.
302
+ if (element.style.marginLeft || element.style.paddingLeft) {
303
+ t.adjustPaddingFunction(false)(element);
304
+ }
305
+ }
306
+
307
+ if (element.tagName === 'LI') {
308
+ // No change required.
309
+ } else if (element.tagName === 'P' || element.tagName === 'DIV' || element.tagName === 'BODY') {
310
+ processBrs(element, function(startSection, br, previousBR) {
311
+ doWrapList(startSection, br, element.tagName === 'BODY' ? null : startSection.parentNode);
312
+ li = startSection.parentNode;
313
+ adjustIndentForNewList(li);
314
+ cleanupBr(br);
315
+ });
316
+ if (element.tagName === 'P' || selectedBlocks.length > 1) {
317
+ dom.split(li.parentNode.parentNode, li.parentNode);
318
+ }
319
+ attemptMergeWithAdjacent(li.parentNode, true);
320
+ return;
321
+ } else {
322
+ // Put the list around the element.
323
+ li = dom.create('li');
324
+ dom.insertAfter(li, element);
325
+ li.appendChild(element);
326
+ adjustIndentForNewList(element);
327
+ element = li;
328
+ }
329
+ dom.insertAfter(list, element);
330
+ list.appendChild(element);
331
+ attemptMergeWithAdjacent(list, true);
332
+ applied.push(element);
333
+ }
334
+
335
+ function doWrapList(start, end, template) {
336
+ var li, n = start, tmp, i;
337
+ while (!dom.isBlock(start.parentNode) && start.parentNode !== dom.getRoot()) {
338
+ start = dom.split(start.parentNode, start.previousSibling);
339
+ start = start.nextSibling;
340
+ n = start;
341
+ }
342
+ if (template) {
343
+ li = template.cloneNode(true);
344
+ start.parentNode.insertBefore(li, start);
345
+ while (li.firstChild) dom.remove(li.firstChild);
346
+ li = dom.rename(li, 'li');
347
+ } else {
348
+ li = dom.create('li');
349
+ start.parentNode.insertBefore(li, start);
350
+ }
351
+ while (n && n != end) {
352
+ tmp = n.nextSibling;
353
+ li.appendChild(n);
354
+ n = tmp;
355
+ }
356
+ if (li.childNodes.length === 0) {
357
+ li.innerHTML = '<br _mce_bogus="1" />';
358
+ }
359
+ makeList(li);
360
+ }
361
+
362
+ function processBrs(element, callback) {
363
+ var startSection, previousBR, END_TO_START = 3, START_TO_END = 1,
364
+ breakElements = 'br,ul,ol,p,div,h1,h2,h3,h4,h5,h6,table,blockquote,address,pre,form,center,dl';
365
+ function isAnyPartSelected(start, end) {
366
+ var r = dom.createRng(), sel;
367
+ bookmark.keep = true;
368
+ ed.selection.moveToBookmark(bookmark);
369
+ bookmark.keep = false;
370
+ sel = ed.selection.getRng(true);
371
+ if (!end) {
372
+ end = start.parentNode.lastChild;
373
+ }
374
+ r.setStartBefore(start);
375
+ r.setEndAfter(end);
376
+ return !(r.compareBoundaryPoints(END_TO_START, sel) > 0 || r.compareBoundaryPoints(START_TO_END, sel) <= 0);
377
+ }
378
+ function nextLeaf(br) {
379
+ if (br.nextSibling)
380
+ return br.nextSibling;
381
+ if (!dom.isBlock(br.parentNode) && br.parentNode !== dom.getRoot())
382
+ return nextLeaf(br.parentNode);
383
+ }
384
+ // Split on BRs within the range and process those.
385
+ startSection = element.firstChild;
386
+ // First mark the BRs that have any part of the previous section selected.
387
+ var trailingContentSelected = false;
388
+ each(dom.select(breakElements, element), function(br) {
389
+ var b;
390
+ if (br.hasAttribute && br.hasAttribute('_mce_bogus')) {
391
+ return true; // Skip the bogus Brs that are put in to appease Firefox and Safari.
392
+ }
393
+ if (isAnyPartSelected(startSection, br)) {
394
+ dom.addClass(br, '_mce_tagged_br');
395
+ startSection = nextLeaf(br);
396
+ }
397
+ });
398
+ trailingContentSelected = (startSection && isAnyPartSelected(startSection, undefined));
399
+ startSection = element.firstChild;
400
+ each(dom.select(breakElements, element), function(br) {
401
+ // Got a section from start to br.
402
+ var tmp = nextLeaf(br);
403
+ if (br.hasAttribute && br.hasAttribute('_mce_bogus')) {
404
+ return true; // Skip the bogus Brs that are put in to appease Firefox and Safari.
405
+ }
406
+ if (dom.hasClass(br, '_mce_tagged_br')) {
407
+ callback(startSection, br, previousBR);
408
+ previousBR = null;
409
+ } else {
410
+ previousBR = br;
411
+ }
412
+ startSection = tmp;
413
+ });
414
+ if (trailingContentSelected) {
415
+ callback(startSection, undefined, previousBR);
416
+ }
417
+ }
418
+
419
+ function wrapList(element) {
420
+ processBrs(element, function(startSection, br, previousBR) {
421
+ // Need to indent this part
422
+ doWrapList(startSection, br);
423
+ cleanupBr(br);
424
+ cleanupBr(previousBR);
425
+ });
426
+ }
427
+
428
+ function changeList(element) {
429
+ if (tinymce.inArray(applied, element) !== -1) {
430
+ return;
431
+ }
432
+ if (element.parentNode.tagName === oppositeListType) {
433
+ dom.split(element.parentNode, element);
434
+ makeList(element);
435
+ attemptMergeWithNext(element.parentNode, false);
436
+ }
437
+ applied.push(element);
438
+ }
439
+
440
+ function convertListItemToParagraph(element) {
441
+ var child, nextChild, mergedElement, splitLast;
442
+ if (tinymce.inArray(applied, element) !== -1) {
443
+ return;
444
+ }
445
+ element = splitNestedLists(element, dom);
446
+ while (dom.is(element.parentNode, 'ol,ul,li')) {
447
+ dom.split(element.parentNode, element);
448
+ }
449
+ // Push the original element we have from the selection, not the renamed one.
450
+ applied.push(element);
451
+ element = dom.rename(element, 'p');
452
+ mergedElement = attemptMergeWithAdjacent(element, false, ed.settings.force_br_newlines);
453
+ if (mergedElement === element) {
454
+ // Now split out any block elements that can't be contained within a P.
455
+ // Manually iterate to ensure we handle modifications correctly (doesn't work with tinymce.each)
456
+ child = element.firstChild;
457
+ while (child) {
458
+ if (dom.isBlock(child)) {
459
+ child = dom.split(child.parentNode, child);
460
+ splitLast = true;
461
+ nextChild = child.nextSibling && child.nextSibling.firstChild;
462
+ } else {
463
+ nextChild = child.nextSibling;
464
+ if (splitLast && child.tagName === 'BR') {
465
+ dom.remove(child);
466
+ }
467
+ splitLast = false;
468
+ }
469
+ child = nextChild;
470
+ }
471
+ }
472
+ }
473
+
474
+ each(selectedBlocks, function(e) {
475
+ e = findItemToOperateOn(e, dom);
476
+ if (e.tagName === oppositeListType || (e.tagName === 'LI' && e.parentNode.tagName === oppositeListType)) {
477
+ hasOppositeType = true;
478
+ } else if (e.tagName === targetListType || (e.tagName === 'LI' && e.parentNode.tagName === targetListType)) {
479
+ hasSameType = true;
480
+ } else {
481
+ hasNonList = true;
482
+ }
483
+ });
484
+
485
+ if (hasNonList || hasOppositeType || selectedBlocks.length === 0) {
486
+ actions = {
487
+ 'LI': changeList,
488
+ 'H1': makeList,
489
+ 'H2': makeList,
490
+ 'H3': makeList,
491
+ 'H4': makeList,
492
+ 'H5': makeList,
493
+ 'H6': makeList,
494
+ 'P': makeList,
495
+ 'BODY': makeList,
496
+ 'DIV': selectedBlocks.length > 1 ? makeList : wrapList,
497
+ defaultAction: wrapList
498
+ };
499
+ } else {
500
+ actions = {
501
+ defaultAction: convertListItemToParagraph
502
+ };
503
+ }
504
+ this.process(actions);
505
+ },
506
+
507
+ indent: function() {
508
+ var ed = this.ed, dom = ed.dom, indented = [];
509
+
510
+ function createWrapItem(element) {
511
+ var wrapItem = dom.create('li', { style: 'list-style-type: none;'});
512
+ dom.insertAfter(wrapItem, element);
513
+ return wrapItem;
514
+ }
515
+
516
+ function createWrapList(element) {
517
+ var wrapItem = createWrapItem(element),
518
+ list = dom.getParent(element, 'ol,ul'),
519
+ listType = list.tagName,
520
+ listStyle = dom.getStyle(list, 'list-style-type'),
521
+ attrs = {},
522
+ wrapList;
523
+ if (listStyle !== '') {
524
+ attrs.style = 'list-style-type: ' + listStyle + ';';
525
+ }
526
+ wrapList = dom.create(listType, attrs);
527
+ wrapItem.appendChild(wrapList);
528
+ return wrapList;
529
+ }
530
+
531
+ function indentLI(element) {
532
+ if (!hasParentInList(ed, element, indented)) {
533
+ element = splitNestedLists(element, dom);
534
+ var wrapList = createWrapList(element);
535
+ wrapList.appendChild(element);
536
+ attemptMergeWithAdjacent(wrapList.parentNode, false);
537
+ attemptMergeWithAdjacent(wrapList, false);
538
+ indented.push(element);
539
+ }
540
+ }
541
+
542
+ this.process({
543
+ 'LI': indentLI,
544
+ defaultAction: this.adjustPaddingFunction(true)
545
+ });
546
+
547
+ },
548
+
549
+ outdent: function() {
550
+ var t = this, ed = t.ed, dom = ed.dom, outdented = [];
551
+
552
+ function outdentLI(element) {
553
+ var listElement, targetParent, align;
554
+ if (!hasParentInList(ed, element, outdented)) {
555
+ if (dom.getStyle(element, 'margin-left') !== '' || dom.getStyle(element, 'padding-left') !== '') {
556
+ return t.adjustPaddingFunction(false)(element);
557
+ }
558
+ align = dom.getStyle(element, 'text-align', true);
559
+ if (align === 'center' || align === 'right') {
560
+ dom.setStyle(element, 'text-align', 'left');
561
+ return;
562
+ }
563
+ element = splitNestedLists(element, dom);
564
+ listElement = element.parentNode;
565
+ targetParent = element.parentNode.parentNode;
566
+ if (targetParent.tagName === 'P') {
567
+ dom.split(targetParent, element.parentNode);
568
+ } else {
569
+ dom.split(listElement, element);
570
+ if (targetParent.tagName === 'LI') {
571
+ // Nested list, need to split the LI and go back out to the OL/UL element.
572
+ dom.split(targetParent, element);
573
+ } else if (!dom.is(targetParent, 'ol,ul')) {
574
+ dom.rename(element, 'p');
575
+ }
576
+ }
577
+ outdented.push(element);
578
+ }
579
+ }
580
+
581
+ this.process({
582
+ 'LI': outdentLI,
583
+ defaultAction: this.adjustPaddingFunction(false)
584
+ });
585
+
586
+ each(outdented, attemptMergeWithAdjacent);
587
+ },
588
+
589
+ process: function(actions) {
590
+ var t = this, sel = t.ed.selection, dom = t.ed.dom, selectedBlocks, r;
591
+ function processElement(element) {
592
+ dom.removeClass(element, '_mce_act_on');
593
+ if (!element || element.nodeType !== 1) {
594
+ return;
595
+ }
596
+ element = findItemToOperateOn(element, dom);
597
+ var action = actions[element.tagName];
598
+ if (!action) {
599
+ action = actions.defaultAction;
600
+ }
601
+ action(element);
602
+ }
603
+ function recurse(element) {
604
+ t.splitSafeEach(element.childNodes, processElement);
605
+ }
606
+ function brAtEdgeOfSelection(container, offset) {
607
+ return offset >= 0 && container.hasChildNodes() && offset < container.childNodes.length &&
608
+ container.childNodes[offset].tagName === 'BR';
609
+ }
610
+ selectedBlocks = sel.getSelectedBlocks();
611
+ if (selectedBlocks.length === 0) {
612
+ selectedBlocks = [ dom.getRoot() ];
613
+ }
614
+
615
+ r = sel.getRng(true);
616
+ if (!r.collapsed) {
617
+ if (brAtEdgeOfSelection(r.endContainer, r.endOffset - 1)) {
618
+ r.setEnd(r.endContainer, r.endOffset - 1);
619
+ sel.setRng(r);
620
+ }
621
+ if (brAtEdgeOfSelection(r.startContainer, r.startOffset)) {
622
+ r.setStart(r.startContainer, r.startOffset + 1);
623
+ sel.setRng(r);
624
+ }
625
+ }
626
+ bookmark = sel.getBookmark();
627
+ actions.OL = actions.UL = recurse;
628
+ t.splitSafeEach(selectedBlocks, processElement);
629
+ sel.moveToBookmark(bookmark);
630
+ bookmark = null;
631
+ // Avoids table or image handles being left behind in Firefox.
632
+ t.ed.execCommand('mceRepaint');
633
+ },
634
+
635
+ splitSafeEach: function(elements, f) {
636
+ if (tinymce.isGecko && (/Firefox\/[12]\.[0-9]/.test(navigator.userAgent) ||
637
+ /Firefox\/3\.[0-4]/.test(navigator.userAgent))) {
638
+ this.classBasedEach(elements, f);
639
+ } else {
640
+ each(elements, f);
641
+ }
642
+ },
643
+
644
+ classBasedEach: function(elements, f) {
645
+ var dom = this.ed.dom, nodes, element;
646
+ // Mark nodes
647
+ each(elements, function(element) {
648
+ dom.addClass(element, '_mce_act_on');
649
+ });
650
+ nodes = dom.select('._mce_act_on');
651
+ while (nodes.length > 0) {
652
+ element = nodes.shift();
653
+ dom.removeClass(element, '_mce_act_on');
654
+ f(element);
655
+ nodes = dom.select('._mce_act_on');
656
+ }
657
+ },
658
+
659
+ adjustPaddingFunction: function(isIndent) {
660
+ var indentAmount, indentUnits, ed = this.ed;
661
+ indentAmount = ed.settings.indentation;
662
+ indentUnits = /[a-z%]+/i.exec(indentAmount);
663
+ indentAmount = parseInt(indentAmount, 10);
664
+ return function(element) {
665
+ var currentIndent, newIndentAmount;
666
+ currentIndent = parseInt(ed.dom.getStyle(element, 'margin-left') || 0, 10) + parseInt(ed.dom.getStyle(element, 'padding-left') || 0, 10);
667
+ if (isIndent) {
668
+ newIndentAmount = currentIndent + indentAmount;
669
+ } else {
670
+ newIndentAmount = currentIndent - indentAmount;
671
+ }
672
+ ed.dom.setStyle(element, 'padding-left', '');
673
+ ed.dom.setStyle(element, 'margin-left', newIndentAmount > 0 ? newIndentAmount + indentUnits : '');
674
+ };
675
+ },
676
+
677
+ getInfo: function() {
678
+ return {
679
+ longname : 'Lists',
680
+ author : 'Moxiecode Systems AB',
681
+ authorurl : 'http://tinymce.moxiecode.com',
682
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/lists',
683
+ version : tinymce.majorVersion + "." + tinymce.minorVersion
684
+ };
685
+ }
686
+ });
687
+ tinymce.PluginManager.add("lists", tinymce.plugins.Lists);
688
+ }());