feat(main): Add alert type; add template override support
This commit is contained in:
@@ -18,21 +18,27 @@ td.action-type .btn-group-action {
|
||||
max-width: unset !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
form[name="custom_html_block"] .card-body {
|
||||
form[name="custom_html_block"] .card-body,
|
||||
form[name="custom_html_group"] .card-body {
|
||||
padding: 25px 50px !important;
|
||||
}
|
||||
form[name="custom_html_block"] .card-header,
|
||||
form[name="custom_html_block"] .card-footer {
|
||||
form[name="custom_html_block"] .card-footer,
|
||||
form[name="custom_html_group"] .card-header,
|
||||
form[name="custom_html_group"] .card-footer {
|
||||
padding: 20px 50px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1500px) {
|
||||
form[name="custom_html_block"] .card-body {
|
||||
form[name="custom_html_block"] .card-body,
|
||||
form[name="custom_html_group"] .card-body {
|
||||
padding: 25px 300px !important;
|
||||
}
|
||||
form[name="custom_html_block"] .card-header,
|
||||
form[name="custom_html_block"] .card-footer {
|
||||
form[name="custom_html_block"] .card-footer,
|
||||
form[name="custom_html_group"] .card-header,
|
||||
form[name="custom_html_group"] .card-footer {
|
||||
padding: 20px 300px !important;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,3 +15,25 @@
|
||||
.customhtml-banner-extra-description {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.customhtml-alert {
|
||||
max-height: 500px;
|
||||
overflow: hidden;
|
||||
transition:
|
||||
max-height 0.4s ease,
|
||||
padding 0.4s ease,
|
||||
margin 0.4s ease,
|
||||
opacity 0.4s ease;
|
||||
}
|
||||
|
||||
.customhtml-alert.customhtml-alert-collapsing {
|
||||
max-height: 0;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
margin-bottom: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.customhtml-alert-title {
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
document.querySelectorAll('.customhtml-alert').forEach(function (alertEl) {
|
||||
var timeout = parseInt(alertEl.getAttribute('data-timeout'), 10) || 0;
|
||||
var timer = null;
|
||||
|
||||
var dismiss = function () {
|
||||
alertEl.classList.add('customhtml-alert-collapsing');
|
||||
};
|
||||
|
||||
if (timeout > 0) {
|
||||
timer = setTimeout(dismiss, timeout * 1000);
|
||||
}
|
||||
|
||||
var closeButton = alertEl.querySelector('.customhtml-alert-close');
|
||||
|
||||
if (closeButton) {
|
||||
closeButton.addEventListener('click', function () {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -59,6 +59,8 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{{ form_row(customHtmlBlockForm.alert_type) }}
|
||||
{{ form_row(customHtmlBlockForm.timeout) }}
|
||||
{{ form_row(customHtmlBlockForm.description) }}
|
||||
{{ form_row(customHtmlBlockForm.extra_description) }}
|
||||
{{ form_row(customHtmlBlockForm.link) }}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
$('.customhtmlblock-type-html').hide();
|
||||
$('.customhtmlblock-type-faq').hide();
|
||||
$('.customhtmlblock-type-banner').hide();
|
||||
$('.customhtmlblock-type-alert').hide();
|
||||
$('.customhtmlblock-type-' + type).show();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
$('.customhtmlblock-type-html').hide();
|
||||
$('.customhtmlblock-type-faq').hide();
|
||||
$('.customhtmlblock-type-banner').hide();
|
||||
$('.customhtmlblock-type-alert').hide();
|
||||
$('.customhtmlblock-type-' + type).show();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{if !empty($block.description)}
|
||||
<div
|
||||
id="customhtml-alert-{$block.id_ws_customhtml|intval}"
|
||||
class="alert alert-{$block.alert_type|escape:'html':'UTF-8'} alert-dismissible customhtml-alert"
|
||||
role="alert"
|
||||
data-timeout="{$block.timeout|intval}"
|
||||
>
|
||||
{if $block.show_title && !empty($block.title)}
|
||||
<strong class="customhtml-alert-title">{$block.title|escape:'html':'UTF-8'}</strong>
|
||||
{/if}
|
||||
<span class="customhtml-alert-text">{$block.description|escape:'html':'UTF-8'|nl2br}</span>
|
||||
<button type="button" class="close customhtml-alert-close" aria-label="{l s='Close' d='Modules.Wscustomhtml.Admin'}">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -4,13 +4,19 @@
|
||||
<div class="customhtml-group customhtml-group-{$group.id_ws_customhtml_group|intval} row">
|
||||
{foreach from=$group.blocks item="block"}
|
||||
<div class="customhtml-block col{if !empty($block.custom_class)} {$block.custom_class|escape:'html':'UTF-8'}{/if}">
|
||||
{if $block.type == 'faq'}
|
||||
{assign var="customhtmlOverridePath" value="{$smarty.const._PS_THEME_DIR_}modules/ws_customhtml/views/templates/hook/{$hookName}/{$block.type}.tpl"}
|
||||
|
||||
{if file_exists($customhtmlOverridePath)}
|
||||
{include file="module:ws_customhtml/views/templates/hook/`$hookName`/`$block.type`.tpl" block=$block group=$group hookName=$hookName}
|
||||
{elseif $block.type == 'faq'}
|
||||
{if $block.show_title && !empty($block.title)}
|
||||
<div class="customhtml-title">{$block.title|escape:'html':'UTF-8'}</div>
|
||||
{/if}
|
||||
{include file="module:ws_customhtml/views/templates/hook/_faq_accordion.tpl" block=$block}
|
||||
{elseif $block.type == 'banner'}
|
||||
{include file="module:ws_customhtml/views/templates/hook/_banner.tpl" block=$block}
|
||||
{elseif $block.type == 'alert'}
|
||||
{include file="module:ws_customhtml/views/templates/hook/_alert.tpl" block=$block}
|
||||
{else}
|
||||
{if $block.show_title && !empty($block.title)}
|
||||
<div class="customhtml-title">{$block.title|escape:'html':'UTF-8'}</div>
|
||||
|
||||
Reference in New Issue
Block a user