1var fxMobileViewport = window.matchMedia("screen and (min-width: 768px)"); 2var fxMobileViewport2 = window.matchMedia("screen and (min-width: 1501px)"); 3 4function collapsedMenu() { 5 try { 6 var menu = document.querySelector(".menu"); 7 var mobile = window.matchMedia("(max-width:767px"); 8 9 if (!menu || mobile.matches) { 10 return; 11 } 12 13 var menuList = menu.querySelector(".innermenu .menu-list"); 14 15 if (!menuList) { 16 return; 17 } 18 19 var menuListChildren = menuList.children; 20 var menuListChildrenLast = menuListChildren[menuListChildren.length - 1]; 21 22 if (Math.abs(menuListChildrenLast.offsetTop - menuListChildren[0].offsetTop) <= 10) { 23 return; 24 } 25 26 var li = document.createElement("li"); 27 li.classList.add("parent"); 28 li.classList.add("fx-more"); 29 li.style.visibility = "hidden"; 30 31 var h3 = document.createElement("h3"); 32 var a = document.createElement("a"); 33 var span = document.createElement("span"); 34 35 a.classList.add("spanhover"); 36 a.classList.add("mainlevel"); 37 a.setAttribute("href", "#"); 38 39 span.textContent = Shop.lang ? (Shop.lang.filter ? Shop.lang.filter.show_more : "wiÄcej") : "wiÄcej"; 40 41 a.appendChild(span); 42 h3.appendChild(a); 43 44 li.appendChild(h3); 45 46 menuList.insertBefore(li, menuList.childNodes[2]); 47 48 var items = menuList.children; 49 items = [].slice.call(items); 50 items.shift(); 51 var menuTop = items[0].offsetTop; 52 var moreElements = []; 53 54 for (var i = 0; i < items.length; i++) { 55 if (items[i].offsetTop !== menuTop && items[i].offsetTop >= 20) { 56 moreElements.push(items[i]); 57 } 58 } 59 60 if (moreElements.length === 0) { 61 menuList.removeChild(li); 62 return; 63 } 64 65 li.style.visibility = "visible"; 66 67 //Create wrapper 68 var div = document.createElement("div"); 69 div.classList.add("submenu"); 70 div.classList.add("level1"); 71 72 var ul = document.createElement("ul"); 73 ul.classList.add("level1"); 74 75 var dc = document.createDocumentFragment(); 76 77 for (var j = 0; j < moreElements.length; j++) { 78 if (j === 0) { 79 moreElements[j].classList.add("lastChild"); 80 } 81 dc.appendChild(moreElements[j].cloneNode(true)); 82 } 83 84 ul.appendChild(dc); 85 86 div.appendChild(ul); 87 li.appendChild(div); 88 89 menuList.insertBefore(li, moreElements[0]); 90 91 var liFxMore = li.querySelectorAll("li.parent"); 92 93 $(liFxMore).on("mouseenter", function () { 94 var childUl = $(liFxMore).find("> .submenu > ul"); 95 if (childUl.offset().left + childUl.outerWidth() > window.innerWidth) { 96 childUl.addClass("sub-right"); 97 childUl.find("ul").addClass("sub-right"); 98 } 99 }); 100 101 //menuList.appendChild(li); 102 } catch (e) { 103 console.log("Error : " + e.message); 104 } 105} 106 107//Called function 108 109function randomSpeed(){ 110 return Math.floor((Math.random() * 10) + 1); 111} 112 113var init = function init() { 114 var mainBox = document.querySelector("#box_menu2"); 115 116 if (!mainBox || !mainBox.querySelector(".innerbox")) { 117 return; 118 } 119 120 var howLvl = mainBox.querySelector("p:nth-child(3)") 121 ? mainBox.querySelector("p:nth-child(3)").innerText 122 : -1; 123 var shopLang = document.getElementsByTagName("html")[0].getAttribute("lang"); 124 125 var getInfo = function getInfo() { 126 var endPoint = window.shoper.url("console/tree/gettree/client/1"); 127 mainBox.classList.add("loading"); 128 var innerBox = mainBox.querySelector(".innerbox"); 129 // 1 - all 130 // 2 - hover 131 // 3 - click 132 133 var optionValue = mainBox.querySelector("p:first-child"); 134 var clickValue = mainBox.querySelector("p:nth-child(2)"); 135 var flagItems = mainBox.querySelector("p:nth-child(4)").innerText; 136 var newest = mainBox.querySelector("p:nth-child(5)"); 137 var promo = mainBox.querySelector("p:nth-child(6)"); 138 var offCategory = mainBox.querySelector("p:nth-child(7)"); 139 140 optionValue = optionValue 141 ? "option".concat(optionValue.innerText) 142 : "option1"; 143 clickValue = 144 clickValue && optionValue == "option3" 145 ? "click".concat(clickValue.innerText) 146 : "no-click"; 147 var counterLevel = 0; 148 innerBox.textContent = ""; 149 mainBox.classList.add(optionValue); 150 mainBox.classList.add(clickValue); 151 152 var xhr = new XMLHttpRequest(); 153 154 xhr.onload = function (e) { 155 if (xhr.status >= 200 && xhr.status < 300) { 156 var categories = JSON.parse(xhr.response); 157 var categoriesMenu = document.createElement("ul"); 158 categoriesMenu.classList.add("fx-categoriesMenu"); 159 categoriesMenu.classList.add(optionValue); 160 161 if (clickValue) { 162 categoriesMenu.classList.add(clickValue); 163 } 164 165 categories.tree.forEach(function (item) { 166 var mainLi = document.createElement("li"); 167 mainLi.setAttribute("id", "category".concat(item.id)); 168 mainLi.classList.add("mainLi"); 169 170 if (parseInt(flagItems)) { 171 var numberItems = countItems(item); 172 } 173 174 mainLi.innerHTML = '<a href="' 175 .concat(item.url, '" title="') 176 .concat(item.name, '">\n ') 177 .concat(item.name, "\n </a>") 178 .concat( 179 numberItems >= 0 ? "<em>(".concat(numberItems, ")</em>") : "", 180 "</em>" 181 ); 182 183 categoriesMenu.appendChild(mainLi); 184 185 if (item.children.length > 0) { 186 checkChildren(item.children, counterLevel, mainLi, howLvl); 187 mainLi.classList.add("parent"); 188 } 189 }); 190 191 if (newest && newest.textContent != "0") { 192 var newLi = document.createElement("li"); 193 newLi.setAttribute("id", "category_novelties"); 194 newLi.innerHTML = 195 '<a href="/' + 196 shopLang + 197 '/new/" title="NowoÅci" class="novelties">' + 198 newest.textContent + 199 "</a>"; 200 201 categoriesMenu.appendChild(newLi); 202 } 203 204 if (promo && promo.textContent != "0") { 205 var promoLi = document.createElement("li"); 206 promoLi.setAttribute("id", "category_promo"); 207 promoLi.innerHTML = 208 '<a href="/' + 209 shopLang + 210 '/promotions" title="Promocje" class="promo">' + 211 promo.textContent + 212 "</a>"; 213 214 categoriesMenu.appendChild(promoLi); 215 } 216 217 innerBox.appendChild(categoriesMenu); 218 219 mainBox.classList.remove("loading"); 220 var bodyId = document.body.getAttribute("id"); 221 222 if ( 223 bodyId 224 && bodyId.includes("shop_category") 225 && bodyId !== "shop_category0" 226 ) { 227 var categoryId = bodyId.replace("shop_category", ""); 228 var current = document.querySelector( 229 ".fx-categoriesMenu li#category" + categoryId 230 ); 231 current.classList.add("current"); 232 var curr = current.parentElement.parentElement; 233 var currLoop = true; 234 235 while (curr.classList.contains("parent")) { 236 curr.classList.add("current_parent"); 237 curr = curr.parentElement.parentElement; 238 } 239 } else if (bodyId && bodyId.includes("shop_product")) { 240 var _categoryId = parseInt( 241 document.body 242 .getAttribute("class") 243 .replace(/^.*shop_product_from_cat_(\d+).*$/, "$1") 244 ); 245 246 var _current = document.querySelector( 247 ".fx-categoriesMenu li#category" + _categoryId 248 ); 249 250 _current.classList.add("current"); 251 } 252 253 if (optionValue == "option3") { 254 var allParents = document.querySelectorAll( 255 ".fx-categoriesMenu li.parent" 256 ); 257 258 var _loop = function _loop(t) { 259 span = document.createElement("span"); 260 span.classList.add("fx-triggerCategory"); 261 span.classList.add(clickValue); 262 allParents[t].appendChild(span); 263 span.addEventListener("click", function (e) { 264 e.target.classList.toggle("open"); 265 allParents[t].querySelector("ul").classList.toggle("show"); 266 }); 267 }; 268 269 for (var t = 0; t < allParents.length; t++) { 270 var span; 271 272 _loop(t); 273 } 274 } 275 276 if (offCategory) { 277 offCategory = JSON.parse(offCategory.textContent); 278 279 for (var k = 0; k < offCategory.length; k++) { 280 document.querySelector( 281 ".fx-categoriesMenu li#category" + offCategory[k] 282 ).style.display = "none"; 283 284 var temp = document 285 .querySelector(".fx-categoriesMenu li#category" + offCategory[k]) 286 .parentElement.parentElement.querySelectorAll("ul > li"); 287 var counter = 0; 288 289 for (var l = 0; l < temp.length; l++) { 290 if (temp[l].getAttribute("style")) { 291 counter++; 292 } 293 } 294 295 if (counter == temp.length) { 296 if (optionValue == "option3") 297 document 298 .querySelector( 299 ".fx-categoriesMenu li#category" + offCategory[k] 300 ) 301 .parentElement.parentElement.querySelector( 302 ".fx-triggerCategory" 303 ) 304 .classList.add("none"); 305 else if (optionValue == "option2") { 306 document 307 .querySelector( 308 ".fx-categoriesMenu li#category" + offCategory[k] 309 ) 310 .parentElement.parentElement.classList.add("none"); 311 } 312 } 313 } 314 } 315 316 if (document.querySelector(".shop_product ")) { 317 var currentEl = innerBox.querySelector(".fx-categoriesMenu .current"); 318 319 function checkParent(el) { 320 var parentEl = el.parentElement; 321 if (parentEl.classList.toString().indexOf("level") >= 0) { 322 parentEl.classList.add("show"); 323 parentEl.nextElementSibling.classList.add("open"); 324 } 325 326 if (el.parentElement.parentElement.tagName === "LI") { 327 checkParent(el.parentElement.parentElement); 328 } 329 } 330 331 checkParent(currentEl); 332 } else if (document.querySelector(".shop_product_list")) { 333 var currTop = innerBox.querySelector(".fx-categoriesMenu .current"); 334 335 if (currTop) { 336 var lvl = currTop.querySelector("ul[class^='level']"); 337 if (lvl) { 338 lvl.classList.add("show"); 339 lvl.nextElementSibling.classList.add("open"); 340 } 341 342 var allCurrentParent = innerBox.querySelectorAll( 343 ".fx-categoriesMenu .current_parent" 344 ); 345 346 if (allCurrentParent) { 347 for (var z = 0; z < allCurrentParent.length; z++) { 348 var lvlCurr = allCurrentParent[z].querySelector( 349 "ul[class^='level']" 350 ); 351 if (lvlCurr) { 352 lvlCurr.classList.add("show"); 353 lvlCurr.nextElementSibling.classList.add("open"); 354 } 355 } 356 } 357 } 358 } 359 } else { 360 mainBox.classList.remove("loading"); 361 362 if (xhr.status == 400) { 363 console.warn("BÅÄ d w zapytaniu."); 364 } 365 366 if (xhr.status == 401) { 367 console.warn("BÅÄ d w uwierzytelnieniu"); 368 } 369 370 if (xhr.status == 403) { 371 console.warn("Brak dostÄpu do danych."); 372 } 373 374 if (xhr.status == 404) { 375 console.warn("Zasób nie znaleziony."); 376 } 377 378 if (xhr.status == 405) { 379 console.warn("Zabroniona operacja."); 380 } 381 382 if (xhr.status == 500) { 383 console.warn("WewnÄtrzny bÅÄ d serwera - nie może skoÅczyÄ Å¼Ä dania."); 384 } 385 } 386 }; 387 388 xhr.ontimeout = function (e) { 389 console.warn("Your request timed out."); 390 }; 391 392 xhr.open("GET", endPoint); 393 xhr.send(); 394 }; 395 396 var checkChildren = function checkChildren(item, counter, parent, lvl) { 397 if (item.length) { 398 var counterLevel2 = ++counter; 399 400 if (counterLevel2 <= lvl || lvl == -1) { 401 var subMenu = document.createElement("ul"); 402 subMenu.classList.add("level_".concat(counterLevel2)); 403 parent.classList.add("parent"); 404 item.forEach(function (i) { 405 var li = document.createElement("li"); 406 li.setAttribute("id", "category".concat(i.id)); 407 li.innerHTML = '<a href="' 408 .concat(i.url, '" title="') 409 .concat(i.name, '">\n ') 410 .concat(i.name, "\n </a>"); 411 checkChildren(i.children, counterLevel2, li, howLvl); 412 subMenu.appendChild(li); 413 }); 414 parent.appendChild(subMenu); 415 } 416 } 417 }; 418 419 var countItems = function countItems(item) { 420 var lvl = 421 arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; 422 423 if (lvl == 1) { 424 if (item.items == 0 && item.children.length == 0) { 425 return 0; 426 } else if (item.items > 0 && item.children.length == 0) { 427 return item.items; 428 } else if (item.items == 0 && item.children.length > 0) { 429 return countItems(item.children, 2); 430 } else if (item.items > 0 && item.children.length > 0) { 431 return item.items + countItems(item.children, 2); 432 } 433 } else if (lvl > 1) { 434 var count = 0; 435 436 if (item.length) { 437 item.forEach(function (i) { 438 if (i.items == 0 && i.children.length == 0) { 439 count += 0; 440 } else if (i.items > 0 && i.children.length == 0) { 441 count += i.items; 442 } else if (i.items == 0 && i.children.length > 0) { 443 count += countItems(i.children, 2); 444 } else if (i.items > 0 && i.children.length > 0) { 445 count += i.items + countItems(i.children, 2); 446 } 447 }); 448 return count; 449 } else { 450 return 0; 451 } 452 } 453 }; 454 455 getInfo(); 456}; 457 458window.addEventListener("load", init); 459 460 461$(document).ready(function () { 462 // RWD mobile changes - MENU position 463 464 if (fxMobileViewport.matches) { 465 $('.logo-bar > .basket, .logo-bar > .basket-contain, .logo-bar > .search__container').wrapAll('<div class="bbs-wrap"></div>'); 466 $('.link-logo').after($('.menu')); 467 $('.menu').after($('.bbs-wrap')); 468 $('.bbs-wrap').prepend('<div class="fx-panel"></div><div id="fx-search"></div>'); 469 $('.fx-panel').on('click', function () { 470 $(this).toggleClass('fx-active'); 471 $('header .login-bar .links').toggleClass('fx-active'); 472 }); 473 $('#fx-search').on('click', function () { 474 $(this).toggleClass('fx-active'); 475 $('.search__container').toggleClass('fx-active'); 476 }); 477 478 var fxTabs = $('#fx-tabs'); 479 if (fxTabs.length > 0) { 480 $('#box_specialoffer.slider, #box_lastadded.slider, #box_bestsellers.slider').addClass('fx-tab'); 481 fxTabs.after($('.fx-tab').detach()); 482 $('.fx-tab').each(function (i) { 483 $(this).addClass('fx-box-' + (i + 1)); 484 fxTabs.append($(this).find('.boxhead').detach().addClass('fx-tab-' + (i + 1))); 485 $(".fx-tab-1").addClass("active"); 486 $(".fx-box-1").css("display", "block") 487 }); 488 var fxTab1 = $('.fx-tab-1'); 489 var fxTab2 = $('.fx-tab-2'); 490 var fxTab3 = $('.fx-tab-3'); 491 var fxBox1 = $('.fx-box-1'); 492 var fxBox2 = $('.fx-box-2'); 493 var fxBox3 = $('.fx-box-3'); 494 $(function () { 495 fxTab1.bind('click touchstart', function ()
495 { 496 fxTab1.addClass("active"); 497 fxTab2.removeClass("active"); 498 fxTab3.removeClass("active"); 499 fxBox1.show(); 500 fxBox2.hide(); 501 fxBox3.hide() 502 }); 503 fxTab2.bind('click touchstart', function () { 504 fxTab2.addClass("active"); 505 fxTab1.removeClass("active"); 506 fxTab3.removeClass("active"); 507 fxBox2.show(); 508 fxBox1.hide(); 509 fxBox3.hide() 510 }); 511 fxTab3.bind('click touchstart', function () { 512 fxTab3.addClass("active"); 513 fxTab2.removeClass("active"); 514 fxTab1.removeClass("active"); 515 fxBox3.show(); 516 fxBox2.hide(); 517 fxBox1.hide() 518 }) 519 }) 520 } 521 522 if ($('#fx-curtain-menu').length > 0) { 523 $('.wrap > .menu').addClass('fx-curtain-menu') 524 } 525 526 // Blog 527 528 var fxBlog = $('#box_articlelist'); 529 var fxNews = $('#fx-news'); 530 if (fxBlog.length > 0) { 531 fxNews.addClass('fx-active'); 532 533 $('#box_articlelist article').each(function () { 534 var article = $(this) 535 , fxSpeed = randomSpeed() 536 , fxImg = article.find('.article-image') 537 , fxBlogLink = article.find('.article-name').attr('href'); 538 539 540 article.find('.article-header').prepend('<a class="fx-img row" data-speed="' + fxSpeed + '"></a>'); 541 article.find('.fx-img').prepend(fxImg); 542 article.find('.fx-img').attr('href', fxBlogLink); 543 544 if (fxImg.attr('src') != null) { 545 article.find('.fx-img').css('background-image', 'url(' + fxImg.attr('src') + ')'); 546 } else { 547 article.find('.fx-img').css('background', '#ededed'); 548 } 549 550 $('#box_articlelist').mousemove(function (e) { 551 var s = article.find('.fx-img').data('speed') * 10 552 , height = s / $(window).height() 553 , width = s / $(window).width() 554 , pageX = e.pageX - ($(window).width() / 2) 555 , pageY = e.pageY - ($(window).height() / 2) 556 , newX = width * pageX * -1 - 25 557 , newY = height * pageY * -1 - 50; 558 559 article.find('.fx-img').css("background-position", newX/2 + "px " + newY/3 + "px"); 560 }); 561 }); 562 563 if (fxNews.length > 0) { 564 fxNews.append(fxBlog); 565 } 566 }; 567 568 // footer mods 569 $('.logo-bar .link-logo').clone().insertBefore($('footer .innerfooter ul.overall')); 570 571 if ($('.userfooter').length > 0) { 572 $('footer .userfooter').append($('#shoper-foot')); 573 } 574 575 // producers in menu 576 var fxprod = $('.menu .innermenu .menu-list li h3 a[href="/fx-producent"]'); 577 578 if ($('#box_producers').length > 0 && fxprod.length > 0){ 579 //add class to parent li 580 fxprod.parents('li').addClass('parent fx-producers').append('<div class="submenu level1"></div>'); 581 582 var fxcontainer = $('.fx-producers .submenu'); 583 var fxproducers = $('#box_producers_select'); 584 if (fxcontainer.length > 0 && fxproducers.length > 0) { 585 $('#box_producers').css('display', 'none'); 586 fxproducers.find('option').each(function () { 587 var name = $(this).text(); 588 var href = $(this).attr('value') 589 fxcontainer.append('<li><a href="' + href + '">' + name + '</a></li>') 590 }); 591 592 // create the title letters 593 var lastLetter = ''; 594 fxcontainer.find('li').each(function () { 595 var $this = $(this), 596 text = $.trim($this.text()), 597 firstLetter = text[0]; 598
599 if (firstLetter != lastLetter) { 600 $this.before('<p class="title">' + firstLetter); 601 lastLetter = firstLetter; 602 } 603 }); 604 fxcontainer.find('p').each(function () { 605 $(this).nextUntil('p', 'li').wrapAll('<ul>'); 606 $(this).next().wrap('<li class="fx-col"></li>'); 607 $(this).next().prepend($(this)); 608 }); 609 $('.fx-col:nth-of-type(1)').remove(); 610 $('.fx-col').wrapAll('<ul class="level1"></ul>'); 611 } 612 } 613 614 //animations 615 616 var animateHTML = function () { 617 var elems; 618 var windowHeight; 619 620 function init() { 621 elems = document.querySelectorAll('.fx-animation'); 622 windowHeight = window.innerHeight; 623 addEventHandlers(); 624 checkPosition(); 625 } 626 627 function addEventHandlers() { 628 window.addEventListener('scroll', checkPosition); 629 window.addEventListener('resize', init); 630 } 631 632 function checkPosition() { 633 for (var i = 0; i < elems.length; i++) { 634 var positionFromTop = elems[i].getBoundingClientRect().top + 200; 635 636 if (positionFromTop - windowHeight <= 0) { 637 elems[i].className = elems[i].className.replace( 638 'fx-animation', 639 'fx-start-animation' 640 ); 641 } 642 } 643 } 644 return { 645 init: init 646 }; 647 }; 648 animateHTML().init(); 649 650 } else { 651 console.log('mobil header'); 652 } 653 654 var fxWelcome = $('#fx-welcome'); 655 if (fxWelcome.length > 0) { 656 fxWelcome.append('<div id="fx-welcome-x"><i class="fa fa-times"></i></div>'); 657 $('header').prepend(fxWelcome); 658 $('#fx-welcome-x').click(function () { 659 fxWelcome.slideToggle() 660 }) 661 } 662 663 // List style 664 $('#box_mainproducts .boxhead').append($('.top.row #box_filter')); 665 666 // product page 667 $('#box_productfull .productimg.f-grid-6+div').prepend($('#box_productfull .boxhead')); 668 669 // slick slider init 670 /* 671 $('#fx-product-slider').slick({ 672 slidesToShow: 1, 673 slidesToScroll: 1, 674 autoplay: false, 675 autoplaySpeed: 2000, 676 dots: true, 677 });*/ 678 679 // quantity buttons 680 681 $(function () { 682 var fxCardBtns = $(".shop_product .quantity_wrap .number-wrap"); 683 fxCardBtns.append('<span class="fx-quantity-plus">+</span>'); 684 fxCardBtns.append('<span class="fx-quantity-minus">-</span>'); 685 $('.fx-quantity-plus').on('click', function () { 686 var $qty = $(this).parent().find('input.short'); 687 var currentVal = parseInt($qty.val()); 688 if (!isNaN(currentVal)) { 689 $qty.val(currentVal + 1); 690 } 691 }); 692 $('.fx-quantity-minus').on('click', function () { 693 var $qty = $(this).parent().find('input.short'); 694 var currentVal = parseInt($qty.val()); 695 if (!isNaN(currentVal) && currentVal > 1) { 696 $qty.val(currentVal - 1); 697 } 698 }); 699 700 }); 701 702 // lang module in header 703 if ($('#fx-lang').length > 0 && $('#box_languages .icons').length > 0) { 704 $('.login-bar').prepend($('#box_languages .icons')); 705 $('#box_languages').css('display', 'none'); 706 } 707 708 //Bottom of callback function in "ready" method 709 setTimeout(collapsedMenu, 1000); 710 711}); 712 713Shop.include({ 714 selectorFunctions: { 715 boxslider: { 716 selector: '.box.slider', 717 load: function (slider, shopInstance) { 718 var isAnimated; 719 var _initialSlideWidth = 280; 720 var _slideWidth; 721 var _sliderWidth; 722 var _visibleSlides; 723 var _maxHeight = 0; 724 var _autoMove = false; 725 var slides; 726 var sliderWrap; 727 var prev; 728 var next; 729 var _autoMoveDuration = Shop.useroptions.slider.automove; 730 var nav; 731 /** 732 * in xhrBox we need to know if this functiona was already called or no 733 */ 734 slider.selectorFnTriggered = true; 735 736 isAnimated = false;
737 slider.removeClass('loading'); 738 shopInstance.lazypicture.lazyLoading(); 739 740 if (slider.hasClass('slider_automove')) { 741 _autoMove = true; 742 } 743 744 var slides = slider.find('.product'); 745 746 if (slides.length > 1) { 747 var sliderWrap = $('<div class="slider-wrap" />').css('text-align', 'left'); 748 749 var nav = $('<div />').appendTo(slider); 750 var prev = $('<span class="slider-nav-left" />').css({ 751 'display': 'none' 752 }).appendTo(nav); 753 var next = $('<span class="slider-nav-right" />').css({ 754 'display': 'block' 755 }).appendTo(nav); 756 757 slides.wrapAll(sliderWrap); 758 sliderWrap = slider.find('.slider-wrap'); 759 760 shopInstance.addEvent('img:change:slider:'+ slider.attr('id'), function () { 761 sliderWrap.css('height', 'auto'); 762 763 slides.each(function() { 764 if($(this).outerHeight() >= _maxHeight) { 765 _maxHeight = $(this).outerHeight(); 766 sliderWrap.height(_maxHeight + 6); 767 } 768 }); 769 }); 770 771 $(window).on('resize', fxBoxSlider).trigger('resize'); 772 $('#fx-tabs .boxhead').click('resize', fxBoxSlider); 773 774 next.on('click', function (ev) { 775 ev.stopPropagation(); 776 if(!isAnimated) { 777 slides.animate({ 778 left: "-=" + (_slideWidth+20) 779 }, { 780 duration: 400, 781 start: function () { 782 isAnimated = true; 783 }, 784 complete: function() { 785 var pos = parseInt($(this).css('left')); 786 787 if((slides.length - _visibleSlides) * Math.floor(_slideWidth) <= -pos) { 788 next.hide(); 789 } 790 791 if(-pos > 0) { 792 prev.show(); 793 } 794 795 isAnimated = false; 796 } 797 }); 798 } 799 }); 800 801 prev.on('click', function (ev) { 802 ev.stopPropagation(); 803 if(!isAnimated) { 804 slides.animate({ 805 left: "+=" + (_slideWidth+20) 806 }, { 807 duration: 400, 808 start: function () { 809 isAnimated = true; 810 }, 811 complete: function() { 812 var pos = parseInt($(this).css('left')); 813 814 if(-pos <= 0) { 815 prev.hide(); 816 } 817 818 if((slides.length - _visibleSlides) * Math.floor(_slideWidth) >= -pos) { 819 next.show(); 820 } 821 isAnimated = false; 822 } 823 }); 824 } 825 }); 826 827 slider.on('swipeleft', function () { 828 if (next.is(':visible')) { 829 next.trigger('click'); 830 } 831 }); 832 833 slider.on('swiperight', function () { 834 if (prev.is(':visible')) { 835 prev.trigger('click'); 836 } 837 }); 838 839 if (_autoMove) { 840 setInterval(function () { 841 if (next.is(':visible')) { 842 next.trigger('click'); 843 } else { 844 slides.animate({ 845 left: 0 846 }, 600, function () { 847 next.show(); 848 prev.hide(); 849 }) 850 } 851 }, _autoMoveDuration) 852 } 853 854 function fxBoxSlider() { 855 _sliderWidth = slider.outerWidth(); 856 _visibleSlides = Math.floor(_sliderWidth / _initialSlideWidth) || 1; 857 _slideWidth = (_sliderWidth - (20 * (_visibleSlides - 1))) / _visibleSlides; 858 859 slides.each(function () { 860 if ($(this).outerHeight() >= _maxHeight) { 861 _maxHeight = $(this).outerHeight(); 862 } 863 }); 864 865 slides.outerWidth(_slideWidth); 866 sliderWrap.outerWidth(((_slideWidth + 20) * slides.length) + 3).height(_maxHeight + 6); 867 868 slides.css('left', '0'); 869 870 if (slides.length > _visibleSlides) { 871 next.show(); 872 prev.hide(); 873 874 } else { 875 next.hide(); 876 prev.hide(); 877 } 878 } 879 880 } 881 } 882 } 883 884 } 885});
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.