CRM-15789 - Improve disabled button handling
authorColeman Watts <coleman@civicrm.org>
Sun, 8 Feb 2015 23:10:16 +0000 (18:10 -0500)
committerColeman Watts <coleman@civicrm.org>
Sun, 8 Feb 2015 23:10:16 +0000 (18:10 -0500)
----------------------------------------
* CRM-15789: Add icons to submit buttons
  https://issues.civicrm.org/jira/browse/CRM-15789

css/civicrm.css
js/Common.js
templates/CRM/common/formButtons.tpl

index 8f74c0f516f7c9590b26e1873b03d376c18068ce..bbc407c7e72138cd86257ca088ec8dd0ff13bcb7 100644 (file)
@@ -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%);
 }
index 4d2ae26f9ddbcf591b580e23a5a23088d97f32af..04d471e42194673e133f0ee3f3b212b7233aed44 100644 (file)
@@ -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
index 526983dfd8332db2feae4dd14c0ddab0d8606461..842db45868495e59ebebd442f78363417839e53c 100644 (file)
@@ -36,7 +36,8 @@
           {assign var='html' value=$form.buttons.$key.html}
         {/if}
         {crmGetAttribute html=$html attr='crm-icon' assign='icon'}
-        <span class="crm-button crm-button-type-{$key|crmBtnType} crm-button{$key}{if $icon} crm-icon-button{/if}"{if $buttonStyle} style="{$buttonStyle}"{/if}>
+        {crmGetAttribute html=$html attr='disabled' assign='disabled'}
+        <span class="crm-button crm-button-type-{$key|crmBtnType} crm-button{$key}{if $icon} crm-icon-button{/if}{if $disabled} crm-button-disabled{/if}"{if $buttonStyle} style="{$buttonStyle}"{/if}>
           {if $icon}<span class="crm-button-icon ui-icon-{$icon}"> </span>{/if}
           {$html}
         </span>