From d34e9db0ee28b895d26ad96ff70c65ae288567b2 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 5 Sep 2014 20:59:12 -0400 Subject: [PATCH] CRM-13863 - Tweak popup button icons and fix enter-to-submit --- js/crm.ajax.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/js/crm.ajax.js b/js/crm.ajax.js index 31eed91b2d..92fa70283e 100644 --- a/js/crm.ajax.js +++ b/js/crm.ajax.js @@ -452,27 +452,29 @@ } // Show form buttons as part of the dialog if ($el.data('uiDialog')) { - var buttons = [], added = []; - $('input.crm-form-submit, a.button', $el).each(function() { + var buttonContainers = '.crm-submit-buttons, .action-link', + buttons = [], + added = []; + $(buttonContainers, $el).find('input.crm-form-submit, a.button').each(function() { var $el = $(this), label = $el.is('input') ? $el.attr('value') : $el.text(), identifier = $el.attr('name') || $el.attr('href'); if (!identifier || identifier === '#' || $.inArray(identifier, added) < 0) { - var button = {text: label, click: function () { - $el.click(); - }}; - if ($el.find('.icon').length) { - button.icons = {primary: $el.find('.icon').attr('class')}; + var $icon = $el.find('.icon'), + button = {text: label, click: function() { + $el.click(); + }}; + if ($icon.length) { + button.icons = {primary: $icon.attr('class')}; } else { - button.icons = {primary: $el.hasClass('cancel') ? 'ui-icon-close' : 'ui-icon-check'}; - if (identifier.substr(identifier.length-4) === '_new') { - button.icons.secondary = 'ui-icon-plus'; - } + var action = $el.hasClass('cancel') ? 'close' : (identifier.substr(identifier.length-4) === '_new' ? 'plus' : 'check'); + button.icons = {primary: 'ui-icon-' + action}; } buttons.push(button); added.push(identifier); } - $el.hide().parents('.crm-button, .crm-submit-buttons, .action-link').hide(); + // display:none causes the form to not submit when pressing "enter" + $el.parents(buttonContainers).css({height: 0, padding: 0, margin: 0, overflow: 'hidden'}); }); $el.dialog('option', 'buttons', buttons); } -- 2.25.1