550eac02
Administrator
second
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
(function($){
$.fn.basket = function(callerSettings) {
var basket_id = this;
var find_products = function(){
$("a[rel~='product']").each(function (i) {
$(this).bind('click',function(){
var rel = $(this).attr('rel');
var id = $('#product_id').val();
var count = 1;
go_product({mod_id : id,count:count});
return false;
})
})
|
3f2bc3d0
Administrator
first commit
|
17
|
}
|
550eac02
Administrator
second
|
18
19
20
21
22
23
24
25
26
27
28
|
var go_product = function(data){
var product_id = data.product_id;
$.get("/basket/add/", data ,
function(data){
//alert_msg("Товар добавлен<br /> в корзину",product_id);
popup(0,'.black');
start_basket();
});
}
|
444e4745
Administrator
image size
|
29
30
31
32
33
34
35
36
37
|
var update = function(data,form,w){
console.log(data);
$('.basket_items').html(data);
$('.basket_items .delete_button').click(function(){
var id =$(this).data('id');
$.get("/basket/items/", {deleteID : id},function(data){
popup(w,form);
start_basket(w,form);
|
550eac02
Administrator
second
|
38
|
});
|
444e4745
Administrator
image size
|
39
40
41
42
43
44
45
46
47
48
49
50
51
|
return false;
});
$(".item_num").bind('input',function(){
sendformitems(w,form);
});
$(".minus").click(function(){
var a = $(this).parent().find(".item_num").attr("value");
if (a == 1) {
/* минимум 1 элемент */
}
else{
a--;
$(this).parent().find('.item_num').val(a);
|
550eac02
Administrator
second
|
52
|
sendformitems(w,form);
|
444e4745
Administrator
image size
|
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
}
});
$(".plus").click(function(){
var a = $(this).parent().find(".item_num").attr("value");
if (a == 10) {
/* минимум 1 элемент */
}
else{
a++;
$(this).parent().find('.item_num').val(a);
sendformitems(w,form);
}
});
};
var popup = function(w,form){
$.get("/basket/items/", {} ,function(data){
update(data,form,w);
|
550eac02
Administrator
second
|
71
72
73
74
75
76
77
78
79
80
81
82
83
|
});
if(w==0) {
$(".black").removeClass("hidden");
$(".black_close").click(function () {
$(this).parent().parent().addClass("hidden");
});
$(".cont_shop").click(function () {
$(".black").addClass("hidden");
});
}
}
var sendformitems = function(w,form){
|
50795343
Administrator
image size
|
84
|
var data_form = $(form+' .basket_form2').serialize();
|
444e4745
Administrator
image size
|
85
|
console.log(w);
|
550eac02
Administrator
second
|
86
87
88
|
$.ajax({
type: 'POST',
url: "/basket/items/",
|
5f509693
Administrator
image size
|
89
|
dataType: "json",
|
550eac02
Administrator
second
|
90
|
data: data_form,
|
444e4745
Administrator
image size
|
91
92
|
done: function(data) {
update(data,form,w);
|
550eac02
Administrator
second
|
93
94
95
96
97
98
99
100
101
102
|
start_basket();
},
});
}
var start_basket = function(){
$.get("/basket/info/",
function(data){
$(basket_id).html(data);
});
|
3f2bc3d0
Administrator
first commit
|
103
|
|
3f2bc3d0
Administrator
first commit
|
104
105
|
}
|
550eac02
Administrator
second
|
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
var alert_msg = function(msg,product_id){
winW = document.body.offsetWidth;
winH = document.body.offsetHeight
$('.modal_box').remove();
$('#data_box').remove();
$('body').append('<div class="modal_box"></div>');
$('body').append('<div id="data_box"></div>');
$('#data_box').append('<div class="data_wrp"></div>');
$('#data_box').css( "left", ((winW-400)/2)+'px' );
var scrollTop = document.documentElement.scrollTop
if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1 || navigator.userAgent.toLowerCase().indexOf('safari') > -1) {
scrollTop = document.body.scrollTop;
}
$('#data_box').css( "top", (scrollTop+150)+'px' );
app = '<center>';
app +='<h1>'+msg+'</h1>';
app += '<br /><input type="submit" class="submit4" style="text-transform:none;" value="Перейти в корзину" onClick="document.location=\'/basket/\'" /> ';
app += '<input type="submit" class="submit4" style="text-transform:none;" id="p_close" value="Продолжить покупки" />';
app += '</center>';
$('#data_box .data_wrp').append(app);
$(".modal_box, #modal_close, #p_close").click(function() {
$('.modal_box').remove();
$('#data_box').remove();
});
}
find_products();
start_basket();
$(".more").click(function(){
if($(this).hasClass("hideico")){
$(this).removeClass("hideico");
$(this).parent().addClass("open");
$(this).parent().removeClass("open");
}
else{
$(this).addClass("hideico");
$(this).parent().addClass("open");
popup(1,'.basket_hovered');
}
})
}
})(jQuery);
|