diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-09-13 18:07:59 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-09-13 18:07:59 +0200 |
| commit | 6c948c36bbf72dd896e0bff03aa7fbddadcbb0cd (patch) | |
| tree | f8620905c011735d8a3c340c46d1417a54a75972 /addons/website/static/src/js | |
| parent | 48503fcf08eac6fed12e080d4f501f9bbc8d257d (diff) | |
| parent | 197474e5b9ad43ab2d587a98136a1a809ce9a2e7 (diff) | |
[MERGE] forward port branch saas-12.5 up to 197474e5b9a
Diffstat (limited to 'addons/website/static/src/js')
| -rw-r--r-- | addons/website/static/src/js/backend/dashboard.js | 2 | ||||
| -rw-r--r-- | addons/website/static/src/js/content/menu.js | 3 | ||||
| -rw-r--r-- | addons/website/static/src/js/content/website_root.js | 2 | ||||
| -rw-r--r-- | addons/website/static/src/js/editor/editor_menu.js | 2 | ||||
| -rw-r--r-- | addons/website/static/src/js/editor/snippets.options.js | 76 | ||||
| -rw-r--r-- | addons/website/static/src/js/editor/wysiwyg_multizone.js | 142 | ||||
| -rw-r--r-- | addons/website/static/src/js/menu/content.js | 121 | ||||
| -rw-r--r-- | addons/website/static/src/js/menu/seo.js | 10 | ||||
| -rw-r--r-- | addons/website/static/src/js/menu/translate.js | 7 | ||||
| -rw-r--r-- | addons/website/static/src/js/tours/banner.js | 10 |
10 files changed, 270 insertions, 105 deletions
diff --git a/addons/website/static/src/js/backend/dashboard.js b/addons/website/static/src/js/backend/dashboard.js index dda40102904..28b9a55c8a4 100644 --- a/addons/website/static/src/js/backend/dashboard.js +++ b/addons/website/static/src/js/backend/dashboard.js @@ -185,7 +185,7 @@ var Dashboard = AbstractAction.extend({ }; }); - var ctx = document.getElementById(chart_id); + var ctx = this.$canvas[0]; this.chart = new Chart(ctx, { type: 'line', data: { diff --git a/addons/website/static/src/js/content/menu.js b/addons/website/static/src/js/content/menu.js index 9d3d5621f65..1b6fa07a5c0 100644 --- a/addons/website/static/src/js/content/menu.js +++ b/addons/website/static/src/js/content/menu.js @@ -19,6 +19,7 @@ publicWidget.registry.affixMenu = publicWidget.Widget.extend({ this.$headerClone.insertAfter(this.$target); this.$headers = this.$target.add(this.$headerClone); this.$dropdowns = this.$headers.find('.dropdown'); + this.$dropdownMenus = this.$headers.find('.dropdown-menu'); this.$navbarCollapses = this.$headers.find('.navbar-collapse'); this._adaptDefaultOffset(); @@ -100,7 +101,7 @@ publicWidget.registry.affixMenu = publicWidget.Widget.extend({ this.$headerClone.toggleClass('affixed', wOffset > (hOffset + 300)); // Reset opened menus - this.$dropdowns.removeClass('show'); + this.$dropdowns.add(this.$dropdownMenus).removeClass('show'); this.$navbarCollapses.removeClass('show').attr('aria-expanded', false); }, }); diff --git a/addons/website/static/src/js/content/website_root.js b/addons/website/static/src/js/content/website_root.js index 4b61a33d779..a8e208f1408 100644 --- a/addons/website/static/src/js/content/website_root.js +++ b/addons/website/static/src/js/content/website_root.js @@ -105,7 +105,7 @@ var WebsiteRoot = publicRootData.PublicRoot.extend({ var $target = $(ev.target); // retrieve the hash before the redirect var redirect = { - lang: $target.data('lang'), + lang: $target.data('url_code'), url: encodeURIComponent($target.attr('href').replace(/[&?]edit_translations[^&?]+/, '')), hash: encodeURIComponent(window.location.hash) }; diff --git a/addons/website/static/src/js/editor/editor_menu.js b/addons/website/static/src/js/editor/editor_menu.js index 72c2e6bee81..87422efdb1f 100644 --- a/addons/website/static/src/js/editor/editor_menu.js +++ b/addons/website/static/src/js/editor/editor_menu.js @@ -113,7 +113,7 @@ var EditorMenu = Widget.extend({ save: function (reload) { var self = this; this.trigger_up('edition_will_stopped'); - return this.wysiwyg.save(true).then(function (result) { + return this.wysiwyg.save(false).then(function (result) { var $wrapwrap = $('#wrapwrap'); self.editable($wrapwrap).removeClass('o_editable'); if (result.isDirty && reload !== false) { diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index d659677c478..baa1d8c5a7c 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -1297,35 +1297,51 @@ options.registry.gallery = options.Class.extend({ * @override */ _setActive: function () { - this._super(); - var classes = _.uniq((this.$target.attr('class').replace(/(^|\s)o_/g, ' ') || '').split(/\s+/)); - this.$el.find('[data-mode]') - .removeClass('active') - .filter('[data-mode="' + classes.join('"], [data-mode="') + '"]').addClass('active'); - var mode = this.$el.find('[data-mode].active').data('mode'); + this._super(...arguments); - classes = _.uniq((this.$('img:first').attr('class') || '').split(/\s+/)); - this.$el.find('[data-styling]') + var activeModeSelectors = []; + for (const className of this.$target[0].classList) { + if (className.startsWith('o_')) { + activeModeSelectors.push('[data-mode="' + className.substring(2) + '"]'); + } + } + var activeMode = this.$el.find('[data-mode]') .removeClass('active') - .filter('[data-styling="' + classes.join('"], [data-styling="') + '"]').addClass('active'); - - this.$el.find('[data-interval]').removeClass('active') - .filter('[data-interval='+this.$target.find('.carousel:first').attr('data-interval')+']') + .filter(activeModeSelectors.join(', ')) + .addClass('active') + .data('mode'); + + var carousel = this.$target[0].querySelector('.carousel'); + var activeInterval = carousel ? carousel.dataset.interval : undefined; + var $intervalOptions = this.$el.find('[data-interval]'); + $intervalOptions.removeClass('active') + .filter('[data-interval="' + activeInterval + '"]') .addClass('active'); - - var interval = this.$target.find('.carousel:first').attr('data-interval'); - this.$el.find('[data-interval]') - .removeClass('active') - .filter('[data-interval=' + interval + ']').addClass('active'); + $intervalOptions.closest('we-collapse-area')[0] + .classList.toggle('d-none', activeMode !== 'slideshow'); var columns = this._getColumns(); - this.$el.find('[data-columns]') - .removeClass('active') - .filter('[data-columns=' + columns + ']').addClass('active'); - - this.$el.find('[data-columns]:first, [data-select-class="spc-none"]') - .parent().parent().toggle(['grid', 'masonry'].indexOf(mode) !== -1); - this.$el.find('[data-interval]:first').parent().parent().toggle(mode === 'slideshow'); + var $columnOptions = this.$el.find('[data-columns]'); + $columnOptions.removeClass('active') + .filter('[data-columns="' + columns + '"]') + .addClass('active'); + $columnOptions.closest('we-collapse-area')[0] + .classList.toggle('d-none', !(activeMode === 'grid' || activeMode === 'masonry')); + + this.el.querySelector('.o_w_image_spacing_option') + .classList.toggle('d-none', activeMode === 'slideshow'); + + var $stylingOptions = this.$el.find('[data-styling]'); + $stylingOptions.removeClass('active'); + var img = this.$target[0].querySelector('img'); + if (img) { + var activeStyleSelectors = []; + for (const className of img.classList) { + activeStyleSelectors.push('[data-styling="' + className + '"]'); + } + $stylingOptions.filter(activeStyleSelectors.join(', ')) + .addClass('active'); + } }, }); @@ -1410,7 +1426,7 @@ options.registry.topMenuTransparency = options.Class.extend({ enabled = value; }, }); - this.$el.find('[data-transparent]').addBack('[data-transparent]').toggleClass('active', !!enabled); + this.$el.find('[data-transparent]').toggleClass('active', !!enabled); }, }); @@ -1465,7 +1481,6 @@ options.registry.topMenuColor = options.registry.colorpicker.extend({ */ options.registry.anchorName = options.Class.extend({ xmlDependencies: ['/website/static/src/xml/website.editor.xml'], - preventChildPropagation: true, //-------------------------------------------------------------------------- // Public @@ -1493,6 +1508,13 @@ options.registry.anchorName = options.Class.extend({ click: function () { var $input = this.$('.o_input_anchor_name'); var anchorName = $input.val().trim().replace(/\s/g, '_'); + if (self.$target[0].id === anchorName) { + // If the chosen anchor name is already the one used by the + // element, close the dialog and do nothing else + this.close(); + return; + } + var isValid = /^[\w-]+$/.test(anchorName); var alreadyExists = isValid && $('#' + anchorName).length > 0; var anchorOK = isValid && !alreadyExists; @@ -1520,7 +1542,7 @@ options.registry.anchorName = options.Class.extend({ }); } new Dialog(this, { - title: _t("Anchor Name"), + title: _t("Link Anchor"), $content: $(qweb.render('website.dialog.anchorName', { currentAnchor: this.$target.attr('id'), })), diff --git a/addons/website/static/src/js/editor/wysiwyg_multizone.js b/addons/website/static/src/js/editor/wysiwyg_multizone.js index 202257857d2..9ed31d3afe5 100644 --- a/addons/website/static/src/js/editor/wysiwyg_multizone.js +++ b/addons/website/static/src/js/editor/wysiwyg_multizone.js @@ -1,7 +1,38 @@ odoo.define('web_editor.wysiwyg.multizone', function (require) { 'use strict'; + var Wysiwyg = require('web_editor.wysiwyg'); +var snippetsEditor = require('web_editor.snippet.editor'); +/** + * Show/hide the dropdowns associated to the given toggles and allows to wait + * for when it is fully shown/hidden. + * + * Note: this also takes care of the fact the 'toggle' method of bootstrap does + * not properly work in all cases. + * + * @param {jQuery} $toggles + * @param {boolean} [show] + * @returns {Promise<jQuery>} + */ +function toggleDropdown($toggles, show) { + return Promise.all(_.map($toggles, toggle => { + var $toggle = $(toggle); + var $dropdown = $toggle.parent(); + var shown = $dropdown.hasClass('show'); + if (shown === show) { + return; + } + var toShow = !shown; + return new Promise(resolve => { + $dropdown.one( + toShow ? 'shown.bs.dropdown' : 'hidden.bs.dropdown', + () => resolve() + ); + $toggle.dropdown(toShow ? 'show' : 'hide'); + }); + })).then(() => $toggles); +} /** * HtmlEditor @@ -13,7 +44,6 @@ var Wysiwyg = require('web_editor.wysiwyg'); * */ var WysiwygMultizone = Wysiwyg.extend({ - /** * @override */ @@ -24,7 +54,35 @@ var WysiwygMultizone = Wysiwyg.extend({ var outerHTML = this._getEscapedElement($el).prop('outerHTML'); return self._saveElement(outerHTML, self.options.recordInfo, $el[0]); }; - return this._super(); + + // Mega menu initialization: handle dropdown openings by hand + var $megaMenuToggles = this.$('.o_mega_menu_toggle'); + $megaMenuToggles.removeAttr('data-toggle').dropdown('dispose'); + $megaMenuToggles.on('click.wysiwyg_multizone', ev => { + var $toggle = $(ev.currentTarget); + + // Each time we toggle a dropdown, we will destroy the dropdown + // behavior afterwards to keep manual control of it + var dispose = ($els => $els.dropdown('dispose')); + + // First hide all other mega menus + toggleDropdown($megaMenuToggles.not($toggle), false).then(dispose); + + // Then toggle the clicked one + toggleDropdown($toggle) + .then(dispose) + .then($el => { + var isShown = $el.parent().hasClass('show'); + this.editor.snippetsMenu.toggleMegaMenuSnippets(isShown); + }); + }); + + return this._super.apply(this, arguments).then(() => { + // Showing Mega Menu snippets if one dropdown is already opened + if (this.$('.o_mega_menu').hasClass('show')) { + this.editor.snippetsMenu.toggleMegaMenuSnippets(true); + } + }); }, /** * @override @@ -32,20 +90,26 @@ var WysiwygMultizone = Wysiwyg.extend({ */ save: function () { if (this.isDirty()) { - return this.editor.save().then(function() { - return {isDirty: true}; - }); + return this._restoreMegaMenus() + .then(() => this.editor.save(false)) + .then(() => ({isDirty: true})); } else { return {isDirty: false}; } }, - + /** + * @override + */ + destroy: function () { + this._restoreMegaMenus(); + this._super.apply(this, arguments); + }, //-------------------------------------------------------------------------- // Private //-------------------------------------------------------------------------- - _getEditableArea: function() { + _getEditableArea: function () { return $(':o_editable'); }, /** @@ -59,8 +123,9 @@ var WysiwygMultizone = Wysiwyg.extend({ * page element) */ _saveElement: function (outerHTML, recordInfo, editable) { + var promises = []; var $el = $(editable); - return this._rpc({ + promises.push(this._rpc({ model: 'ir.ui.view', method: 'save', args: [ @@ -69,7 +134,66 @@ var WysiwygMultizone = Wysiwyg.extend({ $el.data('oe-xpath') || null, ], context: recordInfo.context, - }); + })); + if ($el.data('oe-field') === 'mega_menu_content') { + // On top of saving the mega menu content like any other field + // content, we must save the custom classes that were set on the + // menu itself. + // FIXME normally removing the 'show' class should not be necessary here + // TODO check that editor classes are removed here as well + var classes = _.without($el.attr('class').split(' '), 'dropdown-menu', 'o_mega_menu', 'show'); + promises.push(this._rpc({ + model: 'website.menu', + method: 'write', + args: [ + [parseInt($el.data('oe-id'))], + { + 'mega_menu_classes': classes.join(' '), + }, + ], + })); + } + return Promise.all(promises); + }, + /** + * Restores mega menu behaviors and closes them (important to do before + * saving otherwise they would be saved opened). + * + * @private + * @returns {Promise} + */ + _restoreMegaMenus: function () { + var $megaMenuToggles = this.$('.o_mega_menu_toggle'); + $megaMenuToggles.off('.wysiwyg_multizone') + .attr('data-toggle', 'dropdown') + .dropdown({}); + return toggleDropdown($megaMenuToggles, false); + }, +}); + +snippetsEditor.Class.include({ + /** + * @private + * @param {boolean} show + */ + toggleMegaMenuSnippets: function (show) { + setTimeout(() => this._activateSnippet(false)); + this.$('#snippet_mega_menu').toggleClass('d-none', !show); + }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @override + */ + _insertDropzone: function ($hook) { + var $hookParent = $hook.parent(); + var $dropzone = this._super(...arguments); + $dropzone.attr('data-editor-message', $hookParent.attr('data-editor-message')); + $dropzone.attr('data-editor-sub-message', $hookParent.attr('data-editor-sub-message')); + return $dropzone; }, }); diff --git a/addons/website/static/src/js/menu/content.js b/addons/website/static/src/js/menu/content.js index 9582e0f4778..c0daa93925f 100644 --- a/addons/website/static/src/js/menu/content.js +++ b/addons/website/static/src/js/menu/content.js @@ -369,14 +369,15 @@ var MenuEntryDialog = weWidgets.LinkDialog.extend({ * @constructor */ init: function (parent, options, data) { - data.text = data.name || ''; - data.isNewWindow = data.new_window; - this._super(parent, _.extend({ title: _t("Add a menu item"), }, options || {}), _.extend({ needLabel: true, + text: data.name || '', + isNewWindow: data.new_window, }, data || {})); + + this.menuType = data.menuType; }, /** * @override @@ -391,6 +392,13 @@ var MenuEntryDialog = weWidgets.LinkDialog.extend({ // Adapt URL label this.$('label[for="o_link_dialog_label_input"]').text(_t("Menu Label")); + // Auto add '#' URL and hide the input if for mega menu + if (this.menuType === 'mega') { + var $url = this.$('input[name="url"]'); + $url.val('#').trigger('change'); + $url.closest('.form-group').addClass('d-none'); + } + return this._super.apply(this, arguments); }, @@ -469,7 +477,6 @@ var EditMenuDialog = weWidgets.Dialog.extend({ */ willStart: function () { var defs = [this._super.apply(this, arguments)]; - var self = this; var context; this.trigger_up('context_get', { callback: function (ctx) { @@ -480,11 +487,11 @@ var EditMenuDialog = weWidgets.Dialog.extend({ model: 'website.menu', method: 'get_tree', args: [context.website_id, this.rootID], - }).then(function (menu) { - self.menu = menu; - self.root_menu_id = menu.id; - self.flat = self._flatenize(menu); - self.to_delete = []; + }).then(menu => { + this.menu = menu; + this.rootMenuID = menu.fields['id']; + this.flat = this._flatenize(menu); + this.toDelete = []; })); return Promise.all(defs); }, @@ -505,6 +512,10 @@ var EditMenuDialog = weWidgets.Dialog.extend({ tolerance: 'pointer', attribute: 'data-menu-id', expression: '()(.+)', // nestedSortable takes the second match of an expression (*sigh*) + isAllowed: (placeholder, placeholderParent, currentItem) => { + return !placeholderParent + || !currentItem[0].dataset.megaMenu && !placeholderParent[0].dataset.megaMenu; + }, }); return r; }, @@ -518,8 +529,7 @@ var EditMenuDialog = weWidgets.Dialog.extend({ */ save: function () { var _super = this._super.bind(this); - var self = this; - var new_menu = this.$('.oe_menu_editor').nestedSortable('toArray', {startDepthCount: 0}); + var newMenus = this.$('.oe_menu_editor').nestedSortable('toArray', {startDepthCount: 0}); var levels = []; var data = []; var context; @@ -529,20 +539,25 @@ var EditMenuDialog = weWidgets.Dialog.extend({ }, }); // Resequence, re-tree and remove useless data - new_menu.forEach(function (menu) { + newMenus.forEach(menu => { if (menu.id) { levels[menu.depth] = (levels[menu.depth] || 0) + 1; - var mobj = self.flat[menu.id]; - mobj.sequence = levels[menu.depth]; - mobj.parent_id = (menu.parent_id|0) || menu.parent_id || self.root_menu_id; - delete(mobj.children); - data.push(mobj); + var menuFields = this.flat[menu.id].fields; + menuFields['sequence'] = levels[menu.depth]; + menuFields['parent_id'] = menu['parent_id'] || this.rootMenuID; + data.push(menuFields); } }); - this._rpc({ + return this._rpc({ model: 'website.menu', method: 'save', - args: [context.website_id, { data: data, to_delete: self.to_delete }], + args: [ + context.website_id, + { + 'data': data, + 'to_delete': this.toDelete, + } + ], }).then(function () { return _super(); }); @@ -563,10 +578,9 @@ var EditMenuDialog = weWidgets.Dialog.extend({ */ _flatenize: function (node, _dict) { _dict = _dict || {}; - var self = this; - _dict[node.id] = node; - node.children.forEach(function (child) { - self._flatenize(child, _dict); + _dict[node.fields['id']] = node; + node.children.forEach(child => { + this._flatenize(child, _dict); }); return _dict; }, @@ -580,23 +594,31 @@ var EditMenuDialog = weWidgets.Dialog.extend({ * dialog to edit this new menu. * * @private + * @param {Event} ev */ - _onAddMenuButtonClick: function () { - var self = this; - var dialog = new MenuEntryDialog(this, {}, {}); - dialog.on('save', this, function (link) { - var new_menu = { - id: _.uniqueId('new-'), - name: link.text, - url: link.url, - new_window: link.isNewWindow, - parent_id: false, - sequence: 0, - children: [], + _onAddMenuButtonClick: function (ev) { + var menuType = ev.currentTarget.dataset.type; + var dialog = new MenuEntryDialog(this, {}, { + menuType: menuType, + }); + dialog.on('save', this, link => { + var newMenu = { + 'fields': { + 'id': _.uniqueId('new-'), + 'name': link.text, + 'url': link.url, + 'new_window': link.isNewWindow, + 'is_mega_menu': menuType === 'mega', + 'sequence': 0, + 'parent_id': false, + }, + 'children': [], + 'is_homepage': false, }; - self.flat[new_menu.id] = new_menu; - self.$('.oe_menu_editor').append( - qweb.render('website.contentMenu.dialog.submenu', { submenu: new_menu })); + this.flat[newMenu.fields['id']] = newMenu; + this.$('.oe_menu_editor').append( + qweb.render('website.contentMenu.dialog.submenu', {submenu: newMenu}) + ); }); dialog.open(); }, @@ -607,9 +629,9 @@ var EditMenuDialog = weWidgets.Dialog.extend({ */ _onDeleteMenuButtonClick: function (ev) { var $menu = $(ev.currentTarget).closest('[data-menu-id]'); - var menuID = $menu.data('menu-id')|0; + var menuID = parseInt($menu.data('menu-id')); if (menuID) { - this.to_delete.push(menuID); + this.toDelete.push(menuID); } $menu.remove(); }, @@ -620,21 +642,20 @@ var EditMenuDialog = weWidgets.Dialog.extend({ * @private */ _onEditMenuButtonClick: function (ev) { - var self = this; - var menu_id = $(ev.currentTarget).closest('[data-menu-id]').data('menu-id'); - var menu = self.flat[menu_id]; + var $menu = $(ev.currentTarget).closest('[data-menu-id]'); + var menuID = $menu.data('menu-id'); + var menu = this.flat[menuID]; if (menu) { - var dialog = new MenuEntryDialog(this, {}, menu); - dialog.on('save', this, function (link) { - var id = link.id; - var menu_obj = self.flat[id]; - _.extend(menu_obj, { + var dialog = new MenuEntryDialog(this, {}, _.extend({ + menuType: menu.fields['is_mega_menu'] ? 'mega' : undefined, + }, menu.fields)); + dialog.on('save', this, link => { + _.extend(menu.fields, { 'name': link.text, 'url': link.url, 'new_window': link.isNewWindow, }); - var $menu = self.$('[data-menu-id="' + id + '"]'); - $menu.find('.js_menu_label').first().text(menu_obj.name); + $menu.find('.js_menu_label').first().text(menu.fields['name']); }); dialog.open(); } else { diff --git a/addons/website/static/src/js/menu/seo.js b/addons/website/static/src/js/menu/seo.js index 3844a1d4731..60bc2318955 100644 --- a/addons/website/static/src/js/menu/seo.js +++ b/addons/website/static/src/js/menu/seo.js @@ -20,7 +20,7 @@ var Suggestion = Widget.extend({ template: 'website.seo_suggestion', xmlDependencies: ['/website/static/src/xml/website.seo.xml'], events: { - 'click .js_seo_suggestion': 'select', + 'click .o_seo_suggestion': 'select', }, init: function (parent, options) { @@ -106,7 +106,7 @@ var Keyword = Widget.extend({ }, start: function () { var self = this; - this.$('.js_seo_keyword_suggestion').empty(); + this.$('.o_seo_keyword_suggestion').empty(); this.suggestionList = new SuggestionList(this, { root: this.keyword, language: this.language, @@ -115,7 +115,7 @@ var Keyword = Widget.extend({ this.suggestionList.on('selected', this, function (word, language) { this.trigger('selected', word, language); }); - return this.suggestionList.appendTo(this.$('.js_seo_keyword_suggestion')).then(function() { + return this.suggestionList.appendTo(this.$('.o_seo_keyword_suggestion')).then(function() { self.htmlPage.on('title-changed', self, self._updateTitle); self.htmlPage.on('description-changed', self, self._updateDescription); self._updateTitle(); @@ -497,9 +497,7 @@ var MetaKeywords = Widget.extend({ }, }); this._rpc({ - model: 'website', - method: 'get_languages', - args: [[context.website_id]], + route: '/website/get_languages', }).then(function (data) { self.$('#language-box').html(core.qweb.render('Configurator.language_promote', { 'language': data, diff --git a/addons/website/static/src/js/menu/translate.js b/addons/website/static/src/js/menu/translate.js index 043a900fff6..cab37bf3473 100644 --- a/addons/website/static/src/js/menu/translate.js +++ b/addons/website/static/src/js/menu/translate.js @@ -46,14 +46,11 @@ var TranslatePageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({ * @returns {Promise} */ _goToMasterPage: function () { - var lang = '/' + utils.get_cookie('frontend_lang'); - var current = document.createElement('a'); current.href = window.location.toString(); current.search += (current.search ? '&' : '?') + 'enable_editor=1'; - if (current.pathname.indexOf(lang) === 0) { - current.pathname = current.pathname.replace(lang, ''); - } + // we are in translate mode, the pathname starts with '/<url_code/' + current.pathname = current.pathname.substr(current.pathname.indexOf('/', 1)); var link = document.createElement('a'); link.href = '/website/lang/default'; diff --git a/addons/website/static/src/js/tours/banner.js b/addons/website/static/src/js/tours/banner.js index 5febdf1c749..f4ddc040c69 100644 --- a/addons/website/static/src/js/tours/banner.js +++ b/addons/website/static/src/js/tours/banner.js @@ -24,10 +24,14 @@ tour.register("banner", { position: "bottom", run: "text", }, { - trigger: ".oe_overlay_options .oe_options", + trigger: ".o_we_customize_panel", extra_trigger: "#wrapwrap .s_cover h1:not(:containsExact(\"Catchy Headline\"))", content: _t("Customize any block through this menu. Try to change the background color of this block."), - position: "top", + position: "right", +}, { + trigger: '.o_we_add_snippet_btn', + content: _t("Go back to the blocks menu."), + position: 'bottom', }, { trigger: "#snippet_structure .oe_snippet:eq(3) .oe_snippet_thumbnail", content: _t("Drag another block in your page, below the cover."), @@ -35,7 +39,6 @@ tour.register("banner", { run: "drag_and_drop #wrap", }, { trigger: "button[data-action=save]", - extra_trigger: ".oe_overlay_options .oe_options", content: _t("Click the <b>Save</b> button."), position: "bottom", }, { @@ -69,7 +72,6 @@ tour.register("banner", { run: "drag_and_drop #wrap", }, { trigger: "button[data-action=save]", - extra_trigger: ".oe_overlay_options .oe_options", content: _t("Click the <b>Save</b> button."), position: "bottom", }, { |
