From 27f190b4fea075c7e9491debad76f31a444598e0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 27 Sep 2014 13:56:44 -0400 Subject: [PATCH] CRM.confirm - ensure that "no" goes on the right-hand side --- js/Common.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/js/Common.js b/js/Common.js index 2758eb91ba..3f7846a650 100644 --- a/js/Common.js +++ b/js/Common.js @@ -773,7 +773,7 @@ CRM.strings = CRM.strings || {}; * @see https://wiki.civicrm.org/confluence/display/CRMDOC/Notification+Reference */ CRM.confirm = function (options) { - var dialog, url, msg, settings = { + var dialog, url, msg, buttons = [], settings = { title: ts('Confirm'), message: ts('Are you sure you want to continue?'), url: null, @@ -791,13 +791,13 @@ CRM.strings = CRM.strings || {}; }; $.extend(settings, ($.isFunction(options) ? arguments[1] : options) || {}); if (!settings.buttons && $.isPlainObject(settings.options)) { - settings.buttons = []; - $.each(settings.options, function(key, label) { - settings.buttons.push({ + $.each(settings.options, function(op, label) { + buttons.push({ text: label, - icons: {primary: key === 'no' ? 'ui-icon-close' : 'ui-icon-check'}, + 'data-op': op, + icons: {primary: op === 'no' ? 'ui-icon-close' : 'ui-icon-check'}, click: function() { - var event = $.Event('crmConfirm:' + key); + var event = $.Event('crmConfirm:' + op); $(this).trigger(event); if (!event.isDefaultPrevented()) { dialog.dialog('close'); @@ -805,6 +805,8 @@ CRM.strings = CRM.strings || {}; } }); }); + // Order buttons so that "no" goes on the right-hand side + settings.buttons = _.sortBy(buttons, 'data-op').reverse(); } url = settings.url; msg = settings.message; -- 2.25.1