1/** 2 * 2007-2017 Leotheme 3 * 4 * NOTICE OF LICENSE 5 * 6 * Leo feature for prestashop 1.7: ajax cart, review, compare, wishlist at product list 7 * 8 * DISCLAIMER 9 * 10 * @Module Name: Leo Feature 11 * @author leotheme <[email protected]> 12 * @copyright 2007-2017 Leotheme 13 * @license http://leotheme.com - prestashop template provider 14 */ 15$(document).ready(function(){ 16 if ($('.open-review-form').length) 17 { 18 var id_product = $('.open-review-form').data('id-product'); 19 var is_logged = $('.open-review-form').data('is-logged'); 20 $.ajax({ 21 type: 'POST', 22 headers: {"cache-control": "no-cache"}, 23 url: prestashop.urls.base_url + 'modules/leofeature/psajax_review.php?rand=' + new Date().getTime(), 24 async: true, 25 cache: false, 26 data: { 27 "action": "render-modal-review", 28 "id_product": id_product, 29 "is_logged": is_logged, 30 "token": leo_token 31 }, 32 success: function (result) 33 { 34 if(result != '') 35 { 36 $('body').append(result); 37 activeEventModalReview(); 38 activeStar(); 39 $('.open-review-form').fadeIn('fast'); 40 } 41 else 42 { 43 alert(review_error); 44 } 45 46 }, 47 error: function (XMLHttpRequest, textStatus, errorThrown) { 48 // alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); 49 } 50 }); 51 52 $('.open-review-form').click(function(){ 53 if ($('#criterions_list').length) 54 { 55 $('.leo-modal-review').modal('show'); 56 } 57 else 58 { 59 if ($('.leo-modal-review .modal-body .disable-form-review').length) 60 { 61 $('.leo-modal-review').modal('show'); 62 } 63 else 64 { 65 $('.leo-modal-review-bt').remove(); 66 $('.leo-modal-review .modal-header').remove(); 67 $('.leo-modal-review .modal-body').empty(); 68 $('.leo-modal-review .modal-body').append('<div class="form-group disable-form-review has-danger text-center"><label class="form-control-label">'+disable_review_form_txt+'</label></div>'); 69 $('.leo-modal-review').modal('show'); 70 } 71 72 } 73 return false; 74 }); 75 } 76 77 $('.read-review').click(function(){
78 // if ($('.leo-product-show-review-title').length && $('#leo-product-show-review-content').length) 79 if ($('.leo-product-show-review-title').length) 80 { 81 if ($('.leo-product-show-review-title').hasClass('leofeature-accordion')) 82 { 83 if ($('.leo-product-show-review-title').hasClass('collapsed')) 84 { 85 $('.leo-product-show-review-title').trigger('click'); 86 } 87 var timer = setInterval(function() { 88 if ($('#collapseleofeatureproductreview').hasClass('collapse in') || $('#collapsereviews').hasClass('collapse in')) { 89 //run some other function 90 $('html, body').animate({ 91 scrollTop: $('.leo-product-show-review-title').offset().top 92 }, 500); 93 clearInterval(timer); 94 } 95 }, 200); 96 } 97 else 98 { 99 $('.leo-product-show-review-title').trigger('click'); 100 $('html, body').animate({ 101 scrollTop: $('.leo-product-show-review-title').offset().top 102 }, 500); 103 } 104 } 105 return false; 106 }); 107 108 $('.usefulness_btn').click(function(){ 109 if (!$(this).hasClass('disabled')) 110 { 111 $(this).addClass('active'); 112 $(this).parents('.review_button').find('.usefulness_btn').addClass('disabled'); 113 var id_product_review = $(this).data('id-product-review'); 114 var is_usefull = $(this).data('is-usefull'); 115 var e_parent_button = $(this).parent(); 116 $.ajax({ 117 type: 'POST', 118 headers: {"cache-control": "no-cache"}, 119 url: prestashop.urls.base_url + 'modules/leofeature/psajax_review.php?rand=' + new Date().getTime(), 120 async: true, 121 cache: false, 122 data: { 123 "action": "add-review-usefull", 124 "id_product_review": id_product_review, 125 "is_usefull": is_usefull, 126 "token": leo_token 127 }, 128 success: function (result) 129 { 130 if (result != '') 131 { 132 e_parent_button.fadeOut(function(){ 133 e_parent_button.remove(); 134 }); 135 } 136 else 137 { 138 alert(review_error); 139 } 140 141 }, 142 error: function (XMLHttpRequest, textStatus, errorThrown) { 143 alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); 144 // window.location.replace($('.open-review-form').data('product-link')); 145 } 146 }); 147 } 148 }); 149 150 $('.report_btn').click(function(){ 151 if (!$(this).hasClass('disabled')) 152 { 153 $(this).addClass('disabled'); 154 var e_button = $(this); 155 var id_product_review = $(this).data('id-product-review'); 156 $.ajax({ 157 type: 'POST', 158 headers: {"cache-control": "no-cache"}, 159 url: prestashop.urls.base_url + 'modules/leofeature/psajax_review.php?rand=' + new Date().getTime(), 160 async: true, 161 cache: false, 162 data: { 163 "action": "add-review-report", 164 "id_product_review": id_product_review, 165 "token": leo_token 166 }, 167 success: function (result) 168 { 169 if (result != '') 170 { 171 e_button.fadeOut(function(){ 172 e_button.remove(); 173 }); 174 } 175 else 176 { 177 alert(review_error); 178 } 179 180 }, 181 error: function (XMLHttpRequest, textStatus, errorThrown) { 182 alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); 183 // window.location.replace($('.open-review-form').data('product-link')); 184 } 185 }); 186 } 187 return false; 188 }); 189 190 // activeEventModalReview(); 191 activeStar(); 192}); 193 194function activeStar() 195{ 196 //DONGND:: add txt cancel rating to translate 197 $('input.star').rating({cancel: cancel_rating_txt}); 198 $('.auto-submit-star').rating({cancel: cancel_rating_txt}); 199} 200 201function activeEventModalReview() 202{ 203 $('.form-new-review').submit(function(){ 204 if ($('.new_review_form_content .form-group.leo-has-error').length || $('.leo-fake-button').hasClass('validate-ok')) 205 { 206 return false; 207 } 208 }); 209 $('.leo-modal-review').on('show.bs.modal', function (e) { 210 $('.leo-modal-review-bt').click(function(){ 211 if (!$(this).hasClass('active')) 212 { 213 $(this).addClass('active'); 214 $('.leo-modal-review-bt-text').hide(); 215 $('.leo-modal-review-loading').css({'display':'block'}); 216 217 $('.new_review_form_content input, .new_review_form_content textarea').each(function(){ 218 219 if ($(this).val() == '') 220 { 221 $(this).parent('.form-group').addClass('leo-has-error'); 222 $(this).attr("required", ""); 223 } 224 else 225 { 226 $(this).parent('.form-group').removeClass('leo-has-error'); 227 $(this).removeAttr('required'); 228 } 229 }) 230 231 if ($('.new_review_form_content .form-group.leo-has-error').length) 232 { 233 $(this).removeClass('active'); 234 $('.leo-modal-review-bt-text').show(); 235 $('.leo-modal-review-loading').hide(); 236 } 237 else 238 { 239 // console.log('pass'); 240 // $('.leo-modal-review-bt').remove(); 241 // console.log($( ".new_review_form_content input, .new_review_form_content textarea" ).serialize()); 242 $('.leo-fake-button').addClass('validate-ok'); 243 $.ajax({ 244 type: 'POST', 245 headers: {"cache-control": "no-cache"}, 246 url: prestashop.urls.base_url + 'modules/leofeature/psajax_review.php?action=add-new-review&token='+leo_token+'&rand=' + new Date().getTime(), 247 async: true, 248 cache: false, 249 data: $( ".new_review_form_content input, .new_review_form_content textarea" ).serialize(), 250 success: function (result) 251 { 252 if (result != '') 253 { 254 var object_result = $.parseJSON(result); 255 // console.log(object_result); 256 $('.leo-modal-review-bt').fadeOut('slow', function(){ 257 $(this).remove(); 258 259 }); 260 261 $('.leo-modal-review .modal-body>.row').fadeOut('slow', function(){ 262 $(this).remove(); 263 if (object_result.result) 264 { 265 $('.leo-modal-review .modal-body').append('<div class="form-group has-success"><label class="form-control-label">'+object_result.sucess_mess+'</label></div>'); 266 } 267 else 268 { 269 // $('.leo-modal-review .modal-body').append('<div class="form-group has-danger text-center"></div>'); 270 $.each(object_result.errors, function(key, val){ 271 $('.leo-modal-review .modal-body').append('<div class="form-group has-danger text-center"><label class="form-control-label">'+val+'</label></div>'); 272 }); 273 } 274 }); 275 } 276 else 277 { 278 alert(review_error); 279 } 280 281 }, 282 error: function (XMLHttpRequest, textStatus, errorThrown) { 283 alert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); 284 window.location.replace($('.open-review-form').data('product-link')); 285 } 286 }); 287 } 288 $('.leo-fake-button').trigger('click'); 289 } 290 291 }) 292 }) 293 294 $('.leo-modal-review').on('hide.bs.modal', function (e) { 295 // console.log($('.leo-modal-review-bt').length); 296 if (!$('.leo-modal-review-bt').length && !$('.leo-modal-review .modal-body .disable-form-review').length) 297 { 298 // console.log('aaa'); 299 // window.location.replace($('.open-review-form').data('product-link')); 300 location.reload(); 301 302 } 303 }) 304 305} 306
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.