[REF] web_editor, website: use editor helper setClass
This helper is the equivalent of jquery's `toggleClass` with a value for the `force` attribute. I chose to name it `setClass` instead because with that attribute it's technically not toggling: it's setting.
This commit is contained in:
@@ -2714,11 +2714,7 @@ const SnippetOptionWidget = Widget.extend({
|
||||
value = value.split(params.saveUnit).join('');
|
||||
}
|
||||
if (params.extraClass) {
|
||||
if (params.defaultValue === value) {
|
||||
await this.editorHelpers.removeClass(context, this.$target[0], params.extraClass, context);
|
||||
} else {
|
||||
await this.editorHelpers.addClass(context, this.$target[0], params.extraClass, context);
|
||||
}
|
||||
await this.editorHelpers.setClass(context, this.$target[0], params.extraClass, params.defaultValue !== value)
|
||||
}
|
||||
return value;
|
||||
},
|
||||
@@ -4166,11 +4162,7 @@ registry.BackgroundPosition = SnippetOptionWidget.extend({
|
||||
*/
|
||||
backgroundType: async function (previewMode, widgetValue, params) {
|
||||
const backgroundType = async (context)=> {
|
||||
if (widgetValue === 'repeat-pattern') {
|
||||
await this.editorHelpers.addClass(context, this.$target[0], 'o_bg_img_opt_repeat');
|
||||
} else {
|
||||
await this.editorHelpers.removeClass(context, this.$target[0], 'o_bg_img_opt_repeat');
|
||||
}
|
||||
await this.editorHelpers.setClass(context, this.$target[0], 'o_bg_img_opt_repeat', widgetValue === 'repeat-pattern');
|
||||
await this.editorHelpers.setStyle(context, this.$target[0], 'background-position', '');
|
||||
await this.editorHelpers.setStyle(context, this.$target[0], 'background-size', '');
|
||||
}
|
||||
|
||||
@@ -794,11 +794,7 @@ var ContentMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
header_overlay: async function (value, wysiwyg) {
|
||||
const $wrapwrap = $('#wrapwrap');
|
||||
wysiwyg = wysiwyg || $wrapwrap.data('wysiwyg');
|
||||
if (value) {
|
||||
await wysiwyg.editorHelpers.addClass(wysiwyg.editor, $wrapwrap[0], 'o_header_overlay');
|
||||
} else {
|
||||
await wysiwyg.editorHelpers.removeClass(wysiwyg.editor, $wrapwrap[0], 'o_header_overlay');
|
||||
}
|
||||
await wysiwyg.editorHelpers.setClass(wysiwyg.editor, $wrapwrap[0], 'o_header_overlay', !!value);
|
||||
},
|
||||
header_color: async function (value, wysiwyg) {
|
||||
const $wrapwrap = $('#wrapwrap');
|
||||
|
||||
@@ -27,11 +27,7 @@ snippetOptions.registry.countdown = snippetOptions.SnippetOptionWidget.extend({
|
||||
if (!this.$target.find('.s_countdown_end_message').length) {
|
||||
const message = this.endMessage || qweb.render('website.s_countdown.end_message');
|
||||
await this.editorHelpers.insertHtml(context, message, this.$target.find('.container')[0], 'INSIDE');
|
||||
if (widgetValue === 'message_no_countdown') {
|
||||
await this.editorHelpers.addClass(this.wysiwyg.editor, this.$target, 'flex-row-reverse flex-row');
|
||||
} else {
|
||||
await this.editorHelpers.removeClass(this.wysiwyg.editor, this.$target, 'flex-row-reverse flex-row');
|
||||
}
|
||||
await this.editorHelpers.setClass(this.wysiwyg.editor, this.$target, 'flex-row-reverse flex-row', widgetValue === 'message_no_countdown');
|
||||
}
|
||||
} else {
|
||||
const $message = this.$target.find('.s_countdown_end_message');
|
||||
|
||||
Reference in New Issue
Block a user