1/* 2* 2007-2015 PrestaShop 3* 4* NOTICE OF LICENSE 5* 6* This source file is subject to the Academic Free License (AFL 3.0) 7* that is bundled with this package in the file LICENSE.txt. 8* It is also available through the world-wide-web at this URL: 9* http://opensource.org/licenses/afl-3.0.php 10* If you did not receive a copy of the license and are unable to 11* obtain it through the world-wide-web, please send an email 12* to [email protected] so we can send you a copy immediately. 13* 14* DISCLAIMER 15* 16* Do not edit or add to this file if you wish to upgrade PrestaShop to newer 17* versions in the future. If you wish to customize PrestaShop for your 18* needs please refer to http://www.prestashop.com for more information. 19* 20* @author PrestaShop SA <[email protected]> 21* @copyright 2007-2015 PrestaShop SA 22* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) 23* International Registered Trademark & Property of PrestaShop SA 24*/ 25//global variables 26var responsiveflag = false; 27 28$(document).ready(function(){ 29 highdpiInit(); 30 responsiveResize(); 31 $(window).resize(responsiveResize); 32 if (navigator.userAgent.match(/Android/i)) 33 { 34 var viewport = document.querySelector('meta[name="viewport"]'); 35 viewport.setAttribute('content', 'initial-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width,height=device-height'); 36 window.scrollTo(0, 1); 37 } 38 if (typeof quickView !== 'undefined' && quickView) 39 quick_view(); 40 dropDown(); 41 42 if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product'])) 43 { 44 bindGrid(); 45 46 $(document).on('change', '.selectProductSort', function(e){ 47 if (typeof request != 'undefined' && request) 48 var requestSortProducts = request; 49 var splitData = $(this).val().split(':'); 50 var url = ''; 51 if (typeof requestSortProducts != 'undefined' && requestSortProducts) 52 { 53 url += requestSortProducts ; 54 if (typeof splitData[0] !== 'undefined' && splitData[0]) 55 { 56 url += ( requestSortProducts.indexOf('?') < 0 ? '?' : '&') + 'orderby=' + splitData[0] + (splitData[1] ? '&orderway=' + splitData[1] : ''); 57 if (typeof splitData[1] !== 'undefined' && splitData[1]) 58 url += '&orderway=' + splitData[1]; 59 } 60 document.location.href = url; 61 } 62 }); 63 64 $(document).on('change', 'select[name="n"]', function(){ 65 $(this.form).submit(); 66 }); 67 68 $(document).on('change', 'select[name="currency_payment"]', function(){ 69 setCurrency($(this).val()); 70 }); 71 } 72 73 $(document).on('change', 'select[name="manufacturer_list"], select[name="supplier_list"]', function(){ 74 if (this.value != '') 75 location.href = this.value; 76 }); 77 78 $(document).on('click', '.back', function(e){ 79 e.preventDefault(); 80 history.back(); 81 }); 82 83 jQuery.curCSS = jQuery.css; 84 if (!!$.prototype.cluetip) 85 $('a.cluetip').cluetip({ 86 local:true, 87 cursor: 'pointer', 88 dropShadow: false, 89 dropShadowSteps: 0, 90 showTitle: false, 91 tracking: true, 92 sticky: false, 93 mouseOutClose: true, 94 fx: { 95 open: 'fadeIn', 96 openSpeed: 'fast' 97 } 98 }).css('opacity', 0.8); 99 100 if (!!$.prototype.fancybox) 101 $.extend($.fancybox.defaults.tpl, { 102 closeBtn : '<a title="' + FancyboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>', 103 next : '<a title="' + FancyboxI18nNext + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>', 104 prev : '<a title="' + FancyboxI18nPrev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>' 105 }); 106 107 // Close Alert messages 108 $(".alert.alert-danger").on('click', this, function(e){ 109 if (e.offsetX >= 16 && e.offsetX <= 39 && e.offsetY >= 16 && e.offsetY <= 34) 110 $(this).fadeOut(); 111 }); 112}); 113 114function highdpiInit() 115{ 116 if($('.replace-2x').css('font-size') == "1px") 117 { 118 var els = $("img.replace-2x").get(); 119 for(var i = 0; i < els.length; i++) 120 { 121 src = els[i].src; 122 extension = src.substr( (src.lastIndexOf('.') +1) ); 123 src = src.replace("." + extension, "2x." + extension); 124 125 var img = new Image(); 126 img.src = src; 127 img.height != 0 ? els[i].src = src : els[i].src = els[i].src; 128 } 129 } 130} 131 132 133// Used to compensante Chrome/Safari bug (they don't care about scroll bar for width)
134function scrollCompensate() 135{ 136 var inner = document.createElement('p'); 137 inner.style.width = "100%"; 138 inner.style.height = "200px"; 139 140 var outer = document.createElement('div'); 141 outer.style.position = "absolute"; 142 outer.style.top = "0px"; 143 outer.style.left = "0px"; 144 outer.style.visibility = "hidden"; 145 outer.style.width = "200px"; 146 outer.style.height = "150px"; 147 outer.style.overflow = "hidden"; 148 outer.appendChild(inner); 149 150 document.body.appendChild(outer); 151 var w1 = inner.offsetWidth; 152 outer.style.overflow = 'scroll'; 153 var w2 = inner.offsetWidth; 154 if (w1 == w2) w2 = outer.clientWidth; 155 156 document.body.removeChild(outer); 157 158 return (w1 - w2); 159} 160 161function responsiveResize() 162{ 163 compensante = scrollCompensate(); 164 if (($(window).width()+scrollCompensate()) <= 767 && responsiveflag == false) 165 { 166 accordion('enable'); 167 accordionFooter('enable'); 168 responsiveflag = true; 169 } 170 else if (($(window).width()+scrollCompensate()) >= 768) 171 { 172 accordion('disable'); 173 accordionFooter('disable'); 174 responsiveflag = false; 175 } 176 blockHover(); 177} 178 179function blockHover(status) 180{ 181 var screenLg = $('body').find('.container').width() == 1170; 182 183 if ($('.product_list').is('.grid')) 184 if (screenLg) 185 $('.product_list .button-container').hide(); 186 else 187 $('.product_list .button-container').show(); 188 189 $(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function(e){ 190 if (screenLg) 191 { 192 var pcHeight = $(this).parent().outerHeight(); 193 var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight(); 194 $(this).parent().addClass('hovered').css({'height':pcHeight + pcPHeight, 'margin-bottom':pcPHeight * (-1)}); 195 $(this).find('.button-container').show(); 196 } 197 }); 198 199 $(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function(e){ 200 if (screenLg) 201 { 202 $(this).parent().removeClass('hovered').css({'height':'auto', 'margin-bottom':'0'}); 203 $(this).find('.button-container').hide(); 204 } 205 }); 206} 207 208function quick_view() 209{ 210 $(document).on('click', '.quick-view:visible, .quick-view-mobile:visible', function(e){ 211 e.preventDefault(); 212 var url = this.rel; 213 var anchor = ''; 214 215 if (url.indexOf('#') != -1) 216 { 217 anchor = url.substring(url.indexOf('#'), url.length); 218 url = url.substring(0, url.indexOf('#')); 219 } 220 221 if (url.indexOf('?') != -1) 222 url += '&'; 223 else 224 url += '?'; 225 226 if (!!$.prototype.fancybox) 227 $.fancybox({ 228 'padding': 0, 229 'width': 1087, 230 'height': 610, 231 'type': 'iframe', 232 'href': url + 'content_only=1' + anchor 233 }); 234 }); 235} 236 237function bindGrid() 238{ 239 var view = $.totalStorage('display'); 240 241 if (!view && (typeof displayList != 'undefined') && displayList) 242 view = 'list'; 243 244 if (view && view != 'grid') 245 display(view); 246 else 247 $('.display').find('li#grid').addClass('selected'); 248 249 $(document).on('click', '#grid', function(e){ 250 e.preventDefault(); 251 display('grid'); 252 }); 253 254 $(document).on('click', '#list', function(e){ 255 e.preventDefault(); 256 display('list'); 257 }); 258} 259 260function display(view) 261{ 262 if (view == 'list') 263 { 264 $('ul.product_list').removeClass('grid').addClass('list row'); 265 $('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-4').addClass('col-xs-12'); 266 $('.product_list > li').each(function(index, element) { 267 html = ''; 268 html = '<div class="product-container"><div class="row">'; 269 html += '<div class="left-block col-xs-4 col-xs-5 col-md-4">' + $(element).find('.left-block').html() + '</div>'; 270 html += '<div class="center-block col-xs-4 col-xs-7 col-md-4">'; 271 html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>'; 272 html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>'; 273 var rating = $(element).find('.comments_note').html(); // check : rating 274 if (rating != null) { 275 html += '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>'; 276 } 277 html += '<p class="product-desc">'+ $(element).find('.product-desc').html() + '</p>'; 278 var colorList = $(element).find('.color-list-container').html(); 279 if (colorList != null) { 280 html += '<div class="color-list-container">'+ colorList +'</div>'; 281 } 282 var availability = $(element).find('.availability').html(); // check : catalog mode is enabled 283 if (availability != null) { 284 html += '<span class="availability">'+ availability +'</span>'; 285 } 286 html += '</div>'; 287 html += '<div class="right-block col-xs-4 col-xs-12 col-md-4"><div class="right-block-content row">'; 288 var price = $(element).find('.content_price').html(); // check : catalog mode is enabled 289 if (price != null) { 290 html += '<div class="content_price col-xs-5 col-md-12">'+ price + '</div>'; 291 } 292 html += '<div class="button-container col-xs-7 col-md-12">'+ $(element).find('.button-container').html() +'</div>'; 293 html += '<div class="functional-buttons clearfix col-sm-12">' + $(element).find('.functional-buttons').html() + '</div>'; 294 html += '</div>'; 295 html += '</div></div>'; 296 $(element).html(html); 297 }); 298 $('.display').find('li#list').addClass('selected'); 299 $('.display').find('li#grid').removeAttr('class'); 300 $.totalStorage('display', 'list'); 301 } 302 else 303 { 304 $('ul.product_list').removeClass('list').addClass('grid row'); 305 $('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-4'); 306 $('.product_list > li').each(function(index, element) { 307 html = ''; 308 html += '<div class="product-container">'; 309 html += '<div class="left-block">' + $(element).find('.left-block').html() + '</div>'; 310 html += '<div class="right-block">'; 311 html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>'; 312 html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>'; 313 var rating = $(element).find('.comments_note').html(); // check : rating 314 if (rating != null) { 315 html += '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>'; 316 } 317 html += '<p itemprop="description" class="product-desc">'+ $(element).find('.product-desc').html() + '</p>'; 318 var price = $(element).find('.content_price').html(); // check : catalog mode is enabled 319 if (price != null) { 320 html += '<div class="content_price">'+ price + '</div>'; 321 } 322 html += '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="button-container">'+ $(element).find('.button-container').html() +'</div>'; 323 var colorList = $(element).find('.color-list-container').html(); 324 if (colorList != null) { 325 html += '<div class="color-list-container">'+ colorList +'</div>'; 326 } 327 var availability = $(element).find('.availability').html(); // check : catalog mode is enabled 328 if (availability != null) { 329 html += '<span class="availability">'+ availability +'</span>'; 330 } 331 html += '</div>'; 332 html += '<div class="functional-buttons clearfix">' + $(element).find('.functional-buttons').html() + '</div>'; 333 html += '</div>'; 334 $(element).html(html); 335 }); 336 $('.display').find('li#grid').addClass('selected'); 337 $('.display').find('li#list').removeAttr('class'); 338 $.totalStorage('display', 'grid'); 339 } 340} 341 342function dropDown() 343{ 344 elementClick = '#header .current'; 345 elementSlide = 'ul.toogle_content'; 346 activeClass = 'active'; 347 348 $(elementClick).on('click', function(e){ 349 e.stopPropagation(); 350 var subUl = $(this).next(elementSlide); 351 if(subUl.is(':hidden')) 352 { 353 subUl.slideDown(); 354 $(this).addClass(activeClass); 355 } 356 else 357 { 358 subUl.slideUp(); 359 $(this).removeClass(activeClass); 360 } 361 $(elementClick).not(this).next(elementSlide).slideUp(); 362 $(elementClick).not(this).removeClass(activeClass); 363 e.preventDefault(); 364 }); 365 366 $(elementSlide).on('click', function(e){ 367 e.stopPropagation(); 368 }); 369 370 $(document).on('click', function(e){ 371 e.stopPropagation(); 372 var elementHide = $(elementClick).next(elementSlide); 373 $(elementHide).slideUp(); 374 $(elementClick).removeClass('active'); 375 }); 376} 377 378function accordionFooter(status) 379{ 380 if(status == 'enable') 381 { 382 $('#footer .footer-block h4').on('click', function(){ 383 $(this).toggleClass('active').parent().find('.toggle-footer').stop().slideToggle('medium'); 384 }) 385 $('#footer').addClass('accordion').find('.toggle-footer').slideUp('fast'); 386 } 387 else 388 { 389 $('.footer-block h4').removeClass('active').off().parent().find('.toggle-footer').removeAttr('style').slideDown('fast'); 390 $('#footer').removeClass('accordion'); 391 } 392} 393 394function accordion(status) 395{ 396 leftColumnBlocks = $('#left_column'); 397 if(status == 'enable') 398 { 399 var accordion_selector = '#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4,' + 400 '#left_column .shopping_cart > a:first-child, #right_column .shopping_cart > a:first-child'; 401 402 $(accordion_selector).on('click', function(e){ 403 $(this).toggleClass('active').parent().find('.block_content').stop().slideToggle('medium'); 404 }); 405 $('#right_column, #left_column').addClass('accordion').find('.block .block_content').slideUp('fast'); 406 if (typeof(ajaxCart) !== 'undefined') 407 ajaxCart.collapse(); 408 } 409 else 410 { 411 $('#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4').removeClass('active').off().parent().find('.block_content').removeAttr('style').slideDown('fast'); 412 $('#left_column, #right_column').removeClass('accordion'); 413 } 414}
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.