Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for localizable dialog buttons #2

Open
wants to merge 1 commit into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/ellib/js/eldialogform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(); },
Expand All @@ -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'); }
}
]
}
};

Expand Down
9 changes: 9 additions & 0 deletions src/elrte/js/elRTE.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
11 changes: 7 additions & 4 deletions src/elrte/js/ui/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'); }
}
]
}
}

Expand All @@ -40,7 +43,7 @@
+'<div class="elrte-copy">'+this.rte.i18n('For more information about this software visit the')+' <a href="http://elrte.org">'+this.rte.i18n('elRTE website')+'.</a></div>'
+'<div class="elrte-copy">Twitter: <a href="http://twitter.com/elrte_elfinder">elrte_elfinder</a></div>';

d = new elDialogForm(opts);
d = new elDialogForm(opts, this.rte.getI18n());
d.append(txt);
d.open();
}
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 8 additions & 3 deletions src/elrte/js/ui/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<span />').append(this.src.url.css('width', '85%'))
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/horizontalrule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'), $('<span />').append(this.src.width).append(this.src.wunit) ], null, true)
.append([this.rte.i18n('Height'), $('<span />').append(this.src.height).append(' px')], null, true)
.append([this.rte.i18n('Border'), this.src.border], null, true)
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
? $('<div class="elrte-image-src-fm"><span class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-folder-open"/></span></div>')
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = $('<div />')
.append( $('<label />').append(this.src.popup.location).append(this.rte.i18n('Location bar')))
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/pasteformattext.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ elRTE.prototype.ui.prototype.buttons.pasteformattext = function(rte, name) {
title : this.rte.i18n('Paste formatted text')
}
},
d = new elDialogForm(opts);
d = new elDialogForm(opts, this.rte.getI18n());
d.append(this.iframe).open();
this.doc = this.iframe.get(0).contentWindow.document;
html = this.rte.options.doctype
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/pastetext.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ elRTE.prototype.ui.prototype.buttons.pastetext = function(rte, name) {
title : this.rte.i18n('Paste only text')
}
}
var d = new elDialogForm(opts);
var d = new elDialogForm(opts, this.rte.getI18n());
d.append(this.input).open();
}

Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/smiley.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ elRTE.prototype.ui.prototype.buttons.smiley = function(rte, name) {
buttons : {}
}
}
d = new elDialogForm(opts);
d = new elDialogForm(opts, this.rte.getI18n());
$.each(this.smileys, function(name, img) {
d.append($('<img src="'+url+img+'" title="'+name+'" id="'+name+'" class="el-rte-smiley"/>').click(function() { self.set(this.id, d); }));
});
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ elRTE.prototype.ui.prototype.buttons.table = function(rte, name) {
title : this.rte.i18n('Table')
}
}
var d = new elDialogForm(opts);
var d = new elDialogForm(opts, this.rte.getI18n());

for (var tab in this.src) {
d.tab(tab, this.rte.i18n(this.labels[tab]));
Expand Down
2 changes: 1 addition & 1 deletion src/elrte/js/ui/tbcellprops.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ elRTE.prototype.ui.prototype.buttons.tbcellprops = function(rte, name) {
title : this.rte.i18n('Table cell properties')
}
}
var d = new elDialogForm(opts);
var d = new elDialogForm(opts, this.rte.getI18n());
for (var tab in this.src) {
d.tab(tab, this.rte.i18n(this.labels[tab]));

Expand Down