| | |
| | | /**
|
| | | * $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');
|
| | |
| | | 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
|
| | | };
|
| | | },
|
| | |
| | | }
|
| | |
|
| | | 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)
|
| | |
| | | defValue("resizable", "no");
|
| | |
|
| | | switch (command) {
|
| | | case "mceResetSearch" :
|
| | | tinyMCE.lastSearchRng = null;
|
| | | return true;
|
| | |
|
| | | case "mceSearch" :
|
| | | if (user_interface) {
|
| | | var template = new Array();
|
| | |
| | | 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;
|
| | |
| | | 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))
|
| | | replaceSel(value['string'], value['replacestring'], value['backwards']);
|
| | | found = false;
|
| | |
|
| | | alert(tinyMCE.getLang('lang_searchreplace_allreplaced'));
|
| | | 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))
|
| | | alert(tinyMCE.getLang('lang_searchreplace_notfound'));
|
| | | awin.alert(tinyMCE.getLang('lang_searchreplace_notfound'));
|
| | | }
|
| | | }
|
| | |
|