| 13579 |
anikendra |
1 |
$(function(){
|
|
|
2 |
$('.scroll').jscroll({
|
|
|
3 |
loadingHtml: '<center><img src="/img/ajax-loader.gif" alt="Loading" /></center>',
|
|
|
4 |
autoTriggerUntil: 3,
|
|
|
5 |
padding: 20,
|
|
|
6 |
});
|
| 13695 |
anikendra |
7 |
$('.categorytab').on('click','.categorytabcontrol.active',function(){
|
|
|
8 |
$(this).toggleClass('active');
|
|
|
9 |
$('#preferences-'+$(this).data('id')).addClass('hidden');
|
|
|
10 |
$(this).parent().parent().children().find('.savecategorypreferences',0).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
|
|
|
11 |
});
|
|
|
12 |
$('.categorytab').on('click','.editcategorypreferences',function(e){
|
|
|
13 |
var that = $(this);
|
|
|
14 |
$(that).removeClass('editcategorypreferences').addClass('savecategorypreferences').html('Done').addClass('btn-success');
|
|
|
15 |
$('#togglepreferences-'+$(that).data('id')).toggleClass('active');
|
|
|
16 |
$('#preferences-'+$(that).data('id')).removeClass('hidden');
|
|
|
17 |
$('.brandselector').each(function(){
|
|
|
18 |
if($(this).data('catid')==$(that).data('id')){
|
|
|
19 |
$(this).addClass('active');
|
|
|
20 |
}
|
|
|
21 |
});
|
|
|
22 |
});
|
|
|
23 |
$('.categorytab').on('click','.savecategorypreferences',function(e){
|
|
|
24 |
var that = $(this);
|
|
|
25 |
$(that).removeClass('savecategorypreferences').addClass('editcategorypreferences').html('Edit').removeClass('btn-success');
|
|
|
26 |
$('#togglepreferences-'+$(that).data('id')).toggleClass('active');
|
|
|
27 |
$.ajax({
|
|
|
28 |
url: $('#categorypreference-'+$(that).data('id')).attr('action'),
|
|
|
29 |
data: $('#categorypreference-'+$(that).data('id')).serialize(),
|
|
|
30 |
// Tell jQuery we're expecting JSONP
|
|
|
31 |
dataType: "json",
|
|
|
32 |
// Tell YQL what we want and that we want JSON
|
|
|
33 |
method: 'post',
|
|
|
34 |
// Work with the response
|
|
|
35 |
success: function( response ) {
|
|
|
36 |
if(response.success){
|
|
|
37 |
$('#preferences-'+$(that).data('id')).addClass('hidden');
|
|
|
38 |
}
|
|
|
39 |
}
|
|
|
40 |
});
|
|
|
41 |
ga('send', 'event', 'preferences', 'update', me);
|
|
|
42 |
});
|
| 13599 |
anikendra |
43 |
$('.row').on('click','.viewproduct',function(e){
|
| 13686 |
anikendra |
44 |
$('#loadingModal').modal();
|
| 13579 |
anikendra |
45 |
var url = apihost+"clicks/add/"+me+"/"+$(this).data('id');
|
|
|
46 |
$.ajax({
|
|
|
47 |
url: url,
|
|
|
48 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
49 |
jsonp: "callback",
|
|
|
50 |
// Tell jQuery we're expecting JSONP
|
|
|
51 |
dataType: "jsonp",
|
|
|
52 |
// Tell YQL what we want and that we want JSON
|
|
|
53 |
data: {
|
|
|
54 |
format: "json"
|
|
|
55 |
},
|
|
|
56 |
// Work with the response
|
|
|
57 |
success: function( response ) {
|
|
|
58 |
if(response.success && response.type=='redirect'){
|
|
|
59 |
document.location = response.url;
|
|
|
60 |
}
|
|
|
61 |
}
|
|
|
62 |
});
|
| 13686 |
anikendra |
63 |
ga('send', 'event', 'product', 'click', $(this).data('id'));
|
| 13583 |
anikendra |
64 |
});
|
| 13719 |
anikendra |
65 |
$('.jscroll-inner').on('click','.likedeal',function(e){
|
| 13583 |
anikendra |
66 |
var that = $(this);
|
| 13682 |
anikendra |
67 |
if($(that).hasClass('active')){
|
| 13583 |
anikendra |
68 |
//User has already liked it,so remove like
|
|
|
69 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/like";
|
|
|
70 |
}else{
|
|
|
71 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/like";
|
|
|
72 |
}
|
|
|
73 |
$.ajax({
|
|
|
74 |
url: url,
|
|
|
75 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
76 |
jsonp: "callback",
|
|
|
77 |
// Tell jQuery we're expecting JSONP
|
|
|
78 |
dataType: "jsonp",
|
|
|
79 |
// Tell YQL what we want and that we want JSON
|
|
|
80 |
data: {
|
|
|
81 |
format: "json"
|
|
|
82 |
},
|
|
|
83 |
// Work with the response
|
|
|
84 |
success: function( response ) {
|
|
|
85 |
if(response.success){
|
| 13672 |
anikendra |
86 |
$(that).toggleClass('active');
|
|
|
87 |
$(that).parent().find('li.dislikedeal',0).removeClass('active');
|
| 13583 |
anikendra |
88 |
}
|
|
|
89 |
}
|
|
|
90 |
});
|
| 13686 |
anikendra |
91 |
ga('send', 'event', 'product', 'like', $(this).data('id'));
|
| 13583 |
anikendra |
92 |
});
|
| 13688 |
anikendra |
93 |
$('#myModal').on('click','#unlikebtn',function(e){
|
| 13682 |
anikendra |
94 |
e.preventDefault();
|
|
|
95 |
var url = $('#unlikeproductform').attr('action')+'?'+$('#unlikeproductform').serialize()
|
|
|
96 |
console.log(url);
|
|
|
97 |
$.ajax({
|
|
|
98 |
url: url,
|
|
|
99 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
100 |
jsonp: "callback",
|
|
|
101 |
// Tell jQuery we're expecting JSONP
|
|
|
102 |
dataType: "jsonp",
|
|
|
103 |
// Tell YQL what we want and that we want JSON
|
|
|
104 |
data: {
|
|
|
105 |
format: "json"
|
|
|
106 |
},
|
|
|
107 |
// Work with the response
|
|
|
108 |
success: function( response ) {
|
|
|
109 |
// console.log(response);
|
|
|
110 |
}
|
|
|
111 |
});
|
|
|
112 |
$('#myModal').modal('hide');
|
| 13686 |
anikendra |
113 |
ga('send', 'event', 'brand', 'hide', $('#myModal').find('#productToHide',0).val());
|
| 13682 |
anikendra |
114 |
})
|
| 13719 |
anikendra |
115 |
$('.jscroll-inner').on('click','.dislikedeal',function(e){
|
| 13583 |
anikendra |
116 |
var that = $(this);
|
| 13682 |
anikendra |
117 |
if($(that).hasClass('active')){
|
| 13583 |
anikendra |
118 |
//User has already liked it,so remove like
|
|
|
119 |
var url = apihost+"/user_actions/rem/"+me+"/"+$(this).data('id')+"/dislike";
|
|
|
120 |
}else{
|
| 13682 |
anikendra |
121 |
console.log('show modal');
|
|
|
122 |
$('#myModal').find('#productToHide',0).val($(this).data('id'));
|
|
|
123 |
$('#myModal').modal();
|
| 13583 |
anikendra |
124 |
var url = apihost+"/user_actions/update/"+me+"/"+$(this).data('id')+"/dislike";
|
|
|
125 |
}
|
|
|
126 |
$.ajax({
|
|
|
127 |
url: url,
|
|
|
128 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
129 |
jsonp: "callback",
|
|
|
130 |
// Tell jQuery we're expecting JSONP
|
|
|
131 |
dataType: "jsonp",
|
|
|
132 |
// Tell YQL what we want and that we want JSON
|
|
|
133 |
data: {
|
|
|
134 |
format: "json"
|
|
|
135 |
},
|
|
|
136 |
// Work with the response
|
|
|
137 |
success: function( response ) {
|
|
|
138 |
if(response.success){
|
| 13672 |
anikendra |
139 |
$(that).toggleClass('active');
|
|
|
140 |
$(that).parent().find('li.likedeal',0).removeClass('active');
|
| 13583 |
anikendra |
141 |
}
|
|
|
142 |
}
|
|
|
143 |
});
|
| 13686 |
anikendra |
144 |
ga('send', 'event', 'product', 'dislike', $(this).data('id'));
|
| 13583 |
anikendra |
145 |
});
|
| 13731 |
anikendra |
146 |
$('.deletefav').on('click',function(){
|
|
|
147 |
var that = $(this);
|
|
|
148 |
$('#loadingModal').modal();
|
|
|
149 |
var url = apihost+"/user_actions/deletefav/"+me+"/"+$(this).data('id');
|
|
|
150 |
$.ajax({
|
|
|
151 |
url: url,
|
|
|
152 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
153 |
jsonp: "callback",
|
|
|
154 |
// Tell jQuery we're expecting JSONP
|
|
|
155 |
dataType: "jsonp",
|
|
|
156 |
// Tell YQL what we want and that we want JSON
|
|
|
157 |
data: {
|
|
|
158 |
format: "json"
|
|
|
159 |
},
|
|
|
160 |
// Work with the response
|
|
|
161 |
success: function( response ) {
|
|
|
162 |
$('#loadingModal').modal('hide');
|
|
|
163 |
if(response.success){
|
|
|
164 |
$('#fav-'+$(that).data('id')).hide('slow');
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
});
|
|
|
168 |
ga('send', 'event', 'favourites', 'remove', $(this).data('id'));
|
|
|
169 |
});
|
|
|
170 |
$('.clearfavs').on('click',function(){
|
|
|
171 |
var that = $(this);
|
|
|
172 |
$('#loadingModal').modal();
|
|
|
173 |
var url = apihost+"/user_actions/deleteallfavs/"+me;
|
|
|
174 |
$.ajax({
|
|
|
175 |
url: url,
|
|
|
176 |
// The name of the callback parameter, as specified by the YQL service
|
|
|
177 |
jsonp: "callback",
|
|
|
178 |
// Tell jQuery we're expecting JSONP
|
|
|
179 |
dataType: "jsonp",
|
|
|
180 |
// Tell YQL what we want and that we want JSON
|
|
|
181 |
data: {
|
|
|
182 |
format: "json"
|
|
|
183 |
},
|
|
|
184 |
// Work with the response
|
|
|
185 |
success: function( response ) {
|
|
|
186 |
$('#loadingModal').modal('hide');
|
|
|
187 |
if(response.success){
|
|
|
188 |
$('.deletefav').each(function(){
|
|
|
189 |
$('#fav-'+$(this).data('id')).hide('slow');
|
|
|
190 |
})
|
|
|
191 |
}
|
|
|
192 |
$(that).hide();
|
|
|
193 |
}
|
|
|
194 |
});
|
|
|
195 |
ga('send', 'event', 'favourites', 'removeall', me);
|
|
|
196 |
});
|
|
|
197 |
});
|