Homparty v1.0
This commit is contained in:
parent
ac0d5b781e
commit
c73299e52e
40 changed files with 1234 additions and 908 deletions
|
|
@ -13,6 +13,7 @@ var IqHomepartyCart = {
|
|||
insert_show_total_order: '#insert_show_total_order',
|
||||
insert_show_bonus: '#insert_show_bonus',
|
||||
insert_show_bonus_host: '#insert_show_bonus_host',
|
||||
select_delivery_option: '.select_delivery_option',
|
||||
/*
|
||||
comp_holder: '#holder_html_view_comp_product',
|
||||
is_for: null,
|
||||
|
|
@ -32,7 +33,6 @@ var IqHomepartyCart = {
|
|||
init: function () {
|
||||
var _self = this;
|
||||
_self.url = $(_self.form).attr('action');
|
||||
_self._log(_self.url);
|
||||
|
||||
|
||||
$(_self.cart_holders).each(function (key, obj){
|
||||
|
|
@ -48,7 +48,6 @@ var IqHomepartyCart = {
|
|||
},
|
||||
setDatabase: function (oTable){
|
||||
var _self = this;
|
||||
_self._log($(oTable));
|
||||
_self.oTable = oTable;
|
||||
},
|
||||
reInitModal: function (){
|
||||
|
|
@ -78,7 +77,6 @@ var IqHomepartyCart = {
|
|||
_self.remove_product($(this), _obj)
|
||||
});
|
||||
obj.find(_self.table_input).off('change').on('change', function(){
|
||||
_self._log($(this));
|
||||
_self.update_input_table($(this), _obj);
|
||||
});
|
||||
|
||||
|
|
@ -86,7 +84,9 @@ var IqHomepartyCart = {
|
|||
_self.remove_from_cart($(this), _obj);
|
||||
});
|
||||
|
||||
|
||||
obj.find(_self.select_delivery_option).off('change').on('change', function(){
|
||||
_self.update_delivery_option($(this), _obj);
|
||||
});
|
||||
},
|
||||
|
||||
add_product: function (_obj, _holder){
|
||||
|
|
@ -133,6 +133,16 @@ var IqHomepartyCart = {
|
|||
action: 'removeFromCart'
|
||||
}).done(_self.refreshView);
|
||||
},
|
||||
update_delivery_option: function (_obj, _holder){
|
||||
var _self = this;
|
||||
_self.performRequest({
|
||||
delivery: _obj.val(),
|
||||
homeparty_id: _holder.data('homeparty-id'),
|
||||
homeparty_user_id: _holder.data('homeparty-user-id'),
|
||||
action: 'updateDeliveryOption'
|
||||
}).done(_self.refreshView);
|
||||
},
|
||||
|
||||
refreshView: function (data) {
|
||||
var _self = IqHomepartyCart;
|
||||
var obj = $(_self.cart_holder+data.data.homeparty_user_id)
|
||||
|
|
@ -187,98 +197,5 @@ var IqHomepartyCart = {
|
|||
return 100;
|
||||
}
|
||||
return number;
|
||||
},
|
||||
|
||||
/*
|
||||
|
||||
showInit: function (){
|
||||
var _self = this;
|
||||
$(_self.btn_clear).on('click', function (){
|
||||
_self.performRequest({action: 'clearCart'})
|
||||
.done(_self.refreshDatabaseRefreshAndView)
|
||||
});
|
||||
$(_self.cart_input).on('change', function(){
|
||||
_self.update_input_cart($(this));
|
||||
});
|
||||
$(_self.remove_item).on('click', function(event){
|
||||
event.preventDefault();
|
||||
_self.update_cart_database($(this).data('product-id'), 0);
|
||||
});
|
||||
if(_self.is_for === 'me'){
|
||||
$('input[name^="'+_self.comp_products+'"]').on('change', function(){
|
||||
_self.update_comp_product($(this));
|
||||
});
|
||||
}
|
||||
},
|
||||
update_shipping_state : function (_obj){
|
||||
var _self = this;
|
||||
var id = parseInt(_obj.val());
|
||||
var is_for = _obj.data('is-for');
|
||||
_self.performRequest({shipping_country_id: id, shipping_is_for: is_for, action: 'updateShippingCountry'})
|
||||
.done(_self.refreshItemsAndView);
|
||||
},
|
||||
update_input_table: function (_obj){
|
||||
var _self = this;
|
||||
var qty = parseInt(_obj.val());
|
||||
qty = _self.checkNumber(qty);
|
||||
_obj.val(qty);
|
||||
_self.update_cart(_obj.data('product-id'), qty);
|
||||
},
|
||||
update_input_cart: function (_obj){
|
||||
var _self = this;
|
||||
var qty = parseInt(_obj.val());
|
||||
qty = _self.checkNumber(qty);
|
||||
_obj.val(qty);
|
||||
_self.update_cart_database(_obj.data('product-id'), qty);
|
||||
},
|
||||
update_comp_product: function (_obj){
|
||||
var _self = this;
|
||||
_self.performRequest({comp_product_id: _obj.val(), comp_num: _obj.data('comp_num'), count_comp_products: $('input[name="'+_self.count_comp_products+'"]').val(), action: 'updateCompProduct'})
|
||||
.done(_self.refreshItemsAndView);
|
||||
},
|
||||
|
||||
update_cart_database: function (product_id, qty){
|
||||
var _self = this;
|
||||
_self.performRequest({product_id: product_id, qty: qty, action: 'updateCart'})
|
||||
.done(_self.refreshDatabaseAndView);
|
||||
},
|
||||
update_cart: function (product_id, qty){
|
||||
var _self = this;
|
||||
_self.performRequest({product_id: product_id, qty: qty, action: 'updateCart'})
|
||||
.done(_self.refreshItemsAndView);
|
||||
},
|
||||
refreshItemsAndView: function (data){
|
||||
var _self = IqShoppingCart;
|
||||
$(_self.cart_holder).html(data.html_cart);
|
||||
$(_self.comp_holder).html(data.html_comp);
|
||||
_self.showInit();
|
||||
|
||||
},
|
||||
refreshDatabaseAndView: function (data) {
|
||||
var _self = IqShoppingCart;
|
||||
$(_self.cart_holder).html(data.html_cart);
|
||||
$(_self.comp_holder).html(data.html_comp);
|
||||
|
||||
var input = $(_self.table).find('input[name="product_qty_'+data.data.product_id+'"]');
|
||||
input.val(data.data.qty);
|
||||
_self.showInit();
|
||||
},
|
||||
refreshDatabaseRefreshAndView : function (data){
|
||||
var _self = IqShoppingCart;
|
||||
$(_self.cart_holder).html(data.html_cart);
|
||||
$(_self.comp_holder).html(data.html_comp);
|
||||
|
||||
_self.showInit();
|
||||
_self.oTable.draw();
|
||||
},
|
||||
checkNumber : function(number){
|
||||
if(number < 0 || isNaN(number)){
|
||||
return 0;
|
||||
}
|
||||
if(number >= 100){
|
||||
return 100;
|
||||
}
|
||||
return number;
|
||||
},
|
||||
*/
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue