From df88d10f1347680f3446d802a47f8044b872a11a Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 12 Feb 2017 15:35:27 +0100 Subject: [PATCH] simple_dialog() improvements --- program/js/app.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/program/js/app.js b/program/js/app.js index 9ac3279eb..bca2f2c7a 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -6676,18 +6676,12 @@ function rcube_webmail() this.qrcode = function() { var title = this.get_label('qrcode'), - buttons = [{ - text: this.get_label('close'), - 'class': 'mainaction', - click: function() { - (ref.is_framed() ? parent.$ : $)(this).dialog('destroy'); - } - }], + options = {button: false, cancel_button: 'close', width: 310, height: 410}, img = new Image(300, 300); img.src = this.url('addressbook/qrcode', {_source: this.env.source, _cid: this.env.cid}); - return this.show_popup_dialog(img, title, buttons, {width: 310, height: 410}); + return this.simple_dialog(img, title, null, options); }; @@ -7673,24 +7667,24 @@ function rcube_webmail() return popup; }; - // show_popup_dialog() wrapper for simple dialogs with Save and Cancel buttons - this.simple_dialog = function(content, title, button_func, options) + // show_popup_dialog() wrapper for simple dialogs with action and Cancel buttons + this.simple_dialog = function(content, title, action_func, options) { var title = this.get_label(title), + close_func = function() { (ref.is_framed() ? parent.$ : $)(this).dialog('close'); }, buttons = [{ + text: ref.get_label((options || {}).cancel_button || 'cancel'), + click: close_func + }]; + + if (!action_func) + buttons[0]['class'] = 'mainaction'; + else + buttons.unshift({ text: this.get_label((options || {}).button || 'save'), 'class': 'mainaction', - click: function(e) { - if (button_func(e)) - $(this).dialog('close'); - } - }, - { - text: ref.get_label('cancel'), - click: function() { - $(this).dialog('close'); - } - }]; + click: function(e) { if (action_func(e)) close_func(); } + }); return this.show_popup_dialog(content, title, buttons, options); };