Advertisement
krownthemes

/assets/js_main.js

Apr 26th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 84.30 KB | None | 0 0
  1. /* ALL THE SCRIPTS IN THIS FILE ARE MADE BY KROWNTHEMES.COM --- REDISTRIBUTION IS NOT ALLOWED! */
  2.  
  3. $(window).bind("pageshow", function(event) {
  4. if (event.originalEvent.persisted) {
  5. window.location.reload()
  6. }
  7. });
  8.  
  9. $.ajaxSetup({ cache: false });
  10.  
  11. // CONTINUE WITH EVERYTHING ELSE
  12.  
  13. window.blockStickyHeader = false;
  14.  
  15. (function($) {
  16.  
  17. $('#site-filters select:not(.styled)').each(function(){
  18.  
  19. $(this).styledSelect({
  20. coverClass: 'regular-select-cover',
  21. innerClass: 'regular-select-inner'
  22. }).addClass('styled');
  23.  
  24. $(this).parent().append($.themeAssets.arrowDown);
  25.  
  26. if ( $(this).data('label') != '' ) {
  27.  
  28. if ( $(this).find('option:selected').hasClass('default') ) {
  29. $(this).parent().find('.regular-select-inner').html($(this).data('label'));
  30. }
  31.  
  32. $(this).on('change', function(e){
  33. if ( $(this).find('option:selected').hasClass('default') ) {
  34. $(this).parent().find('.regular-select-inner').html($(this).data('label'));
  35. }
  36. });
  37.  
  38. }
  39.  
  40. });
  41.  
  42. $('.site-header').append('<span id="js-helpers"><span id="fix-me-header"></span><span id="fix-me-collection"></span></span>');
  43.  
  44. // tab navigation
  45.  
  46. $('a:not(.ach), button, span, input').on('focus', function(e){
  47. $(this).addClass('hover');
  48. }).on('blur', function(e){
  49. $(this).removeClass('hover');
  50. });
  51.  
  52. $(document).keyup(function(e) {
  53. if (e.keyCode === 27) {
  54. $('.site-close-handle').trigger('click');
  55. }
  56. });
  57.  
  58. // We start with the newsletter code (it needs to be wrapped inside a $(window).load() event function in order to get the perfect timeout after the site has completely loaded
  59.  
  60. window.CUBER = {
  61.  
  62. // MAIN
  63.  
  64. Nav: {
  65.  
  66. $siteHeader: null,
  67. $siteNav: null,
  68. $siteOverlay: null,
  69.  
  70. mount: function() {
  71.  
  72. this.$siteHeader = $('#site-header');
  73. this.$siteNav = $('#site-nav--mobile');
  74. this.$siteOverlay = $('#site-overlay');
  75.  
  76. $('#site-menu-handle').on('click focusin', (function(){
  77.  
  78. if ( ! this.$siteNav.hasClass('active') ) {
  79.  
  80. this.$siteNav.addClass('active');
  81. this.$siteNav.removeClass('show-filters').removeClass('show-cart').removeClass('show-search');
  82.  
  83. this.$siteOverlay.addClass('active');
  84.  
  85. $('.fixing-scroll-now .site-box-background').addClass('sidebar-move');
  86. $('body').addClass('sidebar-move');
  87.  
  88. }
  89.  
  90. }).bind(this));
  91.  
  92. if ( $('#site-filter-handle').length > 0 ) {
  93.  
  94. $('#site-filter-handle').on('click', (function(){
  95.  
  96. if ( ! this.$siteNav.hasClass('active') ) {
  97.  
  98. this.$siteNav.addClass('active');
  99. this.$siteNav.removeClass('show-cart').removeClass('show-search').addClass('show-filters');
  100.  
  101. this.$siteOverlay.addClass('active');
  102.  
  103. $('.fixing-scroll-now .site-box-background').addClass('sidebar-move');
  104. $('body').addClass('sidebar-move');
  105.  
  106. }
  107.  
  108. }).bind(this));
  109.  
  110. }
  111.  
  112. if ( $('#site-cart-handle').length > 0 && ! $('html').hasClass('ie9') ) {
  113.  
  114. if ( $.themeCartSettings == 'overlay' ) {
  115.  
  116. $('#site-cart-handle a').addClass('block-fade');
  117.  
  118. $('#site-cart-handle a').on('click', (function(e){
  119.  
  120. e.preventDefault();
  121.  
  122. if ( ! this.$siteNav.hasClass('active') ) {
  123.  
  124. this.$siteNav.addClass('active');
  125. this.$siteNav.removeClass('show-filters').removeClass('show-search').addClass('show-cart');
  126.  
  127. this.$siteOverlay.addClass('active');
  128.  
  129. $('.fixing-scroll-now .site-box-background').addClass('sidebar-move');
  130. $('body').addClass('sidebar-move');
  131.  
  132. }
  133.  
  134. }).bind(this));
  135.  
  136. }
  137.  
  138. $('#site-cart-handle').on('mouseenter focusis', function(){
  139. $(this).addClass('hover-in').removeClass('hover-out');
  140. }).on('mouseleave focusout', function(){
  141. $(this).addClass('hover-out').removeClass('hover-in');
  142. });
  143.  
  144. }
  145.  
  146. if ( $('#site-search-handle').length > 0 ) {
  147.  
  148. $('#site-search-handle a').addClass('block-fade');
  149.  
  150. $('#site-search-handle a').on('click', (function(e){
  151.  
  152. e.preventDefault();
  153.  
  154. if ( ! this.$siteNav.hasClass('active') ) {
  155.  
  156. if ( $('html').hasClass('ie9') ) {
  157. document.location.href = '/search';
  158. } else {
  159. this.$siteNav.addClass('active');
  160. this.$siteNav.removeClass('show-filters').removeClass('show-cart').addClass('show-search');
  161.  
  162. this.$siteOverlay.addClass('active');
  163.  
  164. $('.fixing-scroll-now .site-box-background').addClass('sidebar-move');
  165. $('body').addClass('sidebar-move');
  166.  
  167. $('form.search-bar input[type="search"]').focus();
  168. }
  169.  
  170. }
  171.  
  172. }).bind(this));
  173.  
  174. $('#site-search-handle').on('mouseenter', function(){
  175. $(this).addClass('hover-in').removeClass('hover-out');
  176. }).on('mouseleave focusout', function(){
  177. $(this).addClass('hover-out').removeClass('hover-in');
  178. });
  179.  
  180. $('a[href="#search"]').on('click', function(e){
  181. e.preventDefault();
  182. $('#site-search-handle a').trigger('click');
  183. })
  184.  
  185. }
  186.  
  187. $('.site-close-handle, #site-overlay').on('click', (function(){
  188.  
  189. if ( this.$siteNav.hasClass('active') ) {
  190.  
  191. this.$siteNav.removeClass('active');
  192. this.$siteOverlay.removeClass('active');
  193.  
  194. $('.fixing-scroll-now .site-box-background').removeClass('sidebar-move');
  195. $('body').removeClass('sidebar-move');
  196.  
  197. }
  198.  
  199. }).bind(this));
  200.  
  201. ///
  202.  
  203. $('.site-nav.style--classic .has-submenu').each(function(){
  204. $(this).on('mouseenter focusin', function(){
  205. $(this).find('.submenu').stop().slideDown(200);
  206. $('body').addClass('opened-submenu');
  207. $('body').addClass('opened-submenu-flag');
  208. $('.site-overlay').addClass('active');
  209. $(this).find('.submenu').attr('aria-expanded', 'true');
  210. }).on('mouseleave focusout', function(){
  211. $(this).find('.submenu').attr('aria-expanded', 'false');
  212. $(this).find('.submenu').stop().slideUp(200, function(){
  213. if ( ! $('body').hasClass('opened-submenu-flag') ) {
  214. $('body').removeClass('opened-submenu');
  215. }
  216. });
  217. $('.site-overlay').removeClass('active');
  218. $('body').removeClass('opened-submenu-flag');
  219. })
  220. })
  221.  
  222. $('.site-nav.style--sidebar .has-submenu:not(.collections-menu)').each(function(){
  223.  
  224. $(this).children('a').addClass('block-fade');
  225. $(this).children('a').on('click touchstart', function(e) {
  226. e.preventDefault();
  227. })
  228.  
  229. $(this).children('a').on('click touchstart', function(e){
  230.  
  231. e.preventDefault();
  232. var $parent = $(this).parent();
  233.  
  234. if ( $parent.hasClass('active') ) {
  235.  
  236. var tempBoNo = false;
  237. var tempBoHref = $(this).attr('href');
  238.  
  239. if ( tempBoHref != '' ) {
  240.  
  241. if ( tempBoHref.indexOf('#') >= 0 ) {
  242.  
  243. tempBoNo = true;
  244.  
  245. if ( tempBoHref.indexOf('#') == ( tempBoHref.length-1 ) ) {
  246. // nothing
  247. } else {
  248. $('.site-close-handle').trigger('click');
  249. document.location.href = tempBoHref;
  250. }
  251.  
  252. } else if ( $(this).attr('target') == '_blank' ) {
  253.  
  254. window.open(tempBoHref, '_blank');
  255.  
  256. } else {
  257.  
  258. $('body').fadeOut(200);
  259. setTimeout((function(){
  260. document.location.href = tempBoHref;
  261. }).bind(this), 200);
  262. e.preventDefault();
  263.  
  264. }
  265.  
  266. } else {
  267. tempBoNo = true;
  268. }
  269.  
  270. if ( tempBoNo ) {
  271. $parent.find('.submenu').stop().slideUp(200);
  272. $parent.removeClass('active');
  273. $parent.find('.submenu').attr('aria-expanded', 'false');
  274. }
  275.  
  276. } else {
  277. $parent.addClass('active');
  278. $parent.find('.submenu').stop().slideDown(200);
  279. $parent.find('.submenu').attr('aria-expanded', 'true');
  280. }
  281.  
  282. $(this).removeClass('hover');
  283.  
  284. })
  285.  
  286. })
  287.  
  288. $('.site-nav.style--sidebar .has-babymenu:not(.collections-menu)').each(function(){
  289.  
  290. $(this).children('a').addClass('block-fade');
  291. $(this).children('a').on('click touchstart', function(e) {
  292. e.preventDefault();
  293. })
  294.  
  295. $(this).children('a').on('click touchstart', function(e){
  296.  
  297. e.preventDefault();
  298. var $parent = $(this).parent();
  299.  
  300. if ( $parent.hasClass('active') ) {
  301.  
  302. var tempBoNo = false;
  303. var tempBoHref = $(this).attr('href');
  304.  
  305. if ( tempBoHref != '' ) {
  306.  
  307. if ( tempBoHref.indexOf('#') >= 0 ) {
  308.  
  309. tempBoNo = true;
  310.  
  311. if ( tempBoHref.indexOf('#') == ( tempBoHref.length-1 ) ) {
  312. // nothing
  313. } else {
  314. $('.site-close-handle').trigger('click');
  315. document.location.href = tempBoHref;
  316. }
  317.  
  318. } else if ( $(this).attr('target') == '_blank' ) {
  319.  
  320. window.open(tempBoHref, '_blank');
  321.  
  322. } else {
  323.  
  324. $('body').fadeOut(200);
  325. setTimeout((function(){
  326. document.location.href =tempBoHref
  327. }).bind(this), 200);
  328. e.preventDefault();
  329.  
  330. }
  331.  
  332. } else {
  333. TempBoNo = true;
  334. }
  335.  
  336. if ( tempBoNo) {
  337. $parent.removeClass('active');
  338. $parent.find('.babymenu').stop().slideUp(200);
  339. $parent.find('.babymenu').attr('aria-expanded', 'false');
  340. }
  341.  
  342. } else {
  343. $parent.addClass('active');
  344. $parent.find('.babymenu').stop().slideDown(200);
  345. $parent.find('.babymenu').attr('aria-expanded', 'true');
  346. }
  347.  
  348. })
  349.  
  350. })
  351.  
  352. $('.style--classic .babymenu').each(function(){
  353.  
  354. var bestWidth = 0;
  355. $(this).parent().parent().css('display', 'block');
  356.  
  357. $(this).find('a').each(function(){
  358. $(this).css('position', 'fixed');
  359. $(this).attr('data-width', $(this).outerWidth(true))
  360. if ( $(this).outerWidth() > bestWidth ) {
  361. bestWidth = $(this).outerWidth(true);
  362. }
  363. $(this).css({'position': 'static', 'width': '100%'});
  364. });
  365.  
  366. bestWidth += 30;
  367. $(this).css('width', bestWidth);
  368. $(this).css('transform', 'translateX(-45%)');
  369. $(this).parent().parent().css('display', 'none');
  370. $(this).css('display', 'none');
  371.  
  372. });
  373.  
  374. $('.style--classic .has-babymenu').each(function(){
  375. $(this).on('mouseenter focusin', function(){
  376. $(this).find('.babymenu').stop().slideDown(200);
  377. $(this).find('.babymenu ul').attr('aria-expanded', 'true');
  378. $(this).css('zIndex', 9);
  379. }).on('mouseleave focusout', function(){
  380. $(this).find('.babymenu').stop().slideUp(200);
  381. $(this).find('.babymenu ul').attr('aria-expanded', 'false');
  382. $(this).css('zIndex', 1);
  383. });
  384. });
  385.  
  386. ///
  387.  
  388. $('body').addClass('desktop--add-some-padding');
  389.  
  390. $('.style--classic li.has-submenu[data-size]').each(function(){
  391. var menuSize = parseInt( $(this).data('size') )
  392. if ( menuSize > 15 ) {
  393. $(this).addClass('text-smallest');
  394. } else if ( menuSize > 10 ) {
  395. $(this).addClass('text-smaller');
  396. } else if ( menuSize > 5 ) {
  397. $(this).addClass('text-small');
  398. }
  399. });
  400.  
  401. // end -- */
  402.  
  403. if ( $('#site-header').hasClass('header-scroll') ) {
  404.  
  405. if ( $('body').hasClass('template-index') ) {
  406. $('body').addClass('index-margin-fix');
  407. }
  408.  
  409. window.lst = $(window).scrollTop();
  410.  
  411. $('.site-nav.style--classic .submenu').css('top', $('.site-header').outerHeight())
  412.  
  413. $(window).on('scroll.sticky-header', (function(){
  414.  
  415. if ( ! window.blockStickyHeader ) {
  416.  
  417. var st = $(window).scrollTop();
  418.  
  419. if ( st < 0 || Math.abs(lst - st) <= 5 )
  420. return;
  421.  
  422. if ( st == 0) {
  423.  
  424. this.$siteHeader.removeClass('animate');
  425. this.$siteHeader.removeClass('fix');
  426. this.$siteHeader.removeClass('ready');
  427. //$('body').css('paddingTop', 0);
  428.  
  429. } else if ( st <= lst && ! this.$siteHeader.hasClass('fix') ) {
  430.  
  431. this.$siteHeader.addClass('fix');
  432. //$('body').css('paddingTop', this.$siteHeader.outerHeight());
  433. setTimeout((function(){
  434. this.$siteHeader.addClass('ready');
  435. }).bind(this), 5);
  436. setTimeout((function(){
  437. this.$siteHeader.addClass('animate');
  438. }).bind(this), 25);
  439.  
  440. } else if ( st > lst && this.$siteHeader.hasClass('animate') ) {
  441.  
  442. this.$siteHeader.removeClass('animate');
  443. setTimeout((function(){
  444. this.$siteHeader.removeClass('fix');
  445. this.$siteHeader.removeClass('ready');
  446. //$('body').css('paddingTop', 0);
  447. }).bind(this), 105);
  448.  
  449. }
  450.  
  451. window.lst = st;
  452.  
  453. }
  454.  
  455. }).bind(this));
  456.  
  457. }
  458.  
  459. },
  460.  
  461. unmount: function() {
  462.  
  463. $('#site-menu-handle').off('click');
  464. $('#site-cart-handle a').off('click');
  465. $('#site-filter-handle').off('click');
  466.  
  467. this.$siteNav.removeClass('active');
  468. this.$siteOverlay.removeClass('active');
  469.  
  470. $('.fixing-scroll-now .site-box-background').removeClass('sidebar-move');
  471. $('body').removeClass('sidebar-move');
  472.  
  473. $(window).off('scroll.sticky-header');
  474.  
  475. }
  476.  
  477. },
  478.  
  479. // COLLECTION
  480.  
  481. Collection: {
  482.  
  483. $collectionGrid: null,
  484. $collectionNext: null,
  485. $collectionNextLink: null,
  486.  
  487. mount: function() {
  488.  
  489. if ( $('.box__paginate').length > 0 ) {
  490.  
  491. this.$collectionGrid = $('#section-collection');
  492. this.$collectionNext = $('.box__paginate');
  493. this.$collectionNextLink = $('.box__paginate a');
  494.  
  495. this.$collectionNextLink.append('<div class="preloader"><span>.</span><span>.</span><span>.</span></div>')
  496.  
  497. this.$collectionNextLink.on('click', (function(e){
  498.  
  499. this.$collectionNextLink.addClass('loading');
  500. var nextPageURL = this.$collectionNextLink.attr('href');
  501.  
  502. $.ajax({
  503. url: nextPageURL
  504. }).done((function(data){
  505.  
  506. this.$collectionNextLink.removeClass('loading');
  507. this.$collectionNext.before($(data).find('.site-box.box__collection'));
  508. //window.CUBER.Images.mount();
  509.  
  510. var i = 0;
  511. this.$collectionGrid.find('.box__collection:not(.active)').each(function(){
  512. setTimeout((function(){
  513. $(this).addClass('active');
  514. }).bind(this), 100*i++);
  515. });
  516.  
  517. if ( $(data).find('.site-box.box__paginate').length > 0 ) {
  518. this.$collectionNextLink.attr('href', $(data).find('.site-box.box__paginate a').attr('href'));
  519. } else {
  520. this.$collectionNext.remove();
  521. }
  522.  
  523. }).bind(this));
  524.  
  525. e.preventDefault();
  526.  
  527. }).bind(this));
  528.  
  529. }
  530.  
  531. $(window).on('resize.collection-grid', window.debounce((function(){
  532. this._resizeCollection();
  533. }).bind(this), 300)).trigger('resize.collection-grid');
  534. this._resizeCollection();
  535.  
  536. // empty grid fix
  537.  
  538. var collectionSize = parseInt($('.box__heading').data('size'));
  539.  
  540. if ( collectionSize > 0 && collectionSize < 4 ) {
  541. for ( var i = 0; i < 4 - collectionSize; i++ ) {
  542. $('#section-collection').append('<div class="site-box box--small box--typo-small lap--hide box--no-padding box__collection active" />');
  543. }
  544. }
  545.  
  546. },
  547.  
  548. _resizeCollection: function() {
  549.  
  550.  
  551. if ( $('#fix-me-header').css('display') == 'block' && $('#fix-me-collection').css('display') == 'block' ) {
  552.  
  553. var h = $(window).height() - $('.site-header').outerHeight();
  554.  
  555. if ( h > 720 ) {
  556.  
  557. //$('.mount-products .site-box.box__heading').attr('style', 'height:' + h + 'px !important; min-height: 0 !important;');
  558. $('.mount-products .site-box.box__collection_image').attr('style', 'height:' + h + 'px !important; min-height: 0 !important;');
  559.  
  560. } else {
  561.  
  562. h = 720;
  563.  
  564. if ( $('.mount-products .site-box.box__collection_image').length > 0 ) {
  565. $('.mount-products .site-box.box__heading').attr('style', 'height:' + ( $(window).height() - $('.site-header').outerHeight() ) + 'px !important; min-height: 0 !important;');
  566. $('.mount-products .site-box.box__collection_image').attr('style', 'height:' + ( $(window).height() - $('.site-header').outerHeight() ) + 'px !important; min-height: 0 !important;');
  567. } else {
  568.  
  569. //$('.mount-products .site-box.box__heading').attr('style', 'height:' + h + 'px !important; min-height: 0 !important;');
  570. //$('.mount-products .site-box.box__heading .site-box-content').css('marginTop', -$('.site-header').outerHeight());
  571.  
  572. }
  573.  
  574.  
  575. }
  576.  
  577. $('.mount-products .site-box.box__collection').each(function(){
  578. //$(this).attr('style', 'height:' + ( h / 2 ) + 'px !important');
  579. });
  580.  
  581. } else {
  582.  
  583. $('.mount-products .site-box.box__collection, .mount-products .site-box.box__heading').attr('style', '');
  584.  
  585. }
  586.  
  587. },
  588.  
  589. unmount: function() {
  590. $(window).off('resize.collection-grid');
  591. }
  592.  
  593. },
  594.  
  595. // PRODUCT
  596.  
  597. Product: {
  598.  
  599. $productGallery: null,
  600. $productGalleryItem: null,
  601. $productGalleryIndex: null,
  602.  
  603. $productCarousel: null,
  604. $productCarouselImgs: null,
  605. productFlkty: null,
  606.  
  607. $productStuff: null,
  608. productStuffMove: false,
  609.  
  610. mount: function($product) {
  611.  
  612. var productIsDisabled = false;
  613.  
  614. if ( $product.find('.product--section').data('hide-variants') && $product.find('.product--section').data('product-available') ) {
  615. this._advancedOptionsSelector($product, JSON.parse($product.find('.product-json')[0].innerHTML));
  616. } else if ( $product.find('.product--section').data('hide-variants') && ! $product.find('.product--section').data('product-available') ) {
  617. productIsDisabled = true;
  618. }
  619.  
  620. // Product gallery
  621.  
  622. var _this = {};
  623. $product.data('po', _this);
  624.  
  625. _this.$productGallery = $product.find('.box__product-gallery');
  626. _this.$productGalleryItem = $product.find('.box__product-gallery .gallery-item');
  627.  
  628. _this.$productGallery.append('<div class="gallery-index out-with-you"><span class="current">' + ( window.CuberProductImageIndex != undefined ? ( window.CuberProductImageIndex + 1 ) : 1 ) + '</span> / <span class="total">' + _this.$productGalleryItem.length + '</span></div>');
  629. _this.$productGalleryIndex = _this.$productGallery.find('.gallery-index .current');
  630.  
  631. _this.$productCarousel = _this.$productGallery.children('.site-box-content');
  632.  
  633. window.CUBER.Main._mountScrollMovers({
  634. 'parent': _this.$productGallery,
  635. 'items': $('.gallery-index, .site-sharing, .product-zoom')
  636. });
  637.  
  638. window.CUBER.Main._mobileSharingInit();
  639.  
  640. if ( _this.$productGallery.hasClass('scroll') ) {
  641.  
  642. // init scrollable gallery
  643.  
  644. $(window).on('scroll.product-gallery', (function() {
  645.  
  646. if ( ! _this.$productCarousel.hasClass('flickity-enabled') ) {
  647.  
  648. _this.$productGalleryItem.each((function(key, elm){
  649.  
  650. if ( $(window).scrollTop() + $(window).height() > $(elm).offset().top + $(window).height() / 2 && ! $(elm).hasClass('current') ) {
  651.  
  652. $(elm).addClass('current');
  653. _this.$productGalleryIndex.html($(elm).index() + 1);
  654.  
  655. } else if ( $(window).scrollTop() + $(window).height() < $(elm).offset().top + $(window).height() / 2 && $(elm).hasClass('current') ) {
  656.  
  657. $(elm).removeClass('current');
  658. _this.$productGalleryIndex.html($(elm).index());
  659.  
  660. }
  661.  
  662. }).bind(_this));
  663.  
  664. }
  665.  
  666. }).bind(_this)).trigger('scroll.product-gallery');
  667.  
  668. }
  669.  
  670. // init sliding gallery (always, because it turns into this at responsive)
  671.  
  672. _this.$productCarousel.flickity({
  673. cellSelector: '.gallery-item:not(.remove-from-flick)',
  674. initialIndex: window.CuberProductImageIndex != undefined ? window.CuberProductImageIndex : 0,
  675. wrapAround: true,
  676. prevNextButtons: false,
  677. pageDots: true,
  678. watchCSS: _this.$productGallery.hasClass('scroll') ? true : false,
  679. resize: true
  680. });
  681.  
  682. window.CUBER.Scroll.mount();
  683.  
  684. _this.productFlkty = _this.$productCarousel.data('flickity');
  685. _this.$productCarouselImgs = _this.$productCarousel.find('.gallery-item img');
  686.  
  687. _this.$productCarousel.on('select.flickity', (function(){
  688. _this.$productGalleryIndex.html((_this.productFlkty.selectedIndex+1));
  689. }).bind(_this))
  690.  
  691. if ( _this.$productGallery.hasClass('slider') ) {
  692.  
  693. _this.$productGallery.find('.gallery-index').append('<span class="icon-go go-prev">' + $.themeAssets.arrowRight + '</span><span class="icon-go go-next">' + $.themeAssets.arrowRight + '</span>');
  694.  
  695. _this.$productGallery.find('.go-prev').on('click', (function(){
  696. _this.productFlkty.previous();
  697. }).bind(_this));
  698.  
  699. _this.$productGallery.find('.go-next').on('click', (function(){
  700. _this.productFlkty.next();
  701. }).bind(_this));
  702.  
  703. }
  704.  
  705. // Product zoom
  706.  
  707. if ( $('#product-zoom-in').length > 0 ) {
  708.  
  709. $('body').append('<div id="product-zoomed-image"><img /><div id="product-zoom-out" class="product-zoom expand"><span class="zoom-out">' + $.themeAssets.iconZoom + '</span></div></div>');
  710.  
  711. $('#product-zoom-in').on('click', (function(e){
  712.  
  713. // animation out
  714.  
  715. $('#section-product').find('.site-box.box__product-content').addClass('animate');
  716. setTimeout(function(){
  717. $('#section-product').find('.site-box.box__product-content').addClass('expand');
  718. $('body').addClass('kill-overflow');
  719. }, 10);
  720.  
  721. $('#section-product').find('.site-box.box__product-gallery').stop().animate({'opacity': 0}, 200);
  722. $('#shopify-section-header, #shopify-section-footer, .site-sharing').stop().animate({'opacity': 0}, 200);
  723.  
  724. // object
  725.  
  726. var $image = $('#product-zoomed-image img');
  727. $image.attr('src', $('.gallery-item').eq(parseInt(_this.$productGalleryIndex.html())-1).data('master'));
  728.  
  729. setTimeout((function(){
  730. if ( $image[0].naturalWidth > 0 ) {
  731. this._productZoomMount($image);
  732. } else {
  733. $image.on('load', (function(){
  734. this._productZoomMount($image);
  735. }).bind(this))
  736. }
  737. }).bind(this), 200);
  738.  
  739. }).bind(this));
  740.  
  741. $('#product-zoom-out').on('click', (function(e){
  742.  
  743. setTimeout(function(){
  744.  
  745. // animation out
  746.  
  747. $('#section-product').find('.site-box.box__product-content').removeClass('expand');
  748. $('body').removeClass('kill-overflow')
  749. setTimeout(function(){
  750. $('#section-product').find('.site-box.box__product-content').removeClass('animate');
  751. }, 400);
  752.  
  753. $('#section-product').find('.site-box.box__product-gallery').stop().animate({'opacity': 1}, 200);
  754. $('#shopify-section-header, #shopify-section-footer, .site-sharing').stop().animate({'opacity': 1}, 200);
  755.  
  756. }, 150);
  757.  
  758. // object
  759.  
  760. this._productZoomUnmount();
  761.  
  762. }).bind(this));
  763.  
  764. }
  765.  
  766. // Add to cart (& ajax)
  767.  
  768. if ( ! $product.find('.product--section').hasClass('onboarding-true') ) {
  769. this.initProductForm($product, productIsDisabled);
  770. }
  771.  
  772. if ( $product.find('.qty-button').length > 0 ) {
  773.  
  774. var $productQty = $product.find('.quantity-selector');
  775.  
  776. if ( parseInt($productQty.val()) - 1 < parseInt($productQty.attr('min')) ) {
  777. $product.find('.qty-minus').addClass('disabled');
  778. }
  779. if ( parseInt($productQty.val()) + 1 > parseInt($productQty.attr('max')) ) {
  780. $product.find('.qty-plus').addClass('disabled');
  781. }
  782.  
  783. $product.find('.qty-minus').on('click', (function($productQty, $productQtyPlus, e){
  784. if ( ! $(e.target).hasClass('disabled') ) {
  785. var currentQty = parseInt($productQty.val());
  786. if ( currentQty - 1 >= parseInt( $productQty.attr('min') ) ) {
  787. $productQty.val(currentQty - 1);
  788. $productQtyPlus.removeClass('disabled');
  789. }
  790. if ( currentQty - 1 <= parseInt( $productQty.attr('min') ) ) {
  791. $(e.target).addClass('disabled');
  792. }
  793. }
  794. e.preventDefault();
  795. }).bind(this, $productQty, $product.find('.qty-plus')));
  796.  
  797. $product.find('.qty-plus').on('click', (function($productQty, $productQtyMinus, e){
  798. if ( ! $(e.target).hasClass('disabled') ) {
  799. var currentQty = parseInt($productQty.val());
  800. if ( currentQty + 1 <= parseInt( $productQty.attr('max') ) ) {
  801. $productQty.val(currentQty + 1);
  802. $productQtyMinus.removeClass('disabled');
  803. }
  804. if ( currentQty + 1 >= parseInt( $productQty.attr('max') ) ) {
  805. $(e.target).addClass('disabled');
  806. }
  807. }
  808. e.preventDefault();
  809. }).bind(this, $productQty, $product.find('.qty-minus')));
  810.  
  811. }
  812.  
  813. if ( $product.find('.product--add-to-cart-form').length > 0 && $product.find('.product--add-to-cart-form').data('type') == 'overlay' && ! $('html').hasClass('ie9') ) {
  814.  
  815. var $form = $product.find('.product--add-to-cart-form form'),
  816. $submitText = $form.find('.add-to-cart-text'),
  817. $submitButton = $form.find('button[type="submit"]'),
  818. $cartCount = $('.cart-menu .count'),
  819. $cartQty = $product.find('.quantity-selector');
  820.  
  821. if ( $form.attr('action').indexOf('.js') < 0 ) {
  822. $form.attr('action', $form.attr('action') + '.js');
  823. }
  824.  
  825. $form.submit(function(e){
  826.  
  827. e.preventDefault();
  828.  
  829. var oldText = $submitText.html();
  830. $submitText.html('<span class="preloader"><span>.</span><span>.</span><span>.</span></span>');
  831. $submitButton.css('pointer-events', 'none');
  832.  
  833. var itemName = $product.find('.product-title').text(),
  834. itemPrice = $product.find('.product-price').attr('data-price'),
  835. itemCurrency = $('meta[itemprop="priceCurrency"]').attr('content'),
  836. itemId = $product.find('.product--section').data('id');
  837.  
  838. $.ajax({
  839.  
  840. type: $form.prop('method'),
  841. url: $form.prop('action'),
  842. data: $form.serialize(),
  843. dataType: 'json',
  844. success: function(data){
  845.  
  846. setTimeout(function(){
  847. $submitText.html(oldText);
  848. $submitButton.css('pointer-events', 'all');
  849. }, 500);
  850.  
  851. $.ajax({
  852. url: '/cart',
  853. success: function(data) {
  854.  
  855. if ( typeof fbq !== 'undefined' ) {
  856. fbq('track', 'AddToCart', {
  857. content_name: itemName,
  858. content_ids: [itemId],
  859. content_type: 'product_group',
  860. value: itemPrice,
  861. currency: itemCurrency
  862. });
  863. }
  864.  
  865. $('#site-cart .cart-items').html($(data).find('#site-cart .cart-items .cart-item'));
  866. $('#CartTotal').html($(data).find('#CartTotal').html());
  867.  
  868. setTimeout(function(){
  869. $submitText.html(oldText);
  870. $submitButton.css('pointer-events', 'all');
  871. }, 500);
  872.  
  873. if ( $cartQty.length > 0 ) {
  874.  
  875. var qty = parseInt($cartQty.val());
  876. if ( qty == 1 ) {
  877. $('#site-cart .subtitle').html($('#site-cart .subtitle').data('added-singular').replace(/{{ count }}|count|{{count}}/g, qty));
  878. } else {
  879. $('#site-cart .subtitle').html($('#site-cart .subtitle').data('added-plural').replace(/{{ count }}|count|{{count}}/g, qty));
  880. }
  881.  
  882. $cartCount.text(parseInt($cartCount.text()) + parseInt($cartQty.val()));
  883.  
  884. } else {
  885.  
  886. $cartCount.text(parseInt($cartCount.text()) + 1);
  887. $('#site-cart .subtitle').html($('#site-cart .subtitle').data('added-singular').replace(/{{ count }}|count|{{count}}/, 1));
  888.  
  889. }
  890.  
  891. $('.site-cart-handle a').trigger('click');
  892.  
  893. }
  894. });
  895.  
  896. },
  897.  
  898. error: function(data) {
  899.  
  900. alert(data.responseJSON.description);
  901.  
  902. setTimeout(function(){
  903. $submitText.html(oldText);
  904. $submitButton.css('pointer-events', 'all');
  905. }, 100);
  906.  
  907. }
  908. });
  909.  
  910. });
  911.  
  912. }
  913.  
  914. },
  915.  
  916. _productZoomMount: function( $image ) {
  917.  
  918. $('#product-zoomed-image').css('display', 'block');
  919. $image.css({'left': 0, 'top': 0});
  920.  
  921. $(window).on('mousemove.product-zoom', function(e) {
  922. e.preventDefault();
  923. window.clientX = e.clientX;
  924. window.clientY = e.clientY;
  925. var x = e.clientX * ( $(window).width() - $image.width() ) / $(window).width();
  926. var y = e.clientY * ( $(window).height() - $image.height() ) / $(window).height();
  927.  
  928. $image.css({'left': x, 'top': y});
  929. });
  930.  
  931. if ( $image[0].naturalWidth <= $image[0].naturalHeight ) {
  932. $image.addClass('portrait');
  933. } else {
  934. $image.addClass('landscape');
  935. }
  936. $image.data('ratio', $image[0].naturalWidth / $image[0].naturalHeight);
  937.  
  938. $(window).on('resize.product-zoom', function(){
  939.  
  940. var rf = $(window).width() > 768 ? 1 : 2;
  941.  
  942. if ( $image.hasClass('portrait') ) {
  943. $image.css('width', $(window).width()*rf);
  944. $image.css('height', $(window).width()*rf / $image.data('ratio'));
  945. } else {
  946.  
  947. $image.css('height', $(window).height()*rf);
  948. $image.css('width', $(window).height()*rf * $image.data('ratio'));
  949.  
  950. if ( $image.width() < $(window).width() ) {
  951. $image.css('width', $(window).width()*rf);
  952. $image.css('height', $(window).width()*rf / $image.data('ratio'));
  953. }
  954.  
  955. }
  956.  
  957. var x = window.clientX * ( $(window).width() - $image.width() ) / $(window).width();
  958. var y = window.clientY * ( $(window).height() - $image.height() ) / $(window).height();
  959.  
  960. //$image.css({'left': x, 'top': y});
  961.  
  962. }).trigger('resize');
  963.  
  964. $image.css('opacity', 1);
  965.  
  966. },
  967.  
  968. _productZoomUnmount: function() {
  969.  
  970. $('#product-zoomed-image img').css('opacity', '0');
  971.  
  972. setTimeout(function(){
  973. $(window).off('resize.product-zoom');
  974. $(window).off('mousemove.product-zoom');
  975. $('#product-zoomed-image img').attr('src', '');
  976. $('#product-zoomed-image').css('display', 'none');
  977. }, 300);
  978.  
  979. },
  980.  
  981. initProductForm : function( $product, pdisabled ) {
  982.  
  983. var firstVariantEver = true;
  984.  
  985. var productSingleObject = JSON.parse($product.find('.product-json')[0].innerHTML),
  986. productVariants = productSingleObject.variants;
  987.  
  988. $product.find('form select.product-variants').on('change', (function(e){
  989. this._initProductVariantChange(false, productSingleObject, $product);
  990. }).bind(this));
  991.  
  992. this._initProductVariantChange(true, productSingleObject, $product);
  993.  
  994. if ( $product.find('.product--add-to-cart-form').hasClass('style--classic') ) {
  995.  
  996. $product.find('select.product-variants:not(.styled)').each(function(){
  997.  
  998. $(this).styledSelect({
  999. coverClass: 'regular-select-cover',
  1000. innerClass: 'regular-select-inner'
  1001. }).addClass('styled');
  1002.  
  1003. $(this).parent().append($.themeAssets.arrowDown);
  1004.  
  1005. $(this).on('focusin', function(){
  1006. $(this).parent().addClass('focus');
  1007. }).on('focusout', function(){
  1008. $(this).parent().removeClass('focus');
  1009. });
  1010.  
  1011. });
  1012.  
  1013. $product.find('.product-variant').removeClass('hidden');
  1014.  
  1015. if ( pdisabled ) {
  1016. $product.find('.product-variant').css('display', 'none');
  1017. }
  1018.  
  1019. } else {
  1020.  
  1021. var i = 1;
  1022.  
  1023. $product.find('.product-variant').each(function(){
  1024.  
  1025. var color = window.returnColorVariant($(this).find('label').text()) ? true : false,
  1026. varDOM = '<ul class="color-' + color + '">';
  1027.  
  1028. $(this).find('.product-variants option').each(function(){
  1029. varDOM += '<li' + ( $(this).is(':selected') ? ' class="active"' : '' ) + ' tabindex="0" data-text="' + $(this).val() + '"><span' + ( color ? ' style="background-color: ' + $(this).val().split(' ').pop() + '"' : '' ) + '>' + $(this).val() + '</span></li>';
  1030. });
  1031.  
  1032. varDOM += '</ul>';
  1033. $(this).find('select').hide();
  1034. $(this).append(varDOM);
  1035.  
  1036. $(this).removeClass('hidden');
  1037.  
  1038. $(this).find('ul li').on('click', function(){
  1039. $(this).parent().parent().find('select').val($(this).find('span').text()).change();
  1040. });
  1041.  
  1042. $(this).find('ul li').on('keyup', function(e){
  1043. if ( e.keyCode == 13 ) {
  1044. $(this).parent().parent().find('select').val($(this).find('span').text()).change();
  1045. }
  1046. });
  1047.  
  1048. });
  1049.  
  1050. if ( pdisabled ) {
  1051. $product.find('.product-variant').find('li').addClass('disabled');
  1052. }
  1053.  
  1054. }
  1055.  
  1056. if ( productSingleObject.variants.length == 1 && productSingleObject.variants[0].title.indexOf('Default') >= 0 ) {
  1057. $product.find('.product-variant').hide();
  1058. }
  1059.  
  1060. },
  1061.  
  1062. _getProductVariant : function( $product ) {
  1063.  
  1064. /* ----
  1065. Get current variant
  1066. ---- */
  1067.  
  1068. var optionArray = [];
  1069.  
  1070. $product.find('form select.product-variants').each(function(){
  1071. optionArray.push($(this).find(':selected').val())
  1072. });
  1073.  
  1074. return optionArray;
  1075.  
  1076. },
  1077.  
  1078. _initProductVariantChange : function(firstTime, productSingleObject, $product) {
  1079.  
  1080. var variant = null,
  1081. options = this._getProductVariant( $product );
  1082.  
  1083. productSingleObject.variants.forEach(function(el){
  1084.  
  1085. if ( $(el)[0].options.equals(options) ) {
  1086. variant = $(el)[0];
  1087. }
  1088.  
  1089. });
  1090.  
  1091. this._productSelectCallback(variant, $product, productSingleObject);
  1092.  
  1093. if ( ! firstTime && $product.find('#productSelect option').length > 1 && ! $('body').hasClass('template-index') ) {
  1094. this._updateProductVariantState(variant);
  1095. }
  1096.  
  1097. },
  1098.  
  1099. _updateProductVariantState : function(variant) {
  1100.  
  1101. if (!history.pushState || !variant) {
  1102. return;
  1103. }
  1104.  
  1105. var newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + '?variant=' + variant.id;
  1106. window.history.replaceState({path: newurl}, '', newurl);
  1107.  
  1108. },
  1109.  
  1110. _productSelectCallback : function(variant, $product, productSingleObject) {
  1111.  
  1112. var _po = $product.data('po');
  1113.  
  1114. var $addToCart = $product.find('.product--add-to-cart-form'),
  1115. $addToCartButton = $addToCart.find('button[type="submit"]'),
  1116. $productPrice = $product.find('.product-price'),
  1117. $comparePrice = $product.find('.compare-price'),
  1118. $quantityElements = $product.find('.quantity-selector, label + .js-qty'),
  1119. $quantityElementsHolder = $product.find('.quantity-selector-holder'),
  1120. $addToCartText = $product.find('.add-to-cart-text'),
  1121. $productGallery = $product.find('.box__product-gallery');
  1122.  
  1123. if (variant) {
  1124.  
  1125. // Set cart value id
  1126.  
  1127. $product.find('#productSelect').find('option[value="' + variant.id + '"]').prop('selected', true);
  1128.  
  1129. // Swipe to variant slide
  1130.  
  1131. if ( variant.featured_image != null ) {
  1132.  
  1133. var variantImg = $productGallery.find('.gallery-item[data-variant-img="' + variant.featured_image.id + '"]');
  1134.  
  1135. if ( typeof VIG !== 'undefined' ) {
  1136.  
  1137. VIG.switchImages(productSingleObject.id, variant.id, '.box__product-gallery .site-box-content');
  1138.  
  1139. if ( $product.find('.box__product-gallery .site-box-content').hasClass('flickity-enabled') ) {
  1140.  
  1141. setTimeout(function(){
  1142.  
  1143. $product.find('.box__product-gallery .gallery-item').each(function(){
  1144. $(this).removeClass('remove-from-flick');
  1145. if ( $(this).css('display') == 'none' ) {
  1146. $(this).addClass('remove-from-flick');
  1147. }
  1148. })
  1149.  
  1150. _po.productFlkty.reloadCells();
  1151. _po.productFlkty.reposition();
  1152.  
  1153. }, 1000);
  1154.  
  1155. }
  1156.  
  1157. } else if ( $productGallery.hasClass('scroll') && variantImg.length > 0 && $(window).width() > 1024 ) {
  1158.  
  1159. if ( $(window).scrollTop() > 0 ) {
  1160. $('html, body').stop().animate({'scrollTop': $productGallery.offset().top}, 150, function(){
  1161. $(window).off('scroll.to-junk');
  1162. })
  1163. }
  1164.  
  1165. variantImg.prependTo($product.find('.box__product-gallery .site-box-content'))
  1166.  
  1167. } else if ( _po != undefined && variantImg.length > 0 ) {
  1168. if ( _po.productFlkty != undefined && variantImg.data('index') != _po.productFlkty.selectedElement ) {
  1169. _po.productFlkty.select(variantImg.data('index'));
  1170. } else {
  1171. window.CuberProductImageIndex = variantImg.data('index');
  1172. }
  1173. }
  1174.  
  1175. }
  1176.  
  1177. // Disable other variants
  1178.  
  1179. if ( $addToCart.hasClass('style--minimal') ) {
  1180. $product.find('.product-variant li').each(function(){
  1181. $(this).removeClass('active');
  1182. if ( variant.option1 == $(this).data('text') || variant.option2 == $(this).data('text') || variant.option3 == $(this).data('text') ) {
  1183. $(this).addClass('active');
  1184. }
  1185. })
  1186. }
  1187.  
  1188. // Edit cart buttons based on stock
  1189.  
  1190. var $variantQuantity = $product.find('.variant-quantity');
  1191.  
  1192. if ( variant.available ) {
  1193.  
  1194. $quantityElements.prop('max', 999);
  1195. $addToCartButton.removeClass('disabled').prop('disabled', false);
  1196. $addToCartText.text($('body').hasClass('template-product-pre-order') ? $addToCartText.data('text') : window.product_words_add_to_cart_button);
  1197. $variantQuantity.text($('body').hasClass('template-product-pre-order') ? $variantQuantity.data('text') : '');
  1198. $quantityElements.show();
  1199. if ( $quantityElementsHolder != null ) {
  1200. $quantityElementsHolder.show();
  1201. }
  1202.  
  1203. } else {
  1204.  
  1205. $variantQuantity.text(window.product_words_no_products);
  1206. $addToCartButton.addClass('disabled').prop('disabled', true);
  1207. $addToCartText.text(window.product_words_sold_out_variant);
  1208. $quantityElements.hide();
  1209. if ( $quantityElementsHolder != null ) {
  1210. $quantityElementsHolder.hide();
  1211. }
  1212.  
  1213. }
  1214.  
  1215. // Update price
  1216.  
  1217. $productPrice.html( theme.Currency.formatMoney(variant.price, window.shop_money_format) );
  1218. $productPrice.attr( 'data-price', variant.price / 100 );
  1219. if ( variant.compare_at_price > variant.price ) {
  1220. $comparePrice.html(theme.Currency.formatMoney(variant.compare_at_price, window.shop_money_format)).show();
  1221. } else {
  1222. $comparePrice.hide();
  1223. }
  1224.  
  1225. // Update sku
  1226.  
  1227. if ( $product.find('.variant-sku').length > 0 ) {
  1228. if ( variant ) {
  1229. $product.find('.variant-sku').text(variant.sku);
  1230. } else {
  1231. $product.find('.variant-sku').empty();
  1232. }
  1233. }
  1234.  
  1235. } else {
  1236.  
  1237. // Disable variant completely
  1238.  
  1239. $addToCartButton.addClass('disabled').prop('disabled', true);
  1240. $addToCartText.text(window.product_words_unavailable_variant);
  1241. $quantityElements.hide();
  1242. if ( $quantityElementsHolder != null ) {
  1243. $quantityElementsHolder.hide();
  1244. }
  1245.  
  1246. }
  1247.  
  1248. if ( $product.find('.qty-button').length > 0 ) {
  1249.  
  1250. var $productQty = $product.find('.quantity-selector');
  1251. $product.find('.qty-minus').removeClass('disabled');
  1252. $product.find('.qty-plus').removeClass('disabled');
  1253.  
  1254. if ( parseInt($productQty.val()) - 1 < parseInt($productQty.attr('min')) ) {
  1255. $product.find('.qty-minus').addClass('disabled');
  1256. }
  1257. if ( parseInt($productQty.val()) + 1 > parseInt($productQty.attr('max')) ) {
  1258. $product.find('.qty-plus').addClass('disabled');
  1259. }
  1260.  
  1261. }
  1262.  
  1263. },
  1264.  
  1265. _advancedOptionsSelector: function($product, productJson) {
  1266. var om = {};
  1267. $product.data('om', om);
  1268. var forceMutation = false;
  1269. var $addToCartForm = $product.find('.product--add-to-cart-form');
  1270. if (window.MutationObserver && $addToCartForm.length) {
  1271. if (typeof observer === 'object' && typeof observer.disconnect === 'function') {
  1272. observer.disconnect();
  1273. }
  1274. var config = { childList: true, subtree: true };
  1275. var observer = new MutationObserver(function() {
  1276. Shopify.linkOptionSelectors(productJson, $product);
  1277. observer.disconnect();
  1278. });
  1279. if ( forceMutation ) {
  1280. Shopify.linkOptionSelectors(productJson, $product);
  1281. }
  1282. observer.observe($addToCartForm[0], config);
  1283. }
  1284. },
  1285.  
  1286. unmount: function($product) {
  1287. var po = $product.data('po');
  1288. $(window).off('scroll.product-gallery');
  1289. $(window).off('resize.position-product-zoom');
  1290. po.$productCarousel.off('scroll.flickity');
  1291. po.$productCarousel.off('select.flickity');
  1292. po.productFlkty.destroy();
  1293. $('#product-zoom').off('click');
  1294. }
  1295.  
  1296. },
  1297.  
  1298. Main: {
  1299.  
  1300. $searchForm: null,
  1301. $searchResults: null,
  1302. $searchPreloader: null,
  1303. $searchPagination: null,
  1304.  
  1305. $body: null,
  1306. $siteHeader: null,
  1307. $siteFooter: null,
  1308.  
  1309. $siteBoxes: null,
  1310.  
  1311. _mountScrollMovers: function(props) {
  1312.  
  1313. var $parent = props['parent'],
  1314. parentOutOfFocus = false;
  1315.  
  1316. setTimeout(function(){
  1317. props['items'].removeClass('out-with-you');
  1318. }, 1000);
  1319. props['items'].addClass('animate-owy');
  1320.  
  1321. $(window).on('scroll.scroll-movers', (function(){
  1322.  
  1323. /*if ( ! parentOutOfFocus && $(window).scrollTop() + $(window).height() < $parent.offset().top ) {
  1324.  
  1325. // before element
  1326. props['items'].addClass('out-with-you');
  1327. parentOutOfFocus = true;
  1328.  
  1329. } else */if ( ! parentOutOfFocus && $(window).scrollTop() + $(window).height() > $parent.offset().top + $parent.height() ) {
  1330.  
  1331. // after element
  1332. props['items'].addClass('out-with-you');
  1333. parentOutOfFocus = true;
  1334.  
  1335. } else if ( parentOutOfFocus && $(window).scrollTop() + $(window).height() <= $parent.offset().top + $parent.height() ) {
  1336.  
  1337. // within element
  1338. parentOutOfFocus = false;
  1339. props['items'].removeClass('out-with-you');
  1340.  
  1341. }
  1342.  
  1343. }).bind(this));
  1344.  
  1345. },
  1346.  
  1347. _mobileSharingInit: function() {
  1348.  
  1349. $('.touchevents .site-sharing .icon').on('touchstart', function(e){
  1350.  
  1351. e.preventDefault();
  1352. var $parent = $(this).parent();
  1353.  
  1354. if ( $parent.hasClass('hover') ) {
  1355. $parent.removeClass('hover');
  1356. } else {
  1357. $parent.addClass('hover');
  1358. }
  1359.  
  1360. });
  1361.  
  1362. $('.touchevents .site-sharing a').on('touchstart', function(e){
  1363. $(this).parent().removeClass('hover');
  1364. });
  1365.  
  1366. },
  1367.  
  1368. _resizeEverything: function() {
  1369.  
  1370. this.$body.css('paddingTop', this.$siteHeader.outerHeight());
  1371.  
  1372. if ( this.$body.hasClass('template-index') ) {
  1373.  
  1374. if ( $('#fix-me-header').css('display') == 'block' ) {
  1375.  
  1376. if ( $('.mount-slideshow').children('div').length > 0 ) {
  1377.  
  1378. $('#shopify-section-home_slideshow').css('marginTop', -this.$siteHeader.outerHeight());
  1379. $('.fix-me-with-margin').css('marginTop', this.$siteHeader.outerHeight());
  1380.  
  1381. } else {
  1382.  
  1383. $('.index-section:first-child .fix-me-with-margin').css('marginTop', -this.$siteHeader.outerHeight());
  1384. $('.index-section:first-child .fix-me-with-height').css('height', $(window).height() - this.$siteHeader.outerHeight());
  1385.  
  1386. }
  1387.  
  1388. } else {
  1389.  
  1390. if ( $('.mount-slideshow').children('div').length > 0 ) {
  1391.  
  1392. $('#shopify-section-home_slideshow').css('marginTop', '0');
  1393. $('.slideshow-item:first-child .site-box-content').css('marginTop', '0');
  1394.  
  1395. }
  1396.  
  1397. }
  1398.  
  1399. } else {
  1400.  
  1401. if ( $('#fix-me-header').css('display') == 'block' ) {
  1402.  
  1403. $('.fix-me-with-margin').each((function(key, elm){
  1404. if ( $(elm).outerHeight() < $(window).height() ) {
  1405. $(elm).css('marginTop', -this.$siteHeader.outerHeight())
  1406. } else {
  1407. $(elm).css('marginTop', '0')
  1408. }
  1409. }).bind(this));
  1410.  
  1411. $('.fix-me-with-height-hard').css({
  1412. 'height': $(window).height() - this.$siteHeader.outerHeight(),
  1413. 'min-height': $(window).height() - this.$siteHeader.outerHeight()
  1414. });
  1415. $('.fix-me-with-height').css({
  1416. 'min-height': $(window).height() - this.$siteHeader.outerHeight()
  1417. });
  1418.  
  1419. } else {
  1420.  
  1421. $('.fix-me-with-margin').css('marginTop', '0');
  1422. $('.fix-me-with-height, .fix-me-with-height-hard').attr('style', '');
  1423.  
  1424. }
  1425.  
  1426. }
  1427.  
  1428. if ( $('.mount-product').length > 0 ) {
  1429.  
  1430. $('.mount-product').each((function(key, elm){
  1431.  
  1432. if ( $('#fix-me-header').css('content') == '"fix-gallery-item"' ) {
  1433. $(elm).find('.gallery-item').css('height', ( $(window).height() - this.$siteHeader.outerHeight() ) * 0.8 );
  1434. } else {
  1435. //$('.gallery-item').css('height', $(window).height() - this.$siteHeader.outerHeight());
  1436. }
  1437.  
  1438. $(elm).find('.product--section').removeClass('sticky-because');
  1439. if ( $(elm).find('.site-box.box__product-gallery').css('content') != '"fix-me-also"' && $(elm).find('.site-box.box__product-gallery').height() < $(elm).find('.site-box.box__product-content').height() ) {
  1440. $(elm).find('.product--section').addClass('sticky-because');
  1441. }
  1442.  
  1443. }).bind(this));
  1444.  
  1445. /*if ( $('.site-box.box__product-gallery').css('content') == '"fix-me-also"' ) {
  1446. $('.site-box.box__product-gallery').css('height', $(window).height() - this.$siteHeader.outerHeight());
  1447. }*/
  1448.  
  1449. }
  1450.  
  1451. $('.site-header.desktop-view--classic .submenu').css('top', $('.site-header').outerHeight());
  1452.  
  1453. if ( $('#site-menu-handle').css('opacity') == '1' ) {
  1454. $('.site-nav.style--sidebar a, #site-menu-handle').attr('tabIndex', 0);
  1455. } else {
  1456. $('.site-nav.style--sidebar a, #site-menu-handle').attr('tabIndex', -1);
  1457. }
  1458.  
  1459. },
  1460.  
  1461. _animateEverything: function(firstAnimation) {
  1462.  
  1463. var i = 0;
  1464.  
  1465. this.$siteBoxes.each(function(){
  1466.  
  1467. var vp = 0;
  1468.  
  1469. /*if ( ! firstAnimation ) {
  1470.  
  1471. if ( ( $(this).height() - 100 ) > $(window).height() / 2 ) {
  1472. vp = 0;
  1473. } else {
  1474. vp = 0;
  1475. }
  1476. }*/
  1477.  
  1478. if ( ! $(this).hasClass('active') && $(window).scrollTop() + $(window).height() > $(this).offset().top + vp ) {
  1479.  
  1480. i++;
  1481.  
  1482. setTimeout((function(){
  1483. $(this).addClass('active');
  1484. }).bind(this), ( 100 * i ) );
  1485.  
  1486. }
  1487.  
  1488. });
  1489.  
  1490. if ( ! this.$siteFooter.hasClass('active') && $(window).scrollTop() + $(window).height() > this.$siteFooter.offset().top + 150 ) {
  1491.  
  1492. this.$siteFooter.addClass('active');
  1493. this.$siteFooter.find('.site-box').addClass('active');
  1494.  
  1495. }
  1496.  
  1497. },
  1498.  
  1499. mount: function() {
  1500.  
  1501. $('.rte').fitVids();
  1502.  
  1503. this.$siteBoxes = $('.site-box:not(.footer-box)');
  1504. this.$siteFooter = $('.site-footer');
  1505.  
  1506. if ( ! $('body').hasClass('ie9') ) {
  1507.  
  1508. this._animateEverything(true);
  1509. $(window).on('scroll.fade-animation', (function(e){
  1510. this._animateEverything(false);
  1511. }).bind(this));
  1512.  
  1513. }
  1514.  
  1515. $('html.no-touchevents a[href]').each(function(){
  1516.  
  1517. $(this).on('click', function(e){
  1518.  
  1519. if ( ( e.ctrlKey || e.metaKey ) || $(this).attr('target') == '_blank' || $(this).hasClass('video-lightbox') || $(this).hasClass('lightbox') || $(this).hasClass('block-fade') || $(this).attr('href') == '' || $(this).attr('href').indexOf('#') >= 0 ) {
  1520. //
  1521. } else {
  1522.  
  1523. $(this).off('click');
  1524.  
  1525. $('body').fadeOut(200);
  1526. setTimeout((function(){
  1527. document.location.href = $(this).attr('href');
  1528. }).bind(this), 200);
  1529. e.preventDefault();
  1530. }
  1531.  
  1532. });
  1533.  
  1534. });
  1535.  
  1536. //
  1537.  
  1538. this.$body = $('body');
  1539. this.$siteHeader = $('#site-header');
  1540.  
  1541. $(window).on('resize', window.debounce((function(){
  1542. this._resizeEverything();
  1543. }).bind(this), 300));
  1544. this._resizeEverything();
  1545.  
  1546. setTimeout((function(){
  1547. this._resizeEverything();
  1548. }).bind(this), 1000);
  1549.  
  1550. if ( $('.logo-img').length > 0 && ! $('.logo-img img')[0].naturalWidth > 0 ) {
  1551. $('.logo-img img').on('load', function(){
  1552. window.CUBER.Main._resizeEverything();
  1553. })
  1554. }
  1555.  
  1556. this.$searchForm = $('.search-bar:not(.no-ajax)');
  1557. this.$searchResults = $('#search-results');
  1558. this.$searchPreloader = $('#site-search .preloader');
  1559.  
  1560. this.$searchForm.find('input[type="search"]').on('keyup', window.debounce((function(){
  1561. this._ajaxSearchForm();
  1562. }).bind(this), 300));
  1563.  
  1564. this.$searchForm.submit((function(e){
  1565. e.preventDefault();
  1566. this._ajaxSearchForm();
  1567. }).bind(this));
  1568.  
  1569. // tabs & toggles
  1570.  
  1571. if ( $('.krown-tabs').data('design') == 'toggles' ) {
  1572.  
  1573. $('.krown-tabs').each(function(){
  1574.  
  1575. var $titles = $(this).children('.titles').children('h5'),
  1576. $contents = $(this).find('.contents').children('div'),
  1577. i = 0;
  1578.  
  1579. $titles.each(function(){
  1580.  
  1581. $contents.eq(i++).insertAfter($(this));
  1582.  
  1583. $(this).on('click', function(){
  1584.  
  1585. var $toggle = $(this).next('.tab');
  1586.  
  1587. if ( ! $(this).hasClass('opened') ) {
  1588. $(this).addClass('opened');
  1589. $toggle.stop().slideDown(200);
  1590. } else {
  1591. $(this).removeClass('opened');
  1592. $toggle.stop().slideUp(200);
  1593. }
  1594.  
  1595. });
  1596.  
  1597. });
  1598.  
  1599. $(this).find('.contents').remove();
  1600.  
  1601. });
  1602.  
  1603. } else {
  1604.  
  1605. $('.krown-tabs').each(function(){
  1606.  
  1607. var $titles = $(this).children('.titles').children('h5'),
  1608. $contents = $(this).children('.contents').children('div'),
  1609. $openedT = $titles.eq(0),
  1610. $openedC = $contents.eq(0);
  1611.  
  1612. $openedT.addClass('opened');
  1613. $openedC.stop().slideDown(0);
  1614.  
  1615. $titles.find('a').prop('href', '#').off('click');;
  1616.  
  1617. $titles.click(function(e){
  1618.  
  1619. $openedT.removeClass('opened');
  1620. $openedT = $(this);
  1621. $openedT.addClass('opened');
  1622.  
  1623. $openedC.stop().slideUp(200);
  1624. $openedC = $contents.eq($(this).index());
  1625. $openedC.stop().delay(200).slideDown(200);
  1626.  
  1627. e.preventDefault();
  1628.  
  1629. });
  1630.  
  1631. });
  1632.  
  1633. }
  1634.  
  1635. },
  1636.  
  1637. _ajaxSearchForm: function() {
  1638.  
  1639. this.$searchPreloader.css('opacity', 1);
  1640.  
  1641. $.ajax({
  1642.  
  1643. type: this.$searchForm.prop('method'),
  1644. url: this.$searchForm.prop('action'),
  1645. data: this.$searchForm.serialize(),
  1646. success: (function(data){
  1647.  
  1648. this.$searchResults.html($(data).find('.search-results.with-results'));
  1649. this.$searchPreloader.css('opacity', 0);
  1650.  
  1651. $('#site-search').off('scroll.search-pagination');
  1652.  
  1653. if ( $('.search-results').find('.next-page').length > 0 ) {
  1654. this.$searchPagination = $('.search-results').find('.next-page');
  1655. $('#site-search').on('scroll.search-pagination', this._ajaxSearchPagination.bind(this));
  1656. }
  1657.  
  1658. }).bind(this)
  1659.  
  1660. });
  1661.  
  1662. },
  1663.  
  1664. _ajaxSearchPagination: function() {
  1665.  
  1666. if ( $('#site-search').scrollTop() + $(window).height() >= this.$searchPagination.offset().top - 250 ) {
  1667.  
  1668. this.$searchPreloader.css({'opacity': 1, 'top': 'auto', 'bottom': '-60px'});
  1669. $('#site-search').off('scroll.search-pagination');
  1670.  
  1671. $.ajax({
  1672.  
  1673. url: this.$searchPagination.attr('href'),
  1674. success: (function(data){
  1675.  
  1676. this.$searchResults.find('.next-page').remove();
  1677. this.$searchResults.append($(data).find('.search-item'));
  1678.  
  1679. if ( $(data).find('.search-results .next-page').length > 0 ) {
  1680. this.$searchResults.append($(data).find('.search-results .next-page'));
  1681. this.$searchPagination = $('.search-results').find('.next-page');
  1682. $('#site-search').on('scroll.search-pagination', this._ajaxSearchPagination.bind(this));
  1683. }
  1684.  
  1685. this.$searchPreloader.css({'opacity': 0, 'top': '20px', 'bottom': 'auto'});
  1686.  
  1687. }).bind(this)
  1688.  
  1689. })
  1690.  
  1691. }
  1692.  
  1693. },
  1694.  
  1695. unmount: function() {
  1696. $(window).off('scroll.scroll-movers');
  1697. }
  1698.  
  1699. },
  1700.  
  1701. Contact: {
  1702.  
  1703. mount: function($elm) {
  1704.  
  1705. if ( $elm.find('.contact-map-holder').length > 0 ) {
  1706.  
  1707. if ( $elm.find('.contact-map-object').data('address') != '' ) {
  1708.  
  1709. if ( typeof google !== 'undefined' ) {
  1710. this._createMap($elm.attr('id'), $elm.find('.contact-map-object'), $elm.find('.contact-map-address-holder'));
  1711. } else {
  1712.  
  1713. if ( window.loadingGoogleMapsScript ) {
  1714. $elm.ti = setInterval((function($elm){
  1715. if ( typeof google !== 'undefined' ) {
  1716. clearInterval($elm.ti);
  1717. this._createMap($elm.attr('id'), $elm.find('.contact-map-object'), $elm.find('.contact-map-address-holder'));
  1718. }
  1719. }).bind(this, $elm), 100);
  1720.  
  1721. } else {
  1722.  
  1723. window.loadingGoogleMapsScript = true;
  1724. $.getScript('https://maps.googleapis.com/maps/api/js?v=3&key='+ $elm.find('.contact-map-holder').data('key')).done((function(){
  1725. this._createMap($elm.attr('id'), $elm.find('.contact-map-object'), $elm.find('.contact-map-address-holder'));
  1726. }).bind(this));
  1727.  
  1728. }
  1729. }
  1730.  
  1731. }
  1732.  
  1733. }
  1734.  
  1735. },
  1736.  
  1737. _createMap: function(id, $mapInsert, $mapAddress) {
  1738.  
  1739. $mapInsert.attr('id', 'contact-map-' + id);
  1740.  
  1741. var coordsKey = 'map-coords-' + $mapInsert.attr('id'),
  1742. coordsStorage = localStorage.getItem(coordsKey) != null ? JSON.parse(localStorage.getItem(coordsKey)) : null,
  1743. mapLat = 0,
  1744. mapLong = 0;
  1745.  
  1746. if ( coordsStorage != null && coordsStorage['address'] == $mapInsert.data('address') ) {
  1747. mapLat = coordsStorage['lat'];
  1748. mapLong = coordsStorage['long'];
  1749. }
  1750.  
  1751. var geocoder, map, address;
  1752.  
  1753. geocoder = new google.maps.Geocoder();
  1754. address = $mapInsert.data('address');
  1755.  
  1756. var mapOptions = {
  1757. zoom: $mapInsert.data('zoom'),
  1758. center: new google.maps.LatLng(mapLat, mapLong),
  1759. streetViewControl: false,
  1760. scrollwheel: true,
  1761. panControl: false,
  1762. mapTypeControl: false,
  1763. overviewMapControl: false,
  1764. zoomControl: false,
  1765. draggable: true,
  1766. styles: $mapInsert.data('style') == 'light' ? window.lightMapStyle : window.darkMapStyle
  1767. };
  1768.  
  1769. map = new google.maps.Map(document.getElementById($mapInsert.attr('id')), mapOptions);
  1770.  
  1771. if ( mapLat != 0 || mapLong != 0 ) {
  1772.  
  1773. var markerOptions = {
  1774. position: new google.maps.LatLng(mapLat, mapLong),
  1775. map: map,
  1776. title: address
  1777. }
  1778.  
  1779. if( $mapInsert.data('marker') != 'none' ) {
  1780. markerOptions['icon'] = {
  1781. url: $mapInsert.data('marker'),
  1782. scaledSize: new google.maps.Size(60, 60)
  1783. }
  1784. }
  1785.  
  1786. $mapAddress.find('a').attr('href', 'http://www.google.com/maps/place/' + mapLat + ',' + mapLong);
  1787. var contentString = $mapAddress.html();
  1788. var infowindow = new google.maps.InfoWindow({
  1789. content: contentString
  1790. });
  1791.  
  1792. var marker = new google.maps.Marker(markerOptions);
  1793. marker.addListener('click', function() {
  1794. infowindow.open(map, marker);
  1795. if ( $(window).width() < 480 ) {
  1796. $('.template-page-contact .box__heading .title').css('marginTop', 50);
  1797. } else if ( $(window).width() < 768 ) {
  1798. $('.template-page-contact .box__heading .title').css('marginTop', 100);
  1799. }
  1800. });
  1801.  
  1802. if ( $(window).width() > 768 ) {
  1803. map.panBy(-150, 150);
  1804. } else {
  1805. map.panBy(-75, 75);
  1806. }
  1807.  
  1808. } else {
  1809.  
  1810. if ( geocoder ) {
  1811.  
  1812. geocoder.geocode( { 'address': address }, function(results, status){
  1813.  
  1814. if (status == google.maps.GeocoderStatus.OK) {
  1815. if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
  1816.  
  1817. map.setCenter(results[0].geometry.location);
  1818.  
  1819. var markerOptions = {
  1820. position: results[0].geometry.location,
  1821. map: map,
  1822. title: address
  1823. }
  1824.  
  1825. if( $mapInsert.data('marker') != 'none' ) {
  1826. markerOptions['icon'] = {
  1827. url: $mapInsert.data('marker'),
  1828. scaledSize: new google.maps.Size(60, 60)
  1829. }
  1830. }
  1831.  
  1832. $mapAddress.find('a').attr('href', 'http://www.google.com/maps/place/' + results[0].geometry.location.lat() + ',' + results[0].geometry.location.lng());
  1833. var contentString = $mapAddress.html();
  1834. var infowindow = new google.maps.InfoWindow({
  1835. content: contentString
  1836. });
  1837.  
  1838. var marker = new google.maps.Marker(markerOptions);
  1839. marker.addListener('click', function() {
  1840. infowindow.open(map, marker);
  1841. });
  1842.  
  1843. if ( $(window).width() > 768 ) {
  1844. map.panBy(-150, 150);
  1845. } else {
  1846. map.panBy(-75, 75);
  1847. }
  1848.  
  1849. localStorage.setItem(coordsKey, JSON.stringify({
  1850. 'address': $mapInsert.data('address'),
  1851. 'lat': results[0].geometry.location.lat(),
  1852. 'long': results[0].geometry.location.lng()
  1853. }));
  1854.  
  1855. } else {
  1856. alert("No results found for the given address");
  1857. }
  1858. } else {
  1859. console.log("Geocode was not successful for the following reason: " + status);
  1860. }
  1861.  
  1862. });
  1863.  
  1864. }
  1865.  
  1866. }
  1867.  
  1868. },
  1869.  
  1870. unmount: function() {
  1871.  
  1872. }
  1873.  
  1874. },
  1875.  
  1876. // SCROLL
  1877.  
  1878. Scroll: {
  1879.  
  1880. $body: null,
  1881. $footer: null,
  1882.  
  1883. mount: function() {
  1884.  
  1885. if ( ! $('html').hasClass('csspositionsticky') ) {
  1886.  
  1887. this.$body = $('body');
  1888. this.$footer = $('#shopify-section-footer');
  1889.  
  1890. // grid
  1891.  
  1892. var scrollFixArray = [];
  1893.  
  1894. if ( $(window).width() > 768 ) {
  1895.  
  1896. $('.site-box-container.container--fullscreen.box--can-stick').each(function(){
  1897.  
  1898. var $boxChildren = $(this).children('.site-box');
  1899.  
  1900. if ( $boxChildren.length == 2 ) {
  1901.  
  1902. if ( $(this).children('.site-box[data-order="0"]').outerHeight(true) != $(this).children('.site-box[data-order="1"]').outerHeight(true) ) {
  1903.  
  1904. var $bigChild = null,
  1905. $smallChild = null;
  1906.  
  1907. if ( $(this).children('.site-box[data-order="0"]').outerHeight(true) > $(this).children('.site-box[data-order="1"]').outerHeight(true) ) {
  1908. $bigChild = $(this).children('.site-box[data-order="0"]');
  1909. $smallChild = $(this).children('.site-box[data-order="1"]');
  1910. } else if ( $(this).children('.site-box[data-order="1"]').outerHeight(true) > $(this).children('.site-box[data-order="0"]').outerHeight(true) ) {
  1911. $bigChild = $(this).children('.site-box[data-order="1"]');
  1912. $smallChild = $(this).children('.site-box[data-order="0"]');
  1913. }
  1914.  
  1915. scrollFixArray.push({
  1916. 'parent': $(this),
  1917. 'big-child': $bigChild,
  1918. 'small-child': $smallChild
  1919. });
  1920.  
  1921. }
  1922.  
  1923. } else if ( $boxChildren.length == 1 ) {
  1924.  
  1925. if ( $(this).children('.site-box[data-order="0"]').outerHeight(true) > $(window).height() ) {
  1926.  
  1927. scrollFixArray.push({
  1928. 'parent': $(this),
  1929. 'big-child': $(this).children('.site-box[data-order="0"]'),
  1930. 'small-child': null
  1931. });
  1932.  
  1933. }
  1934.  
  1935. }
  1936.  
  1937. });
  1938.  
  1939. }
  1940.  
  1941. scrollFixArray.forEach(function(obj){
  1942.  
  1943. obj['parent'].removeClass('fixing-scroll-now');
  1944. obj['big-child'].css({'position': 'relative', 'top': '0', 'bottom': 'auto', 'marginLeft': '0'});
  1945.  
  1946. if ( obj['small-child'] != null ) {
  1947. obj['small-child'].css({'position': 'relative', 'top': '0', 'bottom': 'auto', 'marginLeft': '0'});
  1948. obj['small-child'].removeClass('ok-scroll');
  1949. }
  1950.  
  1951.  
  1952. });
  1953.  
  1954. $(window).off('scroll.scroll-fix');
  1955.  
  1956. scrollFixArray.forEach(function(obj) {
  1957.  
  1958. if ( $(window).scrollTop() + $(window).height() >= obj['parent'].offset().top + obj['parent'].outerHeight() ) {
  1959.  
  1960. if ( obj['small-child'] != null ) {
  1961. obj['small-child'].css({'position': 'absolute', 'bottom': 0, 'top': 'auto' });
  1962. if ( obj['small-child'].attr('data-order') == '1' ) {
  1963. obj['small-child'].css('marginLeft', '50%');
  1964. }
  1965. }
  1966.  
  1967. if ( obj['big-child'].attr('data-order') == '1' ) {
  1968. obj['big-child'].css('marginLeft', '50%');
  1969. }
  1970.  
  1971. }
  1972.  
  1973. })
  1974.  
  1975. $(window).on('scroll.scroll-fix', (function(){
  1976.  
  1977. if ( $(window).scrollTop() >= 0 ) {
  1978.  
  1979. scrollFixArray.forEach(function(obj){
  1980.  
  1981. if ( $(window).scrollTop() >= obj['parent'].offset().top && $(window).scrollTop() + $(window).height() < obj['parent'].offset().top + obj['parent'].outerHeight() && ! obj['parent'].hasClass('fixing-scroll-now') ) {
  1982.  
  1983. obj['parent'].addClass('fixing-scroll-now');
  1984.  
  1985. if ( obj['small-child'] != null ) {
  1986.  
  1987. obj['small-child'].css({'position': 'fixed', 'top': 0, 'bottom': 'auto'});
  1988.  
  1989. if ( obj['small-child'].attr('data-order') == '1' ) {
  1990. obj['small-child'].css('marginLeft', '50%');
  1991. }
  1992.  
  1993. if ( obj['small-child'].height() > $(window).height() ) {
  1994. obj['small-child'].addClass('ok-scroll');
  1995. }
  1996.  
  1997. }
  1998.  
  1999. if ( obj['big-child'].attr('data-order') == '1' ) {
  2000. obj['big-child'].css('marginLeft', '50%');
  2001. }
  2002.  
  2003. }
  2004.  
  2005. if ( $(window).scrollTop() + $(window).height() >= obj['parent'].offset().top + obj['parent'].outerHeight() && obj['parent'].hasClass('fixing-scroll-now') ) {
  2006.  
  2007. obj['parent'].removeClass('fixing-scroll-now');
  2008.  
  2009. if ( obj['small-child'] != null ) {
  2010. obj['small-child'].removeClass('ok-scroll');
  2011. obj['small-child'].css({'position': 'absolute', 'bottom': 0, 'top': 'auto' });
  2012. }
  2013.  
  2014. }
  2015.  
  2016. if ( $(window).scrollTop() < obj['parent'].offset().top && obj['parent'].hasClass('fixing-scroll-now') ) {
  2017.  
  2018. obj['parent'].removeClass('fixing-scroll-now');
  2019. obj['big-child'].css('marginLeft', '0');
  2020.  
  2021. if ( obj['small-child'] != null ) {
  2022. obj['small-child'].css({'position': 'relative', 'top': '0', 'bottom': 'auto', 'marginLeft': '0'});
  2023. }
  2024.  
  2025.  
  2026. }
  2027. if ( obj['small-child'] != null && obj['small-child'].height() > $(window).height() && obj['small-child'].hasClass('ok-scroll') ) {
  2028.  
  2029. var x = obj['big-child'].height() - $(window).height(),
  2030. y = $(window).height() - obj['small-child'].height(),
  2031. z = $(window).scrollTop();
  2032.  
  2033. //obj['small-child'].css('top', Math.ceil(z * y / x));
  2034.  
  2035. }
  2036.  
  2037.  
  2038. });
  2039.  
  2040. }
  2041.  
  2042. }).bind(this)).trigger('scroll.scroll-fix');
  2043.  
  2044. $(window).off('resize.scroll-fix');
  2045. $(window).on('resize.scroll-fix', window.debounce((function(){
  2046. window.CUBER.Scroll.mount();
  2047. }).bind(this), 250));
  2048.  
  2049. }
  2050.  
  2051. },
  2052.  
  2053. unmount: function() {
  2054.  
  2055. $(window).off('resize.scroll-fix');
  2056. $(window).off('scroll.scroll-fix');
  2057.  
  2058. }
  2059.  
  2060. },
  2061.  
  2062. // IMAGES
  2063.  
  2064. Images: {
  2065.  
  2066. boxImages: [],
  2067.  
  2068. mount: function() {
  2069.  
  2070. this.boxImages = [];
  2071.  
  2072. if ( $('.box--product-image').length > 0 ) {
  2073. $('.box--product-image:not(.on)').each((function(key, elm){
  2074.  
  2075. $(elm).addClass('on');
  2076. this.boxImages.push({
  2077. '$elm': $(elm),
  2078. 'img': $(elm).children('img')[0],
  2079. 'srcset': $(elm).children('img').data('srcset')
  2080. });
  2081.  
  2082. }).bind(this));
  2083. }
  2084.  
  2085. $(window).on('resize.box-images', (function(){
  2086.  
  2087. this.boxImages.forEach(function(entry){
  2088.  
  2089. var desiredDensity = window.devicePixelRatio <= 2 ? window.devicePixelRatio : 2,
  2090. desiredSize = entry['$elm'].width() * desiredDensity;
  2091.  
  2092. if ( entry['img'].naturalWidth > 0 ) {
  2093.  
  2094. if ( entry['$elm'].width() / entry['$elm'].height() < entry['img'].naturalWidth / entry['img'].naturalHeight ) {
  2095. var desiredHeight = Math.ceil(( entry['$elm'].height() * desiredDensity ));
  2096. desiredSize = desiredHeight * entry['img'].naturalWidth / entry['img'].naturalHeight;
  2097. }
  2098.  
  2099. }
  2100.  
  2101. if ( desiredSize <= 480 ) {
  2102. entry['$elm'].css('backgroundImage', 'url(' + entry['srcset'].small + ')');
  2103. } else if ( desiredSize <= 960 ) {
  2104. entry['$elm'].css('backgroundImage', 'url(' + entry['srcset'].medium + ')');
  2105. } else if ( desiredSize <= 1440 ) {
  2106. entry['$elm'].css('backgroundImage', 'url(' + entry['srcset'].large + ')');
  2107. } else if ( desiredSize > 1440 ) {
  2108. entry['$elm'].css('backgroundImage', 'url(' + entry['srcset'].huge + ')');
  2109. }
  2110.  
  2111. });
  2112.  
  2113. }).bind(this)).trigger('resize.box-images');
  2114.  
  2115. },
  2116.  
  2117. unmount: function() {
  2118. $(window).off('resize.box-images');
  2119. }
  2120.  
  2121. },
  2122.  
  2123. Video: {
  2124.  
  2125. mount: function() {
  2126.  
  2127. if ( $('.video-lightbox').length > 0 ) {
  2128. $('.video-lightbox').magnificPopup({
  2129. type: 'iframe'
  2130. });
  2131. }
  2132.  
  2133. },
  2134.  
  2135. unmount: function() {
  2136. }
  2137.  
  2138. },
  2139.  
  2140. Popup: {
  2141.  
  2142. $popup: null,
  2143.  
  2144. mount: function() {
  2145.  
  2146. this.$popup = $('#shopify-section-popup');
  2147.  
  2148. var show = this.$popup.find('.popup-content').data('show'),
  2149. freq = this.$popup.find('.popup-content').data('freq'),
  2150. enable = this.$popup.find('.popup-content').data('enable');
  2151.  
  2152. if ( show > 0 && enable ) {
  2153. setTimeout((function(){
  2154. this._trigger(show, freq);
  2155. }).bind(this), parseInt(show*1000));
  2156. }
  2157.  
  2158. this.$popup.find('.site-close-handle').on('click', (function(e){
  2159. this._hide();
  2160. }).bind(this));
  2161.  
  2162. this.$popup.find('.popup-background').on('click', (function(e){
  2163. this._hide();
  2164. }).bind(this));
  2165.  
  2166. },
  2167.  
  2168. _show: function() {
  2169. this.$popup.addClass('active');
  2170. },
  2171.  
  2172. _hide: function() {
  2173. this.$popup.removeClass('active');
  2174. },
  2175.  
  2176. _trigger: function(show, freq) {
  2177.  
  2178. var popupKey = 'popup-' + document.location.hostname,
  2179. popupStorage = localStorage.getItem(popupKey) != null ? JSON.parse(localStorage.getItem(popupKey)) : null;
  2180.  
  2181. if ( popupStorage != null ) {
  2182.  
  2183. if ( popupStorage['show'] != show || popupStorage['freq'] != freq ) {
  2184.  
  2185. this._refreshStorage(popupKey, show, freq);;
  2186.  
  2187. // user saw the ad but settings are different - show it!
  2188. this._show();
  2189.  
  2190. } else {
  2191.  
  2192. // user saw the ad so we need to check if he should see it again
  2193.  
  2194. if ( freq == 'every' ) {
  2195.  
  2196. if ( sessionStorage[popupKey] == null || sessionStorage[popupKey] != 'shown' ) {
  2197. this._show();
  2198. this._refreshStorage(popupKey, show, freq);;
  2199. }
  2200.  
  2201. } else {
  2202.  
  2203. var shownAt = popupStorage['shown'],
  2204. nowAt = new Date().getTime(),
  2205. inBetween = Math.round((nowAt - shownAt) / 1000);
  2206.  
  2207. if ( freq == 'day' && inBetween > 129600 ) {
  2208. this._show();
  2209. this._refreshStorage(popupKey, show, freq);;
  2210. } else if ( freq == 'week' && inBetween > 907200 ) {
  2211. this._show();
  2212. this._refreshStorage(popupKey, show, freq);;
  2213. }
  2214.  
  2215. }
  2216.  
  2217. }
  2218.  
  2219. } else {
  2220.  
  2221. this._refreshStorage(popupKey, show, freq);
  2222.  
  2223. // user never saw the ad - show it!
  2224.  
  2225. this._show();
  2226.  
  2227. }
  2228.  
  2229. },
  2230.  
  2231. _refreshStorage: function(popupKey, show, freq) {
  2232.  
  2233. localStorage.setItem(popupKey, JSON.stringify({
  2234. 'show': show,
  2235. 'freq': freq,
  2236. 'shown': new Date().getTime()
  2237. }));
  2238.  
  2239. sessionStorage[popupKey] = 'shown';
  2240.  
  2241. },
  2242.  
  2243. unmount: function() {
  2244. }
  2245.  
  2246. },
  2247.  
  2248. // SOCIAL
  2249.  
  2250. Social: {
  2251.  
  2252. $container: null,
  2253. nameTwitter: '',
  2254. nameInstagram: '',
  2255.  
  2256. mount: function( $elm ) {
  2257.  
  2258. this.$container = $elm.children('.site-box-container');
  2259. this.nameTwitter = this.$container.data('twitter');
  2260. this.nameInstagram = this.$container.data('instagram');
  2261.  
  2262. var no = this.$container.data('posts'),
  2263. noT = 0,
  2264. noI = 0,
  2265. socialArr = [];
  2266.  
  2267. if ( this.nameTwitter != '' && this.nameInstagram != '' ) {
  2268. noT = Math.ceil(no/2);
  2269. noI = Math.floor(no/2);
  2270. } else if ( this.nameTwitter != '' ) {
  2271. noT = no;
  2272. } else if ( this.nameInstagram != '' ) {
  2273. noI = no;
  2274. }
  2275.  
  2276. if ( noI > 0 ) {
  2277.  
  2278. var feed = new Instafeed({
  2279.  
  2280. get: 'user',
  2281. userId: this.nameInstagram.split('.')[0],
  2282. accessToken: this.nameInstagram,
  2283. limit: noI,
  2284. resolution: 'standard_resolution',
  2285. mock: true,
  2286. sortBy: 'random',
  2287. success: (function(obj) {
  2288.  
  2289. obj.data.forEach(function(entry){
  2290.  
  2291. socialArr.push({
  2292. 'type': 'instagram',
  2293. 'thumb': entry.images.standard_resolution.url,
  2294. 'link': entry.link,
  2295. 'caption': typeof entry.caption === 'object' && entry.caption !== null ? entry.caption.text : '',
  2296. 'likes': entry.likes.count,
  2297. 'time': new Date(entry.created_time*1000).toLocaleDateString('en-US'),
  2298. 'timestamp': parseInt(entry.created_time)
  2299. });
  2300. });
  2301.  
  2302. this._pushFeed('instagram', socialArr);
  2303.  
  2304. }).bind(this)
  2305.  
  2306. });
  2307.  
  2308. feed.run();
  2309.  
  2310. } else {
  2311. this._pushFeed('instagram', socialArr);
  2312. }
  2313.  
  2314. if ( noT > 0 ) {
  2315.  
  2316. twitterFetcher.fetch({
  2317.  
  2318. 'profile': {'screenName': this.nameTwitter},
  2319. 'dataOnly': true,
  2320. 'maxTweets': noT,
  2321. 'dateFunction': function(date){
  2322. return parse(date);
  2323. },
  2324. 'customCallback': (function(obj){
  2325.  
  2326. obj.forEach(function(entry){
  2327. socialArr.push({
  2328. 'type': 'twitter',
  2329. 'text': entry.tweet,
  2330. 'timestamp': Date.parse(entry.timestamp)/1000
  2331. })
  2332. });
  2333.  
  2334. this._pushFeed('twitter', socialArr);
  2335.  
  2336. }).bind(this)
  2337.  
  2338. });
  2339.  
  2340. } else {
  2341. this._pushFeed('twitter', socialArr);
  2342. }
  2343.  
  2344. },
  2345.  
  2346. _pushFeed: function(type, feed) {
  2347.  
  2348. if ( type == 'twitter' ) {
  2349. this.checkTwitter = true;
  2350. } else if ( type == 'instagram' ) {
  2351. this.checkInstagram = true;
  2352. }
  2353.  
  2354. if ( this.checkTwitter && this.checkInstagram ) {
  2355.  
  2356. feed.sort(function(a, b){
  2357. return a.timestamp - b.timestamp;
  2358. }).reverse();
  2359.  
  2360. feed.forEach((function(entry, key){
  2361.  
  2362. var feedContent = '';
  2363.  
  2364. if ( entry.type == 'twitter' ) {
  2365.  
  2366. feedContent += '<div class="site-box-content">';
  2367. feedContent += '<span class="icon" aria-hidden="true">' + $.themeAssets.iconTwitter + '</span>';
  2368. feedContent += '<p>' + entry.text + '</p>';
  2369. feedContent += '<a href="https://twitter.com/' + this.nameTwitter + '" target="_blank">@' + this.nameTwitter + '</a>';
  2370. feedContent += '</div>';
  2371.  
  2372. } else if ( entry.type == 'instagram' ) {
  2373.  
  2374. feedContent += '<div class="site-box-content" style="background-image:url(' + entry.thumb + ')">';
  2375. feedContent += '<a href="' + entry.link + '" target="_blank">';
  2376. feedContent += '<span class="icon child" aria-hidden="true">' + $.themeAssets.iconInstagram + '</span>';
  2377. feedContent += '<p class="caption child">' + entry.caption + '</p>';
  2378. feedContent += '<div class="meta child">';
  2379. feedContent += '<span class="likes">' + $.themeAssets.iconHeart + entry.likes + '</span>';
  2380. feedContent += '<span class="time">' + entry.time + '</span>';
  2381. feedContent += '</div>';
  2382. feedContent += '</a>';
  2383. feedContent += '</div>';
  2384.  
  2385. }
  2386.  
  2387. this.$container.find('.site-box[data-order="' + (key+1) + '"]')
  2388. .removeClass('box__twitter').removeClass('box__instagram')
  2389. .addClass('box__' + entry.type)
  2390. .html(feedContent);
  2391.  
  2392. }).bind(this));
  2393.  
  2394. }
  2395.  
  2396. },
  2397.  
  2398. unmount: function() {
  2399. //
  2400. }
  2401.  
  2402. },
  2403.  
  2404. SplitSlider: {
  2405.  
  2406. _mountFlickity: function() {
  2407.  
  2408. $('.responsive-flickity').flickity({
  2409. cellSelector: '.slideshow-item',
  2410. wrapAround: true,
  2411. prevNextButtons: false,
  2412. pageDots: false,
  2413. watchCSS: true,
  2414. resize: true
  2415. });
  2416.  
  2417. var $slider = $('.box__slideshow-split'),
  2418. flkty = $('.responsive-flickity').data('flickity'),
  2419. currentI = 0,
  2420. totalI = 100 / ( $slider.find('.slideshow-item').length - 1 ),
  2421. $currentSlide = null,
  2422. $currentSlideBlack = null;
  2423.  
  2424. if ( $slider.find('.slider-meta').length <= 0 ) {
  2425.  
  2426. $slider.find('.slider-meta').remove();
  2427.  
  2428. $slider.append('<div class="slider-meta hide lap--show"><div class="slider-index"><span class="current">1</span> / <span class="total">' + sliderT + '</span></div><div class="slider-nav"><span class="go-prev">' + $.themeAssets.arrowRight + '</span><span class="go-next">' + $.themeAssets.arrowRight + '</span></div>' );
  2429.  
  2430. $slider.find('.go-prev').on('click', (function(){
  2431. flkty.previous();
  2432. }).bind(this));
  2433.  
  2434. $slider.find('.go-next').on('click', (function(){
  2435. flkty.next();
  2436. }).bind(this));
  2437.  
  2438. $('.responsive-flickity').on('select.flickity', function(){
  2439. $slider.find('.slider-index .current').html(flkty.selectedIndex + 1);
  2440. });
  2441.  
  2442. setTimeout(function(){
  2443. $slider.find('.slider-meta').addClass('active');
  2444. }, 1000);
  2445.  
  2446. }
  2447.  
  2448. },
  2449.  
  2450. mount: function( flick ) {
  2451.  
  2452. var $slider = $('.box__slideshow-split'),
  2453. $slides = $slider.find('.slideshow-item'),
  2454. $slidesMedia = $slider.find('.site-box-background-container').children('div'),
  2455. slidesBlackArray = [];
  2456.  
  2457. currentScroll = $(window).scrollTop(),
  2458.  
  2459. sliderI = Math.min( Math.ceil(currentScroll / $(window).height()), $slides.length-1 );
  2460. sliderJ = sliderI-1,
  2461. sliderT = $slides.length;
  2462. // mobile slider
  2463.  
  2464. if ( flick ) {
  2465. this._mountFlickity();
  2466. }
  2467.  
  2468. if ( $('.responsive-flickity').hasClass('flickity-enabled') ) {
  2469. $slider.height($(window).height() - $('#site-header').outerHeight());
  2470. $slider.addClass('remove-min-height');
  2471. } else {
  2472. $slider.css('height', 'auto');
  2473. $slider.removeClass('remove-min-height');
  2474. }
  2475.  
  2476. // split
  2477.  
  2478. $slidesMedia.each(function(key){
  2479.  
  2480. if ( key > 0 ) {
  2481. if ( key < sliderI ) {
  2482. $(this).css('clip', 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px ' + $(window).height() + 'px 0)');
  2483. } else if ( key == sliderI ) {
  2484. $(this).css('clip', 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px ' + ( Math.ceil($(window).scrollTop() - $(window).height() * sliderJ ) ) + 'px 0)');
  2485. } else {
  2486. $(this).css('clip', 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px 0 0)');
  2487. }
  2488.  
  2489. } else if ( key == 0 & flick ) {
  2490. $(this).css({
  2491. 'clip': 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px 0 0)',
  2492. 'opacity': 0
  2493. });
  2494.  
  2495. $(this).addClass('clip-transition');
  2496. setTimeout((function(){
  2497. $(this).css({
  2498. 'clip': 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px ' + $(window).height() + 'px 0)',
  2499. 'opacity': 1
  2500. });
  2501. }).bind(this), 10);
  2502.  
  2503. setTimeout((function(){
  2504. $(this).removeClass('clip-transition');
  2505. }).bind(this), 650);
  2506.  
  2507. }
  2508.  
  2509. $(this).addClass('active');
  2510.  
  2511. if ( $(this).find('.site-box-black-overlay').length <= 0 ) {
  2512. $(this).append('<span class="site-box-black-overlay" />');
  2513. }
  2514. slidesBlackArray.push($(this).find('.site-box-black-overlay'));
  2515.  
  2516. });
  2517.  
  2518. $(window).on('scroll.split-slider', function(e){
  2519.  
  2520. if ( currentScroll < $(window).scrollTop() ) {
  2521.  
  2522. // next
  2523. if ( $slides.eq(sliderI+1).length > 0 && $(window).scrollTop() + $(window).height() >= $slides.eq(sliderI+1).offset().top) {
  2524.  
  2525. if ( sliderI != 0 ) {
  2526. // finish scroll
  2527. $slidesMedia.eq(sliderI).css('clip', 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px ' + $(window).height() + 'px 0)');
  2528. if ( slidesBlackArray[sliderJ] ) {
  2529. slidesBlackArray[sliderJ].css('opacity', 0.5 );
  2530. }
  2531. }
  2532.  
  2533. sliderJ = sliderI;
  2534. sliderI++;
  2535. down = true;
  2536.  
  2537. } else if ( $(window).scrollTop() + $(window).height() >= $slider.height() && ! $slider.hasClass('back-to-normal') ) {
  2538. $slider.addClass('back-to-normal');
  2539. $slidesMedia.eq(sliderI).css('clip', 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px ' + $(window).height() + 'px 0)');
  2540. }
  2541.  
  2542. } else {
  2543.  
  2544. // prev
  2545. if ( $slides.eq(sliderI).length > 0 && $slides.eq(sliderI-1).length > 0 && $(window).scrollTop() + $(window).height() < $slides.eq(sliderI).offset().top ) {
  2546.  
  2547. // finish scroll
  2548.  
  2549. var stupid = $slidesMedia.eq(sliderI).hasClass('obs') ? 1 : 0;
  2550.  
  2551. $slidesMedia.eq(sliderI).css('clip', 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px ' + stupid + 'px 0)');
  2552. if ( slidesBlackArray[sliderJ] ) {
  2553. slidesBlackArray[sliderJ].css('opacity', 0 );
  2554. }
  2555.  
  2556. sliderI--;
  2557. sliderJ = sliderI-1;
  2558. down = false;
  2559.  
  2560. } else if ( $(window).scrollTop() + $(window).height() <= $slider.height() && $slider.hasClass('back-to-normal') ) {
  2561. $slider.removeClass('back-to-normal');
  2562. }
  2563.  
  2564. }
  2565.  
  2566. if ( ! $slider.hasClass('back-to-normal') ) {
  2567.  
  2568. var scrollValue = Math.ceil($(window).scrollTop() - $(window).height() * sliderJ );
  2569.  
  2570. var stupid = $slidesMedia.eq(sliderI).hasClass('obs') ? 1 : 0;
  2571.  
  2572. $slidesMedia.eq(sliderI).css('clip', 'rect(0 ' + Math.ceil($(window).width() / 2) + 'px ' + Math.max(stupid, scrollValue) + 'px 0)');
  2573.  
  2574. if ( slidesBlackArray[sliderJ] ) {
  2575. slidesBlackArray[sliderJ].css('opacity', ( Math.ceil(scrollValue * 50 / $(window).height()) ) / 100 );
  2576. }
  2577.  
  2578. var scrollFactor = Math.round($(window).height() / 6);
  2579.  
  2580. $slides.eq(sliderJ).find('.caption').css('transform', 'translateY(' + ( 0 - Math.ceil(scrollValue * ( scrollFactor*1 ) / $(window).height() ) ) + 'px)');
  2581. $slides.eq(sliderJ).find('.title').css('transform', 'translateY(' + ( 0 - Math.ceil(scrollValue * ( scrollFactor*0.75 ) / $(window).height() ) ) + 'px)');
  2582. $slides.eq(sliderJ).find('.subtitle').css('transform', 'translateY(' + ( 0 - Math.ceil(scrollValue * ( scrollFactor*0.5 ) / $(window).height() ) ) + 'px)');
  2583. $slides.eq(sliderJ).find('.button').css('transform', 'translateY(' + ( 0 - Math.ceil(scrollValue * ( scrollFactor*0.25 ) / $(window).height() ) ) + 'px)');
  2584.  
  2585. $slides.eq(sliderI).find('.caption').css('transform', 'translateY(' + ( Math.ceil(scrollValue * ( scrollFactor * 1) / $(window).height()) - ( scrollFactor * 1) ) + 'px)');
  2586. $slides.eq(sliderI).find('.title').css('transform', 'translateY(' + ( Math.ceil(scrollValue * ( scrollFactor * 0.75) / $(window).height()) - ( scrollFactor * 0.75) ) + 'px)');
  2587. $slides.eq(sliderI).find('.subtitle').css('transform', 'translateY(' + ( Math.ceil(scrollValue * ( scrollFactor * 0.5) / $(window).height()) - ( scrollFactor * 0.5) ) + 'px)');
  2588. $slides.eq(sliderI).find('.button').css('transform', 'translateY(' + ( Math.ceil(scrollValue * ( scrollFactor * 0.25) / $(window).height()) - ( scrollFactor * 0.25) ) + 'px)');
  2589.  
  2590. }
  2591.  
  2592. currentScroll = $(window).scrollTop();
  2593.  
  2594. }).trigger('scroll.split-slider');
  2595.  
  2596. $(window).on('resize.split-slider', window.debounce((function(){
  2597.  
  2598. this.unmount();
  2599. this.mount(false);
  2600.  
  2601. }).bind(this), 250));
  2602.  
  2603. },
  2604.  
  2605. unmount: function() {
  2606. $(window).off('scroll.split-slider');
  2607. }
  2608.  
  2609. }
  2610.  
  2611. }
  2612.  
  2613. $(document).on('ready', function(){
  2614.  
  2615. window.CUBER.Nav.mount();
  2616. window.CUBER.Main.mount();
  2617. window.CUBER.Scroll.mount();
  2618.  
  2619. if ( $('.mount-social').length > 0 ) {
  2620. $('.mount-social').each(function(){
  2621. window.CUBER.Social.mount($(this));
  2622. })
  2623. }
  2624.  
  2625. if ( $('.box__slideshow-split').length > 0 ) {
  2626. window.CUBER.SplitSlider.mount(true);
  2627. }
  2628.  
  2629. if ( $('.mount-product').length > 0 ) {
  2630. $('.mount-product').each(function(){
  2631. window.CUBER.Product.mount($(this));
  2632. });
  2633. }
  2634. if ( $('body').hasClass('template-collection') ) {
  2635. window.CUBER.Collection.mount();
  2636. }
  2637. if ( $('body').hasClass('template-page-contact') || ( $('body').hasClass('template-index') ) && $('.mount-map').length > 0 ) {
  2638. $('.mount-map').each(function(){
  2639. window.CUBER.Contact.mount($(this));
  2640. });
  2641. }
  2642.  
  2643. //window.CUBER.Images.mount();
  2644. window.CUBER.Video.mount();
  2645.  
  2646. window.CUBER.Popup.mount();
  2647.  
  2648. // Section events
  2649.  
  2650. // select
  2651.  
  2652. $(document).on('shopify:section:select', function(e){
  2653.  
  2654. var $section = $(e.target);
  2655.  
  2656. if ( $section.hasClass('mount-header') ) {
  2657.  
  2658. if ( $section.find('#site-header').hasClass('style--sidebar' ) || $section.find('#site-header').hasClass('style--fullscreen' ) ) {
  2659. if ( ! $section.find('#site-nav').hasClass('active') ) {
  2660. $('#site-menu-handle a').trigger('click');
  2661. }
  2662. }
  2663.  
  2664. }
  2665.  
  2666. if ( $('#site-header').hasClass('desktop-view--minimal') && $('#fix-me-header').css('display') == 'none' ) {
  2667. setTimeout(function(){
  2668. $('html, body').stop().animate({'scrollTop': $section.offset().top}, 0);
  2669. }, 400);
  2670. }
  2671.  
  2672. if ( $section.hasClass('mount-popup') ) {
  2673. window.CUBER.Popup._show();
  2674. }
  2675.  
  2676. });
  2677.  
  2678. // deselect
  2679.  
  2680. $(document).on('shopify:section:deselect', function(e){
  2681.  
  2682. var $section = $(e.target);
  2683.  
  2684. if ( $section.hasClass('mount-header') ) {
  2685.  
  2686. if ( $section.find('#site-header').hasClass('style--sidebar' ) || $section.find('#site-header').hasClass('style--fullscreen' ) ) {
  2687. if ( $section.find('#site-nav').hasClass('active') ) {
  2688. $('#site-menu-handle a').trigger('click');
  2689. }
  2690. }
  2691.  
  2692. }
  2693.  
  2694. if ( $section.hasClass('mount-popup') ) {
  2695. window.CUBER.Popup._hide();
  2696. }
  2697.  
  2698.  
  2699. });
  2700.  
  2701. // load
  2702.  
  2703. $(document).on('shopify:section:load', function(e){
  2704.  
  2705. var $section = $(e.target);
  2706.  
  2707. if ( $section.hasClass('mount-header') ) {
  2708. window.CUBER.Nav.mount();
  2709. }
  2710. if ( $section.hasClass('mount-images') ) {
  2711. //window.CUBER.Images.mount();
  2712. }
  2713. if ( $section.hasClass('mount-video') ) {
  2714. window.CUBER.Video.mount();
  2715. }
  2716. if ( $section.hasClass('mount-social') ) {
  2717. window.CUBER.Social.mount($section);
  2718. }
  2719. if ( $section.hasClass('mount-slideshow') && $section.find('.box__slideshow-split').length > 0 ) {
  2720. window.CUBER.SplitSlider.mount(true);
  2721. $(window).scrollTop(0);
  2722. }
  2723. if ( $section.hasClass('mount-product') ) {
  2724. window.CUBER.Product.mount($section);
  2725. }
  2726. if ( $section.hasClass('mount-map') ) {
  2727. window.CUBER.Contact.mount($section);
  2728. }
  2729.  
  2730. if ( $section.hasClass('mount-popup') ) {
  2731. window.CUBER.Popup.mount();
  2732. }
  2733.  
  2734. window.CUBER.Main.mount();
  2735. window.CUBER.Scroll.mount();
  2736.  
  2737. });
  2738.  
  2739. // unload
  2740.  
  2741. $(document).on('shopify:section:unload', function(e){
  2742.  
  2743. var $section = $(e.target);
  2744.  
  2745. if ( $section.hasClass('mount-header') ) {
  2746. window.CUBER.Nav.unmount();
  2747. }
  2748. if ( $section.hasClass('mount-images') ) {
  2749. window.CUBER.Images.unmount();
  2750. }
  2751. if ( $section.hasClass('mount-video') ) {
  2752. window.CUBER.Video.unmount();
  2753. }
  2754. if ( $section.hasClass('mount-social') ) {
  2755. window.CUBER.Social.unmount();
  2756. }
  2757. if ( $section.hasClass('mount-slideshow') && $section.find('.box__slideshow-split').length > 0 ) {
  2758. window.CUBER.SplitSlider.unmount();
  2759. }
  2760. if ( $section.hasClass('mount-product') ) {
  2761. window.CUBER.Product.unmount($section);
  2762. }
  2763. if ( $section.hasClass('mount-map') ) {
  2764. window.CUBER.Contact.unmount();
  2765. }
  2766.  
  2767. window.CUBER.Main.unmount();
  2768. window.CUBER.Scroll.unmount();
  2769.  
  2770. });
  2771.  
  2772. // blocks
  2773.  
  2774. $(document).on('shopify:block:select', function(e){
  2775.  
  2776. var $block = $(e.target);
  2777. if ( $block.hasClass('slideshow-item') ) {
  2778. if ( $('.responsive-flickity').hasClass('flickity-enabled') ) {
  2779. $('.responsive-flickity').data('flickity').select($block.index())
  2780. } else {
  2781. $(window).scrollTop($block.offset().top);
  2782. }
  2783. $block.find('.caption, .title, .subtitle').css('transform', 'translateY(0)');
  2784. }
  2785.  
  2786. });
  2787.  
  2788. // Various stuff that doesn't need remounting
  2789.  
  2790. $(window).on('resize', function(){
  2791. if ( $(window).width() < 1024 ) {
  2792.  
  2793. }
  2794. });
  2795.  
  2796. $('.simple-grid select:not(.styled)').each(function(){
  2797. $(this).styledSelect({
  2798. coverClass: 'regular-select-cover',
  2799. innerClass: 'regular-select-inner'
  2800. }).addClass('styled');
  2801. $(this).parent().append($.themeAssets.arrowDown);
  2802. });
  2803.  
  2804. if ( $('body').hasClass('template-customers-login') ) {
  2805.  
  2806. if ( $('#RecoverPassword').length > 0 ) {
  2807.  
  2808. $('#RecoverPassword').on('click', function(e){
  2809. $('#CustomerLoginForm').hide();
  2810. $('#RecoverPasswordForm').show();
  2811. $('#LoginRecoverTitle').html($('#LoginRecoverTitle').data('password_recovery'));
  2812. e.preventDefault();
  2813. });
  2814.  
  2815. $('#HideRecoverPasswordLink').on('click', function(e){
  2816. $('#RecoverPasswordForm').hide();
  2817. $('#CustomerLoginForm').show();
  2818. $('#LoginRecoverTitle').html($('#LoginRecoverTitle').data('login'));
  2819. e.preventDefault();
  2820. });
  2821.  
  2822. if (window.location.hash == '#recover') {
  2823. $('#RecoverPassword').trigger('click');
  2824. }
  2825.  
  2826. }
  2827.  
  2828. } else if ( $('body').hasClass('template-customers-addresses') ) {
  2829. $('#section-addresses a').on('click', function(){
  2830. window.CUBER.Scroll.mount();
  2831. })
  2832. }
  2833.  
  2834. //
  2835.  
  2836. if ( $('body').hasClass('template-blog') || $('body').hasClass('template-article') ) {
  2837.  
  2838. window.CUBER.Main._mountScrollMovers({
  2839. 'parent': $('.scroll-movers-parent'),
  2840. 'items': $('.site-sharing')
  2841. });
  2842.  
  2843. window.CUBER.Main._mobileSharingInit();
  2844.  
  2845. }
  2846.  
  2847. });
  2848.  
  2849. if ( $('body').attr('id') == 'challenge' ) {
  2850. document.location.hash = '';
  2851. $('html, body').scrollTop(0);
  2852. }
  2853.  
  2854. })(jQuery);
  2855.  
  2856. function response(data) {
  2857. console.log(data);
  2858. }
  2859.  
  2860. window._getLuminance = function(hexy) {
  2861. var rgb = this._toRgb(hexy);
  2862. return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
  2863. }
  2864.  
  2865. window._toRgb = function(hexy) {
  2866. var hex = hexy.replace('rgb(', '');
  2867. hex = hex.replace(')', '');
  2868. hex = hex.replace(' ', '');
  2869. hex = hex.replace(' ', '');
  2870. hex = hex.split(',');
  2871. return { r: hex[0], g: hex[1], b: hex[2] };
  2872. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement