summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/widgets/theme.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website/static/src/js/widgets/theme.js')
-rw-r--r--addons/website/static/src/js/widgets/theme.js85
1 files changed, 25 insertions, 60 deletions
diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js
index c48bab3c74f..68a1c6bc50b 100644
--- a/addons/website/static/src/js/widgets/theme.js
+++ b/addons/website/static/src/js/widgets/theme.js
@@ -154,72 +154,45 @@ var ThemeCustomizeDialog = Dialog.extend({
switch (item.tagName) {
case 'OPT':
- var colorPalette = $item.data('colorPalette') === 'user';
- var icon = $item.data('icon');
+ var widgetName = $item.data('widget');
// Build the options template
- var $multiChoiceLabel = $(core.qweb.render('website.theme_customize_modal_option', {
+ var $option = $(core.qweb.render('website.theme_customize_modal_option', {
name: optionsName,
id: $item.attr('id') || _.uniqueId('o_theme_customize_input_id_'),
string: $item.attr('string'),
- icon: icon,
- color: $item.data('color'),
+ icon: $item.data('icon'),
font: $item.data('font'),
- colorPalette: colorPalette,
-
xmlid: $item.data('xmlid'),
enable: $item.data('enable'),
disable: $item.data('disable'),
reload: $item.data('reload'),
+
+ widget: widgetName,
}));
- $multiChoiceLabel.find('.o_theme_customize_color[data-color="primary"]').addClass('d-none').removeClass('d-flex');
- $multiChoiceLabel.find('.o_theme_customize_color[data-color="secondary"]').addClass('d-none').removeClass('d-flex');
+ if (widgetName) {
+ var $widget = $(core.qweb.render('website.theme_customize_' + widgetName));
+ $option.append($widget);
+ }
if ($container.hasClass('form-row')) {
- $col = $('<div/>', {class: (icon ? 'col-4' : (colorPalette ? 'col-12' : 'col-6'))});
- $col.append($multiChoiceLabel);
+ $col = $('<div/>', {
+ class: _.str.sprintf('col-%s', $item.data('col') || 6),
+ });
+ $col.append($option);
$container.append($col);
} else {
- $container.append($multiChoiceLabel);
- }
- break;
-
- case 'MORE':
- var collapseID = _.uniqueId('collapse-');
-
- $col = $('<div/>', {
- class: 'col-12',
- }).appendTo($container);
-
- var string = $item.attr('string');
- if (string) {
- var $button = $('<button/>', {
- 'type': 'button',
- class: 'btn btn-primary d-block mx-auto mt-3 collapsed',
- 'data-toggle': 'collapse',
- 'data-target': "#" + collapseID,
- text: string,
- });
- $col.append($button);
+ $container.append($option);
}
-
- var $collapse = $('<div/>',{
- id: collapseID,
- class: 'collapse form-row justify-content-between mt-3',
- 'data-depends': $item.data('depends'),
- });
- $col.append($collapse);
-
- _processItems($item.children(), $collapse);
break;
case 'LIST':
var $listContainer = $('<div/>', {class: 'py-1 px-2 o_theme_customize_option_list'});
$col = $('<div/>', {
- class: 'col-6 mt-2',
+ class: _.str.sprintf('col-%s mt-2', $item.data('col') || 6),
'data-depends': $item.data('depends'),
}).append($('<h6/>', {text: $item.attr('string')}), $listContainer);
$container.append($col);
@@ -353,21 +326,13 @@ var ThemeCustomizeDialog = Dialog.extend({
$set.prop('checked', checked).closest('label').toggleClass('checked', checked);
});
- // Mark the collapsed section as visible if their dependencies are met
- var $collapsedElements = this.$('[data-depends]');
- _.each($collapsedElements, function (collapsed) {
- var $collapsed = $(collapsed);
- var enabled = false;
- var nbDependencies = $collapsed.data('depends') ? $collapsed.data('depends').split(',').length : 0;
- if (self._getInputs($collapsed.data('depends')).filter(':checked').length === nbDependencies) {
- enabled = true;
- }
-
- if ($collapsed.is('.collapse')) {
- $collapsed.collapse(enabled ? 'show' : 'hide');
- } else {
- $collapsed.toggleClass('d-none', !enabled);
- }
+ // Make the hidden sections visible if their dependencies are met
+ _.each(this.$('[data-depends]'), function (hidden) {
+ var $hidden = $(hidden);
+ var depends = $hidden.data('depends');
+ var nbDependencies = depends ? depends.split(',').length : 0;
+ var enabled = self._getInputs(depends).filter(':checked').length === nbDependencies;
+ $hidden.toggleClass('d-none', !enabled);
});
},
/**
@@ -377,8 +342,8 @@ var ThemeCustomizeDialog = Dialog.extend({
if (reload || config.debug === 'assets') {
window.location.href = $.param.querystring('/website/theme_customize_reload', {
href: window.location.href,
- enable: enable.join(','),
- disable: disable.join(','),
+ enable: (enable || []).join(','),
+ disable: (disable || []).join(','),
tab: this.$('.nav-link.active').parent().index(),
});
return $.Deferred();
@@ -538,7 +503,7 @@ var ThemeCustomizeDialog = Dialog.extend({
},
});
}).then(function () {
- self.$('#' + $color.closest('.o_theme_customize_color_previews').data('depends')).click();
+ return self._updateStyle();
});
});
colorpicker.open();