summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.editor.js
diff options
context:
space:
mode:
authorqsm-odoo <qsm@odoo.com>2016-09-30 10:07:17 +0200
committerqsm-odoo <qsm@odoo.com>2016-09-30 12:22:56 +0200
commit2432a1296a55dfe9894455d33a0a0cb546cb450d (patch)
treeb15dc884ea51db1bb208f3600bac11c31a17221c /addons/website/static/src/js/website.editor.js
parent3cbc7ebc4c3e0edb25d1a91dcbf4df163ef6d29e (diff)
[FIX] website: load customize menu at once if already opened
Following commit 3cbc7ebc4c3e0edb25d1a91dcbf4df163ef6d29e, the bug for customize menu could have been ignored but as it is an easy fix : The customize menu is filled after a rpc which is performed on mousedown on the menu toggle. But in the case the user clicked on the customize menu before the mousedown handler was attached... nothing occured. It is possible since the customize menu is rendered but its JS widget is only attached to it once everything is ready. Now, the menu is filled on first mousedown or if the menu is already opened when the JS widget is attached.
Diffstat (limited to 'addons/website/static/src/js/website.editor.js')
-rw-r--r--addons/website/static/src/js/website.editor.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index 8873703d790..e0cf880e611 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -54,39 +54,36 @@ website.TopBar.include({
website.TopBarCustomize = Widget.extend({
events: {
- 'mousedown a.dropdown-toggle': 'load_menu',
- 'click ul a[data-view-id]': 'do_customize',
+ 'click > ul a[data-view-id]': 'do_customize',
},
start: function () {
- var self = this;
- this.$menu = self.$el.find('ul');
this.view_name = $(document.documentElement).data('view-xmlid');
if (!this.view_name) {
this.$el.hide();
}
- this.loaded = false;
+
+ if (this.$el.is(".open")) {
+ this.load_menu();
+ } else {
+ this.$el.one("mousedown", "> a.dropdown-toggle", this.load_menu.bind(this));
+ }
},
load_menu: function () {
- var self = this;
- if(this.loaded) {
- return;
- }
+ var $menu = this.$el.children("ul");
ajax.jsonRpc('/website/customize_template_get', 'call', {
key: this.view_name,
}).then(function (result) {
_.each(result, function (item) {
- if (item.key === "website.debugger" && !window.location.search.match(/[&?]debug(&|$)/)) return;
if (item.header) {
- self.$menu.append('<li class="dropdown-header">' + item.name + '</li>');
+ $menu.append('<li class="dropdown-header">' + item.name + '</li>');
} else {
var $li = $('<li/>', {role: 'presentation'})
.append($('<a/>', {href: '#', 'data-view-id': item.id, role: 'menuitem'})
.append(qweb.render('web_editor.components.switch', {id: 'switch-' + item.id, label: item.name})));
$li.find('input').prop('checked', !!item.active);
- self.$menu.append($li);
+ $menu.append($li);
}
});
- self.loaded = true;
});
},
do_customize: function (e) {