diff --git a/.gitignore b/.gitignore index 5e52405..56635bc 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ bower.json # Ignore node_modules node_modules/ + +# Ignore master key for decrypting credentials and more. +/config/master.key diff --git a/Gemfile b/Gemfile index ad42699..4f71e55 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,8 @@ gem 'coffee-rails', '~> 4.2.1' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby +gem 'sprockets-rails' + # Use jquery as the JavaScript library gem 'jquery-rails' gem 'jquery-ui-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 09ba6b0..48fb39e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -353,6 +353,7 @@ DEPENDENCIES simplecov slack-notifier spring + sprockets-rails sqlite3 timecop toastr-rails diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index ba8b915..abd12bf 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -13,7 +13,10 @@ //= require jquery //= require rails-ujs //= require turbolinks +//= require popper //= require bootstrap -//= require_tree . +//= require scrollreveal.min.js //= require toastr -//= require popper +//= require jquery.magnific-popup.min.js + +//= require_tree . diff --git a/app/assets/javascripts/creative.coffee b/app/assets/javascripts/creative.coffee new file mode 100644 index 0000000..af089cc --- /dev/null +++ b/app/assets/javascripts/creative.coffee @@ -0,0 +1,65 @@ +(($) -> + 'use strict' + # Start of use strict + # Smooth scrolling using jQuery easing + $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click -> + if location.pathname.replace(/^\//, '') == @pathname.replace(/^\//, '') and location.hostname == @hostname + target = $(@hash) + target = if target.length then target else $('[name=' + @hash.slice(1) + ']') + if target.length + $('html, body').animate { scrollTop: target.offset().top - 57 }, 1000, 'easeInOutExpo' + return false + return + # Closes responsive menu when a scroll trigger link is clicked + $('.js-scroll-trigger').click -> + $('.navbar-collapse').collapse 'hide' + return + # Activate scrollspy to add active class to navbar items on scroll + $('body').scrollspy + target: '#mainNav' + offset: 57 + # Collapse Navbar + + navbarCollapse = -> + if $('#mainNav').offset().top > 100 + $('#mainNav').addClass 'navbar-shrink' + else + $('#mainNav').removeClass 'navbar-shrink' + return + + # Collapse now if page is not at top + $(document).on 'turbolinks:load', navbarCollapse + # Collapse the navbar when page is scrolled + $(window).scroll navbarCollapse + # Scroll reveal calls + window.sr = ScrollReveal() + sr.reveal '.sr-icons', { + duration: 600 + scale: 0.3 + distance: '0px' + }, 200 + sr.reveal '.sr-button', + duration: 1000 + delay: 200 + sr.reveal '.sr-contact', { + duration: 600 + scale: 0.3 + distance: '0px' + }, 300 + # Magnific popup calls + $('.popup-gallery').magnificPopup + delegate: 'a' + type: 'image' + tLoading: 'Loading image #%curr%...' + mainClass: 'mfp-img-mobile' + gallery: + enabled: true + navigateByImgClick: true + preload: [ + 0 + 1 + ] + image: tError: 'The image #%curr% could not be loaded.' + return +) jQuery +# End of use strict diff --git a/app/assets/javascripts/creative.js b/app/assets/javascripts/creative.js deleted file mode 100644 index 7a65340..0000000 --- a/app/assets/javascripts/creative.js +++ /dev/null @@ -1,75 +0,0 @@ -(function($) { - "use strict"; // Start of use strict - - // Smooth scrolling using jQuery easing - $('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function() { - if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { - var target = $(this.hash); - target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); - if (target.length) { - $('html, body').animate({ - scrollTop: (target.offset().top - 57) - }, 1000, "easeInOutExpo"); - return false; - } - } - }); - - // Closes responsive menu when a scroll trigger link is clicked - $('.js-scroll-trigger').click(function() { - $('.navbar-collapse').collapse('hide'); - }); - - // Activate scrollspy to add active class to navbar items on scroll - $('body').scrollspy({ - target: '#mainNav', - offset: 57 - }); - - // Collapse Navbar - var navbarCollapse = function() { - if ($("#mainNav").offset().top > 100) { - $("#mainNav").addClass("navbar-shrink"); - } else { - $("#mainNav").removeClass("navbar-shrink"); - } - }; - // Collapse now if page is not at top - navbarCollapse(); - // Collapse the navbar when page is scrolled - $(window).scroll(navbarCollapse); - - // Scroll reveal calls - window.sr = ScrollReveal(); - sr.reveal('.sr-icons', { - duration: 600, - scale: 0.3, - distance: '0px' - }, 200); - sr.reveal('.sr-button', { - duration: 1000, - delay: 200 - }); - sr.reveal('.sr-contact', { - duration: 600, - scale: 0.3, - distance: '0px' - }, 300); - - // Magnific popup calls - $('.popup-gallery').magnificPopup({ - delegate: 'a', - type: 'image', - tLoading: 'Loading image #%curr%...', - mainClass: 'mfp-img-mobile', - gallery: { - enabled: true, - navigateByImgClick: true, - preload: [0, 1] - }, - image: { - tError: 'The image #%curr% could not be loaded.' - } - }); - -})(jQuery); // End of use strict diff --git a/app/assets/javascripts/js-check.coffee b/app/assets/javascripts/js-check.coffee new file mode 100644 index 0000000..6b0646f --- /dev/null +++ b/app/assets/javascripts/js-check.coffee @@ -0,0 +1,7 @@ +$ -> + console.log('No Events') + $(document).on 'turbolinks:load', callTurbolinks_load_event + +callTurbolinks_load_event = -> + console.log('turbolinks:load called!') + return diff --git a/app/assets/javascripts/staticpages.coffee b/app/assets/javascripts/staticpages.coffee index bafcddb..461bd75 100644 --- a/app/assets/javascripts/staticpages.coffee +++ b/app/assets/javascripts/staticpages.coffee @@ -2,9 +2,6 @@ # All this logic will automatically be available in application.js. # You can use CoffeeScript in this file: http://coffeescript.org/ -document.addEventListener 'turbolinks:load', -> - componentHandler.upgradeDom() - # ((d, s, id) -> # js = undefined # fjs = d.getElementsByTagName(s)[0] @@ -30,4 +27,4 @@ document.addEventListener 'turbolinks:load', -> # fjs.parentNode.insertBefore js, fjs # return # )(document, 'script', 'twitter-wjs') -# return \ No newline at end of file +# return diff --git a/app/assets/javascripts/twitter.coffee b/app/assets/javascripts/twitter.coffee index fb760e8..712a809 100644 --- a/app/assets/javascripts/twitter.coffee +++ b/app/assets/javascripts/twitter.coffee @@ -1,3 +1,4 @@ + twttr_events_bound = false $ -> @@ -9,7 +10,7 @@ bindTwitterEventHandlers = -> twttr_events_bound = true renderTweetButtons = -> - $('.twitter-follow-button').each -> + $('.twitter-share-button').each -> button = $(this) button.attr('data-url', document.location.href) unless button.data('url')? button.attr('data-text', document.title) unless button.data('text')? @@ -17,3 +18,18 @@ renderTweetButtons = -> loadTwitterSDK = (callback) -> $.getScript('//platform.twitter.com/widgets.js', callback) + + +document.addEventListener 'turbolinks:load', -> + !((d, s, id) -> + js = undefined + fjs = d.getElementsByTagName(s)[0] + p = if /^http:/.test(d.location) then 'http' else 'https' + if !d.getElementById(id) + js = d.createElement(s) + js.id = id + js.src = p + '://platform.twitter.com/widgets.js' + fjs.parentNode.insertBefore js, fjs + return + )(document, 'script', 'twitter-wjs') + return diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 5107641..ec6d0e8 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -17,6 +17,8 @@ @import "toastr"; +@import "magnific-popup.css"; + @import "bootstrap-creative/creative"; @import "pages"; @import "posts"; diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000..2d705d0 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +93UJISKB7KDNP4+U59DLd7AtYZM2XBaJ73Z2KymZ6uWVm8rT2gd3vN8HkMy4A4ZmOUq8Q7y9Y4iPBhgQoBT990vG4Uvjjntcy5svtdFaGqwb+rp/Vge69FIzloXBYK46Xjgm2hD/gkZKfjru/j5eKmBJeRPbKgezsmFdfFwZVo+wTLoevaLf+X0cezrKzNX3nBB15ZHqe+A2//Sj7cxxO8flgOaeCm3Ukvathdrzv3OI9TfSepdA8CqXPunX55FW+qShgl41R5qZrZ01umwIJW+uCSItG3/bmQ2BKHAK9/TrRiSDUmSit5IxSP3B0ktwJH5Rdt0jSoWLWxr54Aj3K6cyiTbO1cM2BhbYugBTxsHl6Mbx5aXtyOY2wuROvK7TzXnO3w/b00s21fEJLd6/8uZ/fzXd0IPE5YEk--+6JTITAbwvy6yF68--e8oPyx0l4g2Sm+EWUuWwsg== \ No newline at end of file diff --git a/config/environments/production.rb b/config/environments/production.rb index 70f3bfc..a7d7f5d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,7 +14,7 @@ config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = true config.action_controller.perform_caching = true # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] @@ -23,14 +23,14 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = true # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + config.assets.compile = true # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb diff --git a/vendor/assets/magnific-popup/jquery.magnific-popup.js b/vendor/assets/magnific-popup/jquery.magnific-popup.js new file mode 100755 index 0000000..927b3c1 --- /dev/null +++ b/vendor/assets/magnific-popup/jquery.magnific-popup.js @@ -0,0 +1,1860 @@ +/*! Magnific Popup - v1.1.0 - 2016-02-20 +* http://dimsemenov.com/plugins/magnific-popup/ +* Copyright (c) 2016 Dmitry Semenov; */ +;(function (factory) { +if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { + // Node/CommonJS + factory(require('jquery')); + } else { + // Browser globals + factory(window.jQuery || window.Zepto); + } + }(function($) { + +/*>>core*/ +/** + * + * Magnific Popup Core JS file + * + */ + + +/** + * Private static constants + */ +var CLOSE_EVENT = 'Close', + BEFORE_CLOSE_EVENT = 'BeforeClose', + AFTER_CLOSE_EVENT = 'AfterClose', + BEFORE_APPEND_EVENT = 'BeforeAppend', + MARKUP_PARSE_EVENT = 'MarkupParse', + OPEN_EVENT = 'Open', + CHANGE_EVENT = 'Change', + NS = 'mfp', + EVENT_NS = '.' + NS, + READY_CLASS = 'mfp-ready', + REMOVING_CLASS = 'mfp-removing', + PREVENT_CLOSE_CLASS = 'mfp-prevent-close'; + + +/** + * Private vars + */ +/*jshint -W079 */ +var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this' + MagnificPopup = function(){}, + _isJQ = !!(window.jQuery), + _prevStatus, + _window = $(window), + _document, + _prevContentType, + _wrapClasses, + _currPopupType; + + +/** + * Private functions + */ +var _mfpOn = function(name, f) { + mfp.ev.on(NS + name + EVENT_NS, f); + }, + _getEl = function(className, appendTo, html, raw) { + var el = document.createElement('div'); + el.className = 'mfp-'+className; + if(html) { + el.innerHTML = html; + } + if(!raw) { + el = $(el); + if(appendTo) { + el.appendTo(appendTo); + } + } else if(appendTo) { + appendTo.appendChild(el); + } + return el; + }, + _mfpTrigger = function(e, data) { + mfp.ev.triggerHandler(NS + e, data); + + if(mfp.st.callbacks) { + // converts "mfpEventName" to "eventName" callback and triggers it if it's present + e = e.charAt(0).toLowerCase() + e.slice(1); + if(mfp.st.callbacks[e]) { + mfp.st.callbacks[e].apply(mfp, $.isArray(data) ? data : [data]); + } + } + }, + _getCloseBtn = function(type) { + if(type !== _currPopupType || !mfp.currTemplate.closeBtn) { + mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) ); + _currPopupType = type; + } + return mfp.currTemplate.closeBtn; + }, + // Initialize Magnific Popup only when called at least once + _checkInstance = function() { + if(!$.magnificPopup.instance) { + /*jshint -W020 */ + mfp = new MagnificPopup(); + mfp.init(); + $.magnificPopup.instance = mfp; + } + }, + // CSS transition detection, http://stackoverflow.com/questions/7264899/detect-css-transitions-using-javascript-and-without-modernizr + supportsTransitions = function() { + var s = document.createElement('p').style, // 's' for style. better to create an element if body yet to exist + v = ['ms','O','Moz','Webkit']; // 'v' for vendor + + if( s['transition'] !== undefined ) { + return true; + } + + while( v.length ) { + if( v.pop() + 'Transition' in s ) { + return true; + } + } + + return false; + }; + + + +/** + * Public functions + */ +MagnificPopup.prototype = { + + constructor: MagnificPopup, + + /** + * Initializes Magnific Popup plugin. + * This function is triggered only once when $.fn.magnificPopup or $.magnificPopup is executed + */ + init: function() { + var appVersion = navigator.appVersion; + mfp.isLowIE = mfp.isIE8 = document.all && !document.addEventListener; + mfp.isAndroid = (/android/gi).test(appVersion); + mfp.isIOS = (/iphone|ipad|ipod/gi).test(appVersion); + mfp.supportsTransition = supportsTransitions(); + + // We disable fixed positioned lightbox on devices that don't handle it nicely. + // If you know a better way of detecting this - let me know. + mfp.probablyMobile = (mfp.isAndroid || mfp.isIOS || /(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent) ); + _document = $(document); + + mfp.popupsCache = {}; + }, + + /** + * Opens popup + * @param data [description] + */ + open: function(data) { + + var i; + + if(data.isObj === false) { + // convert jQuery collection to array to avoid conflicts later + mfp.items = data.items.toArray(); + + mfp.index = 0; + var items = data.items, + item; + for(i = 0; i < items.length; i++) { + item = items[i]; + if(item.parsed) { + item = item.el[0]; + } + if(item === data.el[0]) { + mfp.index = i; + break; + } + } + } else { + mfp.items = $.isArray(data.items) ? data.items : [data.items]; + mfp.index = data.index || 0; + } + + // if popup is already opened - we just update the content + if(mfp.isOpen) { + mfp.updateItemHTML(); + return; + } + + mfp.types = []; + _wrapClasses = ''; + if(data.mainEl && data.mainEl.length) { + mfp.ev = data.mainEl.eq(0); + } else { + mfp.ev = _document; + } + + if(data.key) { + if(!mfp.popupsCache[data.key]) { + mfp.popupsCache[data.key] = {}; + } + mfp.currTemplate = mfp.popupsCache[data.key]; + } else { + mfp.currTemplate = {}; + } + + + + mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data ); + mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos; + + if(mfp.st.modal) { + mfp.st.closeOnContentClick = false; + mfp.st.closeOnBgClick = false; + mfp.st.showCloseBtn = false; + mfp.st.enableEscapeKey = false; + } + + + // Building markup + // main containers are created only once + if(!mfp.bgOverlay) { + + // Dark overlay + mfp.bgOverlay = _getEl('bg').on('click'+EVENT_NS, function() { + mfp.close(); + }); + + mfp.wrap = _getEl('wrap').attr('tabindex', -1).on('click'+EVENT_NS, function(e) { + if(mfp._checkIfClose(e.target)) { + mfp.close(); + } + }); + + mfp.container = _getEl('container', mfp.wrap); + } + + mfp.contentContainer = _getEl('content'); + if(mfp.st.preloader) { + mfp.preloader = _getEl('preloader', mfp.container, mfp.st.tLoading); + } + + + // Initializing modules + var modules = $.magnificPopup.modules; + for(i = 0; i < modules.length; i++) { + var n = modules[i]; + n = n.charAt(0).toUpperCase() + n.slice(1); + mfp['init'+n].call(mfp); + } + _mfpTrigger('BeforeOpen'); + + + if(mfp.st.showCloseBtn) { + // Close button + if(!mfp.st.closeBtnInside) { + mfp.wrap.append( _getCloseBtn() ); + } else { + _mfpOn(MARKUP_PARSE_EVENT, function(e, template, values, item) { + values.close_replaceWith = _getCloseBtn(item.type); + }); + _wrapClasses += ' mfp-close-btn-in'; + } + } + + if(mfp.st.alignTop) { + _wrapClasses += ' mfp-align-top'; + } + + + + if(mfp.fixedContentPos) { + mfp.wrap.css({ + overflow: mfp.st.overflowY, + overflowX: 'hidden', + overflowY: mfp.st.overflowY + }); + } else { + mfp.wrap.css({ + top: _window.scrollTop(), + position: 'absolute' + }); + } + if( mfp.st.fixedBgPos === false || (mfp.st.fixedBgPos === 'auto' && !mfp.fixedContentPos) ) { + mfp.bgOverlay.css({ + height: _document.height(), + position: 'absolute' + }); + } + + + + if(mfp.st.enableEscapeKey) { + // Close on ESC key + _document.on('keyup' + EVENT_NS, function(e) { + if(e.keyCode === 27) { + mfp.close(); + } + }); + } + + _window.on('resize' + EVENT_NS, function() { + mfp.updateSize(); + }); + + + if(!mfp.st.closeOnContentClick) { + _wrapClasses += ' mfp-auto-cursor'; + } + + if(_wrapClasses) + mfp.wrap.addClass(_wrapClasses); + + + // this triggers recalculation of layout, so we get it once to not to trigger twice + var windowHeight = mfp.wH = _window.height(); + + + var windowStyles = {}; + + if( mfp.fixedContentPos ) { + if(mfp._hasScrollBar(windowHeight)){ + var s = mfp._getScrollbarSize(); + if(s) { + windowStyles.marginRight = s; + } + } + } + + if(mfp.fixedContentPos) { + if(!mfp.isIE7) { + windowStyles.overflow = 'hidden'; + } else { + // ie7 double-scroll bug + $('body, html').css('overflow', 'hidden'); + } + } + + + + var classesToadd = mfp.st.mainClass; + if(mfp.isIE7) { + classesToadd += ' mfp-ie7'; + } + if(classesToadd) { + mfp._addClassToMFP( classesToadd ); + } + + // add content + mfp.updateItemHTML(); + + _mfpTrigger('BuildControls'); + + // remove scrollbar, add margin e.t.c + $('html').css(windowStyles); + + // add everything to DOM + mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || $(document.body) ); + + // Save last focused element + mfp._lastFocusedEl = document.activeElement; + + // Wait for next cycle to allow CSS transition + setTimeout(function() { + + if(mfp.content) { + mfp._addClassToMFP(READY_CLASS); + mfp._setFocus(); + } else { + // if content is not defined (not loaded e.t.c) we add class only for BG + mfp.bgOverlay.addClass(READY_CLASS); + } + + // Trap the focus in popup + _document.on('focusin' + EVENT_NS, mfp._onFocusIn); + + }, 16); + + mfp.isOpen = true; + mfp.updateSize(windowHeight); + _mfpTrigger(OPEN_EVENT); + + return data; + }, + + /** + * Closes the popup + */ + close: function() { + if(!mfp.isOpen) return; + _mfpTrigger(BEFORE_CLOSE_EVENT); + + mfp.isOpen = false; + // for CSS3 animation + if(mfp.st.removalDelay && !mfp.isLowIE && mfp.supportsTransition ) { + mfp._addClassToMFP(REMOVING_CLASS); + setTimeout(function() { + mfp._close(); + }, mfp.st.removalDelay); + } else { + mfp._close(); + } + }, + + /** + * Helper for close() function + */ + _close: function() { + _mfpTrigger(CLOSE_EVENT); + + var classesToRemove = REMOVING_CLASS + ' ' + READY_CLASS + ' '; + + mfp.bgOverlay.detach(); + mfp.wrap.detach(); + mfp.container.empty(); + + if(mfp.st.mainClass) { + classesToRemove += mfp.st.mainClass + ' '; + } + + mfp._removeClassFromMFP(classesToRemove); + + if(mfp.fixedContentPos) { + var windowStyles = {marginRight: ''}; + if(mfp.isIE7) { + $('body, html').css('overflow', ''); + } else { + windowStyles.overflow = ''; + } + $('html').css(windowStyles); + } + + _document.off('keyup' + EVENT_NS + ' focusin' + EVENT_NS); + mfp.ev.off(EVENT_NS); + + // clean up DOM elements that aren't removed + mfp.wrap.attr('class', 'mfp-wrap').removeAttr('style'); + mfp.bgOverlay.attr('class', 'mfp-bg'); + mfp.container.attr('class', 'mfp-container'); + + // remove close button from target element + if(mfp.st.showCloseBtn && + (!mfp.st.closeBtnInside || mfp.currTemplate[mfp.currItem.type] === true)) { + if(mfp.currTemplate.closeBtn) + mfp.currTemplate.closeBtn.detach(); + } + + + if(mfp.st.autoFocusLast && mfp._lastFocusedEl) { + $(mfp._lastFocusedEl).focus(); // put tab focus back + } + mfp.currItem = null; + mfp.content = null; + mfp.currTemplate = null; + mfp.prevHeight = 0; + + _mfpTrigger(AFTER_CLOSE_EVENT); + }, + + updateSize: function(winHeight) { + + if(mfp.isIOS) { + // fixes iOS nav bars https://github.com/dimsemenov/Magnific-Popup/issues/2 + var zoomLevel = document.documentElement.clientWidth / window.innerWidth; + var height = window.innerHeight * zoomLevel; + mfp.wrap.css('height', height); + mfp.wH = height; + } else { + mfp.wH = winHeight || _window.height(); + } + // Fixes #84: popup incorrectly positioned with position:relative on body + if(!mfp.fixedContentPos) { + mfp.wrap.css('height', mfp.wH); + } + + _mfpTrigger('Resize'); + + }, + + /** + * Set content of popup based on current index + */ + updateItemHTML: function() { + var item = mfp.items[mfp.index]; + + // Detach and perform modifications + mfp.contentContainer.detach(); + + if(mfp.content) + mfp.content.detach(); + + if(!item.parsed) { + item = mfp.parseEl( mfp.index ); + } + + var type = item.type; + + _mfpTrigger('BeforeChange', [mfp.currItem ? mfp.currItem.type : '', type]); + // BeforeChange event works like so: + // _mfpOn('BeforeChange', function(e, prevType, newType) { }); + + mfp.currItem = item; + + if(!mfp.currTemplate[type]) { + var markup = mfp.st[type] ? mfp.st[type].markup : false; + + // allows to modify markup + _mfpTrigger('FirstMarkupParse', markup); + + if(markup) { + mfp.currTemplate[type] = $(markup); + } else { + // if there is no markup found we just define that template is parsed + mfp.currTemplate[type] = true; + } + } + + if(_prevContentType && _prevContentType !== item.type) { + mfp.container.removeClass('mfp-'+_prevContentType+'-holder'); + } + + var newContent = mfp['get' + type.charAt(0).toUpperCase() + type.slice(1)](item, mfp.currTemplate[type]); + mfp.appendContent(newContent, type); + + item.preloaded = true; + + _mfpTrigger(CHANGE_EVENT, item); + _prevContentType = item.type; + + // Append container back after its content changed + mfp.container.prepend(mfp.contentContainer); + + _mfpTrigger('AfterChange'); + }, + + + /** + * Set HTML content of popup + */ + appendContent: function(newContent, type) { + mfp.content = newContent; + + if(newContent) { + if(mfp.st.showCloseBtn && mfp.st.closeBtnInside && + mfp.currTemplate[type] === true) { + // if there is no markup, we just append close button element inside + if(!mfp.content.find('.mfp-close').length) { + mfp.content.append(_getCloseBtn()); + } + } else { + mfp.content = newContent; + } + } else { + mfp.content = ''; + } + + _mfpTrigger(BEFORE_APPEND_EVENT); + mfp.container.addClass('mfp-'+type+'-holder'); + + mfp.contentContainer.append(mfp.content); + }, + + + /** + * Creates Magnific Popup data object based on given data + * @param {int} index Index of item to parse + */ + parseEl: function(index) { + var item = mfp.items[index], + type; + + if(item.tagName) { + item = { el: $(item) }; + } else { + type = item.type; + item = { data: item, src: item.src }; + } + + if(item.el) { + var types = mfp.types; + + // check for 'mfp-TYPE' class + for(var i = 0; i < types.length; i++) { + if( item.el.hasClass('mfp-'+types[i]) ) { + type = types[i]; + break; + } + } + + item.src = item.el.attr('data-mfp-src'); + if(!item.src) { + item.src = item.el.attr('href'); + } + } + + item.type = type || mfp.st.type || 'inline'; + item.index = index; + item.parsed = true; + mfp.items[index] = item; + _mfpTrigger('ElementParse', item); + + return mfp.items[index]; + }, + + + /** + * Initializes single popup or a group of popups + */ + addGroup: function(el, options) { + var eHandler = function(e) { + e.mfpEl = this; + mfp._openClick(e, el, options); + }; + + if(!options) { + options = {}; + } + + var eName = 'click.magnificPopup'; + options.mainEl = el; + + if(options.items) { + options.isObj = true; + el.off(eName).on(eName, eHandler); + } else { + options.isObj = false; + if(options.delegate) { + el.off(eName).on(eName, options.delegate , eHandler); + } else { + options.items = el; + el.off(eName).on(eName, eHandler); + } + } + }, + _openClick: function(e, el, options) { + var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick; + + + if(!midClick && ( e.which === 2 || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey ) ) { + return; + } + + var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn; + + if(disableOn) { + if($.isFunction(disableOn)) { + if( !disableOn.call(mfp) ) { + return true; + } + } else { // else it's number + if( _window.width() < disableOn ) { + return true; + } + } + } + + if(e.type) { + e.preventDefault(); + + // This will prevent popup from closing if element is inside and popup is already opened + if(mfp.isOpen) { + e.stopPropagation(); + } + } + + options.el = $(e.mfpEl); + if(options.delegate) { + options.items = el.find(options.delegate); + } + mfp.open(options); + }, + + + /** + * Updates text on preloader + */ + updateStatus: function(status, text) { + + if(mfp.preloader) { + if(_prevStatus !== status) { + mfp.container.removeClass('mfp-s-'+_prevStatus); + } + + if(!text && status === 'loading') { + text = mfp.st.tLoading; + } + + var data = { + status: status, + text: text + }; + // allows to modify status + _mfpTrigger('UpdateStatus', data); + + status = data.status; + text = data.text; + + mfp.preloader.html(text); + + mfp.preloader.find('a').on('click', function(e) { + e.stopImmediatePropagation(); + }); + + mfp.container.addClass('mfp-s-'+status); + _prevStatus = status; + } + }, + + + /* + "Private" helpers that aren't private at all + */ + // Check to close popup or not + // "target" is an element that was clicked + _checkIfClose: function(target) { + + if($(target).hasClass(PREVENT_CLOSE_CLASS)) { + return; + } + + var closeOnContent = mfp.st.closeOnContentClick; + var closeOnBg = mfp.st.closeOnBgClick; + + if(closeOnContent && closeOnBg) { + return true; + } else { + + // We close the popup if click is on close button or on preloader. Or if there is no content. + if(!mfp.content || $(target).hasClass('mfp-close') || (mfp.preloader && target === mfp.preloader[0]) ) { + return true; + } + + // if click is outside the content + if( (target !== mfp.content[0] && !$.contains(mfp.content[0], target)) ) { + if(closeOnBg) { + // last check, if the clicked element is in DOM, (in case it's removed onclick) + if( $.contains(document, target) ) { + return true; + } + } + } else if(closeOnContent) { + return true; + } + + } + return false; + }, + _addClassToMFP: function(cName) { + mfp.bgOverlay.addClass(cName); + mfp.wrap.addClass(cName); + }, + _removeClassFromMFP: function(cName) { + this.bgOverlay.removeClass(cName); + mfp.wrap.removeClass(cName); + }, + _hasScrollBar: function(winHeight) { + return ( (mfp.isIE7 ? _document.height() : document.body.scrollHeight) > (winHeight || _window.height()) ); + }, + _setFocus: function() { + (mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus(); + }, + _onFocusIn: function(e) { + if( e.target !== mfp.wrap[0] && !$.contains(mfp.wrap[0], e.target) ) { + mfp._setFocus(); + return false; + } + }, + _parseMarkup: function(template, values, item) { + var arr; + if(item.data) { + values = $.extend(item.data, values); + } + _mfpTrigger(MARKUP_PARSE_EVENT, [template, values, item] ); + + $.each(values, function(key, value) { + if(value === undefined || value === false) { + return true; + } + arr = key.split('_'); + if(arr.length > 1) { + var el = template.find(EVENT_NS + '-'+arr[0]); + + if(el.length > 0) { + var attr = arr[1]; + if(attr === 'replaceWith') { + if(el[0] !== value[0]) { + el.replaceWith(value); + } + } else if(attr === 'img') { + if(el.is('img')) { + el.attr('src', value); + } else { + el.replaceWith( $('').attr('src', value).attr('class', el.attr('class')) ); + } + } else { + el.attr(arr[1], value); + } + } + + } else { + template.find(EVENT_NS + '-'+key).html(value); + } + }); + }, + + _getScrollbarSize: function() { + // thx David + if(mfp.scrollbarSize === undefined) { + var scrollDiv = document.createElement("div"); + scrollDiv.style.cssText = 'width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;'; + document.body.appendChild(scrollDiv); + mfp.scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth; + document.body.removeChild(scrollDiv); + } + return mfp.scrollbarSize; + } + +}; /* MagnificPopup core prototype end */ + + + + +/** + * Public static functions + */ +$.magnificPopup = { + instance: null, + proto: MagnificPopup.prototype, + modules: [], + + open: function(options, index) { + _checkInstance(); + + if(!options) { + options = {}; + } else { + options = $.extend(true, {}, options); + } + + options.isObj = true; + options.index = index || 0; + return this.instance.open(options); + }, + + close: function() { + return $.magnificPopup.instance && $.magnificPopup.instance.close(); + }, + + registerModule: function(name, module) { + if(module.options) { + $.magnificPopup.defaults[name] = module.options; + } + $.extend(this.proto, module.proto); + this.modules.push(name); + }, + + defaults: { + + // Info about options is in docs: + // http://dimsemenov.com/plugins/magnific-popup/documentation.html#options + + disableOn: 0, + + key: null, + + midClick: false, + + mainClass: '', + + preloader: true, + + focus: '', // CSS selector of input to focus after popup is opened + + closeOnContentClick: false, + + closeOnBgClick: true, + + closeBtnInside: true, + + showCloseBtn: true, + + enableEscapeKey: true, + + modal: false, + + alignTop: false, + + removalDelay: 0, + + prependTo: null, + + fixedContentPos: 'auto', + + fixedBgPos: 'auto', + + overflowY: 'auto', + + closeMarkup: '', + + tClose: 'Close (Esc)', + + tLoading: 'Loading...', + + autoFocusLast: true + + } +}; + + + +$.fn.magnificPopup = function(options) { + _checkInstance(); + + var jqEl = $(this); + + // We call some API method of first param is a string + if (typeof options === "string" ) { + + if(options === 'open') { + var items, + itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup, + index = parseInt(arguments[1], 10) || 0; + + if(itemOpts.items) { + items = itemOpts.items[index]; + } else { + items = jqEl; + if(itemOpts.delegate) { + items = items.find(itemOpts.delegate); + } + items = items.eq( index ); + } + mfp._openClick({mfpEl:items}, jqEl, itemOpts); + } else { + if(mfp.isOpen) + mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1)); + } + + } else { + // clone options obj + options = $.extend(true, {}, options); + + /* + * As Zepto doesn't support .data() method for objects + * and it works only in normal browsers + * we assign "options" object directly to the DOM element. FTW! + */ + if(_isJQ) { + jqEl.data('magnificPopup', options); + } else { + jqEl[0].magnificPopup = options; + } + + mfp.addGroup(jqEl, options); + + } + return jqEl; +}; + +/*>>core*/ + +/*>>inline*/ + +var INLINE_NS = 'inline', + _hiddenClass, + _inlinePlaceholder, + _lastInlineElement, + _putInlineElementsBack = function() { + if(_lastInlineElement) { + _inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach(); + _lastInlineElement = null; + } + }; + +$.magnificPopup.registerModule(INLINE_NS, { + options: { + hiddenClass: 'hide', // will be appended with `mfp-` prefix + markup: '', + tNotFound: 'Content not found' + }, + proto: { + + initInline: function() { + mfp.types.push(INLINE_NS); + + _mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() { + _putInlineElementsBack(); + }); + }, + + getInline: function(item, template) { + + _putInlineElementsBack(); + + if(item.src) { + var inlineSt = mfp.st.inline, + el = $(item.src); + + if(el.length) { + + // If target element has parent - we replace it with placeholder and put it back after popup is closed + var parent = el[0].parentNode; + if(parent && parent.tagName) { + if(!_inlinePlaceholder) { + _hiddenClass = inlineSt.hiddenClass; + _inlinePlaceholder = _getEl(_hiddenClass); + _hiddenClass = 'mfp-'+_hiddenClass; + } + // replace target inline element with placeholder + _lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass); + } + + mfp.updateStatus('ready'); + } else { + mfp.updateStatus('error', inlineSt.tNotFound); + el = $('
'); + } + + item.inlineElement = el; + return el; + } + + mfp.updateStatus('ready'); + mfp._parseMarkup(template, {}, item); + return template; + } + } +}); + +/*>>inline*/ + +/*>>ajax*/ +var AJAX_NS = 'ajax', + _ajaxCur, + _removeAjaxCursor = function() { + if(_ajaxCur) { + $(document.body).removeClass(_ajaxCur); + } + }, + _destroyAjaxRequest = function() { + _removeAjaxCursor(); + if(mfp.req) { + mfp.req.abort(); + } + }; + +$.magnificPopup.registerModule(AJAX_NS, { + + options: { + settings: null, + cursor: 'mfp-ajax-cur', + tError: 'The content could not be loaded.' + }, + + proto: { + initAjax: function() { + mfp.types.push(AJAX_NS); + _ajaxCur = mfp.st.ajax.cursor; + + _mfpOn(CLOSE_EVENT+'.'+AJAX_NS, _destroyAjaxRequest); + _mfpOn('BeforeChange.' + AJAX_NS, _destroyAjaxRequest); + }, + getAjax: function(item) { + + if(_ajaxCur) { + $(document.body).addClass(_ajaxCur); + } + + mfp.updateStatus('loading'); + + var opts = $.extend({ + url: item.src, + success: function(data, textStatus, jqXHR) { + var temp = { + data:data, + xhr:jqXHR + }; + + _mfpTrigger('ParseAjax', temp); + + mfp.appendContent( $(temp.data), AJAX_NS ); + + item.finished = true; + + _removeAjaxCursor(); + + mfp._setFocus(); + + setTimeout(function() { + mfp.wrap.addClass(READY_CLASS); + }, 16); + + mfp.updateStatus('ready'); + + _mfpTrigger('AjaxContentAdded'); + }, + error: function() { + _removeAjaxCursor(); + item.finished = item.loadError = true; + mfp.updateStatus('error', mfp.st.ajax.tError.replace('%url%', item.src)); + } + }, mfp.st.ajax.settings); + + mfp.req = $.ajax(opts); + + return ''; + } + } +}); + +/*>>ajax*/ + +/*>>image*/ +var _imgInterval, + _getTitle = function(item) { + if(item.data && item.data.title !== undefined) + return item.data.title; + + var src = mfp.st.image.titleSrc; + + if(src) { + if($.isFunction(src)) { + return src.call(mfp, item); + } else if(item.el) { + return item.el.attr(src) || ''; + } + } + return ''; + }; + +$.magnificPopup.registerModule('image', { + + options: { + markup: '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
'+ + '
', + cursor: 'mfp-zoom-out-cur', + titleSrc: 'title', + verticalFit: true, + tError: 'The image could not be loaded.' + }, + + proto: { + initImage: function() { + var imgSt = mfp.st.image, + ns = '.image'; + + mfp.types.push('image'); + + _mfpOn(OPEN_EVENT+ns, function() { + if(mfp.currItem.type === 'image' && imgSt.cursor) { + $(document.body).addClass(imgSt.cursor); + } + }); + + _mfpOn(CLOSE_EVENT+ns, function() { + if(imgSt.cursor) { + $(document.body).removeClass(imgSt.cursor); + } + _window.off('resize' + EVENT_NS); + }); + + _mfpOn('Resize'+ns, mfp.resizeImage); + if(mfp.isLowIE) { + _mfpOn('AfterChange', mfp.resizeImage); + } + }, + resizeImage: function() { + var item = mfp.currItem; + if(!item || !item.img) return; + + if(mfp.st.image.verticalFit) { + var decr = 0; + // fix box-sizing in ie7/8 + if(mfp.isLowIE) { + decr = parseInt(item.img.css('padding-top'), 10) + parseInt(item.img.css('padding-bottom'),10); + } + item.img.css('max-height', mfp.wH-decr); + } + }, + _onImageHasSize: function(item) { + if(item.img) { + + item.hasSize = true; + + if(_imgInterval) { + clearInterval(_imgInterval); + } + + item.isCheckingImgSize = false; + + _mfpTrigger('ImageHasSize', item); + + if(item.imgHidden) { + if(mfp.content) + mfp.content.removeClass('mfp-loading'); + + item.imgHidden = false; + } + + } + }, + + /** + * Function that loops until the image has size to display elements that rely on it asap + */ + findImageSize: function(item) { + + var counter = 0, + img = item.img[0], + mfpSetInterval = function(delay) { + + if(_imgInterval) { + clearInterval(_imgInterval); + } + // decelerating interval that checks for size of an image + _imgInterval = setInterval(function() { + if(img.naturalWidth > 0) { + mfp._onImageHasSize(item); + return; + } + + if(counter > 200) { + clearInterval(_imgInterval); + } + + counter++; + if(counter === 3) { + mfpSetInterval(10); + } else if(counter === 40) { + mfpSetInterval(50); + } else if(counter === 100) { + mfpSetInterval(500); + } + }, delay); + }; + + mfpSetInterval(1); + }, + + getImage: function(item, template) { + + var guard = 0, + + // image load complete handler + onLoadComplete = function() { + if(item) { + if (item.img[0].complete) { + item.img.off('.mfploader'); + + if(item === mfp.currItem){ + mfp._onImageHasSize(item); + + mfp.updateStatus('ready'); + } + + item.hasSize = true; + item.loaded = true; + + _mfpTrigger('ImageLoadComplete'); + + } + else { + // if image complete check fails 200 times (20 sec), we assume that there was an error. + guard++; + if(guard < 200) { + setTimeout(onLoadComplete,100); + } else { + onLoadError(); + } + } + } + }, + + // image error handler + onLoadError = function() { + if(item) { + item.img.off('.mfploader'); + if(item === mfp.currItem){ + mfp._onImageHasSize(item); + mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) ); + } + + item.hasSize = true; + item.loaded = true; + item.loadError = true; + } + }, + imgSt = mfp.st.image; + + + var el = template.find('.mfp-img'); + if(el.length) { + var img = document.createElement('img'); + img.className = 'mfp-img'; + if(item.el && item.el.find('img').length) { + img.alt = item.el.find('img').attr('alt'); + } + item.img = $(img).on('load.mfploader', onLoadComplete).on('error.mfploader', onLoadError); + img.src = item.src; + + // without clone() "error" event is not firing when IMG is replaced by new IMG + // TODO: find a way to avoid such cloning + if(el.is('img')) { + item.img = item.img.clone(); + } + + img = item.img[0]; + if(img.naturalWidth > 0) { + item.hasSize = true; + } else if(!img.width) { + item.hasSize = false; + } + } + + mfp._parseMarkup(template, { + title: _getTitle(item), + img_replaceWith: item.img + }, item); + + mfp.resizeImage(); + + if(item.hasSize) { + if(_imgInterval) clearInterval(_imgInterval); + + if(item.loadError) { + template.addClass('mfp-loading'); + mfp.updateStatus('error', imgSt.tError.replace('%url%', item.src) ); + } else { + template.removeClass('mfp-loading'); + mfp.updateStatus('ready'); + } + return template; + } + + mfp.updateStatus('loading'); + item.loading = true; + + if(!item.hasSize) { + item.imgHidden = true; + template.addClass('mfp-loading'); + mfp.findImageSize(item); + } + + return template; + } + } +}); + +/*>>image*/ + +/*>>zoom*/ +var hasMozTransform, + getHasMozTransform = function() { + if(hasMozTransform === undefined) { + hasMozTransform = document.createElement('p').style.MozTransform !== undefined; + } + return hasMozTransform; + }; + +$.magnificPopup.registerModule('zoom', { + + options: { + enabled: false, + easing: 'ease-in-out', + duration: 300, + opener: function(element) { + return element.is('img') ? element : element.find('img'); + } + }, + + proto: { + + initZoom: function() { + var zoomSt = mfp.st.zoom, + ns = '.zoom', + image; + + if(!zoomSt.enabled || !mfp.supportsTransition) { + return; + } + + var duration = zoomSt.duration, + getElToAnimate = function(image) { + var newImg = image.clone().removeAttr('style').removeAttr('class').addClass('mfp-animated-image'), + transition = 'all '+(zoomSt.duration/1000)+'s ' + zoomSt.easing, + cssObj = { + position: 'fixed', + zIndex: 9999, + left: 0, + top: 0, + '-webkit-backface-visibility': 'hidden' + }, + t = 'transition'; + + cssObj['-webkit-'+t] = cssObj['-moz-'+t] = cssObj['-o-'+t] = cssObj[t] = transition; + + newImg.css(cssObj); + return newImg; + }, + showMainContent = function() { + mfp.content.css('visibility', 'visible'); + }, + openTimeout, + animatedImg; + + _mfpOn('BuildControls'+ns, function() { + if(mfp._allowZoom()) { + + clearTimeout(openTimeout); + mfp.content.css('visibility', 'hidden'); + + // Basically, all code below does is clones existing image, puts in on top of the current one and animated it + + image = mfp._getItemToZoom(); + + if(!image) { + showMainContent(); + return; + } + + animatedImg = getElToAnimate(image); + + animatedImg.css( mfp._getOffset() ); + + mfp.wrap.append(animatedImg); + + openTimeout = setTimeout(function() { + animatedImg.css( mfp._getOffset( true ) ); + openTimeout = setTimeout(function() { + + showMainContent(); + + setTimeout(function() { + animatedImg.remove(); + image = animatedImg = null; + _mfpTrigger('ZoomAnimationEnded'); + }, 16); // avoid blink when switching images + + }, duration); // this timeout equals animation duration + + }, 16); // by adding this timeout we avoid short glitch at the beginning of animation + + + // Lots of timeouts... + } + }); + _mfpOn(BEFORE_CLOSE_EVENT+ns, function() { + if(mfp._allowZoom()) { + + clearTimeout(openTimeout); + + mfp.st.removalDelay = duration; + + if(!image) { + image = mfp._getItemToZoom(); + if(!image) { + return; + } + animatedImg = getElToAnimate(image); + } + + animatedImg.css( mfp._getOffset(true) ); + mfp.wrap.append(animatedImg); + mfp.content.css('visibility', 'hidden'); + + setTimeout(function() { + animatedImg.css( mfp._getOffset() ); + }, 16); + } + + }); + + _mfpOn(CLOSE_EVENT+ns, function() { + if(mfp._allowZoom()) { + showMainContent(); + if(animatedImg) { + animatedImg.remove(); + } + image = null; + } + }); + }, + + _allowZoom: function() { + return mfp.currItem.type === 'image'; + }, + + _getItemToZoom: function() { + if(mfp.currItem.hasSize) { + return mfp.currItem.img; + } else { + return false; + } + }, + + // Get element postion relative to viewport + _getOffset: function(isLarge) { + var el; + if(isLarge) { + el = mfp.currItem.img; + } else { + el = mfp.st.zoom.opener(mfp.currItem.el || mfp.currItem); + } + + var offset = el.offset(); + var paddingTop = parseInt(el.css('padding-top'),10); + var paddingBottom = parseInt(el.css('padding-bottom'),10); + offset.top -= ( $(window).scrollTop() - paddingTop ); + + + /* + + Animating left + top + width/height looks glitchy in Firefox, but perfect in Chrome. And vice-versa. + + */ + var obj = { + width: el.width(), + // fix Zepto height+padding issue + height: (_isJQ ? el.innerHeight() : el[0].offsetHeight) - paddingBottom - paddingTop + }; + + // I hate to do this, but there is no another option + if( getHasMozTransform() ) { + obj['-moz-transform'] = obj['transform'] = 'translate(' + offset.left + 'px,' + offset.top + 'px)'; + } else { + obj.left = offset.left; + obj.top = offset.top; + } + return obj; + } + + } +}); + + + +/*>>zoom*/ + +/*>>iframe*/ + +var IFRAME_NS = 'iframe', + _emptyPage = '//about:blank', + + _fixIframeBugs = function(isShowing) { + if(mfp.currTemplate[IFRAME_NS]) { + var el = mfp.currTemplate[IFRAME_NS].find('iframe'); + if(el.length) { + // reset src after the popup is closed to avoid "video keeps playing after popup is closed" bug + if(!isShowing) { + el[0].src = _emptyPage; + } + + // IE8 black screen bug fix + if(mfp.isIE8) { + el.css('display', isShowing ? 'block' : 'none'); + } + } + } + }; + +$.magnificPopup.registerModule(IFRAME_NS, { + + options: { + markup: '
'+ + '
'+ + ''+ + '
', + + srcAction: 'iframe_src', + + // we don't care and support only one default type of URL by default + patterns: { + youtube: { + index: 'youtube.com', + id: 'v=', + src: '//www.youtube.com/embed/%id%?autoplay=1' + }, + vimeo: { + index: 'vimeo.com/', + id: '/', + src: '//player.vimeo.com/video/%id%?autoplay=1' + }, + gmaps: { + index: '//maps.google.', + src: '%id%&output=embed' + } + } + }, + + proto: { + initIframe: function() { + mfp.types.push(IFRAME_NS); + + _mfpOn('BeforeChange', function(e, prevType, newType) { + if(prevType !== newType) { + if(prevType === IFRAME_NS) { + _fixIframeBugs(); // iframe if removed + } else if(newType === IFRAME_NS) { + _fixIframeBugs(true); // iframe is showing + } + }// else { + // iframe source is switched, don't do anything + //} + }); + + _mfpOn(CLOSE_EVENT + '.' + IFRAME_NS, function() { + _fixIframeBugs(); + }); + }, + + getIframe: function(item, template) { + var embedSrc = item.src; + var iframeSt = mfp.st.iframe; + + $.each(iframeSt.patterns, function() { + if(embedSrc.indexOf( this.index ) > -1) { + if(this.id) { + if(typeof this.id === 'string') { + embedSrc = embedSrc.substr(embedSrc.lastIndexOf(this.id)+this.id.length, embedSrc.length); + } else { + embedSrc = this.id.call( this, embedSrc ); + } + } + embedSrc = this.src.replace('%id%', embedSrc ); + return false; // break; + } + }); + + var dataObj = {}; + if(iframeSt.srcAction) { + dataObj[iframeSt.srcAction] = embedSrc; + } + mfp._parseMarkup(template, dataObj, item); + + mfp.updateStatus('ready'); + + return template; + } + } +}); + + + +/*>>iframe*/ + +/*>>gallery*/ +/** + * Get looped index depending on number of slides + */ +var _getLoopedId = function(index) { + var numSlides = mfp.items.length; + if(index > numSlides - 1) { + return index - numSlides; + } else if(index < 0) { + return numSlides + index; + } + return index; + }, + _replaceCurrTotal = function(text, curr, total) { + return text.replace(/%curr%/gi, curr + 1).replace(/%total%/gi, total); + }; + +$.magnificPopup.registerModule('gallery', { + + options: { + enabled: false, + arrowMarkup: '', + preload: [0,2], + navigateByImgClick: true, + arrows: true, + + tPrev: 'Previous (Left arrow key)', + tNext: 'Next (Right arrow key)', + tCounter: '%curr% of %total%' + }, + + proto: { + initGallery: function() { + + var gSt = mfp.st.gallery, + ns = '.mfp-gallery'; + + mfp.direction = true; // true - next, false - prev + + if(!gSt || !gSt.enabled ) return false; + + _wrapClasses += ' mfp-gallery'; + + _mfpOn(OPEN_EVENT+ns, function() { + + if(gSt.navigateByImgClick) { + mfp.wrap.on('click'+ns, '.mfp-img', function() { + if(mfp.items.length > 1) { + mfp.next(); + return false; + } + }); + } + + _document.on('keydown'+ns, function(e) { + if (e.keyCode === 37) { + mfp.prev(); + } else if (e.keyCode === 39) { + mfp.next(); + } + }); + }); + + _mfpOn('UpdateStatus'+ns, function(e, data) { + if(data.text) { + data.text = _replaceCurrTotal(data.text, mfp.currItem.index, mfp.items.length); + } + }); + + _mfpOn(MARKUP_PARSE_EVENT+ns, function(e, element, values, item) { + var l = mfp.items.length; + values.counter = l > 1 ? _replaceCurrTotal(gSt.tCounter, item.index, l) : ''; + }); + + _mfpOn('BuildControls' + ns, function() { + if(mfp.items.length > 1 && gSt.arrows && !mfp.arrowLeft) { + var markup = gSt.arrowMarkup, + arrowLeft = mfp.arrowLeft = $( markup.replace(/%title%/gi, gSt.tPrev).replace(/%dir%/gi, 'left') ).addClass(PREVENT_CLOSE_CLASS), + arrowRight = mfp.arrowRight = $( markup.replace(/%title%/gi, gSt.tNext).replace(/%dir%/gi, 'right') ).addClass(PREVENT_CLOSE_CLASS); + + arrowLeft.click(function() { + mfp.prev(); + }); + arrowRight.click(function() { + mfp.next(); + }); + + mfp.container.append(arrowLeft.add(arrowRight)); + } + }); + + _mfpOn(CHANGE_EVENT+ns, function() { + if(mfp._preloadTimeout) clearTimeout(mfp._preloadTimeout); + + mfp._preloadTimeout = setTimeout(function() { + mfp.preloadNearbyImages(); + mfp._preloadTimeout = null; + }, 16); + }); + + + _mfpOn(CLOSE_EVENT+ns, function() { + _document.off(ns); + mfp.wrap.off('click'+ns); + mfp.arrowRight = mfp.arrowLeft = null; + }); + + }, + next: function() { + mfp.direction = true; + mfp.index = _getLoopedId(mfp.index + 1); + mfp.updateItemHTML(); + }, + prev: function() { + mfp.direction = false; + mfp.index = _getLoopedId(mfp.index - 1); + mfp.updateItemHTML(); + }, + goTo: function(newIndex) { + mfp.direction = (newIndex >= mfp.index); + mfp.index = newIndex; + mfp.updateItemHTML(); + }, + preloadNearbyImages: function() { + var p = mfp.st.gallery.preload, + preloadBefore = Math.min(p[0], mfp.items.length), + preloadAfter = Math.min(p[1], mfp.items.length), + i; + + for(i = 1; i <= (mfp.direction ? preloadAfter : preloadBefore); i++) { + mfp._preloadItem(mfp.index+i); + } + for(i = 1; i <= (mfp.direction ? preloadBefore : preloadAfter); i++) { + mfp._preloadItem(mfp.index-i); + } + }, + _preloadItem: function(index) { + index = _getLoopedId(index); + + if(mfp.items[index].preloaded) { + return; + } + + var item = mfp.items[index]; + if(!item.parsed) { + item = mfp.parseEl( index ); + } + + _mfpTrigger('LazyLoad', item); + + if(item.type === 'image') { + item.img = $('').on('load.mfploader', function() { + item.hasSize = true; + }).on('error.mfploader', function() { + item.hasSize = true; + item.loadError = true; + _mfpTrigger('LazyLoadError', item); + }).attr('src', item.src); + } + + + item.preloaded = true; + } + } +}); + +/*>>gallery*/ + +/*>>retina*/ + +var RETINA_NS = 'retina'; + +$.magnificPopup.registerModule(RETINA_NS, { + options: { + replaceSrc: function(item) { + return item.src.replace(/\.\w+$/, function(m) { return '@2x' + m; }); + }, + ratio: 1 // Function or number. Set to 1 to disable. + }, + proto: { + initRetina: function() { + if(window.devicePixelRatio > 1) { + + var st = mfp.st.retina, + ratio = st.ratio; + + ratio = !isNaN(ratio) ? ratio : ratio(); + + if(ratio > 1) { + _mfpOn('ImageHasSize' + '.' + RETINA_NS, function(e, item) { + item.img.css({ + 'max-width': item.img[0].naturalWidth / ratio, + 'width': '100%' + }); + }); + _mfpOn('ElementParse' + '.' + RETINA_NS, function(e, item) { + item.src = st.replaceSrc(item, ratio); + }); + } + } + + } + } +}); + +/*>>retina*/ + _checkInstance(); })); \ No newline at end of file diff --git a/vendor/assets/magnific-popup/jquery.magnific-popup.min.js b/vendor/assets/magnific-popup/jquery.magnific-popup.min.js new file mode 100755 index 0000000..6ee3a3b --- /dev/null +++ b/vendor/assets/magnific-popup/jquery.magnific-popup.min.js @@ -0,0 +1,4 @@ +/*! Magnific Popup - v1.1.0 - 2016-02-20 +* http://dimsemenov.com/plugins/magnific-popup/ +* Copyright (c) 2016 Dmitry Semenov; */ +!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):window.jQuery||window.Zepto)}(function(a){var b,c,d,e,f,g,h="Close",i="BeforeClose",j="AfterClose",k="BeforeAppend",l="MarkupParse",m="Open",n="Change",o="mfp",p="."+o,q="mfp-ready",r="mfp-removing",s="mfp-prevent-close",t=function(){},u=!!window.jQuery,v=a(window),w=function(a,c){b.ev.on(o+a+p,c)},x=function(b,c,d,e){var f=document.createElement("div");return f.className="mfp-"+b,d&&(f.innerHTML=d),e?c&&c.appendChild(f):(f=a(f),c&&f.appendTo(c)),f},y=function(c,d){b.ev.triggerHandler(o+c,d),b.st.callbacks&&(c=c.charAt(0).toLowerCase()+c.slice(1),b.st.callbacks[c]&&b.st.callbacks[c].apply(b,a.isArray(d)?d:[d]))},z=function(c){return c===g&&b.currTemplate.closeBtn||(b.currTemplate.closeBtn=a(b.st.closeMarkup.replace("%title%",b.st.tClose)),g=c),b.currTemplate.closeBtn},A=function(){a.magnificPopup.instance||(b=new t,b.init(),a.magnificPopup.instance=b)},B=function(){var a=document.createElement("p").style,b=["ms","O","Moz","Webkit"];if(void 0!==a.transition)return!0;for(;b.length;)if(b.pop()+"Transition"in a)return!0;return!1};t.prototype={constructor:t,init:function(){var c=navigator.appVersion;b.isLowIE=b.isIE8=document.all&&!document.addEventListener,b.isAndroid=/android/gi.test(c),b.isIOS=/iphone|ipad|ipod/gi.test(c),b.supportsTransition=B(),b.probablyMobile=b.isAndroid||b.isIOS||/(Opera Mini)|Kindle|webOS|BlackBerry|(Opera Mobi)|(Windows Phone)|IEMobile/i.test(navigator.userAgent),d=a(document),b.popupsCache={}},open:function(c){var e;if(c.isObj===!1){b.items=c.items.toArray(),b.index=0;var g,h=c.items;for(e=0;e(a||v.height())},_setFocus:function(){(b.st.focus?b.content.find(b.st.focus).eq(0):b.wrap).focus()},_onFocusIn:function(c){return c.target===b.wrap[0]||a.contains(b.wrap[0],c.target)?void 0:(b._setFocus(),!1)},_parseMarkup:function(b,c,d){var e;d.data&&(c=a.extend(d.data,c)),y(l,[b,c,d]),a.each(c,function(c,d){if(void 0===d||d===!1)return!0;if(e=c.split("_"),e.length>1){var f=b.find(p+"-"+e[0]);if(f.length>0){var g=e[1];"replaceWith"===g?f[0]!==d[0]&&f.replaceWith(d):"img"===g?f.is("img")?f.attr("src",d):f.replaceWith(a("").attr("src",d).attr("class",f.attr("class"))):f.attr(e[1],d)}}else b.find(p+"-"+c).html(d)})},_getScrollbarSize:function(){if(void 0===b.scrollbarSize){var a=document.createElement("div");a.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(a),b.scrollbarSize=a.offsetWidth-a.clientWidth,document.body.removeChild(a)}return b.scrollbarSize}},a.magnificPopup={instance:null,proto:t.prototype,modules:[],open:function(b,c){return A(),b=b?a.extend(!0,{},b):{},b.isObj=!0,b.index=c||0,this.instance.open(b)},close:function(){return a.magnificPopup.instance&&a.magnificPopup.instance.close()},registerModule:function(b,c){c.options&&(a.magnificPopup.defaults[b]=c.options),a.extend(this.proto,c.proto),this.modules.push(b)},defaults:{disableOn:0,key:null,midClick:!1,mainClass:"",preloader:!0,focus:"",closeOnContentClick:!1,closeOnBgClick:!0,closeBtnInside:!0,showCloseBtn:!0,enableEscapeKey:!0,modal:!1,alignTop:!1,removalDelay:0,prependTo:null,fixedContentPos:"auto",fixedBgPos:"auto",overflowY:"auto",closeMarkup:'',tClose:"Close (Esc)",tLoading:"Loading...",autoFocusLast:!0}},a.fn.magnificPopup=function(c){A();var d=a(this);if("string"==typeof c)if("open"===c){var e,f=u?d.data("magnificPopup"):d[0].magnificPopup,g=parseInt(arguments[1],10)||0;f.items?e=f.items[g]:(e=d,f.delegate&&(e=e.find(f.delegate)),e=e.eq(g)),b._openClick({mfpEl:e},d,f)}else b.isOpen&&b[c].apply(b,Array.prototype.slice.call(arguments,1));else c=a.extend(!0,{},c),u?d.data("magnificPopup",c):d[0].magnificPopup=c,b.addGroup(d,c);return d};var C,D,E,F="inline",G=function(){E&&(D.after(E.addClass(C)).detach(),E=null)};a.magnificPopup.registerModule(F,{options:{hiddenClass:"hide",markup:"",tNotFound:"Content not found"},proto:{initInline:function(){b.types.push(F),w(h+"."+F,function(){G()})},getInline:function(c,d){if(G(),c.src){var e=b.st.inline,f=a(c.src);if(f.length){var g=f[0].parentNode;g&&g.tagName&&(D||(C=e.hiddenClass,D=x(C),C="mfp-"+C),E=f.after(D).detach().removeClass(C)),b.updateStatus("ready")}else b.updateStatus("error",e.tNotFound),f=a("
");return c.inlineElement=f,f}return b.updateStatus("ready"),b._parseMarkup(d,{},c),d}}});var H,I="ajax",J=function(){H&&a(document.body).removeClass(H)},K=function(){J(),b.req&&b.req.abort()};a.magnificPopup.registerModule(I,{options:{settings:null,cursor:"mfp-ajax-cur",tError:'The content could not be loaded.'},proto:{initAjax:function(){b.types.push(I),H=b.st.ajax.cursor,w(h+"."+I,K),w("BeforeChange."+I,K)},getAjax:function(c){H&&a(document.body).addClass(H),b.updateStatus("loading");var d=a.extend({url:c.src,success:function(d,e,f){var g={data:d,xhr:f};y("ParseAjax",g),b.appendContent(a(g.data),I),c.finished=!0,J(),b._setFocus(),setTimeout(function(){b.wrap.addClass(q)},16),b.updateStatus("ready"),y("AjaxContentAdded")},error:function(){J(),c.finished=c.loadError=!0,b.updateStatus("error",b.st.ajax.tError.replace("%url%",c.src))}},b.st.ajax.settings);return b.req=a.ajax(d),""}}});var L,M=function(c){if(c.data&&void 0!==c.data.title)return c.data.title;var d=b.st.image.titleSrc;if(d){if(a.isFunction(d))return d.call(b,c);if(c.el)return c.el.attr(d)||""}return""};a.magnificPopup.registerModule("image",{options:{markup:'
',cursor:"mfp-zoom-out-cur",titleSrc:"title",verticalFit:!0,tError:'The image could not be loaded.'},proto:{initImage:function(){var c=b.st.image,d=".image";b.types.push("image"),w(m+d,function(){"image"===b.currItem.type&&c.cursor&&a(document.body).addClass(c.cursor)}),w(h+d,function(){c.cursor&&a(document.body).removeClass(c.cursor),v.off("resize"+p)}),w("Resize"+d,b.resizeImage),b.isLowIE&&w("AfterChange",b.resizeImage)},resizeImage:function(){var a=b.currItem;if(a&&a.img&&b.st.image.verticalFit){var c=0;b.isLowIE&&(c=parseInt(a.img.css("padding-top"),10)+parseInt(a.img.css("padding-bottom"),10)),a.img.css("max-height",b.wH-c)}},_onImageHasSize:function(a){a.img&&(a.hasSize=!0,L&&clearInterval(L),a.isCheckingImgSize=!1,y("ImageHasSize",a),a.imgHidden&&(b.content&&b.content.removeClass("mfp-loading"),a.imgHidden=!1))},findImageSize:function(a){var c=0,d=a.img[0],e=function(f){L&&clearInterval(L),L=setInterval(function(){return d.naturalWidth>0?void b._onImageHasSize(a):(c>200&&clearInterval(L),c++,void(3===c?e(10):40===c?e(50):100===c&&e(500)))},f)};e(1)},getImage:function(c,d){var e=0,f=function(){c&&(c.img[0].complete?(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("ready")),c.hasSize=!0,c.loaded=!0,y("ImageLoadComplete")):(e++,200>e?setTimeout(f,100):g()))},g=function(){c&&(c.img.off(".mfploader"),c===b.currItem&&(b._onImageHasSize(c),b.updateStatus("error",h.tError.replace("%url%",c.src))),c.hasSize=!0,c.loaded=!0,c.loadError=!0)},h=b.st.image,i=d.find(".mfp-img");if(i.length){var j=document.createElement("img");j.className="mfp-img",c.el&&c.el.find("img").length&&(j.alt=c.el.find("img").attr("alt")),c.img=a(j).on("load.mfploader",f).on("error.mfploader",g),j.src=c.src,i.is("img")&&(c.img=c.img.clone()),j=c.img[0],j.naturalWidth>0?c.hasSize=!0:j.width||(c.hasSize=!1)}return b._parseMarkup(d,{title:M(c),img_replaceWith:c.img},c),b.resizeImage(),c.hasSize?(L&&clearInterval(L),c.loadError?(d.addClass("mfp-loading"),b.updateStatus("error",h.tError.replace("%url%",c.src))):(d.removeClass("mfp-loading"),b.updateStatus("ready")),d):(b.updateStatus("loading"),c.loading=!0,c.hasSize||(c.imgHidden=!0,d.addClass("mfp-loading"),b.findImageSize(c)),d)}}});var N,O=function(){return void 0===N&&(N=void 0!==document.createElement("p").style.MozTransform),N};a.magnificPopup.registerModule("zoom",{options:{enabled:!1,easing:"ease-in-out",duration:300,opener:function(a){return a.is("img")?a:a.find("img")}},proto:{initZoom:function(){var a,c=b.st.zoom,d=".zoom";if(c.enabled&&b.supportsTransition){var e,f,g=c.duration,j=function(a){var b=a.clone().removeAttr("style").removeAttr("class").addClass("mfp-animated-image"),d="all "+c.duration/1e3+"s "+c.easing,e={position:"fixed",zIndex:9999,left:0,top:0,"-webkit-backface-visibility":"hidden"},f="transition";return e["-webkit-"+f]=e["-moz-"+f]=e["-o-"+f]=e[f]=d,b.css(e),b},k=function(){b.content.css("visibility","visible")};w("BuildControls"+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.content.css("visibility","hidden"),a=b._getItemToZoom(),!a)return void k();f=j(a),f.css(b._getOffset()),b.wrap.append(f),e=setTimeout(function(){f.css(b._getOffset(!0)),e=setTimeout(function(){k(),setTimeout(function(){f.remove(),a=f=null,y("ZoomAnimationEnded")},16)},g)},16)}}),w(i+d,function(){if(b._allowZoom()){if(clearTimeout(e),b.st.removalDelay=g,!a){if(a=b._getItemToZoom(),!a)return;f=j(a)}f.css(b._getOffset(!0)),b.wrap.append(f),b.content.css("visibility","hidden"),setTimeout(function(){f.css(b._getOffset())},16)}}),w(h+d,function(){b._allowZoom()&&(k(),f&&f.remove(),a=null)})}},_allowZoom:function(){return"image"===b.currItem.type},_getItemToZoom:function(){return b.currItem.hasSize?b.currItem.img:!1},_getOffset:function(c){var d;d=c?b.currItem.img:b.st.zoom.opener(b.currItem.el||b.currItem);var e=d.offset(),f=parseInt(d.css("padding-top"),10),g=parseInt(d.css("padding-bottom"),10);e.top-=a(window).scrollTop()-f;var h={width:d.width(),height:(u?d.innerHeight():d[0].offsetHeight)-g-f};return O()?h["-moz-transform"]=h.transform="translate("+e.left+"px,"+e.top+"px)":(h.left=e.left,h.top=e.top),h}}});var P="iframe",Q="//about:blank",R=function(a){if(b.currTemplate[P]){var c=b.currTemplate[P].find("iframe");c.length&&(a||(c[0].src=Q),b.isIE8&&c.css("display",a?"block":"none"))}};a.magnificPopup.registerModule(P,{options:{markup:'
',srcAction:"iframe_src",patterns:{youtube:{index:"youtube.com",id:"v=",src:"//www.youtube.com/embed/%id%?autoplay=1"},vimeo:{index:"vimeo.com/",id:"/",src:"//player.vimeo.com/video/%id%?autoplay=1"},gmaps:{index:"//maps.google.",src:"%id%&output=embed"}}},proto:{initIframe:function(){b.types.push(P),w("BeforeChange",function(a,b,c){b!==c&&(b===P?R():c===P&&R(!0))}),w(h+"."+P,function(){R()})},getIframe:function(c,d){var e=c.src,f=b.st.iframe;a.each(f.patterns,function(){return e.indexOf(this.index)>-1?(this.id&&(e="string"==typeof this.id?e.substr(e.lastIndexOf(this.id)+this.id.length,e.length):this.id.call(this,e)),e=this.src.replace("%id%",e),!1):void 0});var g={};return f.srcAction&&(g[f.srcAction]=e),b._parseMarkup(d,g,c),b.updateStatus("ready"),d}}});var S=function(a){var c=b.items.length;return a>c-1?a-c:0>a?c+a:a},T=function(a,b,c){return a.replace(/%curr%/gi,b+1).replace(/%total%/gi,c)};a.magnificPopup.registerModule("gallery",{options:{enabled:!1,arrowMarkup:'',preload:[0,2],navigateByImgClick:!0,arrows:!0,tPrev:"Previous (Left arrow key)",tNext:"Next (Right arrow key)",tCounter:"%curr% of %total%"},proto:{initGallery:function(){var c=b.st.gallery,e=".mfp-gallery";return b.direction=!0,c&&c.enabled?(f+=" mfp-gallery",w(m+e,function(){c.navigateByImgClick&&b.wrap.on("click"+e,".mfp-img",function(){return b.items.length>1?(b.next(),!1):void 0}),d.on("keydown"+e,function(a){37===a.keyCode?b.prev():39===a.keyCode&&b.next()})}),w("UpdateStatus"+e,function(a,c){c.text&&(c.text=T(c.text,b.currItem.index,b.items.length))}),w(l+e,function(a,d,e,f){var g=b.items.length;e.counter=g>1?T(c.tCounter,f.index,g):""}),w("BuildControls"+e,function(){if(b.items.length>1&&c.arrows&&!b.arrowLeft){var d=c.arrowMarkup,e=b.arrowLeft=a(d.replace(/%title%/gi,c.tPrev).replace(/%dir%/gi,"left")).addClass(s),f=b.arrowRight=a(d.replace(/%title%/gi,c.tNext).replace(/%dir%/gi,"right")).addClass(s);e.click(function(){b.prev()}),f.click(function(){b.next()}),b.container.append(e.add(f))}}),w(n+e,function(){b._preloadTimeout&&clearTimeout(b._preloadTimeout),b._preloadTimeout=setTimeout(function(){b.preloadNearbyImages(),b._preloadTimeout=null},16)}),void w(h+e,function(){d.off(e),b.wrap.off("click"+e),b.arrowRight=b.arrowLeft=null})):!1},next:function(){b.direction=!0,b.index=S(b.index+1),b.updateItemHTML()},prev:function(){b.direction=!1,b.index=S(b.index-1),b.updateItemHTML()},goTo:function(a){b.direction=a>=b.index,b.index=a,b.updateItemHTML()},preloadNearbyImages:function(){var a,c=b.st.gallery.preload,d=Math.min(c[0],b.items.length),e=Math.min(c[1],b.items.length);for(a=1;a<=(b.direction?e:d);a++)b._preloadItem(b.index+a);for(a=1;a<=(b.direction?d:e);a++)b._preloadItem(b.index-a)},_preloadItem:function(c){if(c=S(c),!b.items[c].preloaded){var d=b.items[c];d.parsed||(d=b.parseEl(c)),y("LazyLoad",d),"image"===d.type&&(d.img=a('').on("load.mfploader",function(){d.hasSize=!0}).on("error.mfploader",function(){d.hasSize=!0,d.loadError=!0,y("LazyLoadError",d)}).attr("src",d.src)),d.preloaded=!0}}}});var U="retina";a.magnificPopup.registerModule(U,{options:{replaceSrc:function(a){return a.src.replace(/\.\w+$/,function(a){return"@2x"+a})},ratio:1},proto:{initRetina:function(){if(window.devicePixelRatio>1){var a=b.st.retina,c=a.ratio;c=isNaN(c)?c():c,c>1&&(w("ImageHasSize."+U,function(a,b){b.img.css({"max-width":b.img[0].naturalWidth/c,width:"100%"})}),w("ElementParse."+U,function(b,d){d.src=a.replaceSrc(d,c)}))}}}}),A()}); \ No newline at end of file diff --git a/vendor/assets/magnific-popup/magnific-popup.css b/vendor/assets/magnific-popup/magnific-popup.css new file mode 100755 index 0000000..8561e18 --- /dev/null +++ b/vendor/assets/magnific-popup/magnific-popup.css @@ -0,0 +1,351 @@ +/* Magnific Popup CSS */ +.mfp-bg { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1042; + overflow: hidden; + position: fixed; + background: #0b0b0b; + opacity: 0.8; } + +.mfp-wrap { + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1043; + position: fixed; + outline: none !important; + -webkit-backface-visibility: hidden; } + +.mfp-container { + text-align: center; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + padding: 0 8px; + box-sizing: border-box; } + +.mfp-container:before { + content: ''; + display: inline-block; + height: 100%; + vertical-align: middle; } + +.mfp-align-top .mfp-container:before { + display: none; } + +.mfp-content { + position: relative; + display: inline-block; + vertical-align: middle; + margin: 0 auto; + text-align: left; + z-index: 1045; } + +.mfp-inline-holder .mfp-content, +.mfp-ajax-holder .mfp-content { + width: 100%; + cursor: auto; } + +.mfp-ajax-cur { + cursor: progress; } + +.mfp-zoom-out-cur, .mfp-zoom-out-cur .mfp-image-holder .mfp-close { + cursor: -moz-zoom-out; + cursor: -webkit-zoom-out; + cursor: zoom-out; } + +.mfp-zoom { + cursor: pointer; + cursor: -webkit-zoom-in; + cursor: -moz-zoom-in; + cursor: zoom-in; } + +.mfp-auto-cursor .mfp-content { + cursor: auto; } + +.mfp-close, +.mfp-arrow, +.mfp-preloader, +.mfp-counter { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; } + +.mfp-loading.mfp-figure { + display: none; } + +.mfp-hide { + display: none !important; } + +.mfp-preloader { + color: #CCC; + position: absolute; + top: 50%; + width: auto; + text-align: center; + margin-top: -0.8em; + left: 8px; + right: 8px; + z-index: 1044; } + .mfp-preloader a { + color: #CCC; } + .mfp-preloader a:hover { + color: #FFF; } + +.mfp-s-ready .mfp-preloader { + display: none; } + +.mfp-s-error .mfp-content { + display: none; } + +button.mfp-close, +button.mfp-arrow { + overflow: visible; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; + display: block; + outline: none; + padding: 0; + z-index: 1046; + box-shadow: none; + touch-action: manipulation; } + +button::-moz-focus-inner { + padding: 0; + border: 0; } + +.mfp-close { + width: 44px; + height: 44px; + line-height: 44px; + position: absolute; + right: 0; + top: 0; + text-decoration: none; + text-align: center; + opacity: 0.65; + padding: 0 0 18px 10px; + color: #FFF; + font-style: normal; + font-size: 28px; + font-family: Arial, Baskerville, monospace; } + .mfp-close:hover, + .mfp-close:focus { + opacity: 1; } + .mfp-close:active { + top: 1px; } + +.mfp-close-btn-in .mfp-close { + color: #333; } + +.mfp-image-holder .mfp-close, +.mfp-iframe-holder .mfp-close { + color: #FFF; + right: -6px; + text-align: right; + padding-right: 6px; + width: 100%; } + +.mfp-counter { + position: absolute; + top: 0; + right: 0; + color: #CCC; + font-size: 12px; + line-height: 18px; + white-space: nowrap; } + +.mfp-arrow { + position: absolute; + opacity: 0.65; + margin: 0; + top: 50%; + margin-top: -55px; + padding: 0; + width: 90px; + height: 110px; + -webkit-tap-highlight-color: transparent; } + .mfp-arrow:active { + margin-top: -54px; } + .mfp-arrow:hover, + .mfp-arrow:focus { + opacity: 1; } + .mfp-arrow:before, + .mfp-arrow:after { + content: ''; + display: block; + width: 0; + height: 0; + position: absolute; + left: 0; + top: 0; + margin-top: 35px; + margin-left: 35px; + border: medium inset transparent; } + .mfp-arrow:after { + border-top-width: 13px; + border-bottom-width: 13px; + top: 8px; } + .mfp-arrow:before { + border-top-width: 21px; + border-bottom-width: 21px; + opacity: 0.7; } + +.mfp-arrow-left { + left: 0; } + .mfp-arrow-left:after { + border-right: 17px solid #FFF; + margin-left: 31px; } + .mfp-arrow-left:before { + margin-left: 25px; + border-right: 27px solid #3F3F3F; } + +.mfp-arrow-right { + right: 0; } + .mfp-arrow-right:after { + border-left: 17px solid #FFF; + margin-left: 39px; } + .mfp-arrow-right:before { + border-left: 27px solid #3F3F3F; } + +.mfp-iframe-holder { + padding-top: 40px; + padding-bottom: 40px; } + .mfp-iframe-holder .mfp-content { + line-height: 0; + width: 100%; + max-width: 900px; } + .mfp-iframe-holder .mfp-close { + top: -40px; } + +.mfp-iframe-scaler { + width: 100%; + height: 0; + overflow: hidden; + padding-top: 56.25%; } + .mfp-iframe-scaler iframe { + position: absolute; + display: block; + top: 0; + left: 0; + width: 100%; + height: 100%; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: #000; } + +/* Main image in popup */ +img.mfp-img { + width: auto; + max-width: 100%; + height: auto; + display: block; + line-height: 0; + box-sizing: border-box; + padding: 40px 0 40px; + margin: 0 auto; } + +/* The shadow behind the image */ +.mfp-figure { + line-height: 0; } + .mfp-figure:after { + content: ''; + position: absolute; + left: 0; + top: 40px; + bottom: 40px; + display: block; + right: 0; + width: auto; + height: auto; + z-index: -1; + box-shadow: 0 0 8px rgba(0, 0, 0, 0.6); + background: #444; } + .mfp-figure small { + color: #BDBDBD; + display: block; + font-size: 12px; + line-height: 14px; } + .mfp-figure figure { + margin: 0; } + +.mfp-bottom-bar { + margin-top: -36px; + position: absolute; + top: 100%; + left: 0; + width: 100%; + cursor: auto; } + +.mfp-title { + text-align: left; + line-height: 18px; + color: #F3F3F3; + word-wrap: break-word; + padding-right: 36px; } + +.mfp-image-holder .mfp-content { + max-width: 100%; } + +.mfp-gallery .mfp-image-holder .mfp-figure { + cursor: pointer; } + +@media screen and (max-width: 800px) and (orientation: landscape), screen and (max-height: 300px) { + /** + * Remove all paddings around the image on small screen + */ + .mfp-img-mobile .mfp-image-holder { + padding-left: 0; + padding-right: 0; } + .mfp-img-mobile img.mfp-img { + padding: 0; } + .mfp-img-mobile .mfp-figure:after { + top: 0; + bottom: 0; } + .mfp-img-mobile .mfp-figure small { + display: inline; + margin-left: 5px; } + .mfp-img-mobile .mfp-bottom-bar { + background: rgba(0, 0, 0, 0.6); + bottom: 0; + margin: 0; + top: auto; + padding: 3px 5px; + position: fixed; + box-sizing: border-box; } + .mfp-img-mobile .mfp-bottom-bar:empty { + padding: 0; } + .mfp-img-mobile .mfp-counter { + right: 5px; + top: 3px; } + .mfp-img-mobile .mfp-close { + top: 0; + right: 0; + width: 35px; + height: 35px; + line-height: 35px; + background: rgba(0, 0, 0, 0.6); + position: fixed; + text-align: center; + padding: 0; } } + +@media all and (max-width: 900px) { + .mfp-arrow { + -webkit-transform: scale(0.75); + transform: scale(0.75); } + .mfp-arrow-left { + -webkit-transform-origin: 0; + transform-origin: 0; } + .mfp-arrow-right { + -webkit-transform-origin: 100%; + transform-origin: 100%; } + .mfp-container { + padding-left: 6px; + padding-right: 6px; } } diff --git a/vendor/assets/scrollreveal/scrollreveal.js b/vendor/assets/scrollreveal/scrollreveal.js new file mode 100755 index 0000000..798aa2e --- /dev/null +++ b/vendor/assets/scrollreveal/scrollreveal.js @@ -0,0 +1,862 @@ +///// ///// ///// ///// +///// ///// ///// ///// +///// ///// ///// ///// +///// ///// ///// ///// +///// ///// ///// +///// ///// ///// +///// ///// ///// ///// +///// ///// ///// ///// + ///// ///// + ///// ///// +///// ///// ///// ///// +///// ///// ///// ///// +///// ///// ///// ///// +///// ///// ///// ///// + +/** + * ScrollReveal + * ------------ + * Version : 3.4.0 + * Website : scrollrevealjs.org + * Repo : github.com/jlmakes/scrollreveal.js + * Author : Julian Lloyd (@jlmakes) + */ + +;(function () { + 'use strict' + + var sr + var _requestAnimationFrame + + function ScrollReveal (config) { + // Support instantiation without the `new` keyword. + if (typeof this === 'undefined' || Object.getPrototypeOf(this) !== ScrollReveal.prototype) { + return new ScrollReveal(config) + } + + sr = this // Save reference to instance. + sr.version = '3.4.0' + sr.tools = new Tools() // *required utilities + + if (sr.isSupported()) { + sr.tools.extend(sr.defaults, config || {}) + + sr.defaults.container = _resolveContainer(sr.defaults) + + sr.store = { + elements: {}, + containers: [] + } + + sr.sequences = {} + sr.history = [] + sr.uid = 0 + sr.initialized = false + } else if (typeof console !== 'undefined' && console !== null) { + // Note: IE9 only supports console if devtools are open. + console.log('ScrollReveal is not supported in this browser.') + } + + return sr + } + + /** + * Configuration + * ------------- + * This object signature can be passed directly to the ScrollReveal constructor, + * or as the second argument of the `reveal()` method. + */ + + ScrollReveal.prototype.defaults = { + // 'bottom', 'left', 'top', 'right' + origin: 'bottom', + + // Can be any valid CSS distance, e.g. '5rem', '10%', '20vw', etc. + distance: '20px', + + // Time in milliseconds. + duration: 500, + delay: 0, + + // Starting angles in degrees, will transition from these values to 0 in all axes. + rotate: { x: 0, y: 0, z: 0 }, + + // Starting opacity value, before transitioning to the computed opacity. + opacity: 0, + + // Starting scale value, will transition from this value to 1 + scale: 0.9, + + // Accepts any valid CSS easing, e.g. 'ease', 'ease-in-out', 'linear', etc. + easing: 'cubic-bezier(0.6, 0.2, 0.1, 1)', + + // `` is the default reveal container. You can pass either: + // DOM Node, e.g. document.querySelector('.fooContainer') + // Selector, e.g. '.fooContainer' + container: window.document.documentElement, + + // true/false to control reveal animations on mobile. + mobile: true, + + // true: reveals occur every time elements become visible + // false: reveals occur once as elements become visible + reset: false, + + // 'always' — delay for all reveal animations + // 'once' — delay only the first time reveals occur + // 'onload' - delay only for animations triggered by first load + useDelay: 'always', + + // Change when an element is considered in the viewport. The default value + // of 0.20 means 20% of an element must be visible for its reveal to occur. + viewFactor: 0.2, + + // Pixel values that alter the container boundaries. + // e.g. Set `{ top: 48 }`, if you have a 48px tall fixed toolbar. + // -- + // Visual Aid: https://scrollrevealjs.org/assets/viewoffset.png + viewOffset: { top: 0, right: 0, bottom: 0, left: 0 }, + + // Callbacks that fire for each triggered element reveal, and reset. + beforeReveal: function (domEl) {}, + beforeReset: function (domEl) {}, + + // Callbacks that fire for each completed element reveal, and reset. + afterReveal: function (domEl) {}, + afterReset: function (domEl) {} + } + + /** + * Check if client supports CSS Transform and CSS Transition. + * @return {boolean} + */ + ScrollReveal.prototype.isSupported = function () { + var style = document.documentElement.style + return 'WebkitTransition' in style && 'WebkitTransform' in style || + 'transition' in style && 'transform' in style + } + + /** + * Creates a reveal set, a group of elements that will animate when they + * become visible. If [interval] is provided, a new sequence is created + * that will ensure elements reveal in the order they appear in the DOM. + * + * @param {Node|NodeList|string} [target] The node, node list or selector to use for animation. + * @param {Object} [config] Override the defaults for this reveal set. + * @param {number} [interval] Time between sequenced element animations (milliseconds). + * @param {boolean} [sync] Used internally when updating reveals for async content. + * + * @return {Object} The current ScrollReveal instance. + */ + ScrollReveal.prototype.reveal = function (target, config, interval, sync) { + var container + var elements + var elem + var elemId + var sequence + var sequenceId + + // No custom configuration was passed, but a sequence interval instead. + // let’s shuffle things around to make sure everything works. + if (config !== undefined && typeof config === 'number') { + interval = config + config = {} + } else if (config === undefined || config === null) { + config = {} + } + + container = _resolveContainer(config) + elements = _getRevealElements(target, container) + + if (!elements.length) { + console.log('ScrollReveal: reveal on "' + target + '" failed, no elements found.') + return sr + } + + // Prepare a new sequence if an interval is passed. + if (interval && typeof interval === 'number') { + sequenceId = _nextUid() + + sequence = sr.sequences[sequenceId] = { + id: sequenceId, + interval: interval, + elemIds: [], + active: false + } + } + + // Begin main loop to configure ScrollReveal elements. + for (var i = 0; i < elements.length; i++) { + // Check if the element has already been configured and grab it from the store. + elemId = elements[i].getAttribute('data-sr-id') + if (elemId) { + elem = sr.store.elements[elemId] + } else { + // Otherwise, let’s do some basic setup. + elem = { + id: _nextUid(), + domEl: elements[i], + seen: false, + revealing: false + } + elem.domEl.setAttribute('data-sr-id', elem.id) + } + + // Sequence only setup + if (sequence) { + elem.sequence = { + id: sequence.id, + index: sequence.elemIds.length + } + + sequence.elemIds.push(elem.id) + } + + // New or existing element, it’s time to update its configuration, styles, + // and send the updates to our store. + _configure(elem, config, container) + _style(elem) + _updateStore(elem) + + // We need to make sure elements are set to visibility: visible, even when + // on mobile and `config.mobile === false`, or if unsupported. + if (sr.tools.isMobile() && !elem.config.mobile || !sr.isSupported()) { + elem.domEl.setAttribute('style', elem.styles.inline) + elem.disabled = true + } else if (!elem.revealing) { + // Otherwise, proceed normally. + elem.domEl.setAttribute('style', + elem.styles.inline + + elem.styles.transform.initial + ) + } + } + + // Each `reveal()` is recorded so that when calling `sync()` while working + // with asynchronously loaded content, it can re-trace your steps but with + // all your new elements now in the DOM. + + // Since `reveal()` is called internally by `sync()`, we don’t want to + // record or intiialize each reveal during syncing. + if (!sync && sr.isSupported()) { + _record(target, config, interval) + + // We push initialization to the event queue using setTimeout, so that we can + // give ScrollReveal room to process all reveal calls before putting things into motion. + // -- + // Philip Roberts - What the heck is the event loop anyway? (JSConf EU 2014) + // https://www.youtube.com/watch?v=8aGhZQkoFbQ + if (sr.initTimeout) { + window.clearTimeout(sr.initTimeout) + } + sr.initTimeout = window.setTimeout(_init, 0) + } + + return sr + } + + /** + * Re-runs `reveal()` for each record stored in history, effectively capturing + * any content loaded asynchronously that matches existing reveal set targets. + * @return {Object} The current ScrollReveal instance. + */ + ScrollReveal.prototype.sync = function () { + if (sr.history.length && sr.isSupported()) { + for (var i = 0; i < sr.history.length; i++) { + var record = sr.history[i] + sr.reveal(record.target, record.config, record.interval, true) + } + _init() + } else { + console.log('ScrollReveal: sync failed, no reveals found.') + } + return sr + } + + /** + * Private Methods + * --------------- + */ + + function _resolveContainer (config) { + if (config && config.container) { + if (typeof config.container === 'string') { + return window.document.documentElement.querySelector(config.container) + } else if (sr.tools.isNode(config.container)) { + return config.container + } else { + console.log('ScrollReveal: invalid container "' + config.container + '" provided.') + console.log('ScrollReveal: falling back to default container.') + } + } + return sr.defaults.container + } + + /** + * check to see if a node or node list was passed in as the target, + * otherwise query the container using target as a selector. + * + * @param {Node|NodeList|string} [target] client input for reveal target. + * @param {Node} [container] parent element for selector queries. + * + * @return {array} elements to be revealed. + */ + function _getRevealElements (target, container) { + if (typeof target === 'string') { + return Array.prototype.slice.call(container.querySelectorAll(target)) + } else if (sr.tools.isNode(target)) { + return [target] + } else if (sr.tools.isNodeList(target)) { + return Array.prototype.slice.call(target) + } else if (Array.isArray(target)) { + return target.filter(sr.tools.isNode) + } + return [] + } + + /** + * A consistent way of creating unique IDs. + * @returns {number} + */ + function _nextUid () { + return ++sr.uid + } + + function _configure (elem, config, container) { + // If a container was passed as a part of the config object, + // let’s overwrite it with the resolved container passed in. + if (config.container) config.container = container + // If the element hasn’t already been configured, let’s use a clone of the + // defaults extended by the configuration passed as the second argument. + if (!elem.config) { + elem.config = sr.tools.extendClone(sr.defaults, config) + } else { + // Otherwise, let’s use a clone of the existing element configuration extended + // by the configuration passed as the second argument. + elem.config = sr.tools.extendClone(elem.config, config) + } + + // Infer CSS Transform axis from origin string. + if (elem.config.origin === 'top' || elem.config.origin === 'bottom') { + elem.config.axis = 'Y' + } else { + elem.config.axis = 'X' + } + } + + function _style (elem) { + var computed = window.getComputedStyle(elem.domEl) + + if (!elem.styles) { + elem.styles = { + transition: {}, + transform: {}, + computed: {} + } + + // Capture any existing inline styles, and add our visibility override. + // -- + // See section 4.2. in the Documentation: + // https://github.com/jlmakes/scrollreveal.js#42-improve-user-experience + elem.styles.inline = elem.domEl.getAttribute('style') || '' + elem.styles.inline += '; visibility: visible; ' + + // grab the elements existing opacity. + elem.styles.computed.opacity = computed.opacity + + // grab the elements existing transitions. + if (!computed.transition || computed.transition === 'all 0s ease 0s') { + elem.styles.computed.transition = '' + } else { + elem.styles.computed.transition = computed.transition + ', ' + } + } + + // Create transition styles + elem.styles.transition.instant = _generateTransition(elem, 0) + elem.styles.transition.delayed = _generateTransition(elem, elem.config.delay) + + // Generate transform styles, first with the webkit prefix. + elem.styles.transform.initial = ' -webkit-transform:' + elem.styles.transform.target = ' -webkit-transform:' + _generateTransform(elem) + + // And again without any prefix. + elem.styles.transform.initial += 'transform:' + elem.styles.transform.target += 'transform:' + _generateTransform(elem) + } + + function _generateTransition (elem, delay) { + var config = elem.config + + return '-webkit-transition: ' + elem.styles.computed.transition + + '-webkit-transform ' + config.duration / 1000 + 's ' + + config.easing + ' ' + + delay / 1000 + 's, opacity ' + + config.duration / 1000 + 's ' + + config.easing + ' ' + + delay / 1000 + 's; ' + + + 'transition: ' + elem.styles.computed.transition + + 'transform ' + config.duration / 1000 + 's ' + + config.easing + ' ' + + delay / 1000 + 's, opacity ' + + config.duration / 1000 + 's ' + + config.easing + ' ' + + delay / 1000 + 's; ' + } + + function _generateTransform (elem) { + var config = elem.config + var cssDistance + var transform = elem.styles.transform + + // Let’s make sure our our pixel distances are negative for top and left. + // e.g. origin = 'top' and distance = '25px' starts at `top: -25px` in CSS. + if (config.origin === 'top' || config.origin === 'left') { + cssDistance = /^-/.test(config.distance) + ? config.distance.substr(1) + : '-' + config.distance + } else { + cssDistance = config.distance + } + + if (parseInt(config.distance)) { + transform.initial += ' translate' + config.axis + '(' + cssDistance + ')' + transform.target += ' translate' + config.axis + '(0)' + } + if (config.scale) { + transform.initial += ' scale(' + config.scale + ')' + transform.target += ' scale(1)' + } + if (config.rotate.x) { + transform.initial += ' rotateX(' + config.rotate.x + 'deg)' + transform.target += ' rotateX(0)' + } + if (config.rotate.y) { + transform.initial += ' rotateY(' + config.rotate.y + 'deg)' + transform.target += ' rotateY(0)' + } + if (config.rotate.z) { + transform.initial += ' rotateZ(' + config.rotate.z + 'deg)' + transform.target += ' rotateZ(0)' + } + transform.initial += '; opacity: ' + config.opacity + ';' + transform.target += '; opacity: ' + elem.styles.computed.opacity + ';' + } + + function _updateStore (elem) { + var container = elem.config.container + + // If this element’s container isn’t already in the store, let’s add it. + if (container && sr.store.containers.indexOf(container) === -1) { + sr.store.containers.push(elem.config.container) + } + + // Update the element stored with our new element. + sr.store.elements[elem.id] = elem + } + + function _record (target, config, interval) { + // Save the `reveal()` arguments that triggered this `_record()` call, so we + // can re-trace our steps when calling the `sync()` method. + var record = { + target: target, + config: config, + interval: interval + } + sr.history.push(record) + } + + function _init () { + if (sr.isSupported()) { + // Initial animate call triggers valid reveal animations on first load. + // Subsequent animate calls are made inside the event handler. + _animate() + + // Then we loop through all container nodes in the store and bind event + // listeners to each. + for (var i = 0; i < sr.store.containers.length; i++) { + sr.store.containers[i].addEventListener('scroll', _handler) + sr.store.containers[i].addEventListener('resize', _handler) + } + + // Let’s also do a one-time binding of window event listeners. + if (!sr.initialized) { + window.addEventListener('scroll', _handler) + window.addEventListener('resize', _handler) + sr.initialized = true + } + } + return sr + } + + function _handler () { + _requestAnimationFrame(_animate) + } + + function _setActiveSequences () { + var active + var elem + var elemId + var sequence + + // Loop through all sequences + sr.tools.forOwn(sr.sequences, function (sequenceId) { + sequence = sr.sequences[sequenceId] + active = false + + // For each sequenced elemenet, let’s check visibility and if + // any are visible, set it’s sequence to active. + for (var i = 0; i < sequence.elemIds.length; i++) { + elemId = sequence.elemIds[i] + elem = sr.store.elements[elemId] + if (_isElemVisible(elem) && !active) { + active = true + } + } + + sequence.active = active + }) + } + + function _animate () { + var delayed + var elem + + _setActiveSequences() + + // Loop through all elements in the store + sr.tools.forOwn(sr.store.elements, function (elemId) { + elem = sr.store.elements[elemId] + delayed = _shouldUseDelay(elem) + + // Let’s see if we should revealand if so, + // trigger the `beforeReveal` callback and + // determine whether or not to use delay. + if (_shouldReveal(elem)) { + elem.config.beforeReveal(elem.domEl) + if (delayed) { + elem.domEl.setAttribute('style', + elem.styles.inline + + elem.styles.transform.target + + elem.styles.transition.delayed + ) + } else { + elem.domEl.setAttribute('style', + elem.styles.inline + + elem.styles.transform.target + + elem.styles.transition.instant + ) + } + + // Let’s queue the `afterReveal` callback + // and mark the element as seen and revealing. + _queueCallback('reveal', elem, delayed) + elem.revealing = true + elem.seen = true + + if (elem.sequence) { + _queueNextInSequence(elem, delayed) + } + } else if (_shouldReset(elem)) { + //Otherwise reset our element and + // trigger the `beforeReset` callback. + elem.config.beforeReset(elem.domEl) + elem.domEl.setAttribute('style', + elem.styles.inline + + elem.styles.transform.initial + + elem.styles.transition.instant + ) + // And queue the `afterReset` callback. + _queueCallback('reset', elem) + elem.revealing = false + } + }) + } + + function _queueNextInSequence (elem, delayed) { + var elapsed = 0 + var delay = 0 + var sequence = sr.sequences[elem.sequence.id] + + // We’re processing a sequenced element, so let's block other elements in this sequence. + sequence.blocked = true + + // Since we’re triggering animations a part of a sequence after animations on first load, + // we need to check for that condition and explicitly add the delay to our timer. + if (delayed && elem.config.useDelay === 'onload') { + delay = elem.config.delay + } + + // If a sequence timer is already running, capture the elapsed time and clear it. + if (elem.sequence.timer) { + elapsed = Math.abs(elem.sequence.timer.started - new Date()) + window.clearTimeout(elem.sequence.timer) + } + + // Start a new timer. + elem.sequence.timer = { started: new Date() } + elem.sequence.timer.clock = window.setTimeout(function () { + // Sequence interval has passed, so unblock the sequence and re-run the handler. + sequence.blocked = false + elem.sequence.timer = null + _handler() + }, Math.abs(sequence.interval) + delay - elapsed) + } + + function _queueCallback (type, elem, delayed) { + var elapsed = 0 + var duration = 0 + var callback = 'after' + + // Check which callback we’re working with. + switch (type) { + case 'reveal': + duration = elem.config.duration + if (delayed) { + duration += elem.config.delay + } + callback += 'Reveal' + break + + case 'reset': + duration = elem.config.duration + callback += 'Reset' + break + } + + // If a timer is already running, capture the elapsed time and clear it. + if (elem.timer) { + elapsed = Math.abs(elem.timer.started - new Date()) + window.clearTimeout(elem.timer.clock) + } + + // Start a new timer. + elem.timer = { started: new Date() } + elem.timer.clock = window.setTimeout(function () { + // The timer completed, so let’s fire the callback and null the timer. + elem.config[callback](elem.domEl) + elem.timer = null + }, duration - elapsed) + } + + function _shouldReveal (elem) { + if (elem.sequence) { + var sequence = sr.sequences[elem.sequence.id] + return sequence.active && + !sequence.blocked && + !elem.revealing && + !elem.disabled + } + return _isElemVisible(elem) && + !elem.revealing && + !elem.disabled + } + + function _shouldUseDelay (elem) { + var config = elem.config.useDelay + return config === 'always' || + (config === 'onload' && !sr.initialized) || + (config === 'once' && !elem.seen) + } + + function _shouldReset (elem) { + if (elem.sequence) { + var sequence = sr.sequences[elem.sequence.id] + return !sequence.active && + elem.config.reset && + elem.revealing && + !elem.disabled + } + return !_isElemVisible(elem) && + elem.config.reset && + elem.revealing && + !elem.disabled + } + + function _getContainer (container) { + return { + width: container.clientWidth, + height: container.clientHeight + } + } + + function _getScrolled (container) { + // Return the container scroll values, plus the its offset. + if (container && container !== window.document.documentElement) { + var offset = _getOffset(container) + return { + x: container.scrollLeft + offset.left, + y: container.scrollTop + offset.top + } + } else { + // Otherwise, default to the window object’s scroll values. + return { + x: window.pageXOffset, + y: window.pageYOffset + } + } + } + + function _getOffset (domEl) { + var offsetTop = 0 + var offsetLeft = 0 + + // Grab the element’s dimensions. + var offsetHeight = domEl.offsetHeight + var offsetWidth = domEl.offsetWidth + + // Now calculate the distance between the element and its parent, then + // again for the parent to its parent, and again etc... until we have the + // total distance of the element to the document’s top and left origin. + do { + if (!isNaN(domEl.offsetTop)) { + offsetTop += domEl.offsetTop + } + if (!isNaN(domEl.offsetLeft)) { + offsetLeft += domEl.offsetLeft + } + domEl = domEl.offsetParent + } while (domEl) + + return { + top: offsetTop, + left: offsetLeft, + height: offsetHeight, + width: offsetWidth + } + } + + function _isElemVisible (elem) { + var offset = _getOffset(elem.domEl) + var container = _getContainer(elem.config.container) + var scrolled = _getScrolled(elem.config.container) + var vF = elem.config.viewFactor + + // Define the element geometry. + var elemHeight = offset.height + var elemWidth = offset.width + var elemTop = offset.top + var elemLeft = offset.left + var elemBottom = elemTop + elemHeight + var elemRight = elemLeft + elemWidth + + return confirmBounds() || isPositionFixed() + + function confirmBounds () { + // Define the element’s functional boundaries using its view factor. + var top = elemTop + elemHeight * vF + var left = elemLeft + elemWidth * vF + var bottom = elemBottom - elemHeight * vF + var right = elemRight - elemWidth * vF + + // Define the container functional boundaries using its view offset. + var viewTop = scrolled.y + elem.config.viewOffset.top + var viewLeft = scrolled.x + elem.config.viewOffset.left + var viewBottom = scrolled.y - elem.config.viewOffset.bottom + container.height + var viewRight = scrolled.x - elem.config.viewOffset.right + container.width + + return top < viewBottom && + bottom > viewTop && + left < viewRight && + right > viewLeft + } + + function isPositionFixed () { + return (window.getComputedStyle(elem.domEl).position === 'fixed') + } + } + + /** + * Utilities + * --------- + */ + + function Tools () {} + + Tools.prototype.isObject = function (object) { + return object !== null && typeof object === 'object' && object.constructor === Object + } + + Tools.prototype.isNode = function (object) { + return typeof window.Node === 'object' + ? object instanceof window.Node + : object && typeof object === 'object' && + typeof object.nodeType === 'number' && + typeof object.nodeName === 'string' + } + + Tools.prototype.isNodeList = function (object) { + var prototypeToString = Object.prototype.toString.call(object) + var regex = /^\[object (HTMLCollection|NodeList|Object)\]$/ + + return typeof window.NodeList === 'object' + ? object instanceof window.NodeList + : object && typeof object === 'object' && + regex.test(prototypeToString) && + typeof object.length === 'number' && + (object.length === 0 || this.isNode(object[0])) + } + + Tools.prototype.forOwn = function (object, callback) { + if (!this.isObject(object)) { + throw new TypeError('Expected "object", but received "' + typeof object + '".') + } else { + for (var property in object) { + if (object.hasOwnProperty(property)) { + callback(property) + } + } + } + } + + Tools.prototype.extend = function (target, source) { + this.forOwn(source, function (property) { + if (this.isObject(source[property])) { + if (!target[property] || !this.isObject(target[property])) { + target[property] = {} + } + this.extend(target[property], source[property]) + } else { + target[property] = source[property] + } + }.bind(this)) + return target + } + + Tools.prototype.extendClone = function (target, source) { + return this.extend(this.extend({}, target), source) + } + + Tools.prototype.isMobile = function () { + return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) + } + + /** + * Polyfills + * -------- + */ + + _requestAnimationFrame = window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + function (callback) { + window.setTimeout(callback, 1000 / 60) + } + + /** + * Module Wrapper + * -------------- + */ + if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) { + define(function () { + return ScrollReveal + }) + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = ScrollReveal + } else { + window.ScrollReveal = ScrollReveal + } +})(); diff --git a/vendor/assets/scrollreveal/scrollreveal.min.js b/vendor/assets/scrollreveal/scrollreveal.min.js new file mode 100755 index 0000000..733e682 --- /dev/null +++ b/vendor/assets/scrollreveal/scrollreveal.min.js @@ -0,0 +1 @@ +!function(){"use strict";function e(n){return"undefined"==typeof this||Object.getPrototypeOf(this)!==e.prototype?new e(n):(O=this,O.version="3.4.0",O.tools=new E,O.isSupported()?(O.tools.extend(O.defaults,n||{}),O.defaults.container=t(O.defaults),O.store={elements:{},containers:[]},O.sequences={},O.history=[],O.uid=0,O.initialized=!1):"undefined"!=typeof console&&null!==console,O)}function t(e){if(e&&e.container){if("string"==typeof e.container)return window.document.documentElement.querySelector(e.container);if(O.tools.isNode(e.container))return e.container}return O.defaults.container}function n(e,t){return"string"==typeof e?Array.prototype.slice.call(t.querySelectorAll(e)):O.tools.isNode(e)?[e]:O.tools.isNodeList(e)?Array.prototype.slice.call(e):Array.isArray(e)?e.filter(O.tools.isNode):[]}function i(){return++O.uid}function o(e,t,n){t.container&&(t.container=n),e.config?e.config=O.tools.extendClone(e.config,t):e.config=O.tools.extendClone(O.defaults,t),"top"===e.config.origin||"bottom"===e.config.origin?e.config.axis="Y":e.config.axis="X"}function r(e){var t=window.getComputedStyle(e.domEl);e.styles||(e.styles={transition:{},transform:{},computed:{}},e.styles.inline=e.domEl.getAttribute("style")||"",e.styles.inline+="; visibility: visible; ",e.styles.computed.opacity=t.opacity,t.transition&&"all 0s ease 0s"!==t.transition?e.styles.computed.transition=t.transition+", ":e.styles.computed.transition=""),e.styles.transition.instant=s(e,0),e.styles.transition.delayed=s(e,e.config.delay),e.styles.transform.initial=" -webkit-transform:",e.styles.transform.target=" -webkit-transform:",a(e),e.styles.transform.initial+="transform:",e.styles.transform.target+="transform:",a(e)}function s(e,t){var n=e.config;return"-webkit-transition: "+e.styles.computed.transition+"-webkit-transform "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s, opacity "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s; transition: "+e.styles.computed.transition+"transform "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s, opacity "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s; "}function a(e){var t,n=e.config,i=e.styles.transform;t="top"===n.origin||"left"===n.origin?/^-/.test(n.distance)?n.distance.substr(1):"-"+n.distance:n.distance,parseInt(n.distance)&&(i.initial+=" translate"+n.axis+"("+t+")",i.target+=" translate"+n.axis+"(0)"),n.scale&&(i.initial+=" scale("+n.scale+")",i.target+=" scale(1)"),n.rotate.x&&(i.initial+=" rotateX("+n.rotate.x+"deg)",i.target+=" rotateX(0)"),n.rotate.y&&(i.initial+=" rotateY("+n.rotate.y+"deg)",i.target+=" rotateY(0)"),n.rotate.z&&(i.initial+=" rotateZ("+n.rotate.z+"deg)",i.target+=" rotateZ(0)"),i.initial+="; opacity: "+n.opacity+";",i.target+="; opacity: "+e.styles.computed.opacity+";"}function l(e){var t=e.config.container;t&&O.store.containers.indexOf(t)===-1&&O.store.containers.push(e.config.container),O.store.elements[e.id]=e}function c(e,t,n){var i={target:e,config:t,interval:n};O.history.push(i)}function f(){if(O.isSupported()){y();for(var e=0;em&&np}function n(){return"fixed"===window.getComputedStyle(e.domEl).position}var i=x(e.domEl),o=b(e.config.container),r=h(e.config.container),s=e.config.viewFactor,a=i.height,l=i.width,c=i.top,f=i.left,d=c+a,u=f+l;return t()||n()}function E(){}var O,A;e.prototype.defaults={origin:"bottom",distance:"20px",duration:500,delay:0,rotate:{x:0,y:0,z:0},opacity:0,scale:.9,easing:"cubic-bezier(0.6, 0.2, 0.1, 1)",container:window.document.documentElement,mobile:!0,reset:!1,useDelay:"always",viewFactor:.2,viewOffset:{top:0,right:0,bottom:0,left:0},beforeReveal:function(e){},beforeReset:function(e){},afterReveal:function(e){},afterReset:function(e){}},e.prototype.isSupported=function(){var e=document.documentElement.style;return"WebkitTransition"in e&&"WebkitTransform"in e||"transition"in e&&"transform"in e},e.prototype.reveal=function(e,s,a,d){var u,y,m,p,g,w;if(void 0!==s&&"number"==typeof s?(a=s,s={}):void 0!==s&&null!==s||(s={}),u=t(s),y=n(e,u),!y.length)return O;a&&"number"==typeof a&&(w=i(),g=O.sequences[w]={id:w,interval:a,elemIds:[],active:!1});for(var v=0;v