diff options
author | svncommit <devs@roundcube.net> | 2007-02-26 07:19:44 +0000 |
---|---|---|
committer | svncommit <devs@roundcube.net> | 2007-02-26 07:19:44 +0000 |
commit | 87e2fddb32da8580f73c5ec0628e9eacfb4e0043 (patch) | |
tree | 33a5448f5e22896a0375ce418df5ba294076ebfa /program/js/tiny_mce/plugins/searchreplace | |
parent | e17702395e1aa0fa54eea36817e1150c231d49eb (diff) |
upgrade to TinyMCE v2.1.0
Diffstat (limited to 'program/js/tiny_mce/plugins/searchreplace')
4 files changed, 49 insertions, 36 deletions
diff --git a/program/js/tiny_mce/plugins/searchreplace/editor_plugin.js b/program/js/tiny_mce/plugins/searchreplace/editor_plugin.js index 2ba606647..959e9cc5c 100644 --- a/program/js/tiny_mce/plugins/searchreplace/editor_plugin.js +++ b/program/js/tiny_mce/plugins/searchreplace/editor_plugin.js @@ -1 +1 @@ -tinyMCE.importPluginLanguagePack('searchreplace');var TinyMCE_SearchReplacePlugin={getInfo:function(){return{longname:'Search/Replace',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_searchreplace.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion}},initInstance:function(inst){inst.addShortcut('ctrl','f','lang_searchreplace_search_desc','mceSearch',true);},getControlHTML:function(cn){switch(cn){case"search":return tinyMCE.getButtonHTML(cn,'lang_searchreplace_search_desc','{$pluginurl}/images/search.gif','mceSearch',true);case"replace":return tinyMCE.getButtonHTML(cn,'lang_searchreplace_replace_desc','{$pluginurl}/images/replace.gif','mceSearchReplace',true)}return""},execCommand:function(editor_id,element,command,user_interface,value){var inst=tinyMCE.getInstanceById(editor_id),selectedText=inst.selection.getSelectedText(),rng;function defValue(key,default_value){value[key]=typeof(value[key])=="undefined"?default_value:value[key]}function replaceSel(search_str,str,back){inst.execCommand('mceInsertContent',false,str)}if(!value)value=[];defValue("editor_id",editor_id);defValue("searchstring",selectedText);defValue("replacestring",null);defValue("replacemode","none");defValue("casesensitive",false);defValue("backwards",false);defValue("wrap",false);defValue("wholeword",false);defValue("inline","yes");defValue("resizable","no");switch(command){case"mceResetSearch":tinyMCE.lastSearchRng=null;return true;case"mceSearch":if(user_interface){var template=new Array();template['file']='../../plugins/searchreplace/searchreplace.htm';template['width']=380;template['height']=155+(tinyMCE.isNS7?20:0)+(tinyMCE.isMSIE?15:0);template['width']+=tinyMCE.getLang('lang_searchreplace_delta_width',0);template['height']+=tinyMCE.getLang('lang_searchreplace_delta_height',0);inst.execCommand('SelectAll');if(tinyMCE.isMSIE){var r=inst.selection.getRng();r.collapse(true);r.select()}else inst.selection.getSel().collapseToStart();tinyMCE.openWindow(template,value)}else{var win=tinyMCE.getInstanceById(editor_id).contentWindow;var doc=tinyMCE.getInstanceById(editor_id).contentWindow.document;var body=tinyMCE.getInstanceById(editor_id).contentWindow.document.body;if(body.innerHTML==""){alert(tinyMCE.getLang('lang_searchreplace_notfound'));return true}if(value['replacemode']=="current"){replaceSel(value['string'],value['replacestring'],value['backwards']);value['replacemode']="none";tinyMCE.execInstanceCommand(editor_id,'mceSearch',user_interface,value,false);return true}if(tinyMCE.isMSIE){var rng=tinyMCE.lastSearchRng?tinyMCE.lastSearchRng:doc.selection.createRange();var flags=0;if(value['wholeword'])flags=flags|2;if(value['casesensitive'])flags=flags|4;if(!rng.findText){alert('This operation is currently not supported by this browser.');return true}if(value['replacemode']=="all"){while(rng.findText(value['string'],value['backwards']?-1:1,flags)){rng.scrollIntoView();rng.select();rng.collapse(false);replaceSel(value['string'],value['replacestring'],value['backwards'])}alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));return true}if(rng.findText(value['string'],value['backwards']?-1:1,flags)){rng.scrollIntoView();rng.select();rng.collapse(value['backwards']);tinyMCE.lastSearchRng=rng}else alert(tinyMCE.getLang('lang_searchreplace_notfound'))}else{if(value['replacemode']=="all"){while(win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false))replaceSel(value['string'],value['replacestring'],value['backwards']);alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));return true}if(!win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false))alert(tinyMCE.getLang('lang_searchreplace_notfound'))}}return true;case"mceSearchReplace":value['replacestring']="";tinyMCE.execInstanceCommand(editor_id,'mceSearch',user_interface,value,false);return true}return false}};tinyMCE.addPlugin("searchreplace",TinyMCE_SearchReplacePlugin);
\ No newline at end of file +tinyMCE.importPluginLanguagePack('searchreplace');var TinyMCE_SearchReplacePlugin={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}},initInstance:function(inst){inst.addShortcut('ctrl','f','lang_searchreplace_search_desc','mceSearch',true);},getControlHTML:function(cn){switch(cn){case"search":return tinyMCE.getButtonHTML(cn,'lang_searchreplace_search_desc','{$pluginurl}/images/search.gif','mceSearch',true);case"replace":return tinyMCE.getButtonHTML(cn,'lang_searchreplace_replace_desc','{$pluginurl}/images/replace.gif','mceSearchReplace',true)}return""},execCommand:function(editor_id,element,command,user_interface,value){var inst=tinyMCE.getInstanceById(editor_id),selectedText=inst.selection.getSelectedText(),rng;function defValue(key,default_value){value[key]=typeof(value[key])=="undefined"?default_value:value[key]}function replaceSel(search_str,str,back){if(!inst.selection.isCollapsed()){if(tinyMCE.isRealIE)inst.selection.getRng().duplicate().pasteHTML(str);else inst.execCommand('mceInsertContent',false,str)}}if(!value)value=[];defValue("editor_id",editor_id);defValue("searchstring",selectedText);defValue("replacestring",null);defValue("replacemode","none");defValue("casesensitive",false);defValue("backwards",false);defValue("wrap",false);defValue("wholeword",false);defValue("inline","yes");defValue("resizable","no");switch(command){case"mceSearch":if(user_interface){var template=new Array();template['file']='../../plugins/searchreplace/searchreplace.htm';template['width']=380;template['height']=155+(tinyMCE.isNS7?20:0)+(tinyMCE.isMSIE?15:0);template['width']+=tinyMCE.getLang('lang_searchreplace_delta_width',0);template['height']+=tinyMCE.getLang('lang_searchreplace_delta_height',0);inst.selection.collapse(true);tinyMCE.openWindow(template,value)}else{var win=tinyMCE.getInstanceById(editor_id).contentWindow;var doc=tinyMCE.getInstanceById(editor_id).contentWindow.document;var body=tinyMCE.getInstanceById(editor_id).contentWindow.document.body;var awin=value.win,found;if(body.innerHTML==""){awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));return true}if(value['replacemode']=="current"){replaceSel(value['string'],value['replacestring'],value['backwards']);value['replacemode']="none";}inst.selection.collapse(value['backwards']);if(tinyMCE.isMSIE){var rng=inst.selection.getRng();var flags=0;if(value['wholeword'])flags=flags|2;if(value['casesensitive'])flags=flags|4;if(!rng.findText){awin.alert('This operation is currently not supported by this browser.');return true}if(value['replacemode']=="all"){found=false;while(rng.findText(value['string'],value['backwards']?-1:1,flags)){found=true;rng.scrollIntoView();rng.select();replaceSel(value['string'],value['replacestring'],value['backwards'])}if(found)awin.alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));else awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));return true}if(rng.findText(value['string'],value['backwards']?-1:1,flags)){rng.scrollIntoView();rng.select()}else awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'))}else{if(value['replacemode']=="all"){found=false;while(win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false)){found=true;replaceSel(value['string'],value['replacestring'],value['backwards'])}if(found)awin.alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));else awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));return true}if(!win.find(value['string'],value['casesensitive'],value['backwards'],value['wrap'],value['wholeword'],false,false))awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'))}}return true;case"mceSearchReplace":value['replacestring']="";tinyMCE.execInstanceCommand(editor_id,'mceSearch',user_interface,value,false);return true}return false}};tinyMCE.addPlugin("searchreplace",TinyMCE_SearchReplacePlugin);
\ No newline at end of file diff --git a/program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js b/program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js index f8aee25c6..cd2f3a85c 100644 --- a/program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js +++ b/program/js/tiny_mce/plugins/searchreplace/editor_plugin_src.js @@ -1,8 +1,8 @@ /**
- * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
+ * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
*
* @author Moxiecode
- * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
+ * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
*/
tinyMCE.importPluginLanguagePack('searchreplace');
@@ -13,7 +13,7 @@ var TinyMCE_SearchReplacePlugin = { longname : 'Search/Replace',
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_searchreplace.html',
+ infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/searchreplace',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
};
},
@@ -43,7 +43,12 @@ var TinyMCE_SearchReplacePlugin = { }
function replaceSel(search_str, str, back) {
- inst.execCommand('mceInsertContent', false, str);
+ if (!inst.selection.isCollapsed()) {
+ if (tinyMCE.isRealIE)
+ inst.selection.getRng().duplicate().pasteHTML(str); // Needs to be duplicated due to selection bug in IE
+ else
+ inst.execCommand('mceInsertContent', false, str);
+ }
}
if (!value)
@@ -61,10 +66,6 @@ var TinyMCE_SearchReplacePlugin = { defValue("resizable", "no");
switch (command) {
- case "mceResetSearch" :
- tinyMCE.lastSearchRng = null;
- return true;
-
case "mceSearch" :
if (user_interface) {
var template = new Array();
@@ -75,34 +76,31 @@ var TinyMCE_SearchReplacePlugin = { template['width'] += tinyMCE.getLang('lang_searchreplace_delta_width', 0);
template['height'] += tinyMCE.getLang('lang_searchreplace_delta_height', 0);
- inst.execCommand('SelectAll');
-
- if (tinyMCE.isMSIE) {
- var r = inst.selection.getRng();
- r.collapse(true);
- r.select();
- } else
- inst.selection.getSel().collapseToStart();
+ inst.selection.collapse(true);
tinyMCE.openWindow(template, value);
} else {
var win = tinyMCE.getInstanceById(editor_id).contentWindow;
var doc = tinyMCE.getInstanceById(editor_id).contentWindow.document;
var body = tinyMCE.getInstanceById(editor_id).contentWindow.document.body;
+ var awin = value.win, found;
+
if (body.innerHTML == "") {
- alert(tinyMCE.getLang('lang_searchreplace_notfound'));
+ awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));
return true;
}
if (value['replacemode'] == "current") {
replaceSel(value['string'], value['replacestring'], value['backwards']);
value['replacemode'] = "none";
- tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value, false);
- return true;
+ //tinyMCE.execInstanceCommand(editor_id, 'mceSearch', user_interface, value);
+ //return true;
}
+ inst.selection.collapse(value['backwards']);
+
if (tinyMCE.isMSIE) {
- var rng = tinyMCE.lastSearchRng ? tinyMCE.lastSearchRng : doc.selection.createRange();
+ var rng = inst.selection.getRng();
var flags = 0;
if (value['wholeword'])
flags = flags | 2;
@@ -111,41 +109,52 @@ var TinyMCE_SearchReplacePlugin = { flags = flags | 4;
if (!rng.findText) {
- alert('This operation is currently not supported by this browser.');
+ awin.alert('This operation is currently not supported by this browser.');
return true;
}
if (value['replacemode'] == "all") {
+ found = false;
+
while (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) {
+ found = true;
rng.scrollIntoView();
rng.select();
- rng.collapse(false);
replaceSel(value['string'], value['replacestring'], value['backwards']);
}
- alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));
+ if (found)
+ awin.alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));
+ else
+ awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));
+
return true;
}
if (rng.findText(value['string'], value['backwards'] ? -1 : 1, flags)) {
rng.scrollIntoView();
rng.select();
- rng.collapse(value['backwards']);
- tinyMCE.lastSearchRng = rng;
} else
- alert(tinyMCE.getLang('lang_searchreplace_notfound'));
-
+ awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));
} else {
if (value['replacemode'] == "all") {
- while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false))
+ found = false;
+
+ while (win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false)) {
+ found = true;
replaceSel(value['string'], value['replacestring'], value['backwards']);
+ }
+
+ if (found)
+ awin.alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));
+ else
+ awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));
- alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));
return true;
}
if (!win.find(value['string'], value['casesensitive'], value['backwards'], value['wrap'], value['wholeword'], false, false))
- alert(tinyMCE.getLang('lang_searchreplace_notfound'));
+ awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));
}
}
diff --git a/program/js/tiny_mce/plugins/searchreplace/jscripts/searchreplace.js b/program/js/tiny_mce/plugins/searchreplace/jscripts/searchreplace.js index 2eca3ea64..ac6cdf6fc 100755 --- a/program/js/tiny_mce/plugins/searchreplace/jscripts/searchreplace.js +++ b/program/js/tiny_mce/plugins/searchreplace/jscripts/searchreplace.js @@ -13,8 +13,6 @@ function init() { formObj[task + "_panel_casesensitivebox"].checked = tinyMCE.getWindowArg("casesensitive");
formObj[task + "_panel_backwardsu"].checked = tinyMCE.getWindowArg("backwards");
formObj[task + "_panel_backwardsd"].checked = !tinyMCE.getWindowArg("backwards");
-
- tinyMCEPopup.execCommand("mceResetSearch", false, {dummy : ""}, false);
}
function searchNext(replacemode) {
@@ -26,7 +24,7 @@ function searchNext(replacemode) { if (task == "replace") {
// Whats the point?
if (formObj[task + "_panel_searchstring"].value == "" || formObj[task + "_panel_searchstring"].value == formObj[task + "_panel_replacestring"].value)
- return;
+ return false;
}
// Do search
@@ -35,10 +33,13 @@ function searchNext(replacemode) { replacestring : formObj["replace_panel_replacestring"].value,
replacemode : replacemode,
casesensitive : formObj[task + "_panel_casesensitivebox"].checked,
- backwards : false
+ backwards : formObj[task + "_panel_backwardsu"].checked,
+ win : window
}, false);
window.focus();
+
+ return false;
}
function cancelAction() {
diff --git a/program/js/tiny_mce/plugins/searchreplace/searchreplace.htm b/program/js/tiny_mce/plugins/searchreplace/searchreplace.htm index 8575e2aad..192e0cbc6 100755 --- a/program/js/tiny_mce/plugins/searchreplace/searchreplace.htm +++ b/program/js/tiny_mce/plugins/searchreplace/searchreplace.htm @@ -90,12 +90,15 @@ </div>
<div class="mceActionPanel">
- <div style="text-align: center;">
+ <div style="float: left">
<input type="button" id="insert" name="insert" value="{$lang_searchreplace_findnext}" onclick="searchNext('none');" />
<span id="replace_buttons">
<input type="button" id="replaceBtn" name="replaceBtn" value="{$lang_searchreplace_replace}" onclick="searchNext('current');" />
<input type="button" id="replaceAllBtn" name="replaceAllBtn" value="{$lang_searchreplace_replaceall}" onclick="searchNext('all');;" />
</span>
+ </div>
+
+ <div style="float: right">
<input type="button" id="cancel" name="cancel" value="{$lang_searchreplace_cancel}" onclick="tinyMCEPopup.close();" />
</div>
</div>
|