1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
\r
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
4 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
\r
6 * == BEGIN LICENSE ==
\r
8 * Licensed under the terms of any of the following licenses at your
\r
11 * - GNU General Public License Version 2 or later (the "GPL")
\r
12 * http://www.gnu.org/licenses/gpl.html
\r
14 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
15 * http://www.gnu.org/licenses/lgpl.html
\r
17 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
18 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
22 * "Replace" dialog box window.
\r
24 <html xmlns="http://www.w3.org/1999/xhtml">
\r
27 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
28 <meta content="noindex, nofollow" name="robots" />
\r
29 <script type="text/javascript">
\r
31 var oEditor = window.parent.InnerDialogLoaded() ;
\r
35 // First of all, translate the dialog box texts
\r
36 oEditor.FCKLanguageManager.TranslatePage( document ) ;
\r
38 window.parent.SetAutoSize( true ) ;
\r
40 oEditor.FCKUndo.SaveUndoStep() ;
\r
43 function btnStat(frm)
\r
45 document.getElementById('btnReplace').disabled =
\r
46 document.getElementById('btnReplaceAll').disabled =
\r
47 ( document.getElementById('txtFind').value.length == 0 ) ;
\r
50 function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll, hasFound )
\r
52 for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
\r
54 var oNode = parentNode.childNodes[i] ;
\r
55 if ( oNode.nodeType == 3 )
\r
57 var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ;
\r
58 if ( oNode.nodeValue != sReplaced )
\r
60 oNode.nodeValue = sReplaced ;
\r
67 hasFound = ReplaceTextNodes( oNode, regex, replaceValue, replaceAll, hasFound ) ;
\r
68 if ( ! replaceAll && hasFound )
\r
75 function GetRegexExpr()
\r
77 var sExpr = EscapeRegexString( document.getElementById('txtFind').value ) ;
\r
79 if ( document.getElementById('chkWord').checked )
\r
80 sExpr = '\\b' + sExpr + '\\b' ;
\r
87 return ( document.getElementById('chkCase').checked ? '' : 'i' ) ;
\r
90 function GetReplacement()
\r
92 return document.getElementById('txtReplace').value.replace( /\$/g, '$$$$' ) ;
\r
95 function EscapeRegexString( str )
\r
97 return str.replace( /[\\\^\$\*\+\?\{\}\.\(\)\!\|\[\]\-]/g, '\\$&' ) ;
\r
102 var oRegex = new RegExp( GetRegexExpr(), GetCase() ) ;
\r
103 if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, GetReplacement(), false, false ) )
\r
104 alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
\r
107 function ReplaceAll()
\r
109 var oRegex = new RegExp( GetRegexExpr(), GetCase() + 'g' ) ;
\r
110 if ( !ReplaceTextNodes( oEditor.FCK.EditorDocument.body, oRegex, GetReplacement(), true, false ) )
\r
111 alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
\r
112 window.parent.Cancel() ;
\r
116 <body onload="OnLoad()" style="overflow: hidden">
\r
117 <table cellspacing="3" cellpadding="2" width="100%" border="0">
\r
119 <td nowrap="nowrap">
\r
120 <label for="txtFind" fcklang="DlgReplaceFindLbl">
\r
124 <input id="txtFind" onkeyup="btnStat(this.form)" style="width: 100%" tabindex="1"
\r
128 <input id="btnReplace" style="width: 100%" disabled="disabled" onclick="Replace();"
\r
129 type="button" value="Replace" fcklang="DlgReplaceReplaceBtn" />
\r
133 <td valign="top" nowrap="nowrap">
\r
134 <label for="txtReplace" fcklang="DlgReplaceReplaceLbl">
\r
135 Replace with:</label>
\r
138 <input id="txtReplace" style="width: 100%" tabindex="2" type="text" />
\r
141 <input id="btnReplaceAll" disabled="disabled" onclick="ReplaceAll()" type="button"
\r
142 value="Replace All" fcklang="DlgReplaceReplAllBtn" />
\r
146 <td valign="bottom" colspan="3">
\r
147 <input id="chkCase" tabindex="3" type="checkbox" /><label for="chkCase" fcklang="DlgReplaceCaseChk">Match
\r
150 <input id="chkWord" tabindex="4" type="checkbox" /><label for="chkWord" fcklang="DlgReplaceWordChk">Match
\r