Changeset 752
- Timestamp:
- 02/17/07 01:32:00 (6 years ago)
- Location:
- trunk/plugins/SmartReplace
- Files:
-
- 1 removed
- 2 modified
-
dialog.html (modified) (1 diff)
-
popups (deleted)
-
smart-replace.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/SmartReplace/dialog.html
r751 r752 1 <!DOCTYPE html 2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 4 5 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 6 <head> 7 <title>SmartReplace Settings</title> 8 <script type="text/javascript" src="../../../popups/popup.js"></script> 9 <link rel="stylesheet" type="text/css" href="../../../popups/popup.css" /> 10 11 <script type="text/javascript"> 12 window.resizeTo(350, 200); 13 14 Xinha = window.opener.Xinha; 15 16 function i18n(str) { 17 return (Xinha._lc(str, 'SmartReplace')); 18 } 19 20 function Init() { 21 __dlg_translate('SmartReplace'); 22 __dlg_init(); 23 var param = window.dialogArguments; 24 document.getElementById('enable').checked = param.active; 25 } 26 27 function onOK() { 28 29 var param = { 30 enable : document.getElementById("enable").checked, 31 convert : document.getElementById("convert").checked 32 }; 33 __dlg_close(param); 34 return false; 35 } 36 37 function onCancel() { 38 __dlg_close(null); 39 return false; 40 } 41 42 </script> 43 44 </head> 45 46 <body class="dialog" onload="Init()"> 47 <div class="title">SmartReplace Settings</div> 48 <form action=""> 1 <h1 id="[h1]"><l10n>SmartReplace Settings</l10n></h1> 2 <div style="margin-left: 10px;"> 49 3 <table style="width: 100%;border:none"> 50 4 <tr> 51 <td style="width:15px"><input type="checkbox" id=" enable" /></td>52 <td style="text-align:left"> Enable automatic replacements</td>5 <td style="width:15px"><input type="checkbox" id="[enable]" name="[enable]" /></td> 6 <td style="text-align:left"><l10n>Enable automatic replacements</l10n></td> 53 7 </tr> 54 8 <tr> 55 <td style="width:15px"><input type="checkbox" id=" convert"/></td>56 <td style="text-align:left"> Convert all quotes and dashes in the current document</td>9 <td style="width:15px"><input type="checkbox" id="[convert]" name="[convert]" /></td> 10 <td style="text-align:left"><l10n>Convert all quotes and dashes in the current document</l10n></td> 57 11 </tr> 58 12 </table> 59 60 <div id="buttons">61 <button type="submit" name="ok" onclick="return onOK();">OK</button>62 < button type="button" name="cancel" onclick="return onCancel();">Cancel</button>13 <div style="margin-top: 10px;"> 14 <input type="button" id="[ok]" value="_(OK)" /> 15 <input type="button" id="[cancel]" value="_(Cancel)" /> 16 </div> 63 17 </div> 64 </form>65 </body>66 </html> -
trunk/plugins/SmartReplace/smart-replace.js
r681 r752 11 11 var self = this; 12 12 13 cfg.registerButton({ 14 id : "smartreplace", 15 tooltip : this._lc("SmartReplace"), 16 image : _editor_url+"plugins/SmartReplace/img/smartquotes.gif", 17 textMode : false, 18 action : function(editor) { 19 self.dialog(editor); 20 } 13 cfg.registerButton 14 ({ 15 id : "smartreplace", 16 tooltip : this._lc("SmartReplace"), 17 image : _editor_url+"plugins/SmartReplace/img/smartquotes.gif", 18 textMode : false, 19 /* action : function(editor) { 20 self.dialog(editor); 21 } 22 }); */ 23 action : function(e, objname, obj) { self.buttonPress(null, obj); } 21 24 }); 22 25 cfg.addToolbarElement("smartreplace", "htmlmode", 1); … … 85 88 { 86 89 this.openingQuotes = this._lc("OpeningDoubleQuotes"); 90 this.closingQuote = this._lc("ClosingSingleQuote"); 87 91 this.closingQuotes = this._lc("ClosingDoubleQuotes"); 88 92 this.openingQuote = this._lc("OpeningSingleQuote"); 89 this.closingQuote = this._lc("ClosingSingleQuote");90 93 } 91 94 … … 254 257 Dialog(_editor_url+'plugins/SmartReplace/popups/dialog.html', action, init); 255 258 } 259 260 261 SmartReplace.prototype.buttonPress = function(opts, obj) 262 { 263 var self = this; 264 265 if ( this._dialog.dialog.rootElem.style.display != 'none') 266 { 267 return this._dialog.hide(); 268 } 269 var doOK = function() 270 { 271 var opts = self._dialog.hide(); 272 self.toggleActivity((opts.enable) ? true : false); 273 if (opts.convert) 274 { 275 self.replaceAll(); 276 self._dialog.dialog.getElementById("convert").checked = false; 277 } 278 } 279 var inputs = 280 { 281 enable : self.active ? "on" : '', 282 convert: '' 283 }; 284 this._dialog.show(inputs, doOK); 285 }; 286 287 SmartReplace.prototype.onGenerateOnce = function() 288 { 289 if( !this._dialog) 290 { 291 this._dialog = new SmartReplace.Dialog(this); 292 } 293 }; 294 295 SmartReplace.Dialog = function (mainPluginObject) 296 { 297 this.Dialog_nxtid = 0; 298 this.mainPluginObject = mainPluginObject; 299 this.id = { }; // This will be filled below with a replace, nifty 300 301 this.ready = false; 302 this.files = false; 303 this.html = false; 304 this.dialog = false; 305 306 this._prepareDialog(); 307 308 }; 309 310 SmartReplace.Dialog.prototype._prepareDialog = function() 311 { 312 var pluginDialogObject = this; 313 var editor = this.mainPluginObject.editor; 314 315 if(this.html == false) 316 { 317 Xinha._getback(_editor_url + 'plugins/SmartReplace/dialog.html', function(getback) { pluginDialogObject.html = getback; pluginDialogObject._prepareDialog(); }); 318 return; 319 } 320 321 // Now we have everything we need, so we can build the dialog. 322 this.dialog = new Xinha.Dialog(editor, this.html, 'SmartReplace'); 323 324 this.ready = true; 325 }; 326 327 SmartReplace.Dialog.prototype._lc = SmartReplace.prototype._lc; 328 329 SmartReplace.Dialog.prototype.show = function(inputs, ok, cancel) 330 { 331 if(!this.ready) 332 { 333 var pluginDialogObject = this; 334 window.setTimeout(function() {pluginDialogObject.show(inputs,ok,cancel);},100); 335 return; 336 } 337 338 // Connect the OK and Cancel buttons 339 var dialog = this.dialog; 340 var pluginDialogObject = this; 341 if(ok) 342 { 343 this.dialog.getElementById('ok').onclick = ok; 344 } 345 else 346 { 347 this.dialog.getElementById('ok').onclick = function() {pluginDialogObject.hide();}; 348 } 349 350 if(cancel) 351 { 352 this.dialog.getElementById('cancel').onclick = cancel; 353 } 354 else 355 { 356 this.dialog.getElementById('cancel').onclick = function() { pluginDialogObject.hide()}; 357 } 358 359 // Show the dialog 360 this.mainPluginObject.editor.disableToolbar(['fullscreen','smartreplace']); 361 362 this.dialog.show(inputs); 363 364 // Init the sizes 365 this.dialog.onresize(); 366 }; 367 368 SmartReplace.Dialog.prototype.hide = function() 369 { 370 this.mainPluginObject.editor.enableToolbar(); 371 return this.dialog.hide(); 372 };
