radiant-forum-extension 2.1.6 → 3.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. data/README.md +20 -16
  2. data/Rakefile +0 -16
  3. data/app/controllers/forum_base_controller.rb +32 -10
  4. data/app/controllers/posts_controller.rb +37 -14
  5. data/app/helpers/forum_helper.rb +23 -16
  6. data/app/models/forum.rb +11 -7
  7. data/app/models/post.rb +53 -14
  8. data/app/models/post_attachment.rb +1 -1
  9. data/app/models/topic.rb +21 -8
  10. data/app/views/admin/dashboard/_forum_dashboard.html.haml +51 -0
  11. data/app/views/admin/forums/_form.html.haml +12 -0
  12. data/app/views/admin/forums/edit.html.haml +1 -1
  13. data/app/views/admin/forums/index.html.haml +16 -20
  14. data/app/views/admin/posts/_form.html.haml +2 -2
  15. data/app/views/admin/posts/edit.html.haml +1 -1
  16. data/app/views/admin/posts/index.html.haml +5 -5
  17. data/app/views/admin/reader_configuration/_edit_forum.html.haml +6 -0
  18. data/app/views/admin/reader_configuration/_forum.html.haml +5 -1
  19. data/app/views/admin/topics/_form.html.haml +3 -5
  20. data/app/views/admin/topics/edit.html.haml +1 -1
  21. data/app/views/admin/topics/index.html.haml +5 -5
  22. data/app/views/forums/_forum.html.haml +6 -5
  23. data/app/views/forums/_latest.html.haml +14 -12
  24. data/app/views/forums/_statistics.html.haml +4 -4
  25. data/app/views/forums/index.html.haml +8 -10
  26. data/app/views/forums/index.rss.builder +2 -2
  27. data/app/views/forums/show.html.haml +12 -15
  28. data/app/views/pages/_add_comment.html.haml +9 -8
  29. data/app/views/pages/_comments.html.haml +3 -3
  30. data/app/views/posts/_attachments.html.haml +1 -1
  31. data/app/views/posts/_confirm_delete.html.haml +7 -2
  32. data/app/views/posts/_context.html.haml +5 -5
  33. data/app/views/posts/_edit_links.html.haml +4 -4
  34. data/app/views/posts/_form.html.haml +15 -12
  35. data/app/views/posts/_ineditable.html.haml +7 -0
  36. data/app/views/posts/_latest.html.haml +3 -8
  37. data/app/views/posts/_minimal.html.haml +7 -0
  38. data/app/views/posts/_post.html.haml +20 -17
  39. data/app/views/posts/_post.rss.builder +2 -2
  40. data/app/views/posts/_search_form.html.haml +13 -13
  41. data/app/views/posts/_search_results.html.haml +15 -0
  42. data/app/views/posts/_search_summary.html.haml +13 -0
  43. data/app/views/posts/_uploader.html.haml +1 -1
  44. data/app/views/posts/edit.html.haml +22 -21
  45. data/app/views/posts/index.html.haml +12 -19
  46. data/app/views/posts/index.rss.builder +6 -6
  47. data/app/views/posts/new.html.haml +19 -22
  48. data/app/views/posts/remove.html.haml +15 -15
  49. data/app/views/posts/show.html.haml +16 -10
  50. data/app/views/readers/_forum_messages.html.haml +9 -6
  51. data/app/views/readers/_messages_summary.html.haml +1 -1
  52. data/app/views/shared/_standard_forum_parts.html.haml +41 -0
  53. data/app/views/topics/_busiest.html.haml +9 -8
  54. data/app/views/topics/_context.html.haml +11 -8
  55. data/app/views/topics/_latest.html.haml +2 -2
  56. data/app/views/topics/_locked.html.haml +1 -1
  57. data/app/views/topics/_minimal.html.haml +2 -2
  58. data/app/views/topics/_replies.html.haml +4 -3
  59. data/app/views/topics/_reply.html.haml +13 -8
  60. data/app/views/topics/_topic.html.haml +5 -9
  61. data/app/views/topics/_topic.rss.builder +1 -1
  62. data/app/views/topics/index.html.haml +14 -10
  63. data/app/views/topics/index.rss.builder +2 -2
  64. data/app/views/topics/show.html.haml +20 -19
  65. data/app/views/topics/show.rss.builder +3 -3
  66. data/config/initializers/radiant_config.rb +4 -1
  67. data/config/locales/en.yml +202 -178
  68. data/db/migrate/002_pages_commentable.rb +1 -2
  69. data/db/migrate/004_sample_layout.rb +38 -15
  70. data/db/migrate/20110111080550_detach_observer.rb +4 -4
  71. data/db/migrate/20110613112823_search_text.rb +9 -0
  72. data/db/migrate/20110613130230_tidy_up.rb +27 -0
  73. data/db/migrate/20110630083446_page_replied_at.rb +11 -0
  74. data/forum_extension.rb +13 -11
  75. data/lib/commentable_model.rb +13 -9
  76. data/lib/forum_admin_ui.rb +6 -6
  77. data/lib/forum_page.rb +5 -3
  78. data/lib/forum_reader.rb +7 -1
  79. data/lib/forum_reader_sessions_controller.rb +2 -3
  80. data/lib/forum_tags.rb +126 -11
  81. data/lib/radiant-forum-extension.rb +8 -0
  82. data/public/cleditor/images/buttons.gif +0 -0
  83. data/public/cleditor/images/icons/1.gif +0 -0
  84. data/public/cleditor/images/icons/10.gif +0 -0
  85. data/public/cleditor/images/icons/11.gif +0 -0
  86. data/public/cleditor/images/icons/12.gif +0 -0
  87. data/public/cleditor/images/icons/2.gif +0 -0
  88. data/public/cleditor/images/icons/3.gif +0 -0
  89. data/public/cleditor/images/icons/4.gif +0 -0
  90. data/public/cleditor/images/icons/5.gif +0 -0
  91. data/public/cleditor/images/icons/6.gif +0 -0
  92. data/public/cleditor/images/icons/7.gif +0 -0
  93. data/public/cleditor/images/icons/8.gif +0 -0
  94. data/public/cleditor/images/icons/9.gif +0 -0
  95. data/public/cleditor/images/icons/icons.gif +0 -0
  96. data/public/cleditor/images/toolbar.gif +0 -0
  97. data/public/cleditor/jquery.cleditor.css +24 -0
  98. data/public/cleditor/jquery.cleditor.icon.js +65 -0
  99. data/public/cleditor/jquery.cleditor.js +1132 -0
  100. data/public/cleditor/jquery.cleditor.xhtml.js +230 -0
  101. data/public/javascripts/forum.js +146 -107
  102. data/public/stylesheets/sass/forum.sass +94 -58
  103. data/radiant-forum-extension.gemspec +25 -276
  104. data/spec/controllers/forums_controller_spec.rb +0 -7
  105. data/spec/controllers/posts_controller_spec.rb +20 -37
  106. data/spec/controllers/topics_controller_spec.rb +1 -7
  107. data/spec/datasets/forums_dataset.rb +38 -40
  108. data/spec/lib/commentable_model_spec.rb +26 -38
  109. data/spec/lib/forum_reader_spec.rb +0 -4
  110. data/spec/models/forum_spec.rb +46 -16
  111. data/spec/models/post_spec.rb +10 -6
  112. data/spec/models/topic_spec.rb +26 -17
  113. data/spec/spec_helper.rb +1 -0
  114. metadata +66 -99
  115. data/VERSION +0 -1
  116. data/app/views/forums/_standard_parts.html.haml +0 -59
  117. data/lib/sanitize/config/forum.rb +0 -49
  118. data/public/javascripts/gallery.js +0 -275
  119. data/public/punymce/blank.htm +0 -1
  120. data/public/punymce/css/content.css +0 -4
  121. data/public/punymce/css/editor.css +0 -58
  122. data/public/punymce/i18n/sv.js +0 -28
  123. data/public/punymce/img/icons.gif +0 -0
  124. data/public/punymce/img/icons_uncompressed.png +0 -0
  125. data/public/punymce/plugins/bbcode.js +0 -1
  126. data/public/punymce/plugins/bbcode_src.js +0 -50
  127. data/public/punymce/plugins/editsource/css/editor.css +0 -3
  128. data/public/punymce/plugins/editsource/editsource.js +0 -1
  129. data/public/punymce/plugins/editsource/editsource_src.js +0 -81
  130. data/public/punymce/plugins/editsource/img/icons.gif +0 -0
  131. data/public/punymce/plugins/emoticons/css/content.css +0 -13
  132. data/public/punymce/plugins/emoticons/css/editor.css +0 -17
  133. data/public/punymce/plugins/emoticons/emoticons.js +0 -1
  134. data/public/punymce/plugins/emoticons/emoticons_src.js +0 -303
  135. data/public/punymce/plugins/emoticons/img/emoticons.gif +0 -0
  136. data/public/punymce/plugins/emoticons/img/emoticons.png +0 -0
  137. data/public/punymce/plugins/emoticons/img/trans.gif +0 -0
  138. data/public/punymce/plugins/entities.js +0 -1
  139. data/public/punymce/plugins/entities_src.js +0 -37
  140. data/public/punymce/plugins/forceblocks.js +0 -1
  141. data/public/punymce/plugins/forceblocks_src.js +0 -465
  142. data/public/punymce/plugins/forcenl.js +0 -1
  143. data/public/punymce/plugins/forcenl_src.js +0 -26
  144. data/public/punymce/plugins/image/css/editor.css +0 -1
  145. data/public/punymce/plugins/image/image.js +0 -1
  146. data/public/punymce/plugins/image/image_src.js +0 -30
  147. data/public/punymce/plugins/image/img/icons.gif +0 -0
  148. data/public/punymce/plugins/link/css/editor.css +0 -2
  149. data/public/punymce/plugins/link/img/icons.gif +0 -0
  150. data/public/punymce/plugins/link/link.js +0 -1
  151. data/public/punymce/plugins/link/link_src.js +0 -36
  152. data/public/punymce/plugins/paste.js +0 -1
  153. data/public/punymce/plugins/paste_src.js +0 -169
  154. data/public/punymce/plugins/protect.js +0 -1
  155. data/public/punymce/plugins/protect_src.js +0 -30
  156. data/public/punymce/plugins/safari2x.js +0 -1
  157. data/public/punymce/plugins/safari2x_src.js +0 -284
  158. data/public/punymce/plugins/tabfocus.js +0 -1
  159. data/public/punymce/plugins/tabfocus_src.js +0 -45
  160. data/public/punymce/plugins/textcolor/css/editor.css +0 -7
  161. data/public/punymce/plugins/textcolor/img/icons.gif +0 -0
  162. data/public/punymce/plugins/textcolor/textcolor.js +0 -1
  163. data/public/punymce/plugins/textcolor/textcolor_src.js +0 -73
  164. data/public/punymce/puny_mce.js +0 -1
  165. data/public/punymce/puny_mce_full.js +0 -1
  166. data/public/punymce/puny_mce_src.js +0 -1460
@@ -1,169 +0,0 @@
1
- (function(punymce) {
2
- var Event = punymce.Event;
3
-
4
- function insertAfter(n, r) {
5
- var p, ns;
6
-
7
- p = r.parentNode;
8
- ns = r.nextSibling;
9
-
10
- if (ns)
11
- p.insertBefore(n, ns);
12
- else
13
- p.appendChild(n);
14
-
15
- return n;
16
- };
17
-
18
- function findTextNode(ed, n, first) {
19
- // Find last text node
20
- var tn, w = ed.getDoc().createTreeWalker(n, NodeFilter.SHOW_TEXT, null, false);
21
-
22
- if (first)
23
- return w.nextNode();
24
-
25
- while (tn = w.nextNode())
26
- n = tn;
27
-
28
- return n;
29
- };
30
-
31
- punymce.plugins.Paste = function(ed) {
32
- var dom = punymce.DOM, bookmark;
33
-
34
- ed.onPaste = new punymce.Dispatcher(ed);
35
-
36
- function insert(v) {
37
- var lines, parents = [], block, caret, sel = ed.selection, start, end, i, rng, marker;
38
-
39
- ed.getWin().focus();
40
-
41
- // Restore caret location on IE
42
- if (bookmark) {
43
- r = ed.selection.getRng();
44
- r.moveToBookmark(bookmark);
45
- r.select();
46
- }
47
-
48
- // Convert lines to paragraphs
49
- lines = v.split(/\r?\n/);
50
- if (lines.length > 1) {
51
- v = '';
52
- punymce.each(lines, function(line) {
53
- v += '<p>' + line + '</p>';
54
- });
55
-
56
- // Split current container
57
- if (!punymce.isIE) {
58
- ed.execCommand('Delete');
59
- sel.setContent('<span id="marker"></span>');
60
- block = ed.dom.getParent(ed.dom.get('marker').parentNode, function(n) {
61
- parents.push(n);
62
-
63
- if (/^(p|h[1-6]|div)$/i.test(n.nodeName))
64
- return true;
65
- });
66
-
67
- if (block) {
68
- ed.onPaste.dispatch({text : v});
69
-
70
- start = end = '';
71
- for (i = 0; i < parents.length; i++)
72
- start += '</' + parents[i].nodeName.toLowerCase() + '>';
73
-
74
- for (i = parents.length - 1; i >= 0; i--)
75
- end += '<' + parents[i].nodeName.toLowerCase() + '>';
76
-
77
- v = start + v + end + '<span id="_caret">&nbsp;</span>';
78
-
79
- ed.getBody().innerHTML = ed.getBody().innerHTML.replace(/<span id=\"marker\"><\/span>/gi, v);
80
-
81
- caret = ed.dom.get('_caret');
82
-
83
- if (!punymce.isGecko)
84
- caret.scrollIntoView();
85
-
86
- rng = ed.getDoc().createRange();
87
- rng.setStartBefore(caret);
88
- rng.setEndAfter(caret);
89
- sel.setRng(rng);
90
- ed.execCommand('Delete');
91
-
92
- return;
93
- } else {
94
- marker = ed.dom.get('marker');
95
- marker.parentNode.removeChild(marker);
96
- }
97
- }
98
- }
99
-
100
- ed.selection.setContent(v);
101
- ed.onPaste.dispatch({text : v});
102
- };
103
-
104
- function grab(e) {
105
- var n, rng, sel = ed.selection, se = sel.getSel(), or, body = ed.getBody();
106
-
107
- n = ed.dom.add(body, 'div', {id : '_mcePaste', style : 'position:absolute;left:-10000px;top:' + body.scrollTop}, '&nbsp;');
108
-
109
- // Move caret into hidden div
110
- or = sel.getRng();
111
- n = n.firstChild;
112
- rng = ed.getDoc().createRange();
113
- rng.setStart(n, 0);
114
- rng.setEnd(n, 1);
115
-
116
- se.removeAllRanges();
117
- se.addRange(rng);
118
-
119
- window.setTimeout(function() {
120
- var n = ed.dom.get('_mcePaste'), h;
121
-
122
- // Grab the HTML contents
123
- h = n.innerHTML;
124
-
125
- // Remove hidden div and restore selection
126
- n.parentNode.removeChild(n);
127
-
128
- // Restore the old selection
129
- if (or)
130
- sel.setRng(or);
131
-
132
- insert(h.replace(/[\r\n]/g, '').replace(/<(\/p|br\s*\/?)>/g, '\n').replace(/<!--.*?-->/g, '').replace(/<[^>]+>/g, ''));
133
- }, 0);
134
- };
135
-
136
- ed.onInit.add(function() {
137
- if (punymce.isOpera)
138
- return;
139
-
140
- // Use Ctrl+v handler on FF 2
141
- if (/Firefox\/2/.test(navigator.userAgent)) {
142
- Event.add(ed.getDoc(), 'keydown', function(e) {
143
- // Fake onpaste event (ctrl+v or shift+insert)
144
- if (((e.metaKey || e.ctrlKey) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45)) {
145
- // Store away caret location
146
- if (punymce.isIE)
147
- bookmark = ed.selection.getRng().getBookmark();
148
-
149
- grab(e);
150
- }
151
- }, this);
152
- } else {
153
- Event.add(punymce.isIE ? ed.getBody() : ed.getDoc(), 'paste', function(e) {
154
- var val;
155
-
156
- if (ed.getWin().clipboardData) {
157
- insert(ed.getWin().clipboardData.getData('Text'));
158
- return Event.cancel(e);
159
- } if (e.clipboardData) {
160
- insert(e.clipboardData.getData('text/plain'));
161
- return Event.cancel(e);
162
- }
163
-
164
- grab(e);
165
- });
166
- }
167
- });
168
- };
169
- })(punymce);
@@ -1 +0,0 @@
1
- (function(a){a.plugins.Protect=function(b){var e=[],c,d;d=b.settings.protect||{};if(!d.list){d.list=[/<(script|noscript|style)[\u0000-\uFFFF]*?<\/(script|noscript|style)>/g]}b.onSetContent.add(function(f,g){a.each(d.list,function(h){g.content=g.content.replace(h,function(i){e.push(i);return"<!-- pro:"+(e.length-1)+" -->"})})});b.onGetContent.add(function(f,g){g.content=g.content.replace(/<!-- pro:([0-9]+) -->/g,function(i,h){return e[parseInt(h)]})})}})(punymce);
@@ -1,30 +0,0 @@
1
- (function(punymce) {
2
- punymce.plugins.Protect = function(ed) {
3
- var pr = [], s, p;
4
-
5
- // Default settings
6
- p = ed.settings.protect || {};
7
- if (!p.list) {
8
- p.list = [
9
- /<(script|noscript|style)[\u0000-\uFFFF]*?<\/(script|noscript|style)>/g
10
- ];
11
- }
12
-
13
- // Store away things to protect
14
- ed.onSetContent.add(function(ed, o) {
15
- punymce.each(p.list, function(re) {
16
- o.content = o.content.replace(re, function(a) {
17
- pr.push(a);
18
- return '<!-- pro:' + (pr.length-1) + ' -->';
19
- });
20
- });
21
- });
22
-
23
- // Restore protected things
24
- ed.onGetContent.add(function(ed, o) {
25
- o.content = o.content.replace(/<!-- pro:([0-9]+) -->/g, function(a, b) {
26
- return pr[parseInt(b)];
27
- });
28
- });
29
- };
30
- })(punymce);
@@ -1 +0,0 @@
1
- (function(a){a.plugins.Safari2x=function(h){var k=a.each,l=a.Event,g,f,j;if(!a.isOldWebKit){return}h.selection.getRng=function(){var n=this,o=n.getSel(),w=h.getDoc(),q,u,v,p;if(o.anchorNode){q=w.createRange();try{u=w.createRange();u.setStart(o.anchorNode,o.anchorOffset);u.collapse(1);v=w.createRange();v.setStart(o.focusNode,o.focusOffset);v.collapse(1);p=u.compareBoundaryPoints(u.START_TO_END,v)<0;q.setStart(p?o.anchorNode:o.focusNode,p?o.anchorOffset:o.focusOffset);q.setEnd(p?o.focusNode:o.anchorNode,p?o.focusOffset:o.anchorOffset)}catch(m){}}return q};f=h.selection.setContent;h.selection.setContent=function(o,n){var p=this.getRng();try{f.call(this,o,n)}catch(m){b=h.dom.create("body");b.innerHTML=o;k(b.childNodes,function(q){p.insertNode(q.cloneNode(true))})}};j=h.selection.collapse;h.selection.collapse=function(m){try{j.call(this,m)}catch(n){}};h.onInit.add(function(){a.DOM.get(h.settings.id+"_r").style.display="none"});h.onPreInit.add(function(){l.add(h.getDoc(),"click",function(m){if(m.target.nodeName=="A"){h.selection.select(m.target);return l.cancel(m)}});l.add(h.getDoc(),"keydown",function(q){var m=h.selection,v,t,p,u;if(q.charCode>32||q.keyCode==13){v=h.dom.getParent(m.getNode(),function(o){return o.nodeName=="LI"});if(v){t=m.getRng().startOffset;if(q.keyCode==13){if(!v.hasChildNodes()){if(!v.nextSibling||v.nextSibling.nodeName!="LI"){p=h.dom.getParent(m.getNode(),function(o){return/(UL|OL)/.test(o.nodeName)});v.parentNode.removeChild(v);m.select(p.nextSibling);return}return l.cancel(q)}u=h.getDoc().createTextNode("\u00a0");v.appendChild(u);window.setTimeout(function(){var o=m.getNode();if(o.firstChild&&o.firstChild.nodeValue.charAt(0)=="\u00a0"){o.removeChild(o.firstChild);m.select(o)}},1)}else{u=String.fromCharCode(q.charCode);if(!/^\w$/.test(u)){return}m.setContent(u);p=m.getRng();m=m.getSel();v=m.anchorNode;if(v.nodeName=="LI"){m.setBaseAndExtent(v,1,v,1)}else{v=v.nextSibling;m.setBaseAndExtent(v,1,v,1)}return l.cancel(q)}}}})});function c(t,m){var q=h.getDoc(),p,o;m=m||{};q.execCommand("FontName",false,"_tmp");k(h.dom.select("span"),function(n){if(n.style.fontFamily=="_tmp"){p=d(n,t,m);if(!o){o=p}}});p=p.firstChild;h.selection.getSel().setBaseAndExtent(o,0,p,p.nodeValue.length)}function i(p){var o=h.selection,m;o.setContent("<"+p+'><li id="_tmp"></li></'+p+">");m=h.dom.get("_tmp");m.id="";o.select(m);o.collapse(1)}function e(m){return h.dom.getParent(m,function(o){return/^(H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CODE|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(o.nodeName)})}function d(p,s,m){var q=h.getDoc(),o;m=m||{};o=q.createElement(s);k(p.attributes,function(t){if(t.specified&&t.nodeValue){o.setAttribute(t.nodeName,t.nodeValue)}});k(m,function(t,n){o.setAttribute(n,t)});k(p.childNodes,function(t){o.appendChild(t.cloneNode(true))});p.parentNode.replaceChild(o,p);return o}a.extend(h.commands,{IncreaseFontSize:function(){var n=h.getDoc(),m=parseInt(n.queryCommandValue("FontSize"));n.execCommand("FontSize",false,(m+1)+"px")},DecreaseFontSize:function(){var n=h.getDoc(),m=parseInt(n.queryCommandValue("FontSize"));if(m>0){n.execCommand("FontSize",false,(m-1)+"px")}},Strikethrough:function(){c("strike")},CreateLink:function(n,m){c("a",{href:m,mce_href:m})},Unlink:function(){var m=h.selection;m.setContent(m.getContent().replace(/(<a[^>]+>|<\/a>)/,""))},RemoveFormat:function(){var m=h.selection;m.setContent(m.getContent().replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g,""))},FormatBlock:function(o,m){var p=h.selection,q;q=e(h.selection.getNode());if(q){r=d(q,m.replace(/<|>/g,""))}p.select(r);p.collapse(1)},InsertUnorderedList:function(){i("ul")},InsertOrderedList:function(){i("ol")},Indent:function(){var o=e(h.selection.getNode()),m;if(o){m=parseInt(o.style.paddingLeft)||0;o.style.paddingLeft=(m+10)+"px"}},Outdent:function(){var o=e(h.selection.getNode()),m;if(o){m=parseInt(o.style.paddingLeft)||0;if(m>=10){o.style.paddingLeft=(m-10)+"px"}}}})}})(punymce);
@@ -1,284 +0,0 @@
1
- (function(punymce) {
2
- punymce.plugins.Safari2x = function(ed) {
3
- var each = punymce.each, Event = punymce.Event, html, setContent, collapse;
4
-
5
- // Is Safari 2.x
6
- if (!punymce.isOldWebKit)
7
- return;
8
-
9
- // Fake range on Safari 2.x
10
- ed.selection.getRng = function() {
11
- var t = this, s = t.getSel(), d = ed.getDoc(), r, rb, ra, di;
12
-
13
- // Fake range on Safari 2.x
14
- if (s.anchorNode) {
15
- r = d.createRange();
16
-
17
- try {
18
- // Setup before range
19
- rb = d.createRange();
20
- rb.setStart(s.anchorNode, s.anchorOffset);
21
- rb.collapse(1);
22
-
23
- // Setup after range
24
- ra = d.createRange();
25
- ra.setStart(s.focusNode, s.focusOffset);
26
- ra.collapse(1);
27
-
28
- // Setup start/end points by comparing locations
29
- di = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0;
30
- r.setStart(di ? s.anchorNode : s.focusNode, di ? s.anchorOffset : s.focusOffset);
31
- r.setEnd(di ? s.focusNode : s.anchorNode, di ? s.focusOffset : s.anchorOffset);
32
- } catch (ex) {
33
- // Sometimes fails, at least we tried to do it by the book. I hope Safari 2.x will go away soooon
34
- }
35
- }
36
-
37
- return r;
38
- };
39
-
40
- // Fix setContent so it works
41
- setContent = ed.selection.setContent;
42
- ed.selection.setContent = function(h, s) {
43
- var r = this.getRng();
44
-
45
- try {
46
- setContent.call(this, h, s);
47
- } catch (ex) {
48
- // Workaround for Safari 2.x
49
- b = ed.dom.create('body');
50
- b.innerHTML = h;
51
-
52
- each(b.childNodes, function(n) {
53
- r.insertNode(n.cloneNode(true));
54
- });
55
- }
56
- };
57
-
58
- collapse = ed.selection.collapse;
59
- ed.selection.collapse = function(b) {
60
- try {
61
- collapse.call(this, b);
62
- } catch (ex) {
63
- // Safari 2.x might fail to collapse
64
- }
65
- };
66
-
67
- // Resize is not supported too buggy
68
- ed.onInit.add(function() {
69
- punymce.DOM.get(ed.settings.id + '_r').style.display = 'none';
70
- });
71
-
72
- ed.onPreInit.add(function() {
73
- Event.add(ed.getDoc(), 'click', function(e) {
74
- if (e.target.nodeName == "A") {
75
- ed.selection.select(e.target);
76
- return Event.cancel(e);
77
- }
78
- });
79
-
80
- Event.add(ed.getDoc(), 'keydown', function(e) {
81
- var s = ed.selection, n, o, r, c;
82
-
83
- if (e.charCode > 32 || e.keyCode == 13) {
84
- n = ed.dom.getParent(s.getNode(), function(n) {return n.nodeName == 'LI';});
85
-
86
- if (n) {
87
- o = s.getRng().startOffset;
88
-
89
- // Create new LI on enter
90
- if (e.keyCode == 13) {
91
- // Empty list item
92
- if (!n.hasChildNodes()) {
93
- // At end of list then use default behavior
94
- if (!n.nextSibling || n.nextSibling.nodeName != 'LI') {
95
- r = ed.dom.getParent(s.getNode(), function(n) {return /(UL|OL)/.test(n.nodeName);});
96
- n.parentNode.removeChild(n);
97
- s.select(r.nextSibling);
98
- return;
99
- }
100
-
101
- // Cancel if in middle of list
102
- return Event.cancel(e);
103
- }
104
-
105
- // Insert temp character
106
- c = ed.getDoc().createTextNode('\u00a0');
107
- n.appendChild(c);
108
- //s.getSel().setBaseAndExtent(c, 0, c, 0);
109
- window.setTimeout(function() {
110
- var n = s.getNode();
111
-
112
- if (n.firstChild && n.firstChild.nodeValue.charAt(0) == '\u00a0') {
113
- n.removeChild(n.firstChild);
114
- s.select(n);
115
- }
116
- }, 1);
117
- } else {
118
- // Get char and check if it's alpha numeric
119
- c = String.fromCharCode(e.charCode);
120
- if (!/^\w$/.test(c))
121
- return;
122
-
123
- s.setContent(c);
124
- r = s.getRng();
125
- s = s.getSel();
126
- n = s.anchorNode;
127
-
128
- if (n.nodeName == 'LI') {
129
- s.setBaseAndExtent(n, 1, n, 1);
130
- } else {
131
- n = n.nextSibling;
132
- s.setBaseAndExtent(n, 1, n, 1);
133
- }
134
-
135
- return Event.cancel(e);
136
- }
137
- }
138
- }
139
- });
140
- });
141
-
142
- function wrap(n, a) {
143
- var d = ed.getDoc(), r, s;
144
-
145
- a = a || {};
146
-
147
- d.execCommand('FontName', false, '_tmp');
148
-
149
- each(ed.dom.select('span'), function(e) {
150
- if (e.style.fontFamily == '_tmp') {
151
- r = rename(e, n, a);
152
-
153
- if (!s)
154
- s = r;
155
- }
156
- });
157
-
158
- // Select
159
- r = r.firstChild;
160
- ed.selection.getSel().setBaseAndExtent(s, 0, r, r.nodeValue.length);
161
- };
162
-
163
- function insertList(n) {
164
- var s = ed.selection, li;
165
-
166
- s.setContent('<' + n + '><li id="_tmp"></li></' + n + '>');
167
- li = ed.dom.get('_tmp');
168
- li.id = '';
169
-
170
- s.select(li);
171
- s.collapse(1);
172
- };
173
-
174
- function getParentBlock(n) {
175
- return ed.dom.getParent(n, function(n) {
176
- return /^(H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CODE|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n.nodeName);
177
- });
178
- };
179
-
180
- function rename(e, n, a) {
181
- var d = ed.getDoc(), r;
182
-
183
- a = a || {};
184
- r = d.createElement(n);
185
-
186
- // Copy attributes
187
- each(e.attributes, function(n) {
188
- if (n.specified && n.nodeValue)
189
- r.setAttribute(n.nodeName, n.nodeValue);
190
- });
191
-
192
- // Add attributes
193
- each(a, function(v, k) {
194
- r.setAttribute(k, v);
195
- });
196
-
197
- // Add children
198
- each(e.childNodes, function(n) {
199
- r.appendChild(n.cloneNode(true));
200
- });
201
-
202
- // Replace old node
203
- e.parentNode.replaceChild(r, e);
204
-
205
- return r;
206
- };
207
-
208
- // Fake commands
209
- punymce.extend(ed.commands, {
210
- IncreaseFontSize : function() {
211
- var d = ed.getDoc(), v = parseInt(d.queryCommandValue('FontSize'));
212
-
213
- d.execCommand('FontSize', false, (v + 1) + 'px');
214
- },
215
-
216
- DecreaseFontSize : function() {
217
- var d = ed.getDoc(), v = parseInt(d.queryCommandValue('FontSize'));
218
-
219
- if (v > 0)
220
- d.execCommand('FontSize', false, (v - 1) + 'px');
221
- },
222
-
223
- Strikethrough : function() {
224
- wrap('strike');
225
- },
226
-
227
- CreateLink : function(u, v) {
228
- wrap('a', {href : v, mce_href : v});
229
- },
230
-
231
- Unlink : function() {
232
- var s = ed.selection;
233
-
234
- s.setContent(s.getContent().replace(/(<a[^>]+>|<\/a>)/, ''));
235
- },
236
-
237
- RemoveFormat : function() {
238
- var s = ed.selection;
239
-
240
- s.setContent(s.getContent().replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g, ''));
241
- },
242
-
243
- FormatBlock : function(u, v) {
244
- var s = ed.selection, n;
245
-
246
- n = getParentBlock(ed.selection.getNode());
247
-
248
- if (n)
249
- r = rename(n, v.replace(/<|>/g, ''));
250
-
251
- s.select(r);
252
- s.collapse(1);
253
- },
254
-
255
- InsertUnorderedList : function() {
256
- insertList('ul');
257
- },
258
-
259
- InsertOrderedList : function() {
260
- insertList('ol');
261
- },
262
-
263
- Indent : function() {
264
- var n = getParentBlock(ed.selection.getNode()), v;
265
-
266
- if (n) {
267
- v = parseInt(n.style.paddingLeft) || 0;
268
- n.style.paddingLeft = (v + 10) + 'px';
269
- }
270
- },
271
-
272
- Outdent : function() {
273
- var n = getParentBlock(ed.selection.getNode()), v;
274
-
275
- if (n) {
276
- v = parseInt(n.style.paddingLeft) || 0;
277
-
278
- if (v >= 10)
279
- n.style.paddingLeft = (v - 10) + 'px';
280
- }
281
- }
282
- });
283
- };
284
- })(punymce);
@@ -1 +0,0 @@
1
- (function(a){function b(f,d){var e,c;e=d.parentNode;c=d.nextSibling;if(c){e.insertBefore(f,c)}else{e.appendChild(f)}return f}a.plugins.TabFocus=function(d){var c=a.Event,e=a.DOM;d.onInit.add(function(){var g,f,h;h=b(e.create("a",{href:"#"}),e.get(d.settings.id+"_c"));c.add(h,"focus",function(i){d.getWin().focus()});c.add(d.getDoc(),"keydown",function(i){if(i.keyCode==9){return c.cancel(i)}});c.add(d.getDoc(),"keydown",function(i){if(i.keyCode==9){window.focus();e.get(d.settings.tabfocus_id).focus()}})})}})(punymce);
@@ -1,45 +0,0 @@
1
- (function(punymce) {
2
- function insertAfter(n, r) {
3
- var p, ns;
4
-
5
- p = r.parentNode;
6
- ns = r.nextSibling;
7
-
8
- if (ns)
9
- p.insertBefore(n, ns);
10
- else
11
- p.appendChild(n);
12
-
13
- return n;
14
- };
15
-
16
- punymce.plugins.TabFocus = function(ed) {
17
- var Event = punymce.Event, DOM = punymce.DOM;
18
-
19
- ed.onInit.add(function() {
20
- var p, ns, n;
21
-
22
- // Append an anchor element after the editor container ones this gets focused it will
23
- // focus the editor instead this makes it possible to shift tab into the editor
24
- n = insertAfter(DOM.create('a', {href : '#'}), DOM.get(ed.settings.id + '_c'));
25
-
26
- Event.add(n, 'focus', function(e) {
27
- ed.getWin().focus();
28
- });
29
-
30
- Event.add(ed.getDoc(), 'keydown', function(e) {
31
- if (e.keyCode == 9)
32
- return Event.cancel(e);
33
- });
34
-
35
- Event.add(ed.getDoc(), 'keydown', function(e) {
36
- if (e.keyCode == 9) {
37
- window.focus();
38
-
39
- // Focus the specified element
40
- DOM.get(ed.settings.tabfocus_id).focus();
41
- }
42
- });
43
- });
44
- };
45
- })(punymce);
@@ -1,7 +0,0 @@
1
- .punymce a.textcolor { background: url('../img/icons.gif') 0 0; }
2
-
3
- /* Color picker */
4
- div.punymce_color { position: absolute; display: none; background: #FFF; }
5
- div.punymce_color table { background: #FFF; }
6
- div.punymce_color td { width: 8px; height: 8px; }
7
- div.punymce_color a { display: block; width: 8px; height: 8px; border: 1px solid #808080; overflow: hidden; }
@@ -1 +0,0 @@
1
- (function(a){a.plugins.TextColor=function(d){var c="000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF";var f=a.DOM,b=a.Event,g=a.each,h=a.extend,e;if(!d.settings.textcolor||d.settings.textcolor.skip_css){f.loadCSS(a.baseURL+"/plugins/textcolor/css/editor.css")}e=h({colors:c},d.settings.textcolor);h(d.commands,{mceColor:function(w,s,o){var k,x=this,i=d.settings.id,j=f.getPos(o.target),q,l;if(d.hideMenu){return d.hideMenu()}function m(n){d.hideMenu=null;b.remove(document,"click",m);b.remove(d.getDoc(),"click",m);f.get(i+"_mcolor").style.display="none";return 1}k=f.get(i+"_mcolor");if(!k){k=f.get(i+"_t");k=f.add(document.body,"div",{id:i+"_mcolor","class":"punymce_color punymce"});k=f.add(k,"table",{"class":"punymce"});k=f.add(k,"tbody");q=8;g(e.colors.split(","),function(n){if(q==8){r=f.add(k,"tr");q=0}q++;b.add(f.add(f.add(r,"td"),"a",{href:"#",style:"background:#"+n}),"mousedown",function(p){m.call(x);d.execCommand("forecolor",0,"#"+n);return b.cancel(p)})})}b.add(document,"click",m,x);b.add(d.getDoc(),"click",m,x);d.hideMenu=m;e=f.get(i+"_mcolor").style;e.left=j.x+"px";e.top=(j.y+o.target.clientHeight+2)+"px";e.display="block"}});h(d.tools,{textcolor:{cmd:"mceColor",title:a.I18n.textcolor}})};a.extend(a.I18n,{textcolor:"Text color"})})(punymce);
@@ -1,73 +0,0 @@
1
- (function(punymce) {
2
- punymce.plugins.TextColor = function(ed) {
3
- var colors = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF';
4
- var DOM = punymce.DOM, Event = punymce.Event, each = punymce.each, extend = punymce.extend, s;
5
-
6
- if (!ed.settings.textcolor || ed.settings.textcolor.skip_css)
7
- DOM.loadCSS(punymce.baseURL + '/plugins/textcolor/css/editor.css');
8
-
9
- s = extend({
10
- colors : colors
11
- }, ed.settings.textcolor);
12
-
13
- extend(ed.commands, {
14
- mceColor : function(u, v, e) {
15
- var n, t = this, id = ed.settings.id, p = DOM.getPos(e.target), co, cb;
16
-
17
- if (ed.hideMenu)
18
- return ed.hideMenu();
19
-
20
- function hide(e) {
21
- ed.hideMenu = null;
22
- Event.remove(document, 'click', hide);
23
- Event.remove(ed.getDoc(), 'click', hide);
24
- DOM.get(id + '_mcolor').style.display = 'none';
25
- return 1;
26
- };
27
-
28
- n = DOM.get(id + '_mcolor');
29
- if (!n) {
30
- n = DOM.get(id + '_t');
31
- n = DOM.add(document.body, 'div', {id : id + '_mcolor', 'class' : 'punymce_color punymce'});
32
- n = DOM.add(n, 'table', {'class' : 'punymce'});
33
- n = DOM.add(n, 'tbody');
34
- co = 8;
35
- each(s.colors.split(','), function(c) {
36
- if (co == 8) {
37
- r = DOM.add(n, 'tr');
38
- co = 0;
39
- }
40
-
41
- co++;
42
-
43
- Event.add(DOM.add(DOM.add(r, 'td'), 'a', {href : '#', style : 'background:#' + c}), 'mousedown', function(e) {
44
- hide.call(t);
45
-
46
- ed.execCommand('forecolor', 0, '#' + c);
47
-
48
- return Event.cancel(e);
49
- });
50
- });
51
- }
52
-
53
- Event.add(document, 'click', hide, t);
54
- Event.add(ed.getDoc(), 'click', hide, t);
55
- ed.hideMenu = hide;
56
-
57
- s = DOM.get(id + '_mcolor').style;
58
- s.left = p.x + 'px';
59
- s.top = (p.y + e.target.clientHeight + 2) + 'px';
60
- s.display = 'block';
61
- }
62
- });
63
-
64
- extend(ed.tools, {
65
- textcolor : {cmd : 'mceColor', title : punymce.I18n.textcolor}
66
- });
67
- };
68
-
69
- // English i18n strings
70
- punymce.extend(punymce.I18n, {
71
- textcolor : 'Text color'
72
- });
73
- })(punymce);