1/*!----------------------------------------------------------------- 2 Name: Snow - Minimal & Clean Portfolio HTML Template 3 Version: 1.1.0 4 Author: nK, unvab 5 Website: https://nkdev.info, http://unvab.com/ 6 Purchase: https://nkdev.info 7 Support: https://nk.ticksy.com 8 License: You must have a valid license purchased only from ThemeForest (the above link) in order to legally use the theme for your project. 9 Copyright 2017. 10-------------------------------------------------------------------*/ 11;(function() { 12'use strict'; 13 14var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 15 16function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 17 18/*------------------------------------------------------------------ 19 20 Theme Options 21 22-------------------------------------------------------------------*/ 23var options = { 24 enableShortcuts: true, 25 scrollToAnchorSpeed: 700, 26 parallaxSpeed: 0.8, 27 28 templates: { 29 secondaryNavbarBackItem: 'Back', 30 31 plainVideoIcon: '<span class="nk-video-icon"><span><span class="nk-play-icon"></span></span></span>', 32 plainVideoLoadIcon: '<span class="nk-loading-spinner"><i></i></span>', 33 fullscreenVideoClose: '<span class="nk-icon-close"></span>', 34 35 instagram: '<div class="col-3">\n <a href="{{link}}" target="_blank">\n <img src="{{image}}" alt="{{caption}}" class="nk-img-stretch">\n </a>\n </div>', 36 instagramLoadingText: 'Loading...', 37 instagramFailText: 'Failed to fetch data', 38 instagramApiPath: 'php/instagram/instagram.php', 39 40 twitter: '<div class="nk-twitter">\n <span class="nk-twitter-icon fa fa-twitter"></span>\n <div class="nk-twitter-text">\n {{tweet}}\n </div>\n </div>', 41 twitterLoadingText: 'Loading...', 42 twitterFailText: 'Failed to fetch data', 43 twitterApiPath: 'php/twitter/tweet.php' 44 }, 45 46 shortcuts: { 47 closeFullscreenVideo: 'esc', 48 49 postScrollToComments: 'c', 50 51 toggleSideLeftNavbar: 'alt+l', 52 openSideLeftNavbar: '', 53 closeSideLeftNavbar: 'esc', 54 55 toggleSideRightNavbar: 'alt+r', 56 openSideRightNavbar: '', 57 closeSideRightNavbar: 'esc', 58 59 toggleFullscreenNavbar: 'alt+f', 60 openFullscreenNavbar: '', 61 closeFullscreenNavbar: 'esc' 62 } 63}; 64 65/*------------------------------------------------------------------ 66 67 Utility 68 69-------------------------------------------------------------------*/ 70var $ = jQuery; 71var tween = window.TweenMax; 72var isIOs = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 73var isMobile = /Android|iPhone|iPad|iPod|BlackBerry|Windows Phone/g.test(navigator.userAgent || navigator.vendor || window.opera); 74var isTouch = 'ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch; 75 76// add 'is-mobile' or 'is-desktop' classname to html tag 77$('html').addClass(isMobile ? 'is-mobile' : 'is-desktop'); 78 79/** 80 * window size 81 */ 82var $wnd = $(window); 83var $doc = $(document); 84var $body = $('body'); 85var wndW = 0; 86var wndH = 0; 87var docH = 0; 88function getWndSize() { 89 wndW = $wnd.width(); 90 wndH = $wnd.height(); 91 docH = $doc.height(); 92} 93getWndSize(); 94$wnd.on('resize load orientationchange', getWndSize); 95 96/** 97 * Debounce resize 98 */ 99var resizeArr = []; 100var resizeTimeout = void 0; 101$wnd.on('load resize orientationchange', function (e) { 102 if (resizeArr.length) { 103 clearTimeout(resizeTimeout); 104 resizeTimeout = setTimeout(function () { 105 for (var k = 0; k < resizeArr.length; k++) { 106 resizeArr[k](e); 107 } 108 }, 50); 109 } 110}); 111function _debounceResize(func) { 112 if (typeof func === 'function') { 113 resizeArr.push(func); 114 } else { 115 window.dispatchEvent(new Event('resize')); 116 } 117} 118 119/** 120 * Throttle scroll 121 * thanks: https://jsfiddle.net/mariusc23/s6mLJ/31/ 122 */ 123var hideOnScrollList = []; 124var didScroll = void 0; 125var lastST = 0; 126 127$wnd.on('scroll load resize orientationchange', function () { 128 if (hideOnScrollList.length) { 129 didScroll = true; 130 } 131}); 132 133function hasScrolled() { 134 var ST = $wnd.scrollTop(); 135 136 var type = ''; // [up, down, end, start] 137 138 if (ST > lastST) { 139 type = 'down'; 140 } else if (ST < lastST) { 141 type = 'up'; 142 } else { 143 type = 'none'; 144 } 145 146 if (ST === 0) { 147 type = 'start'; 148 } else if (ST >= docH - wndH) { 149 type = 'end'; 150 } 151 152 for (var k in hideOnScrollList) { 153 if (typeof hideOnScrollList[k] === 'function') { 154 hideOnScrollList[k](type, ST, lastST, $wnd); 155 } 156 } 157 158 lastST = ST; 159} 160 161setInterval(function () { 162 if (didScroll) { 163 didScroll = false;
164 window.requestAnimationFrame(hasScrolled); 165 } 166}, 250); 167 168function _throttleScroll(callback) { 169 hideOnScrollList.push(callback); 170} 171 172/** 173 * Body Overflow 174 * Thanks https://jsfiddle.net/mariusc23/s6mLJ/31/ 175 * Usage: 176 * // enable 177 * bodyOverflow(1); 178 * 179 * // disable 180 * bodyOverflow(0); 181 */ 182var bodyOverflowEnabled = void 0; 183var isBodyOverflowing = void 0; 184var scrollbarWidth = void 0; 185var originalBodyPadding = void 0; 186var $fullNavbar = $('.nk-navbar-full'); 187function bodyGetScrollbarWidth() { 188 // thx d.walsh 189 var scrollDiv = document.createElement('div'); 190 scrollDiv.className = 'nk-body-scrollbar-measure'; 191 $body[0].appendChild(scrollDiv); 192 var result = scrollDiv.offsetWidth - scrollDiv.clientWidth; 193 $body[0].removeChild(scrollDiv); 194 return result; 195} 196function bodyCheckScrollbar() { 197 var fullWindowWidth = window.innerWidth; 198 if (!fullWindowWidth) { 199 // workaround for missing window.innerWidth in IE8 200 var documentElementRect = document.documentElement.getBoundingClientRect(); 201 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left); 202 } 203 isBodyOverflowing = $body[0].clientWidth < fullWindowWidth; 204 scrollbarWidth = bodyGetScrollbarWidth(); 205} 206function bodySetScrollbar() { 207 if (typeof originalBodyPadding === 'undefined') { 208 originalBodyPadding = $body.css('padding-right') || ''; 209 } 210 211 if (isBodyOverflowing) { 212 $body.add($fullNavbar).css('paddingRight', scrollbarWidth + 'px'); 213 } 214} 215function bodyResetScrollbar() { 216 $body.css('paddingRight', originalBodyPadding); 217 $fullNavbar.css('paddingRight', ''); 218} 219function _bodyOverflow(enable) { 220 if (enable && !bodyOverflowEnabled) { 221 bodyOverflowEnabled = 1; 222 bodyCheckScrollbar(); 223 bodySetScrollbar(); 224 $body.css('overflow', 'hidden'); 225 } else if (!enable && bodyOverflowEnabled) { 226 bodyOverflowEnabled = 0; 227 $body.css('overflow', ''); 228 bodyResetScrollbar(); 229 } 230} 231 232/** 233 * In Viewport checker 234 * return visible percent from 0 to 1 235 */ 236function _isInViewport($item, returnRect) { 237 var rect = $item[0].getBoundingClientRect(); 238 var result = 1; 239 240 if (rect.right <= 0 || rect.left >= wndW) { 241 result = 0; 242 } else if (rect.bottom < 0 && rect.top <= wndH) { 243 result = 0; 244 } else { 245 var beforeTopEnd = Math.max(0, rect.height + rect.top); 246 var beforeBottomEnd = Math.max(0, rect.height - (rect.top + rect.height - wndH)); 247 var afterTop = Math.max(0, -rect.top); 248 var beforeBottom = Math.max(0, rect.top + rect.height - wndH); 249 if (rect.height < wndH) { 250 result = 1 - (afterTop || beforeBottom) / rect.height; 251 } else { 252 if (beforeTopEnd <= wndH) { 253 result = beforeTopEnd / wndH; 254 } else if (beforeBottomEnd <= wndH) { 255 result = beforeBottomEnd / wndH; 256 } 257 } 258 result = result < 0 ? 0 : result; 259 } 260 if (returnRect) { 261 return [result, rect]; 262 } 263 return result; 264} 265 266/** 267 * Scroll To 268 */ 269function _scrollTo($to, callback) { 270 var scrollPos = false; 271 var speed = this.options.scrollToAnchorSpeed / 1000; 272 273 if ($to === 'top') { 274 scrollPos = 0; 275 } else if ($to === 'bottom') { 276 scrollPos = Math.max(0, docH - wndH); 277 } else if (typeof $to === 'number') { 278 scrollPos = $to; 279 } else { 280 scrollPos = $to.offset ? $to.offset().top : false; 281 } 282 283 if (scrollPos !== false && $wnd.scrollTop() !== scrollPos) { 284 tween.to($wnd, speed, { 285 scrollTo: { 286 y: scrollPos, 287 autoKill: true 288 }, 289 ease: Power2.easeOut, 290 autoKill: true, 291 overwrite: 5 292 }); 293 if (callback) { 294 tween.delayedCall(speed, callback); 295 } 296 } else if (typeof callback === 'function') { 297 callback(); 298 } 299} 300 301/*------------------------------------------------------------------ 302 303 Set Custom Options 304 305-------------------------------------------------------------------*/ 306function _setOptions(newOpts) { 307 var self = this; 308 309 var optsTemplates = $.extend({}, this.options.templates, newOpts && newOpts.templates || {}); 310 var optsShortcuts = $.extend({}, this.options.shortcuts, newOpts && newOpts.shortcuts || {}); 311 312 self.options = $.extend({}, self.options, newOpts); 313 self.options.templates = optsTemplates; 314 self.options.shortcuts = optsShortcuts; 315} 316 317/*------------------------------------------------------------------ 318 319 Shortcuts 320 https://github.com/madrobby/keymaster 321 322-------------------------------------------------------------------*/ 323function _key(name, fn) { 324 if (typeof window.key === 'undefined') { 325 return; 326 } 327 name = this.options && this.options.shortcuts && this.options.shortcuts[name]; 328 329 if (name) { 330 window.key(name, fn); 331 } 332} 333function _initShortcuts() { 334 if (typeof window.key === 'undefined' || !this.options.enableShortcuts) { 335 return; 336 } 337 338 var self = this; 339 340 // FullScreen Video 341 self.key('closeFullscreenVideo', function () { 342 self.closeFullScreenVideo && self.closeFullScreenVideo(); 343 }); 344 345 // post single 346 self.key('postScrollToComments', function () { 347 var $comments = $('#comments'); 348 if ($comments.length) { 349 self.scrollTo($comments); 350 } 351 }); 352 353 // Side Left Navbar 354 var $leftSide = $('.nk-navbar-left-side'); 355 self.key('toggleSideLeftNavbar', function () { 356 self.toggleSide($leftSide); 357 }); 358 self.key('openSideLeftNavbar', function () { 359 self.openSide($leftSide); 360 }); 361 self.key('closeSideLeftNavbar', function () { 362 self.closeSide($leftSide); 363 }); 364 365 // Side Right Navbar 366 var $rightSide = $('.nk-navbar-right-side'); 367 self.key('toggleSideRightNavbar', function () { 368 self.toggleSide($rightSide); 369 }); 370 self.key('openSideRightNavbar', function () { 371 self.openSide($rightSide); 372 }); 373 self.key('closeSideRightNavbar', function () { 374 self.closeSide($rightSide); 375 }); 376 377 // Fullscreen Navbar 378 self.key('toggleFullscreenNavbar', function () { 379 self.toggleFullscreenNavbar(); 380 }); 381 self.key('openFullscreenNavbar', function () { 382 self.openFullscreenNavbar(); 383 }); 384 self.key('closeFullscreenNavbar', function () { 385 self.closeFullscreenNavbar(); 386 }); 387 388 // ESC - use also inside form elements 389 window.key.filter = function (event) { 390 var tagName = (event.target || event.srcElement).tagName; 391 var isContentEditable = (event.target || event.srcElement).getAttribute('contenteditable'); 392 var isESC = window.key.isPressed('esc'); 393 return isESC || !(isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA'); 394 }; 395} 396 397/*------------------------------------------------------------------ 398 399 Init Navbar 400 401-------------------------------------------------------------------*/ 402function _initNavbar() { 403 var self = this;
404 var $navbarTop = $('.nk-navbar-top'); 405 406 // add mobile navbar 407 var $mobileNavItems = $('[data-nav-mobile]'); 408 if ($mobileNavItems.length) { 409 $mobileNavItems.each(function () { 410 var $nav = $($(this).html()); 411 var $mobileNav = $($(this).attr('data-nav-mobile')); 412 413 // insert into mobile nav 414 $mobileNav.find('.nk-navbar-mobile-content > ul.nk-nav').append($nav); 415 }); 416 417 var $nav = $('.nk-navbar-mobile-content > ul.nk-nav'); 418 419 // remove background images 420 $nav.find('.bg-image, .bg-video').remove(); 421 422 // remove mega menus 423 $nav.find('.nk-mega-item > .dropdown').each(function () { 424 var $drop = $(this).children('ul').addClass('dropdown'); 425 426 // fix mega menu columns 427 $drop.find('> li > label').each(function () { 428 $(this).next().addClass('dropdown'); 429 $(this).parent().addClass('nk-drop-item'); 430 $(this).replaceWith($('<a href="#"></a>').html($(this).html())); 431 }); 432 433 $(this).replaceWith($drop); 434 }); 435 $nav.find('.nk-mega-item').removeClass('nk-mega-item'); 436 } 437 438 // sticky navbar 439 var navbarTop = $navbarTop.length ? $navbarTop.offset().top : 0; 440 // fake hidden navbar to prevent page jumping on stick 441 var $navbarFake = $('<div>').hide(); 442 function onScrollNav() { 443 var stickyOn = $wnd.scrollTop() >= navbarTop; 444 445 if (stickyOn) { 446 $navbarTop.addClass('nk-navbar-fixed'); 447 $navbarFake.show(); 448 } else { 449 $navbarTop.removeClass('nk-navbar-fixed'); 450 $navbarFake.hide(); 451 } 452 } 453 if ($navbarTop.hasClass('nk-navbar-sticky')) { 454 $wnd.on('scroll resize', onScrollNav); 455 onScrollNav(); 456 457 $navbarTop.after($navbarFake); 458 self.debounceResize(function () { 459 $navbarFake.height($navbarTop.innerHeight()); 460 }); 461 } 462 463 // correct dropdown position 464 function correctDropdown($item) { 465 if ($item.parent().is('.nk-nav')) { 466 var $dropdown = $item.children('.dropdown'); 467 var $parent = $item.parents('.nk-navbar:eq(0)'); 468 var isRight = $dropdown.css('right') !== 'auto'; 469 var css = { 470 marginLeft: '', 471 marginRight: '', 472 marginTop: 0, 473 display: 'block' 474 }; 475 476 $dropdown.css(css); 477 478 var rect = $dropdown[0].getBoundingClientRect(); 479 var itemRect = $item[0].getBoundingClientRect(); 480 481 // move dropdown from left corner 482 if (rect.left < 0) { 483 css.marginLeft = -rect.left; 484 } 485 486 // move dropdown from right corner 487 else if (rect.right > wndW) { 488 css.marginLeft = wndW - rect.right; 489 } 490 491 // check if dropdown not under item 492 var currentLeftPost = rect.left + (css.marginLeft || 0); 493 if (currentLeftPost > itemRect.left) { 494 css.marginLeft = (css.marginLeft || 0) - (currentLeftPost - itemRect.left); 495 } 496 497 // change to margin-right. In some cases left margin isn't working, for ex. in mega menu 498 if (isRight) { 499 css.marginRight = -1 * css.marginLeft; 500 css.marginLeft = ''; 501 } 502 503 // correct top position 504 css.marginTop = $parent.innerHeight() - $dropdown.offset().top + $parent.offset().top; 505 506 // hide menu 507 css.display = 'none'; 508 509 $dropdown.css(css); 510 } 511 } 512 513 // toggle dropdown 514 function closeSubmenu($item) { 515 if ($item.length) { 516 $item.removeClass('open'); 517 tween.to($item.children('.dropdown'), 0.3, { 518 opacity: 0, 519 display: 'none' 520 }); 521 $wnd.trigger('nk-closed-submenu', [$item]); 522 } 523 } 524 function openSubmenu($item) { 525 if (!$item.hasClass('open')) { 526 correctDropdown($item); 527 tween.to($item.children('.dropdown'), 0.3, { 528 opacity: 1, 529 display: 'block' 530 }); 531 $item.addClass('open'); 532 $wnd.trigger('nk-opened-submenu', [$item]); 533 } 534 } 535 var dropdownTimeout = void 0; 536 $navbarTop.on('mouseenter', 'li.nk-drop-item', function () { 537 var $item = $(this); 538 var $openedSiblings = $item.siblings('.open').add($item.siblings().find('.open')).add($item.parents('.nk-nav:eq(0)').siblings().find('.open')).add($item.parents('.nk-nav:eq(0)').siblings('.open')).add($item.parents('.nk-nav:eq(0)').parent().siblings().find('.open')); 539 540 clearTimeout(dropdownTimeout); 541 closeSubmenu($openedSiblings); 542 openSubmenu($item); 543 }).on('mouseleave', 'li.nk-drop-item', function () { 544 var $item = $(this); 545 clearTimeout(dropdownTimeout); 546 dropdownTimeout = setTimeout(function () { 547 closeSubmenu($item); 548 }, 200); 549 }); 550 $navbarTop.on('mouseleave', function () { 551 clearTimeout(dropdownTimeout); 552 dropdownTimeout = setTimeout(function () { 553 closeSubmenu($navbarTop.find('.open')); 554 }, 400); 555 }); 556 557 // hide / show 558 // add / remove solid color 559 var $autohide_nav = $navbarTop.filter('.nk-navbar-autohide'); 560 self.throttleScroll(function (type, scroll) { 561 var start = 400; 562 var hideClass = 'nk-onscroll-hide';
563 var showClass = 'nk-onscroll-show'; 564 565 // hide / show 566 if (type === 'down' && scroll > start) { 567 $autohide_nav.removeClass(showClass).addClass(hideClass); 568 } else if (type === 'up' || type === 'end' || type === 'start') { 569 $autohide_nav.removeClass(hideClass).addClass(showClass); 570 } 571 572 // add solid color 573 if ($navbarTop.hasClass('nk-navbar-transparent') && $navbarTop.hasClass('nk-navbar-sticky')) { 574 $navbarTop[(scroll > 70 ? 'add' : 'remove') + 'Class']('nk-navbar-solid'); 575 } 576 }); 577} 578 579/*------------------------------------------------------------------ 580 581 Init Navbar Side 582 583-------------------------------------------------------------------*/ 584function _initNavbarSide() { 585 var self = this; 586 var $overlay = $('<div class="nk-navbar-overlay">').appendTo($body); 587 588 // side navbars 589 var $leftSide = $('.nk-navbar-left-side'); 590 var $rightSide = $('.nk-navbar-right-side'); 591 var $sideNavs = $('.nk-navbar-side'); 592 593 self.sideNavbarIsOpened = function () { 594 return $sideNavs.hasClass('open'); 595 }; 596 597 // toggle navbars 598 function updateTogglers() { 599 $('[data-nav-toggle]').each(function () { 600 var active = $($(this).attr('data-nav-toggle')).hasClass('open'); 601 $(this)[(active ? 'add' : 'remove') + 'Class']('active'); 602 }); 603 } 604 self.toggleSide = function ($side, speed) { 605 self[$side.hasClass('open') ? 'closeSide' : 'openSide']($side, speed); 606 }; 607 self.openSide = function ($side, speed) { 608 if ($side.css('display') === 'none') { 609 return; 610 } 611 612 $side.addClass('open'); 613 614 // show sidebar 615 tween.to($side, speed || 0.4, { 616 x: $side.hasClass('nk-navbar-left-side') ? '100%' : '-100%' 617 }); 618 619 // show overlay 620 if ($side.hasClass('nk-navbar-overlay-content')) { 621 tween.to($overlay, 0.3, { 622 opacity: 0.6, 623 display: 'block' 624 }); 625 } 626 627 updateTogglers(); 628 }; 629 self.closeSide = function ($side, speed) { 630 $side.each(function () { 631 $(this).removeClass('open'); 632 633 // hide sidebar 634 tween.to(this, speed || 0.4, { 635 x: '0%' 636 }); 637 638 updateTogglers(); 639 }); 640 641 if (!$sideNavs.filter('.nk-navbar-overlay-content.open').length) { 642 // hide overlay 643 tween.to($overlay, 0.3, { 644 opacity: 0, 645 display: 'none' 646 }); 647 } 648 }; 649 $doc.on('click', '[data-nav-toggle]', function (e) { 650 var $nav = $($(this).attr('data-nav-toggle')); 651 if ($nav.hasClass('open')) { 652 self.closeSide($nav); 653 } else { 654 // hide another navigations 655 $('[data-nav-toggle]').each(function () { 656 self.closeSide($($(this).attr('data-nav-toggle'))); 657 }); 658 659 self.openSide($nav); 660 } 661 e.preventDefault(); 662 }); 663 664 // overlay 665 $doc.on('click', '.nk-navbar-overlay', function () { 666 self.closeSide($sideNavs); 667 }); 668 669 // hide sidebar if it invisible 670 self.debounceResize(function () { 671 $sideNavs.filter('.open').each(function () { 672 if (!$(this).is(':visible')) { 673 self.closeSide($(this)); 674 } 675 }); 676 }); 677 678 // swipe side navbars 679 if (!isTouch || typeof Hammer === 'undefined') { 680 return; 681 } 682 var swipeStartSize = 50; 683 var $swipeItem = void 0; 684 var navSize = void 0; 685 var openNav = void 0; 686 var closeNav = void 0; 687 var isRightSide = void 0; 688 var isLeftSide = void 0; 689 var isScrolling = 0; 690 var swipeDir = void 0; 691 var sidePos = false; 692 var startSwipe = false; 693 var endSwipe = false; 694 var mc = Hammer(document, { 695 touchAction: 'pan-x pan-y' 696 }); 697 mc.add(new Hammer.Pan({ 698 pointers: 1, 699 threshold: 0 700 })); 701 // If we detect a scroll before a panleft/panright, disable panning 702 // thanks: https://github.com/hammerjs/hammer.js/issues/771 703 mc.on('panstart', function (e) { 704 if (e.additionalEvent === 'panup' || e.additionalEvent === 'pandown') { 705 isScrolling = 1; 706 } 707 }); 708 // Reenable panning 709 mc.on('panend', function (e) { 710 if (!isScrolling) { 711 if ($swipeItem) { 712 var swipeSize = sidePos ? openNav ? sidePos : closeNav ? navSize - sidePos : 0 : 0; 713 var transitionTime = Math.max(0.15, 0.4 * (navSize - swipeSize) / navSize); 714 var swiped = 0; 715 716 if (swipeSize && swipeSize > 10) { 717 var velocityTest = Math.abs(e.velocityX) > 0.7; 718 if (swipeSize >= navSize / 3 || velocityTest) { 719 swiped = 1; 720 if (openNav) { 721 self.openSide($swipeItem, transitionTime); 722 } else { 723 self.closeSide($swipeItem, transitionTime); 724 } 725 } 726 } 727 if (!swiped) { 728 if (openNav) { 729 self.closeSide($swipeItem, transitionTime); 730 } else { 731 self.openSide($swipeItem, transitionTime); 732 } 733 } 734 } 735 openNav = closeNav = isRightSide = isLeftSide = swipeDir = sidePos = $swipeItem = startSwipe = endSwipe = false;
736 } 737 isScrolling = 0; 738 }); 739 mc.on('panleft panright panup pandown', function (e) { 740 if (isScrolling) { 741 return; 742 } 743 744 var isFirst = false; 745 var isFinal = e.isFinal; 746 747 if (startSwipe === false) { 748 startSwipe = e.center.x; 749 isFirst = true; 750 } 751 endSwipe = e.center.x; 752 753 // init 754 if (isFirst) { 755 swipeDir = e.direction === 2 ? 'left' : e.direction === 4 ? 'right' : false; 756 757 // right side 758 if ($rightSide && $rightSide.length) { 759 navSize = $rightSide.width(); 760 761 // open 762 if (wndW - startSwipe <= swipeStartSize && !$rightSide.hasClass('open') && !$leftSide.hasClass('open')) { 763 openNav = isRightSide = 1; 764 } 765 766 // close 767 else if (wndW - startSwipe >= navSize - 100 && $rightSide.hasClass('open')) { 768 closeNav = isRightSide = 1; 769 } 770 } 771 772 // left side 773 if ($leftSide && $leftSide.length && !isRightSide && $leftSide.is(':visible')) { 774 navSize = $leftSide.width(); 775 776 // open 777 if (startSwipe <= swipeStartSize && !$rightSide.hasClass('open') && !$leftSide.hasClass('open')) { 778 openNav = isLeftSide = 1; 779 } 780 781 // close 782 else if (startSwipe >= navSize - 100 && $leftSide.hasClass('open')) { 783 closeNav = isLeftSide = 1; 784 } 785 } 786 787 // swipe item 788 $swipeItem = isLeftSide ? $leftSide : isRightSide ? $rightSide : false;
789 790 // move 791 } else if (!isFinal && $swipeItem) { 792 if (isRightSide && (openNav && swipeDir === 'left' || closeNav && swipeDir === 'right')) { 793 // open side navbar 794 if (openNav) { 795 sidePos = Math.min(navSize, Math.max(0, startSwipe - endSwipe)); 796 } 797 798 // close side navbar 799 if (closeNav) { 800 var curPos = startSwipe - endSwipe; 801 if (startSwipe < wndW - navSize) { 802 curPos = wndW - navSize - endSwipe; 803 } 804 sidePos = navSize - Math.abs(Math.max(-navSize, Math.min(0, curPos))); 805 } 806 807 tween.set($swipeItem, { 808 x: -100 * sidePos / navSize + '%' 809 }); 810 } else if (isLeftSide && (openNav && swipeDir === 'right' || closeNav && swipeDir === 'left')) { 811 // open mobile navbar 812 if (openNav) { 813 sidePos = Math.min(navSize, Math.max(0, endSwipe - startSwipe)); 814 } 815 816 // close mobile navbar 817 if (closeNav) { 818 var curPos2 = endSwipe - startSwipe; 819 if (startSwipe > navSize) { 820 curPos2 = endSwipe - navSize; 821 } 822 sidePos = navSize - Math.abs(Math.max(-navSize, Math.min(0, curPos2))); 823 } 824 825 tween.set($swipeItem, { 826 x: 100 * sidePos / navSize + '%' 827 }); 828 } 829 } 830 831 if (isRightSide || isLeftSide) { 832 e.srcEvent.preventDefault(); 833 } 834 }); 835} 836 837/*------------------------------------------------------------------ 838 839 Init Navbar Fullscreen 840 841-------------------------------------------------------------------*/ 842function _initNavbarFullscreen() { 843 var self = this; 844 var $navbar = $('.nk-navbar-full'); 845 var $navbarTop = $('.nk-navbar-top'); 846 var $navbarSocial = $navbar.find('.nk-nav-social'); 847 var isOpened = void 0; 848 849 self.fullscreenNavbarIsOpened = function () { 850 return isOpened; 851 }; 852 853 self.toggleFullscreenNavbar = function () { 854 self[isOpened ? 'closeFullscreenNavbar' : 'openFullscreenNavbar'](); 855 }; 856 self.openFullscreenNavbar = function () { 857 if (isOpened || !$navbar.length) { 858 return; 859 } 860 isOpened = 1; 861 862 var $navbarMenuItems = $navbar.find('.nk-nav .nk-drop-item.open > .dropdown:not(.closed) > li > a'); 863 if (!$navbarMenuItems.length) { 864 $navbarMenuItems = $navbar.find('.nk-nav > li > a'); 865 } 866 867 // active all togglers 868 $('.nk-navbar-full-toggle').addClass('active'); 869 870 // set top position and animate 871 tween.set($navbarMenuItems, { 872 opacity: 0, 873 force3D: true 874 }); 875 tween.set($navbarSocial, { 876 opacity: 0, 877 force3D: true 878 }); 879 tween.to($navbar, 0.5, { 880 opacity: 1, 881 force3D: true, 882 display: 'block', 883 onComplete: function onComplete() { 884 self.initPluginNano($navbar); 885 } 886 }); 887 tween.staggerTo($navbarMenuItems, 0.3, { 888 y: 0, 889 opacity: 1, 890 delay: 0.2 891 }, 0.05); 892 tween.to($navbarSocial, 0.3, { 893 y: 0, 894 opacity: 1, 895 delay: 0.4 896 }); 897 898 $navbar.addClass('open'); 899 900 // prevent body scrolling 901 self.bodyOverflow(1); 902 903 // trigger event 904 $wnd.trigger('nk-open-full-navbar', [$navbar]); 905 }; 906 907 self.closeFullscreenNavbar = function (dontTouchBody) { 908 if (!isOpened || !$navbar.length) { 909 return; 910 } 911 isOpened = 0; 912 913 // disactive all togglers 914 $('.nk-navbar-full-toggle').removeClass('active'); 915 916 // set top position and animate 917 tween.to($navbar, 0.5, { 918 opacity: 0, 919 force3D: true, 920 display: 'none', 921 onComplete: function onComplete() { 922 if (!dontTouchBody) { 923 // restore body scrolling 924 self.bodyOverflow(0); 925 } 926 } 927 }); 928 929 // open navbar block 930 $navbar.removeClass('open'); 931 932 // trigger event 933 $wnd.trigger('nk-close-full-navbar', [$navbar]); 934 }; 935 936 $doc.on('click', '.nk-navbar-full-toggle', function (e) { 937 self.toggleFullscreenNavbar(); 938 e.preventDefault(); 939 }); 940 941 $wnd.on('nk-open-search-block', function () { 942 self.closeFullscreenNavbar(1); 943 }); 944 $wnd.on('nk-open-share-place', self.closeFullscreenNavbar); 945} 946 947/*------------------------------------------------------------------ 948 949 Init Dropdown Effect 1 for side navbars and fullscreen 950 951-------------------------------------------------------------------*/ 952function _initNavbarDropEffect() { 953 var self = this;
954 var $navbars = $('.nk-navbar-side, .nk-navbar-full'); 955 956 // add back item for dropdowns 957 $navbars.find('.dropdown').prepend('<li class="bropdown-back"><a href="#">' + self.options.templates.secondaryNavbarBackItem + '</a></li>'); 958 959 // change height of opened dropdown 960 function updateSideNavDropdown($item) { 961 var $nav = $item.parents('.nk-navbar:eq(0)'); 962 var $khNav = $nav.find('.nk-nav'); 963 var $drop = $nav.find('.nk-drop-item.open > .dropdown:not(.closed)'); 964 var $parentDrop = $drop.parents('.dropdown.closed:eq(0)'); 965 var $nano = $item.parents('.nano:eq(0)'); 966 var $nanoCont = $nano.children('.nano-content'); 967 var $navRow = $item.parents('.nk-nav-row:eq(0)'); 968 var $rows = $navRow.siblings('.nk-nav-row'); 969 if ($drop.length) { 970 var dropHeight = $drop.innerHeight(); 971 972 // vertical center for dropdown 973 if ($navRow.hasClass('nk-nav-row-center')) { 974 (function () { 975 $drop.css({ 976 top: 0 977 }); 978 979 var nanoHeight = $nano.innerHeight(); 980 var nanoNavRowHeight = nanoHeight; 981 var nanoTop = $nano.offset().top; 982 var dropTop = $drop.offset().top; 983 984 // remove additional rows size 985 if ($rows.length) { 986 $rows.each(function () { 987 nanoNavRowHeight = nanoNavRowHeight - $(this).innerHeight(); 988 }); 989 } 990 991 var top = 0; 992 if (dropHeight < nanoNavRowHeight) { 993 top = nanoTop - dropTop - $nanoCont.scrollTop(); 994 top += (nanoHeight - dropHeight) / 2; 995 } else { 996 top = -parseFloat($parentDrop.css('top')) || 0; 997 } 998 999 $drop.css({ 1000 top: top 1001 }); 1002 })(); 1003 } 1004 1005 $khNav.css('height', dropHeight); 1006 self.initPluginNano($nav); 1007 1008 // scroll to top 1009 tween.to($nanoCont, 0.3, { 1010 scrollTo: { y: 0 }, 1011 delay: 0.2 1012 }); 1013 } else { 1014 $khNav.css('height', ''); 1015 } 1016 self.initPluginNano($nav); 1017 } 1018 1019 // open / close submenu 1020 function toggleSubmenu(open, $drop) { 1021 var $newItems = $drop.find('> .dropdown > li > a'); 1022 var $oldItems = $drop.parent().find('> li > a'); 1023 1024 if (open) { 1025 $drop.addClass('open').parent().addClass('closed'); 1026 } else { 1027 $drop.removeClass('open').parent().removeClass('closed'); 1028 1029 var tmp = $newItems; 1030 $newItems = $oldItems; 1031 $oldItems = tmp; 1032 } 1033 1034 // show items 1035 tween.set($newItems, { 1036 x: open ? '15%' : '-15%', 1037 opacity: 0, 1038 display: 'block' 1039 }, 0.1); 1040 tween.staggerTo($newItems, 0.2, { 1041 x: '0%', 1042 opacity: 1, 1043 delay: 0.1 1044 }, 0.03); 1045 1046 // hide items 1047 tween.staggerTo($oldItems, 0.2, { 1048 x: open ? '-15%' : '15%', 1049 opacity: 0 1050 }, 0.03, function () { 1051 $oldItems.css('display', 'none'); 1052 }); 1053 } 1054 1055 $navbars.on('click', '.nk-drop-item > a', function (e) { 1056 toggleSubmenu(true, $(this).parent()); 1057 updateSideNavDropdown($(this)); 1058 e.preventDefault(); 1059 }); 1060 $navbars.on('click', '.bropdown-back > a', function (e) { 1061 toggleSubmenu(false, $(this).parent().parent().parent()); 1062 updateSideNavDropdown($(this)); 1063 e.preventDefault(); 1064 }); 1065} 1066 1067/*------------------------------------------------------------------ 1068 1069 Init Header Title 1070 1071-------------------------------------------------------------------*/ 1072function _initHeaderTitle() { 1073 var self = this; 1074 var $navbarHeader = $('.nk-header'); 1075 var isNavbarOpaque = $navbarHeader.hasClass('nk-header-opaque'); 1076 var isNavbarTransparent = $('.nk-navbar-top').hasClass('nk-header-transparent'); 1077 var $fullHeaderTitle = $('.nk-header-title-full'); 1078 1079 // remove header title padding if navbar opaque 1080 if (isNavbarOpaque) { 1081 $('.nk-header-title').css('padding-top', 0); 1082 } 1083 1084 self.debounceResize(function () { 1085 if ((isNavbarTransparent || isNavbarOpaque) && (!$fullHeaderTitle.length || !isNavbarOpaque)) { 1086 return; 1087 } 1088 1089 var navH = $navbarHeader.outerHeight() || 0; 1090 1091 // add header title padding 1092 if (!isNavbarTransparent && !isNavbarOpaque) { 1093 $('.nk-header-title').css('padding-top', navH); 1094 } 1095 1096 // fix header title height 1097 if ($fullHeaderTitle.length) { 1098 var headerH = '100vh'; 1099 1100 $fullHeaderTitle.css('height', 'auto'); 1101 1102 if (isNavbarOpaque) { 1103 headerH = 'calc(100vh - ' + navH + 'px)'; 1104 } 1105 1106 if ($fullHeaderTitle[0].scrollHeight < wndH) { 1107 $fullHeaderTitle.css('height', headerH); 1108 } 1109 } 1110 }); 1111} 1112 1113/*------------------------------------------------------------------ 1114 1115 Init Counters 1116 1117-------------------------------------------------------------------*/ 1118function _initCounters() { 1119 var self = this; 1120 var $progressCount = $('.nk-progress.nk-count'); 1121 var $numberCount = $('.nk-count:not(.nk-progress)'); 1122 1123 // set default progress 1124 $progressCount.each(function () { 1125 $(this).attr('data-nk-count', $(this).attr('data-progress')).find('.nk-progress-line > div').css('width', ($(this).attr('data-nk-count-from') || '0') + '%').find('.nk-progress-percent').html(''); 1126 }); 1127 1128 // set default numbers 1129 $numberCount.each(function () { 1130 $(this).attr('data-nk-count', $(this).attr('data-nk-count') || parseInt($(this).text(), 10)).html($(this).attr('data-nk-count-from') || '0'); 1131 }); 1132 1133 var countersNum = 1; 1134 function runCounters() { 1135 if (!countersNum) { 1136 return; 1137 } 1138 1139 var progress = $progressCount.filter('[data-nk-count]'); 1140 var numbers = $numberCount.filter('[data-nk-count]'); 1141 countersNum = progress.length + numbers.length; 1142 1143 // progress 1144 $progressCount.filter('[data-nk-count]').each(function () { 1145 var $item = $(this); 1146 if (self.isInViewport($item)) { 1147 (function () { 1148 var count = { 1149 curr: $item.attr('data-nk-count-from') || '0', 1150 to: $item.attr('data-nk-count') 1151 }; 1152 var $itemLine = $item.find('.nk-progress-line > div'); 1153 var $itemLabel = $item.find('.nk-progress-percent'); 1154 1155 tween.to($itemLine, 1, { 1156 width: count.to + '%' 1157 }); 1158 tween.to(count, 1, { 1159 curr: count.to, 1160 roundProps: 'curr', 1161 ease: Circ.easeIn, 1162 onUpdate: function onUpdate() { 1163 $itemLabel.text(count.curr + '%'); 1164 } 1165 }); 1166 $item.removeAttr('data-nk-count'); 1167 })(); 1168 } 1169 }); 1170 1171 // number 1172 $numberCount.filter('[data-nk-count]').each(function () { 1173 var $item = $(this); 1174 if (self.isInViewport($item)) { 1175 (function () { 1176 var count = { 1177 curr: $item.text(), 1178 to: $item.attr('data-nk-count') 1179 }; 1180 $item.removeAttr('data-nk-count data-nk-count-from'); 1181 tween.to(count, 1, { 1182 curr: count.to, 1183 roundProps: 'curr', 1184 ease: Circ.easeIn, 1185 onUpdate: function onUpdate() { 1186 $item.text(count.curr); 1187 } 1188 }); 1189 })(); 1190 } 1191 }); 1192 } 1193 1194 self.throttleScroll(runCounters); 1195 runCounters(); 1196} 1197 1198/*------------------------------------------------------------------ 1199 1200 Anchors 1201 1202-------------------------------------------------------------------*/ 1203function _initAnchors() { 1204 var self = this; 1205 1206 // click on anchors 1207 var $leftSideNav = $('.nk-navbar-left-side'); 1208 var $rightSideNav = $('.nk-navbar-right-side'); 1209 function closeNavs() { 1210 self.closeSide($leftSideNav); 1211 self.closeSide($rightSideNav); 1212 self.closeFullscreenNavbar(); 1213 } 1214 $doc.on('click', '.navbar a, .nk-navbar a, a.btn, a.nk-btn, a.nk-anchor, a.nk-header-title-scroll-down', function (e) { 1215 var isHash = this.hash; 1216 var isURIsame = this.baseURI === window.location.href; 1217 1218 if (isHash && isURIsame) { 1219 // sometimes hashs have no valid selector like ##hash, it will throw errors 1220 try { 1221 var $hashBlock = $(isHash); 1222 var hash = isHash.replace(/^#/, ''); 1223 if ($hashBlock.length || hash === 'top' || hash === 'bottom') { 1224 // close navigations 1225 closeNavs(); 1226 1227 // add hash to address bar 1228 if ($hashBlock.length) { 1229 $hashBlock.attr('id', ''); 1230 document.location.hash = hash; 1231 $hashBlock.attr('id', hash); 1232 } 1233 1234 // scroll to block 1235 self.scrollTo($hashBlock.length ? $hashBlock : hash); 1236 1237 e.preventDefault(); 1238 } 1239 } catch (e) {} 1240 } 1241 }); 1242 1243 // add active class on navbar items 1244 var $anchorItems = $('.nk-navbar .nk-nav > li > a[href*="#"]'); 1245 var anchorBlocks = []; 1246 function hashInArray(item) { 1247 for (var k = 0; k < anchorBlocks.length; k++) { 1248 if (anchorBlocks[k].hash === item) { 1249 return k; 1250 } 1251 } 1252 return false;
1253 } 1254 // get all anchors + blocks on the page 1255 $anchorItems.each(function () { 1256 var hash = this.hash.replace(/^#/, ''); 1257 if (!hash) { 1258 return; 1259 } 1260 1261 var $item = $(this).parent(); 1262 var $block = $('#' + hash); 1263 1264 if (hash && $block.length || hash === 'top') { 1265 var inArray = hashInArray(hash); 1266 if (inArray === false) { 1267 anchorBlocks.push({ 1268 hash: hash, 1269 $item: $item, 1270 $block: $block 1271 }); 1272 } else { 1273 anchorBlocks[inArray].$item = anchorBlocks[inArray].$item.add($item); 1274 } 1275 } 1276 }); 1277 // prepare anchor list and listen for scroll to activate items in navbar 1278 function updateAnchorItemsPositions() { 1279 for (var k = 0; k < anchorBlocks.length; k++) { 1280 var item = anchorBlocks[k]; 1281 var blockTop = 0; 1282 var blockH = wndH; 1283 if (item.$block.length) { 1284 blockTop = item.$block.offset().top; 1285 blockH = item.$block.innerHeight(); 1286 } 1287 item.activate = blockTop - wndH / 2; 1288 item.deactivate = blockTop + blockH - wndH / 2; 1289 } 1290 } 1291 function setAnchorActiveItem(type, ST) { 1292 for (var k = 0; k < anchorBlocks.length; k++) { 1293 var item = anchorBlocks[k]; 1294 var active = ST >= item.activate && ST < item.deactivate; 1295 item.$item[active ? 'addClass' : 'removeClass']('active'); 1296 } 1297 } 1298 if (anchorBlocks.length) { 1299 updateAnchorItemsPositions(); 1300 setAnchorActiveItem('static', $wnd.scrollTop()); 1301 self.throttleScroll(setAnchorActiveItem); 1302 self.debounceResize(updateAnchorItemsPositions); 1303 } 1304} 1305 1306/*------------------------------------------------------------------ 1307 1308 Init Video Blocks 1309 1310 -------------------------------------------------------------------*/ 1311function _initVideoBlocks() { 1312 if (typeof window.VideoWorker === 'undefined') { 1313 return; 1314 } 1315 var self = this; 1316 1317 // open fullscreen videos 1318 var openedFSVideo = void 0; 1319 self.openFullScreenVideo = function (url) { 1320 if (openedFSVideo) { 1321 return; 1322 } 1323 openedFSVideo = 1; 1324 1325 // get api for this video 1326 self.FullScreenVideoApi = new VideoWorker(url, { 1327 autoplay: 1, 1328 loop: 0, 1329 mute: 0, 1330 controls: 1 1331 }); 1332 1333 // set video size 1334 function setVideoSize() { 1335 var ratio = 16 / 9; 1336 var resultW = void 0; 1337 var resultH = void 0; 1338 1339 if (ratio > wndW / wndH) { 1340 resultW = wndW * 0.9; 1341 resultH = resultW / ratio; 1342 } else { 1343 resultH = wndH * 0.9; 1344 resultW = resultH * ratio; 1345 } 1346 self.FullScreenVideoWrapper.css({ 1347 width: resultW, 1348 height: resultH, 1349 top: (wndH - resultH) / 2, 1350 left: (wndW - resultW) / 2 1351 }); 1352 } 1353 1354 // create fullscreen video wrapper if doesn't exist 1355 if (!self.FullScreenVideo) { 1356 self.FullScreenVideo = $('<div class="nk-video-fullscreen"></div>').appendTo($body); 1357 1358 self.closeFullScreenVideo = function () { 1359 if (openedFSVideo) { 1360 openedFSVideo = 0; 1361 1362 self.FullScreenVideoApi.pause(); 1363 1364 // hide animation 1365 tween.to(self.FullScreenVideo, 0.4, { 1366 opacity: 0, 1367 display: 'none', 1368 onComplete: function onComplete() { 1369 self.FullScreenVideoWrapper.html(''); 1370 } 1371 }); 1372 tween.to(self.FullScreenVideoWrapper, 0.4, { 1373 scale: 0.9 1374 }); 1375 1376 // restore body scrolling 1377 self.bodyOverflow(0); 1378 } 1379 }; 1380 1381 // close icon 1382 $('<div class="nk-video-fullscreen-close">' + self.options.templates.fullscreenVideoClose + '</div>').on('click', self.closeFullScreenVideo).appendTo(self.FullScreenVideo); 1383 1384 // video container
1385 self.FullScreenVideoWrapper = $('<div class="nk-video-fullscreen-cont"></div>').appendTo(self.FullScreenVideo); 1386 1387 setVideoSize(); 1388 self.debounceResize(setVideoSize); 1389 } 1390 1391 // check api and run fullscreen 1392 if (self.FullScreenVideoApi && self.FullScreenVideoApi.isValid()) { 1393 self.FullScreenVideoApi.getIframe(function (iframe) { 1394 var $parent = $(iframe).parent(); 1395 self.FullScreenVideoWrapper.append(iframe); 1396 $parent.remove(); 1397 1398 // pause audio 1399 if (typeof soundManager !== 'undefined') { 1400 soundManager.pauseAll(); 1401 } 1402 1403 // show animation 1404 tween.fromTo(self.FullScreenVideo, 0.4, { 1405 opacity: 0 1406 }, { 1407 opacity: 1, 1408 display: 'block' 1409 }); 1410 tween.fromTo(self.FullScreenVideoWrapper, 0.4, { 1411 opacity: 0, 1412 scale: 0.9 1413 }, { 1414 opacity: 1, 1415 scale: 1, 1416 delay: 0.3 1417 }); 1418 1419 // prevent body scrolling 1420 self.bodyOverflow(1); 1421 }); 1422 } 1423 }; 1424 $doc.on('click', '.nk-video-fullscreen-toggle', function (e) { 1425 e.preventDefault(); 1426 self.openFullScreenVideo($(this).attr('href')); 1427 }); 1428 1429 // init plain video 1430 function addPlainPlayButton($plainCont) { 1431 $plainCont.find('.nk-video-plain-toggle').html(self.options.templates.plainVideoIcon); 1432 } 1433 function addPlainLoadButton($plainCont) { 1434 $plainCont.find('.nk-video-plain-toggle').html(self.options.templates.plainVideoLoadIcon || self.options.templates.plainVideoIcon); 1435 } 1436 $('.nk-plain-video[data-video]').each(function () { 1437 var $plainCont = $(this); 1438 var $plainIframe = void 0; 1439 var url = $(this).attr('data-video'); 1440 var thumb = $(this).attr('data-video-thumb'); 1441 var api = new VideoWorker(url, { 1442 autoplay: 0, 1443 loop: 0, 1444 mute: 0, 1445 controls: 1 1446 }); 1447 1448 if (api && api.isValid()) { 1449 var loaded = 0; 1450 api.getIframe(function (iframe) { 1451 // add iframe 1452 $plainIframe = $(iframe); 1453 var $parent = $plainIframe.parent(); 1454 tween.set(iframe, { 1455 opacity: 0, 1456 display: 'none' 1457 }); 1458 $plainIframe.appendTo($plainCont); 1459 $parent.remove(); 1460 1461 // add play button 1462 $plainCont.append('<span class="nk-video-plain-toggle"></span>'); 1463 addPlainPlayButton($plainCont); 1464 1465 // add play event 1466 $plainCont.on('click', function () { 1467 if (isMobile) { 1468 window.open(api.url); 1469 return; 1470 } 1471 1472 api.play(); 1473 1474 // add loading button 1475 if (!loaded) { 1476 addPlainLoadButton($plainCont); 1477 } 1478 }); 1479 }); 1480 // set thumb 1481 if (thumb) { 1482 $plainCont.css('background-image', 'url("' + thumb + '")'); 1483 } else { 1484 api.getImageURL(function (imgSrc) { 1485 $plainCont.css('background-image', 'url("' + imgSrc + '")'); 1486 }); 1487 } 1488 if (isMobile) { 1489 return; 1490 } 1491 api.on('play', function () { 1492 tween.to($plainIframe, 0.5, { 1493 opacity: 1, 1494 display: 'block', 1495 onComplete: function onComplete() { 1496 // add play button 1497 if (!loaded) { 1498 addPlainPlayButton($plainCont); 1499 loaded = 1; 1500 } 1501 } 1502 }); 1503 1504 // pause audio 1505 if (typeof soundManager !== 'undefined') { 1506 soundManager.pauseAll(); 1507 } 1508 }); 1509 api.on('pause', function () { 1510 tween.to($plainIframe, 0.5, { 1511 opacity: 0, 1512 display: 'none' 1513 }); 1514 }); 1515 } 1516 }); 1517} 1518 1519/*------------------------------------------------------------------ 1520 1521 Init Fullpage 1522 1523-------------------------------------------------------------------*/ 1524function _initFullPage() { 1525 var $fullPage = $('.nk-fullpage-portfolio:eq(0)'); 1526 var $eachItems = $fullPage.find('.nk-fullpage-item'); 1527 if (!$fullPage.length || !$eachItems.length) { 1528 return; 1529 } 1530 1531 $('html').css('overflow', 'hidden'); 1532 $('.nk-main').css('overflow', 'visible'); 1533 1534 var self = this; 1535 1536 // parse slides 1537 var slides = []; 1538 $eachItems.each(function () { 1539 var $this = $(this); 1540 slides.push({ 1541 $item: $this, 1542 $viewBtn: $this.find('.nk-fullpage-view-button').html(), 1543 $content: $this.find('.nk-fullpage-content').html(), 1544 img: $this.find('.nk-fullpage-image').attr('src'), 1545 letter: $this.attr('data-letter'), 1546 number: $this.attr('data-number') 1547 }); 1548 }); 1549 1550 // image blocks
1551 var $image1 = $('<div class="nk-fullpage-bg-image">').appendTo($fullPage); 1552 var $image2 = $('<div class="nk-fullpage-bg-image">').appendTo($fullPage); 1553 1554 // content 1555 var $content = $('<div class="nk-fullpage-content">'); 1556 var $content2 = $('<div class="nk-fullpage-content">'); 1557 var $content_button = $('<div class="nk-fullpage-view-button">'); 1558 $fullPage.append($content); 1559 $fullPage.append($content2); 1560 $fullPage.append($content_button); 1561 1562 // bullet navigation 1563 var $bullets = '<ul class="nk-fullpage-nav active">'; 1564 for (var k = 0; k < slides.length; k++) { 1565 $bullets += '<li>' + slides[k].letter + '</li>'; 1566 } 1567 $bullets += '</ul>'; 1568 $bullets = $($bullets); 1569 $fullPage.append($bullets); 1570 var $bulletsItems = $bullets.children('li'); 1571 1572 // numbers 1573 var $numbers = $('<div class="nk-fullpage-number">'); 1574 var $numbers2 = $('<div class="nk-fullpage-number">'); 1575 $fullPage.append($numbers); 1576 $fullPage.append($numbers2); 1577 1578 var isBusy = 0; 1579 var curIndex = 0; 1580 1581 // show new slide 1582 // effect: fade, up, down 1583 function slideShow(index) { 1584 var effect = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'fade'; 1585 var force = arguments[2]; 1586 1587 if (typeof slides[index] !== 'undefined' && curIndex != index && !isBusy || force) { 1588 isBusy = 1; 1589 1590 // animate image background 1591 switch (effect) { 1592 case 'up': 1593 case 'down': 1594 tween.set($image2, { 1595 y: effect == 'down' ? '100%' : '-100%', 1596 display: 'block' 1597 }); 1598 $image2.css('background-image', 'url("' + slides[index].img + '")'); 1599 tween.to($image2, 0.8, { 1600 y: '0%', 1601 force3D: true, 1602 ease: Power1.easeInOut 1603 }); 1604 tween.to($image1, 0.8, { 1605 opacity: 0, 1606 scale: 0.9, 1607 force3D: true, 1608 ease: Power1.easeInOut, 1609 onComplete: function onComplete() { 1610 $image1.css('background-image', 'url("' + slides[index].img + '")'); 1611 tween.set($image1, { 1612 scale: 1, 1613 opacity: 1 1614 }); 1615 $image2.css('background-image', ''); 1616 tween.set($image2, { 1617 display: 'none' 1618 }); 1619 isBusy = 0; 1620 } 1621 }); 1622 break; 1623 default: 1624 // fade 1625 tween.set($image2, { 1626 opacity: 0, 1627 display: 'block' 1628 }); 1629 $image2.css('background-image', 'url("' + slides[index].img + '")'); 1630 tween.to($image2, 0.8, { 1631 opacity: 1, 1632 force3D: true, 1633 onComplete: function onComplete() { 1634 $image1.css('background-image', 'url("' + slides[index].img + '")'); 1635 $image2.css('background-image', ''); 1636 tween.set($image2, { 1637 display: 'none' 1638 }); 1639 isBusy = 0; 1640 } 1641 }); 1642 break; 1643 } 1644 1645 // activate bullet 1646 $bulletsItems.removeClass('active'); 1647 $bulletsItems.eq(index).addClass('active'); 1648 1649 // show slide number 1650 tween.set($numbers2, { 1651 opacity: 0, 1652 y: 0, 1653 display: 'block' 1654 }); 1655 $numbers2.html(slides[index].number); 1656 tween.to($numbers, 0.5, { 1657 opacity: 0, 1658 y: -50, 1659 force3D: true 1660 }); 1661 tween.to($numbers2, 0.5, { 1662 opacity: 1, 1663 y: 0, 1664 force3D: true, 1665 delay: 0.1, 1666 onComplete: function onComplete() { 1667 $numbers.html(slides[index].number); 1668 tween.set($numbers, { 1669 opacity: 1, 1670 y: 0 1671 }); 1672 tween.set($numbers2, { 1673 display: 'none' 1674 }); 1675 } 1676 }); 1677 1678 // set new content 1679 tween.set($content2, { 1680 opacity: 0, 1681 y: effect == 'down' ? 100 : -100, 1682 display: 'flex' 1683 }); 1684 $content2.html(slides[index].$content); 1685 tween.to($content, 0.5, { 1686 opacity: 0, 1687 y: effect == 'down' ? -100 : 100, 1688 force3D: true 1689 }); 1690 tween.to($content2, 0.5, { 1691 opacity: 1, 1692 y: 0, 1693 force3D: true, 1694 delay: 0.1, 1695 onComplete: function onComplete() { 1696 $content.html(slides[index].$content); 1697 tween.set($content, { 1698 opacity: 1, 1699 clearProps: 'transform' 1700 }); 1701 tween.set($content2, { 1702 display: 'none' 1703 }); 1704 } 1705 }); 1706 1707 // set new button 1708 $content_button.html(slides[index].$viewBtn); 1709 1710 curIndex = index; 1711 } 1712 } 1713 slideShow(curIndex, 'fade', 1); 1714 $bullets.on('click', '> li', function () { 1715 var index = $(this).index(); 1716 if (index > curIndex) { 1717 slideShow(index, 'down'); 1718 } else if (index < curIndex) { 1719 slideShow(index, 'up'); 1720 } 1721 }); 1722 1723 // show next / previous slider 1724 function slideShowNext() { 1725 if (curIndex != slides.length - 1) { 1726 slideShow(curIndex + 1, 'down'); 1727 } 1728 } 1729 function slideShowPrev() { 1730 if (curIndex != 0) { 1731 slideShow(curIndex - 1, 'up'); 1732 } 1733 } 1734 1735 var wheelEvent = void 0;
1736 if ('onwheel' in document.createElement('div')) { 1737 wheelEvent = 'wheel'; 1738 } else if ('onmousewheel' in document.createElement('div')) { 1739 wheelEvent = 'mousewheel'; 1740 } 1741 if (wheelEvent) { 1742 // mouse wheel scroll 1743 $wnd.on(wheelEvent, function (e) { 1744 // check if delta >= 2 and mouse under slider 1745 if (Math.abs(e.originalEvent.deltaY) < 2 || !$(e.target).parents('.nk-fullpage-portfolio').length) { 1746 return; 1747 } 1748 1749 if (e.originalEvent.deltaY > 0) { 1750 slideShowNext(); 1751 } else if (e.originalEvent.deltaY < 0) { 1752 slideShowPrev(); 1753 } 1754 }); 1755 } 1756 1757 // touch swipe 1758 var touchStart = 0; 1759 var touchDelta = 0; 1760 $wnd.on('touchstart', function (e) { 1761 touchStart = e.originalEvent.touches[0].screenY; 1762 touchDelta = 0; 1763 }); 1764 $wnd.on('touchmove touchend', function (e) { 1765 var y = e.originalEvent.touches && e.originalEvent.touches.length ? e.originalEvent.touches[0].screenY : false; 1766 touchDelta = y === false ? touchDelta : touchStart - y; 1767 1768 // check if delta >= 2 and mouse under slider 1769 if (Math.abs(touchDelta) < 2 || !$(e.target).parents('.nk-fullpage-portfolio').length) { 1770 return; 1771 } 1772 1773 if (e.type === 'touchend') { 1774 if (touchDelta > 0) { 1775 slideShowNext(); 1776 } else if (touchDelta < 0) { 1777 slideShowPrev(); 1778 } 1779 } 1780 }); 1781} 1782 1783/*------------------------------------------------------------------ 1784 1785 Init AJAX Forms 1786 1787-------------------------------------------------------------------*/ 1788function _initForms() { 1789 if (typeof $.fn.ajaxSubmit === 'undefined' || typeof $.validator === 'undefined') { 1790 return; 1791 } 1792 var self = this; 1793 1794 // Validate Forms 1795 $('form:not(.nk-form-ajax):not([novalidate])').each(function () { 1796 $(this).validate({ 1797 errorClass: 'nk-error', 1798 errorElement: 'div', 1799 errorPlacement: function errorPlacement(error, element) { 1800 var $parent = element.parent('.input-group'); 1801 if ($parent.length) { 1802 $parent.after(error); 1803 } else { 1804 element.after(error); 1805 } 1806 self.debounceResize(); 1807 } 1808 }); 1809 }); 1810 // ajax form 1811 $('form.nk-form-ajax:not([novalidate])').each(function () { 1812 $(this).validate({ 1813 errorClass: 'nk-error', 1814 errorElement: 'div', 1815 errorPlacement: function errorPlacement(error, element) { 1816 var $parent = element.parent('.input-group'); 1817 if ($parent.length) { 1818 $parent.after(error); 1819 } else { 1820 element.after(error); 1821 } 1822 self.debounceResize(); 1823 }, 1824 1825 // Submit the form via ajax (see: jQuery Form plugin) 1826 submitHandler: function submitHandler(form) { 1827 var $responseSuccess = $(form).find('.nk-form-response-success'); 1828 var $responseError = $(form).find('.nk-form-response-error'); 1829 $(form).ajaxSubmit({ 1830 type: 'POST', 1831 success: function success(response) { 1832 response = JSON.parse(response); 1833 if (response.type && response.type === 'success') { 1834 $responseError.hide(); 1835 $responseSuccess.html(response.response).show(); 1836 form.reset(); 1837 } else { 1838 $responseSuccess.hide(); 1839 $responseError.html(response.response).show(); 1840 } 1841 self.debounceResize(); 1842 }, 1843 error: function error(response) { 1844 $responseSuccess.hide(); 1845 $responseError.html(response.responseText).show(); 1846 self.debounceResize(); 1847 } 1848 }); 1849 } 1850 }); 1851 }); 1852} 1853 1854/*------------------------------------------------------------------ 1855 1856 Team Block 1857 1858 -------------------------------------------------------------------*/ 1859function _initTeamBlock() { 1860 1861 function activateMemberBlock($item) { 1862 var id = $item.attr('data-item-id'); 1863 1864 // add active class to item 1865 $item.siblings().removeClass('active'); 1866 $item.addClass('active'); 1867 1868 // add class to item background 1869 $item.siblings('.nk-team-block-backgrounds:eq(0)').find('[data-bg-id="' + id + '"]').addClass('active').siblings().removeClass('active'); 1870 } 1871 1872 // prepare team blocks 1873 $('.nk-team-block').each(function () { 1874 var $this = $(this); 1875 1876 // prepare backgrounds 1877 var $backgrounds = $('<div class="nk-team-block-backgrounds">'); 1878 $this.find('.nk-team-member img.nk-team-member-photo').each(function () { 1879 var $img = $(this); 1880 var $parent = $img.parent(); 1881 var id = $parent.index(); 1882 1883 $parent.attr('data-item-id', id); 1884 $('<div>').css({ 1885 'background-image': 'url("' + $img.attr('src') + '")' 1886 }).attr('data-bg-id', id).appendTo($backgrounds); 1887 }); 1888 $this.append($backgrounds); 1889 1890 // activate item 1891 var $active_member = $this.children('.nk-team-member.active:eq(0)'); 1892 if (!$active_member.length) { 1893 $active_member = $this.children('.nk-team-member:eq(0)'); 1894 } 1895 activateMemberBlock($active_member); 1896 }); 1897 1898 // hover activation 1899 $body.on('click', '.nk-team-block .nk-team-member', function () { 1900 activateMemberBlock($(this)); 1901 }); 1902} 1903 1904/*------------------------------------------------------------------ 1905 1906 Init Instagram 1907 1908-------------------------------------------------------------------*/ 1909function _initInstagram() { 1910 var self = this; 1911 var $instagram = $('.nk-instagram'); 1912 if (!$instagram.length || !self.options.templates.instagram) { 1913 return; 1914 } 1915 1916 /** 1917 * Templating a instagram item using '{{ }}' braces 1918 * @param {Object} data Instagram item details are passed 1919 * @return {String} Templated string 1920 */ 1921 function templating(data, temp) { 1922 var temp_variables = ['link', 'image', 'caption']; 1923 1924 for (var i = 0, len = temp_variables.length; i < len; i++) { 1925 temp = temp.replace(new RegExp('{{' + temp_variables[i] + '}}', 'gi'), data[temp_variables[i]]); 1926 } 1927 1928 return temp; 1929 } 1930 1931 $instagram.each(function () { 1932 var $this = $(this); 1933 var options = { 1934 userID: $this.attr('data-instagram-user-id') || null, 1935 count: $this.attr('data-instagram-count') || 8, 1936 template: $this.attr('data-instagram-template') || self.options.templates.instagram, 1937 quality: $this.attr('data-instagram-quality') || 'sm', // sm, md, lg 1938 loadingText: self.options.templates.instagramLoadingText, 1939 failText: self.options.templates.instagramFailText, 1940 apiPath: self.options.templates.instagramApiPath 1941 }; 1942 1943 // stop if running in file protocol 1944 if (window.location.protocol === 'file:') { 1945 $this.html('<div class="col-12">' + options.failText + '</div>'); 1946 console.error('You should run you website on webserver with PHP to get working Instagram'); 1947 return; 1948 } 1949 1950 $this.html('<div class="col-12">' + options.loadingText + '</div>'); 1951 1952 // Fetch instagram images 1953 $.getJSON(options.apiPath, { 1954 userID: options.userID, 1955 count: options.count 1956 }, function (response) { 1957 $this.html(''); 1958 1959 for (var i = 0; i < options.count; i++) { 1960 var instaItem = false;
1961 if (response[i]) { 1962 instaItem = response[i]; 1963 } else if (response.statuses && response.statuses[i]) { 1964 instaItem = response.statuses[i]; 1965 } else { 1966 break; 1967 } 1968 1969 var resolution = 'thumbnail'; 1970 if (options.quality === 'md') { 1971 resolution = 'low_resolution'; 1972 } 1973 if (options.quality === 'lg') { 1974 resolution = 'standard_resolution'; 1975 } 1976 1977 var temp_data = { 1978 link: instaItem.link, 1979 image: instaItem.images[resolution].url, 1980 caption: instaItem.caption 1981 }; 1982 1983 $this.append(templating(temp_data, options.template)); 1984 } 1985 1986 // resize window 1987 self.debounceResize(); 1988 }).fail(function (a) { 1989 $this.html('<div class="col-12">' + options.failText + '</div>'); 1990 $.error(a.responseText); 1991 }); 1992 }); 1993} 1994 1995/*------------------------------------------------------------------ 1996 1997 Init Twitter 1998 1999-------------------------------------------------------------------*/ 2000function _initTwitter() { 2001 var self = this; 2002 var $twtFeeds = $('.nk-twitter-list'); 2003 if (!$twtFeeds.length || !self.options.templates.twitter) { 2004 return; 2005 } 2006 2007 /** 2008 * Templating a tweet using '{{ }}' braces 2009 * @param {Object} data Tweet details are passed 2010 * @return {String} Templated string 2011 */ 2012 function templating(data, temp) { 2013 var temp_variables = ['date', 'tweet', 'avatar', 'url', 'retweeted', 'screen_name', 'user_name']; 2014 2015 for (var i = 0, len = temp_variables.length; i < len; i++) { 2016 temp = temp.replace(new RegExp('{{' + temp_variables[i] + '}}', 'gi'), data[temp_variables[i]]); 2017 } 2018 2019 return temp; 2020 } 2021 2022 $twtFeeds.each(function () { 2023 var $this = $(this); 2024 var options = { 2025 username: $this.attr('data-twitter-user-name') || null, 2026 list: null, 2027 hashtag: $this.attr('data-twitter-hashtag') || null, 2028 count: $this.attr('data-twitter-count') || 2, 2029 hideReplies: $this.attr('data-twitter-hide-replies') === 'true' ? true : false, 2030 template: $this.attr('data-twitter-template') || self.options.templates.twitter, 2031 loadingText: self.options.templates.twitterLoadingText, 2032 failText: self.options.templates.twitterFailText, 2033 apiPath: self.options.templates.twitterApiPath 2034 }; 2035 2036 // stop if running in file protocol 2037 if (window.location.protocol === 'file:') { 2038 $this.html(options.failText); 2039 console.error('You should run you website on webserver with PHP to get working Twitter'); 2040 return; 2041 } 2042 2043 // Set loading 2044 $this.html('<span>' + options.loadingText + '</span>'); 2045 2046 // Fetch tweets 2047 $.getJSON(options.apiPath, { 2048 username: options.username, 2049 list: options.list, 2050 hashtag: options.hashtag, 2051 count: options.count, 2052 exclude_replies: options.hideReplies 2053 }, function (twt) { 2054 $this.html(''); 2055 2056 for (var i = 0; i < options.count; i++) { 2057 var tweet = false;
2058 if (twt[i]) { 2059 tweet = twt[i]; 2060 } else if (twt.statuses && twt.statuses[i]) { 2061 tweet = twt.statuses[i]; 2062 } else { 2063 break; 2064 } 2065 2066 var temp_data = { 2067 user_name: tweet.user.name, 2068 date: tweet.date_formatted, 2069 tweet: tweet.text_entitled, 2070 avatar: '<img src="' + tweet.user.profile_image_url + '" />', 2071 url: 'https://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id_str, 2072 retweeted: tweet.retweeted, 2073 screen_name: '@' + tweet.user.screen_name 2074 }; 2075 2076 $this.append(templating(temp_data, options.template)); 2077 } 2078 2079 // resize window 2080 self.debounceResize(); 2081 }).fail(function (a) { 2082 $this.html(options.failText); 2083 $.error(a.responseText); 2084 }); 2085 }); 2086} 2087 2088/*------------------------------------------------------------------ 2089 2090 Init Documentation 2091 2092-------------------------------------------------------------------*/ 2093function _initDoc() { 2094 var self = this; 2095 var $menu = $('.nk-doc-links'); 2096 var $firstBlocks = $('.nk-doc > .nk-doc-item'); 2097 var $childBlocks = $('.nk-doc > .nk-doc-item > .nk-doc-item'); 2098 var $blocks = $firstBlocks.add($childBlocks); 2099 var blocks = []; 2100 2101 if (!$blocks.length) { 2102 return; 2103 } 2104 2105 // get block by attr 2106 function getBlocksBy(by, val, getFrom) { 2107 var result = []; 2108 getFrom = getFrom || blocks; 2109 for (var k = 0; k < getFrom.length; k++) { 2110 if (getFrom[k] && typeof getFrom[k][by] !== 'undefined' && getFrom[k][by] === val) { 2111 result.push(getFrom[k]); 2112 } 2113 } 2114 return result; 2115 } 2116 2117 // prepare links 2118 var uniqID = 0; 2119 var hashID = 0; 2120 function prepareLinks($block) { 2121 if (!hashID) { 2122 uniqID++; 2123 } 2124 var title = $block.find('> h2, > h3').eq(0).text(); 2125 var hash = 'doc-' + title.replace(/\s+/g, '-').toLowerCase() + (hashID ? '-' + hashID : ''); 2126 2127 if (getBlocksBy('hash', hash).length) { 2128 hashID++; 2129 return prepareLinks($block); 2130 } 2131 2132 $block.attr('data-id', uniqID); 2133 2134 // add parent value if this is child 2135 var parent = false; 2136 var $parent = $block.parents('.nk-doc-item:eq(0)'); 2137 if ($parent.length) { 2138 parent = parseInt($parent.attr('data-id'), 10); 2139 } 2140 2141 hashID = 0; 2142 2143 return { 2144 id: uniqID, 2145 title: title, 2146 hash: hash, 2147 $block: $block, 2148 parent: parent 2149 }; 2150 } 2151 $firstBlocks.each(function () { 2152 var block = prepareLinks($(this)); 2153 blocks.push(block); 2154 }); 2155 $childBlocks.each(function () { 2156 var block = prepareLinks($(this)); 2157 blocks.push(block); 2158 }); 2159 2160 // activate block 2161 var firstRun = 1; 2162 function activeBlock(id) { 2163 // add hash 2164 var selectedBlock = getBlocksBy('id', id)[0]; 2165 var issetChilds = getBlocksBy('parent', id)[0]; 2166 if (issetChilds) { 2167 activeBlock(issetChilds.id); 2168 return; 2169 } 2170 if (selectedBlock) { 2171 // hide all blocks 2172 $blocks.hide(); 2173 2174 // activate menu item 2175 $menu.find('[data-id]').removeClass('active'); 2176 $menu.find('[data-id=' + id + ']').addClass('active'); 2177 2178 // activate parent menu item 2179 var parentBlock = getBlocksBy('id', selectedBlock.parent)[0]; 2180 if (parentBlock) { 2181 $menu.find('[data-id=' + selectedBlock.parent + ']').addClass('active'); 2182 2183 // show parent 2184 parentBlock.$block.show(); 2185 } 2186 2187 // show submenu 2188 var $sub_menus = $menu.find('[data-id] + ul'); 2189 $sub_menus.each(function () { 2190 var $this = $(this); 2191 var isActive = !!$this.find('[data-id].active').length; 2192 var isOpened = $this.hasClass('opened'); 2193 2194 // open 2195 if (isActive && !isOpened) { 2196 $this.css('height', ''); 2197 $this.show(); 2198 var h = $this.innerHeight(); 2199 $this.hide(); 2200 tween.set($this, { 2201 height: 0 2202 }); 2203 tween.to($this, 0.4, { 2204 height: h, 2205 display: 'block', 2206 onComplete: function onComplete() { 2207 self.debounceResize(); 2208 } 2209 }); 2210 $this.addClass('opened'); 2211 2212 // close 2213 } 2214 2215 if (!isActive && isOpened) { 2216 tween.to($this, 0.4, { 2217 height: 0, 2218 display: 'none', 2219 onComplete: function onComplete() { 2220 self.debounceResize(); 2221 } 2222 }); 2223 $this.removeClass('opened'); 2224 } 2225 }); 2226 2227 // show current 2228 selectedBlock.$block.show(); 2229 2230 location.hash = selectedBlock.hash; 2231 2232 // resize and scroll to top 2233 if (!firstRun) { 2234 self.debounceResize(); 2235 self.scrollTo($('.nk-header-title').next()); 2236 } 2237 firstRun = 0; 2238 } 2239 } 2240 2241 // create side menu 2242 var menuTemplate = ''; 2243 for (var k = 0; k < blocks.length; k++) { 2244 if (blocks[k].parent === false) { 2245 var childs = getBlocksBy('parent', blocks[k].id); 2246 2247 menuTemplate += '<li><div data-id="' + blocks[k].id + '">' + blocks[k].title + (childs.length ? ' <sup>[' + childs.length + ']</sup>' : '') + '</div>'; 2248 2249 // add childs 2250 if (childs.length) { 2251 menuTemplate += '<ul>'; 2252 for (var i = 0; i < childs.length; i++) { 2253 menuTemplate += '<li><div data-id="' + childs[i].id + '">' + childs[i].title + '</div>'; 2254 } 2255 menuTemplate += '</ul>'; 2256 } 2257 2258 menuTemplate += '</li>'; 2259 } 2260 } 2261 $menu.html('<ul>' + menuTemplate + '</ul>'); 2262 $menu.on('click', '[data-id]:not(.active)', function () { 2263 activeBlock(parseInt($(this).attr('data-id'), 10)); 2264 }); 2265 2266 // activate default block 2267 if (location.hash) { 2268 var curBlock = getBlocksBy('hash', location.hash.replace('#', '')); 2269 if (curBlock[0]) { 2270 activeBlock(curBlock[0].id); 2271 } 2272 } else { 2273 activeBlock(blocks[0].id); 2274 } 2275} 2276 2277/*------------------------------------------------------------------ 2278 2279 Init Plugin Sticky Sidebar 2280 2281-------------------------------------------------------------------*/ 2282function _initPluginStickySidebar() { 2283 if (typeof $.fn.stick_in_parent === 'undefined') { 2284 return; 2285 } 2286 2287 $('.nk-sidebar-sticky').each(function () { 2288 var $this = $(this); 2289 var $parent = $this.parent(); 2290 2291 $parent.addClass('nk-sidebar-sticky-parent'); 2292 2293 $this.wrapInner('<div>').children().stick_in_parent({ 2294 parent: $parent, 2295 recalc_every: 50, 2296 offset_top: parseInt($this.attr('data-offset-top'), 10) || 0, 2297 2298 // fixed ADS reloading issue https://github.com/leafo/sticky-kit/issues/45 2299 spacer: false 2300 }) 2301 2302 // we need to set min height on parent block (in theme it is equal height column) to prevent sidebar content jumping 2303 .on('sticky_kit:unbottom sticky_kit:stick sticky_kit:bottom', function () { 2304 $parent.css('min-height', $(this).height()); 2305 }).on('sticky_kit:unstick', function () { 2306 $parent.css('min-height', ''); 2307 }); 2308 }); 2309} 2310 2311/* Nano Scroller */ 2312function _initPluginNano($context) { 2313 if (typeof $.fn.nanoScroller !== 'undefined') { 2314 ($context || $doc).find('.nano').nanoScroller(); 2315 } 2316} 2317 2318/* Jarallax */ 2319function _initPluginJarallax() { 2320 if (typeof $.fn.jarallax === 'undefined') { 2321 return; 2322 } 2323 var self = this; 2324 2325 // header parallax 2326 var $parallaxHeader = $('.nk-header-title-parallax, .nk-header-title-parallax-opacity').eq(0); 2327 if ($parallaxHeader.length) { 2328 (function () { 2329 var $headerImage = $parallaxHeader.find('> .bg-image >
2329 div:eq(0)'); 2330 var $headerContent = $parallaxHeader.find('> .bg-image ~ *'); 2331 var headerParallaxScroll = $parallaxHeader.hasClass('nk-header-title-parallax'); 2332 var headerParallaxOpacity = $parallaxHeader.hasClass('nk-header-title-parallax-opacity'); 2333 $parallaxHeader.jarallax({ 2334 type: 'custom', 2335 imgSrc: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 2336 imgWidth: 1, 2337 imgHeight: 1, 2338 onScroll: function onScroll(calc) { 2339 var scrollImg = Math.min(100, 100 * (1 - calc.visiblePercent)); 2340 var scrollInfo = Math.min(50, 50 * (1 - calc.visiblePercent)); 2341 2342 // fix if top banner not on top 2343 if (calc.beforeTop > 0) { 2344 scrollImg = 0; 2345 scrollInfo = 0; 2346 } 2347 2348 if (headerParallaxScroll) { 2349 $headerImage.css({ 2350 transform: 'translateY(' + scrollImg + 'px) translateZ(0)' 2351 }); 2352 $headerContent.css({ 2353 transform: 'translateY(' + scrollInfo + 'px) translateZ(0)' 2354 }); 2355 } 2356 if (headerParallaxOpacity) { 2357 $headerContent.css({ 2358 opacity: calc.visiblePercent < 0 || calc.beforeTop > 0 ? 1 : calc.visiblePercent 2359 }); 2360 } 2361 } 2362 }); 2363 })(); 2364 } 2365 2366 // footer parallax 2367 var $parallaxFooter = $('.nk-footer-parallax, .nk-footer-parallax-opacity').eq(0); 2368 if ($parallaxFooter.length) { 2369 (function () { 2370 var $footerImage = $parallaxFooter.find('> .bg-image > div'); 2371 var $footerContent = $parallaxFooter.find('> .bg-image ~ *'); 2372 var footerParallaxScroll = $parallaxFooter.hasClass('nk-footer-parallax'); 2373 var footerParallaxOpacity = $parallaxFooter.hasClass('nk-footer-parallax-opacity'); 2374 $parallaxFooter.jarallax({ 2375 type: 'custom', 2376 imgSrc: 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7', 2377 imgWidth: 1, 2378 imgHeight: 1, 2379 onScroll: function onScroll(calc) { 2380 var scrollImg = -Math.min(100, 100 * (1 - calc.visiblePercent)); 2381 var scrollInfo = -Math.min(50, 50 * (1 - calc.visiblePercent)); 2382 if (footerParallaxScroll) { 2383 $footerImage.css({ 2384 transform: 'translateY(' + scrollImg + 'px) translateZ(0)' 2385 }); 2386 $footerContent.css({ 2387 transform: 'translateY(' + scrollInfo + 'px) translateZ(0)' 2388 }); 2389 } 2390 if (footerParallaxOpacity) { 2391 $footerContent.css({ 2392 opacity: calc.visiblePercent < 0 ? 1 : calc.visiblePercent 2393 }); 2394 } 2395 } 2396 }); 2397 })(); 2398 } 2399 2400 // video backgrounds 2401 $('.bg-video[data-video]').each(function () { 2402 $(this).attr('data-jarallax-video', $(this).attr('data-video')); 2403 $(this).removeAttr('data-video'); 2404 }); 2405 2406 // primary parallax 2407 $('.bg-image-parallax, .bg-video-parallax').jarallax({ 2408 speed: self.options.parallaxSpeed 2409 }); 2410 2411 // video without parallax 2412 $('.bg-video:not(.bg-video-parallax)').jarallax({ 2413 speed: 1 2414 }); 2415} 2416 2417/* Flickity */ 2418function _initPluginFlickity() { 2419 if (typeof window.Flickity === 'undefined') { 2420 return; 2421 } 2422 2423 function isMobileDevice() { 2424 return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1); 2425 }; 2426 2427 var self = this; 2428 2429 function addDefaultArrows($carousel) { 2430 $('<div class="nk-flickity-arrow nk-flickity-arrow-prev"><span class="pe-7s-angle-left"></span></div>').on('click', function () { 2431 $carousel.flickity('previous'); 2432 }).appendTo($carousel); 2433 2434 $('<div class="nk-flickity-arrow nk-flickity-arrow-next"><span class="pe-7s-angle-right"></span></div>').on('click', function () { 2435 $carousel.flickity('next'); 2436 }).appendTo($carousel); 2437 } 2438 2439 function addDefaultArrowsGallery($carousel) {
2440 // $('<div class="nk-flickity-arrow-c nk-flickity-arrow-prev"><span class="pe-7s-angle-left"></span></div>').on('click', function () { 2441 // $carousel.flickity('previous'); 2442 // }).appendTo($carousel); 2443 2444 // $('<div class="nk-flickity-arrow-c nk-flickity-arrow-next"><span class="pe-7s-angle-right"></span></div>').on('click', function () { 2445 // $carousel.flickity('next'); 2446 // }).appendTo($carousel); 2447 } 2448 2449 function updateCustomArrows($carousel) { 2450 var data = $carousel.children('.nk-carousel-inner').data('flickity'); 2451 var currIndex = data.selectedIndex; 2452 var nextIndex = void 0; 2453 var prevIndex = void 0; 2454 2455 // get next and prev cells 2456 if (currIndex === 0) { 2457 nextIndex = 1; 2458 prevIndex = data.cells.length - 1; 2459 } else if (currIndex === data.cells.length - 1) { 2460 nextIndex = 0; 2461 prevIndex = data.cells.length - 2; 2462 } else { 2463 nextIndex = currIndex + 1; 2464 prevIndex = currIndex - 1; 2465 } 2466 var $nextCell = $(data.cells[nextIndex].element); 2467 var $prevCell = $(data.cells[prevIndex].element); 2468 var $currCell = $(data.cells[currIndex].element); 2469 2470 // get name and sources 2471 var nextName = $nextCell.find('.nk-carousel-item-name').text(); 2472 var prevName = $prevCell.find('.nk-carousel-item-name').text(); 2473 var currName = $currCell.find('.nk-carousel-item-name').html(); 2474 var currLinks = $currCell.find('.nk-carousel-item-links').html(); 2475 2476 // add info to buttons 2477 $carousel.find('.nk-carousel-next > .nk-carousel-arrow-name').html(nextName); 2478 $carousel.find('.nk-carousel-prev > .nk-carousel-arrow-name').html(prevName); 2479 $carousel.find('.nk-carousel-current > .nk-carousel-name').html(currName); 2480 $carousel.find('.nk-carousel-current > .nk-carousel-links').html(currLinks); 2481 } 2482 2483 // prevent click event fire when drag carousel 2484 function noClickEventOnDrag($carousel) { 2485 $carousel.on('dragStart', function () { 2486 $(this).find('.flickity-viewport').addClass('is-dragging'); 2487 }); 2488 $carousel.on('dragEnd', function () { 2489 $(this).find('.flickity-viewport').removeClass('is-dragging'); 2490 }); 2491 } 2492 2493 // carousel 1 2494 var $carousel1 = $('.nk-carousel'); 2495 if ($carousel1.length) { 2496 $carousel1.children('.nk-carousel-inner').each(function () { 2497 $(this).flickity({ 2498 pageDots: $(this).parent().attr('data-dots') === 'true' || false, 2499 // autoPlay: parseFloat($(this).parent().attr('data-autoplay')) || false, 2500 autoPlay: !isMobileDevice, 2501 prevNextButtons: false, 2502 wrapAround: true, 2503 cellAlign: $(this).parent().attr('data-cell-align') || 'center' 2504 }); 2505 if ($(this).parent().attr('data-arrows') === 'true') { 2506 addDefaultArrows($(this)); 2507 } 2508 updateCustomArrows($(this).parent()); 2509 }).on('cellSelect', function () { 2510 updateCustomArrows($(this).parent()); 2511 }); 2512 $carousel1.on('click', '.nk-carousel-next', function () { 2513 $(this).parent().children('.nk-carousel-inner').flickity('next'); 2514 }); 2515 $carousel1.on('click', '.nk-carousel-prev', function () { 2516 $(this).parent().children('.nk-carousel-inner').flickity('previous'); 2517 }); 2518 noClickEventOnDrag($carousel1.children('.nk-carousel-inner')); 2519 } 2520 2521 // carousel 2 2522 $('.nk-carousel-2 > .nk-carousel-inner').each(function () { 2523 $(this).flickity({ 2524 pageDots: $(this).parent().attr('data-dots') === 'true' || false, 2525 // autoPlay: parseFloat($(this).parent().attr('data-autoplay')) || false, 2526 autoPlay: !isMobileDevice, 2527 prevNextButtons: false, 2528 wrapAround: true, 2529 imagesLoaded: true, 2530 cellAlign: $(this).parent().attr('data-cell-align') || 'center' 2531 }); 2532 if ($(this).parent().attr('data-arrows') === 'true') { 2533 addDefaultArrows($(this)); 2534 } 2535 noClickEventOnDrag($(this)); 2536 }); 2537 2538 // carousel 3 2539 var $carousel3 = $('.nk-carousel-3'); 2540 // set height for items 2541 function setHeightCarousel3() { 2542 $carousel3.each(function () { 2543 var $allImages = $(this).find('img'); 2544 var size = $(this).attr('data-size') || 0.8; 2545 var resultH = wndH * size; 2546 var maxItemW = Math.min($(this).parent().width(), wndW) * size; 2547 $allImages.each(function () {
2548 if (this.naturalWidth && this.naturalHeight && resultH * this.naturalWidth / this.naturalHeight > maxItemW) { 2549 resultH = maxItemW * this.naturalHeight / this.naturalWidth; 2550 } 2551 }); 2552 $allImages.css('height', resultH); 2553 $(this).children('.nk-carousel-inner').flickity('reposition'); 2554 }); 2555 } 2556 if ($carousel3.length) { 2557 $carousel3.children('.nk-carousel-inner').each(function () { 2558 $(this).flickity({ 2559 pageDots: $(this).parent().attr('data-dots') === 'true' || false, 2560 // autoPlay: parseFloat($(this).parent().attr('data-autoplay')) || false, 2561 autoPlay: !isMobileDevice, 2562 pauseAutoPlayOnHover: $(this).parent().attr('data-pause-hover') || true, 2563 // pauseAutoPlayOnHover: false, 2564 groupCells: $(this).parent().attr('data-grouped') || false, 2565 prevNextButtons: false, 2566 wrapAround: true, 2567 imagesLoaded: true, 2568 cellAlign: $(this).parent().attr('data-cell-align') || 'center' 2569 }); 2570 // updateCustomArrows($(this).parent()); 2571 if ($(this).parent().attr('data-arrows') === 'true' && !$(this).parent().hasClass('gallery')) { 2572 addDefaultArrows($(this)); 2573 } else { 2574 addDefaultArrows($(this)); 2575 } 2576 }).on('cellSelect', function () { 2577 updateCustomArrows($(this).parent()); 2578 }); 2579 $carousel3.on('click', '.nk-carousel-next', function () { 2580 $(this).parents('.nk-carousel-3:eq(0)').children('.nk-carousel-inner').flickity('next'); 2581 }); 2582 $carousel3.on('click', '.nk-carousel-prev', function () { 2583 $(this).parents('.nk-carousel-3:eq(0)').children('.nk-carousel-inner').flickity('previous'); 2584 }); 2585 setHeightCarousel3(); 2586 self.debounceResize(setHeightCarousel3); 2587 noClickEventOnDrag($carousel3.children('.nk-carousel-inner')); 2588 } 2589 2590 // update products carousel 2591 var $storeCarousel = $('.nk-carousel-1, .nk-carousel-2, .nk-carousel-3').filter('.nk-store'); 2592 function updateStoreProducts() { 2593 $storeCarousel.each(function () { 2594 var currentTallest = 0; 2595 var currentRowStart = 0; 2596 var rowDivs = []; 2597 var topPosition = 0; 2598 var currentDiv = 0; 2599 var $el = void 0; 2600 $(this).find('.nk-product').each(function () { 2601 $el = $(this); 2602 $el.css('height', ''); 2603 topPosition = $el.position().top; 2604 2605 if (currentRowStart !== topPosition) { 2606 for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 2607 rowDivs[currentDiv].css('height', currentTallest); 2608 } 2609 rowDivs.length = 0; // empty the array 2610 currentRowStart = topPosition; 2611 currentTallest = $el.innerHeight(); 2612 rowDivs.push($el); 2613 } else { 2614 rowDivs.push($el); 2615 currentTallest = currentTallest < $el.innerHeight() ? $el.innerHe
2615ight() : currentTallest; 2616 } 2617 for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) { 2618 rowDivs[currentDiv].css('height', currentTallest); 2619 } 2620 }); 2621 }); 2622 } 2623 if ($storeCarousel.length) { 2624 self.debounceResize(updateStoreProducts); 2625 updateStoreProducts(); 2626 } 2627} 2628 2629/* Isotope */ 2630function _initPluginIsotope() { 2631 if (typeof window.Isotope === 'undefined') { 2632 return; 2633 } 2634 var self = this; 2635 2636 $('.nk-isotope').each(function () { 2637 var $this = $(this); 2638 var $grid = $this.isotope({ 2639 itemSelector: '.nk-isotope-item' 2640 }); 2641 $grid.imagesLoaded().progress(function () { 2642 $grid.isotope('layout'); 2643 }); 2644 $grid.on('arrangeComplete', function () { 2645 self.debounceResize(); 2646 }); 2647 2648 // filter 2649 var $filter = []; 2650 if ($this.parent().hasClass('nk-portfolio-list')) { 2651 $filter = $this.parent().prev('.nk-isotope-filter'); 2652 } else { 2653 $filter = $this.prev('.nk-isotope-filter'); 2654 } 2655 if ($filter.length) { 2656 $filter.on('click', '[data-filter]', function (e) { 2657 e.preventDefault(); 2658 var filter = $(this).attr('data-filter'); 2659 2660 $(this).addClass('active').siblings().removeClass('active'); 2661 2662 $grid.isotope({ 2663 filter: filter === '*' ? '' : '[data-filter*=' + filter + ']' 2664 }); 2665 }); 2666 } 2667 }); 2668 2669 // filter toggler 2670 $body.on('click', '[href="#nk-toggle-filter"]:not(.busy)', function (e) { 2671 var $pagination = $(this).parent('.nk-pagination'); 2672 var $filter = $pagination.next('.nk-isotope-filter'); 2673 var isActive = $filter.hasClass('nk-isotope-filter-active'); 2674 2675 if (!$pagination.length || !$filter.length) { 2676 return; 2677 } 2678 2679 e.preventDefault(); 2680 e.stopPropagation(); 2681 2682 $pagination.addClass('busy'); 2683 2684 if (isActive) { 2685 tween.staggerTo($filter.children(), 0.2, { 2686 y: -10, 2687 opacity: 0 2688 }, 0.04, function () { 2689 tween.to($filter, 0.4, { 2690 height: 0, 2691 marginBottom: 0, 2692 marginTop: 0, 2693 force3D: true, 2694 display: 'none', 2695 onComplete: function onComplete() { 2696 $pagination.removeClass('nk-isotope-filter-active'); 2697 $filter.removeClass('nk-isotope-filter-active'); 2698 $pagination.removeClass('busy'); 2699 _debounceResize(); 2700 } 2701 }); 2702 }); 2703 } else { 2704 $filter.css('height', 'auto'); 2705 var filterHeight = $filter.height(); 2706 $filter.css('height', 0); 2707 tween.set($filter.children(), { 2708 y: -10, 2709 opacity: 0 2710 }); 2711 tween.to($filter, 0.4, { 2712 height: filterHeight, 2713 marginBottom: 30, 2714 marginTop: -23, 2715 force3D: true, 2716 display: 'block', 2717 onComplete: function onComplete() { 2718 tween.staggerTo($filter.children(), 0.2, { 2719 y: 0, 2720 opacity: 1 2721 }, 0.04, function () { 2722 $pagination.addClass('nk-isotope-filter-active'); 2723 $filter.addClass('nk-isotope-filter-active'); 2724 $pagination.removeClass('busy'); 2725 _debounceResize(); 2726 }); 2727 } 2728 }); 2729 } 2730 }); 2731} 2732 2733/* PhotoSwipe */ 2734function _initPluginPhotoswipe() { 2735 var $gallery = $('.nk-popup-gallery'); 2736 if (typeof PhotoSwipe === 'undefined' || !$gallery.length) { 2737 return; 2738 } 2739 2740 // prepare photoswipe markup 2741 var markup = '<div id="gallery" class="pswp" tabindex="-1" role="dialog" aria-hidden="true">\n <div class="pswp__bg"></div>\n <div class="pswp__scroll-wrap">\n <div class="pswp__container">\n <div class="pswp__item"></div>\n <div class="pswp__item"></div>\n <div class="pswp__item"></div>\n </div>\n <div class="pswp__ui pswp__ui--hidden">\n <div class="pswp__top-bar">\n <div class="pswp__counter"></div>\n <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>\n <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>\n <div class="pswp__preloader">\n <div class="pswp__preloader__icn">\n <div class="pswp__preloader__cut">\n <div class="pswp__preloader__donut"></div>\n </div>\n </div>\n </div>\n </div>\n <div class="pswp__loading-indicator"><div class="pswp__loading-indicator__line"></div></div>\n <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button>\n <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button>\n <div class="pswp__caption">\n <div class="pswp__caption__center">\n </div>\n </div>\n </div>\n </div>\n </div>'; 2742 $body.append(markup); 2743 2744 // init code 2745 var parseThumbnailElements = function parseThumbnailElements(el) { 2746 var thumbElements = $(el).find('a.nk-gallery-item'), 2747 items = [], 2748 childElements = void 0, 2749 descrElement = void 0, 2750 size = void 0, 2751 item = void 0; 2752 2753 thumbElements.each(function () { 2754 childElements = $(this).find('img'); 2755 descrElement = $(this).next('.nk-gallery-item-description'); 2756 size = (this.getAttribute('data-size') || '1920x1080').split('x'); 2757 2758 // create slide object 2759 item = { 2760 src: this.getAttribute('href'), 2761 w: parseInt(size[0], 10), 2762 h: parseInt(size[1], 10), 2763 author: this.getAttribute('data-author') 2764 }; 2765 2766 if (descrElement.length) { 2767 item.title = descrElement.html(); 2768 } 2769 2770 // save link to element for getThumbBoundsFn 2771 item.el = this; 2772 2773 if (childElements.length > 0) { 2774 // thumbnail url 2775 item.msrc = item.src; 2776 if (childElements.length > 1) { 2777 item.title = $(childElements).filter('.photoswipe-description').html(); 2778 } 2779 } 2780 2781 var mediumSrc = this.getAttribute('data-med') || item.src; 2782 if (mediumSrc) { 2783 size = (this.getAttribute('data-med-size') || this.getAttribute('data-size') || '1920x1080').split('x'); 2784 // "medium-sized" image 2785 item.m = { 2786 src: mediumSrc, 2787 w: parseInt(size[0], 10), 2788 h: parseInt(size[1], 10) 2789 }; 2790 } 2791 2792 // original image 2793 item.o = { 2794 src: item.src, 2795 w: item.w, 2796 h: item.h 2797 }; 2798 items.push(item); 2799 }); 2800 2801 return items; 2802 }; 2803 2804 var openPhotoSwipe = function openPhotoSwipe(index, galleryElement, disableAnimation, fromURL) { 2805 var pswpElement = $('.pswp')[0], 2806 gallery = void 0, 2807 options = void 0, 2808 items = void 0; 2809 2810 items = parseThumbnailElements(galleryElement); 2811 2812 // define options (if needed) 2813 options = { 2814 captionAndToolbarShowEmptyCaptions: false,
2815 mainClass: 'pswp--minimal--dark', 2816 barsSize: { top: 0, bottom: 0 }, 2817 captionEl: true, 2818 fullscreenEl: false, 2819 shareEl: false, 2820 bgOpacity: 0.85, 2821 tapToClose: true, 2822 tapToToggleControls: false, 2823 showHideOpacity: true, 2824 2825 // Function builds caption markup 2826 addCaptionHTMLFn: function addCaptionHTMLFn(item, captionEl) { 2827 // item - slide object 2828 // captionEl - caption DOM element 2829 // isFake - true when content is added to fake caption container 2830 // (used to get size of next or previous caption) 2831 2832 if (!item.title && !item.author) { 2833 captionEl.children[0].innerHTML = ''; 2834 return false; 2835 } 2836 var caption = ''; 2837 if (item.title) { 2838 caption += item.title; 2839 } 2840 if (item.author) { 2841 if (item.title) { 2842 caption += '<br>'; 2843 } 2844 caption += '<small>' + item.author + '</small>'; 2845 } 2846 captionEl.children[0].innerHTML = caption; 2847 return true; 2848 }, 2849 2850 galleryUID: galleryElement.getAttribute('data-pswp-uid') 2851 }; 2852 2853 if (fromURL) { 2854 if (options.galleryPIDs) { 2855 // parse real index when custom PIDs are used 2856 // http://photoswipe.com/documentation/faq.html#custom-pid-in-url 2857 for (var j = 0; j < items.length; j++) { 2858 if (items[j].pid === index) { 2859 options.index = j; 2860 break; 2861 } 2862 } 2863 } else { 2864 options.index = parseInt(index, 10) - 1; 2865 } 2866 } else { 2867 options.index = parseInt(index, 10); 2868 } 2869 2870 // exit if index not found 2871 if (isNaN(options.index)) { 2872 return; 2873 } 2874 2875 if (disableAnimation) { 2876 options.showAnimationDuration = 0; 2877 } 2878 2879 // Pass data to PhotoSwipe and initialize it 2880 gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 2881 2882 // see: http://photoswipe.com/documentation/responsive-images.html 2883 var realViewportWidth = void 0, 2884 useLargeImages = false, 2885 firstResize = true, 2886 imageSrcWillChange = void 0; 2887 2888 gallery.listen('beforeResize', function () { 2889 var dpiRatio = window.devicePixelRatio ? window.devicePixelRatio : 1; 2890 dpiRatio = Math.min(dpiRatio, 2.5); 2891 realViewportWidth = gallery.viewportSize.x * dpiRatio; 2892 2893 if (realViewportWidth >= 1200 || !gallery.likelyTouchDevice && realViewportWidth > 800 || screen.width > 1200) { 2894 if (!useLargeImages) { 2895 useLargeImages = true; 2896 imageSrcWillChange = true; 2897 } 2898 } else { 2899 if (useLargeImages) { 2900 useLargeImages = false; 2901 imageSrcWillChange = true; 2902 } 2903 } 2904 2905 if (imageSrcWillChange && !firstResize) { 2906 gallery.invalidateCurrItems(); 2907 } 2908 2909 if (firstResize) { 2910 firstResize = false; 2911 } 2912 2913 imageSrcWillChange = false; 2914 }); 2915 2916 gallery.listen('gettingData', function (idx, item) { 2917 if (useLargeImages) { 2918 item.src = item.o.src; 2919 item.w = item.o.w; 2920 item.h = item.o.h; 2921 } else { 2922 item.src = item.m.src; 2923 item.w = item.m.w; 2924 item.h = item.m.h; 2925 } 2926 }); 2927 2928 gallery.init(); 2929 }; 2930 2931 var photoswipeParseHash = function photoswipeParseHash() { 2932 var hash = window.location.hash.substring(1), 2933 params = {}; 2934 2935 if (hash.length < 5) { 2936 // pid=1 2937 return params; 2938 } 2939 2940 var vars = hash.split('&'); 2941 for (var _i = 0; _i < vars.length; _i++) { 2942 if (!vars[_i]) { 2943 continue; 2944 } 2945 var pair = vars[_i].split('='); 2946 if (pair.length < 2) { 2947 continue; 2948 } 2949 params[pair[0]] = pair[1]; 2950 } 2951 2952 if (params.gid) { 2953 params.gid = parseInt(params.gid, 10); 2954 } 2955 2956 return params; 2957 }; 2958 2959 // select all gallery elements 2960 var i = 0; 2961 $gallery.each(function () { 2962 var $thisGallery = $(this); 2963 $thisGallery.attr('data-pswp-uid', i + 1); 2964 2965 $thisGallery.on('click', 'a.nk-gallery-item', function (e) { 2966 e.preventDefault(); 2967 var index = 0; 2968 var clicked = this; 2969 $thisGallery.find('a.nk-gallery-item').each(function (idx) { 2970 if (this === clicked) { 2971 index = idx; 2972 return false;
2973 } 2974 return true; 2975 }); 2976 openPhotoSwipe(index, $thisGallery[0]); 2977 }); 2978 i++; 2979 }); 2980 2981 // Parse URL and open gallery if it contains #&pid=3&gid=1 2982 var hashData = photoswipeParseHash(); 2983 if (hashData.pid && hashData.gid) { 2984 openPhotoSwipe(hashData.pid, $gallery.get(hashData.gid - 1), true, true); 2985 } 2986} 2987 2988/* Bootstrap Tabs */ 2989function _initPluginTabs() { 2990 var self = this; 2991 $wnd.on('shown.bs.tab', function () { 2992 self.debounceResize(); 2993 }); 2994} 2995 2996/*------------------------------------------------------------------ 2997 2998 Snow Class 2999 3000-------------------------------------------------------------------*/ 3001 3002var SNOW = function () { 3003 function SNOW() { 3004 _classCallCheck(this, SNOW); 3005 3006 this.options = options; 3007 } 3008 3009 _createClass(SNOW, [{ 3010 key: 'init', 3011 value: function init() { 3012 var self = this; 3013 self.initNavbar(); 3014 self.initNavbarSide(); 3015 self.initNavbarFullscreen(); 3016 self.initNavbarDropEffect1(); 3017 self.initHeaderTitle(); 3018 self.initCounters(); 3019 self.initAnchors(); 3020 self.initVideoBlocks(); 3021 self.initFullPage(); 3022 self.initForms(); 3023 self.initTeamBlock(); 3024 self.initInstagram(); 3025 self.initTwitter(); 3026 self.initShortcuts(); 3027 self.initDoc(); 3028 3029 // init plugins 3030 self.initPluginStickySidebar(); 3031 self.initPluginNano(); 3032 self.initPluginJarallax(); 3033 self.initPluginFlickity(); 3034 self.initPluginIsotope(); 3035 self.initPluginPhotoswipe(); 3036 self.initPluginTabs(); 3037 3038 return self; 3039 } 3040 }, { 3041 key: 'setOptions', 3042 value: function setOptions(newOpts) { 3043 return _setOptions.call(this, newOpts); 3044 } 3045 }, { 3046 key: 'debounceResize', 3047 value: function debounceResize(func) { 3048 return _debounceResize.call(this, func); 3049 } 3050 }, { 3051 key: 'throttleScroll', 3052 value: function throttleScroll(callback) { 3053 return _throttleScroll.call(this, callback); 3054 } 3055 }, { 3056 key: 'bodyOverflow', 3057 value: function bodyOverflow(type) { 3058 return _bodyOverflow.call(this, type); 3059 } 3060 }, { 3061 key: 'isInViewport', 3062 value: function isInViewport($item, returnRect) { 3063 return _isInViewport.call(this, $item, returnRect); 3064 } 3065 }, { 3066 key: 'scrollTo', 3067 value: function scrollTo($to, callback) { 3068 return _scrollTo.call(this, $to, callback); 3069 } 3070 }, { 3071 key: 'key', 3072 value: function key(name, callback) { 3073 return _key.call(this, name, callback); 3074 } 3075 }, { 3076 key: 'initShortcuts', 3077 value: function initShortcuts() { 3078 return _initShortcuts.call(this); 3079 } 3080 }, { 3081 key: 'initHeaderTitle', 3082 value: function initHeaderTitle() { 3083 return _initHeaderTitle.call(this); 3084 } 3085 }, { 3086 key: 'initNavbar', 3087 value: function initNavbar() { 3088 return _initNavbar.call(this); 3089 } 3090 }, { 3091 key: 'initNavbarSide', 3092 value: function initNavbarSide() { 3093 return _initNavbarSide.call(this); 3094 } 3095 }, { 3096 key: 'initNavbarFullscreen', 3097 value: function initNavbarFullscreen() { 3098 return _initNavbarFullscreen.call(this); 3099 } 3100 }, { 3101 key: 'initNavbarDropEffect1', 3102 value: function initNavbarDropEffect1() { 3103 return _initNavbarDropEffect.call(this); 3104 } 3105 }, { 3106 key: 'initCounters', 3107 value: function initCounters() { 3108 return _initCounters.call(this); 3109 } 3110 }, { 3111 key: 'initAnchors', 3112 value: function initAnchors() { 3113 return _initAnchors.call(this); 3114 } 3115 }, { 3116 key: 'initVideoBlocks', 3117 value: function initVideoBlocks() { 3118 return _initVideoBlocks.call(this); 3119 } 3120 }, {
3121 key: 'initFullPage', 3122 value: function initFullPage() { 3123 return _initFullPage.call(this); 3124 } 3125 }, { 3126 key: 'initForms', 3127 value: function initForms() { 3128 return _initForms.call(this); 3129 } 3130 }, { 3131 key: 'initTeamBlock', 3132 value: function initTeamBlock() { 3133 return _initTeamBlock.call(this); 3134 } 3135 }, { 3136 key: 'initInstagram', 3137 value: function initInstagram() { 3138 return _initInstagram.call(this); 3139 } 3140 }, { 3141 key: 'initTwitter', 3142 value: function initTwitter() { 3143 return _initTwitter.call(this); 3144 } 3145 }, { 3146 key: 'initDoc', 3147 value: function initDoc() { 3148 return _initDoc.call(this); 3149 } 3150 }, { 3151 key: 'initPluginStickySidebar', 3152 value: function initPluginStickySidebar() { 3153 return _initPluginStickySidebar.call(this); 3154 } 3155 }, { 3156 key: 'initPluginNano', 3157 value: function initPluginNano($context) { 3158 return _initPluginNano.call(this, $context); 3159 } 3160 }, { 3161 key: 'initPluginJarallax', 3162 value: function initPluginJarallax($context) { 3163 return _initPluginJarallax.call(this, $context); 3164 } 3165 }, { 3166 key: 'initPluginFlickity', 3167 value: function initPluginFlickity($context) { 3168 return _initPluginFlickity.call(this, $context); 3169 } 3170 }, { 3171 key: 'initPluginIsotope', 3172 value: function initPluginIsotope($context) { 3173 return _initPluginIsotope.call(this, $context); 3174 } 3175 }, { 3176 key: 'initPluginPhotoswipe', 3177 value: function initPluginPhotoswipe($context) { 3178 return _initPluginPhotoswipe.call(this, $context); 3179 } 3180 }, { 3181 key: 'initPluginTabs', 3182 value: function initPluginTabs($context) { 3183 return _initPluginTabs.call(this, $context); 3184 } 3185 }]); 3186 3187 return SNOW; 3188}(); 3189 3190/*------------------------------------------------------------------ 3191 3192 Init Snow 3193 3194-------------------------------------------------------------------*/ 3195 3196 3197window.Snow = new SNOW(); 3198 3199 3200}()); 3201$(document).ready(function() { 3202 3203 var condizioni_meteo = { 3204 "0" : "tornado", 3205 "1" : "tempesta tropicale", 3206 "2" : "uragano", 3207 "3" : "temporali di grande intensità ", 3208 "4" : "temporali", 3209 "5" : "pioggia mista e neve", 3210 "6" : "pioggia mista e nevischio", 3211 "7" : "neve mista e nevischio", 3212 "8" : "pioggia gelata", 3213 "9" : "pioggerella", 3214 "10" : "grandine", 3215 "11" : "pioggia abbondante", 3216 "12" : "pioggia abbondante", 3217 "13" : "raffiche di neve", 3218 "14" : "deboli nevicate", 3219 "15" : "bufera di neve", 3220 "16" : "neve", 3221 "17" : "grandine", 3222 "18" : "nevischio", 3223 "19" : "ventoso", 3224 "20" : "nebbia", 3225 "21" : "foschia", 3226 "22" : "foschia", 3227 "23" : "ventoso", 3228 "24" : "ventoso", 3229 "25" : "umido", 3230 "26" : "nuvoloso", 3231 "27" : "prevalentemente nuvoloso", 3232 "28" : "prevalentemente nuvoloso", 3233 "29" : "parzialmente nuvoloso", 3234 "30" : "parzialmente nuvoloso", 3235 "31" : "limpido", 3236 "32" : "soleggiato", 3237 "33" : "limpido", 3238 "34" : "limpido", 3239 "35" : "pioggia mista e grandine", 3240 "36" : "caldo", 3241 "37" : "temporali isolati", 3242 "38" : "temporali sparsi", 3243 "39" : "temporali sparsi",
3244 "40" : "acquazzoni sparsi", 3245 "41" : "neve abbondante", 3246 "42" : "neve", 3247 "43" : "neve abbondante", 3248 "44" : "parzialmente nuvoloso", 3249 "45" : "rovesci temporaleschi", 3250 "46" : "neve", 3251 "47" : "temporali", 3252 "3200" : "meteo non disponibile" 3253 } 3254 3255 $('.weather-location').each(function() { 3256 var self = $(this); 3257 // console.log($(this).data('weather-location')); 3258 $.simpleWeather({ 3259 location: $(this).data('weather-location'), 3260 woeid: '', 3261 unit: 'c', 3262 success: function(weather) { 3263 // html = condizioni_meteo[weather.code]+' '+weather.temp+'°'+weather.units.temp; 3264 3265 self.find('.weather-condition').html(condizioni_meteo[weather.code]); 3266 self.find('.weather-temp').html(weather.temp+'°'+weather.units.temp); 3267 self.find('.weather-high').html(weather.high+'°'+weather.units.temp); 3268 self.find('.weather-low').html(weather.low+'°'+weather.units.temp); 3269 self.find('.weather-thumbnail').html('<img src="'+weather.thumbnail+'">'); 3270 self.find('.weather-city').html(self.data('weather-location')); 3271 // console.log(weather); 3272 }, 3273 error: function(error) { 3274 self.html('Situazione metereologica momentaneamente non disponibile.'); 3275 } 3276 }); 3277 }); 3278 3279 if ( $('.generic-carousel').length > 0 ) { 3280 $('.generic-carousel').flickity({ 3281 // options 3282 cellAlign: 'left', 3283 contain: true 3284 }); 3285 } 3286 3287 3288 3289 3290 3291 // var svgshape = document.getElementById( 'notification-shape' ), 3292 // s = Snap( svgshape.querySelector( 'svg' ) ), 3293 // path = s.select( 'path' ), 3294 // pathConfig = { 3295 // from : path.attr( 'd' ), 3296 // to : svgshape.getAttribute( 'data-path-to' ) 3297 // }; 3298 // // bttn = document.getElementById( 'notification-trigger' ); 3299 // var notification_text = $('.notification-shape').data('message'); 3300 // console.log(notification_text); 3301 3302 // // setTimeout(function() { 3303 3304 // var intervalpopup = setInterval(function() { 3305 3306 3307 3308 // if ($(document).scrollTop() > 1000) { 3309 3310 // path.animate( { 'path' : pathConfig.to }, 300, mina.easeinout ); 3311 3312 // // classie.remove( bttn, 'active' ); 3313 3314 3315 // // create the notification 3316 // var notification = new NotificationFx({ 3317 // wrapper : svgshape, 3318 // message: notification_text, 3319 // layout : 'other', 3320 // effect : 'cornerexpand', 3321 // type : 'notice', 3322 // ttl: 10000, 3323 // onClose : function() { 3324 // // bttn.disabled = false; 3325 // setTimeout(function() { 3326 // path.animate( { 'path' : pathConfig.from }, 300, mina.easeinout ); 3327 // }, 200 ); 3328 // } 3329 // }); 3330 3331 // console.log($(document).scrollTop()); 3332 // console.log(notification); 3333 // notification.show(); 3334 3335 // clearInterval(intervalpopup); 3336 // } 3337 // }, 1000); 3338 3339 // // show the notification 3340 // // notification.show(); 3341 // }, 10000); 3342 3343}); // fine document-ready 3344 3345// $(document).ready(function() { 3346// ⦠3347// //FORCE VIDEO PLAY - SAFARI 11 ISSUE 3348// $(window).load(function() { 3349// $('video').get(0).play(); 3350// }); 3351// ⦠3352// }); 3353
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.