34883c69019f2ab6984a6d6883b88b23a02f2a4b
[Packages/TYPO3.CMS.git] / typo3 / sysext / rtehtmlarea / htmlarea / plugins / FindReplace / find-replace.js
1 /***************************************************************
2 * Copyright notice
3 *
4 * (c) 2004 Cau guanabara <caugb@ibest.com.br>
5 * (c) 2005-2008 Stanislas Rolland <stanislas.rolland(arobas)fructifor.ca>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This script is a modified version of a script published under the htmlArea License.
26 * A copy of the htmlArea License may be found in the textfile HTMLAREA_LICENSE.txt.
27 *
28 * This copyright notice MUST APPEAR in all copies of the script!
29 ***************************************************************/
30 /*
31 * Find and Replace Plugin for TYPO3 htmlArea RTE
32 *
33 * TYPO3 CVS ID: $Id$
34 */
35 FindReplace = HTMLArea.Plugin.extend({
36
37 constructor : function(editor, pluginName) {
38 this.base(editor, pluginName);
39 },
40
41 /*
42 * This function gets called by the class constructor
43 */
44 configurePlugin : function(editor) {
45
46 /*
47 * Registering plugin "About" information
48 */
49 var pluginInformation = {
50 version : "1.2",
51 developer : "Cau Guanabara & Stanislas Rolland",
52 developerUrl : "mailto:caugb@ibest.com.br",
53 copyrightOwner : "Cau Guanabara & Stanislas Rolland",
54 sponsor : "Independent production & Fructifor Inc.",
55 sponsorUrl : "http://www.netflash.com.br/gb/HA3-rc1/examples/find-replace.html",
56 license : "GPL"
57 };
58 this.registerPluginInformation(pluginInformation);
59
60 /*
61 * Registering the button
62 */
63 var buttonId = "FindReplace";
64 var buttonConfiguration = {
65 id : buttonId,
66 tooltip : this.localize("Find and Replace"),
67 action : "onButtonPress",
68 dialog : true
69 };
70 this.registerButton(buttonConfiguration);
71
72 this.popupWidth = 300;
73 this.popupHeight = 400;
74
75 return true;
76 },
77
78 /*
79 * This function gets called when the button was pressed.
80 *
81 * @param object editor: the editor instance
82 * @param string id: the button id or the key
83 *
84 * @return boolean false if action is completed
85 */
86 onButtonPress : function (editor, id, target) {
87 // Could be a button or its hotkey
88 var buttonId = this.translateHotKey(id);
89 buttonId = buttonId ? buttonId : id;
90
91 var sel = this.editor.getSelectedHTML(), param = null;
92 if (/\w/.test(sel)) {
93 sel = sel.replace(/<[^>]*>/g,"");
94 sel = sel.replace(/&nbsp;/g,"");
95 }
96 if (/\w/.test(sel)) {
97 param = { fr_pattern: sel };
98 }
99
100 this.dialog = this.openDialog("FindReplace", this.makeUrlFromPopupName("find_replace"), null, param, {width:this.popupWidth, height:this.popupHeight});
101 return false;
102 }
103 });