From 9f8862e1b9971e0799de6fb7999aafc83ec1d0f4 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 8 Feb 2015 18:10:16 -0500 Subject: [PATCH] CRM-15789 - Improve disabled button handling ---------------------------------------- * CRM-15789: Add icons to submit buttons https://issues.civicrm.org/jira/browse/CRM-15789 --- css/civicrm.css | 7 +++++++ js/Common.js | 14 ++++++++++++++ templates/CRM/common/formButtons.tpl | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/css/civicrm.css b/css/civicrm.css index 8f74c0f516..bbc407c7e7 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -2283,6 +2283,9 @@ div.grippie { background-position: 0 -25px; } +.crm-container .crm-button-disabled, +.crm-container .crm-button.crm-button-disabled, +.crm-container .ui-dialog-buttonset .ui-button[disabled], .crm-container input.crm-form-submit[disabled], .crm-container input[type=button][disabled], .crm-container .crm-button[disabled] { @@ -2291,6 +2294,10 @@ div.grippie { background-position: top left; } +.crm-container .crm-button-disabled input[disabled] { + opacity: 1; +} + .crm-container .ui-dialog-buttonpane { background: linear-gradient(to bottom, #f2f2f2 0%,#ffffff 35%); } diff --git a/js/Common.js b/js/Common.js index 4d2ae26f9d..04d471e421 100644 --- a/js/Common.js +++ b/js/Common.js @@ -212,6 +212,20 @@ CRM.strings = CRM.strings || {}; return !!$(e.target).closest('.ui-dialog, .ui-datepicker, .select2-drop, .cke_dialog').length; }; + // Implements jQuery hook.prop + $.propHooks.disabled = { + set: function (el, value, name) { + // Sync button enabled status with wrapper css + if ($(el).is('span.crm-button > input.crm-form-submit')) { + $(el).parent().toggleClass('crm-button-disabled', !!value); + } + // Sync button enabled status with dialog button + if ($(el).is('.ui-dialog input.crm-form-submit')) { + $(el).closest('.ui-dialog').find('.ui-dialog-buttonset button[data-identifier='+ $(el).attr('name') +']').prop('disabled', !!value); + } + } + }; + /** * Populate a select list, overwriting the existing options except for the placeholder. * @param select jquery selector - 1 or more select elements diff --git a/templates/CRM/common/formButtons.tpl b/templates/CRM/common/formButtons.tpl index 526983dfd8..842db45868 100644 --- a/templates/CRM/common/formButtons.tpl +++ b/templates/CRM/common/formButtons.tpl @@ -36,7 +36,8 @@ {assign var='html' value=$form.buttons.$key.html} {/if} {crmGetAttribute html=$html attr='crm-icon' assign='icon'} - + {crmGetAttribute html=$html attr='disabled' assign='disabled'} + {if $icon} {/if} {$html} -- 2.25.1