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
@@ -0,0 +1,230 @@
1
+ /**
2
+ @preserve CLEditor XHTML Plugin v1.0.0
3
+ http://premiumsoftware.net/cleditor
4
+ requires CLEditor v1.3.0 or later
5
+
6
+ Copyright 2010, Chris Landowski, Premium Software, LLC
7
+ Dual licensed under the MIT or GPL Version 2 licenses.
8
+
9
+ Based on John Resig's HTML Parser Project (ejohn.org)
10
+ http://ejohn.org/files/htmlparser.js
11
+ Original code by Erik Arvidsson, Mozilla Public License
12
+ http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
13
+ */
14
+
15
+ // ==ClosureCompiler==
16
+ // @compilation_level SIMPLE_OPTIMIZATIONS
17
+ // @output_file_name jquery.cleditor.xhtml.min.js
18
+ // ==/ClosureCompiler==
19
+
20
+ (function($) {
21
+
22
+ // Save the previously assigned callback handler
23
+ var oldCallback = $.cleditor.defaultOptions.updateTextArea;
24
+
25
+ // Wireup the updateTextArea callback handler
26
+ $.cleditor.defaultOptions.updateTextArea = function(html) {
27
+
28
+ // Fire the previously assigned callback handler
29
+ if (oldCallback)
30
+ html = oldCallback(html);
31
+
32
+ // Convert the HTML to XHTML
33
+ return $.cleditor.convertHTMLtoXHTML(html);
34
+
35
+ }
36
+
37
+ // Expose the convertHTMLtoXHTML method
38
+ $.cleditor.convertHTMLtoXHTML = function(html) {
39
+
40
+ // Regular Expressions for parsing tags and attributes
41
+ var startTag = /^<(\w+)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
42
+ endTag = /^<\/(\w+)[^>]*>/,
43
+ attr = /(\w+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
44
+
45
+ // Empty Elements - HTML 4.01
46
+ var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed");
47
+
48
+ // Block Elements - HTML 4.01
49
+ var block = makeMap("address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul");
50
+
51
+ // Inline Elements - HTML 4.01
52
+ var inline = makeMap("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
53
+
54
+ // Elements that you can, intentionally, leave open (and which close themselves)
55
+ var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
56
+
57
+ // Attributes that have their values filled in disabled="disabled"
58
+ var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
59
+
60
+ // Special Elements (can contain anything)
61
+ var special = makeMap("script,style");
62
+
63
+ // Stack of open tag names
64
+ var stack = [];
65
+ stack.last = function () {
66
+ return this[this.length - 1];
67
+ };
68
+
69
+ var index, match, last = html, results = "";
70
+
71
+ // Cycle through all html fragments
72
+ while (html) {
73
+
74
+ // Make sure we're not in a script or style element
75
+ if (!stack.last() || !special[stack.last()]) {
76
+
77
+ // Comment
78
+ if (html.indexOf("<!--") == 0) {
79
+ index = html.indexOf("-->");
80
+ if (index >= 0) {
81
+ results += html.substring(0, index + 3);
82
+ html = html.substring(index + 3);
83
+ }
84
+ }
85
+
86
+ // End tag
87
+ else if (html.indexOf("</") == 0) {
88
+ match = html.match(endTag);
89
+ if (match) {
90
+ html = html.substring(match[0].length);
91
+ match[0].replace(endTag, parseEndTag);
92
+ }
93
+ }
94
+
95
+ // Start tag
96
+ else if (html.indexOf("<") == 0) {
97
+ match = html.match(startTag);
98
+ if (match) {
99
+ html = html.substring(match[0].length);
100
+ match[0].replace(startTag, parseStartTag);
101
+ }
102
+ }
103
+
104
+ // Text
105
+ else {
106
+ index = html.indexOf("<");
107
+ results += (index < 0 ? html : html.substring(0, index));
108
+ html = index < 0 ? "" : html.substring(index);
109
+ }
110
+ }
111
+
112
+ // Handle script and style tags
113
+ else {
114
+ html = html.replace(new RegExp("(.*)<\/" + stack.last() + "[^>]*>"), function (all, text) {
115
+ text = text.replace(/<!--(.*?)-->/g, "$1")
116
+ .replace(/<!\[CDATA\[(.*?)]]>/g, "$1");
117
+ results += text;
118
+ return "";
119
+ });
120
+ parseEndTag("", stack.last());
121
+ }
122
+
123
+ // Handle parsing error
124
+ if (html == last)
125
+ throw "Parse Error: " + html;
126
+ last = html;
127
+ }
128
+
129
+ // Clean up any remaining tags
130
+ parseEndTag();
131
+
132
+ // Replace depreciated tags
133
+ replace(/<b>(.*?)<\/b>/g, "<strong>$1</strong>");
134
+ replace(/<i>(.*?)<\/i>/g, "<em>$1</em>");
135
+
136
+ // Return the XHTML
137
+ return results;
138
+
139
+ //-----------------
140
+ // Helper Functions
141
+ //-----------------
142
+
143
+ // makeMap - creates a map array object from the passed in comma delimitted string
144
+ function makeMap(str) {
145
+ var obj = {}, items = str.split(",");
146
+ for (var i = 0; i < items.length; i++)
147
+ obj[items[i]] = true;
148
+ return obj;
149
+ }
150
+
151
+ // parseStartTag - handles an opening tag
152
+ function parseStartTag(tag, tagName, rest, unary) {
153
+
154
+ // IE generates tags in uppercase
155
+ tagName = tagName.toLowerCase();
156
+
157
+ // Close all inline tags before this block tag
158
+ if (block[tagName])
159
+ while (stack.last() && inline[stack.last()])
160
+ parseEndTag("", stack.last());
161
+
162
+ // Close the self closing tag prior to this one
163
+ if (closeSelf[tagName] && stack.last() == tagName)
164
+ parseEndTag("", tagName);
165
+
166
+ // Push tag onto the stack
167
+ unary = empty[tagName] || !!unary;
168
+ if (!unary)
169
+ stack.push(tagName);
170
+
171
+ // Load the tags attributes
172
+ var attrs = [];
173
+
174
+ rest.replace(attr, function (match, name) {
175
+ var value = arguments[2] ? arguments[2] :
176
+ arguments[3] ? arguments[3] :
177
+ arguments[4] ? arguments[4] :
178
+ fillAttrs[name] ? name : "";
179
+
180
+ attrs.push({
181
+ name: name,
182
+ escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
183
+ });
184
+
185
+ });
186
+
187
+ // Append the tag to the results
188
+ results += "<" + tagName;
189
+
190
+ for (var i = 0; i < attrs.length; i++)
191
+ results += " " + attrs[i].name + '="' + attrs[i].escaped + '"';
192
+
193
+ results += (unary ? "/" : "") + ">";
194
+
195
+ }
196
+
197
+ // parseEndTag - handles a closing tag
198
+ function parseEndTag(tag, tagName) {
199
+
200
+ // If no tag name is provided, clean shop
201
+ if (!tagName)
202
+ var pos = 0;
203
+
204
+ // Find the closest opened tag of the same type
205
+ else {
206
+ tagName = tagName.toLowerCase();
207
+ for (var pos = stack.length - 1; pos >= 0; pos--)
208
+ if (stack[pos] == tagName)
209
+ break;
210
+ }
211
+
212
+ if (pos >= 0) {
213
+ // Close all the open elements, up the stack
214
+ for (var i = stack.length - 1; i >= pos; i--)
215
+ results += "</" + stack[i] + ">";
216
+
217
+ // Remove the open elements from the stack
218
+ stack.length = pos;
219
+ }
220
+
221
+ }
222
+
223
+ // replace - replace shorthand
224
+ function replace(regexp, newstring) {
225
+ results = results.replace(regexp, newstring);
226
+ }
227
+
228
+ }
229
+
230
+ })(jQuery);
@@ -9,54 +9,63 @@
9
9
  */
10
10
 
11
11
  (function($) {
12
+ $.ajaxSettings.accepts.html = $.ajaxSettings.accepts.script;
12
13
 
13
14
  function RemoteAction (url, holder) {
14
15
  var self = this;
15
- $.extend(self, {
16
- url: url,
17
- holder: holder,
18
- container: null,
19
- form: null,
16
+ $.extend(self, {
17
+ url: url,
18
+ holder: holder,
19
+ container: null,
20
+ form: null,
20
21
 
21
- fetch: function () {
22
- if (self.showing()) self.hide();
22
+ fetch: function () {
23
+ if (self.showing()) self.hide();
23
24
  else if (self.form) self.show();
24
25
  else {
25
26
  self.wait();
26
- $.get(self.url, self.step);
27
+ $.get(self.url, self.step, 'html');
27
28
  }
28
29
  },
29
30
  submit: function (e) {
30
31
  var ajaxable = true;
32
+ // file to upload means not ajaxable at all
31
33
  self.container.find('input:file').each(function () {
32
34
  var file = $(this).val();
33
35
  if (file && file != "") ajaxable = false;
34
36
  });
37
+ // presence of title field means not ajaxable because that appears elsewhere on the page
38
+ if (self.container.find('input:text').length > 0) ajaxable = false;
39
+
35
40
  if (ajaxable) {
36
41
  e.preventDefault();
37
- self.form.find('textarea.toolbarred').read_editor();
38
- $.post(self.form.attr('action'), self.form.serialize(), self.step);
42
+ var editor = $(this).data('editor');
43
+ self.form.find('textarea').each(function (box) {
44
+ var editor = $(box).data('editor');
45
+ if (editor) editor.save();
46
+ });
47
+ $.post(self.form.attr('action'), self.form.serialize(), self.step, 'html');
39
48
  } else {
40
- return true; // allow event through so that uploads are sent by normal HTTP POST
49
+ return true; // allow event through so that form is sent by normal HTTP POST
41
50
  // toolbar is read in onSubmit
42
51
  }
43
52
  },
44
53
  step: function (results) {
45
54
  self.unwait();
46
55
  if (results) self.container.html(results);
56
+ self.container.find('.cancel').click(self.cancel);
47
57
  self.form = self.container.find('form');
48
58
  if (self.form.length > 0) {
49
59
  self.form.submit(self.submit);
50
- self.form.find('div.upload_stack').upload_stack();
51
- self.form.find('a.cancel').click(self.cancel);
52
- self.form.find("textarea.toolbarred").add_editor({});
60
+ self.form.init_forum();
53
61
  self.show();
54
62
  } else {
63
+ $(results).init_forum();
55
64
  holder.replaceWith(results);
56
65
  }
57
66
  },
58
67
  cancel: function (event) {
59
- squash(event);
68
+ if (event) event.preventDefault();
60
69
  self.unwait();
61
70
  self.hide();
62
71
  },
@@ -78,31 +87,31 @@
78
87
  unwait: function () {
79
88
  holder.unwait();
80
89
  }
81
- });
82
- self.container = $('<div class="remote_form" />').hide();
83
- self.holder.append(self.container);
90
+ });
91
+ self.container = $('<div class="remote_form" />').hide();
92
+ self.holder.append(self.container);
84
93
  }
85
94
 
86
- function ActionHolder(container, conf) {
95
+ function ActionHolder(container, conf) {
87
96
  var self = this;
88
- $.extend(self, {
89
- container: container,
90
- wrapper: container.find('.wrapper'),
91
- actions: {},
92
- initActions: function () {
93
- self.actions = {};
94
- self.container.find('a.remote').each(function () {
95
- var a = $(this);
96
- var href = a.attr('href');
97
+ $.extend(self, {
98
+ container: container,
99
+ wrapper: container.find('.wrapper'),
100
+ actions: {},
101
+ initActions: function () {
102
+ self.actions = {};
103
+ self.container.find('a.remote').each(function () {
104
+ var a = $(this);
105
+ var href = a.attr('href');
97
106
  self.addAction(href);
98
107
  a.click(function (event) {
99
- squash(event);
108
+ if (event) event.preventDefault();
100
109
  a.addClass('waiting');
101
110
  self.showAction(href);
102
111
  });
103
112
  if (a.is('.autoload')) self.showAction(href);
104
- });
105
- },
113
+ });
114
+ },
106
115
  addAction: function (url) {
107
116
  if (!self.actions[url]) self.actions[url] = new RemoteAction(url, self);
108
117
  return self.actions[url];
@@ -127,7 +136,7 @@
127
136
  self.wrapper.hide();
128
137
  },
129
138
  toggle: function (event) {
130
- squash(event);
139
+ if (event) event.preventDefault();
131
140
  if (self.wrapper.is(":visible")) self.hide();
132
141
  else self.show();
133
142
  },
@@ -139,23 +148,23 @@
139
148
  self.container.removeClass('waiting');
140
149
  self.container.find('a.remote').removeClass('waiting');
141
150
  }
142
- });
143
- self.initActions();
144
- }
145
-
146
- $.fn.enable_remote_actions = function(conf) {
147
- this.each(function() {
148
- new ActionHolder($(this), conf);
149
- });
150
- return this;
151
- };
151
+ });
152
+ self.initActions();
153
+ }
154
+
155
+ $.fn.enable_remote_actions = function(conf) {
156
+ this.each(function() {
157
+ new ActionHolder($(this), conf);
158
+ });
159
+ return this;
160
+ };
152
161
 
153
- function HideablePost(container, conf) {
162
+ function HideablePost(container, conf) {
154
163
  var self = this;
155
- $.extend(self, {
156
- head: container.find('.post_header'),
157
- body: container.find('.post_body'),
158
- shower: null,
164
+ $.extend(self, {
165
+ head: container.find('.post_header'),
166
+ body: container.find('.post_body'),
167
+ shower: null,
159
168
  show: function () {
160
169
  self.body.slideDown();
161
170
  self.shower.text('Hide');
@@ -165,36 +174,36 @@
165
174
  self.shower.text('Show');
166
175
  },
167
176
  toggle: function (event) {
168
- squash(event);
177
+ if (event) event.preventDefault();
169
178
  if (self.body.is(":visible")) self.hide();
170
179
  else self.show();
171
180
  }
172
- });
181
+ });
173
182
  if ($('a.prev_page').length > 0) {
174
- self.shower = $('<a href="#" class="shower">Hide</a>').appendTo(self.head.find('p.context'));
183
+ self.shower = $('<a href="#" class="shower">Hide</a>').appendTo(self.head.find('p.context'));
175
184
  self.shower.click(self.toggle);
176
185
  self.hide();
177
186
  }
178
- }
187
+ }
179
188
 
180
- $.fn.hideable_post = function() {
181
- this.each(function() {
182
- new HideablePost($(this));
183
- });
184
- return this;
185
- };
189
+ $.fn.hideable_post = function() {
190
+ this.each(function() {
191
+ new HideablePost($(this));
192
+ });
193
+ return this;
194
+ };
186
195
 
187
- function UploadStack(container) {
196
+ function UploadStack(container) {
188
197
  var self = this;
189
- $.extend(self, {
190
- container: container,
198
+ $.extend(self, {
199
+ container: container,
191
200
  attachments_list: container.find('ul.attachments'),
192
201
  uploads_list: container.find('ul.uploads'),
193
202
  selector: container.find('div.selector'),
194
203
  file_field: container.find('div.selector').find('input'),
195
204
 
196
- addUpload: function(event) {
197
- squash(event);
205
+ addUpload: function(event) {
206
+ if (event) event.preventDefault();
198
207
  var upload_field = self.file_field.clone();
199
208
  var nest_id = self.attachmentCount() + self.uploadCount(); // nb. starts at zero so this total is +1
200
209
  var container = $('<li class="attachment">' + upload_field.val() + '</li>');
@@ -225,67 +234,97 @@
225
234
  });
226
235
  self.attachments_list.find('li').add_remover();
227
236
  self.file_field.change(self.addUpload);
228
- }
229
-
230
- $.fn.upload_stack = function(conf) {
231
- this.each(function() {
232
- el = new UploadStack($(this), conf);
233
- });
234
- return this;
235
- };
237
+ }
238
+
239
+ $.fn.upload_stack = function(conf) {
240
+ this.each(function() {
241
+ el = new UploadStack($(this), conf);
242
+ });
243
+ return this;
244
+ };
236
245
 
237
- $.fn.add_remover = function() {
238
- this.each(function() {
239
- var self = $(this);
246
+ $.fn.add_remover = function() {
247
+ this.each(function() {
248
+ var self = $(this);
240
249
  var remover = $('<a href="#" class="remove">remove</a>');
241
250
  remover.click(function (event) {
242
- squash(event);
251
+ if (event) event.preventDefault();
243
252
  self.slideUp('500', function() {
244
253
  self.find('input.checkbox').attr('checked', true);
245
254
  self.find('input.filefield').remove();
246
255
  });
247
256
  });
248
257
  self.append(remover);
249
- });
250
- return self;
251
- };
258
+ });
259
+ return self;
260
+ };
252
261
 
253
- $.fn.add_editor = function() {
254
- this.each(function() {
255
- var self = $(this);
256
- var editor = new punymce.Editor({
257
- id : self.attr('id'),
258
- plugins : 'Link,Image,Emoticons,EditSource',
259
- toolbar : 'bold,italic,link,unlink,image,emoticons,editsource',
260
- width : 510,
261
- height : 375,
262
- resize : true
262
+ $.fn.add_editor = function() {
263
+ if(window.punymce !== undefined) {
264
+ this.each(function() {
265
+ var self = $(this);
266
+ var editor = new punymce.Editor({
267
+ id : self.attr('id'),
268
+ plugins : 'Link,Image,Emoticons,EditSource',
269
+ toolbar : 'bold,italic,link,unlink,image,emoticons,editsource',
270
+ width : 510,
271
+ height : 375,
272
+ resize : true
273
+ });
274
+ self.data('editor', editor);
263
275
  });
264
- self.data('editor', editor);
265
- });
266
- return this;
267
- };
268
-
269
- $.fn.read_editor = function() {
270
- this.each(function() {
271
- var self = $(this);
272
- if (self.data('editor')) {
273
- self.val(self.data('editor').getContent());
274
- }
275
- });
276
- return this;
277
- };
276
+ }
277
+ return this;
278
+ };
278
279
 
280
+ $.fn.capture_search = function() {
281
+ this.each(function() {
282
+ var self = $(this);
283
+ var target = $('#results');
284
+ if (target.length >= 1) {
285
+ self.submit(function (e) {
286
+ if(e) e.preventDefault();
287
+ self.addClass("waiting");
288
+ target.addClass("waiting");
289
+ target.load(self.attr('action'), self.serialize(), function () {
290
+ self.removeClass("waiting");
291
+ target.removeClass("waiting");
292
+ });
293
+ });
294
+ } else {
295
+ return true;
296
+ }
297
+ });
298
+ return this;
299
+ };
300
+
301
+ $.fn.add_rte = function() {
302
+ this.cleditor({
303
+ width: 630,
304
+ height: 400,
305
+ controls: "bold italic underline strikethrough size removeformat | bullets numbering outdent indent | icon image link unlink | source"
306
+ });
307
+ };
308
+
309
+ $.fn.init_forum = function () {
310
+ this.each(function() {
311
+ var self = $(this);
312
+ self.find(".post").enable_remote_actions();
313
+ self.find(".new_post").enable_remote_actions();
314
+ self.find(".post.first").hideable_post();
315
+ self.find(".upload_stack").upload_stack();
316
+ self.find(".forum_search").capture_search();
317
+ self.find("textarea.rte").add_rte();
318
+ });
319
+ return this;
320
+ };
279
321
  })(jQuery);
280
322
 
281
323
  $(function() {
282
- $(".post").enable_remote_actions({});
283
- $(".new_post").enable_remote_actions({});
284
- $(".post.first").hideable_post({});
285
- $(".upload_stack").upload_stack({});
286
- $(".toolbarred").add_editor({});
324
+ $(document).init_forum();
325
+
287
326
  $("input:submit").live('click', function (event) {
288
- var self = $(this);
327
+ var self = $(this);
289
328
  self.after('<span class="waiting">Please wait</span>');
290
329
  self.hide();
291
330
  return true;