1/* 2* 2007-2014 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-2014 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 blockHover(); 39 if (typeof quickView !== 'undefined' && quickView) 40 quick_view(); 41 dropDown(); 42 43 if (typeof page_name != 'undefined' && !in_array(page_name, ['index', 'product'])) 44 { 45 bindGrid(); 46 47 $(document).on('change', '.selectProductSort', function(e){ 48 if (typeof request != 'undefined' && request) 49 var requestSortProducts = request; 50 var splitData = $(this).val().split(':'); 51 if (typeof requestSortProducts != 'undefined' && requestSortProducts) 52 document.location.href = requestSortProducts + ((requestSortProducts.indexOf('?') < 0) ? '?' : '&') + 'orderby=' + splitData[0] + '&orderway=' + splitData[1]; 53 }); 54 55 $(document).on('change', 'select[name="n"]', function(){ 56 $(this.form).submit(); 57 }); 58 59 $(document).on('change', 'select[name="manufacturer_list"], select[name="supplier_list"]', function() { 60 if (this.value != '') 61 location.href = this.value; 62 }); 63 64 $(document).on('change', 'select[name="currency_payement"]', function(){ 65 setCurrency($(this).val()); 66 }); 67 } 68 69 $(document).on('click', '.back', function(e){ 70 e.preventDefault(); 71 history.back(); 72 }); 73 74 jQuery.curCSS = jQuery.css; 75 if (!!$.prototype.cluetip) 76 $('a.cluetip').cluetip({ 77 local:true, 78 cursor: 'pointer', 79 dropShadow: false, 80 dropShadowSteps: 0, 81 showTitle: false, 82 tracking: true, 83 sticky: false, 84 mouseOutClose: true, 85 fx: { 86 open: 'fadeIn', 87 openSpeed: 'fast' 88 } 89 }).css('opacity', 0.8); 90 91 if (!!$.prototype.fancybox) 92 $.extend($.fancybox.defaults.tpl, { 93 closeBtn : '<a title="' + FancyboxI18nClose + '" class="fancybox-item fancybox-close" href="javascript:;"></a>', 94 next : '<a title="' + FancyboxI18nNext + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>', 95 prev : '<a title="' + FancyboxI18nPrev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>' 96 }); 97 98 99 if ($('#nq_menu_list').is(':empty')){ 100 $('#block_top_menu .sf-menu.menu-content').clone(true).appendTo('#nq_menu_list'); 101 $('.cart_block.block.exclusive .block_content').clone(true).appendTo('#nq_cart'); 102 } 103 104 $('#nq_mobile_sticky').off('click').click(function(e) { 105 var clicked_element = (e.target.dataset.target) ? e.target : 106 ( (e.target.parentElement.dataset.target) ? e.target.parentElement : null ) ; 107 108 if (clicked_element) { 109 var target = document.getElementById(clicked_element.dataset.target); 110 111 if(target.classList.contains('nq-extended')) { 112 target.classList.remove('nq-extended'); 113 } else { 114 if( $('.nq-extended').length === 0) { 115 target.classList.add('nq-extended'); 116 } else { 117 $('.nq-extended').removeClass('nq-extended'); 118 119 //setTimeout(function() { 120 target.classList.add('nq-extended'); 121 //}, 250); 122 } 123 } 124 } 125 }); 126 127 $('#nq_current_language').click(function(){ 128 $('#nq_languagues_list').toggleClass('nq-language-extended'); 129 }); 130 131 window.onscroll = function() {nq_scroll()}; 132 133 var nq_menu = document.getElementById("nq_mobile_sticky_wrapper"); 134 var nq_sticky = nq_menu.offsetTop; 135 136 function nq_scroll() { 137 if (window.pageYOffset > nq_sticky) 138 nq_menu.classList.add("nq_sticky"); 139 else 140 nq_menu.classList.remove("nq_sticky"); 141 } 142}); 143 144function highdpiInit() 145{ 146 if($('.replace-2x').css('font-size') == "1px") 147 { 148 var els = $("img.replace-2x").get(); 149 for(var i = 0; i < els.length; i++) 150 { 151 src = els[i].src; 152 extension = src.substr( (src.lastIndexOf('.') +1) ); 153 src = src.replace("." + extension, "2x." + extension); 154 155 var img = new Image(); 156 img.src = src; 157 img.height != 0 ? els[i].src = src : els[i].src = els[i].src; 158 } 159 } 160} 161 162function responsiveResize() 163{ 164 if ($(document).width() <= 767 && responsiveflag == false) 165 { 166 accordion('enable'); 167 accordionFooter('enable'); 168 responsiveflag = true; 169 } 170 else if ($(document).width() >= 768) 171 { 172 accordion('disable'); 173 accordionFooter('disable'); 174 responsiveflag = false;
175 } 176 if (typeof page_name != 'undefined' && in_array(page_name, ['category'])) 177 resizeCatimg(); 178} 179 180function blockHover(status) 181{ 182 $(document).off('mouseenter').on('mouseenter', '.product_list.grid li.ajax_block_product .product-container', function(e){ 183 184 if ($('body').find('.container').width() == 1170) 185 { 186 var pcHeight = $(this).parent().outerHeight(); 187 var pcPHeight = $(this).parent().find('.button-container').outerHeight() + $(this).parent().find('.comments_note').outerHeight() + $(this).parent().find('.functional-buttons').outerHeight(); 188 $(this).parent().addClass('hovered').css({'height':pcHeight + pcPHeight, 'margin-bottom':pcPHeight * (-1)}); 189 } 190 }); 191 192 $(document).off('mouseleave').on('mouseleave', '.product_list.grid li.ajax_block_product .product-container', function(e){ 193 if ($('body').find('.container').width() == 1170) 194 $(this).parent().removeClass('hovered').css({'height':'auto', 'margin-bottom':'0'}); 195 }); 196} 197 198function quick_view() 199{ 200 $(document).on('click', '.quick-view:visible, .quick-view-mobile:visible', function(e) 201 { 202 e.preventDefault(); 203 var url = this.rel; 204 if (url.indexOf('?') != -1) 205 url += '&'; 206 else 207 url += '?'; 208 209 if (!!$.prototype.fancybox) 210 $.fancybox({ 211 'padding': 0, 212 'width': 1087, 213 'height': 610, 214 'type': 'iframe', 215 'href': url + 'content_only=1' 216 }); 217 }); 218} 219 220function bindGrid() 221{ 222 var view = $.totalStorage('display'); 223 224 if (!view && (typeof displayList != 'undefined') && displayList) 225 view = 'list'; 226 227 if (view && view != 'grid') 228 display(view); 229 else 230 $('.display').find('li#grid').addClass('selected'); 231 232 $(document).on('click', '#grid', function(e){ 233 e.preventDefault(); 234 display('grid'); 235 }); 236 237 $(document).on('click', '#list', function(e){ 238 e.preventDefault(); 239 display('list'); 240 }); 241} 242 243function display(view) 244{ 245 if (view == 'list') 246 { 247 $('ul.product_list').removeClass('grid').addClass('list row'); 248 $('.product_list > li').removeClass('col-xs-12 col-sm-6 col-md-4').addClass('col-xs-12'); 249 $('.product_list > li').each(function(index, element) { 250 html = ''; 251 html = '<div class="product-container"><div class="row">'; 252 html += '<div class="left-block col-xs-4 col-xs-5 col-md-4">' + $(element).find('.left-block').html() + '</div>'; 253 html += '<div class="center-block col-xs-4 col-xs-7 col-md-4">'; 254 html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>'; 255 html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>'; 256 var rating = $(element).find('.comments_note').html(); // check : rating 257 if (rating != null) { 258 html += '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>'; 259 } 260 html += '<p class="product-desc">'+ $(element).find('.product-desc').html() + '</p>'; 261 var colorList = $(element).find('.color-list-container').html(); 262 if (colorList != null) { 263 html += '<div class="color-list-container">'+ colorList +'</div>'; 264 } 265 var availability = $(element).find('.availability').html(); // check : catalog mode is enabled 266 if (availability != null) { 267 html += '<span class="availability">'+ availability +'</span>'; 268 } 269 html += '</div>'; 270 html += '<div class="right-block col-xs-4 col-xs-12 col-md-4"><div class="right-block-content row">'; 271 var price = $(element).find('.content_price').html(); // check : catalog mode is enabled 272 if (price != null) { 273 html += '<div class="content_price col-xs-5 col-md-12">'+ price + '</div>'; 274 } 275 html += '<div class="button-container col-xs-7 col-md-12">'+ $(element).find('.button-container').html() +'</div>'; 276 html += '<div class="functional-buttons clearfix col-sm-12">' + $(element).find('.functional-buttons').html() + '</div>'; 277 html += '</div>'; 278 html += '</div></div>'; 279 $(element).html(html); 280 }); 281 $('.display').find('li#list').addClass('selected'); 282 $('.display').find('li#grid').removeAttr('class'); 283 $.totalStorage('display', 'list'); 284 } 285 else 286 { 287 $('ul.product_list').removeClass('list').addClass('grid row'); 288 $('.product_list > li').removeClass('col-xs-12').addClass('col-xs-12 col-sm-6 col-md-4'); 289 $('.product_list > li').each(function(index, element) { 290 html = ''; 291 html += '<div class="product-container">'; 292 html += '<div class="left-block">' + $(element).find('.left-block').html() + '</div>'; 293 html += '<div class="right-block">'; 294 html += '<div class="product-flags">'+ $(element).find('.product-flags').html() + '</div>'; 295 html += '<h5 itemprop="name">'+ $(element).find('h5').html() + '</h5>'; 296 var rating = $(element).find('.comments_note').html(); // check : rating 297 if (rating != null) { 298 html += '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" class="comments_note">'+ rating + '</div>'; 299 } 300 html += '<p itemprop="description" class="product-desc">'+ $(element).find('.product-desc').html() + '</p>'; 301 var price = $(element).find('.content_price').html(); // check : catalog mode is enabled 302 if (price != null) { 303 html += '<div class="content_price">'+ price + '</div>'; 304 } 305 html += '<div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="button-container">'+ $(element).find('.button-container').html() +'</div>'; 306 var colorList = $(element).find('.color-list-container').html(); 307 if (colorList != null) { 308 html += '<div class="color-list-container">'+ colorList +'</div>'; 309 } 310 var availability = $(element).find('.availability').html(); // check : catalog mode is enabled 311 if (availability != null) { 312 html += '<span class="availability">'+ availability +'</span>'; 313 } 314 html += '</div>'; 315 html += '<div class="functional-buttons clearfix">' + $(element).find('.functional-buttons').html() + '</div>'; 316 html += '</div>'; 317 $(element).html(html); 318 }); 319 $('.display').find('li#grid').addClass('selected'); 320 $('.display').find('li#list').removeAttr('class'); 321 $.totalStorage('display', 'grid'); 322 } 323} 324 325function dropDown() 326{ 327 elementClick = '#header .current'; 328 elementSlide = 'ul.toogle_content'; 329 activeClass = 'active'; 330 331 $(elementClick).on('click', function(e){ 332 e.stopPropagation(); 333 var subUl = $(this).next(elementSlide); 334 if(subUl.is(':hidden')) 335 { 336 subUl.slideDown(); 337 $(this).addClass(activeClass); 338 } 339 else 340 { 341 subUl.slideUp(); 342 $(this).removeClass(activeClass); 343 } 344 $(elementClick).not(this).next(elementSlide).slideUp(); 345 $(elementClick).not(this).removeClass(activeClass); 346 e.preventDefault(); 347 }); 348 349 $(elementSlide).on('click', function(e){ 350 e.stopPropagation(); 351 }); 352 353 $(document).on('click', function(e){ 354 e.stopPropagation(); 355 var elementHide = $(elementClick).next(elementSlide); 356 $(elementHide).slideUp(); 357 $(elementClick).removeClass('active'); 358 }); 359} 360 361function accordionFooter(status) 362{ 363 if(status == 'enable') 364 { 365 $('#footer .footer-block h4').on('click', function(){ 366 $(this).toggleClass('active').parent().find('.toggle-footer').stop().slideToggle('medium'); 367 }) 368 $('#footer').addClass('accordion').find('.toggle-footer').slideUp('fast'); 369 } 370 else 371 { 372 $('.footer-block h4').removeClass('active').off().parent().find('.toggle-footer').removeAttr('style').slideDown('fast'); 373 $('#footer').removeClass('accordion'); 374 } 375} 376 377function accordion(status) 378{ 379 leftColumnBlocks = $('#left_column'); 380 if(status == 'enable') 381 { 382 $('#right_column .block .title_block, #left_column .block .title_block, #left_column #newsletter_block_left h4').on('click', function(){ 383 $(this).toggleClass('active').parent().find('.block_content').stop().slideToggle('medium'); 384 }) 385 $('#right_column, #left_column').addClass('accordion').find('.block .block_content').slideUp('fast'); 386 } 387 else 388 { 389 $('#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'); 390 $('#left_column, #right_column').removeClass('accordion'); 391 } 392} 393 394function resizeCatimg() 395{ 396 var div = $('.cat_desc').parent('div'); 397 var image = new Image; 398 $(image).load(function(){ 399 var width = image.width; 400 var height = image.height; 401 var ratio = parseFloat(height / width); 402 var calc = Math.round(ratio * parseInt(div.outerWidth(false))); 403 div.css('min-height', calc); 404 }); 405 if (div.length) 406 image.src = div.css('background-image').replace(/url\("?|"?\)$/ig, ''); 407}
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.