From 934605fa5c1c6b4c55ad3d1f506cdb36f183a1d8 Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Wed, 5 Mar 2014 13:07:41 +0100 Subject: [PATCH 1/9] add delte-confirm icon svg --- .../resource/img/icon/delete-confirm.svg | 22 +++++++++++ layout/default/resource/img/icon/delete.svg | 38 ++++++++++--------- 2 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 layout/default/resource/img/icon/delete-confirm.svg diff --git a/layout/default/resource/img/icon/delete-confirm.svg b/layout/default/resource/img/icon/delete-confirm.svg new file mode 100644 index 000000000..6ab244103 --- /dev/null +++ b/layout/default/resource/img/icon/delete-confirm.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + diff --git a/layout/default/resource/img/icon/delete.svg b/layout/default/resource/img/icon/delete.svg index 259e58449..c9fa5010c 100644 --- a/layout/default/resource/img/icon/delete.svg +++ b/layout/default/resource/img/icon/delete.svg @@ -1,17 +1,21 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + From 89ef564fc154e70850339d641f764f0a838fd4ec Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Wed, 5 Mar 2014 13:34:03 +0100 Subject: [PATCH 2/9] remove Tooltip from clickConfirm --- .../jquery.clickDecorators/decorators/20-confirmed.js | 8 +------- .../decorators/20-confirmed.less | 11 +++++++++++ library/CM/App.js | 5 ----- 3 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.less diff --git a/client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.js b/client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.js index 9080bbc04..7c2d1c0d7 100644 --- a/client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.js +++ b/client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.js @@ -4,20 +4,14 @@ (function($) { $.clickDecorators.confirmed = { - settings: { - message: 'Please Confirm' - }, - before: function(event) { var $this = $(this); var activateButton = function() { $this.addClass('confirmClick'); - $this.attr('title', $.clickDecorators.confirmed.settings.message).tooltip({trigger: 'manual'}).tooltip('show'); var deactivateButton = function() { $this.removeClass('confirmClick'); - $this.removeAttr('title').tooltip('hide'); $this.removeData('clickConfirmed.deactivate'); clearTimeout(deactivateTimeout); $(document).off('click.clickConfirmed', documentClickHandler); @@ -27,7 +21,7 @@ var deactivateTimeout = setTimeout(function() { deactivateButton(); - }, 5000); + }, 3000); var documentClickHandler = function(e) { if (!$this.length || e.target !== $this[0] && !$.contains($this[0], e.target)) { diff --git a/client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.less b/client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.less new file mode 100644 index 000000000..1525f24d9 --- /dev/null +++ b/client-vendor/after-body/jquery.clickDecorators/decorators/20-confirmed.less @@ -0,0 +1,11 @@ +[data-click-confirmed]:not(.confirmClick) { + .confirmClick-state-active { + display: none; + } +} + +[data-click-confirmed].confirmClick { + .confirmClick-state-inactive { + display: none; + } +} diff --git a/library/CM/App.js b/library/CM/App.js index 6390f3cfd..0f1d8cd45 100644 --- a/library/CM/App.js +++ b/library/CM/App.js @@ -16,7 +16,6 @@ var CM_App = CM_Class_Abstract.extend({ this.dom.ready(); this.window.ready(); this.date.ready(); - this.ui.ready(); this.template.ready(); this.router.ready(); }, @@ -463,10 +462,6 @@ var CM_App = CM_Class_Abstract.extend({ }, ui: { - ready: function() { - $.clickDecorators.confirmed.settings.message = cm.language.get('Please Confirm'); - }, - /** * @param {String} question * @param {Function} callback From 1c98de96587056ff91578682775ee436f5ffad74 Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Wed, 5 Mar 2014 15:22:57 +0100 Subject: [PATCH 3/9] add iconConfirm option to button functions --- library/CM/SmartyPlugins/function.button.php | 12 +++++++++++- library/CM/SmartyPlugins/function.button_link.php | 13 ++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/library/CM/SmartyPlugins/function.button.php b/library/CM/SmartyPlugins/function.button.php index 34ad754e7..e9e267131 100644 --- a/library/CM/SmartyPlugins/function.button.php +++ b/library/CM/SmartyPlugins/function.button.php @@ -29,8 +29,13 @@ function smarty_function_button(array $params, Smarty_Internal_Template $templat } $icon = null; + $iconConfirm = null; if (isset($params['icon'])) { $icon = $params['icon']; + + if (isset($params['iconConfirm'])) { + $iconConfirm = $params['iconConfirm']; + } } $label = ''; @@ -62,7 +67,12 @@ function smarty_function_button(array $params, Smarty_Internal_Template $templat } $html .= '>'; if ($icon) { - $html .= ''; + if ($iconConfirm) { + $html .= '' + . ''; + } else { + $html .= ''; + } } if ($label) { $html .= '' . CM_Util::htmlspecialchars($label) . ''; diff --git a/library/CM/SmartyPlugins/function.button_link.php b/library/CM/SmartyPlugins/function.button_link.php index 2d67542a4..e196cd4a0 100644 --- a/library/CM/SmartyPlugins/function.button_link.php +++ b/library/CM/SmartyPlugins/function.button_link.php @@ -10,10 +10,16 @@ function smarty_function_button_link(array $params, Smarty_Internal_Template $te $attrs = ''; $icon = null; + $iconConfirm = null; if (isset($params['icon'])) { $icon = $params['icon']; + + if (isset($params['iconConfirm'])) { + $iconConfirm = $params['iconConfirm']; + } } unset($params['icon']); + unset($params['iconConfirm']); $iconPosition = 'left'; if (!empty($params['iconPosition']) && $params['iconPosition'] == 'right') { @@ -47,7 +53,12 @@ function smarty_function_button_link(array $params, Smarty_Internal_Template $te $iconMarkup = ''; if ($icon) { - $iconMarkup = ''; + if ($iconConfirm) { + $iconMarkup = '' + . ''; + } else { + $iconMarkup = ''; + } if ($iconPosition == 'right') { $class .= ' hasIconRight'; From 8074d360a594e2e443cc290f43e797a6d2a0c8d3 Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Wed, 5 Mar 2014 15:24:16 +0100 Subject: [PATCH 4/9] add prefix-free animation mixin --- layout/default/css/mixins.less | 1 + 1 file changed, 1 insertion(+) diff --git a/layout/default/css/mixins.less b/layout/default/css/mixins.less index fd86d8124..654d5c957 100644 --- a/layout/default/css/mixins.less +++ b/layout/default/css/mixins.less @@ -161,6 +161,7 @@ -webkit-animation: @name @duration @timing-function @delay @iteration-count @direction @fill-mode; -moz-animation: @name @duration @timing-function @delay @iteration-count @direction @fill-mode; -ms-animation: @name @duration @timing-function @delay @iteration-count @direction @fill-mode; + animation: @name @duration @timing-function @delay @iteration-count @direction @fill-mode; } .background-size(@value) { From 84664a6e796028929e4681a707f7067a78cbcddf Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Wed, 5 Mar 2014 16:43:18 +0100 Subject: [PATCH 5/9] add animation to clickConfirm button --- layout/default/css/animation.less | 27 +++++++++++++++++---------- layout/default/css/form.less | 1 + 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/layout/default/css/animation.less b/layout/default/css/animation.less index 17d154085..b51f1581a 100644 --- a/layout/default/css/animation.less +++ b/layout/default/css/animation.less @@ -1,13 +1,20 @@ @keyframes highlightErrorField { - 40% { outline-color: @colorError; } + 0% { outline-color: transparent; } + 40% { outline-color: @colorError; background-color: lighten(@colorError, 57); } + 100% { outline-color: transparent; } } -@-webkit-keyframes highlightErrorField { - 40% { outline-color: @colorError; - background-color: lighten(@colorError, 57);} -} -@-moz-keyframes highlightErrorField { - 40% { outline-color: @colorError; } -} -@-ms-keyframes highlightErrorField { - 40% { outline-color: @colorError; } + +@keyframes clickConfirm { + 0% { .transform(scale(1)); } + 4% { .transform(scale(1.3)); } + 7% { .transform(scale(1)); } + 45% { .transform(scale(.95)); } + 50% { .transform(scale(1)); opacity: 1; } + 60% { .transform(scale(.95)); opacity: .5; } + 70% { .transform(scale(1)); opacity: 1; } + 80% { .transform(scale(.95)); opacity: 0.5; } + 90% { .transform(scale(1)); opacity: 1; } + 91% { .transform(scale(1.05)); } + 94% { .transform(scale(.7)); opacity: 1; } + 100% { .transform(scale(1.4)); opacity: .1; } } diff --git a/layout/default/css/form.less b/layout/default/css/form.less index aa9c04f9d..4534afe0d 100644 --- a/layout/default/css/form.less +++ b/layout/default/css/form.less @@ -105,6 +105,7 @@ textarea.textinput { .button.confirmClick { .button-success; + .animation(clickConfirm, 3000ms, ease-out, 0, 1); } .button.confirmClick.warning { From b7926eb52a7fb73acba825e1811a895909855126 Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Wed, 5 Mar 2014 16:46:29 +0100 Subject: [PATCH 6/9] add delete-confirm to example --- layout/default/Component/Example/tabs/buttons.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layout/default/Component/Example/tabs/buttons.tpl b/layout/default/Component/Example/tabs/buttons.tpl index 3f8c9f0bc..d2fa332d1 100644 --- a/layout/default/Component/Example/tabs/buttons.tpl +++ b/layout/default/Component/Example/tabs/buttons.tpl @@ -16,4 +16,4 @@

Confirmation

{button_link class="confirmAction" label="With Confirmation" data=['click-confirmed' => true]} -{button_link class="confirmAction warning" label="With Warning" data=['click-confirmed' => true]} +{button_link icon='delete' iconConfirm='delete-confirm' class="confirmAction warning" label="With Warning" data=['click-confirmed' => true]} From eb4ac2abfca6aff8a763ad76e284adce5c38859d Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Wed, 5 Mar 2014 16:50:11 +0100 Subject: [PATCH 7/9] delete "Please Confirm" language key --- resources/db/setup.php | 1 - resources/db/update/25.php | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 resources/db/update/25.php diff --git a/resources/db/setup.php b/resources/db/setup.php index d961339b4..e2240e59c 100644 --- a/resources/db/setup.php +++ b/resources/db/setup.php @@ -6,7 +6,6 @@ $english->setTranslation('Close', 'Close'); $english->setTranslation('{$label} is required.', '{$label} is required.', array('label')); $english->setTranslation('Required', 'Required'); -$english->setTranslation('Please Confirm', 'Please Confirm'); $english->setTranslation('Confirmation', 'Confirmation'); $english->setTranslation('.date.month.1', 'January'); $english->setTranslation('.date.month.2', 'February'); diff --git a/resources/db/update/25.php b/resources/db/update/25.php new file mode 100644 index 000000000..8eed5bbf9 --- /dev/null +++ b/resources/db/update/25.php @@ -0,0 +1,3 @@ + Date: Fri, 7 Mar 2014 12:02:04 +0100 Subject: [PATCH 8/9] apply code styles --- layout/default/css/form.less | 497 ++++++++++++++++++----------------- 1 file changed, 249 insertions(+), 248 deletions(-) diff --git a/layout/default/css/form.less b/layout/default/css/form.less index 4534afe0d..a51ad90d1 100644 --- a/layout/default/css/form.less +++ b/layout/default/css/form.less @@ -1,324 +1,325 @@ .textinput { - .appearance(none); - width: 100%; - height: @heightInputText; - overflow: hidden; - padding-left: 6px; - padding-right: 6px; - border-radius: 0; - background: @colorBg; - border: 1px solid @colorFgBorderEmphasize2; - .transition(.1s); - - &:hover { - border-left: 1px solid lighten(@colorNotice, 15); - } + .appearance(none); + width: 100%; + height: @heightInputText; + overflow: hidden; + padding-left: 6px; + padding-right: 6px; + border-radius: 0; + background: @colorBg; + border: 1px solid @colorFgBorderEmphasize2; + .transition(.1s); + + &:hover { + border-left: 1px solid lighten(@colorNotice, 15); + } } textarea.textinput { - height: @heightInputTextarea; - padding-top: 6px; - overflow: auto; - resize: vertical; + height: @heightInputTextarea; + padding-top: 6px; + overflow: auto; + resize: vertical; } .input_focus { - outline: none; - border: 1px solid lighten(@colorNotice, 15); + outline: none; + border: 1px solid lighten(@colorNotice, 15); } .placeholder(@color) { - ::-webkit-input-placeholder { - color: @color; - } - :-moz-placeholder { // < FF 19 - color: @color; - } - ::-moz-placeholder { - color: @color; - } - :-ms-input-placeholder { - color: @color; - } - label.placeholder { - color: @color; - margin-top: 7px; - - .CM_FormField_Textarea & { - margin-top: 1px; - } - } + ::-webkit-input-placeholder { + color: @color; + } + :-moz-placeholder { + // < FF 19 + color: @color; + } + ::-moz-placeholder { + color: @color; + } + :-ms-input-placeholder { + color: @color; + } + label.placeholder { + color: @color; + margin-top: 7px; + + .CM_FormField_Textarea & { + margin-top: 1px; + } + } } .placeholder(lighten(@colorFgSubtle, 10)); .button { - width: auto; - height: @sizeButton; - line-height: @sizeButton - 2px; - min-width: @sizeButton; - max-width: 100%; - padding: 0 8px; - overflow: hidden; - margin: 1px; - font-weight: bold; - cursor: pointer; - vertical-align: top; - white-space: nowrap; - border-radius: 0; - background-size: auto 200%; - background-position: 0 0; - .transition(background-position 200ms); - - &:not(:disabled):active { - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - } - - &:not(:disabled):hover { - background-position: 0 100%; - } - - &:focus { - .input_focus; - } - - &:disabled { - opacity: .5; - } - - &.hasIcon { - padding: 0; - - &.hasLabel { - padding: 0 8px; - - .icon { - margin-right: 5px; - } - } - } - - &.hasIconRight.hasLabel .icon { - margin-left: 5px; - } + width: auto; + height: @sizeButton; + line-height: @sizeButton - 2px; + min-width: @sizeButton; + max-width: 100%; + padding: 0 8px; + overflow: hidden; + margin: 1px; + font-weight: bold; + cursor: pointer; + vertical-align: top; + white-space: nowrap; + border-radius: 0; + background-size: auto 200%; + background-position: 0 0; + .transition(background-position 200ms); + + &:not(:disabled):active { + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); + } + + &:not(:disabled):hover { + background-position: 0 100%; + } + + &:focus { + .input_focus; + } + + &:disabled { + opacity: .5; + } + + &.hasIcon { + padding: 0; + + &.hasLabel { + padding: 0 8px; + + .icon { + margin-right: 5px; + } + } + } + + &.hasIconRight.hasLabel .icon { + margin-left: 5px; + } } .button.confirmClick { - .button-success; + .button-success; .animation(clickConfirm, 3000ms, ease-out, 0, 1); } .button.confirmClick.warning { - .button-danger; + .button-danger; } .button-default-active { - background: darken(@colorBg, 8); + background: darken(@colorBg, 8); } .button-default { - .gradient(vertical, @colorBg, darken(@colorBg, 10)); - border: 1px solid @colorFgBorderEmphasize3; - color: lighten(@colorFg, 25); - text-shadow: 1px 1px fadeout(@colorFgTheme, 80); - - &:not(:disabled):active { - border-color: darken(@colorFgBorderEmphasize3, 5); - } + .gradient(vertical, @colorBg, darken(@colorBg, 10)); + border: 1px solid @colorFgBorderEmphasize3; + color: lighten(@colorFg, 25); + text-shadow: 1px 1px fadeout(@colorFgTheme, 80); + + &:not(:disabled):active { + border-color: darken(@colorFgBorderEmphasize3, 5); + } } .button-transparent { - background: none; - border: 1px solid transparent; + background: none; + border: 1px solid transparent; } .button-highlight { - .gradient(vertical, @colorHighlight, spin(@colorHighlight, -6)); - border: 1px solid spin(@colorHighlight, -3); - color: @colorFgTheme; - text-shadow: 1px 1px spin(@colorHighlight, -8); - - &:not(:disabled):active { - border-color: spin(@colorHighlight, -15); - } + .gradient(vertical, @colorHighlight, spin(@colorHighlight, -6)); + border: 1px solid spin(@colorHighlight, -3); + color: @colorFgTheme; + text-shadow: 1px 1px spin(@colorHighlight, -8); + + &:not(:disabled):active { + border-color: spin(@colorHighlight, -15); + } } .button-success { - .gradient(vertical, lighten(@colorOk, 9), lighten(@colorOk, 3)); - border: 1px solid lighten(@colorOk, 3); - color: @colorFgTheme; - text-shadow: 1px 1px spin(@colorOk, -8); - - &:not(:disabled):active { - border-color: darken(@colorOk, 6); - } + .gradient(vertical, lighten(@colorOk, 9), lighten(@colorOk, 3)); + border: 1px solid lighten(@colorOk, 3); + color: @colorFgTheme; + text-shadow: 1px 1px spin(@colorOk, -8); + + &:not(:disabled):active { + border-color: darken(@colorOk, 6); + } } .button-danger { - .gradient(vertical, lighten(@colorError, 10), @colorError); - border: 1px solid @colorError; - color: @colorFgTheme; - text-shadow: 1px 1px @colorError; - - &:not(:disabled):active { - border-color: darken(@colorError, 12); - } + .gradient(vertical, lighten(@colorError, 10), @colorError); + border: 1px solid @colorError; + color: @colorFgTheme; + text-shadow: 1px 1px @colorError; + + &:not(:disabled):active { + border-color: darken(@colorError, 12); + } } .button-large { - height: 1.5*@sizeButton; - min-width: 1.5*@sizeButton; - font-size: 2em; - border-radius: 3px; - padding: 0 15px; - - &.hasIcon.hasLabel { - padding: 0 20px 0 10px; - - .icon { - margin-right: 10px; - font-size: 1em; - } - } + height: 1.5*@sizeButton; + min-width: 1.5*@sizeButton; + font-size: 2em; + border-radius: 3px; + padding: 0 15px; + + &.hasIcon.hasLabel { + padding: 0 20px 0 10px; + + .icon { + margin-right: 10px; + font-size: 1em; + } + } } label { - //Fix for fastclick - > * { - pointer-events: none; - } + //Fix for fastclick + > * { + pointer-events: none; + } } input:disabled { - opacity: .5; + opacity: .5; } input:focus, .textinput:focus, .textinput.focus, select:focus, textarea:focus { - .input_focus; + .input_focus; } input[type=checkbox], input[type=radio] { - position: absolute; - opacity: 0; - - + label { - position: relative; - cursor: pointer; - margin-left: @sizeCheckbox+4px; - - &:before { - position: absolute; - content: ""; - display: block; - width: @sizeCheckbox; - height: @sizeCheckbox; - background-color: @colorBgEmphasize1; - top: 50%; - left: -(@sizeCheckbox+4px); - margin-top: -@sizeCheckbox/2; - border: 1px solid @colorFgBorderEmphasize3; - } - } - - &:hover, &:focus { - &:not(:disabled) + label:before { - .input_focus; - } - } - - &:checked + label:before { - background-color: lighten(@colorNotice, 15); - border-color: lighten(@colorNotice, 15); - } - - &:disabled + label { - opacity: .5; - } + position: absolute; + opacity: 0; + + + label { + position: relative; + cursor: pointer; + margin-left: @sizeCheckbox+4px; + + &:before { + position: absolute; + content: ""; + display: block; + width: @sizeCheckbox; + height: @sizeCheckbox; + background-color: @colorBgEmphasize1; + top: 50%; + left: -(@sizeCheckbox+4px); + margin-top: -@sizeCheckbox/2; + border: 1px solid @colorFgBorderEmphasize3; + } + } + + &:hover, &:focus { + &:not(:disabled) + label:before { + .input_focus; + } + } + + &:checked + label:before { + background-color: lighten(@colorNotice, 15); + border-color: lighten(@colorNotice, 15); + } + + &:disabled + label { + opacity: .5; + } } input[type=radio] { - &:checked + label:before { - box-shadow: inset 0 0 0 .2em @colorBgEmphasize1; - } - - + label { - &:before { - border-radius: 50%; - } - } + &:checked + label:before { + box-shadow: inset 0 0 0 .2em @colorBgEmphasize1; + } + + + label { + &:before { + border-radius: 50%; + } + } } input[type=checkbox] { - &:checked + label:before { - background-image: image('checkbox.svg'); - - html.no-svg & { - background-image: image('checkbox.png'); - } - .background-size(contain); - } - - + label { - &:before { - border-radius: 20%; - } - } + &:checked + label:before { + background-image: image('checkbox.svg'); + + html.no-svg & { + background-image: image('checkbox.png'); + } + .background-size(contain); + } + + + label { + &:before { + border-radius: 20%; + } + } } .formField, .formAction { - max-width: 100%; - padding: 6px; + max-width: 100%; + padding: 6px; } .formField { - > label { - color: @colorFgLinkSubtle; - font-weight: bold; - padding-left: 2px; - - @media (min-width: 600px) { - width: 100px; - float: left; - padding-top: (@heightInputText - @fontSize * @fontLineHeight) / 2; - text-align: right; - } - - &:after { - content: ":"; - } - - .CM_FormField_Abstract { - float: left; - margin-right: 3px; - } - } - - > .input { - - @media (min-width: 600px) { - margin-left: 110px; - } - } - - &.noLabel > .input { - margin-left: 0; - } + > label { + color: @colorFgLinkSubtle; + font-weight: bold; + padding-left: 2px; + + @media (min-width: 600px) { + width: 100px; + float: left; + padding-top: (@heightInputText - @fontSize * @fontLineHeight) / 2; + text-align: right; + } + + &:after { + content: ":"; + } + + .CM_FormField_Abstract { + float: left; + margin-right: 3px; + } + } + + > .input { + + @media (min-width: 600px) { + margin-left: 110px; + } + } + + &.noLabel > .input { + margin-left: 0; + } } .formAction { - text-align: right; + text-align: right; - .formAction-alternatives { - float: left; - } + .formAction-alternatives { + float: left; + } } .messages { - display: block; + display: block; - .formField-error { - display: none; - color: @colorError; - padding: 2px; - } + .formField-error { + display: none; + color: @colorError; + padding: 2px; + } } From 49155e45344e5b723ee1b212423df63293fcf588 Mon Sep 17 00:00:00 2001 From: Christophe Schwyzer Date: Fri, 7 Mar 2014 15:41:21 +0100 Subject: [PATCH 9/9] formatting --- library/CM/SmartyPlugins/function.button.php | 132 ++++++------ .../CM/SmartyPlugins/function.button_link.php | 204 +++++++++--------- 2 files changed, 168 insertions(+), 168 deletions(-) diff --git a/library/CM/SmartyPlugins/function.button.php b/library/CM/SmartyPlugins/function.button.php index e9e267131..9b434d3e5 100644 --- a/library/CM/SmartyPlugins/function.button.php +++ b/library/CM/SmartyPlugins/function.button.php @@ -1,82 +1,82 @@ smarty->getTemplateVars('render'); - /** @var CM_Form_Abstract $form */ - $form = $render->getStackLast('forms'); - if (empty($params['action'])) { - trigger_error('Param `action` missing.'); - } - $action = $form->getAction($params['action']); - $title = isset($params['title']) ? (string) $params['title'] : null; - $theme = isset($params['theme']) ? (string) $params['theme'] : 'default'; + /** @var CM_Render $render */ + $render = $template->smarty->getTemplateVars('render'); + /** @var CM_Form_Abstract $form */ + $form = $render->getStackLast('forms'); + if (empty($params['action'])) { + trigger_error('Param `action` missing.'); + } + $action = $form->getAction($params['action']); + $title = isset($params['title']) ? (string) $params['title'] : null; + $theme = isset($params['theme']) ? (string) $params['theme'] : 'default'; - $class = 'button ' . 'button-' . $theme; - if (isset($params['class'])) { - $class .= ' ' . trim($params['class']); - } + $class = 'button ' . 'button-' . $theme; + if (isset($params['class'])) { + $class .= ' ' . trim($params['class']); + } - $data = array(); - if (isset($params['data'])) { - $data = $params['data']; - unset($params['data']); - } + $data = array(); + if (isset($params['data'])) { + $data = $params['data']; + unset($params['data']); + } - if (isset($params['event'])) { - $data['event'] = (string) $params['event']; - unset($params['event']); - } + if (isset($params['event'])) { + $data['event'] = (string) $params['event']; + unset($params['event']); + } - $icon = null; - $iconConfirm = null; - if (isset($params['icon'])) { - $icon = $params['icon']; + $icon = null; + $iconConfirm = null; + if (isset($params['icon'])) { + $icon = $params['icon']; - if (isset($params['iconConfirm'])) { - $iconConfirm = $params['iconConfirm']; + if (isset($params['iconConfirm'])) { + $iconConfirm = $params['iconConfirm']; + } } - } - $label = ''; - if (isset($params['label'])) { - $label = $params['label']; - } + $label = ''; + if (isset($params['label'])) { + $label = $params['label']; + } - if ($label) { - $class .= ' hasLabel'; - } - if ($icon) { - $class .= ' hasIcon'; - } - if ($title) { - $class .= ' showTooltip'; - } + if ($label) { + $class .= ' hasLabel'; + } + if ($icon) { + $class .= ' hasIcon'; + } + if ($title) { + $class .= ' showTooltip'; + } - $id = $form->getAutoId() . '-' . $action->getName() . '-button'; + $id = $form->getAutoId() . '-' . $action->getName() . '-button'; - $html = ''; - $html .= ''; - return $html; + $html .= ''; + return $html; } diff --git a/library/CM/SmartyPlugins/function.button_link.php b/library/CM/SmartyPlugins/function.button_link.php index e196cd4a0..e9f9a3297 100644 --- a/library/CM/SmartyPlugins/function.button_link.php +++ b/library/CM/SmartyPlugins/function.button_link.php @@ -2,106 +2,106 @@ require_once 'function.linkUrl.php'; function smarty_function_button_link(array $params, Smarty_Internal_Template $template) { - $label = ''; - if (isset($params['label'])) { - $label = CM_Util::htmlspecialchars($params['label']); - unset($params['label']); - } - - $attrs = ''; - $icon = null; - $iconConfirm = null; - if (isset($params['icon'])) { - $icon = $params['icon']; - - if (isset($params['iconConfirm'])) { - $iconConfirm = $params['iconConfirm']; - } - } - unset($params['icon']); - unset($params['iconConfirm']); - - $iconPosition = 'left'; - if (!empty($params['iconPosition']) && $params['iconPosition'] == 'right') { - $iconPosition = 'right'; - } - unset($params['iconPosition']); - - $title = null; - if (isset($params['title'])) { - $title = (string) $params['title']; - $attrs .= ' title="' . CM_Util::htmlspecialchars($title) . '"'; - } - unset($params['title']); - - if (isset($params['id'])) { - $attrs .= ' id="' . $params['id'] . '"'; - } - unset($params['id']); - - $theme = isset($params['theme']) ? (string) $params['theme'] : 'default'; - $class = 'button ' . 'button-' . $theme . ' '; - if (isset($params['class'])) { - $class .= $params['class']; - } - unset($params['theme']); - unset($params['class']); - - if ($label) { - $class .= ' hasLabel'; - } - - $iconMarkup = ''; - if ($icon) { - if ($iconConfirm) { - $iconMarkup = '' - . ''; - } else { - $iconMarkup = ''; - } - - if ($iconPosition == 'right') { - $class .= ' hasIconRight'; - } else { - $class .= ' hasIcon'; - } - } - - if ($title) { - $class .= ' showTooltip'; - } - - $onclick = false; - if (isset($params['onclick'])) { - $onclick = $params['onclick']; - unset($params['onclick']); - } - if (isset($params['page'])) { - $onclick .= ' cm.router.route(\'' . smarty_function_linkUrl($params, $template) . '\');'; - } - - if ($onclick) { - $attrs .= ' onclick="' . $onclick . '"'; - } - - if (isset($params['data'])) { - foreach ($params['data'] as $name => $value) { - $attrs .= ' data-' . $name . '="' . CM_Util::htmlspecialchars($value) . '"'; - } - } - - $html = ''; - $html .= ''; - return $html; + $label = ''; + if (isset($params['label'])) { + $label = CM_Util::htmlspecialchars($params['label']); + unset($params['label']); + } + + $attrs = ''; + $icon = null; + $iconConfirm = null; + if (isset($params['icon'])) { + $icon = $params['icon']; + + if (isset($params['iconConfirm'])) { + $iconConfirm = $params['iconConfirm']; + } + } + unset($params['icon']); + unset($params['iconConfirm']); + + $iconPosition = 'left'; + if (!empty($params['iconPosition']) && $params['iconPosition'] == 'right') { + $iconPosition = 'right'; + } + unset($params['iconPosition']); + + $title = null; + if (isset($params['title'])) { + $title = (string) $params['title']; + $attrs .= ' title="' . CM_Util::htmlspecialchars($title) . '"'; + } + unset($params['title']); + + if (isset($params['id'])) { + $attrs .= ' id="' . $params['id'] . '"'; + } + unset($params['id']); + + $theme = isset($params['theme']) ? (string) $params['theme'] : 'default'; + $class = 'button ' . 'button-' . $theme . ' '; + if (isset($params['class'])) { + $class .= $params['class']; + } + unset($params['theme']); + unset($params['class']); + + if ($label) { + $class .= ' hasLabel'; + } + + $iconMarkup = ''; + if ($icon) { + if ($iconConfirm) { + $iconMarkup = '' + . ''; + } else { + $iconMarkup = ''; + } + + if ($iconPosition == 'right') { + $class .= ' hasIconRight'; + } else { + $class .= ' hasIcon'; + } + } + + if ($title) { + $class .= ' showTooltip'; + } + + $onclick = false; + if (isset($params['onclick'])) { + $onclick = $params['onclick']; + unset($params['onclick']); + } + if (isset($params['page'])) { + $onclick .= ' cm.router.route(\'' . smarty_function_linkUrl($params, $template) . '\');'; + } + + if ($onclick) { + $attrs .= ' onclick="' . $onclick . '"'; + } + + if (isset($params['data'])) { + foreach ($params['data'] as $name => $value) { + $attrs .= ' data-' . $name . '="' . CM_Util::htmlspecialchars($value) . '"'; + } + } + + $html = ''; + $html .= ''; + return $html; }