1$(document).ready(function () { 2 3 //SLIDERS 4 var sslider_wrap = $('.sslider_wrap'); 5 if (typeof(sslider_mode) != 'undefined' && sslider_wrap.length) { 6 sslider_wrap.sslider({ 7 time: 2000, 8 loader: 'none', 9 overlayer: true, 10 //height: 'auto', 11 fx: sslider_mode ? sslider_mode : 'random', 12 onEndTransition: function() { 13 $('.sslider_wrap .sslider_caption').css('top', '-350px'); 14 var idx = $('.sslider_wrap .sslider_target .ssliderSlide.sslidercurrent').index(); 15 $('.sslider_wrap .sslider_caption:eq(' + idx + ')').animate({ top: 0 }, 300); // .css('top', 0); 16 } 17 }); 18 } 19 $('.homepage-bxslider li:eq(0)').find('.bx-details-wrap').css('top', 0); 20 $('.homepage-bxslider').bxSlider({ 21 auto: $('.homepage-bxslider li').length > 1, pause: 5000, autoHover: true, pager:$('.homepage-bxslider li').length > 1, 22 onSlideAfter: function(el, old_index) { 23 $('.homepage-bxslider .bx-details-wrap').css('top', '-350px'); 24 $(el).find('.bx-details-wrap').css('top', 0); //animate({ top: 0 }, 300); 25 } 26 }); 27 $('.homepage-bxslider').css('height','auto'); 28 $('.related-bxslider').bxSlider( { minSlides: 1, maxSlides: 4, slideWidth: 150, slideMargin: 10, infiniteLoop: false, pager: false }); 29 30 var offers = $('.special-offers'); 31 for (var i=0; i<offers.length; i++) { 32 var outer = $(offers[i]), inner = outer.find('li'), outer_width = outer.width(), inner_width = ($(inner[0]).width() + 20) * inner.length; 33 if (inner_width > outer_width) { 34 outer.prev().prepend('<div class="offers-ctrl"><a class="offers-btn next"></a><a class="offers-btn prev disabled"></a></div>'); 35 } 36 } 37 $('.offers-btn').click(function() { 38 var outer = $(this).parent().parent().next(), inner = outer.find('li'), outer_width = outer.width(), inner_width = $(inner[0]).width(), 39 off = Math.floor(outer_width / inner_width) * inner_width, scrollLeft = outer.scrollLeft(); 40 if ($(this).hasClass('next')) { 41 outer.animate({scrollLeft: scrollLeft + off}); 42 if (scrollLeft + off >= outer_width) { 43 $(this).addClass('disabled'); 44 } 45 $('.offers-btn.prev').removeClass('disabled'); 46 } else { 47 outer.animate({scrollLeft: scrollLeft - off}); 48 if (scrollLeft - off <= 0) { 49 $(this).addClass('disabled'); 50 } 51 $('.offers-btn.next').removeClass('disabled'); 52 } 53 }); 54 55 // countdown 56 if ($.fn.countdowntimer) { 57 $('.js-promo-countdown').each(function () { 58 var $this = $(this).html(''); 59 var id = ($this.attr('id') || 'js-promo-countdown' + ('' + Math.random()).slice(2)); 60 $this.attr('id', id); 61 var start = $this.data('start').replace(/-/g, '/'); 62 var end = $this.data('end').replace(/-/g, '/'); 63 $this.countdowntimer({ 64 startDate: start, 65 dateAndTime: end, 66 size: 'md' 67 }); 68 }); 69 } 70 71 /* 72 // SIDEBAR HEADER click 73 // on devices without :hover event (handheld tablets such as iPad + smartphones) clicking on the sidebar header link should show/hide the sidebar, not follow the link 74 if ( (!!('ontouchstart' in window)) && MatchMedia("only screen and (max-width: 1024px)") ) { 75 { 76 $('.nav-sidebar-body').css('opacity',1); 77 $('.nav-sidebar-body').hide(); 78 $('a.nav-sidebar-header').click(function(){ 79 { 80 $('.nav-sidebar-body').slideToggle(200); 81 return false; 82 } 83 }); 84 } 85 */ 86 87 //CART dialog for multi-SKU products 88 $('.dialog').on('click', 'a.dialog-close', function () { 89 $(this).closest('.dialog').hide().find('.cart').empty(); 90 return false; 91 }); 92 $(document).keyup(function(e) { 93 if (e.keyCode == 27) { 94 $(".dialog:visible").hide().find('.cart').empty(); 95 } 96 }); 97 98 // COMPARE 99 $(".container").on('click', '.product-list a.compare', function () { 100 var compare = $.cookie('shop_compare'); 101 $.cookie('shop_compare', compare, { expires: 30, path: '/'}); 102 103 if (!$(this).find('i').hasClass('active')) { 104 if (compare) { 105 compare += ',' + $(this).data('product'); 106 } else { 107 compare = '' + $(this).data('product'); 108 } 109 if (compare.split(',').length > 0) { 110 if (!$('#compare-leash').is(":visible")) { 111 $('#compare-leash').css('height', 0).show().animate({height: 39},function(){ 112 var _blinked = 0; 113 setInterval(function(){ 114 if (_blinked < 4) 115 $("#compare-leash a").toggleClass("just-added"); 116 _blinked++; 117 },500); 118 }); 119 } 120 var url = $("#compare-leash a").attr('href').replace(/compare\/.*$/, 'compare/' + compare + '/'); 121 $('#compare-leash a').attr('href', url).show().find('strong').html(compare.split(',').length); 122 } else { 123 $('#compare-leash').hide(); 124 } 125 $.cookie('shop_compare', compare, { expires: 30, path: '/'}); 126 } else { 127 if (compare) { 128 compare = compare.split(','); 129 } else { 130 compare = []; 131 } 132 var i = $.inArray($(this).data('product') + '', compare); 133 if (i != -1) { 134 compare.splice(i, 1) 135 } 136 if (compare.length > 0) { 137 $.cookie('shop_compare', compare.join(','), { expires: 30, path: '/'}); 138 var url = $("#compare-leash a").attr('href').replace(/compare\/.*$/, 'compare/' + compare.join(',') + '/'); 139 $('#compare-leash a').attr('href', url).show().find('strong').html(compare.length); 140 } else { 141 $('#compare-leash').hide(); 142 $.cookie('shop_compare', null, {path: '/'}); 143 } 144 } 145 $(this).find('i').toggleClass('active'); 146 return false;
147 }); 148 149 //ADD TO CART 150 $(".container").on('submit', '.product-list form.addtocart', function () { 151 var f = $(this); 152 f.find('.adding2cart').addClass('icon16 loading').show(); 153 if (f.data('url')) { 154 var d = $('#dialog'); 155 var c = d.find('.cart'); 156 c.load(f.data('url'), function () { 157 f.find('.adding2cart').hide(); 158 c.prepend('<a href="#" class="dialog-close">×</a>'); 159 d.show(); 160 if ((c.height() > c.find('form').height())) { 161 c.css('bottom', 'auto'); 162 } else { 163 c.css('bottom', '15%'); 164 } 165 }); 166 return false; 167 } 168 $.post(f.attr('action') + '?html=1', f.serialize(), function (response) { 169 f.find('.adding2cart').hide(); 170 171 if (response.status == 'ok') { 172 173 var cart_total = $(".cart-total"); 174 cart_total.closest('#cart').removeClass('empty'); 175 if( $(window).scrollTop() >= 110 ) 176 $('#cart').addClass('fixed'); 177 178 if (MatchMedia("only screen and (max-width: 760px)")) { 179 180 // mobile: show "added to cart" message 181 f.find('input[type="submit"]').hide(); 182 f.find('.price').hide(); 183 f.find('span.added2cart').show(); 184 cart_total.html(response.data.total); 185 $('#cart-content').append($('<div class="cart-just-added"></div>').html(f.find('span.added2cart').text())); 186 if ($('#cart').hasClass('fixed')) 187 $('.cart-to-checkout').hide(); 188 } else { 189 190 // flying cart 191 var origin = f.closest('li'); 192 var block = $('<div></div>').append(origin.html()); 193 block.css({ 194 'z-index': 100500, 195 background: '#fff', 196 top: origin.offset().top, 197 left: origin.offset().left, 198 width: origin.width()+'px', 199 height: origin.height()+'px', 200 position: 'absolute', 201 overflow: 'hidden' 202 }).appendTo('body').css({'border':'2px solid #eee','padding':'20px','background':'#fff'}).animate({ 203 top: cart_total.offset().top, 204 left: cart_total.offset().left, 205 width: '10px', 206 height: '10px', 207 opacity: 0.7 208 }, 700, function() { 209 $(this).remove(); 210 cart_total.html(response.data.total); 211 $('#cart-content').append($('<div class="cart-just-added"></div>').html(f.find('span.added2cart').text())); 212 if ($('#cart').hasClass('fixed')) 213 $('.cart-to-checkout').css('display', 'block'); 214 }); 215 } 216 } else if (response.status == 'fail') { 217 alert(response.errors); 218 } 219 220 }, "json"); 221 return false; 222 }); 223 224 225 //PRODUCT FILTERING 226 var f = function () { 227 228 var ajax_form_callback = function (f) { 229 var fields = f.serializeArray(); 230 var params = []; 231 for (var i = 0; i < fields.length; i++) { 232 if (fields[i].value !== '') { 233 params.push(fields[i].name + '=' + fields[i].value); 234 } 235 } 236 var url = '?' + params.join('&'); 237 $(window).lazyLoad && $(window).lazyLoad('sleep'); 238 $('#product-list').html('<img src="' + f.data('loading') + '">'); 239 $.get(url, function(html) { 240 var tmp = $('<div></div>').html(html); 241 $('#product-list').html(tmp.find('#product-list').html()); 242 if (!!(history.pushState && history.state !== undefined)) { 243 window.history.pushState({}, '', url); 244 } 245 $(window).lazyLoad && $(window).lazyLoad('reload'); 246 }); 247 }; 248 249 $('.filters.ajax form input').change(function () {
250 ajax_form_callback($(this).closest('form')); 251 }); 252 $('.filters.ajax form').submit(function () { 253 ajax_form_callback($(this)); 254 return false; 255 }); 256 257 $('.filters .slider').each(function () { 258 if (!$(this).find('.filter-slider').length) { 259 $(this).append('<div class="filter-slider"></div>'); 260 } else { 261 return; 262 } 263 var min = $(this).find('.min'); 264 var max = $(this).find('.max'); 265 var min_value = parseFloat(min.attr('placeholder')); 266 var max_value = parseFloat(max.attr('placeholder')); 267 var step = 1; 268 var slider = $(this).find('.filter-slider'); 269 if (slider.data('step')) { 270 step = parseFloat(slider.data('step')); 271 } else { 272 var diff = max_value - min_value; 273 if (Math.round(min_value) != min_value || Math.round(max_value) != max_value) { 274 step = diff / 10; 275 var tmp = 0; 276 while (step < 1) { 277 step *= 10; 278 tmp += 1; 279 } 280 step = Math.pow(10, -tmp); 281 tmp = Math.round(100000 * Math.abs(Math.round(min_value) - min_value)) / 100000; 282 if (tmp && tmp < step) { 283 step = tmp; 284 } 285 tmp = Math.round(100000 * Math.abs(Math.round(max_value) - max_value)) / 100000; 286 if (tmp && tmp < step) { 287 step = tmp; 288 } 289 } 290 } 291 slider.slider({ 292 range: true, 293 min: parseFloat(min.attr('placeholder')), 294 max: parseFloat(max.attr('placeholder')), 295 step: step, 296 values: [parseFloat(min.val().length ? min.val() : min.attr('placeholder')), 297 parseFloat(max.val().length ? max.val() : max.attr('placeholder'))], 298 slide: function( event, ui ) { 299 var v = ui.values[0] == $(this).slider('option', 'min') ? '' : ui.values[0]; 300 min.val(v); 301 v = ui.values[1] == $(this).slider('option', 'max') ? '' : ui.values[1]; 302 max.val(v); 303 }, 304 stop: function (event, ui) { 305 min.change(); 306 } 307 }); 308 min.add(max).change(function () { 309 var v_min = min.val() === '' ? slider.slider('option', 'min') : parseFloat(min.val()); 310 var v_max = max.val() === '' ? slider.slider('option', 'max') : parseFloat(max.val()); 311 if (v_max >= v_min) { 312 slider.slider('option', 'values', [v_min, v_max]); 313 } 314 }); 315 }); 316 }; 317 f(); 318 319 //LAZYLOADING 320 if ($.fn.lazyLoad) { 321 var paging = $('.lazyloading-paging'); 322 if (!paging.length) { 323 return; 324 } 325 326 var times = parseInt(paging.data('times'), 10); 327 var link_text = paging.data('linkText') || 'Load more'; 328 329 // check need to initialize lazy-loading 330 var current = paging.find('li.selected'); 331 if (current.children('a').text() != '1') { 332 return; 333 } 334 paging.hide(); 335 var win = $(window); 336 var loading_str = paging.data('loading-str') || 'Loading...'; 337 338 // prevent previous launched lazy-loading 339 win.lazyLoad('stop'); 340 341 // check need to initialize lazy-loading 342 var next = current.next(); 343 if (next.length) { 344 win.lazyLoad({ 345 container: '#product-list .product-list', 346 load: function () { 347 win.lazyLoad('sleep'); 348 349 var paging = $('.lazyloading-paging').hide(); 350 351 // determine actual current and next item for getting actual url 352 var current = paging.find('li.selected'); 353 var next = current.next(); 354 var url = next.find('a').attr('href'); 355 if (!url) { 356 win.lazyLoad('stop'); 357 return; 358 } 359 360 var product_list = $('#product-list .product-list'); 361 var loading = paging.parent().find('.loading').parent(); 362 if (!loading.length) { 363 loading = $('<div><i class="icon16 loading"></i>'+loading_str+'</div>').insertBefore(paging); 364 } 365 366 loading.show(); 367 $.get(url, function (html) { 368 var tmp = $('<div></div>').html(html); 369 if ($.Retina) { 370 tmp.find('#product-list .product-list img').retina(); 371 } 372 product_list.append(tmp.find('#product-list .product-list').children()); 373 var tmp_paging = tmp.find('.lazyloading-paging').hide(); 374 paging.replaceWith(tmp_paging); 375 paging = tmp_paging; 376 377 times -= 1; 378 379 // check need to stop lazy-loading 380 var current = paging.find('li.selected'); 381 var next = current.next(); 382 if (next.length) { 383 if (!isNaN(times) && times <= 0) { 384 win.lazyLoad('sleep'); 385 if (!$('.lazyloading-load-more').length) { 386 $('<a href="#" class="lazyloading-load-more">' + link_text + '</a>').insertAfter(paging) 387 .click(function () { 388 loading.show(); 389 times = 1; // one more time 390 win.lazyLoad('wake'); 391 win.lazyLoad('force'); 392 return false;
393 }); 394 } 395 } else { 396 win.lazyLoad('wake'); 397 } 398 } else { 399 win.lazyLoad('stop'); 400 } 401 402 loading.hide(); 403 tmp.remove(); 404 }); 405 } 406 }); 407 } 408 } 409 410});
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.