1var Journal = {}; 2 3Journal.isMobile = $('html').hasClass('mobile') || $('html').hasClass('tablet'); 4Journal.isOC2 = $('html').hasClass('oc2'); 5Journal.mobileMenuOnTablet = $('html').hasClass('mobile-menu-on-tablet'); 6Journal.notificationTimer = 1700; 7Journal.quickviewText = 'Quickview'; 8Journal.BASE_HREF = null; 9Journal.updatePrice = false; 10 11Journal.init = function () { 12 /* firefox dropdown menu width fix */ 13 $('.journal-menu .drop-down').each(function () { 14 $('ul', this).css('min-width', $(this).width()); 15 }); 16 17 /* currency dropdown */ 18 var $c = $('.journal-currency .dropdown-menu'); 19 $c.css({ 20 'left': '50%', 21 'margin-left': '-' + $c.width() / 2 + 'px' 22 }); 23 $('.product-grid-item .image > a').prepend('<div class="p-over p-grid-over"> </div>'); 24 $('.product-list-item .image > a').prepend('<div class="p-over p-list-over"> </div>'); 25 26 /* */ 27 $('#top-modules .hide-on-mobile, #bottom-modules .hide-on-mobile').each(function () { 28 $(this).parent().addClass('hide-on-mobile'); 29 }); 30}; 31 32Journal.setupMenu = function (type) { 33 var $supermenu = $('.super-menu > li'); 34 var $mobiletrigger = $('.mobile-trigger'); 35 var $mobileplus = $('.mobile-menu > li .mobile-plus'); 36 var $megamenu_category_item = $('.mega-menu-categories .mega-menu-item li'); 37 38 try { $('.super-menu')[0].style.removeProperty('display'); } catch (e) { } 39 40 /* unbind all events */ 41 $supermenu.unbind('mouseenter').unbind('mouseleave').removeProp('hoverIntent_t').removeProp('hoverIntent_s'); 42 $mobiletrigger.unbind('click'); 43 $mobileplus.unbind('click'); 44 $megamenu_category_item.unbind('hover'); 45 46 if (type === 'mobile') { 47 jQuery._data($('.mobile-menu')[0], 'olddisplay', 'block'); 48 //$('.super-menu').css('display','none'); 49 /* setup mobile trigger */ 50 $mobiletrigger.toggle(function () { 51 $('.mobile-menu').stop(true, true).slideDown(250); 52 $(this).addClass('menu-open'); 53 }, function () { 54 $('.mobile-menu').stop(true, true).slideUp(150); 55 $(this).removeClass('menu-open'); 56 }); 57 58 /* setup mobile plus */ 59 $mobileplus.toggle(function () { 60 $('> ul, > div', $(this).parent()).stop(true, true).slideDown(250); 61 $(this).html('-').parent().addClass('menu-open'); 62 }, function () { 63 $('> ul, > div', $(this).parent()).stop(true, true).slideUp(150); 64 $(this).html('+').parent().removeClass('menu-open'); 65 }); 66 67 } 68 69 /* set desktop events */ 70 if (type === 'tablet' || type === 'desktop') { 71 jQuery._data($('.mobile-menu')[0], 'olddisplay', 'table'); 72 //$('.super-menu').css('display','table'); 73 $supermenu.hoverIntent(function () { 74 var self = this; 75 $('> ul, > div', this).hide(); 76 $('> ul, > div', this).stop(true, true).slideDown(250, function () { 77 $('img.lazy', self).lazy({ 78 bind: 'event', 79 visibleOnly: false, 80 effect: "fadeIn", 81 effectTime: 250 82 }); 83 }); 84 }, function () { 85 $('> ul, > div', this).stop(true, true).slideUp(150); 86 }); 87 88 /* change image on hover subcategories */ 89 $megamenu_category_item.hover(function () { 90 $(this).closest('.mega-menu-item').find('img').attr('src', $(this).attr('data-image')); 91 }, function () { 92 var $img = $(this).closest('.mega-menu-item').find('img'); 93 $img.attr('src', $img.attr('data-default-src')); 94 }); 95 } 96}; 97 98// Equal height rows solution - http://codepen.io/micahgodbolt/pen/FgqLc 99Journal.equalHeight = function ($container, item, padding) { 100 if (Journal.isMobile) { 101 return; 102 } 103 var currentTallest = 0, 104 currentRowStart = 0, 105 rowDivs = [], 106 $el, 107 currentDiv, 108 topPosition = 0; 109 padding = padding || 0; 110 $container.each(function () { 111 $el = item ? $(this).find(item) : $(this); 112 $el.height('auto'); 113 topPosition = $el.position().top; 114 if (currentRowStart !== topPosition) { 115 for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 116 rowDivs[currentDiv].height(currentTallest); 117 } 118 rowDivs = []; // empty the array 119 currentRowStart = topPosition; 120 currentTallest = $el.actual('height'); 121 rowDivs.push($el); 122 } else { 123 rowDivs.push($el); 124 currentTallest = (currentTallest < $el.actual('height')) ? $el.actual('height') : currentTallest; 125 } 126 for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 127 rowDivs[currentDiv].height(currentTallest + padding); 128 } 129 }); 130}; 131 132Journal.itemsEqualHeight = function () { 133 /* footer columns equal height */
134 Journal.equalHeight($('footer .column')); 135 136 /* menu items equal height */ 137 $('.mega-menu').addClass('dummy-hide'); 138 $('.mega-menu-categories').each(function () { 139 Journal.equalHeight($(this).find('.mega-menu-item')); 140 }); 141 $('.mega-menu-products').each(function () { 142 Journal.equalHeight($(this).find('.mega-menu-item'), '.name'); 143 }); 144 $('.mega-menu').removeClass('dummy-hide'); 145 146 /* products */ 147 $('#content .product-grid, #top-modules .product-grid, #bottom-modules .product-grid').each(function () { 148 Journal.equalHeight($(this).find('.product-grid-item'), '.name'); 149 }); 150 151 $('#content .box-product, #top-modules .box-product, #bottom-modules .box-product').each(function () { 152 Journal.equalHeight($(this).find('.product-grid-item'), '.name'); 153 }); 154 155 /* refine category name */ 156 Journal.equalHeight($(".refine-images .refine-image"), '.refine-category-name'); 157 158 /* cms blocks */ 159 $('.box.cms-blocks').each(function () { 160 var $this = $(this); 161 Journal.equalHeight($this.find('.cms-block'), '.block-content'); 162 }); 163 164}; 165 166Journal.changeProductImage = function (thumb, image) { 167 image = image || thumb; 168 169 var $image = $('#image'); 170 171 $image.attr('src', image); 172 $image.parent().attr('href', image); 173 174 if ($image.data('imagezoom')) { 175 $image.attr('data-largeimg', image); 176 $image.data('imagezoom').changeImage(image, image); 177 } 178}; 179 180Journal.enableCloudZoom = function (type) { 181 var $image = $('#image'); 182 183 $image.ImageZoom({ 184 showDescription: false, 185 bigImageSrc: $image.attr('data-largeimg'), 186 type: type, 187 offset: [0, 0], 188 zoomSize: [$image.width(), $image.height()] 189 }); 190 191 $(window).resize(function () { 192 if (Journal.cloudZoomTimeout) { 193 clearTimeout(Journal.cloudZoomTimeout); 194 } 195 196 Journal.cloudZoomTimeout = setTimeout(function () { 197 if ($image.data('imagezoom')) { 198 $image.data('imagezoom').changeZoomSize($image.width(), $image.height()); 199 } 200 }, 100); 201 }); 202}; 203 204Journal.productPage = function () { 205 $('.product-info .image-additional a').click(function (e) { 206 e.preventDefault(); 207 var thumb = $(this).find('img').attr('src'); 208 var image = $(this).attr('href'); 209 Journal.changeProductImage(thumb, image); 210 return false; 211 }); 212}; 213 214Journal.productPageGallery = function () { 215 if (!$('html').hasClass('quickview')) { 216 $('.product-info .image-gallery .swipebox').swipebox(); 217 218 $('.zm-viewer').live('click', function () { 219 var src = $(this).find('img').not('.zm-fast').attr('src'); 220 $('.product-info .image-gallery a.swipebox[href="' + src + '"]').first().click(); 221 return false; 222 }); 223 224 $('#image').parent().click(function () { 225 $('.product-info .image-gallery a.swipebox[href="' + $(this).attr('href') + '"]').first().click(); 226 return false; 227 }); 228 $('.gallery-text').click(function () { 229 $('.product-info .image-gallery a.swipebox').first().click(); 230 return false; 231 }); 232 } 233}; 234 235Journal.updateProductPrice = function () { 236 $.ajax({ 237 url: 'index.php?route=journal2/ajax/price', 238 type: 'post', 239 data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'), 240 dataType: 'json', 241 success: function (json) { 242 $('.product-info .price .price-old, .product-info .price .product-price').html(json.price); 243 $('.product-info .price .price-new').html(json.special); 244 $('.product-info .price .price-tax').html(json.tax); 245 $('.description .journal-stock').html(json.stock); 246 } 247 }); 248}; 249 250Journal.enableProductOptions = function () { 251 if (!$('html').hasClass('product-page')) { 252 return; 253 } 254 255 /* change image for select options */ 256 $('.product-info .options .option select').change(function () {
257 Journal.updateProductPrice(); 258 }); 259 260 /* change image for checkbox and radio options */ 261 $('.product-info .options .option input[type="radio"]').click(function () { 262 Journal.updateProductPrice(); 263 }); 264 265 $('.product-info .options .option input[type="checkbox"]').click(function () { 266 Journal.updateProductPrice(); 267 }); 268}; 269 270Journal.showNotification = function (message, image, parent) { 271 $.pnotify.defaults.history = false; 272 var $temp = $('<div>' + message + '</div>'); 273 var href = $temp.find('a').first().attr('href'); 274 var $img = image ? '<a href="' + href + '"><img src="' + image + '" alt="" /></a>' : ''; 275 var $title = $temp.find('a').last().prev(); 276 var timeout = Journal.notificationTimer; 277 var $$ = parent ? parent.$ : $; 278 $$.pnotify({ 279 title: $title.html(), 280 delay: parseInt(timeout, 10), 281 text: $img + message, 282 type: 'success', 283 history: false 284 }); 285 286 $('.ui-pnotify-text a').die('click touchend').live('click touchend', function () { 287 var el = $(this); 288 var link = el.attr('href'); 289 location = link; 290 }); 291 292 return true; 293}; 294 295Journal.enableQuickView = function () { 296 $('.quickview-button').remove(); 297 $('.product-wrapper .image, .product-list-item .image').each(function () { 298 var $quickview = $('<div class="quickview-button"><a class="button hint--top" data-hint="' + Journal.quickviewText + '"><i class="button-left-icon"></i><span class="button-cart-text">' + Journal.quickviewText + '</span><i class="button-right-icon"></i></a></div>'); 299 $(this).prepend($quickview); 300 var $quickbtn = $quickview.find('a'); 301 var $parent = $(this).closest('.product-list-item'); 302 if ($parent.length === 0) { 303 $parent = $(this).closest('.product-wrapper'); 304 } 305 var $cart_btn = $parent.find('.cart .button'); 306 var productId = $cart_btn.attr('onclick') || $cart_btn.attr('data-clk'); 307 if (productId) { 308 productId = productId.match(/'(.*?)'/g); 309 if (productId && productId[0]) { 310 productId = productId[0]; 311 productId = productId.replace("'", ""); 312 productId = parseInt(productId, 10); 313 $quickbtn.attr('href', 'index.php?route=journal2/quickview&pid=' + productId); 314 $quickbtn.magnificPopup({ 315 preloader: true, 316 tLoading: '', 317 type: 'iframe', 318 mainClass: 'quickview', 319 removalDelay: 200, 320 callbacks: { 321 open: function(item) { 322 var scrollTop = ($('html').scrollTop()) ? $('html').scrollTop() : $('body').scrollTop(); 323 $('html').addClass('noscroll').css('top',-scrollTop); 324 }, 325 close: function(item) { 326 var scrollTop = parseInt($('html').css('top')); 327 $('html').removeClass('noscroll'); 328 $('html,body').scrollTop(-scrollTop); 329 } 330 } 331 }); 332 } 333 } 334 }); 335}; 336 337Journal.searchAutoComplete = function () { 338 $('#search input').autocomplete2({ 339 appendTo: '.journal-search > div', 340 width: '100%', 341 serviceUrl: 'index.php?route=journal2/search', 342 deferRequestBy: 500, 343 paramName: 'search', 344 onSelect: function (suggestion) { 345 location = suggestion.url; 346 }, 347 transformResult: function (response) { 348 response = $.parseJSON(response); 349 var suggestions = $.map(response.results, function (dataItem) { 350 return { value: dataItem.name, data: dataItem, image: dataItem.image, price: dataItem.price, special: dataItem.special, url: dataItem.url }; 351 }); 352 if (response['view_more_url']) { 353 suggestions.push({ 354 view_more: true, 355 value: response['view_more_text'], 356 url: response['view_more_url'] 357 }); 358 } 359 return { 360 suggestions: suggestions 361 }; 362 }, 363 formatResult: function (suggestion, currentValue) { 364 if (suggestion['view_more']) { 365 return '<a class="view-more-link" href="' + suggestion['url'] + '">' + suggestion['value'] + '</a>'; 366 } else { 367// var reEscape = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\'].join('|\\') + ')', 'g'), 368// pattern = '(' + currentValue.replace(reEscape, '\\$1') + ')', 369// name = suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>'); 370 var name = suggestion.value; 371 var html = '<a href="' + suggestion.url + '">'; 372 if (suggestion.image) { 373 html += '<span class="p-image xs-33 sm-33 md-33 lg-33 xl-33"><img src="' + suggestion.image + '" /></span>'; 374 } 375 html += '<span class="p-name xs-66 sm-66 md-66 lg-66 xl-66"><span>' + name + '</span>'; 376 if (suggestion.price) { 377 if (suggestion.special) { 378 html += '<span class="p-price xs-66 sm-66 md-66 lg-66 xl-66"><span class="price-old">' + suggestion.price + '</span><span class="price-new">' + suggestion.special + '</span></span>'; 379 } else { 380 html += '<span class="p-price xs-66 sm-66 md-66 lg-66 xl-66">' + suggestion.price + '</span>'; 381 } 382 } 383 html += '</span>'; 384 html += '<div class="clearfix"> </div>'; 385 html += '</a>'; 386 return html; 387 } 388 } 389 }); 390}; 391 392Journal.onMobileOrTablet = function () { 393 /* add click events on language and currency */ 394 $('.btn-group').unbind('click').unbind('hoverIntent').click(function () { 395 $('.btn-group').not($(this)).removeClass('visible').find('ul').fadeOut(150); 396 $(this).toggleClass('visible'); 397 if ($(this).hasClass('visible')) { 398 $(this).find('ul').fadeIn(150); 399 } else { 400 $(this).find('ul').fadeOut(150); 401 } 402 }); 403 404 /* ajax cart */ 405 $('#cart > .heading a').die('mouseleave').die('mouseover').die('mouseleave').die('click'); 406 $('#cart > .heading a').live('click', function () { 407 if (!$("#cart").hasClass('active')) { 408 if (!Journal.isOC2) { 409 $('#cart').load('index.php?route=module/cart #cart > *'); 410 } 411 $('#cart').addClass('active'); 412 } else { 413 $('#cart').removeClass('active'); 414 } 415 }); 416 417 /* block sticky header */ 418 $('header').addClass('sticky-off'); 419 $('header').removeClass('sticky-header-center').removeClass('sticky-header'); 420}; 421 422Journal.onMobile = function () {
423 Journal.setupMenu('mobile'); 424 Journal.onMobileOrTablet(); 425 426 /* add journal-mobile class to html */ 427 $('html').addClass('journal-mobile').removeClass('journal-desktop'); 428 429 /* switch elements */ 430 $('.journal-header-default .journal-search, .journal-header-menu .journal-search').after($('.journal-header-default .journal-cart, .journal-header-menu .journal-cart')); 431 $('.journal-header-center .journal-links').before($('.journal-header-center .journal-language')); 432 $('.journal-header-center .journal-logo').after($('.journal-header-center .journal-search')); 433 434 Journal.itemsEqualHeight(); 435}; 436 437Journal.onTablet = function () { 438 /* switch some elements in markup */ 439 $('.journal-header-default .journal-search, .journal-header-menu .journal-search').after($('.journal-header-default .journal-cart, .journal-header-menu .journal-cart')); 440 $('.journal-header-center .journal-links').after($('.journal-header-center .journal-language')); 441 if (!$('.journal-header-center').hasClass('journal-header-mega')) { 442 $('.journal-header-center .journal-search').after($('.journal-header-center .journal-logo')); 443 } 444 Journal.setupMenu(Journal.mobileMenuOnTablet ? 'mobile' : 'tablet');
445 Journal.onMobileOrTablet(); 446 447 /* add journal-desktop class to html*/ 448 $('html').removeClass('journal-mobile').addClass('journal-desktop'); 449 450 Journal.itemsEqualHeight(); 451}; 452 453Journal.onDesktop = function () { 454 /* switch some elements in markup */ 455 $('.journal-header-default .journal-login, .journal-header-menu .journal-login').before($('.journal-header-default .journal-cart, .journal-header-menu .journal-cart')); 456 $('.journal-header-center .journal-links').after($('.journal-header-center .journal-language')); 457 if (!$('.journal-header-center').hasClass('journal-header-mega')) { 458 $('.journal-header-center .journal-search').after($('.journal-header-center .journal-logo')); 459 } 460 Journal.setupMenu('desktop'); 461 /* add journal-desktop class to html*/ 462 $('html').removeClass('journal-mobile').addClass('journal-desktop'); 463 464 /* hover on currency */ 465 $('.btn-group').unbind('click').unbind('hoverIntent').hoverIntent(function () { 466 $(this).find('ul').fadeIn(150); 467 }, function () { 468 $(this).find('ul').fadeOut(150); 469 }); 470 471 /* ajax cart event*/ 472 $('#cart > .heading a').die('click'); 473 $('#cart').die('mouseleave').die('mouseover').die('mouseleave').die('click'); 474 $('#cart').live('mouseover', function () { 475 if (!$("#cart").hasClass('active')) { 476 if (!Journal.isOC2) { 477 $('#cart').load('index.php?route=module/cart #cart > *'); 478 } 479 $('#cart').addClass('active'); 480 $('#cart').live('mouseleave', function () { 481 $(this).removeClass('active'); 482 }); 483 } 484 }); 485 $('header').removeClass('sticky-off');
486 Journal.itemsEqualHeight(); 487}; 488 489Journal.enableStickyHeader = function () { 490 if ($('header').hasClass('journal-header-center')) { 491 $("header").sticky({topSpacing: -40}); 492 $(window).scroll(function () { 493 if (!$('html').hasClass('noscroll')) { 494 if (!$('header').hasClass('sticky-off')) { 495 if ($(window).scrollTop() > 40) { 496 $(".journal-header-center").addClass('sticky-header-center'); 497 } else { 498 $(".journal-header-center").removeClass('sticky-header-center'); 499 } 500 } 501 } 502 }); 503 return; 504 } 505 if ($('header').hasClass('journal-header-default') || $('header').hasClass('journal-header-menu')) { 506 $("header").sticky({topSpacing: 0}); 507 $(window).scroll(function () { 508 if (!$('html').hasClass('noscroll')) { 509 if (!$('header').hasClass('sticky-off')) { 510 if ($(window).scrollTop() > 80) { 511 $(".journal-header-default, .journal-header-menu").addClass('sticky-header'); 512 $('.journal-header-default #header .journal-search, .journal-header-menu #header .journal-search').after($('.journal-header-default #header .journal-cart, .journal-header-menu #header .journal-cart')); 513 } else { 514 $(".journal-header-default, .journal-header-menu").removeClass('sticky-header'); 515 $('.journal-header-default #header .journal-links, .journal-header-menu #header .journal-links').after($('.journal-header-default #header .journal-cart, .journal-header-menu #header .journal-cart')); 516 } 517 } 518 } 519 }); 520 } 521}; 522 523Journal.enableSideBlocks = function () { 524 $('.side-block-block.side-block-left .side-block-icon').hoverIntent(function () { 525 var $parent = $(this).parent(); 526 var $content = $parent.find('.side-block-content'); 527 if (!$content.hasClass('content-loaded')) { 528 $content.load($content.attr('data-url')).addClass('content-loaded'); 529 } 530 $parent.stop().animate({'left' : '0px'}); 531 }); 532 533 $('.side-block-block.side-block-left .side-block-content').mouseleave(function () { 534 var x = $(this).parent().width(); 535 $(this).parent().stop().animate({'left': -x}); 536 }); 537 538 $('.side-block-block.side-block-right .side-block-icon').hoverIntent(function () { 539 var $parent = $(this).parent(); 540 var $content = $parent.find('.side-block-content'); 541 if (!$content.hasClass('content-loaded')) { 542 $content.load($content.attr('data-url')).addClass('content-loaded'); 543 } 544 $parent.stop().animate({'right' : '0px'}); 545 }); 546 547 $('.side-block-block.side-block-right .side-block-content').mouseleave(function () { 548 var y = $(this).parent().width(); 549 $(this).parent().stop().animate({'right' : -y}); 550 }); 551}; 552 553Journal.enableSelectOptionAsButtonsList = function () { 554 $('.push-select .option.option-select, .push-checkbox .option.option-checkbox, .push-radio .option.option-radio, .push-image .option.option-image').each(function () { 555 var $option = $(this); 556 var html = ''; 557 html += '<ul>'; 558 if ($option.hasClass('option-checkbox') || $option.hasClass('option-radio')) { 559 $option.find('input').each(function () { 560 var $this = $(this); 561 if ($this.val()) { 562 var $label = Journal.isOC2 ? $this.closest('label') : $('label[for="' + $this.attr('id') + '"]'); 563 html += '<li data-value="' + $this.val() + '"><span>' + $label.text().trim() + '</span></li>'; 564 } 565 }); 566 } else if ($option.hasClass('option-select')) { 567 $option.find('option').each(function () { 568 var $this = $(this); 569 if ($this.val()) { 570 html += '<li data-value="' + $this.val() + '"><span>' + $this.text().trim() + '</span></li>'; 571 } 572 }); 573 } else if ($option.hasClass('option-image')) { 574 $option.find(Journal.isOC2 ? '.radio' : 'tr').each(function () { 575 var $this = $(this); 576 var $input = $this.find('input'); 577 var $img = Journal.isOC2 ? ($this.find('img').clone().wrap('<p />').parent()) : $this.find('label'); 578 html += '<li data-value="' + $input.val() + '"><span>' + $img.html() + '</span></li>'; 579 }); 580 } 581 html += '</ul>'; 582 $option.append($(html)); 583 }); 584 585 $('.option-select li, .option-checkbox li, .option-radio li, .option-image li').click(function () { 586 var $this = $(this); 587 var $option = $this.closest('.option'); 588 if ($option.hasClass('option-checkbox')) { 589 $this.toggleClass('selected'); 590 } else { 591 $option.find('.selected').removeClass('selected'); 592 $this.addClass('selected'); 593 } 594 if ($option.hasClass('option-select')) { 595 $option.find('option[value=' + $this.attr('data-value') + ']').attr('selected', 'selected'); 596 } else { 597 $option.find('li').each(function () { 598 var $this = $(this); 599 $option.find('input[value=' + $this.attr('data-value') + ']').prop('checked', $this.hasClass('selected')); 600 }); 601 } 602 if (Journal.updatePrice) {
603 Journal.updateProductPrice(); 604 } 605 }); 606}; 607 608Journal.openPopup = function (module_id) { 609 $.magnificPopup.open({ 610 items: { 611 src: 'index.php?route=module/journal2_popup/show&module_id=' + module_id 612 }, 613 closeOnContentClick: false, 614 closeOnBgClick: false, 615 mainClass: 'quickview', 616 type: 'ajax', 617 removalDelay: 200, 618 callbacks: { 619 beforeClose: function () { 620 $('.mfp-content').addClass('popup-close'); 621 }, 622 open: function(item) { 623 var scrollTop = ($('html').scrollTop()) ? $('html').scrollTop() : $('body').scrollTop(); 624 $('html').addClass('noscroll').css('top',-scrollTop); 625 }, 626 close: function(item) { 627 var scrollTop = parseInt($('html').css('top')); 628 $('html').removeClass('noscroll'); 629 $('html,body').scrollTop(-scrollTop); 630 } 631 } 632 }, 0); 633}; 634 635Journal.newsletter = function ($module) { 636 $module.find('.newsletter-email').attr('disabled', true); 637 $.post('index.php?route=module/journal2_newsletter/subscribe', { email: $module.find('.newsletter-email').val() }, function (response) { 638 $module.find('.newsletter-email').removeAttr('disabled'); 639 if (response.status === 'error' && response.unsubscribe) { 640 if (confirm(response.message)) { 641 $.post('index.php?route=module/journal2_newsletter/unsubscribe', { email: $module.find('.newsletter-email').val() }, function (response) { 642 alert(response.message); 643 }, 'json'); 644 } 645 } else { 646 alert(response.message); 647 } 648 $module.find('.newsletter-email').focus(); 649 }, 'json'); 650}; 651 652Journal.contact = function ($module) { 653 var $button = $module.find('.journal-popup-footer .button'); 654 if ($button.hasClass('disabled')) return false; 655 $button.addClass('disabled'); 656 var $form = $module.find('form'); 657 var data = $form.serializeArray(); 658 data.push({ 659 name: 'url', 660 value: document.URL 661 }); 662 $.post('index.php?route=module/journal2_popup/contact', data, function (response) { 663 $button.removeClass('disabled'); 664 if (response.status === 'error') { 665 $form.find('input[name="captcha"]').val(''); 666 $form.find('img').attr('src', Journal.isOC2 ? 'index.php?route=tool/captcha' : 'index.php?route=information/contact/captcha'); 667 $form.find('.has-error').removeClass('has-error'); 668 $.each(response.error, function (key) { 669 $form.find('[name="' + key +'"]').addClass('has-error'); 670 }); 671 } 672 if (response.status === 'success') { 673 alert(response.message); 674 $form[0].reset(); 675 } 676 }, 'json'); 677 return false; 678}; 679 680if (Journal.isOC2) { 681 cart.add = function(product_id, quantity) { 682 if ($('.hide-cart .outofstock a[onclick="cart.add(\'' + product_id + '\');"]').length) { 683 return false; 684 } 685 686 $.ajax({ 687 url: 'index.php?route=checkout/cart/add', 688 type: 'post', 689 data: 'product_id=' + product_id + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 690 dataType: 'json', 691 beforeSend: function() { 692 $('#cart > button > a > span').button('loading'); 693 }, 694 success: function(json) { 695 $('#cart > button').button('reset'); 696 697 if (json['redirect']) { 698 location = json['redirect']; 699 } 700 701 if (json['success']) { 702 if (!Journal.showNotification(json['success'], json['image'])) { 703 $('.alert, .text-danger').remove(); 704 705 $('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 706 } 707 708 $('#cart-total').html(json['total']); 709 710 $('html, body').animate({ scrollTop: 0 }, 'slow'); 711 712 $('#cart ul').load('index.php?route=common/cart/info ul li'); 713 } 714 } 715 }); 716 }; 717 718 cart.update = function(key, quantity) { 719 $.ajax({ 720 url: 'index.php?route=checkout/cart/edit', 721 type: 'post', 722 data: 'key=' + key + '&quantity=' + (typeof(quantity) != 'undefined' ? quantity : 1), 723 dataType: 'json', 724 beforeSend: function() { 725 $('#cart > button').button('loading'); 726 }, 727 success: function(json) { 728 $('#cart > button').button('reset'); 729 730 $('#cart-total').html(json['total']); 731 732 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 733 location = 'index.php?route=checkout/cart'; 734 } else { 735 $('#cart ul').load('index.php?route=common/cart/info ul li'); 736 } 737 } 738 }); 739 }; 740 741 cart.remove = function(key) { 742 $.ajax({ 743 url: 'index.php?route=checkout/cart/remove', 744 type: 'post', 745 data: 'key=' + key, 746 dataType: 'json', 747 beforeSend: function() { 748 $('#cart > button').button('loading'); 749 }, 750 success: function(json) { 751 $('#cart > button').button('reset'); 752 753 $('#cart-total').html(json['total']); 754 755 if (getURLVar('route') == 'checkout/cart' || getURLVar('route') == 'checkout/checkout') { 756 location = 'index.php?route=checkout/cart'; 757 } else { 758 $('#cart ul').load('index.php?route=common/cart/info ul li'); 759 } 760 } 761 }); 762 }; 763} 764 765function addToCart(product_id, quantity) { 766 if ($('.hide-cart .outofstock a[onclick="addToCart(\'' + product_id + '\');"]').length) { 767 return false;
768 } 769 quantity = typeof(quantity) != 'undefined' ? quantity : 1; 770 771 if (Journal.isOC2) { 772 return cart.add(product_id, quantity); 773 } 774 775 $.ajax({ 776 url: 'index.php?route=checkout/cart/add', 777 type: 'post', 778 data: 'product_id=' + product_id + '&quantity=' + quantity, 779 dataType: 'json', 780 success: function(json) { 781 $('.success, .warning, .attention, .information, .error').remove(); 782 783 if (json['redirect']) { 784 location = json['redirect']; 785 } 786 787 if (json['success']) { 788 if (!Journal.showNotification(json['success'], json['image'])) { 789 $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); 790 } 791 $('.success').fadeIn('slow'); 792 $('#cart-total').html(json['total']); 793 } 794 } 795 }); 796} 797 798if (Journal.isOC2) { 799 wishlist.add = function(product_id) { 800 $.ajax({ 801 url: 'index.php?route=account/wishlist/add', 802 type: 'post', 803 data: 'product_id=' + product_id, 804 dataType: 'json', 805 success: function(json) { 806 if (json['success']) { 807 if (!Journal.showNotification(json['success'], json['image'])) { 808 $('.alert').remove(); 809 810 $('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 811 } 812 } 813 814 if (json['info']) { 815 if (!Journal.showNotification(json['info'], json['image'])) { 816 $('#content').parent().before('<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' + json['info'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 817 } 818 } 819 820 try { 821 $('.wishlist-total .product-count').html(json['total'].match(/\(\d+\)/g)[0].replace('(', '').replace(')', '')); 822 } catch (e) { } 823 824 $('html, body').animate({ scrollTop: 0 }, 'slow'); 825 } 826 }); 827 } 828} 829 830function addToWishList(product_id) { 831 if (Journal.isOC2) { 832 return wishlist.add(product_id); 833 } 834 835 $.ajax({ 836 url: 'index.php?route=account/wishlist/add', 837 type: 'post', 838 data: 'product_id=' + product_id, 839 dataType: 'json', 840 success: function(json) { 841 $('.success, .warning, .attention, .information').remove(); 842 843 if (json['success']) { 844 if (!Journal.showNotification(json['success'], json['image'])) { 845 $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); 846 } 847 $('.success').fadeIn('slow'); 848 849 try { 850 $('.wishlist-total .product-count').html(json['total'].match(/\(\d+\)/g)[0].replace('(', '').replace(')', '')); 851 } catch (e) { } 852 } 853 } 854 }); 855} 856 857if (Journal.isOC2) { 858 compare.add = function(product_id) { 859 $.ajax({ 860 url: 'index.php?route=product/compare/add', 861 type: 'post', 862 data: 'product_id=' + product_id, 863 dataType: 'json', 864 success: function(json) { 865 if (json['success']) { 866 if (!Journal.showNotification(json['success'], json['image'])) { 867 $('.alert').remove(); 868 869 $('#content').parent().before('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + '<button type="button" class="close" data-dismiss="alert">×</button></div>'); 870 } 871 872 $('#compare-total').html(json['total']); 873 874 $('html, body').animate({ scrollTop: 0 }, 'slow'); 875 } 876 } 877 }); 878 } 879} 880 881function addToCompare(product_id) { 882 if (Journal.isOC2) { 883 return compare.add(product_id); 884 } 885 886 $.ajax({ 887 url: 'index.php?route=product/compare/add', 888 type: 'post', 889 data: 'product_id=' + product_id, 890 dataType: 'json', 891 success: function(json) { 892 $('.success, .warning, .attention, .information').remove(); 893 894 if (json['success']) { 895 if (!Journal.showNotification(json['success'], json['image'])) { 896 $('#notification').html('<div class="success" style="display: none;">' + json['success'] + '<img src="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>'); 897 } 898 $('.success').fadeIn('slow'); 899 900 try { 901 $('#compare-total').html(json['total']); 902 $('.compare-total .product-count').html(json['total'].match(/\(\d+\)/g)[0].replace('(', '').replace(')', '')); 903 } catch (e) { } 904 } 905 } 906 }); 907} 908 909Journal.SuperFilter = {}; 910 911Journal.SuperFilter.firstLoad = true; 912 913Journal.SuperFilter.init = function ($parent) { 914 /* reset button event */ 915 $parent.find('.sf-reset').live('click', function () {
916 Journal.SuperFilter.reset($parent); 917 }); 918 919 /* checkbox events */ 920 $parent.find('input[type="checkbox"]').live('click', function () { 921 var $box = $(this).closest('.box'); 922 if ($box.hasClass('sf-single')) { 923 $box.find('input[type="checkbox"]').not($(this)).removeAttr('checked'); 924 } 925 setTimeout(function () { Journal.SuperFilter.filter($parent); }, 1); 926 }); 927 928 /* address change event*/ 929 $.address.change(function (e) { 930 if (!Journal.SuperFilter.firstLoad || (Journal.SuperFilter.firstLoad && ($(location).attr('hash').replace('#/', '').replace('#', '')))) { 931 Journal.SuperFilter.doFilter($parent, e.value); 932 } 933 Journal.SuperFilter.firstLoad = false; 934 }); 935 936 $(function () { 937 /* sort order and limit */ 938 $('.sort select, .limit select').removeAttr('onchange').live('change', function (e) { 939 Journal.SuperFilter.filter($parent); 940 return false; 941 }); 942 943 /* pagination change */ 944 $('.pagination').removeClass('hide'); 945 $('.pagination .links a').live('click', function (e) { 946 $parent.find('.sf-page').val($(this).attr('href').split('page=')[1]); 947 Journal.SuperFilter.filter($parent); 948 $('html, body').animate({scrollTop: 0}, 700); 949 return false; 950 }); 951 }); 952 953 /* render initial price slider */ 954 Journal.SuperFilter.priceSlider($parent); 955}; 956 957Journal.SuperFilter.reset = function ($parent) { 958 var location = window.location.href; 959 location = location.split("#"); 960 window.location.href = location[0]; 961}; 962 963Journal.SuperFilter.filter = function ($parent) { 964 var filters = {}; 965 /* get selected filters */ 966 $parent.find('.box').not('.sf-tags').not('.sf-availability').find('input:checked').each(function () { 967 var name = $(this).attr('name'); 968 filters[name] = filters[name] || { 969 name: name, 970 group: name.replace(/\D/g, ''), 971 filters: [] 972 }; 973 filters[name].filters.push({ 974 keyword: $(this).attr('data-keyword'), 975 value: $(this).val() 976 }); 977 }); 978 979 /* build url */ 980 var url_parts = []; 981 for (var i in filters) { 982 var keywords = []; 983 var values = []; 984 var type = filters[i].name[0]; 985 var group = filters[i].group; 986 for (var j in filters[i].filters) { 987 keywords.push(filters[i].filters[j].keyword); 988 values.push(filters[i].filters[j].value); 989 } 990 url_parts.push(keywords.join(',') + '-' + (group ? '' + type + group + '-v' : type) + values.join(',')); 991 } 992 993 /* add tags */ 994 var tags = []; 995 $parent.find('.sf-tags').find('input:checked').each(function () { 996 tags.push($(this).val()); 997 }); 998 if (tags.length) { 999 url_parts.push(tags.join(',') + '-tags'); 1000 }; 1001 1002 /* add availability */ 1003 var availability = []; 1004 $parent.find('.sf-availability').find('input:checked').each(function () { 1005 availability.push($(this).val()); 1006 }); 1007 if (availability.length) { 1008 url_parts.push('availability=' + availability.join(',')); 1009 }; 1010 1011 /* add sort order */ 1012 if ($('.sort').length > 0) { 1013 var value = $('.sort select option:selected').val().split('sort=')[1].split('&'); 1014 url_parts.push('sort=' + value[0]); 1015 url_parts.push('order=' + value[1].replace('order=', '')); 1016 } 1017 1018 /* add limit */ 1019 if ($('.limit').length > 0) { 1020 url_parts.push('limit=' + $('.limit select option:selected').text()); 1021 } 1022 1023 /* add price */ 1024 if ($parent.find('.sf-price').length > 0) { 1025 var $price_slider = $parent.find('.sf-price'); 1026 var minPrice = $parent.find('.sf-price .slider').attr('data-min') || $parent.find('.sf-price .slider').attr('data-min-value'); 1027 var maxPrice = $parent.find('.sf-price .slider').attr('data-max') || $parent.find('.sf-price .slider').attr('data-max-value'); 1028 if(minPrice && maxPrice && (minPrice != $price_slider.attr('data-min-price') || maxPrice != $price_slider.attr('data-max-price'))){ 1029 url_parts.push('minPrice=' + minPrice); 1030 url_parts.push('maxPrice=' + maxPrice); 1031 } 1032 } 1033 1034 /* add pagination */ 1035 var page = $parent.find('.sf-page').val(); 1036 if (page) { 1037 url_parts.push('page=' + page); 1038 } 1039 1040 /* change hash value */ 1041 $.address.value(url_parts.join('/')); 1042}; 1043 1044Journal.SuperFilter.doFilter = function ($parent, url) { 1045 /* post data */ 1046 var data = { 1047 filters : url, 1048 route : $parent.attr('data-route'), 1049 path : $parent.attr('data-path'), 1050 manufacturer_id : $parent.attr('data-manufacturer'), 1051 search : $parent.attr('data-search'), 1052 tag : $parent.attr('data-tag') 1053 } 1054 1055 if ($("input#description").length) { 1056 data.description = $("input#description").is(':checked') ? 1 : 0; 1057 }; 1058 1059 /* set data for infinite scroll */ 1060 window.J2FilterData = data; 1061 1062 /* hide pagination */ 1063 $('.pagination').addClass('hide'); 1064 1065 /* hide elements */ 1066 $('.sf-loader').remove(); 1067 $('.main-products.product-list, .main-products.product-grid').append('<div class="sf-loader"><span>' + $parent.attr('data-loading-text') + '</span></div>'); 1068 1069 /* filters */ 1070 $.ajax({ 1071 url: $parent.attr('data-filters-action'), 1072 type: 'post', 1073 async: false, 1074 data: data, 1075 success: function (response) { 1076 $parent.html($(response.replace(/\n/g, " ")).html());
1077 Journal.SuperFilter.setFilters($parent, url); 1078 } 1079 }); 1080 1081 /* products */ 1082 $.ajax({ 1083 url: $parent.attr('data-products-action'), 1084 type: 'post', 1085 data: data, 1086 success: function (response) { 1087 var $html = $('<div>' + response.replace(/\n/g, " ") + '</div>'); 1088 1089 $(".main-products.product-list, .main-products.product-grid").html($html.find('.product-list').html()); 1090 1091 if ($(".product-list").length == 0 && $(".product-grid").length == 0) { 1092 $("#content .content:eq(1)").replaceWith($html.html()); 1093 }; 1094 if ($(".pagination").length > 0) { 1095 $(".pagination").html($html.find('.pagination').html()); 1096 }else{ 1097 $(".pagination").after($html.find('.pagination').html()); 1098 $(".pagination").after($html.find('.pagination').html()); 1099 } 1100 1101 $('.pagination').removeClass('hide'); 1102 1103 setTimeout(function(){ 1104 if(Journal.quickViewStatus){ 1105 Journal.enableQuickView(); 1106 } 1107 $('.main-products .product-grid-item .image > a').prepend('<div class="p-over p-grid-over"> </div>'); 1108 $('.main-products .product-list-item .image > a').prepend('<div class="p-over p-list-over"> </div>'); 1109 }, 1); 1110 1111 Journal.SuperFilter.setNavigation(); 1112 } 1113 }); 1114}; 1115 1116Journal.SuperFilter.setFilters = function ($parent, url) { 1117 var categoryPattern = /-c(((\d+)(,*))+)/; 1118 var manufacturerPattern = /-m(((\d+)(,*))+)/; 1119 var attributePattern = /-a(\d*)-v/; 1120 var optionPattern = /-o(\d*)-v/; 1121 var tagsPattern = /(.+)-tags/; 1122 var availabilityPattern = /availability=(.+)/; 1123 1124 var sort = null; 1125 var order = null; 1126 var minPrice = Math.floor(parseFloat($parent.find('.sf-price').attr('data-min-price')));
1127 var maxPrice = Math.ceil(parseFloat($parent.find('.sf-price').attr('data-max-price'))); 1128 1129 $.each(url.split('/'), function (index, part) { 1130 /* categories */ 1131 if (categoryPattern.test(part)) { 1132 var values = part.split(categoryPattern); 1133 $.each(values[1].split(','), function (i, value) { 1134 $parent.find('.sf-category input[value="' + value + '"]').attr('checked', 'checked'); 1135 }); 1136 return; 1137 } 1138 1139 /* manufacturers */ 1140 if (manufacturerPattern.test(part)) { 1141 var values = part.split(manufacturerPattern); 1142 $.each(values[1].split(','), function (i, value) { 1143 $parent.find('.sf-manufacturer input[value="' + value + '"]').attr('checked', 'checked'); 1144 }); 1145 return; 1146 } 1147 1148 /* attributes */ 1149 if (attributePattern.test(part)) { 1150 var values = part.split(attributePattern); 1151 $.each(values[2].split(','), function (i, value) { 1152 $parent.find('.sf-attribute-' + values[1] + ' input[value="' + value + '"]').attr('checked', 'checked'); 1153 }); 1154 return; 1155 } 1156 1157 /* options */ 1158 if (optionPattern.test(part)) { 1159 var values = part.split(optionPattern); 1160 $.each(values[2].split(','), function (i, value) { 1161 $parent.find('.sf-option-' + values[1] + ' input[value="' + value + '"]').attr('checked', 'checked'); 1162 }); 1163 return; 1164 } 1165 1166 /* tags */ 1167 if (tagsPattern.test(part)) { 1168 var values = part.split(tagsPattern); 1169 $.each(values[1].split(','), function (i, value) { 1170 $parent.find('.sf-tags input[value="' + value + '"]').attr('checked', 'checked'); 1171 }); 1172 return; 1173 } 1174 1175 if (availabilityPattern.test(part)) { 1176 var values = part.split(availabilityPattern); 1177 $.each(values[1].split(','), function (i, value) { 1178 $parent.find('.sf-availability input[value="' + value + '"]').attr('checked', 'checked'); 1179 }); 1180 return; 1181 } 1182 1183 /* limit */ 1184 if (part.indexOf('limit=') !== -1) { 1185 $('.limit select option[value$="' + part + '"]').attr('selected', 'selected'); 1186 return; 1187 } 1188 1189 /* sort */ 1190 if (part.indexOf('sort=') !== -1) { 1191 sort = part; 1192 return; 1193 }; 1194 1195 /* order */ 1196 if (part.indexOf('order=') !== -1) { 1197 order = part; 1198 return; 1199 }; 1200 1201 /* min price */ 1202 if (part.indexOf('minPrice=') !== -1) { 1203 minPrice = part.replace('minPrice=', ''); 1204 return; 1205 } 1206 1207 /* max price */ 1208 if (part.indexOf('maxPrice=') !== -1) { 1209 maxPrice = part.replace('maxPrice=', ''); 1210 return; 1211 } 1212 }); 1213 1214 /* check sort order select */ 1215 $('.sort select option[value$="' + sort + "&" + order +'"]').attr('selected', 'selected'); 1216 1217 /* set slider values */ 1218 if (minPrice && maxPrice) { 1219 $parent.find('.slider').attr('data-min-value', minPrice); 1220 $parent.find('.slider').attr('data-max-value', maxPrice); 1221 } 1222 1223 setTimeout(function () { 1224 Journal.SuperFilter.priceSlider($parent); 1225 }, 0); 1226 1227 /* add selected class */ 1228 $parent.find('input:checked').each(function () { 1229 $(this).closest('label').addClass('sf-checked'); 1230 }); 1231}; 1232 1233Journal.SuperFilter.collision = function ($div1, $div2) { 1234 if (!$div1.length || $div2.length) return false; 1235 var x1 = $div1.offset().left; 1236 var w1 = 40; 1237 var r1 = x1 + w1; 1238 var x2 = $div2.offset().left; 1239 var w2 = 40; 1240 var r2 = x2 + w2; 1241 1242 return !(r1 < x2 || x1 > r2); 1243} 1244 1245Journal.SuperFilter.price = function ($parent, value) { 1246 var currency_left = $parent.attr('data-currency-left'); 1247 var currency_right = $parent.attr('data-currency-right'); 1248 var currency_decimal = $parent.attr('data-currency-decimal'); 1249 var currency_thousand = $parent.attr('data-currency-thousand'); 1250 value = value.toString().replace('.', currency_decimal).replace(/\B(?=(\d{3})+(?!\d))/g, currency_thousand); 1251 return currency_left ? (currency_left + value) : (value + currency_right); 1252} 1253 1254Journal.SuperFilter.priceSlider = function ($parent) { 1255 $parent.find('.slider').slider({ 1256 range: true, 1257 min: Math.floor(parseFloat($parent.find('.sf-price').attr('data-min-price'))), 1258 max: Math.ceil(parseFloat($parent.find('.sf-price').attr('data-max-price'))), 1259 values: [ parseFloat($parent.find('.slider').attr('data-min-value')), parseFloat($parent.find('.slider').attr('data-max-value')) ], 1260 slide: function(event, ui) { 1261 $('.ui-slider-handle:eq(0) .price-range-min').html(Journal.SuperFilter.price($parent, ui.values[0])); 1262 $('.ui-slider-handle:eq(1) .price-range-max').html(Journal.SuperFilter.price($parent, ui.values[1])); 1263 $('.price-range-both').html('<i>' + Journal.SuperFilter.price($parent, ui.values[0]) + ' - </i>' + Journal.SuperFilter.price($parent, ui.values[1]) ); 1264 1265 if ( ui.values[0] == ui.values[1] ) { 1266 $('.price-range-both i').css('display', 'none'); 1267 } else { 1268 $('.price-range-both i').css('display', 'inline'); 1269 } 1270 1271 if (Journal.SuperFilter.collision($('.price-range-min'), $('.price-range-max')) == true) { 1272 $('.price-range-min, .price-range-max').css('opacity', '0'); 1273 $('.price-range-both').css('display', 'block'); 1274 } else { 1275 $('.price-range-min, .price-range-max').css('opacity', '1'); 1276 $('.price-range-both').css('display', 'none'); 1277 } 1278 }, 1279 change: function (event, ui) { 1280 $(this).attr('data-min', ui.values[0]); 1281 $(this).attr('data-max', ui.values[1]);
1282 Journal.SuperFilter.filter($parent); 1283 } 1284 }); 1285 1286 $('.ui-slider-range').append('<span class="price-range-both value"><i>' + Journal.SuperFilter.price($parent, $parent.find('.slider').slider('values', 0 )) + ' - </i>' + Journal.SuperFilter.price($parent, $parent.find('.slider').slider('values', 1 )) + '</span>'); 1287 $('.ui-slider-handle:eq(0)').append('<span class="price-range-min value">' + Journal.SuperFilter.price($parent, $parent.find('.slider').slider('values', 0 )) + '</span>'); 1288 $('.ui-slider-handle:eq(1)').append('<span class="price-range-max value">' + Journal.SuperFilter.price($parent, $parent.find('.slider').slider('values', 1 )) + '</span>'); 1289 1290 if ( $('.price-range-min').html() === $('.price-range-max').html() ) { 1291 $('.price-range-both i').css('display', 'none'); 1292 } else { 1293 $('.price-range-both i').css('display', 'inline'); 1294 } 1295 1296 if (Journal.SuperFilter.collision($('.price-range-min'), $('.price-range-max')) == true) { 1297 $('.price-range-min, .price-range-max').css('opacity', '0'); 1298 $('.price-range-both').css('display', 'block'); 1299 } else { 1300 $('.price-range-min, .price-range-max').css('opacity', '1'); 1301 $('.price-range-both').css('display', 'none'); 1302 } 1303}; 1304 1305Journal.SuperFilter.setNavigation = function () { 1306 /* sort and limit events */ 1307 $('.sort select, .limit select').removeAttr('onchange'); 1308 1309 /* display product grid */ 1310 Journal.applyView(); 1311}; 1312 1313Journal.countdown = function ($elem, date) { 1314 $elem.countdown({ 1315 date: date, 1316 render: function (date) { 1317 return $(this.el).html("<span>" 1318 + date.days + " <div>" + Journal.COUNTDOWN.DAYS + "</div></span> <span>" 1319 + (this.leadingZeros(date.hours)) + " <div>" + Journal.COUNTDOWN.HOURS + "</div></span> <span> " 1320 + (this.leadingZeros(date.min)) + " <div>" + Journal.COUNTDOWN.MINUTES + "</div></span> <span> " 1321 + (this.leadingZeros(date.sec)) + " <div>" + Journal.COUNTDOWN.SECONDS + "</div> </span>"); 1322 } 1323 }); 1324}; 1325 1326Journal.enableCountdown = function () { 1327 $('.main-products > div').each(function () { 1328 var $new = $(this).find('.price-new'); 1329 if ($new.length && $new.attr('data-end-date')) { 1330 $(this).find('.image').append('<div class="countdown"></div>'); 1331 } 1332 Journal.countdown($(this).find('.countdown'), $new.attr('data-end-date')); 1333 }); 1334}; 1335 1336Journal.blogSearch = function ($element, url) { 1337 $element.find('a').click(function () { 1338 var term = encodeURIComponent($element.find('input').val()); 1339 if (!term) return false; 1340 parent.window.location = url + term; 1341 }); 1342 $element.find('input').keydown(function (e) { 1343 if (e.keyCode == 13) { 1344 var term = encodeURIComponent($element.find('input').val()); 1345 if (!term) return false; 1346 parent.window.location = url + term; 1347 } 1348 }); 1349}; 1350 1351Journal.gridView = function () { 1352 var classes = $('.main-products').removeClass('product-list').addClass('product-grid').attr('data-grid-classes'); 1353 $('.main-products > div').each(function () { 1354 $(this).attr('class','product-grid-item ' + classes); 1355 }); 1356 $('.product-thumb').addClass('product-wrapper');
1357 Journal.equalHeight($(".product-thumb.product-wrapper"), '.description'); 1358 localStorage.setItem('display', 'grid'); 1359}; 1360 1361Journal.listView = function () { 1362 $('.main-products').removeClass('product-grid').addClass('product-list') 1363 $('.main-products > div').each(function () { 1364 $(this).attr('class','product-list-item xs-100 sm-100 md-100 lg-100 xl-100'); 1365 }); 1366 $('.product-thumb').removeClass('product-wrapper'); 1367 localStorage.setItem('display', 'list'); 1368}; 1369 1370Journal.applyView = function () { 1371 if (Journal.isOC2) { 1372 if (localStorage.getItem('display') == 'list') { 1373 Journal.listView(); 1374 } else { 1375 Journal.gridView(); 1376 } 1377 $('ul.pagination').removeClass('pagination'); 1378 } else { 1379 display($.totalStorage('display')); 1380 } 1381}; 1382 1383//Add sequential classes to menu items 1384 1385$(document).ready(function(){ 1386 $('.super-menu > li').each(function(i) { 1387 $(this).addClass('main-menu-item-'+(i+1)); 1388 }); 1389 1390 $('.journal-links .links > a').each(function(i) { 1391 $(this).addClass('top-menu-item-'+(i+1)); 1392 }); 1393 1394 $('.journal-secondary .links > a').each(function(i) { 1395 $(this).addClass('secondary-menu-item-'+(i+1)); 1396 }); 1397}); 1398 1399
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.