From c12344a9777c61c01d91ae929a3af588d4fb7fbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Mon, 22 Aug 2011 13:44:57 +0200 Subject: [PATCH] added support for localizable dialog buttons --- src/ellib/js/eldialogform.js | 18 ++++++++++++------ src/elrte/js/elRTE.js | 9 +++++++++ src/elrte/js/ui/about.js | 11 +++++++---- src/elrte/js/ui/anchor.js | 2 +- src/elrte/js/ui/copy.js | 11 ++++++++--- src/elrte/js/ui/css.js | 2 +- src/elrte/js/ui/flash.js | 2 +- src/elrte/js/ui/horizontalrule.js | 2 +- src/elrte/js/ui/image.js | 2 +- src/elrte/js/ui/link.js | 2 +- src/elrte/js/ui/pasteformattext.js | 2 +- src/elrte/js/ui/pastetext.js | 2 +- src/elrte/js/ui/smiley.js | 2 +- src/elrte/js/ui/table.js | 2 +- src/elrte/js/ui/tbcellprops.js | 2 +- 15 files changed, 47 insertions(+), 24 deletions(-) diff --git a/src/ellib/js/eldialogform.js b/src/ellib/js/eldialogform.js index 6d9ff33..8e150ba 100644 --- a/src/ellib/js/eldialogform.js +++ b/src/ellib/js/eldialogform.js @@ -35,9 +35,9 @@ * **/ -function elDialogForm(o) { +function elDialogForm(o, i18n) { var self = this; - + var defaults = { 'class' : 'el-dialogform', submit : function(e, d) { d.close(); }, @@ -53,10 +53,16 @@ function elDialogForm(o) { modal : true, resizable : false, closeOnEscape : true, - buttons : { - Cancel : function() { self.close(); }, - Ok : function() { self.form.trigger('submit'); } - } + buttons : [ + { + text: i18n ? i18n.translate('Cancel') : 'Cancel', + click: function() { self.close(); } + }, + { + text: i18n ? i18n.translate('Ok') : 'Ok', + click: function() { self.form.trigger('submit'); } + } + ] } }; diff --git a/src/elrte/js/elRTE.js b/src/elrte/js/elRTE.js index abdf5e7..10659aa 100644 --- a/src/elrte/js/elRTE.js +++ b/src/elrte/js/elRTE.js @@ -328,6 +328,15 @@ elRTE = function(target, opts) { } +/** + * Return localization + * + * @return eli18n + **/ +elRTE.prototype.getI18n = function() { + return this._i18n; +} + /** * Return message translated to selected language * diff --git a/src/elrte/js/ui/about.js b/src/elrte/js/ui/about.js index b04f1ae..8c7f651 100644 --- a/src/elrte/js/ui/about.js +++ b/src/elrte/js/ui/about.js @@ -12,9 +12,12 @@ dialog : { width : 560, title : this.rte.i18n('About this software'), - buttons : { - Ok : function() { $(this).dialog('destroy'); } - } + buttons : [ + { + text : this.rte.i18n('Ok'), + click : function() { $(this).dialog('destroy'); } + } + ] } } @@ -40,7 +43,7 @@ +'
'+this.rte.i18n('For more information about this software visit the')+' '+this.rte.i18n('elRTE website')+'.
' +'
Twitter: elrte_elfinder
'; - d = new elDialogForm(opts); + d = new elDialogForm(opts, this.rte.getI18n()); d.append(txt); d.open(); } diff --git a/src/elrte/js/ui/anchor.js b/src/elrte/js/ui/anchor.js index a166d76..9562294 100644 --- a/src/elrte/js/ui/anchor.js +++ b/src/elrte/js/ui/anchor.js @@ -26,7 +26,7 @@ elRTE.prototype.ui.prototype.buttons.anchor = function(rte, name) { !this.rte.selection.collapsed() && this.rte.selection.collapse(false); this.input.val($(this.anchor).addClass('elrte-anchor').attr('name')); this.rte.selection.saveIERange(); - var d = new elDialogForm(opts); + var d = new elDialogForm(opts, this.rte.getI18n()); d.append([this.rte.i18n('Bookmark name'), this.input], null, true).open(); setTimeout(function() { self.input.focus()}, 20); } diff --git a/src/elrte/js/ui/copy.js b/src/elrte/js/ui/copy.js index 36ddb32..f670fc3 100644 --- a/src/elrte/js/ui/copy.js +++ b/src/elrte/js/ui/copy.js @@ -11,7 +11,7 @@ (function($) { elRTE.prototype.ui.prototype.buttons.copy = function(rte, name) { this.constructor.prototype.constructor.call(this, rte, name); - + this.command = function() { if (this.rte.browser.mozilla) { @@ -27,11 +27,16 @@ elRTE.prototype.ui.prototype.buttons.copy = function(rte, name) { var opts = { dialog : { title : this.rte.i18n('Warning'), - buttons : { Ok : function() { $(this).dialog('close'); } } + buttons : [ + { + text : this.rte.i18n('Ok'), + click : function() { $(this).dialog('close'); } + } + ] } } - var d = new elDialogForm(opts); + var d = new elDialogForm(opts, this.rte.getI18n()); d.append(this.rte.i18n('This operation is disabled in your browser on security reason. Use shortcut instead.')+': '+s).open(); } } else { diff --git a/src/elrte/js/ui/css.js b/src/elrte/js/ui/css.js index 42e0a77..ebdf761 100644 --- a/src/elrte/js/ui/css.js +++ b/src/elrte/js/ui/css.js @@ -24,7 +24,7 @@ this.cssStyle.val($(n).attr('style')); this.cssClass.val($(n).attr('class')); this.elementID.val($(n).attr('id')); - var d = new elDialogForm(opts); + var d = new elDialogForm(opts, this.rte.getI18n()); d.append([this.rte.i18n('Css style'), this.cssStyle], null, true) d.append([this.rte.i18n('Css class'), this.cssClass], null, true) d.append([this.rte.i18n('ID'), this.elementID], null, true) diff --git a/src/elrte/js/ui/flash.js b/src/elrte/js/ui/flash.js index 8b1ddb8..3c55a8d 100644 --- a/src/elrte/js/ui/flash.js +++ b/src/elrte/js/ui/flash.js @@ -100,7 +100,7 @@ title : this.rte.i18n('Flash') } } - var d = new elDialogForm(opts); + var d = new elDialogForm(opts, this.rte.getI18n()); if (this.rte.options.fmAllow && this.rte.options.fmOpen) { var src = $('').append(this.src.url.css('width', '85%')) diff --git a/src/elrte/js/ui/horizontalrule.js b/src/elrte/js/ui/horizontalrule.js index 2330b75..a41f817 100644 --- a/src/elrte/js/ui/horizontalrule.js +++ b/src/elrte/js/ui/horizontalrule.js @@ -49,7 +49,7 @@ elRTE.prototype.ui.prototype.buttons.horizontalrule = function(rte, name) { } } - var d = new elDialogForm(opts); + var d = new elDialogForm(opts, this.rte.getI18n()); d.append([this.rte.i18n('Width'), $('').append(this.src.width).append(this.src.wunit) ], null, true) .append([this.rte.i18n('Height'), $('').append(this.src.height).append(' px')], null, true) .append([this.rte.i18n('Border'), this.src.border], null, true) diff --git a/src/elrte/js/ui/image.js b/src/elrte/js/ui/image.js index a94e41e..7b6accf 100644 --- a/src/elrte/js/ui/image.js +++ b/src/elrte/js/ui/image.js @@ -271,7 +271,7 @@ elRTE.prototype.ui.prototype.buttons.image = function(rte, name) { } } }, - dialog = new elDialogForm(opts), + dialog = new elDialogForm(opts, this.rte.getI18n()); fm = !!rte.options.fmOpen, src = fm ? $('
') diff --git a/src/elrte/js/ui/link.js b/src/elrte/js/ui/link.js index b820d7d..b067b08 100644 --- a/src/elrte/js/ui/link.js +++ b/src/elrte/js/ui/link.js @@ -156,7 +156,7 @@ elRTE.prototype.ui.prototype.buttons.link = function(rte, name) { } } - d = new elDialogForm(opts); + d = new elDialogForm(opts, this.rte.getI18n()); l = $('
') .append( $('