[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 tinyMCEPopup.requireLangPack(); 2 3 var SearchReplaceDialog = { 4 init : function(ed) { 5 var t = this, f = document.forms[0], m = tinyMCEPopup.getWindowArg("mode"); 6 7 t.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 mcTabs.onChange.add(function(tab_id, panel_id) { 15 t.switchMode(tab_id.substring(0, tab_id.indexOf('_'))); 16 }); 17 18 }, 19 20 switchMode : function(m) { 21 var f, lm = this.lastMode; 22 23 if (lm != m) { 24 f = document.forms[0]; 25 26 if (lm) { 27 f[m + '_panel_searchstring'].value = f[lm + '_panel_searchstring'].value; 28 f[m + '_panel_backwardsu'].checked = f[lm + '_panel_backwardsu'].checked; 29 f[m + '_panel_backwardsd'].checked = f[lm + '_panel_backwardsd'].checked; 30 f[m + '_panel_casesensitivebox'].checked = f[lm + '_panel_casesensitivebox'].checked; 31 } 32 33 mcTabs.displayTab(m + '_tab', m + '_panel'); 34 document.getElementById("replaceBtn").style.display = (m == "replace") ? "inline" : "none"; 35 document.getElementById("replaceAllBtn").style.display = (m == "replace") ? "inline" : "none"; 36 this.lastMode = m; 37 } 38 }, 39 40 searchNext : function(a) { 41 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; 42 43 if (tinymce.isIE11 && !window.find) { 44 ed.windowManager.alert("This feature is not available in IE 11+. Upgrade TinyMCE to 4.x to get this functionallity back."); 45 return; 46 } 47 48 // Get input 49 f = document.forms[0]; 50 s = f[m + '_panel_searchstring'].value; 51 b = f[m + '_panel_backwardsu'].checked; 52 ca = f[m + '_panel_casesensitivebox'].checked; 53 rs = f['replace_panel_replacestring'].value; 54 55 if (tinymce.isIE) { 56 r = ed.getDoc().selection.createRange(); 57 } 58 59 if (s == '') 60 return; 61 62 function fix() { 63 // Correct Firefox graphics glitches 64 // TODO: Verify if this is actually needed any more, maybe it was for very old FF versions? 65 r = se.getRng().cloneRange(); 66 ed.getDoc().execCommand('SelectAll', false, null); 67 se.setRng(r); 68 }; 69 70 function replace() { 71 ed.selection.setContent(rs); // Needs to be duplicated due to selection bug in IE 72 }; 73 74 // IE flags 75 if (ca) 76 fl = fl | 4; 77 78 switch (a) { 79 case 'all': 80 // Move caret to beginning of text 81 ed.execCommand('SelectAll'); 82 ed.selection.collapse(true); 83 84 if (tinymce.isIE) { 85 ed.focus(); 86 r = ed.getDoc().selection.createRange(); 87 88 while (r.findText(s, b ? -1 : 1, fl)) { 89 r.scrollIntoView(); 90 r.select(); 91 replace(); 92 fo = 1; 93 94 if (b) { 95 r.moveEnd("character", -(rs.length)); // Otherwise will loop forever 96 } else { 97 // to avoid looping for ever in MSIE 9/10 when just 98 // changing the case 99 r.moveStart("character", rs.length); 100 } 101 } 102 103 tinyMCEPopup.storeSelection(); 104 } else { 105 while (w.find(s, ca, b, false, false, false, false)) { 106 replace(); 107 fo = 1; 108 } 109 } 110 111 if (fo) 112 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.allreplaced')); 113 else 114 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound')); 115 116 return; 117 118 case 'current': 119 if (!ed.selection.isCollapsed()) 120 replace(); 121 122 break; 123 } 124 125 se.collapse(b); 126 r = se.getRng(); 127 128 // Whats the point 129 if (!s) 130 return; 131 132 if (tinymce.isIE) { 133 ed.focus(); 134 r = ed.getDoc().selection.createRange(); 135 136 if (r.findText(s, b ? -1 : 1, fl)) { 137 r.scrollIntoView(); 138 r.select(); 139 } else 140 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound')); 141 142 tinyMCEPopup.storeSelection(); 143 } else { 144 if (!w.find(s, ca, b, false, false, false, false)) 145 tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound')); 146 else 147 fix(); 148 } 149 } 150 }; 151 152 tinyMCEPopup.onInit.add(SearchReplaceDialog.init, SearchReplaceDialog);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |