Put icons inside of button elements
authorAndrew Hunt <andrew@aghstrategies.com>
Thu, 6 Aug 2020 17:12:36 +0000 (13:12 -0400)
committerAndrew Hunt <andrew@aghstrategies.com>
Tue, 8 Sep 2020 19:38:56 +0000 (15:38 -0400)
CRM/Admin/Form/Preferences/Display.php
CRM/Admin/Form/Setting/Smtp.php
CRM/Core/Form.php
CRM/Custom/Form/Option.php
templates/CRM/Admin/Form/Preferences/Display.tpl
templates/CRM/Admin/Page/APIExplorer.tpl
templates/CRM/common/formButtons.tpl

index 41073eed625e50e5358bab6f69d111a14b482303..c251b4502035f1f47548fcd85011608cf010667b 100644 (file)
@@ -50,7 +50,12 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
     $this->assign('invoicing', CRM_Invoicing_Utils::isInvoicingEnabled());
 
-    $this->addElement('xbutton', 'ckeditor_config', ts('Configure CKEditor'), ['type' => 'submit']);
+    $this->addElement(
+      'xbutton',
+      'ckeditor_config',
+      CRM_Core_Page::crmIcon('fa-wrench') . ' ' . ts('Configure CKEditor'),
+      ['type' => 'submit']
+    );
 
     $editOptions = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 0');
     $this->assign('editOptions', $editOptions);
index 1c6dc0d46aa8de6f2eb1a6d0b595073e15639fb7..79e0da4f7782a131935ad6b8b2a2f77bdeb49738 100644 (file)
@@ -61,11 +61,12 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting {
     $this->addFormRule(['CRM_Admin_Form_Setting_Smtp', 'formRule']);
     parent::buildQuickForm();
     $buttons = $this->getElement('buttons')->getElements();
-    $attrs = [
-      'type' => 'submit',
-      'crm-icon' => 'fa-envelope-o',
-    ];
-    $buttons[] = $this->createElement('xbutton', $this->_testButtonName, ts('Save & Send Test Email'), $attrs);
+    $buttons[] = $this->createElement(
+      'xbutton',
+      $this->_testButtonName,
+      CRM_Core_Page::crmIcon('fa-envelope-o') . ' ' . ts('Save & Send Test Email'),
+      ['type' => 'submit']
+    );
     $this->getElement('buttons')->setElements($buttons);
 
     if (!empty($setStatus)) {
index 8a48473c019a228343c1dedd53c1a88229840169..610ea053c6321be480cd96b56646bd71aa92598d 100644 (file)
@@ -705,13 +705,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
         if (in_array($button['type'], ['next', 'upload', 'done']) && $button['name'] === ts('Save')) {
           $attrs['accesskey'] = 'S';
         }
-        $icon = CRM_Utils_Array::value('icon', $button, $defaultIcon);
-        if ($icon) {
-          $attrs['crm-icon'] = $icon;
-        }
+        $buttonContents = CRM_Core_Page::crmIcon($button['icon'] ?? $defaultIcon) . ' ' . $button['name'];
         $buttonName = $this->getButtonName($button['type'], CRM_Utils_Array::value('subName', $button));
         $attrs['type'] = 'submit';
-        $prevnext[] = $this->createElement('xbutton', $buttonName, $button['name'], $attrs);
+        $prevnext[] = $this->createElement('xbutton', $buttonName, $buttonContents, $attrs);
       }
       if (!empty($button['isDefault'])) {
         $this->setDefaultAction($button['type']);
index 054df625296202055000a16297c7ef8d72373ad8..05f6dcd81e72784dffd4ce024dbd224208efef91 100644 (file)
@@ -203,12 +203,11 @@ class CRM_Custom_Form_Option extends CRM_Core_Form {
         );
         $this->addElement('xbutton',
           'done',
-          ts('Done'),
+          CRM_Core_Page::crmIcon('fa-times') . ' ' . ts('Done'),
           [
             'type' => 'button',
             'onclick' => "location.href='$url'",
             'class' => 'crm-form-submit cancel',
-            'crm-icon' => 'fa-times',
           ]
         );
       }
index e36cc9501fd1196c88a062c4a8ed3f6112ea1dad..6ee7378d315fac994eb5dfa4f3603fc9ad4cc61d 100644 (file)
         {$form.editor_id.html}
         &nbsp;
         <span class="crm-button" style="display:inline-block;vertical-align:middle;float:none!important;">
-          <i class="crm-i fa-wrench" aria-hidden="true"></i>
           {$form.ckeditor_config.html}
         </span>
       </td>
index 9c127fcb6fca890238e62db6f5eae51953bad866..98e6529ca16c4aee1483cfc90c7f6d9db9ad049d 100644 (file)
       </div>
       <div class="crm-submit-buttons">
         <span class="crm-button">
-          <i class="crm-i fa-bolt" aria-hidden="true"></i> <input type="submit" value="{ts}Execute{/ts}" class="crm-form-submit" accesskey="S" title="{ts}Execute API call and display results{/ts}"/>
+          <button type="submit" class="crm-form-submit" accesskey="S" title="{ts}Execute API call and display results{/ts}">
+            <i class="crm-i fa-bolt" aria-hidden="true"></i> {ts}Execute{/ts}
+          </button>
         </span>
       </div>
 
index 7af01e646bec483f29db5b938c76eeeea01635b1..0135fe30d104a8ad3c65a614d55fc605e6c8a3b5 100644 (file)
     {else}
       {assign var='html' value=$form.buttons.$key.html}
     {/if}
-    {crmGetAttribute html=$html attr='crm-icon' assign='icon'}
-    {capture assign=iconPrefix}{$icon|truncate:3:"":true}{/capture}
-    {if $icon && $iconPrefix eq 'fa-'}
-      {capture assign=iconDisp}<i class="crm-i {$icon}" aria-hidden="true"></i>{/capture}
-    {/if}
     {crmGetAttribute html=$html attr='disabled' assign='disabled'}
     <span class="crm-button crm-button-type-{$key|crmBtnType} crm-button{$key}{if $disabled} crm-button-disabled{/if}"{if $buttonStyle} style="{$buttonStyle}"{/if}>
-      {$iconDisp}
       {$html}
     </span>
   {/if}