var Core = function() { /** * @memberOf Core * @returns Number */ var a = 200; /** * @memberOf Core * @returns Core */ var self = this; /** * @memberOf Core * @returns Object */ var b = $('body'); /** * @memberOf Core * @returns Object */ var d = document; /** * @memberOf Core * @returns Object */ var w = window; /** * @memberOf Core * @returns Core.Np */ var n = {}; /** * @memberOf Core * @returns Object */ var g = {}; /** * @memberOf Core * @returns String */ var toggler = '.toggle-popup'; /** * @memberOf Core * @returns Void */ var __construct = function() { n = Np(); initMap(); initSliders(); initFeaturedProducts(); settings(); initHeader(); }; var initHeader = function() { var shrinkHeader = 222; $(window).scroll(function() { var scroll = window.pageYOffset || document.documentElement.scrollTop; if (scroll >= shrinkHeader) { $('header').addClass('shrink'); } else { $('header').removeClass('shrink'); } }); } /** * @memberOf Core * @returns Void */ var initFeaturedProducts = function() { if ($('.featured-product .product').length > 5) { var parent = $('.featured-product'); $('.next', parent).addClass('show'); var item = $('.featured-product .product:first'); var max = Math.ceil($('.featured-product .product').length / 5) - 1; var curr = 0, step = Math.round(item.outerWidth() * 5); $('.arrow', parent).on('click', function(e) { e.preventDefault(); if ($(this).hasClass('next')) { curr--; } else { curr++; } $('.arrow', parent).addClass('show'); if (curr >= 0) { curr = 0; $('.prev', parent).removeClass('show'); } if (curr <= -max) { curr = -max; $('.next', parent).removeClass('show'); } item.stop().animate({ marginLeft : step * curr }, a * 5); }); } }; /** * @memberOf Core * @returns Void */ var initSliders = function() { if ($('.slide-item').length && typeof sliderTimer == 'undefined') { var delayTime = a * 50; var selector = '#content-slider .controls'; b.on('change', 'input[name="slide"]', function(e) { if (typeof sliderTimer != 'undefined') { clearTimeout(sliderTimer); } $(selector + ' label').addClass('empty'); $('label[for="' + this.id + '"]').removeClass('empty'); sliderTimer = setTimeout(pager, delayTime); }); var triggeredNext = (new Date()).getTime(); var remainedTime = delayTime; var pager = function() { triggeredNext = (new Date()).getTime(); $(selector + ' .arrows .next').trigger('click'); }; b.on('click', selector + ' .arrows .fa', function(e) { e.preventDefault(); var el = $(this); if (typeof sliderTimer != 'undefined') { clearTimeout(sliderTimer); } el.toggleClass('active'); var all = $(selector + ' label'), active = all.filter(':not(.empty)'); var index = all.index(active), next = index + (1 * (el.hasClass('prev') ? -1 : 1)); if (next == all.length) { next = 0; } if (next < 0) { next = all.length - 1; } setTimeout(function() { all.eq(next).trigger('click'); setTimeout(function() { el.toggleClass('active'); }, a); }, a); sliderTimer = setTimeout(pager, delayTime); }); b.on('mouseover', '.slide-item', function() { if (typeof sliderTimer != 'undefined') { clearTimeout(sliderTimer); } remainedTime = delayTime - ((new Date()).getTime() - triggeredNext); }).on('mouseout', '.slide-item', function() { sliderTimer = setTimeout(pager, remainedTime); }); sliderTimer = setTimeout(pager, delayTime); } }; /** * @memberOf Core * @returns Void */ var settings = function() { if (typeof gallery != 'undefined') { require(['ps', 'psui'], function(PhotoSwipe, PhotoSwipeUI_Default) { initGallery(PhotoSwipe, PhotoSwipeUI_Default); }); } if (typeof ga != 'undefined') { require(['ga'], function(_gat) { try { var pageTracker = _gat._getTracker(ga); pageTracker._trackPageview(); } catch (err) { } }); } var width = screen.width; var fbp = $('.fb-page'); var isFb = typeof FB != 'undefined'; if (isFb) { fbp.addClass('initialized'); FB.init({ xfbml : !0, version : facebook.version }); } var resizing = !1; $(w).load(function() { n.barDone(); }).on('beforeunload', function() { n.barStart(); }).resize(function() { if (!resizing && screen.width != width && isFb) { fbp.html(''); fbp.removeAttr('fb-xfbml-state').removeAttr('fb-iframe-plugin-query'); fbp.removeClass('fb_iframe_widget').removeClass('initialized'); var resizing = !0; } }).resizeEnd({ onDragEnd : function() { if (screen.width != width && isFb) { fbp.addClass('initialized') FB.XFBML.parse(); width = screen.width; var resizing = !1; } }, runOnStart : !0 }); setInterval(function() { var hb = $('html,body'), opened = Boolean($(toggler + ':checked').length); if (opened && !self.top) { self.top = $(self.w).scrollTop(); } hb.toggleClass('no-scroll', opened); if (!opened && self.top && !$(self.w).scrollTop()) { hb.stop(!0, !0).animate({ scrollTop : self.top }, 0); } if (!opened && self.top) { self.top = 0; } }, self.a); var h = $('header').css('position') == 'static' ? 0 : $('header').height() + 10; if ($('.form-error').length) { $('html,body').stop().animate({ scrollTop : $('.form-error:first').parents('.form-group').offset().top - h }, self.a, function() { $('.form-error:first').focus(); $(self.w).trigger('scroll'); }); } if (location.hash && location.hash != '#_=_') { $('html,body').stop().animate({ scrollTop : $(location.hash).offset().top - h }, self.a); $(self.w).trigger('scroll'); } }; /** * @param * PhotoSwipe * @param * PhotoSwipeUI_Default * @memberOf Core * @returns Void */ var initGallery = function(PhotoSwipe, PhotoSwipeUI_Default) { $('article img').each(function() { var el = $(this); if (!el.parent().hasClass('gallery-item')) { var a, b = !1; if (el.parent().prop('tagName') == 'A') { b = !0; a = el.parent(); } else { a = $('').attr('href', 'javascript:void(0)'); } a.addClass('gallery-item'); if (el.attr('alt')) { a.attr('data-alt', el.attr('alt')); } if (!b) { el.wrap(a); } } }); var selector = '.gallery-item'; var items = $(selector); items.selector = selector; if (items.length && (typeof gallery != 'undefined' && gallery.length) && $('.pswp').length == 1) { initGallerySlider(items, PhotoSwipe, PhotoSwipeUI_Default); } }; /** * @param * items * @param * PhotoSwipe * @param * PhotoSwipeUI_Default * @memberOf Core * @returns Void */ var initGallerySlider = function(items, PhotoSwipe, PhotoSwipeUI_Default) { var pswpElement = $('.pswp')[0]; var options = { history : !1, focus : !1, showAnimationDuration : a, hideAnimationDuration : a, index : 0, shareEl : !1, zoomEl : !1, loop : !0, arrowKeys : !0, barsSize : { top : 50, bottom : 'auto' } }; b.on('click', items.selector, function(e) { e.preventDefault(); var el = $(this); options.index = items.index(el); var gallerySlide = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, gallery, options); gallerySlide.init(); }); }; /** * @memberOf Core * @returns Void */ var initMap = function() { if (typeof google == 'undefined' || typeof google.maps == 'undefined') { return false; } g = google.maps; var pos = { lat : parseFloat(pin.coords[0]), lng : parseFloat(pin.coords[1]) }; pos = new g.LatLng(pos); var el = d.getElementById('gmap'); var map = new g.Map(el, { zoom : 16, center : pos, disableDefaultUI : !0, scrollwheel : !1, zoomControl : !0 }); var marker = new g.Marker({ map : map, position : pos }); g.event.addDomListener(w, 'resize', function() { g.event.trigger(map, 'resize'); map.setCenter(pos); }); }; /** * @memberOf Core * @returns Core.Np */ var Np = function() { /** * @memberOf Core.Np * @returns Core.Np */ var t = this; /** * @memberOf Core.Np * @returns Number */ var n = a; /** * @memberOf Core.Np * @returns NProgress */ var e = NProgress; /** * @memberOf Core.Np * @returns Void */ t.barStart = function() { e.isStarted() || e.start(), t.barIncrease() }; /** * @memberOf Core.Np * @returns Void */ t.barIncrease = function() { 'undefined' != typeof Npt && clearTimeout(Npt), e.inc(), Npt = setTimeout(function() { t.barIncrease() }, n) }; /** * @memberOf Core.Np * @returns Void */ t.barDone = function() { 'undefined' != typeof Npt && clearTimeout(Npt), setTimeout(function() { e.done() }, n) }; /** * @memberOf Core.Np * @returns Core.Np */ var o = function() { t.barStart(); if (!loading) { setTimeout(function() { t.barDone(); }, n); } $.ajaxSetup({ beforeSend : function(n, e) { t.barStart(); }, complete : function(n, e) { t.barDone(); } }); return t; }; return o(); }; __construct(); }, c = new Core();