/* jce - 2.6.6 | 2017-01-02 | http://www.joomlacontenteditor.net | Copyright (C) 2006 - 2017 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
var SearchReplaceDialog={settings:{},init:function(ed){var self=this;Wf.init(),$("#next").button({icons:{primary:"uk-icon-arrow-right"},classes:"uk-button-primary"}).click(function(e){self.searchNext("none"),e.preventDefault()}),$("#replaceBtn").button({icons:{primary:"uk-icon-reply"},classes:"uk-button-danger"}).click(function(e){self.searchNext("current"),e.preventDefault()}),$("#replaceAllBtn").button({icons:{primary:"uk-icon-refresh"},classes:"uk-button-danger"}).click(function(e){self.searchNext("all"),e.preventDefault()}),$("#searchstring").val(tinyMCEPopup.getWindowArg("search_string")),$("#searchstring").focus()},searchNext:function(a){function fix(){r=se.getRng().cloneRange(),ed.getDoc().execCommand("SelectAll",!1,null),se.setRng(r)}function replace(){ed.selection.setContent(rs)}var s,b,ca,rs,ed=tinyMCEPopup.editor,se=ed.selection,r=se.getRng(),fl=(this.lastMode,0),w=ed.getWin(),fo=(ed.windowManager,0);if((!tinymce.isIE11||window.find)&&(s=$("#searchstring").val(),b=$("#backwardsu").is(":checked"),ca=$("#casesensitivebox").is(":checked"),rs=$("#replacestring").val(),tinymce.isIE&&(r=ed.getDoc().selection.createRange()),""!=s)){switch(ca&&(fl|=4),a){case"all":if(ed.execCommand("SelectAll"),ed.selection.collapse(!0),tinymce.isIE){for(ed.focus(),r=ed.getDoc().selection.createRange();r.findText(s,b?-1:1,fl);)r.scrollIntoView(),r.select(),replace(),fo=1,b&&r.moveEnd("character",-rs.length);tinyMCEPopup.storeSelection()}else for(;w.find(s,ca,b,!1,!1,!1,!1);)replace(),fo=1;return void(fo?tinyMCEPopup.alert(ed.getLang("searchreplace_dlg.allreplaced","All occurrences of the search string were replaced.")):tinyMCEPopup.alert(ed.getLang("searchreplace_dlg.notfound","The search has been completed. The search string could not be found.")));case"current":ed.selection.isCollapsed()||replace()}se.collapse(b),r=se.getRng(),s&&(tinymce.isIE?(ed.focus(),r=ed.getDoc().selection.createRange(),r.findText(s,b?-1:1,fl)?(r.scrollIntoView(),r.select()):tinyMCEPopup.alert(ed.getLang("searchreplace_dlg.notfound","The search has been completed. The search string could not be found.")),tinyMCEPopup.storeSelection()):w.find(s,ca,b,!1,!1,!1,!1)?fix():tinyMCEPopup.alert(ed.getLang("searchreplace_dlg.notfound","The search has been completed. The search string could not be found.")))}}};tinyMCEPopup.onInit.add(SearchReplaceDialog.init,SearchReplaceDialog);