noodall-ui 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/noodall/ui/version.rb +1 -1
- data/public/images/admin/youtube.gif +0 -0
- data/public/javascripts/admin/application.js +1 -1
- data/public/javascripts/admin/tiny_mce_config.js +14 -2
- data/public/javascripts/admin/tiny_mce_config.js.orig +147 -0
- data/public/javascripts/tiny_mce/plugins/addvideo/dialog.htm +19 -0
- data/public/javascripts/tiny_mce/plugins/addvideo/editor_plugin.js +1 -0
- data/public/javascripts/tiny_mce/plugins/addvideo/editor_plugin_src.js +84 -0
- data/public/javascripts/tiny_mce/plugins/addvideo/img/youtube.gif +0 -0
- data/public/javascripts/tiny_mce/plugins/addvideo/js/dialog.js +33 -0
- data/public/javascripts/tiny_mce/plugins/addvideo/langs/en.js +3 -0
- data/public/javascripts/tiny_mce/plugins/addvideo/langs/en_dlg.js +3 -0
- data/public/javascripts/tiny_mce/plugins/autolink/editor_plugin.js +1 -0
- data/public/javascripts/tiny_mce/plugins/autolink/editor_plugin_src.js +169 -0
- data/public/javascripts/tiny_mce/plugins/lists/editor_plugin.js +1 -0
- data/public/javascripts/tiny_mce/plugins/lists/editor_plugin_src.js +617 -0
- data/public/javascripts/tiny_mce/plugins/media/moxieplayer.swf +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/flash.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/iframe.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/pagebreak.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/quicktime.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/realmedia.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/shockwave.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/trans.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/video.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/img/windowsmedia.gif +0 -0
- data/public/javascripts/tiny_mce/themes/advanced/shortcuts.htm +47 -0
- data/public/javascripts/tiny_mce/themes/advanced/skins/highcontrast/content.css +23 -0
- data/public/javascripts/tiny_mce/themes/advanced/skins/highcontrast/dialog.css +105 -0
- data/public/javascripts/tiny_mce/themes/advanced/skins/highcontrast/ui.css +101 -0
- data/public/stylesheets/admin/ie.css +9 -0
- data/public/stylesheets/admin/ie8.css +10 -0
- data/public/stylesheets/admin/layout.css +4 -0
- metadata +51 -24
data/lib/noodall/ui/version.rb
CHANGED
Binary file
|
@@ -8,7 +8,7 @@ lite_tiny_mce_config = {
|
|
8
8
|
editor_selector : "lite-editor",
|
9
9
|
strict_loading_mode : 1,
|
10
10
|
convert_urls : false,
|
11
|
-
plugins : "safari,inlinepopups,xhtmlxtras,paste,media,advimage,table,media",
|
11
|
+
plugins : "safari,inlinepopups,xhtmlxtras,paste,media,advimage,table,media,addvideo",
|
12
12
|
//"safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking",
|
13
13
|
// Theme options
|
14
14
|
theme_advanced_blockformats : "h2,h3,h4,p",
|
@@ -36,7 +36,7 @@ tiny_mce_config = {};
|
|
36
36
|
$.extend(tiny_mce_config, lite_tiny_mce_config, {
|
37
37
|
editor_selector : "editor",
|
38
38
|
theme_advanced_buttons1 : "bold,italic,underline,|,formatselect,removeformat ,|,bullist,numlist,|,link,unlink,anchor,|,outdent,indent,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull",
|
39
|
-
theme_advanced_buttons2 : "table,delete_table,tablecontrols,col_before,col_after,row_before,row_after,delete_col,delete_row,|,code,attribs,image,media, assetbrowser,nodebrowser",
|
39
|
+
theme_advanced_buttons2 : "table,delete_table,tablecontrols,col_before,col_after,row_before,row_after,delete_col,delete_row,|,code,attribs,image,media, assetbrowser,nodebrowser,addvideo",
|
40
40
|
|
41
41
|
setup : function(ed) {
|
42
42
|
// Add a custom button
|
@@ -98,6 +98,18 @@ $.extend(tiny_mce_config, lite_tiny_mce_config, {
|
|
98
98
|
'script');
|
99
99
|
}
|
100
100
|
});
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
// Adding Videos
|
105
|
+
ed.addButton('addvideo', {
|
106
|
+
title : 'Add a youtube Video',
|
107
|
+
image : '/images/admin/youtube.gif',
|
108
|
+
href: '#',
|
109
|
+
onclick : function() {
|
110
|
+
alert("hi");
|
111
|
+
}
|
112
|
+
});
|
101
113
|
|
102
114
|
ed.onPostProcess.add(function(ed, o) {
|
103
115
|
if(o.save){
|
@@ -0,0 +1,147 @@
|
|
1
|
+
lite_tiny_mce_config = {
|
2
|
+
script_url : '/javascripts/tiny_mce/tiny_mce.js',
|
3
|
+
|
4
|
+
content_css : "/stylesheets/admin/tinymce.css",
|
5
|
+
|
6
|
+
theme : "advanced",
|
7
|
+
mode : "specific_textareas",
|
8
|
+
editor_selector : "lite-editor",
|
9
|
+
strict_loading_mode : 1,
|
10
|
+
convert_urls : false,
|
11
|
+
plugins : "safari,inlinepopups,xhtmlxtras,paste,media,advimage,table,media,addvideo",
|
12
|
+
//"safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking",
|
13
|
+
// Theme options
|
14
|
+
theme_advanced_blockformats : "h2,h3,h4,p",
|
15
|
+
theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,|,link,unlink,|,table,delete_table,tablecontrols,col_before,col_after,row_before,row_after,delete_col,delete_row",
|
16
|
+
theme_advanced_buttons2 : "",
|
17
|
+
theme_advanced_buttons3 : "",
|
18
|
+
theme_advanced_buttons4 : "",
|
19
|
+
theme_advanced_path : false,
|
20
|
+
theme_advanced_toolbar_location : "top",
|
21
|
+
theme_advanced_toolbar_align : "left",
|
22
|
+
theme_advanced_statusbar_location : "bottom",
|
23
|
+
theme_advanced_resizing : true,
|
24
|
+
theme_advanced_styles : "Footnote=footnote",
|
25
|
+
|
26
|
+
paste_auto_cleanup_on_paste : true,
|
27
|
+
paste_strip_class_attributes : "all",
|
28
|
+
paste_remove_spans : true,
|
29
|
+
paste_remove_styles : true
|
30
|
+
|
31
|
+
};
|
32
|
+
|
33
|
+
tiny_mce_config = {};
|
34
|
+
|
35
|
+
// add in some bits for the advanced editor
|
36
|
+
$.extend(tiny_mce_config, lite_tiny_mce_config, {
|
37
|
+
editor_selector : "editor",
|
38
|
+
theme_advanced_buttons1 : "bold,italic,underline,|,formatselect,removeformat ,|,bullist,numlist,|,link,unlink,anchor,|,outdent,indent,blockquote,|,justifyleft,justifycenter,justifyright,justifyfull",
|
39
|
+
theme_advanced_buttons2 : "table,delete_table,tablecontrols,col_before,col_after,row_before,row_after,delete_col,delete_row,|,code,attribs,image,media, assetbrowser,nodebrowser,addvideo",
|
40
|
+
|
41
|
+
setup : function(ed) {
|
42
|
+
// Add a custom button
|
43
|
+
ed.addButton('assetbrowser', {
|
44
|
+
title : 'Insert Asset',
|
45
|
+
image : '/images/admin/image_small.png',
|
46
|
+
href: '#asset-browser',
|
47
|
+
onclick : function() {
|
48
|
+
<<<<<<< HEAD
|
49
|
+
tinyMCE.activeEditor.focus();
|
50
|
+
tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark();
|
51
|
+
Browser.action = function(e) {
|
52
|
+
e.stopImmediatePropagation();
|
53
|
+
asset_id = Browser.assets_to_add[0]
|
54
|
+
=======
|
55
|
+
Browser.do_action_and_close = function() {
|
56
|
+
asset_id = Browser.assets_to_add[0];
|
57
|
+
>>>>>>> 2979ba1... added addvideo plugin, and makes link
|
58
|
+
if (asset_id) {
|
59
|
+
add_url = $('#asset-' + asset_id).siblings('a.show').attr('href').split('?')[0] + '/add';
|
60
|
+
$.get(add_url, { node_id: NoodallNode.id() }, function(data) {
|
61
|
+
$('#asset-browser').html(data);
|
62
|
+
|
63
|
+
choices = $('#asset-browser .choice');
|
64
|
+
if (choices.length > 0) {
|
65
|
+
$.each(choices, function(i, choice){
|
66
|
+
$(choice).click(function(e){
|
67
|
+
tinyMCE.activeEditor.selection.moveToBookmark(tinyMCE.activeEditor.windowManager.bookmark);
|
68
|
+
tinyMCE.activeEditor.selection.setContent($(this).html());
|
69
|
+
$.fancybox.close();
|
70
|
+
return false;
|
71
|
+
});
|
72
|
+
});
|
73
|
+
} else {
|
74
|
+
tinyMCE.activeEditor.selection.moveToBookmark(tinyMCE.activeEditor.windowManager.bookmark);
|
75
|
+
tinyMCE.activeEditor.selection.setContent(data);
|
76
|
+
$.fancybox.close();
|
77
|
+
return false;
|
78
|
+
}
|
79
|
+
}, 'html');
|
80
|
+
}
|
81
|
+
return false;
|
82
|
+
};
|
83
|
+
Browser.open();
|
84
|
+
}
|
85
|
+
});
|
86
|
+
|
87
|
+
ed.addButton('nodebrowser', {
|
88
|
+
title : 'Insert an internal link',
|
89
|
+
image : '/images/admin/top-level_small.png',
|
90
|
+
href: '#asset-browser',
|
91
|
+
onclick : function() {
|
92
|
+
tinyMCE.activeEditor.focus();
|
93
|
+
tinyMCE.activeEditor.windowManager.bookmark = tinyMCE.activeEditor.selection.getBookmark();
|
94
|
+
// open asset lightbox
|
95
|
+
$.get("/admin/nodes/tree", function() {
|
96
|
+
// reopen the opening form if you close this form
|
97
|
+
$.fancybox({
|
98
|
+
href: '#tree-browser',
|
99
|
+
title: "Link to content"
|
100
|
+
});
|
101
|
+
$('#tree-browser').attr('class', 'tinymce');
|
102
|
+
},
|
103
|
+
'script');
|
104
|
+
}
|
105
|
+
});
|
106
|
+
|
107
|
+
ed.onPostProcess.add(function(ed, o) {
|
108
|
+
if(o.save){
|
109
|
+
// remove mce empty spans
|
110
|
+
o.content = o.content.replace(/<span id=._mce_start. .*?><\/span>/ig, '');
|
111
|
+
}
|
112
|
+
});
|
113
|
+
|
114
|
+
// wow what a hack: insert a containing span for the page name if nothing is selected,
|
115
|
+
// then insert the link, then remove containing span after all is good
|
116
|
+
$('#tree-browser.tinymce li a').live('click', function(event) {
|
117
|
+
add_url = $(this).attr('href').split('?')[0];
|
118
|
+
tinyMCE.activeEditor.selection.moveToBookmark(tinyMCE.activeEditor.windowManager.bookmark);
|
119
|
+
|
120
|
+
if(tinyMCE.activeEditor.selection.getContent().length === 0){
|
121
|
+
tinyMCE.execInstanceCommand(tinyMCE.activeEditor.id, 'mceInsertRawHTML', false, '<span class="tmp_tag">' + $(this).text() + '</span>');
|
122
|
+
spans = tinyMCE.activeEditor.dom.select('span');
|
123
|
+
|
124
|
+
$.each(spans, function(i, span){
|
125
|
+
if($(span).hasClass('tmp_tag')) {
|
126
|
+
tinyMCE.activeEditor.selection.select(span);
|
127
|
+
}
|
128
|
+
});
|
129
|
+
}
|
130
|
+
|
131
|
+
tinyMCE.execInstanceCommand(tinyMCE.activeEditor.id, 'mceInsertLink', false, add_url, true);
|
132
|
+
$.fancybox.close();
|
133
|
+
|
134
|
+
tinyMCE.activeEditor.setContent(tinyMCE.activeEditor.getContent().replace(/<span class="tmp_tag">(.*?)<\/span>/i, "$1"));
|
135
|
+
|
136
|
+
event.stopImmediatePropagation();
|
137
|
+
return false;
|
138
|
+
});
|
139
|
+
|
140
|
+
}
|
141
|
+
});
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
$(function() {
|
146
|
+
$('textarea.editor').tinymce(tiny_mce_config);
|
147
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
2
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3
|
+
<head>
|
4
|
+
<title>{#addvideo_dlg.title}</title>
|
5
|
+
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
|
6
|
+
<script type="text/javascript" src="js/dialog.js"></script>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<form onsubmit="AddvideoDialog.insert();return false;" action="#">
|
10
|
+
<p>Please enter the details of your video</p>
|
11
|
+
<p>Video Title: <input id="videotitle" name="videotitle" type="text" class="text" /></p>
|
12
|
+
<p>Video URL: <input id="videourl" name="videourl" type="text" class="text" /></p>
|
13
|
+
<div class="mceActionPanel">
|
14
|
+
<input type="button" id="insert" name="insert" value="{#insert}" onclick="AddvideoDialog.insert();" />
|
15
|
+
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
16
|
+
</div>
|
17
|
+
</form>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(){tinymce.PluginManager.requireLangPack('addvideo');tinymce.create('tinymce.plugins.AddvideoPlugin',{init:function(ed,url){ed.addCommand('mceAddvideo',function(){ed.windowManager.open({file:url+'/dialog.htm',width:320+parseInt(ed.getLang('addvideo.delta_width',0)),height:120+parseInt(ed.getLang('addvideo.delta_height',0)),inline:1},{plugin_url:url,some_custom_arg:'custom arg'})});ed.addButton('addvideo',{title:'addvideo.desc',cmd:'mceAddvideo',image:url+'/img/youtube.gif'});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('youtube',n.nodeName=='IMG')})},createControl:function(n,cm){return null},getInfo:function(){return{longname:'Addvideo plugin',author:'Some author',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/addvideo',version:"1.0"}}});tinymce.PluginManager.add('addvideo',tinymce.plugins.AddvideoPlugin)})();
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
* editor_plugin_src.js
|
3
|
+
*
|
4
|
+
* Copyright 2009, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://tinymce.moxiecode.com/license
|
8
|
+
* Contributing: http://tinymce.moxiecode.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
(function() {
|
12
|
+
// Load plugin specific language pack
|
13
|
+
tinymce.PluginManager.requireLangPack('addvideo');
|
14
|
+
|
15
|
+
tinymce.create('tinymce.plugins.AddvideoPlugin', {
|
16
|
+
/**
|
17
|
+
* Initializes the plugin, this will be executed after the plugin has been created.
|
18
|
+
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
19
|
+
* of the editor instance to intercept that event.
|
20
|
+
*
|
21
|
+
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
22
|
+
* @param {string} url Absolute URL to where the plugin is located.
|
23
|
+
*/
|
24
|
+
init : function(ed, url) {
|
25
|
+
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
26
|
+
ed.addCommand('mceAddvideo', function() {
|
27
|
+
ed.windowManager.open({
|
28
|
+
file : url + '/dialog.htm',
|
29
|
+
width : 320 + parseInt(ed.getLang('addvideo.delta_width', 0)),
|
30
|
+
height : 120 + parseInt(ed.getLang('addvideo.delta_height', 0)),
|
31
|
+
inline : 1
|
32
|
+
}, {
|
33
|
+
plugin_url : url, // Plugin absolute URL
|
34
|
+
some_custom_arg : 'custom arg' // Custom argument
|
35
|
+
});
|
36
|
+
});
|
37
|
+
|
38
|
+
// Register addvideo button
|
39
|
+
ed.addButton('addvideo', {
|
40
|
+
title : 'addvideo.desc',
|
41
|
+
cmd : 'mceAddvideo',
|
42
|
+
image : url + '/img/youtube.gif'
|
43
|
+
});
|
44
|
+
|
45
|
+
// Add a node change handler, selects the button in the UI when a image is selected
|
46
|
+
ed.onNodeChange.add(function(ed, cm, n) {
|
47
|
+
cm.setActive('youtube', n.nodeName == 'IMG');
|
48
|
+
});
|
49
|
+
},
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Creates control instances based in the incomming name. This method is normally not
|
53
|
+
* needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
|
54
|
+
* but you sometimes need to create more complex controls like listboxes, split buttons etc then this
|
55
|
+
* method can be used to create those.
|
56
|
+
*
|
57
|
+
* @param {String} n Name of the control to create.
|
58
|
+
* @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
|
59
|
+
* @return {tinymce.ui.Control} New control instance or null if no control was created.
|
60
|
+
*/
|
61
|
+
createControl : function(n, cm) {
|
62
|
+
return null;
|
63
|
+
},
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Returns information about the plugin as a name/value array.
|
67
|
+
* The current keys are longname, author, authorurl, infourl and version.
|
68
|
+
*
|
69
|
+
* @return {Object} Name/value array containing information about the plugin.
|
70
|
+
*/
|
71
|
+
getInfo : function() {
|
72
|
+
return {
|
73
|
+
longname : 'Addvideo plugin',
|
74
|
+
author : 'Some author',
|
75
|
+
authorurl : 'http://tinymce.moxiecode.com',
|
76
|
+
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/addvideo',
|
77
|
+
version : "1.0"
|
78
|
+
};
|
79
|
+
}
|
80
|
+
});
|
81
|
+
|
82
|
+
// Register plugin
|
83
|
+
tinymce.PluginManager.add('addvideo', tinymce.plugins.AddvideoPlugin);
|
84
|
+
})();
|
Binary file
|
@@ -0,0 +1,33 @@
|
|
1
|
+
tinyMCEPopup.requireLangPack();
|
2
|
+
|
3
|
+
var AddvideoDialog = {
|
4
|
+
init : function() {
|
5
|
+
var f = document.forms[0];
|
6
|
+
|
7
|
+
// Get the selected contents as text and place it in the input
|
8
|
+
f.videourl.value = tinyMCEPopup.editor.selection.getContent({format : 'text'});
|
9
|
+
f.videtitle.value = tinyMCEPopup.editor.selection.getContent({format : 'text'});
|
10
|
+
},
|
11
|
+
|
12
|
+
insert : function() {
|
13
|
+
// Insert the contents from the input into the document
|
14
|
+
|
15
|
+
// VIDEO URL
|
16
|
+
var url = document.forms[0].videourl.value;
|
17
|
+
|
18
|
+
// VIDEO Title
|
19
|
+
var title = document.forms[0].videotitle.value;
|
20
|
+
|
21
|
+
// REGEXP
|
22
|
+
var re=new RegExp(/http:\/\/([^\s\.]+).(youtube.com\/watch\?v=)([A-Za-z0-9\-]+)([^\s]*)/);
|
23
|
+
|
24
|
+
// VIDEO ID
|
25
|
+
var videoid = re.exec(url);
|
26
|
+
|
27
|
+
// Add Link and img to the body
|
28
|
+
tinyMCEPopup.editor.execCommand('mceInsertContent', false, "<a href='" + url + "' title='" + title + "'><img src='http://img.youtube.com/vi/" + videoid[3] + videoid[4] + "/1.jpg' alt='" + title + "' /></a>");
|
29
|
+
tinyMCEPopup.close();
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
tinyMCEPopup.onInit.add(AddvideoDialog.init, AddvideoDialog);
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(){tinymce.create("tinymce.plugins.AutolinkPlugin",{init:function(a,b){var c=this;if(tinyMCE.isIE){return}a.onKeyDown.add(function(d,f){if(f.keyCode==13){return c.handleEnter(d)}if(f.shiftKey&&f.keyCode==48){return c.handleEclipse(d)}});a.onKeyUp.add(function(d,f){if(f.keyCode==32){return c.handleSpacebar(d)}})},handleEclipse:function(a){this.parseCurrentLine(a,-1,"(",true)},handleSpacebar:function(a){this.parseCurrentLine(a,0,"",true)},handleEnter:function(a){this.parseCurrentLine(a,-1,"",false)},parseCurrentLine:function(i,d,b,g){var a,f,c,n,k,m,h,e,j;a=i.selection.getRng().cloneRange();if(a.startOffset<5){e=a.endContainer.previousSibling;if(e==null){if(a.endContainer.firstChild==null||a.endContainer.firstChild.nextSibling==null){return}e=a.endContainer.firstChild.nextSibling}j=e.length;a.setStart(e,j);a.setEnd(e,j);if(a.endOffset<5){return}f=a.endOffset;n=e}else{n=a.endContainer;if(n.nodeType!=3&&n.firstChild){while(n.nodeType!=3&&n.firstChild){n=n.firstChild}a.setStart(n,0);a.setEnd(n,n.nodeValue.length)}if(a.endOffset==1){f=2}else{f=a.endOffset-1-d}}c=f;do{a.setStart(n,f-2);a.setEnd(n,f-1);f-=1}while(a.toString()!=" "&&a.toString()!=""&&a.toString().charCodeAt(0)!=160&&(f-2)>=0&&a.toString()!=b);if(a.toString()==b||a.toString().charCodeAt(0)==160){a.setStart(n,f);a.setEnd(n,c);f+=1}else{if(a.startOffset==0){a.setStart(n,0);a.setEnd(n,c)}else{a.setStart(n,f);a.setEnd(n,c)}}m=a.toString();h=m.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.)(.+)$/i);if(h){if(h[1]=="www."){h[1]="http://www."}k=i.selection.getBookmark();i.selection.setRng(a);tinyMCE.execCommand("mceInsertLink",false,h[1]+h[2]);i.selection.moveToBookmark(k);if(tinyMCE.isWebKit){i.selection.collapse(false);var l=Math.min(n.length,c+1);a.setStart(n,l);a.setEnd(n,l);i.selection.setRng(a)}}},getInfo:function(){return{longname:"Autolink",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autolink",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("autolink",tinymce.plugins.AutolinkPlugin)})();
|
@@ -0,0 +1,169 @@
|
|
1
|
+
/**
|
2
|
+
* editor_plugin_src.js
|
3
|
+
*
|
4
|
+
* Copyright 2011, Moxiecode Systems AB
|
5
|
+
* Released under LGPL License.
|
6
|
+
*
|
7
|
+
* License: http://tinymce.moxiecode.com/license
|
8
|
+
* Contributing: http://tinymce.moxiecode.com/contributing
|
9
|
+
*/
|
10
|
+
|
11
|
+
(function() {
|
12
|
+
tinymce.create('tinymce.plugins.AutolinkPlugin', {
|
13
|
+
/**
|
14
|
+
* Initializes the plugin, this will be executed after the plugin has been created.
|
15
|
+
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
16
|
+
* of the editor instance to intercept that event.
|
17
|
+
*
|
18
|
+
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
19
|
+
* @param {string} url Absolute URL to where the plugin is located.
|
20
|
+
*/
|
21
|
+
|
22
|
+
init : function(ed, url) {
|
23
|
+
var t = this;
|
24
|
+
|
25
|
+
// Internet Explorer has built-in automatic linking
|
26
|
+
if (tinyMCE.isIE)
|
27
|
+
return;
|
28
|
+
|
29
|
+
// Add a key down handler
|
30
|
+
ed.onKeyDown.add(function(ed, e) {
|
31
|
+
if (e.keyCode == 13)
|
32
|
+
return t.handleEnter(ed);
|
33
|
+
if (e.shiftKey && e.keyCode == 48)
|
34
|
+
return t.handleEclipse(ed);
|
35
|
+
});
|
36
|
+
|
37
|
+
// Add a key up handler
|
38
|
+
ed.onKeyUp.add(function(ed, e) {
|
39
|
+
if (e.keyCode == 32)
|
40
|
+
return t.handleSpacebar(ed);
|
41
|
+
});
|
42
|
+
},
|
43
|
+
|
44
|
+
handleEclipse : function(ed) {
|
45
|
+
this.parseCurrentLine(ed, -1, '(', true);
|
46
|
+
},
|
47
|
+
|
48
|
+
handleSpacebar : function(ed) {
|
49
|
+
this.parseCurrentLine(ed, 0, '', true);
|
50
|
+
},
|
51
|
+
|
52
|
+
handleEnter : function(ed) {
|
53
|
+
this.parseCurrentLine(ed, -1, '', false);
|
54
|
+
},
|
55
|
+
|
56
|
+
parseCurrentLine : function(ed, end_offset, delimiter, goback) {
|
57
|
+
var r, end, start, endContainer, bookmark, text, matches, prev, len;
|
58
|
+
|
59
|
+
// We need at least five characters to form a URL,
|
60
|
+
// hence, at minimum, five characters from the beginning of the line.
|
61
|
+
r = ed.selection.getRng().cloneRange();
|
62
|
+
if (r.startOffset < 5) {
|
63
|
+
// During testing, the caret is placed inbetween two text nodes.
|
64
|
+
// The previous text node contains the URL.
|
65
|
+
prev = r.endContainer.previousSibling;
|
66
|
+
if (prev == null) {
|
67
|
+
if (r.endContainer.firstChild == null || r.endContainer.firstChild.nextSibling == null)
|
68
|
+
return;
|
69
|
+
|
70
|
+
prev = r.endContainer.firstChild.nextSibling;
|
71
|
+
}
|
72
|
+
len = prev.length;
|
73
|
+
r.setStart(prev, len);
|
74
|
+
r.setEnd(prev, len);
|
75
|
+
|
76
|
+
if (r.endOffset < 5)
|
77
|
+
return;
|
78
|
+
|
79
|
+
end = r.endOffset;
|
80
|
+
endContainer = prev;
|
81
|
+
} else {
|
82
|
+
endContainer = r.endContainer;
|
83
|
+
|
84
|
+
// Get a text node
|
85
|
+
if (endContainer.nodeType != 3 && endContainer.firstChild) {
|
86
|
+
while (endContainer.nodeType != 3 && endContainer.firstChild)
|
87
|
+
endContainer = endContainer.firstChild;
|
88
|
+
|
89
|
+
r.setStart(endContainer, 0);
|
90
|
+
r.setEnd(endContainer, endContainer.nodeValue.length);
|
91
|
+
}
|
92
|
+
|
93
|
+
if (r.endOffset == 1)
|
94
|
+
end = 2;
|
95
|
+
else
|
96
|
+
end = r.endOffset - 1 - end_offset;
|
97
|
+
}
|
98
|
+
|
99
|
+
start = end;
|
100
|
+
|
101
|
+
do
|
102
|
+
{
|
103
|
+
// Move the selection one character backwards.
|
104
|
+
r.setStart(endContainer, end - 2);
|
105
|
+
r.setEnd(endContainer, end - 1);
|
106
|
+
end -= 1;
|
107
|
+
|
108
|
+
// Loop until one of the following is found: a blank space, , delimeter, (end-2) >= 0
|
109
|
+
} while (r.toString() != ' ' && r.toString() != '' && r.toString().charCodeAt(0) != 160 && (end -2) >= 0 && r.toString() != delimiter);
|
110
|
+
|
111
|
+
if (r.toString() == delimiter || r.toString().charCodeAt(0) == 160) {
|
112
|
+
r.setStart(endContainer, end);
|
113
|
+
r.setEnd(endContainer, start);
|
114
|
+
end += 1;
|
115
|
+
} else if (r.startOffset == 0) {
|
116
|
+
r.setStart(endContainer, 0);
|
117
|
+
r.setEnd(endContainer, start);
|
118
|
+
}
|
119
|
+
else {
|
120
|
+
r.setStart(endContainer, end);
|
121
|
+
r.setEnd(endContainer, start);
|
122
|
+
}
|
123
|
+
|
124
|
+
text = r.toString();
|
125
|
+
matches = text.match(/^(https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.)(.+)$/i);
|
126
|
+
|
127
|
+
if (matches) {
|
128
|
+
if (matches[1] == 'www.') {
|
129
|
+
matches[1] = 'http://www.';
|
130
|
+
}
|
131
|
+
|
132
|
+
bookmark = ed.selection.getBookmark();
|
133
|
+
|
134
|
+
ed.selection.setRng(r);
|
135
|
+
tinyMCE.execCommand('mceInsertLink',false, matches[1] + matches[2]);
|
136
|
+
ed.selection.moveToBookmark(bookmark);
|
137
|
+
|
138
|
+
// TODO: Determine if this is still needed.
|
139
|
+
if (tinyMCE.isWebKit) {
|
140
|
+
// move the caret to its original position
|
141
|
+
ed.selection.collapse(false);
|
142
|
+
var max = Math.min(endContainer.length, start + 1);
|
143
|
+
r.setStart(endContainer, max);
|
144
|
+
r.setEnd(endContainer, max);
|
145
|
+
ed.selection.setRng(r);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
},
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Returns information about the plugin as a name/value array.
|
152
|
+
* The current keys are longname, author, authorurl, infourl and version.
|
153
|
+
*
|
154
|
+
* @return {Object} Name/value array containing information about the plugin.
|
155
|
+
*/
|
156
|
+
getInfo : function() {
|
157
|
+
return {
|
158
|
+
longname : 'Autolink',
|
159
|
+
author : 'Moxiecode Systems AB',
|
160
|
+
authorurl : 'http://tinymce.moxiecode.com',
|
161
|
+
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autolink',
|
162
|
+
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
163
|
+
};
|
164
|
+
}
|
165
|
+
});
|
166
|
+
|
167
|
+
// Register plugin
|
168
|
+
tinymce.PluginManager.add('autolink', tinymce.plugins.AutolinkPlugin);
|
169
|
+
})();
|
@@ -0,0 +1 @@
|
|
1
|
+
(function(){var e=tinymce.each,r=tinymce.dom.Event,g;function p(t,s){while(t&&(t.nodeType===8||(t.nodeType===3&&/^[ \t\n\r]*$/.test(t.nodeValue)))){t=s(t)}return t}function b(s){return p(s,function(t){return t.previousSibling})}function i(s){return p(s,function(t){return t.nextSibling})}function d(s,u,t){return s.dom.getParent(u,function(v){return tinymce.inArray(t,v)!==-1})}function n(s){return s&&(s.tagName==="OL"||s.tagName==="UL")}function c(u,v){var t,w,s;t=b(u.lastChild);while(n(t)){w=t;t=b(w.previousSibling)}if(w){s=v.create("li",{style:"list-style-type: none;"});v.split(u,w);v.insertAfter(s,w);s.appendChild(w);s.appendChild(w);u=s.previousSibling}return u}function m(t,s,u){t=a(t,s,u);return o(t,s,u)}function a(u,s,v){var t=b(u.previousSibling);if(t){return h(t,u,s?t:false,v)}else{return u}}function o(u,t,v){var s=i(u.nextSibling);if(s){return h(u,s,t?s:false,v)}else{return u}}function h(u,s,t,v){if(l(u,s,!!t,v)){return f(u,s,t)}else{if(u&&u.tagName==="LI"&&n(s)){u.appendChild(s)}}return s}function l(u,t,s,v){if(!u||!t){return false}else{if(u.tagName==="LI"&&t.tagName==="LI"){return t.style.listStyleType==="none"||j(t)}else{if(n(u)){return(u.tagName===t.tagName&&(s||u.style.listStyleType===t.style.listStyleType))||q(t)}else{if(v&&u.tagName==="P"&&t.tagName==="P"){return true}else{return false}}}}}function q(t){var s=i(t.firstChild),u=b(t.lastChild);return s&&u&&n(t)&&s===u&&(n(s)||s.style.listStyleType==="none"||j(s))}function j(u){var t=i(u.firstChild),s=b(u.lastChild);return t&&s&&t===s&&n(t)}function f(w,v,s){var u=b(w.lastChild),t=i(v.firstChild);if(w.tagName==="P"){w.appendChild(w.ownerDocument.createElement("br"))}while(v.firstChild){w.appendChild(v.firstChild)}if(s){w.style.listStyleType=s.style.listStyleType}v.parentNode.removeChild(v);h(u,t,false);return w}function k(t,u){var s;if(!u.is(t,"li,ol,ul")){s=u.getParent(t,"li");if(s){t=s}}return t}tinymce.create("tinymce.plugins.Lists",{init:function(u,v){var s=false;function x(y){return y.keyCode===9&&(u.queryCommandState("InsertUnorderedList")||u.queryCommandState("InsertOrderedList"))}function w(y,A){var z=y.selection,B;if(A.keyCode===13){B=z.getStart();s=z.isCollapsed()&&B&&B.tagName==="LI"&&B.childNodes.length===0;return s}}function t(y,z){if(x(z)||w(y,z)){return r.cancel(z)}}this.ed=u;u.addCommand("Indent",this.indent,this);u.addCommand("Outdent",this.outdent,this);u.addCommand("InsertUnorderedList",function(){this.applyList("UL","OL")},this);u.addCommand("InsertOrderedList",function(){this.applyList("OL","UL")},this);u.onInit.add(function(){u.editorCommands.addCommands({outdent:function(){var z=u.selection,A=u.dom;function y(B){B=A.getParent(B,A.isBlock);return B&&(parseInt(u.dom.getStyle(B,"margin-left")||0,10)+parseInt(u.dom.getStyle(B,"padding-left")||0,10))>0}return y(z.getStart())||y(z.getEnd())||u.queryCommandState("InsertOrderedList")||u.queryCommandState("InsertUnorderedList")}},"state")});u.onKeyUp.add(function(z,A){var B,y;if(x(A)){z.execCommand(A.shiftKey?"Outdent":"Indent",true,null);return r.cancel(A)}else{if(s&&w(z,A)){if(z.queryCommandState("InsertOrderedList")){z.execCommand("InsertOrderedList")}else{z.execCommand("InsertUnorderedList")}B=z.selection.getStart();if(B&&B.tagName==="LI"){B=z.dom.getParent(B,"ol,ul").nextSibling;if(B&&B.tagName==="P"){if(!B.firstChild){B.appendChild(z.getDoc().createTextNode(""))}y=z.dom.createRng();y.setStart(B.firstChild,1);y.setEnd(B.firstChild,1);z.selection.setRng(y)}}return r.cancel(A)}}});u.onKeyPress.add(t);u.onKeyDown.add(t)},applyList:function(y,v){var C=this,z=C.ed,I=z.dom,s=[],H=false,u=false,w=false,B,G=z.selection.getSelectedBlocks();function E(t){if(t&&t.tagName==="BR"){I.remove(t)}}function F(M){var N=I.create(y),t;function L(O){if(O.style.marginLeft||O.style.paddingLeft){C.adjustPaddingFunction(false)(O)}}if(M.tagName==="LI"){}else{if(M.tagName==="P"||M.tagName==="DIV"||M.tagName==="BODY"){K(M,function(P,O,Q){J(P,O,M.tagName==="BODY"?null:P.parentNode);t=P.parentNode;L(t);E(O)});if(M.tagName==="P"||G.length>1){I.split(t.parentNode.parentNode,t.parentNode)}m(t.parentNode,true);return}else{t=I.create("li");I.insertAfter(t,M);t.appendChild(M);L(M);M=t}}I.insertAfter(N,M);N.appendChild(M);m(N,true);s.push(M)}function J(Q,L,O){var t,P=Q,N,M;while(!I.isBlock(Q.parentNode)&&Q.parentNode!==I.getRoot()){Q=I.split(Q.parentNode,Q.previousSibling);Q=Q.nextSibling;P=Q}if(O){t=O.cloneNode(true);Q.parentNode.insertBefore(t,Q);while(t.firstChild){I.remove(t.firstChild)}t=I.rename(t,"li")}else{t=I.create("li");Q.parentNode.insertBefore(t,Q)}while(P&&P!=L){N=P.nextSibling;t.appendChild(P);P=N}if(t.childNodes.length===0){t.innerHTML='<br _mce_bogus="1" />'}F(t)}function K(Q,T){var N,R,O=3,L=1,t="br,ul,ol,p,div,h1,h2,h3,h4,h5,h6,table,blockquote,address,pre,form,center,dl";function P(X,U){var V=I.createRng(),W;g.keep=true;z.selection.moveToBookmark(g);g.keep=false;W=z.selection.getRng(true);if(!U){U=X.parentNode.lastChild}V.setStartBefore(X);V.setEndAfter(U);return !(V.compareBoundaryPoints(O,W)>0||V.compareBoundaryPoints(L,W)<=0)}function S(U){if(U.nextSibling){return U.nextSibling}if(!I.isBlock(U.parentNode)&&U.parentNode!==I.getRoot()){return S(U.parentNode)}}N=Q.firstChild;var M=false;e(I.select(t,Q),function(V){var U;if(V.hasAttribute&&V.hasAttribute("_mce_bogus")){return true}if(P(N,V)){I.addClass(V,"_mce_tagged_br");N=S(V)}});M=(N&&P(N,undefined));N=Q.firstChild;e(I.select(t,Q),function(V){var U=S(V);if(V.hasAttribute&&V.hasAttribute("_mce_bogus")){return true}if(I.hasClass(V,"_mce_tagged_br")){T(N,V,R);R=null}else{R=V}N=U});if(M){T(N,undefined,R)}}function D(t){K(t,function(M,L,N){J(M,L);E(L);E(N)})}function A(t){if(tinymce.inArray(s,t)!==-1){return}if(t.parentNode.tagName===v){I.split(t.parentNode,t);F(t);o(t.parentNode,false)}s.push(t)}function x(M){var O,N,L,t;if(tinymce.inArray(s,M)!==-1){return}M=c(M,I);while(I.is(M.parentNode,"ol,ul,li")){I.split(M.parentNode,M)}s.push(M);M=I.rename(M,"p");L=m(M,false,z.settings.force_br_newlines);if(L===M){O=M.firstChild;while(O){if(I.isBlock(O)){O=I.split(O.parentNode,O);t=true;N=O.nextSibling&&O.nextSibling.firstChild}else{N=O.nextSibling;if(t&&O.tagName==="BR"){I.remove(O)}t=false}O=N}}}e(G,function(t){t=k(t,I);if(t.tagName===v||(t.tagName==="LI"&&t.parentNode.tagName===v)){u=true}else{if(t.tagName===y||(t.tagName==="LI"&&t.parentNode.tagName===y)){H=true}else{w=true}}});if(w||u||G.length===0){B={LI:A,H1:F,H2:F,H3:F,H4:F,H5:F,H6:F,P:F,BODY:F,DIV:G.length>1?F:D,defaultAction:D}}else{B={defaultAction:x}}this.process(B)},indent:function(){var u=this.ed,w=u.dom,x=[];function s(z){var y=w.create("li",{style:"list-style-type: none;"});w.insertAfter(y,z);return y}function t(B){var y=s(B),D=w.getParent(B,"ol,ul"),C=D.tagName,E=w.getStyle(D,"list-style-type"),A={},z;if(E!==""){A.style="list-style-type: "+E+";"}z=w.create(C,A);y.appendChild(z);return z}function v(z){if(!d(u,z,x)){z=c(z,w);var y=t(z);y.appendChild(z);m(y.parentNode,false);m(y,false);x.push(z)}}this.process({LI:v,defaultAction:this.adjustPaddingFunction(true)})},outdent:function(){var v=this,u=v.ed,w=u.dom,s=[];function x(t){var z,y,A;if(!d(u,t,s)){if(w.getStyle(t,"margin-left")!==""||w.getStyle(t,"padding-left")!==""){return v.adjustPaddingFunction(false)(t)}A=w.getStyle(t,"text-align",true);if(A==="center"||A==="right"){w.setStyle(t,"text-align","left");return}t=c(t,w);z=t.parentNode;y=t.parentNode.parentNode;if(y.tagName==="P"){w.split(y,t.parentNode)}else{w.split(z,t);if(y.tagName==="LI"){w.split(y,t)}else{if(!w.is(y,"ol,ul")){w.rename(t,"p")}}}s.push(t)}}this.process({LI:x,defaultAction:this.adjustPaddingFunction(false)});e(s,m)},process:function(x){var B=this,v=B.ed.selection,y=B.ed.dom,A,s;function w(t){y.removeClass(t,"_mce_act_on");if(!t||t.nodeType!==1){return}t=k(t,y);var C=x[t.tagName];if(!C){C=x.defaultAction}C(t)}function u(t){B.splitSafeEach(t.childNodes,w)}function z(t,C){return C>=0&&t.hasChildNodes()&&C<t.childNodes.length&&t.childNodes[C].tagName==="BR"}A=v.getSelectedBlocks();if(A.length===0){A=[y.getRoot()]}s=v.getRng(true);if(!s.collapsed){if(z(s.endContainer,s.endOffset-1)){s.setEnd(s.endContainer,s.endOffset-1);v.setRng(s)}if(z(s.startContainer,s.startOffset)){s.setStart(s.startContainer,s.startOffset+1);v.setRng(s)}}g=v.getBookmark();x.OL=x.UL=u;B.splitSafeEach(A,w);v.moveToBookmark(g);g=null;B.ed.execCommand("mceRepaint")},splitSafeEach:function(t,s){if(tinymce.isGecko&&(/Firefox\/[12]\.[0-9]/.test(navigator.userAgent)||/Firefox\/3\.[0-4]/.test(navigator.userAgent))){this.classBasedEach(t,s)}else{e(t,s)}},classBasedEach:function(v,u){var w=this.ed.dom,s,t;e(v,function(x){w.addClass(x,"_mce_act_on")});s=w.select("._mce_act_on");while(s.length>0){t=s.shift();w.removeClass(t,"_mce_act_on");u(t);s=w.select("._mce_act_on")}},adjustPaddingFunction:function(u){var s,v,t=this.ed;s=t.settings.indentation;v=/[a-z%]+/i.exec(s);s=parseInt(s,10);return function(w){var y,x;y=parseInt(t.dom.getStyle(w,"margin-left")||0,10)+parseInt(t.dom.getStyle(w,"padding-left")||0,10);if(u){x=y+s}else{x=y-s}t.dom.setStyle(w,"padding-left","");t.dom.setStyle(w,"margin-left",x>0?x+v:"")}},getInfo:function(){return{longname:"Lists",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/lists",version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add("lists",tinymce.plugins.Lists)}());
|