radiant-forum-extension 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +37 -56
- data/VERSION +1 -1
- data/app/controllers/forum_base_controller.rb +78 -0
- data/app/controllers/forums_controller.rb +5 -34
- data/app/controllers/posts_controller.rb +61 -153
- data/app/controllers/topics_controller.rb +6 -63
- data/app/helpers/forum_helper.rb +24 -48
- data/app/models/forum.rb +5 -18
- data/app/models/post.rb +53 -55
- data/app/models/post_attachment.rb +9 -6
- data/app/models/topic.rb +20 -113
- data/app/views/admin/reader_configuration/_edit_forum.html.haml +4 -2
- data/app/views/admin/reader_configuration/_forum.html.haml +6 -2
- data/app/views/forums/_forum.html.haml +14 -20
- data/app/views/forums/_latest.html.haml +12 -0
- data/app/views/forums/_standard_parts.html.haml +49 -0
- data/app/views/forums/index.html.haml +16 -24
- data/app/views/forums/show.html.haml +18 -28
- data/app/views/pages/_comment.html.haml +1 -1
- data/app/views/posts/_attachments.html.haml +13 -0
- data/app/views/posts/_confirm_delete.html.haml +10 -0
- data/app/views/posts/_context.html.haml +16 -0
- data/app/views/posts/_edit_links.html.haml +11 -0
- data/app/views/posts/_form.html.haml +40 -2
- data/app/views/posts/_latest.html.haml +10 -17
- data/app/views/posts/_new_attachment.html.haml +2 -0
- data/app/views/posts/_post.html.haml +25 -60
- data/app/views/posts/{_search.html.haml → _search_form.html.haml} +1 -1
- data/app/views/posts/_uploader.html.haml +2 -2
- data/app/views/posts/edit.html.haml +26 -13
- data/app/views/posts/index.html.haml +19 -27
- data/app/views/posts/new.html.haml +27 -7
- data/app/views/posts/remove.html.haml +27 -0
- data/app/views/posts/show.html.haml +20 -7
- data/app/views/readers/_forum_messages.html.haml +20 -0
- data/app/views/readers/_messages_summary.html.haml +3 -0
- data/app/views/topics/_context.html.haml +12 -0
- data/app/views/topics/_latest.html.haml +14 -16
- data/app/views/topics/_locked.html.haml +1 -1
- data/app/views/topics/_replies.html.haml +6 -0
- data/app/views/topics/_reply.html.haml +23 -0
- data/app/views/topics/_topic.html.haml +14 -43
- data/app/views/topics/_voices.html.haml +5 -0
- data/app/views/topics/index.html.haml +11 -24
- data/app/views/topics/show.html.haml +25 -38
- data/config/initializers/radiant_config.rb +5 -1
- data/config/locales/en.yml +73 -27
- data/config/routes.rb +3 -4
- data/db/migrate/20101222160900_page_posts.rb +21 -0
- data/db/migrate/20101222163605_no_comment_forum.rb +10 -0
- data/db/migrate/20110105103827_topic_merely_associative.rb +23 -0
- data/db/migrate/20110111080550_detach_observer.rb +11 -0
- data/db/migrate/20110127113852_import_attachments.rb +9 -0
- data/forum_extension.rb +12 -13
- data/lib/commentable_model.rb +98 -0
- data/lib/forum_page.rb +2 -22
- data/lib/forum_reader_sessions_controller.rb +14 -0
- data/lib/forum_readers_controller.rb +2 -9
- data/lib/forum_red_cloth3.rb +23 -4
- data/lib/forum_red_cloth4.rb +23 -4
- data/lib/forum_tags.rb +298 -194
- data/lib/sanitize/config/forum.rb +47 -0
- data/public/images/furniture/blank.png +0 -0
- data/public/images/furniture/emoticons.png +0 -0
- data/public/javascripts/forum.js +349 -93
- data/public/javascripts/jquery.tools.min.js +195 -0
- data/public/punymce/blank.htm +1 -0
- data/public/punymce/css/content.css +4 -0
- data/public/punymce/css/editor.css +58 -0
- data/public/punymce/i18n/sv.js +28 -0
- data/public/punymce/img/icons.gif +0 -0
- data/public/punymce/img/icons_uncompressed.png +0 -0
- data/public/punymce/plugins/bbcode.js +1 -0
- data/public/punymce/plugins/bbcode_src.js +50 -0
- data/public/punymce/plugins/editsource/css/editor.css +3 -0
- data/public/punymce/plugins/editsource/editsource.js +1 -0
- data/public/punymce/plugins/editsource/editsource_src.js +81 -0
- data/public/punymce/plugins/editsource/img/icons.gif +0 -0
- data/public/punymce/plugins/emoticons/css/content.css +13 -0
- data/public/punymce/plugins/emoticons/css/editor.css +17 -0
- data/public/punymce/plugins/emoticons/emoticons.js +1 -0
- data/public/punymce/plugins/emoticons/emoticons_src.js +303 -0
- 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 +1 -0
- data/public/punymce/plugins/entities_src.js +37 -0
- data/public/punymce/plugins/forceblocks.js +1 -0
- data/public/punymce/plugins/forceblocks_src.js +465 -0
- data/public/punymce/plugins/forcenl.js +1 -0
- data/public/punymce/plugins/forcenl_src.js +26 -0
- data/public/punymce/plugins/image/css/editor.css +1 -0
- data/public/punymce/plugins/image/image.js +1 -0
- data/public/punymce/plugins/image/image_src.js +30 -0
- data/public/punymce/plugins/image/img/icons.gif +0 -0
- data/public/punymce/plugins/link/css/editor.css +2 -0
- data/public/punymce/plugins/link/img/icons.gif +0 -0
- data/public/punymce/plugins/link/link.js +1 -0
- data/public/punymce/plugins/link/link_src.js +36 -0
- data/public/punymce/plugins/paste.js +1 -0
- data/public/punymce/plugins/paste_src.js +169 -0
- data/public/punymce/plugins/protect.js +1 -0
- data/public/punymce/plugins/protect_src.js +30 -0
- data/public/punymce/plugins/safari2x.js +1 -0
- data/public/punymce/plugins/safari2x_src.js +284 -0
- data/public/punymce/plugins/tabfocus.js +1 -0
- data/public/punymce/plugins/tabfocus_src.js +45 -0
- data/public/punymce/plugins/textcolor/css/editor.css +7 -0
- data/public/punymce/plugins/textcolor/img/icons.gif +0 -0
- data/public/punymce/plugins/textcolor/textcolor.js +1 -0
- data/public/punymce/plugins/textcolor/textcolor_src.js +73 -0
- data/public/punymce/puny_mce.js +1 -0
- data/public/punymce/puny_mce_full.js +1 -0
- data/public/punymce/puny_mce_src.js +1460 -0
- data/public/stylesheets/sass/forum.sass +175 -169
- data/radiant-forum-extension.gemspec +81 -19
- data/spec/controllers/admin/forums_controller_spec.rb +2 -2
- data/spec/controllers/forums_controller_spec.rb +3 -6
- data/spec/controllers/posts_controller_spec.rb +76 -59
- data/spec/controllers/topics_controller_spec.rb +4 -95
- data/spec/datasets/forum_readers_dataset.rb +1 -0
- data/spec/datasets/forums_dataset.rb +91 -10
- data/spec/lib/commentable_model_spec.rb +88 -0
- data/spec/lib/forum_page_spec.rb +2 -34
- data/spec/lib/forum_site_spec.rb +2 -3
- data/spec/lib/forum_tags_spec.rb +35 -0
- data/spec/models/forum_spec.rb +31 -20
- data/spec/models/post_spec.rb +40 -39
- data/spec/models/topic_spec.rb +29 -71
- data/spec/spec_helper.rb +10 -1
- metadata +84 -22
- data/app/views/posts/_reply.html.haml +0 -35
- data/app/views/posts/_upload.html.haml +0 -2
- data/app/views/posts/preview.html.haml +0 -32
- data/app/views/posts/search.html.haml +0 -63
- data/app/views/posts/search.rss.builder +0 -14
- data/app/views/topics/_form.html.haml +0 -30
- data/app/views/topics/_help.html.haml +0 -8
- data/app/views/topics/comments.html.haml +0 -6
- data/app/views/topics/edit.html.haml +0 -26
- data/app/views/topics/new.html.haml +0 -56
- data/spec/datasets/forum_pages_dataset.rb +0 -11
- data/spec/datasets/posts_dataset.rb +0 -31
- data/spec/datasets/topics_dataset.rb +0 -37
@@ -0,0 +1 @@
|
|
1
|
+
punymce.plugins.ForceNL=function(ed){ed.onGetContent.add(function(ed,o){if(o.format=='forcenl'||o.save){punymce.each([[/<(br\s*\/)>/gi,"\n"],[/<(br.*?\/)>/gi,""]],function(v){o.content=o.content.replace(v[0],v[1])})}});ed.onSetContent.add(function(ed,o){if(o.format=='forcenl'||o.load){punymce.each([[/\n/gi,"<br />"]],function(v){o.content=o.content.replace(v[0],v[1])})}})};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// ForceNL Plugin for PunyMCE
|
2
|
+
// - Converts all <br /> to \n
|
3
|
+
punymce.plugins.ForceNL = function(ed) {
|
4
|
+
// Forces <br /> to \n
|
5
|
+
ed.onGetContent.add(function(ed, o) {
|
6
|
+
if (o.format == 'forcenl' || o.save) {
|
7
|
+
punymce.each([
|
8
|
+
[/<(br\s*\/)>/gi, "\n"],
|
9
|
+
[/<(br.*?\/)>/gi, ""]
|
10
|
+
//[<br type="_moz"/>, ""]
|
11
|
+
], function (v) {
|
12
|
+
o.content = o.content.replace(v[0], v[1]);
|
13
|
+
});
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
ed.onSetContent.add(function(ed, o) {
|
18
|
+
if (o.format == 'forcenl' || o.load) {
|
19
|
+
punymce.each([
|
20
|
+
[/\n/gi,"<br />"]
|
21
|
+
], function (v) {
|
22
|
+
o.content = o.content.replace(v[0], v[1]);
|
23
|
+
});
|
24
|
+
}
|
25
|
+
});
|
26
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
.punymce a.image { background: url('../img/icons.gif') 0 0; }
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(a){a.plugins.Image=function(b){var c=a.I18n;if(!b.settings.image||b.settings.image.skip_css){a.DOM.loadCSS(a.baseURL+"/plugins/image/css/editor.css")}a.extend(b.commands,{mceInsertImage:function(h,g,j){var d,i=b.selection.getNode();d=prompt(c.entersrc,i.nodeName=="IMG"?b.dom.getAttr(i,"src"):"");if(d){b.selection.setNode(b.dom.create("img",{src:d}))}}});a.extend(b.tools,{image:{cmd:"mceInsertImage",title:c.insertimage}})};a.extend(a.I18n,{insertimage:"Insert image",entersrc:"Enter the URL of the image"})})(punymce);
|
@@ -0,0 +1,30 @@
|
|
1
|
+
(function(punymce) {
|
2
|
+
punymce.plugins.Image = function(ed) {
|
3
|
+
var I18n = punymce.I18n;
|
4
|
+
|
5
|
+
if (!ed.settings.image || ed.settings.image.skip_css)
|
6
|
+
punymce.DOM.loadCSS(punymce.baseURL + '/plugins/image/css/editor.css');
|
7
|
+
|
8
|
+
// Add image command
|
9
|
+
punymce.extend(ed.commands, {
|
10
|
+
mceInsertImage : function(u, v, e) {
|
11
|
+
var tx, f = ed.selection.getNode();
|
12
|
+
|
13
|
+
tx = prompt(I18n.entersrc, f.nodeName == "IMG" ? ed.dom.getAttr(f, "src") : "");
|
14
|
+
if (tx)
|
15
|
+
ed.selection.setNode(ed.dom.create('img', {src : tx}));
|
16
|
+
}
|
17
|
+
});
|
18
|
+
|
19
|
+
// Add tools
|
20
|
+
punymce.extend(ed.tools, {
|
21
|
+
image : {cmd : 'mceInsertImage', title : I18n.insertimage}
|
22
|
+
});
|
23
|
+
};
|
24
|
+
|
25
|
+
// English i18n strings
|
26
|
+
punymce.extend(punymce.I18n, {
|
27
|
+
insertimage : 'Insert image',
|
28
|
+
entersrc : 'Enter the URL of the image'
|
29
|
+
});
|
30
|
+
})(punymce);
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(a){a.plugins.Link=function(b){var c=a.I18n;if(!b.settings.link||b.settings.link.skip_css){a.DOM.loadCSS(a.baseURL+"/plugins/link/css/editor.css")}a.extend(b.commands,{mceInsertLink:function(h,g,j){var d,i=b.selection.getNode();d=prompt(c.enterhref,i.nodeName=="A"?b.dom.getAttr(i,"href"):"");if(d){if(b.selection.isCollapsed()){b.selection.setContent('<a href="'+d+'">'+d+"</a>")}else{b.execCommand("CreateLink",0,d)}}}});a.extend(b.tools,{link:{cmd:"mceInsertLink",title:c.link},unlink:{cmd:"Unlink",title:c.unlink}})};a.extend(a.I18n,{link:"Insert link",unlink:"Unlink",enterhref:"Enter the URL of the link"})})(punymce);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
(function(punymce) {
|
2
|
+
punymce.plugins.Link = function(ed) {
|
3
|
+
var I18n = punymce.I18n;
|
4
|
+
|
5
|
+
if (!ed.settings.link || ed.settings.link.skip_css)
|
6
|
+
punymce.DOM.loadCSS(punymce.baseURL + '/plugins/link/css/editor.css');
|
7
|
+
|
8
|
+
// Add image command
|
9
|
+
punymce.extend(ed.commands, {
|
10
|
+
mceInsertLink : function(u, v, e) {
|
11
|
+
var tx, f = ed.selection.getNode();
|
12
|
+
|
13
|
+
tx = prompt(I18n.enterhref, f.nodeName == "A" ? ed.dom.getAttr(f, "href") : "");
|
14
|
+
if (tx) {
|
15
|
+
if (ed.selection.isCollapsed())
|
16
|
+
ed.selection.setContent('<a href="' + tx + '">' + tx + '</a>');
|
17
|
+
else
|
18
|
+
ed.execCommand('CreateLink', 0, tx);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
});
|
22
|
+
|
23
|
+
// Add tools
|
24
|
+
punymce.extend(ed.tools, {
|
25
|
+
link : {cmd : 'mceInsertLink', title : I18n.link},
|
26
|
+
unlink : {cmd : 'Unlink', title : I18n.unlink}
|
27
|
+
});
|
28
|
+
};
|
29
|
+
|
30
|
+
// English i18n strings
|
31
|
+
punymce.extend(punymce.I18n, {
|
32
|
+
link : 'Insert link',
|
33
|
+
unlink : 'Unlink',
|
34
|
+
enterhref : 'Enter the URL of the link'
|
35
|
+
});
|
36
|
+
})(punymce);
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(b){var a=b.Event;function c(h,f){var g,e;g=f.parentNode;e=f.nextSibling;if(e){g.insertBefore(h,e)}else{g.appendChild(h)}return h}function d(g,i,h){var e,f=g.getDoc().createTreeWalker(i,NodeFilter.SHOW_TEXT,null,false);if(h){return f.nextNode()}while(e=f.nextNode()){i=e}return i}b.plugins.Paste=function(f){var i=b.DOM,g;f.onPaste=new b.Dispatcher(f);function h(t){var u,s=[],m,q,l=f.selection,k,n,p,j,o;f.getWin().focus();if(g){r=f.selection.getRng();r.moveToBookmark(g);r.select()}u=t.split(/\r?\n/);if(u.length>1){t="";b.each(u,function(v){t+="<p>"+v+"</p>"});if(!b.isIE){f.execCommand("Delete");l.setContent('<span id="marker"></span>');m=f.dom.getParent(f.dom.get("marker").parentNode,function(v){s.push(v);if(/^(p|h[1-6]|div)$/i.test(v.nodeName)){return true}});if(m){f.onPaste.dispatch({text:t});k=n="";for(p=0;p<s.length;p++){k+="</"+s[p].nodeName.toLowerCase()+">"}for(p=s.length-1;p>=0;p--){n+="<"+s[p].nodeName.toLowerCase()+">"}t=k+t+n+'<span id="_caret"> </span>';f.getBody().innerHTML=f.getBody().innerHTML.replace(/<span id=\"marker\"><\/span>/gi,t);q=f.dom.get("_caret");if(!b.isGecko){q.scrollIntoView()}j=f.getDoc().createRange();j.setStartBefore(q);j.setEndAfter(q);l.setRng(j);f.execCommand("Delete");return}else{o=f.dom.get("marker");o.parentNode.removeChild(o)}}}f.selection.setContent(t);f.onPaste.dispatch({text:t})}function e(p){var q,k,m=f.selection,l=m.getSel(),o,j=f.getBody();q=f.dom.add(j,"div",{id:"_mcePaste",style:"position:absolute;left:-10000px;top:"+j.scrollTop}," ");o=m.getRng();q=q.firstChild;k=f.getDoc().createRange();k.setStart(q,0);k.setEnd(q,1);l.removeAllRanges();l.addRange(k);window.setTimeout(function(){var t=f.dom.get("_mcePaste"),s;s=t.innerHTML;t.parentNode.removeChild(t);if(o){m.setRng(o)}h(s.replace(/[\r\n]/g,"").replace(/<(\/p|br\s*\/?)>/g,"\n").replace(/<!--.*?-->/g,"").replace(/<[^>]+>/g,""))},0)}f.onInit.add(function(){if(b.isOpera){return}if(/Firefox\/2/.test(navigator.userAgent)){a.add(f.getDoc(),"keydown",function(j){if(((j.metaKey||j.ctrlKey)&&j.keyCode==86)||(j.shiftKey&&j.keyCode==45)){if(b.isIE){g=f.selection.getRng().getBookmark()}e(j)}},this)}else{a.add(b.isIE?f.getBody():f.getDoc(),"paste",function(j){var k;if(f.getWin().clipboardData){h(f.getWin().clipboardData.getData("Text"));return a.cancel(j)}if(j.clipboardData){h(j.clipboardData.getData("text/plain"));return a.cancel(j)}e(j)})}})}})(punymce);
|
@@ -0,0 +1,169 @@
|
|
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"> </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}, ' ');
|
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);
|
@@ -0,0 +1 @@
|
|
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);
|
@@ -0,0 +1,30 @@
|
|
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);
|
@@ -0,0 +1 @@
|
|
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);
|
@@ -0,0 +1,284 @@
|
|
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);
|