includes/clientside/tinymce/plugins/searchreplace/js/searchreplace.js
changeset 778 57ce13805b6f
parent 543 dffcbfbc4e59
equal deleted inserted replaced
777:488665d49417 778:57ce13805b6f
    40 		s = f[m + '_panel_searchstring'].value;
    40 		s = f[m + '_panel_searchstring'].value;
    41 		b = f[m + '_panel_backwardsu'].checked;
    41 		b = f[m + '_panel_backwardsu'].checked;
    42 		ca = f[m + '_panel_casesensitivebox'].checked;
    42 		ca = f[m + '_panel_casesensitivebox'].checked;
    43 		rs = f['replace_panel_replacestring'].value;
    43 		rs = f['replace_panel_replacestring'].value;
    44 
    44 
       
    45 		if (s == '')
       
    46 			return;
       
    47 
    45 		function fix() {
    48 		function fix() {
    46 			// Correct Firefox graphics glitches
    49 			// Correct Firefox graphics glitches
    47 			r = se.getRng().cloneRange();
    50 			r = se.getRng().cloneRange();
    48 			ed.getDoc().execCommand('SelectAll', false, null);
    51 			ed.getDoc().execCommand('SelectAll', false, null);
    49 			se.setRng(r);
    52 			se.setRng(r);
    60 		if (ca)
    63 		if (ca)
    61 			fl = fl | 4;
    64 			fl = fl | 4;
    62 
    65 
    63 		switch (a) {
    66 		switch (a) {
    64 			case 'all':
    67 			case 'all':
       
    68 				// Move caret to beginning of text
       
    69 				ed.execCommand('SelectAll');
       
    70 				ed.selection.collapse(true);
       
    71 
    65 				if (tinymce.isIE) {
    72 				if (tinymce.isIE) {
    66 					while (r.findText(s, b ? -1 : 1, fl)) {
    73 					while (r.findText(s, b ? -1 : 1, fl)) {
    67 						r.scrollIntoView();
    74 						r.scrollIntoView();
    68 						r.select();
    75 						r.select();
    69 						replace();
    76 						replace();
    77 						fo = 1;
    84 						fo = 1;
    78 					}
    85 					}
    79 				}
    86 				}
    80 
    87 
    81 				if (fo)
    88 				if (fo)
    82 					wm.alert(ed.getLang('searchreplace_dlg.allreplaced'));
    89 					tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.allreplaced'));
    83 				else
    90 				else
    84 					wm.alert(ed.getLang('searchreplace_dlg.notfound'));
    91 					tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
    85 
    92 
    86 				return;
    93 				return;
    87 
    94 
    88 			case 'current':
    95 			case 'current':
    89 				replace();
    96 				if (!ed.selection.isCollapsed())
       
    97 					replace();
       
    98 
    90 				break;
    99 				break;
    91 		}
   100 		}
    92 
   101 
    93 		se.collapse(b);
   102 		se.collapse(b);
    94 		r = se.getRng();
   103 		r = se.getRng();
   100 		if (tinymce.isIE) {
   109 		if (tinymce.isIE) {
   101 			if (r.findText(s, b ? -1 : 1, fl)) {
   110 			if (r.findText(s, b ? -1 : 1, fl)) {
   102 				r.scrollIntoView();
   111 				r.scrollIntoView();
   103 				r.select();
   112 				r.select();
   104 			} else
   113 			} else
   105 				wm.alert(ed.getLang('searchreplace_dlg.notfound'));
   114 				tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
   106 
   115 
   107 			tinyMCEPopup.storeSelection();
   116 			tinyMCEPopup.storeSelection();
   108 		} else {
   117 		} else {
   109 			if (!w.find(s, ca, b, false, false, false, false))
   118 			if (!w.find(s, ca, b, false, false, false, false))
   110 				wm.alert(ed.getLang('searchreplace_dlg.notfound'));
   119 				tinyMCEPopup.alert(ed.getLang('searchreplace_dlg.notfound'));
   111 			else
   120 			else
   112 				fix();
   121 				fix();
   113 		}
   122 		}
   114 	}
   123 	}
   115 };
   124 };