summaryrefslogtreecommitdiff
path: root/public/javascripts/tiny_mce/plugins/searchreplace
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-02-17 21:54:39 +0100
committerhukl <contact@smyck.org>2009-02-17 21:54:39 +0100
commitf61b5b0597e0c25f084ee67d402f12a43a7a9947 (patch)
tree3b4c3f9f38637f1a7ecf703ece4fd3bc4c6e2934 /public/javascripts/tiny_mce/plugins/searchreplace
parent3d3b786cc43266f6292f5edd25733dbb9bd6ed06 (diff)
added tinymce editor for body area of pages
Diffstat (limited to 'public/javascripts/tiny_mce/plugins/searchreplace')
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/searchreplace/css/searchreplace.css6
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/searchreplace/editor_plugin.js1
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js54
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/searchreplace/js/searchreplace.js126
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/searchreplace/langs/en_dlg.js16
-rwxr-xr-xpublic/javascripts/tiny_mce/plugins/searchreplace/searchreplace.htm105
6 files changed, 308 insertions, 0 deletions
diff --git a/public/javascripts/tiny_mce/plugins/searchreplace/css/searchreplace.css b/public/javascripts/tiny_mce/plugins/searchreplace/css/searchreplace.css
new file mode 100755
index 0000000..ecdf58c
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/searchreplace/css/searchreplace.css
@@ -0,0 +1,6 @@
1.panel_wrapper {height:85px;}
2.panel_wrapper div.current {height:85px;}
3
4/* IE */
5* html .panel_wrapper {height:100px;}
6* html .panel_wrapper div.current {height:100px;}
diff --git a/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin.js b/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin.js
new file mode 100755
index 0000000..7fd913b
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin.js
@@ -0,0 +1 @@
(function(){tinymce.create('tinymce.plugins.SearchReplacePlugin',{init:function(ed,url){function open(m){ed.windowManager.open({file:url+'/searchreplace.htm',width:420+parseInt(ed.getLang('searchreplace.delta_width',0)),height:160+parseInt(ed.getLang('searchreplace.delta_height',0)),inline:1,auto_focus:0},{mode:m,search_string:ed.selection.getContent({format:'text'}),plugin_url:url});};ed.addCommand('mceSearch',function(){open('search');});ed.addCommand('mceReplace',function(){open('replace');});ed.addButton('search',{title:'searchreplace.search_desc',cmd:'mceSearch'});ed.addButton('replace',{title:'searchreplace.replace_desc',cmd:'mceReplace'});ed.addShortcut('ctrl+f','searchreplace.search_desc','mceSearch');},getInfo:function(){return{longname:'Search/Replace',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/searchreplace',version:tinymce.majorVersion+"."+tinymce.minorVersion};}});tinymce.PluginManager.add('searchreplace',tinymce.plugins.SearchReplacePlugin);})(); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js b/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js
new file mode 100755
index 0000000..59edc3b
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/searchreplace/editor_plugin_src.js
@@ -0,0 +1,54 @@
1/**
2 * $Id: editor_plugin_src.js 686 2008-03-09 18:13:49Z spocke $
3 *
4 * @author Moxiecode
5 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
6 */
7
8(function() {
9 tinymce.create('tinymce.plugins.SearchReplacePlugin', {
10 init : function(ed, url) {
11 function open(m) {
12 ed.windowManager.open({
13 file : url + '/searchreplace.htm',
14 width : 420 + parseInt(ed.getLang('searchreplace.delta_width', 0)),
15 height : 160 + parseInt(ed.getLang('searchreplace.delta_height', 0)),
16 inline : 1,
17 auto_focus : 0
18 }, {
19 mode : m,
20 search_string : ed.selection.getContent({format : 'text'}),
21 plugin_url : url
22 });
23 };
24
25 // Register commands
26 ed.addCommand('mceSearch', function() {
27 open('search');
28 });
29
30 ed.addCommand('mceReplace', function() {
31 open('replace');
32 });
33
34 // Register buttons
35 ed.addButton('search', {title : 'searchreplace.search_desc', cmd : 'mceSearch'});
36 ed.addButton('replace', {title : 'searchreplace.replace_desc', cmd : 'mceReplace'});
37
38 ed.addShortcut('ctrl+f', 'searchreplace.search_desc', 'mceSearch');
39 },
40
41 getInfo : function() {
42 return {
43 longname : 'Search/Replace',
44 author : 'Moxiecode Systems AB',
45 authorurl : 'http://tinymce.moxiecode.com',
46 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/searchreplace',
47 version : tinymce.majorVersion + "." + tinymce.minorVersion
48 };
49 }
50 });
51
52 // Register plugin
53 tinymce.PluginManager.add('searchreplace', tinymce.plugins.SearchReplacePlugin);
54})(); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/searchreplace/js/searchreplace.js b/public/javascripts/tiny_mce/plugins/searchreplace/js/searchreplace.js
new file mode 100755
index 0000000..a8585cc
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/searchreplace/js/searchreplace.js
@@ -0,0 +1,126 @@
1tinyMCEPopup.requireLangPack();
2
3var SearchReplaceDialog = {
4 init : function(ed) {
5 var f = document.forms[0], m = tinyMCEPopup.getWindowArg("mode");
6
7 this.switchMode(m);
8
9 f[m + '_panel_searchstring'].value = tinyMCEPopup.getWindowArg("search_string");
10
11 // Focus input field
12 f[m + '_panel_searchstring'].focus();
13 },
14
15 switchMode : function(m) {
16 var f, lm = this.lastMode;
17
18 if (lm != m) {
19 f = document.forms[0];
20
21 if (lm) {
22 f[m + '_panel_searchstring'].value = f[lm + '_panel_searchstring'].value;
23 f[m + '_panel_backwardsu'].checked = f[lm + '_panel_backwardsu'].checked;
24 f[m + '_panel_backwardsd'].checked = f[lm + '_panel_backwardsd'].checked;
25 f[m + '_panel_casesensitivebox'].checked = f[lm + '_panel_casesensitivebox'].checked;
26 }
27
28 mcTabs.displayTab(m + '_tab', m + '_panel');
29 document.getElementById("replaceBtn").style.display = (m == "replace") ? "inline" : "none";
30 document.getElementById("replaceAllBtn").style.display = (m == "replace") ? "inline" : "none";
31 this.lastMode = m;
32 }
33 },
34
35 searchNext : function(a) {
36 var ed = tinyMCEPopup.editor, se = ed.selection, r = se.getRng(), f, m = this.lastMode, s, b, fl = 0, w = ed.getWin(), wm = ed.windowManager, fo = 0;
37
38 // Get input
39 f = document.forms[0];
40 s = f[m + '_panel_searchstring'].value;
41 b = f[m + '_panel_backwardsu'].checked;
42 ca = f[m + '_panel_casesensitivebox'].checked;
43 rs = f['replace_panel_replacestring'].value;
44
45 if (s == '')
46 return;
47
48 function fix() {
49 // Correct Firefox graphics glitches
50 r = se.getRng().cloneRange();
51 ed.getDoc().execCommand('SelectAll', false, null);
52 se.setRng(r);
53 };
54
55 function replace() {
56 if (tinymce.isIE)
57 ed.selection.getRng().duplicate().pasteHTML(rs); // Needs to be duplicated due to selection bug in IE
58 else
59 ed.getDoc().execCommand('InsertHTML', false, rs);
60 };
61
62 // IE flags
63 if (ca)
64 fl = fl | 4;
65
66 switch (a) {
67 case 'all':
68 // Move caret to beginning of text
69 ed.execCommand('SelectAll');
70 ed.selection.collapse(true);
71
72 if (tinymce.isIE) {
73 while (r.findText(s, b ? -1 : 1, fl)) {
74 r.scrollIntoView();
75 r.select();
76 replace();
77 fo = 1;
78 }
79
80 tinyMCEPopup.storeSelection();
81 } else {
82 while (w.find(s, ca, b, false, false, false, false)) {
83 replace();
84 fo = 1;
85 }
86 }
87
88 if (fo)
89 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.allreplaced'));
90 else
91 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
92
93 return;
94
95 case 'current':
96 if (!ed.selection.isCollapsed())
97 replace();
98
99 break;
100 }
101
102 se.collapse(b);
103 r = se.getRng();
104
105 // Whats the point
106 if (!s)
107 return;
108
109 if (tinymce.isIE) {
110 if (r.findText(s, b ? -1 : 1, fl)) {
111 r.scrollIntoView();
112 r.select();
113 } else
114 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
115
116 tinyMCEPopup.storeSelection();
117 } else {
118 if (!w.find(s, ca, b, false, false, false, false))
119 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
120 else
121 fix();
122 }
123 }
124};
125
126tinyMCEPopup.onInit.add(SearchReplaceDialog.init, SearchReplaceDialog);
diff --git a/public/javascripts/tiny_mce/plugins/searchreplace/langs/en_dlg.js b/public/javascripts/tiny_mce/plugins/searchreplace/langs/en_dlg.js
new file mode 100755
index 0000000..370959a
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/searchreplace/langs/en_dlg.js
@@ -0,0 +1,16 @@
1tinyMCE.addI18n('en.searchreplace_dlg',{
2searchnext_desc:"Find again",
3notfound:"The search has been completed. The search string could not be found.",
4search_title:"Find",
5replace_title:"Find/Replace",
6allreplaced:"All occurrences of the search string were replaced.",
7findwhat:"Find what",
8replacewith:"Replace with",
9direction:"Direction",
10up:"Up",
11down:"Down",
12mcase:"Match case",
13findnext:"Find next",
14replace:"Replace",
15replaceall:"Replace all"
16}); \ No newline at end of file
diff --git a/public/javascripts/tiny_mce/plugins/searchreplace/searchreplace.htm b/public/javascripts/tiny_mce/plugins/searchreplace/searchreplace.htm
new file mode 100755
index 0000000..9c95a6a
--- /dev/null
+++ b/public/javascripts/tiny_mce/plugins/searchreplace/searchreplace.htm
@@ -0,0 +1,105 @@
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>{#searchreplace_dlg.replace_title}</title>
5 <script type="text/javascript" src="../../tiny_mce_popup.js"></script>
6 <script type="text/javascript" src="../../utils/mctabs.js"></script>
7 <script type="text/javascript" src="../../utils/form_utils.js"></script>
8 <script type="text/javascript" src="js/searchreplace.js"></script>
9 <link rel="stylesheet" type="text/css" href="css/searchreplace.css" />
10 <base target="_self" />
11</head>
12<body style="display:none;">
13<form onsubmit="SearchReplaceDialog.searchNext('none');return false;" action="#">
14 <div class="tabs">
15 <ul>
16 <li id="search_tab"><span><a href="javascript:SearchReplaceDialog.switchMode('search');" onmousedown="return false;">{#searchreplace.search_desc}</a></span></li>
17 <li id="replace_tab"><span><a href="javascript:SearchReplaceDialog.switchMode('replace');" onmousedown="return false;">{#searchreplace_dlg.replace}</a></span></li>
18 </ul>
19 </div>
20
21 <div class="panel_wrapper">
22 <div id="search_panel" class="panel">
23 <table border="0" cellspacing="0" cellpadding="2">
24 <tr>
25 <td><label for="search_panel_searchstring">{#searchreplace_dlg.findwhat}</label></td>
26 <td><input type="text" id="search_panel_searchstring" name="search_panel_searchstring" style="width: 200px" /></td>
27 </tr>
28 <tr>
29 <td colspan="2">
30 <table border="0" cellspacing="0" cellpadding="0" class="direction">
31 <tr>
32 <td><label>{#searchreplace_dlg.direction}</label></td>
33 <td><input id="search_panel_backwardsu" name="search_panel_backwards" class="radio" type="radio" /></td>
34 <td><label for="search_panel_backwardsu">{#searchreplace_dlg.up}</label></td>
35 <td><input id="search_panel_backwardsd" name="search_panel_backwards" class="radio" type="radio" checked="checked" /></td>
36 <td><label for="search_panel_backwardsd">{#searchreplace_dlg.down}</label></td>
37 </tr>
38 </table>
39 </td>
40 </tr>
41 <tr>
42 <td colspan="2">
43 <table border="0" cellspacing="0" cellpadding="0">
44 <tr>
45 <td><input id="search_panel_casesensitivebox" name="search_panel_casesensitivebox" class="checkbox" type="checkbox" /></td>
46 <td><label for="search_panel_casesensitivebox">{#searchreplace_dlg.mcase}</label></td>
47 </tr>
48 </table>
49 </td>
50 </tr>
51 </table>
52 </div>
53
54 <div id="replace_panel" class="panel">
55 <table border="0" cellspacing="0" cellpadding="2">
56 <tr>
57 <td><label for="replace_panel_searchstring">{#searchreplace_dlg.findwhat}</label></td>
58 <td><input type="text" id="replace_panel_searchstring" name="replace_panel_searchstring" style="width: 200px" /></td>
59 </tr>
60 <tr>
61 <td><label for="replace_panel_replacestring">{#searchreplace_dlg.replacewith}</label></td>
62 <td><input type="text" id="replace_panel_replacestring" name="replace_panel_replacestring" style="width: 200px" /></td>
63 </tr>
64 <tr>
65 <td colspan="2">
66 <table border="0" cellspacing="0" cellpadding="0" class="direction">
67 <tr>
68 <td><label>{#searchreplace_dlg.direction}</label></td>
69 <td><input id="replace_panel_backwardsu" name="replace_panel_backwards" class="radio" type="radio" /></td>
70 <td><label for="replace_panel_backwardsu">{#searchreplace_dlg.up}</label></td>
71 <td><input id="replace_panel_backwardsd" name="replace_panel_backwards" class="radio" type="radio" checked="checked" /></td>
72 <td><label for="replace_panel_backwardsd">{#searchreplace_dlg.down}</label></td>
73 </tr>
74 </table>
75 </td>
76 </tr>
77 <tr>
78 <td colspan="2">
79 <table border="0" cellspacing="0" cellpadding="0">
80 <tr>
81 <td><input id="replace_panel_casesensitivebox" name="replace_panel_casesensitivebox" class="checkbox" type="checkbox" /></td>
82 <td><label for="replace_panel_casesensitivebox">{#searchreplace_dlg.mcase}</label></td>
83 </tr>
84 </table>
85 </td>
86 </tr>
87 </table>
88 </div>
89
90 </div>
91
92 <div class="mceActionPanel">
93 <div style="float: left">
94 <input type="submit" id="insert" name="insert" value="{#searchreplace_dlg.findnext}" />
95 <input type="button" class="button" id="replaceBtn" name="replaceBtn" value="{#searchreplace_dlg.replace}" onclick="SearchReplaceDialog.searchNext('current');" />
96 <input type="button" class="button" id="replaceAllBtn" name="replaceAllBtn" value="{#searchreplace_dlg.replaceall}" onclick="SearchReplaceDialog.searchNext('all');" />
97 </div>
98
99 <div style="float: right">
100 <input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
101 </div>
102 </div>
103</form>
104</body>
105</html>