From fdb0ca2cca69233415d948a2885de70903330739 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 8 Jan 2015 10:35:49 -0500 Subject: [PATCH] CRM-15789 - More consistent button classes and icons --- CRM/Core/Form.php | 36 ++++++------ .../plugins/function.crmGetAttribute.php | 10 +++- .../plugins/modifier.crmBtnValidate.php | 56 ------------------- css/civicrm.css | 5 -- templates/CRM/common/formButtons.tpl | 5 +- 5 files changed, 27 insertions(+), 85 deletions(-) delete mode 100644 CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index a155cc4447..8ccc7fda71 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -498,24 +498,19 @@ class CRM_Core_Form extends HTML_QuickForm_Page { public function addButtons($params) { $prevnext = $spacing = array(); foreach ($params as $button) { - $js = CRM_Utils_Array::value('js', $button); - $isDefault = CRM_Utils_Array::value('isDefault', $button, FALSE); - if ($isDefault) { - $attrs = array('class' => 'crm-form-submit default'); - } - else { - $attrs = array('class' => 'crm-form-submit'); - } + $attrs = array('class' => 'crm-form-submit') + (array) CRM_Utils_Array::value('js', $button); - if ($js) { - $attrs = array_merge($js, $attrs); + if (!empty($button['isDefault'])) { + $attrs['class'] .= ' default'; } - $defaultIcon = 'check'; - - if ($button['type'] === 'cancel') { + if (in_array($button['type'], array('upload', 'next', 'submit', 'done', 'process', 'refresh'))) { + $attrs['class'] .= ' validate'; + $defaultIcon = 'check'; + } + else { $attrs['class'] .= ' cancel'; - $defaultIcon = 'close'; + $defaultIcon = $button['type'] == 'back' ? 'triangle-1-w' : 'close'; } if ($button['type'] === 'reset') { @@ -526,19 +521,22 @@ class CRM_Core_Form extends HTML_QuickForm_Page { if ($button['subName'] == 'new') { $defaultIcon = 'plus'; } - $buttonName = $this->getButtonName($button['type'], $button['subName']); - } - else { - $buttonName = $this->getButtonName($button['type']); + if ($button['subName'] == 'done') { + $defaultIcon = 'circle-check'; + } + if ($button['subName'] == 'next') { + $defaultIcon = 'circle-triangle-e'; + } } if (in_array($button['type'], array('next', 'upload', 'done')) && $button['name'] === ts('Save')) { - $attrs = array_merge($attrs, (array('accesskey' => 'S'))); + $attrs['accesskey'] = 'S'; } $icon = CRM_Utils_Array::value('icon', $button, $defaultIcon); if ($icon) { $attrs['crm-icon'] = $icon; } + $buttonName = $this->getButtonName($button['type'], CRM_Utils_Array::value('subName', $button)); $prevnext[] = $this->createElement('submit', $buttonName, $button['name'], $attrs); } if (!empty($button['isDefault'])) { diff --git a/CRM/Core/Smarty/plugins/function.crmGetAttribute.php b/CRM/Core/Smarty/plugins/function.crmGetAttribute.php index 9fd1b74e32..e2db821a73 100644 --- a/CRM/Core/Smarty/plugins/function.crmGetAttribute.php +++ b/CRM/Core/Smarty/plugins/function.crmGetAttribute.php @@ -42,8 +42,14 @@ * @return string */ function smarty_function_crmGetAttribute($params, &$smarty) { + $ret = ''; if (preg_match('#\W' . $params['attr'] . '="([^"]+)#', $params['html'], $matches)) { - return $matches[1]; + $ret = $matches[1]; + } + if (!empty($params['assign'])) { + $smarty->assign($params['assign'], $ret); + } + else { + return $ret; } - return ''; } diff --git a/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php b/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php deleted file mode 100644 index 9d9c747c9f..0000000000 --- a/CRM/Core/Smarty/plugins/modifier.crmBtnValidate.php +++ /dev/null @@ -1,56 +0,0 @@ - {if $icon} {/if} - {$html|crmAddClass:$validate} + {$html} {/if} {/foreach} -- 2.25.1