From 98da7d6747712e0bea2ccba00f5c13912293242c Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 6 Aug 2020 13:12:36 -0400 Subject: [PATCH] Put icons inside of button elements --- CRM/Admin/Form/Preferences/Display.php | 7 ++++++- CRM/Admin/Form/Setting/Smtp.php | 11 ++++++----- CRM/Core/Form.php | 7 ++----- CRM/Custom/Form/Option.php | 3 +-- templates/CRM/Admin/Form/Preferences/Display.tpl | 1 - templates/CRM/Admin/Page/APIExplorer.tpl | 4 +++- templates/CRM/common/formButtons.tpl | 6 ------ 7 files changed, 18 insertions(+), 21 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 41073eed62..c251b45020 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -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); diff --git a/CRM/Admin/Form/Setting/Smtp.php b/CRM/Admin/Form/Setting/Smtp.php index 1c6dc0d46a..79e0da4f77 100644 --- a/CRM/Admin/Form/Setting/Smtp.php +++ b/CRM/Admin/Form/Setting/Smtp.php @@ -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)) { diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 8a48473c01..610ea053c6 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -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']); diff --git a/CRM/Custom/Form/Option.php b/CRM/Custom/Form/Option.php index 054df62529..05f6dcd81e 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -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', ] ); } diff --git a/templates/CRM/Admin/Form/Preferences/Display.tpl b/templates/CRM/Admin/Form/Preferences/Display.tpl index e36cc9501f..6ee7378d31 100644 --- a/templates/CRM/Admin/Form/Preferences/Display.tpl +++ b/templates/CRM/Admin/Form/Preferences/Display.tpl @@ -162,7 +162,6 @@ {$form.editor_id.html}   - {$form.ckeditor_config.html} diff --git a/templates/CRM/Admin/Page/APIExplorer.tpl b/templates/CRM/Admin/Page/APIExplorer.tpl index 9c127fcb6f..98e6529ca1 100644 --- a/templates/CRM/Admin/Page/APIExplorer.tpl +++ b/templates/CRM/Admin/Page/APIExplorer.tpl @@ -286,7 +286,9 @@
- +
diff --git a/templates/CRM/common/formButtons.tpl b/templates/CRM/common/formButtons.tpl index 7af01e646b..0135fe30d1 100644 --- a/templates/CRM/common/formButtons.tpl +++ b/templates/CRM/common/formButtons.tpl @@ -38,14 +38,8 @@ {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}{/capture} - {/if} {crmGetAttribute html=$html attr='disabled' assign='disabled'} - {$iconDisp} {$html} {/if} -- 2.25.1