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.
- data/README.md +20 -16
- data/Rakefile +0 -16
- data/app/controllers/forum_base_controller.rb +32 -10
- data/app/controllers/posts_controller.rb +37 -14
- data/app/helpers/forum_helper.rb +23 -16
- data/app/models/forum.rb +11 -7
- data/app/models/post.rb +53 -14
- data/app/models/post_attachment.rb +1 -1
- data/app/models/topic.rb +21 -8
- data/app/views/admin/dashboard/_forum_dashboard.html.haml +51 -0
- data/app/views/admin/forums/_form.html.haml +12 -0
- data/app/views/admin/forums/edit.html.haml +1 -1
- data/app/views/admin/forums/index.html.haml +16 -20
- data/app/views/admin/posts/_form.html.haml +2 -2
- data/app/views/admin/posts/edit.html.haml +1 -1
- data/app/views/admin/posts/index.html.haml +5 -5
- data/app/views/admin/reader_configuration/_edit_forum.html.haml +6 -0
- data/app/views/admin/reader_configuration/_forum.html.haml +5 -1
- data/app/views/admin/topics/_form.html.haml +3 -5
- data/app/views/admin/topics/edit.html.haml +1 -1
- data/app/views/admin/topics/index.html.haml +5 -5
- data/app/views/forums/_forum.html.haml +6 -5
- data/app/views/forums/_latest.html.haml +14 -12
- data/app/views/forums/_statistics.html.haml +4 -4
- data/app/views/forums/index.html.haml +8 -10
- data/app/views/forums/index.rss.builder +2 -2
- data/app/views/forums/show.html.haml +12 -15
- data/app/views/pages/_add_comment.html.haml +9 -8
- data/app/views/pages/_comments.html.haml +3 -3
- data/app/views/posts/_attachments.html.haml +1 -1
- data/app/views/posts/_confirm_delete.html.haml +7 -2
- data/app/views/posts/_context.html.haml +5 -5
- data/app/views/posts/_edit_links.html.haml +4 -4
- data/app/views/posts/_form.html.haml +15 -12
- data/app/views/posts/_ineditable.html.haml +7 -0
- data/app/views/posts/_latest.html.haml +3 -8
- data/app/views/posts/_minimal.html.haml +7 -0
- data/app/views/posts/_post.html.haml +20 -17
- data/app/views/posts/_post.rss.builder +2 -2
- data/app/views/posts/_search_form.html.haml +13 -13
- data/app/views/posts/_search_results.html.haml +15 -0
- data/app/views/posts/_search_summary.html.haml +13 -0
- data/app/views/posts/_uploader.html.haml +1 -1
- data/app/views/posts/edit.html.haml +22 -21
- data/app/views/posts/index.html.haml +12 -19
- data/app/views/posts/index.rss.builder +6 -6
- data/app/views/posts/new.html.haml +19 -22
- data/app/views/posts/remove.html.haml +15 -15
- data/app/views/posts/show.html.haml +16 -10
- data/app/views/readers/_forum_messages.html.haml +9 -6
- data/app/views/readers/_messages_summary.html.haml +1 -1
- data/app/views/shared/_standard_forum_parts.html.haml +41 -0
- data/app/views/topics/_busiest.html.haml +9 -8
- data/app/views/topics/_context.html.haml +11 -8
- data/app/views/topics/_latest.html.haml +2 -2
- data/app/views/topics/_locked.html.haml +1 -1
- data/app/views/topics/_minimal.html.haml +2 -2
- data/app/views/topics/_replies.html.haml +4 -3
- data/app/views/topics/_reply.html.haml +13 -8
- data/app/views/topics/_topic.html.haml +5 -9
- data/app/views/topics/_topic.rss.builder +1 -1
- data/app/views/topics/index.html.haml +14 -10
- data/app/views/topics/index.rss.builder +2 -2
- data/app/views/topics/show.html.haml +20 -19
- data/app/views/topics/show.rss.builder +3 -3
- data/config/initializers/radiant_config.rb +4 -1
- data/config/locales/en.yml +202 -178
- data/db/migrate/002_pages_commentable.rb +1 -2
- data/db/migrate/004_sample_layout.rb +38 -15
- data/db/migrate/20110111080550_detach_observer.rb +4 -4
- data/db/migrate/20110613112823_search_text.rb +9 -0
- data/db/migrate/20110613130230_tidy_up.rb +27 -0
- data/db/migrate/20110630083446_page_replied_at.rb +11 -0
- data/forum_extension.rb +13 -11
- data/lib/commentable_model.rb +13 -9
- data/lib/forum_admin_ui.rb +6 -6
- data/lib/forum_page.rb +5 -3
- data/lib/forum_reader.rb +7 -1
- data/lib/forum_reader_sessions_controller.rb +2 -3
- data/lib/forum_tags.rb +126 -11
- data/lib/radiant-forum-extension.rb +8 -0
- data/public/cleditor/images/buttons.gif +0 -0
- data/public/cleditor/images/icons/1.gif +0 -0
- data/public/cleditor/images/icons/10.gif +0 -0
- data/public/cleditor/images/icons/11.gif +0 -0
- data/public/cleditor/images/icons/12.gif +0 -0
- data/public/cleditor/images/icons/2.gif +0 -0
- data/public/cleditor/images/icons/3.gif +0 -0
- data/public/cleditor/images/icons/4.gif +0 -0
- data/public/cleditor/images/icons/5.gif +0 -0
- data/public/cleditor/images/icons/6.gif +0 -0
- data/public/cleditor/images/icons/7.gif +0 -0
- data/public/cleditor/images/icons/8.gif +0 -0
- data/public/cleditor/images/icons/9.gif +0 -0
- data/public/cleditor/images/icons/icons.gif +0 -0
- data/public/cleditor/images/toolbar.gif +0 -0
- data/public/cleditor/jquery.cleditor.css +24 -0
- data/public/cleditor/jquery.cleditor.icon.js +65 -0
- data/public/cleditor/jquery.cleditor.js +1132 -0
- data/public/cleditor/jquery.cleditor.xhtml.js +230 -0
- data/public/javascripts/forum.js +146 -107
- data/public/stylesheets/sass/forum.sass +94 -58
- data/radiant-forum-extension.gemspec +25 -276
- data/spec/controllers/forums_controller_spec.rb +0 -7
- data/spec/controllers/posts_controller_spec.rb +20 -37
- data/spec/controllers/topics_controller_spec.rb +1 -7
- data/spec/datasets/forums_dataset.rb +38 -40
- data/spec/lib/commentable_model_spec.rb +26 -38
- data/spec/lib/forum_reader_spec.rb +0 -4
- data/spec/models/forum_spec.rb +46 -16
- data/spec/models/post_spec.rb +10 -6
- data/spec/models/topic_spec.rb +26 -17
- data/spec/spec_helper.rb +1 -0
- metadata +66 -99
- data/VERSION +0 -1
- data/app/views/forums/_standard_parts.html.haml +0 -59
- data/lib/sanitize/config/forum.rb +0 -49
- data/public/javascripts/gallery.js +0 -275
- data/public/punymce/blank.htm +0 -1
- data/public/punymce/css/content.css +0 -4
- data/public/punymce/css/editor.css +0 -58
- data/public/punymce/i18n/sv.js +0 -28
- data/public/punymce/img/icons.gif +0 -0
- data/public/punymce/img/icons_uncompressed.png +0 -0
- data/public/punymce/plugins/bbcode.js +0 -1
- data/public/punymce/plugins/bbcode_src.js +0 -50
- data/public/punymce/plugins/editsource/css/editor.css +0 -3
- data/public/punymce/plugins/editsource/editsource.js +0 -1
- data/public/punymce/plugins/editsource/editsource_src.js +0 -81
- data/public/punymce/plugins/editsource/img/icons.gif +0 -0
- data/public/punymce/plugins/emoticons/css/content.css +0 -13
- data/public/punymce/plugins/emoticons/css/editor.css +0 -17
- data/public/punymce/plugins/emoticons/emoticons.js +0 -1
- data/public/punymce/plugins/emoticons/emoticons_src.js +0 -303
- data/public/punymce/plugins/emoticons/img/emoticons.gif +0 -0
- data/public/punymce/plugins/emoticons/img/emoticons.png +0 -0
- data/public/punymce/plugins/emoticons/img/trans.gif +0 -0
- data/public/punymce/plugins/entities.js +0 -1
- data/public/punymce/plugins/entities_src.js +0 -37
- data/public/punymce/plugins/forceblocks.js +0 -1
- data/public/punymce/plugins/forceblocks_src.js +0 -465
- data/public/punymce/plugins/forcenl.js +0 -1
- data/public/punymce/plugins/forcenl_src.js +0 -26
- data/public/punymce/plugins/image/css/editor.css +0 -1
- data/public/punymce/plugins/image/image.js +0 -1
- data/public/punymce/plugins/image/image_src.js +0 -30
- data/public/punymce/plugins/image/img/icons.gif +0 -0
- data/public/punymce/plugins/link/css/editor.css +0 -2
- data/public/punymce/plugins/link/img/icons.gif +0 -0
- data/public/punymce/plugins/link/link.js +0 -1
- data/public/punymce/plugins/link/link_src.js +0 -36
- data/public/punymce/plugins/paste.js +0 -1
- data/public/punymce/plugins/paste_src.js +0 -169
- data/public/punymce/plugins/protect.js +0 -1
- data/public/punymce/plugins/protect_src.js +0 -30
- data/public/punymce/plugins/safari2x.js +0 -1
- data/public/punymce/plugins/safari2x_src.js +0 -284
- data/public/punymce/plugins/tabfocus.js +0 -1
- data/public/punymce/plugins/tabfocus_src.js +0 -45
- data/public/punymce/plugins/textcolor/css/editor.css +0 -7
- data/public/punymce/plugins/textcolor/img/icons.gif +0 -0
- data/public/punymce/plugins/textcolor/textcolor.js +0 -1
- data/public/punymce/plugins/textcolor/textcolor_src.js +0 -73
- data/public/punymce/puny_mce.js +0 -1
- data/public/punymce/puny_mce_full.js +0 -1
- 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);
|
data/public/javascripts/forum.js
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
$.extend(self, {
|
17
|
+
url: url,
|
18
|
+
holder: holder,
|
19
|
+
container: null,
|
20
|
+
form: null,
|
20
21
|
|
21
|
-
|
22
|
-
|
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
|
-
|
38
|
-
|
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
|
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.
|
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
|
-
|
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
|
-
|
83
|
-
|
90
|
+
});
|
91
|
+
self.container = $('<div class="remote_form" />').hide();
|
92
|
+
self.holder.append(self.container);
|
84
93
|
}
|
85
94
|
|
86
|
-
|
95
|
+
function ActionHolder(container, conf) {
|
87
96
|
var self = this;
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
-
|
162
|
+
function HideablePost(container, conf) {
|
154
163
|
var self = this;
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
189
|
+
$.fn.hideable_post = function() {
|
190
|
+
this.each(function() {
|
191
|
+
new HideablePost($(this));
|
192
|
+
});
|
193
|
+
return this;
|
194
|
+
};
|
186
195
|
|
187
|
-
|
196
|
+
function UploadStack(container) {
|
188
197
|
var self = this;
|
189
|
-
|
190
|
-
|
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
|
-
|
197
|
-
|
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
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
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
|
-
|
238
|
-
|
239
|
-
|
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
|
-
|
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
|
-
|
251
|
-
|
258
|
+
});
|
259
|
+
return self;
|
260
|
+
};
|
252
261
|
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
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
|
-
|
265
|
-
|
266
|
-
|
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
|
-
$(
|
283
|
-
|
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
|
-
|
327
|
+
var self = $(this);
|
289
328
|
self.after('<span class="waiting">Please wait</span>');
|
290
329
|
self.hide();
|
291
330
|
return true;
|