*
*/
public function addButtons($params) {
- $prevnext = array();
- $spacing = array();
+ $prevnext = $spacing = array();
foreach ($params as $button) {
$js = CRM_Utils_Array::value('js', $button);
$isDefault = CRM_Utils_Array::value('isDefault', $button, FALSE);
$attrs = array_merge($js, $attrs);
}
+ $defaultIcon = 'check';
+
if ($button['type'] === 'cancel') {
$attrs['class'] .= ' cancel';
+ $defaultIcon = 'close';
}
if ($button['type'] === 'reset') {
}
else {
if (!empty($button['subName'])) {
+ if ($button['subName'] == 'new') {
+ $defaultIcon = 'plus';
+ }
$buttonName = $this->getButtonName($button['type'], $button['subName']);
}
else {
if (in_array($button['type'], array('next', 'upload', 'done')) && $button['name'] === ts('Save')) {
$attrs = array_merge($attrs, (array('accesskey' => 'S')));
}
+ $icon = CRM_Utils_Array::value('icon', $button, $defaultIcon);
+ if ($icon) {
+ $attrs['crm-icon'] = $icon;
+ }
$prevnext[] = $this->createElement('submit', $buttonName, $button['name'], $attrs);
}
if (!empty($button['isDefault'])) {
*/
/**
- * Add a stylesheet <LINK> to a specific part of the page
+ * Formats an array of attributes as html
*
* @param array $params
* ['a'] array of attributes.
* @param CRM_Core_Smarty $smarty
*
+ * @return string
* @throws Exception
*/
function smarty_function_crmAttributes($params, &$smarty) {
--- /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
+ * $Id$
+ *
+ */
+
+/**
+ * Fetch an attribute from html
+ *
+ * @param array $params
+ * @param CRM_Core_Smarty $smarty
+ *
+ * @return string
+ */
+function smarty_function_crmGetAttribute($params, &$smarty) {
+ if (preg_match('#\W' . $params['attr'] . '="([^"]+)#', $params['html'], $matches)) {
+ return $matches[1];
+ }
+ return '';
+}
margin-left: .5em;
}
-.crm-container .crm-button,
-#crm-container .crm-button {
+.crm-container .crm-button {
border: medium none;
cursor: pointer;
display: block;
overflow: hidden;
text-shadow: 0 1px 0 black;
margin: 0px 12px 0 0;
- padding: 0px 4px;
- cursor: pointer;
}
-.crm-container .crm-button input,
-#crm-container .crm-button input {
+.crm-container .crm-button input {
background: none;
_background: #6C6C6C;
/* IE6 only */
}
.crm-container .crm-button-type-cancel,
-.crm-container .crm-button-type-back,
-#crm-container .crm-button-type-cancel,
-#crm-container .crm-button-type-back {
+.crm-container .crm-button-type-back {
margin-left: 20px;
}
-.crm-container .crm-button-type-cancel input,
-#crm-container .crm-button-type-cancel input {
+.crm-container .crm-button-type-cancel input {
color: #E6E6DC!important;
}
.crm-container input.crm-form-submit,
.crm-container .crm-button,
.crm-container .ui-dialog-buttonset .ui-button,
-#crm-container input[type=button],
-#crm-container input.crm-form-submit-inline,
-#crm-container .crm-button {
+.crm-container input[type=button],
+.crm-container input.crm-form-submit-inline,
+.crm-container .crm-button {
text-shadow: 0 1px 0 black;
background: #70716B url(../i/crm-button-bg.gif) repeat-x top left;
color: #FFF;
}
.crm-container input.crm-form-submit[disabled],
-.crm-container .crm-button[disabled],
-#crm-container input[type=button][disabled],
-#crm-container input.crm-form-submit-inline[disabled],
-#crm-container .crm-button[disabled] {
+.crm-container input[type=button][disabled],
+.crm-container input.crm-form-submit-inline[disabled],
+.crm-container .crm-button[disabled] {
color: #999;
}
-.crm-container .crm-button,
-#crm-container .crm-button {
+.crm-container .crm-button {
padding: 1px;
}
.crm-container input.crm-form-submit,
-#crm-container input[type=button],
-#crm-container input.crm-form-submit-inline {
+.crm-container input[type=button],
+.crm-container input.crm-form-submit-inline {
padding: 2px 6px;
}
.crm-container .crm-button input[type=button],
.crm-container .crm-button input.crm-form-submit,
-.crm-container .crm-button input.crm-form-submit-inline,
-#crm-container .crm-button input[type=button],
-#crm-container .crm-button input.crm-form-submit,
-#crm-container .crm-button input.crm-form-submit-inline {
+.crm-container .crm-button input.crm-form-submit-inline {
padding: 2px 4px;
margin: 0px;
background: none;
margin-top: 3px;
}
+.crm-container input.crm-button.crm-icon-button {
+ position: relative;
+}
+
+.crm-container .crm-button.crm-icon-button input {
+ padding-left: 18px;
+}
+
+.crm-container .crm-button-icon {
+ background-image: url("../i/icons/jquery-ui-FFFFFF.png");
+ height: 16px;
+ width: 16px;
+ display: block;
+ position: absolute;
+ pointer-events: none;
+}
+
.crm-container .dark-icon {
background-image: url("../packages/jquery/jquery-ui/images/ui-icons_222222_256x240.png")
}
if ($icon.length) {
button.icons = {primary: $icon.attr('class')};
} else {
- var action = $el.hasClass('cancel') ? 'close' : (identifier.substr(identifier.length-4) === '_new' ? 'plus' : 'check');
+ var action = $el.attr('crm-icon') || ($el.hasClass('cancel') ? 'close' : 'check');
button.icons = {primary: 'ui-icon-' + action};
}
buttons.push(button);
{assign var='html' value=$form.buttons.$key.html}
{/if}
{capture assign=validate}{$key|crmBtnValidate}{/capture}
- <span class="crm-button crm-button-type-{$key|crmBtnType} crm-button{$key}"{if $buttonStyle} style="{$buttonStyle}"{/if}>{$html|crmAddClass:$validate}</span>
+ {capture assign=icon}{crmGetAttribute html=$html attr='crm-icon'}{/capture}
+ <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}
+ </span>
{/if}
{/foreach}
{/crmRegion}