summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/widgets
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2018-08-30 10:37:30 +0200
committerqsm-odoo <qsm@odoo.com>2018-08-30 11:10:56 +0200
commit77402a4efc4c8b3fbb146dbef57dfbebae709017 (patch)
tree0c068cd6774f7c53d6cbfcb591a90eab3b9f9bef /addons/website/static/src/js/widgets
parent6e33301693b9f187e7ec3b60df0b6f619ce76364 (diff)
[REF] web_editor, *: review color theming system
* web, website - Introduce gray color palettes (needed for themes migration) - Synchronize BS4 color maps with individual variables (see comments about this in the code). - Review alpha/primary, beta/secondary matching: Before this commit, we decided that the common way to define a color palette was defining primary, secondary, gamma, delta and epsilon. alpha and beta were then forced to primary and secondary without other possibility. The new system makes more sense: 1) define alpha, beta, gamma, delta and epsilon 2) primary and secondary will automatically be set to your alpha and beta (allowing to style the default UI with BS4-independant variables) 3) if you are not happy with (2), you can define primary / secondary in your color palette so that they are not automatically set to alpha / beta This commit also changes what classes the editor uses. Background colors and text colors will now use alpha/beta/gamma/delta/epsilon (not primary and secondary anymore). For buttons, all the possibilities are suggested but color duplicates are hidden (so if your primary and alpha are equal, only one button color is suggested).
Diffstat (limited to 'addons/website/static/src/js/widgets')
-rw-r--r--addons/website/static/src/js/widgets/theme.js32
1 files changed, 28 insertions, 4 deletions
diff --git a/addons/website/static/src/js/widgets/theme.js b/addons/website/static/src/js/widgets/theme.js
index ce73fd35d3d..e2879fb25c6 100644
--- a/addons/website/static/src/js/widgets/theme.js
+++ b/addons/website/static/src/js/widgets/theme.js
@@ -62,6 +62,27 @@ var ThemeCustomizeDialog = Dialog.extend({
var $tabs = this.$('[data-toggle="tab"]');
this.opened().then(function () {
$tabs.eq(self.defaultTab).tab('show');
+
+ var $colorPreview = self.$('.o_theme_customize_color_previews:visible');
+ var $primary = $colorPreview.find('.o_theme_customize_color[data-color="primary"]');
+ var $alpha = $colorPreview.find('.o_theme_customize_color[data-color="alpha"]');
+ var $secondary = $colorPreview.find('.o_theme_customize_color[data-color="secondary"]');
+ var $beta = $colorPreview.find('.o_theme_customize_color[data-color="beta"]');
+ var sameAlphaPrimary = $primary.find('.o_color_preview').css('background-color') === $alpha.find('.o_color_preview').css('background-color');
+ var sameBetaSecondary = $secondary.find('.o_color_preview').css('background-color') === $beta.find('.o_color_preview').css('background-color');
+ if (!sameAlphaPrimary) {
+ $alpha.find('.o_color_name').text(_t("Extra Color"));
+ $primary.removeClass('d-none').addClass('d-flex');
+ }
+ if (!sameBetaSecondary) {
+ $beta.find('.o_color_name').text(_t("Extra Color"));
+ $secondary.removeClass('d-none').addClass('d-flex');
+ }
+ if (!sameAlphaPrimary && sameBetaSecondary) {
+ $beta.insertBefore($alpha);
+ } else if (sameAlphaPrimary && !sameBetaSecondary) {
+ $secondary.insertAfter($alpha);
+ }
});
// Hide the tab navigation if only one tab
@@ -153,6 +174,9 @@ var ThemeCustomizeDialog = Dialog.extend({
reload: $item.data('reload'),
}));
+ $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 ($container.hasClass('form-row')) {
var $col = $('<div/>', {class: (icon ? 'col-4' : (colorPalette ? 'col-12' : 'col-6'))});
$col.append($multiChoiceLabel);
@@ -214,8 +238,8 @@ var ThemeCustomizeDialog = Dialog.extend({
params: {
xml_ids: this._getXMLIDs(this.$inputs),
},
- }).done(function (data) {
- self.$inputs.prop('checked', false);
+ }).done(function (data) {
+ self.$inputs.prop('checked', false);
_.each(self.$inputs.filter('[data-xmlid]:not([data-xmlid=""])'), function (input) {
var $input = $(input);
if (!_.difference(self._getXMLIDs($input), data[0]).length) {
@@ -454,7 +478,7 @@ var ThemeCustomizeDialog = Dialog.extend({
var colorType = $color.data('colorType');
var colorpicker = new ColorpickerDialog(this, {
- defaultColor: $color.find('span').css('background-color'),
+ defaultColor: $color.find('.o_color_preview').css('background-color'),
});
colorpicker.on('colorpicker:saved', this, function (ev) {
ev.stopPropagation();
@@ -551,4 +575,4 @@ var ThemeCustomizeMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
websiteNavbarData.websiteNavbarRegistry.add(ThemeCustomizeMenu, '#theme_customize');
return ThemeCustomizeDialog;
-}); \ No newline at end of file
+});