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') {
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'])) {
* @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 '';
}
+++ /dev/null
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
- | |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
- +--------------------------------------------------------------------+
-*/
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
- */
-
-/**
- * Based on the QF id, give this button a class 'validate' or 'cancel' which will be used by jQuery.validate
- *
- * @param string $btnName
- *
- * @return string
- *
- * @see smarty_modifier_crmBtnType
- */
-function smarty_modifier_crmBtnValidate($btnName) {
- // split the string into 5 or more
- // button name are typically: '_qf_Contact_refresh' OR '_qf_Contact_refresh_dedupe'
- // button type is always the 3rd element
- // note the first _
- $substr = CRM_Utils_System::explode('_', $btnName, 5);
-
- if (in_array($substr[3], array('upload', 'next', 'submit', 'done', 'process', 'refresh'))) {
- return 'validate';
- }
- return 'cancel';
-}
margin-top: 30px;
}
-#crm-container.crm-public #crm-submit-buttons input#_qf_Main_upload-bottom {
- font-size: 1.5em;
- padding: 3px 10px;
-}
-
#crm-container.crm-public #premiums-listings {
margin-top: 10px;
min-width: 450px;
{else}
{assign var='html' value=$form.buttons.$key.html}
{/if}
- {capture assign=validate}{$key|crmBtnValidate}{/capture}
- {capture assign=icon}{crmGetAttribute html=$html attr='crm-icon'}{/capture}
+ {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}>
{if $icon}<span class="crm-button-icon ui-icon-{$icon}"> </span>{/if}
- {$html|crmAddClass:$validate}
+ {$html}
</span>
{/if}
{/foreach}