summaryrefslogtreecommitdiff
path: root/addons/website/static/src/js/website.editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website/static/src/js/website.editor.js')
-rw-r--r--addons/website/static/src/js/website.editor.js113
1 files changed, 25 insertions, 88 deletions
diff --git a/addons/website/static/src/js/website.editor.js b/addons/website/static/src/js/website.editor.js
index a670f53bef1..b40c2deac9f 100644
--- a/addons/website/static/src/js/website.editor.js
+++ b/addons/website/static/src/js/website.editor.js
@@ -23,47 +23,16 @@ website.TopBar.include({
},
start: function () {
var self = this;
- $("#wrapwrap").on('click', '.o_editable, [data-oe-model]', function (event) {
- var $this = $(event.srcElement);
- var tag = $this[0] && $this[0].tagName.toLowerCase();
- if (!(tag === 'a' || tag === "button") && !$this.parents("a, button").length) {
- self.$('[data-action="edit"]').parent().effect('bounce', {distance: 18, times: 5}, 250);
- }
- });
-
$("#wrapwrap").find("[data-oe-model] .oe_structure.oe_empty, [data-oe-model].oe_structure.oe_empty, [data-oe-type=html]:empty")
.filter(".oe_not_editable")
.filter(".oe_no_empty")
- .addClass("oe_empty")
- .attr("data-oe-placeholder", _t("Press The Top-Left Edit Button"));
+ .addClass("oe_empty");
if (location.search.indexOf("enable_editor") >= 0 && $('html').attr('lang') === "en_US") {
this.$el.addClass('editing_mode');
}
- self.init_components()
-
- self.resize()
- $(window).on("resize", function(){
- self.resize()
- })
-
- return this._super();
- },
- init_components: function(){
- $(".switch").each(function(){
- var $el = $(this)
- $el.on('click', function(){
- var $i = $el.find('.switch_input')
- $el.toggleClass('checked')
- if($i.prop("checked")){
- $i.prop("checked", false);
- } else {
- $i.prop("checked", true);
- }
- return false;
- })
- });
+ return this._super.apply(this, arguments);
},
edit: function () {
this.$('button[data-action=edit]').prop('disabled', true);
@@ -71,31 +40,6 @@ website.TopBar.include({
editor.editor_bar = new editor.Class(this);
editor.editor_bar.prependTo(document.body);
},
- resize: function() {
- var wW = $(window).width(),
- $sys = $('#oe_systray'),
- $nav = $('#website_main_menu_navbar');
-
- // Adapt dropdown-menu orientation to fit screen size
- $sys.find('> li.wb_dropdown, >li.dropdown').each(function(){
- var $el = $(this),
- offset = $el.offset(),
- width = $el.width();
- var centerX = offset.left + width / 2;
- if(centerX > wW/2){
- $el.addClass('right')
- } else {
- $el.removeClass('right')
- }
- })
- // Resize oe_systray
- var totalWidth = null;
- $nav.find('>*').not($sys).each(function(index) {
- totalWidth += parseInt($(this).outerWidth() , 10);
- });
- $sys.width((wW - totalWidth)-50).addClass('ready')
-
- }
});
/* ----- Customize Template ---- */
@@ -105,7 +49,7 @@ website.TopBarCustomize = Widget.extend({
'mousedown a.dropdown-toggle': 'load_menu',
'click ul a[data-view-id]': 'do_customize',
},
- start: function() {
+ start: function () {
var self = this;
this.$menu = self.$el.find('ul');
this.view_name = $(document.documentElement).data('view-xmlid');
@@ -119,43 +63,36 @@ website.TopBarCustomize = Widget.extend({
if(this.loaded) {
return;
}
- 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>');
- } else {
- self.$menu.append(_.str.sprintf(
- '<li role="presentation">'+
- '<a href="#" data-view-id="%s" role="menuitem">' +
- '<span class="toggle_container">' +
- '<label class="switch %s" for="switch-%s">' +
- '<input type="checkbox" id="switch-%s" class="switch_input" checked="%s">' +
- '<span class="switch_track"></span>' +
- '</label>' +
- '</span> %s'+
- '</a>' +
- '</li>',
- item.id, item.active ? 'checked' : '', item.id, item.id, item.active ? 'true' : 'false', item.name));
- }
- });
- self.loaded = true;
- }
- );
+ 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>');
+ } 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);
+ }
+ });
+ self.loaded = true;
+ });
},
- do_customize: function (event) {
- var view_id = $(event.currentTarget).data('view-id');
- $('#website_loading').addClass('active')
+ do_customize: function (e) {
+ e.preventDefault();
+ var view_id = $(e.currentTarget).data('view-id');
return ajax.jsonRpc('/web/dataset/call_kw', 'call', {
model: 'ir.ui.view',
method: 'toggle',
args: [],
kwargs: {
ids: [parseInt(view_id, 10)],
- context: base.get_context()
+ context: base.get_context(),
}
- }).then( function() {
+ }).then(function () {
window.location.reload();
});
},