1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!--
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
5 *
6 * == BEGIN LICENSE ==
7 *
8 * Licensed under the terms of any of the following licenses at your
9 * choice:
10 *
11 *  - GNU General Public License Version 2 or later (the "GPL")
12 *    http://www.gnu.org/licenses/gpl.html
13 *
14 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15 *    http://www.gnu.org/licenses/lgpl.html
16 *
17 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18 *    http://www.mozilla.org/MPL/MPL-1.1.html
19 *
20 * == END LICENSE ==
21 *
22 * This is the sample "Find" plugin window.
23-->
24<html>
25	<head>
26		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
27		<meta content="noindex, nofollow" name="robots">
28		<script type="text/javascript">
29
30var oEditor = window.parent.InnerDialogLoaded() ;
31
32function OnLoad()
33{
34	// Whole word is available on IE only.
35	if ( oEditor.FCKBrowserInfo.IsIE )
36		document.getElementById('divWord').style.display = '' ;
37
38	// First of all, translate the dialog box texts.
39	oEditor.FCKLanguageManager.TranslatePage( document ) ;
40
41	window.parent.SetAutoSize( true ) ;
42}
43
44function btnStat(frm)
45{
46	document.getElementById('btnFind').disabled =
47		( document.getElementById('txtFind').value.length == 0 ) ;
48}
49
50function ReplaceTextNodes( parentNode, regex, replaceValue, replaceAll )
51{
52	for ( var i = 0 ; i < parentNode.childNodes.length ; i++ )
53	{
54		var oNode = parentNode.childNodes[i] ;
55		if ( oNode.nodeType == 3 )
56		{
57			var sReplaced = oNode.nodeValue.replace( regex, replaceValue ) ;
58			if ( oNode.nodeValue != sReplaced )
59			{
60				oNode.nodeValue = sReplaced ;
61				if ( ! replaceAll )
62					return true ;
63			}
64		}
65		else
66		{
67			if ( ReplaceTextNodes( oNode, regex, replaceValue ) )
68				return true ;
69		}
70	}
71	return false ;
72}
73
74function GetRegexExpr()
75{
76	if ( document.getElementById('chkWord').checked )
77		var sExpr = '\\b' + document.getElementById('txtFind').value + '\\b' ;
78	else
79		var sExpr = document.getElementById('txtFind').value ;
80
81	return sExpr ;
82}
83
84function GetCase()
85{
86	return ( document.getElementById('chkCase').checked ? '' : 'i' ) ;
87}
88
89function Ok()
90{
91	if ( document.getElementById('txtFind').value.length == 0 )
92		return ;
93
94	if ( oEditor.FCKBrowserInfo.IsIE )
95		FindIE() ;
96	else
97		FindGecko() ;
98}
99
100var oRange = null ;
101
102function FindIE()
103{
104	if ( oRange == null )
105		oRange = oEditor.FCK.EditorDocument.body.createTextRange() ;
106
107	var iFlags = 0 ;
108
109	if ( chkCase.checked )
110		iFlags = iFlags | 4 ;
111
112	if ( chkWord.checked )
113		iFlags = iFlags | 2 ;
114
115	var bFound = oRange.findText( document.getElementById('txtFind').value, 1, iFlags ) ;
116
117	if ( bFound )
118	{
119		oRange.scrollIntoView() ;
120		oRange.select() ;
121		oRange.collapse(false) ;
122		oLastRangeFound = oRange ;
123	}
124	else
125	{
126		oRange = null ;
127		alert( oEditor.FCKLang.DlgFindNotFoundMsg ) ;
128	}
129}
130
131function FindGecko()
132{
133	var bCase = document.getElementById('chkCase').checked ;
134	var bWord = document.getElementById('chkWord').checked ;
135
136	// window.find( searchString, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog ) ;
137	oEditor.FCK.EditorWindow.find( document.getElementById('txtFind').value, bCase, false, false, bWord, false, false ) ;
138
139}
140		</script>
141	</head>
142	<body onload="OnLoad()" scroll="no" style="OVERFLOW: hidden">
143		<div align="center">
144			This is my Plugin!
145		</div>
146		<table cellSpacing="3" cellPadding="2" width="100%" border="0">
147			<tr>
148				<td nowrap>
149					<label for="txtFind" fckLang="DlgMyReplaceFindLbl">Find what:</label>&nbsp;
150				</td>
151				<td width="100%">
152					<input id="txtFind" onkeyup="btnStat(this.form)" style="WIDTH: 100%" tabIndex="1" type="text">
153				</td>
154				<td>
155					<input id="btnFind" style="WIDTH: 100%; PADDING-RIGHT: 5px; PADDING-LEFT: 5px" disabled
156						onclick="Ok();" type="button" value="Find" fckLang="DlgMyFindFindBtn">
157				</td>
158			</tr>
159			<tr>
160				<td valign="bottom" colSpan="3">
161					&nbsp;<input id="chkCase" tabIndex="3" type="checkbox"><label for="chkCase" fckLang="DlgMyReplaceCaseChk">Match
162						case</label>
163					<br>
164					<div id="divWord" style="DISPLAY: none">
165						&nbsp;<input id="chkWord" tabIndex="4" type="checkbox"><label for="chkWord" fckLang="DlgMyReplaceWordChk">Match
166							whole word</label>
167					</div>
168				</td>
169			</tr>
170		</table>
171	</body>
172</html>
173