2013-11-13 17:14:38 +00:00
|
|
|
(function() {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var website = openerp.website;
|
2014-02-06 14:52:36 +00:00
|
|
|
var _t = openerp._t;
|
2013-11-19 11:38:22 +00:00
|
|
|
|
2014-06-27 09:03:34 +00:00
|
|
|
website.EditorBarContent.include({
|
|
|
|
new_product: function() {
|
|
|
|
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
|
2013-11-19 11:38:22 +00:00
|
|
|
});
|
2014-06-27 09:03:34 +00:00
|
|
|
});
|
|
|
|
},
|
2013-11-19 11:38:22 +00:00
|
|
|
});
|
2013-11-21 13:23:17 +00:00
|
|
|
|
2013-12-12 11:47:31 +00:00
|
|
|
function reload_enable_editor() {
|
|
|
|
var search = location.search.replace(/\?|$/, '?enable_editor=1&');
|
|
|
|
location.href = location.href.replace(/(\?|#|$).*/, search + location.hash);
|
|
|
|
}
|
2013-11-21 13:23:17 +00:00
|
|
|
|
2014-01-10 11:24:42 +00:00
|
|
|
$(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) {
|
2013-11-21 13:23:17 +00:00
|
|
|
var $a = $(event.currentTarget);
|
2013-12-12 11:47:31 +00:00
|
|
|
var $data = $a.parents(".js_options:first");
|
2014-01-10 11:24:42 +00:00
|
|
|
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";
|
2014-03-14 16:23:46 +00:00
|
|
|
openerp.jsonRpc('/shop/change_sequence', 'call', {'id': $data.data('id'), 'sequence': sequence})
|
2013-12-12 11:47:31 +00:00
|
|
|
.then(reload_enable_editor);
|
2013-11-21 13:23:17 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$(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");
|
2014-03-14 16:23:46 +00:00
|
|
|
openerp.jsonRpc('/shop/change_styles', 'call', {'id': $data.data('id'), 'style_id': $a.data("id")})
|
2013-11-21 13:23:17 +00:00
|
|
|
.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<y; yi++) tr.push("tr:eq("+yi+")");
|
|
|
|
var $select_tr = $table.find(tr.join(","));
|
|
|
|
var td = [];
|
|
|
|
for (var xi=0; xi<x; xi++) td.push("td:eq("+xi+")");
|
|
|
|
var $select_td = $select_tr.find(td.join(","));
|
|
|
|
|
|
|
|
$table.find("td").removeClass("select");
|
|
|
|
$select_td.addClass("select");
|
|
|
|
});
|
|
|
|
$(document).on('click', '#products_grid .js_options ul[name="size"] td', function (event) {
|
|
|
|
var $td = $(event.currentTarget);
|
|
|
|
var $data = $td.parents(".js_options:first");
|
|
|
|
var x = $td.index()+1;
|
|
|
|
var y = $td.parent().index()+1;
|
2014-03-14 16:23:46 +00:00
|
|
|
openerp.jsonRpc('/shop/change_size', 'call', {'id': $data.data('id'), 'x': x, 'y': y})
|
2013-12-12 11:47:31 +00:00
|
|
|
.then(reload_enable_editor);
|
2013-11-21 13:23:17 +00:00
|
|
|
});
|
|
|
|
|
2013-11-13 17:14:38 +00:00
|
|
|
})();
|