(function() { "use strict"; var website = openerp.website; var _t = openerp._t; website.add_template_file('/website_sale/static/src/xml/website_sale.xml'); website.EditorBar.include({ start: function() { website.is_editable_button = website.is_editable_button || !!$("#wrap.js_sale").size(); var res = this._super(); this.$(".dropdown:has(.oe_content_menu)").removeClass("hidden"); return res; }, events: _.extend({}, website.EditorBar.prototype.events, { 'click a[data-action=new_product]': function (ev) { ev.preventDefault(); website.prompt({ id: "editor_new_product", window_title: _t("New Product"), input: "Product Name", }).then(function (name) { website.form('/shop/add_product', 'POST', { name: name }); }); } }), }); function reload_enable_editor() { var search = location.search.replace(/\?|$/, '?enable_editor=1&'); location.href = location.href.replace(/(\?|#|$).*/, search + location.hash); } $(document).on('click', '.js_options .js_go_to_top,.js_options .js_go_to_bottom,.js_options .js_go_up,.js_options .js_go_down', function (event) { var $a = $(event.currentTarget); var $data = $a.parents(".js_options:first"); var sequence = "top"; if ($a.hasClass('js_go_to_bottom')) sequence = "bottom"; else if ($a.hasClass('js_go_up')) sequence = "up"; else if ($a.hasClass('js_go_down')) sequence = "down"; openerp.jsonRpc('/shop/change_sequence', 'call', {'id': $data.data('id'), 'sequence': sequence}) .then(reload_enable_editor); }); $(document).on('click', '.js_options ul[name="style"] a', function (event) { var $a = $(event.currentTarget); var $li = $a.parent(); var $data = $a.parents(".js_options:first"); var $product = $a.parents(".oe_product:first"); $li.parent().removeClass("active"); openerp.jsonRpc('/shop/change_styles', 'call', {'id': $data.data('id'), 'style_id': $a.data("id")}) .then(function (result) { $product.toggleClass($a.data("class")); $li.toggleClass("active", result); }); }); $(document).on('mouseenter', '#products_grid .js_options ul[name="size"] table', function (event) { $(event.currentTarget).addClass("oe_hover"); }); $(document).on('mouseleave', '#products_grid .js_options ul[name="size"] table', function (event) { $(event.currentTarget).removeClass("oe_hover"); }); $(document).on('mouseover', '#products_grid .js_options ul[name="size"] td', function (event) { var $td = $(event.currentTarget); var $table = $td.parents("table:first"); var x = $td.index()+1; var y = $td.parent().index()+1; var tr = []; for (var yi=0; yi