2013-07-23 13:39:23 +00:00
|
|
|
$(document).ready(function () {
|
2013-08-23 09:40:17 +00:00
|
|
|
$(".oe_website_sale input[name='shipping_different']").change(function () {
|
2013-08-13 10:39:48 +00:00
|
|
|
$(".oe_website_sale .js_shipping").toggle();
|
2013-07-23 13:39:23 +00:00
|
|
|
});
|
2013-08-08 14:23:41 +00:00
|
|
|
|
2013-08-23 09:40:17 +00:00
|
|
|
$payment = $(".oe_website_sale .js_payment");
|
|
|
|
$("input[name='payment_type']", $payment).click(function (ev) {
|
2013-09-02 15:54:31 +00:00
|
|
|
var payment_id = $(ev.currentTarget).val();
|
2013-08-23 09:40:17 +00:00
|
|
|
$("div[data-id]", $payment).addClass("hidden");
|
|
|
|
$("a.btn:last, div[data-id='"+payment_id+"']", $payment).removeClass("hidden");
|
|
|
|
});
|
2013-09-02 15:54:31 +00:00
|
|
|
|
|
|
|
// change for css
|
|
|
|
$(document).on('mouseup', '.js_publish', function (ev) {
|
|
|
|
$(ev.currentTarget).parents(".thumbnail").toggleClass("disabled");
|
|
|
|
});
|
2013-09-03 08:28:14 +00:00
|
|
|
|
2013-09-03 12:34:38 +00:00
|
|
|
function set_my_cart_quantity(qty) {
|
2013-10-03 11:04:11 +00:00
|
|
|
var $q = $(".my_cart_quantity");
|
|
|
|
$q.parent().parent().toggleClass("hidden", !qty);
|
|
|
|
$q.html(qty)
|
|
|
|
.hide()
|
|
|
|
.fadeIn(600);
|
2013-09-03 12:34:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$(".oe_website_sale .oe_mycart input.js_quantity").change(function () {
|
|
|
|
var $input = $(this);
|
|
|
|
var value = parseInt($input.val());
|
2013-09-10 11:51:59 +00:00
|
|
|
if (isNaN(value)) value = 0;
|
2013-09-26 14:07:50 +00:00
|
|
|
openerp.jsonRpc("/shop/set_cart_json/", 'call', {'order_line_id': $input.data('id'), 'set_number': value})
|
|
|
|
.then(function (data) {
|
|
|
|
set_my_cart_quantity(data[1]);
|
|
|
|
$input.val(data[0]);
|
|
|
|
if (!data[0]) {
|
2013-10-03 11:04:11 +00:00
|
|
|
location.reload();
|
2013-09-26 14:07:50 +00:00
|
|
|
}
|
|
|
|
});
|
2013-09-04 08:49:58 +00:00
|
|
|
});
|
2013-09-03 12:34:38 +00:00
|
|
|
|
|
|
|
// hack to add and rome from cart with json
|
2013-10-02 16:28:10 +00:00
|
|
|
$('.oe_website_sale a.js_add_cart_json').on('click', function (ev) {
|
2013-09-03 12:34:38 +00:00
|
|
|
ev.preventDefault();
|
2013-09-26 14:07:50 +00:00
|
|
|
var $link = $(ev.currentTarget);
|
2013-10-02 07:12:39 +00:00
|
|
|
var product = $link.attr("href").match(/product_id=([0-9]+)/);
|
|
|
|
var product_id = product ? +product[1] : 0;
|
2013-09-27 13:40:28 +00:00
|
|
|
openerp.jsonRpc("/shop/add_cart_json/", 'call', {'product_id': product_id, 'order_line_id': $link.data('id'), 'remove': $link.is('[href*="/remove_cart/"]')})
|
2013-09-26 14:07:50 +00:00
|
|
|
.then(function (data) {
|
|
|
|
if (!data[0]) {
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
set_my_cart_quantity(data[1]);
|
2013-10-02 07:12:39 +00:00
|
|
|
$link.parents(".input-group:first").find(".js_quantity").val(data[0]);
|
2013-09-26 14:07:50 +00:00
|
|
|
});
|
2013-09-03 12:34:38 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2013-10-03 10:47:01 +00:00
|
|
|
// change price when they are variants
|
|
|
|
$('form.js_add_cart_json label').on('mouseup', function (ev) {
|
|
|
|
ev.preventDefault();
|
|
|
|
var $label = $(ev.currentTarget);
|
|
|
|
var $price = $label.parent("form").find(".oe_price");
|
|
|
|
if (!$price.data("price")) {
|
|
|
|
$price.data("price", parseFloat($price.html()));
|
|
|
|
}
|
|
|
|
$price.html($price.data("price")+parseFloat($label.find(".badge span").html() || 0));
|
|
|
|
});
|
|
|
|
|
2013-09-27 10:31:48 +00:00
|
|
|
$(document).on('click', '.js_publish_management .js_go_to_top,.js_publish_management .js_go_to_bottom', function (event) {
|
|
|
|
var $a = $(event.currentTarget);
|
|
|
|
var $data = $a.parents(".js_publish_management:first");
|
|
|
|
openerp.jsonRpc('/shop/change_sequence/', 'call', {'id': $data.data('id'), 'top': $a.hasClass('js_go_to_top')});
|
2013-09-26 11:18:54 +00:00
|
|
|
});
|
|
|
|
|
2013-09-27 10:31:48 +00:00
|
|
|
$(document).on('click', '#products_grid .js_options ul[name="style"] a', function (event) {
|
|
|
|
var $a = $(event.currentTarget);
|
2013-09-26 13:09:54 +00:00
|
|
|
var $li = $a.parent();
|
2013-09-27 10:31:48 +00:00
|
|
|
var $data = $a.parents(".js_options:first");
|
|
|
|
var $product = $a.parents(".oe_product:first");
|
2013-09-26 13:09:54 +00:00
|
|
|
|
|
|
|
$li.parent().removeClass("active");
|
2013-09-27 10:31:48 +00:00
|
|
|
openerp.jsonRpc('/shop/change_styles/', 'call', {'id': $data.data('id'), 'style_id': $a.data("id")})
|
2013-09-26 13:09:54 +00:00
|
|
|
.then(function (result) {
|
2013-09-27 10:31:48 +00:00
|
|
|
$product.toggleClass($a.data("class"));
|
2013-09-26 13:09:54 +00:00
|
|
|
$li.toggleClass("active", result);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-09-27 10:31:48 +00:00
|
|
|
$(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;
|
|
|
|
openerp.jsonRpc('/shop/change_size/', 'call', {'id': $data.data('id'), 'x': x, 'y': y})
|
|
|
|
.then(function () {
|
2013-09-27 11:01:46 +00:00
|
|
|
var search = location.search.replace(/\?|$/, '?unable_editor=1&');
|
|
|
|
location.href = location.href.replace(/(\?|#).*/, search + location.hash);
|
2013-09-27 10:31:48 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-08-05 12:38:36 +00:00
|
|
|
});
|