diff --git a/3rd-party/3rd-party.php b/3rd-party/3rd-party.php deleted file mode 100644 index 926fed2..0000000 --- a/3rd-party/3rd-party.php +++ /dev/null @@ -1,4 +0,0 @@ - 1 ) ); - } else { - wp_nonce_ays( '' ); - } - } - - if ( '__rocket_lazyload_imagify_notice' === $args['box'] ) { - update_option( 'rocket_lazyload_dismiss_imagify_notice', 0 ); - } - - global $current_user; - $actual = get_user_meta( $current_user->ID, 'rocket_lazyload_boxes', true ); - $actual = array_merge( (array) $actual, array( $args['box'] ) ); - $actual = array_filter( $actual ); - $actual = array_unique( $actual ); - update_user_meta( $current_user->ID, 'rocket_lazyload_boxes', $actual ); - delete_transient( $args['box'] ); - - if ( 'admin-post.php' === $GLOBALS['pagenow'] ) { - if ( defined( 'DOING_AJAX' ) ) { - wp_send_json( array( 'error' => 0 ) ); - } else { - wp_safe_redirect( wp_get_referer() ); - die(); - } - } - } -} -add_action( 'wp_ajax_rocket_lazyload_ignore', 'rocket_lazyload_dismiss_boxes' ); -add_action( 'admin_post_rocket_lazyload_ignore', 'rocket_lazyload_dismiss_boxes' ); diff --git a/admin/admin.php b/admin/admin.php deleted file mode 100644 index d3ee52a..0000000 --- a/admin/admin.php +++ /dev/null @@ -1,158 +0,0 @@ - array( - 'label' => __( 'Images', 'rocket-lazy-load' ), - ), - 'iframes' => array( - 'label' => __( 'Iframes & Videos', 'rocket-lazy-load' ), - ), - 'youtube' => array( - 'label' => __( 'Replace Youtube videos by thumbnail', 'rocket-lazy-load' ), - ), - ); - - // check user capabilities. - if ( ! current_user_can( 'manage_options' ) ) { - return; - } - - ?> -
- - = 0 ? 'h1' : 'h2'; ?> - < class="screen-reader-text">> -
-
-

<?php echo esc_attr( get_admin_page_title() ); ?>

-

-
- -

- tag, %2$s is
, %3$s is the complete link tag to Rocket Lazy Load review form, %4$s is the closing tag. - printf( __( '%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'rocket-lazy-load' ), '', '
', '', '' ); - ?> -
- ', 5 ); ?> -

-
-
-
-
- -

-

-
    - $infos ) { ?> - -
  • - aria-labelledby="describe-lazyload-"> - -
  • - - - -
-
- - - -
- -
-

-

- - -

- -
- - - 20%', '' ); ?> - */ ?> - -
-
- -
-
    -
  • ', '' ) ?>
  • -
  • ', '' ) ?>
  • -
  • ', '' ) ?>
  • -
  • ', '' ) ?>
  • -
  • ', '' ) ?>
  • -
  • ', '' ) ?>
  • -
  • ', '' ) ?>
  • -
-
- -
- - -

- -

-
-
-
-base ) ) { - return; - } - - $boxes = get_user_meta( $GLOBALS['current_user']->ID, 'rocket_lazyload_boxes', true ); - - if ( defined( 'IMAGIFY_VERSION' ) || in_array( __FUNCTION__, (array) $boxes, true ) || 1 === get_option( 'rocket_lazyload_dismiss_imagify_notice' ) || ! current_user_can( 'manage_options' ) ) { - return; - } - - $action_url = wp_nonce_url( add_query_arg( - array( - 'action' => 'install-plugin', - 'plugin' => 'imagify', - ), - admin_url( 'update.php' ) - ), 'install-plugin_imagify' ); - - $classes = ' install-now'; - $cta_txt = esc_html__( 'Install Imagify for Free', 'rocket-lazy-load' ); - - $dismiss_url = wp_nonce_url( - admin_url( 'admin-post.php?action=rocket_lazyload_ignore&box=' . __FUNCTION__ ), - 'rocket_lazyload_ignore_' . __FUNCTION__ - ); - ?> - -
- - - -

- -

-

- -

-
- - - jQuery( document ).ready( function( $ ){ - $( '.rktll-cross' ).on( 'click', function( e ) { - e.preventDefault(); - var url = $( this ).attr( 'href' ).replace( 'admin-post', 'admin-ajax' ); - $.get( url ).done( $( this ).parent().hide( 'slow' ) ); - }); - } ); - -HTML; -} -add_action( 'admin_footer', 'rocket_lazyload_notice_script' ); diff --git a/assets/js/lazyload-10.19.js b/assets/js/lazyload-10.19.js new file mode 100755 index 0000000..82d98b4 --- /dev/null +++ b/assets/js/lazyload-10.19.js @@ -0,0 +1,448 @@ +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +(function (global, factory) { + (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory(); +})(this, function () { + 'use strict'; + + var defaultSettings = { + elements_selector: "img", + container: document, + threshold: 300, + thresholds: null, + data_src: "src", + data_srcset: "srcset", + data_sizes: "sizes", + data_bg: "bg", + class_loading: "loading", + class_loaded: "loaded", + class_error: "error", + load_delay: 0, + callback_load: null, + callback_error: null, + callback_set: null, + callback_enter: null, + callback_finish: null, + to_webp: false + }; + + var getInstanceSettings = function getInstanceSettings(customSettings) { + return _extends({}, defaultSettings, customSettings); + }; + + var dataPrefix = "data-"; + var processedDataName = "was-processed"; + var timeoutDataName = "ll-timeout"; + var trueString = "true"; + + var getData = function getData(element, attribute) { + return element.getAttribute(dataPrefix + attribute); + }; + + var setData = function setData(element, attribute, value) { + var attrName = dataPrefix + attribute; + if (value === null) { + element.removeAttribute(attrName); + return; + } + element.setAttribute(attrName, value); + }; + + var setWasProcessedData = function setWasProcessedData(element) { + return setData(element, processedDataName, trueString); + }; + + var getWasProcessedData = function getWasProcessedData(element) { + return getData(element, processedDataName) === trueString; + }; + + var setTimeoutData = function setTimeoutData(element, value) { + return setData(element, timeoutDataName, value); + }; + + var getTimeoutData = function getTimeoutData(element) { + return getData(element, timeoutDataName); + }; + + var purgeProcessedElements = function purgeProcessedElements(elements) { + return elements.filter(function (element) { + return !getWasProcessedData(element); + }); + }; + + var purgeOneElement = function purgeOneElement(elements, elementToPurge) { + return elements.filter(function (element) { + return element !== elementToPurge; + }); + }; + + /* Creates instance and notifies it through the window element */ + var createInstance = function createInstance(classObj, options) { + var event; + var eventString = "LazyLoad::Initialized"; + var instance = new classObj(options); + try { + // Works in modern browsers + event = new CustomEvent(eventString, { detail: { instance: instance } }); + } catch (err) { + // Works in Internet Explorer (all versions) + event = document.createEvent("CustomEvent"); + event.initCustomEvent(eventString, false, false, { instance: instance }); + } + window.dispatchEvent(event); + }; + + /* Auto initialization of one or more instances of lazyload, depending on the + options passed in (plain object or an array) */ + function autoInitialize(classObj, options) { + if (!options) { + return; + } + if (!options.length) { + // Plain object + createInstance(classObj, options); + } else { + // Array of objects + for (var i = 0, optionsItem; optionsItem = options[i]; i += 1) { + createInstance(classObj, optionsItem); + } + } + } + + var replaceExtToWebp = function replaceExtToWebp(value, condition) { + return condition ? value.replace(/\.(jpe?g|png)/gi, ".webp") : value; + }; + + var detectWebp = function detectWebp() { + var webpString = "image/webp"; + var canvas = document.createElement("canvas"); + + if (canvas.getContext && canvas.getContext("2d")) { + return canvas.toDataURL(webpString).indexOf('data:' + webpString) === 0; + } + + return false; + }; + + var runningOnBrowser = typeof window !== "undefined"; + + var isBot = runningOnBrowser && !("onscroll" in window) || /(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent); + + var supportsIntersectionObserver = runningOnBrowser && "IntersectionObserver" in window; + + var supportsClassList = runningOnBrowser && "classList" in document.createElement("p"); + + var supportsWebp = runningOnBrowser && detectWebp(); + + var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName, toWebpFlag) { + for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) { + if (childTag.tagName === "SOURCE") { + var attrValue = getData(childTag, dataAttrName); + setAttributeIfValue(childTag, attrName, attrValue, toWebpFlag); + } + } + }; + + var setAttributeIfValue = function setAttributeIfValue(element, attrName, value, toWebpFlag) { + if (!value) { + return; + } + element.setAttribute(attrName, replaceExtToWebp(value, toWebpFlag)); + }; + + var setSourcesImg = function setSourcesImg(element, settings) { + var toWebpFlag = supportsWebp && settings.to_webp; + var srcsetDataName = settings.data_srcset; + var parent = element.parentNode; + + if (parent && parent.tagName === "PICTURE") { + setSourcesInChildren(parent, "srcset", srcsetDataName, toWebpFlag); + } + var sizesDataValue = getData(element, settings.data_sizes); + setAttributeIfValue(element, "sizes", sizesDataValue); + var srcsetDataValue = getData(element, srcsetDataName); + setAttributeIfValue(element, "srcset", srcsetDataValue, toWebpFlag); + var srcDataValue = getData(element, settings.data_src); + setAttributeIfValue(element, "src", srcDataValue, toWebpFlag); + }; + + var setSourcesIframe = function setSourcesIframe(element, settings) { + var srcDataValue = getData(element, settings.data_src); + + setAttributeIfValue(element, "src", srcDataValue); + }; + + var setSourcesVideo = function setSourcesVideo(element, settings) { + var srcDataName = settings.data_src; + var srcDataValue = getData(element, srcDataName); + + setSourcesInChildren(element, "src", srcDataName); + setAttributeIfValue(element, "src", srcDataValue); + element.load(); + }; + + var setSourcesBgImage = function setSourcesBgImage(element, settings) { + var toWebpFlag = supportsWebp && settings.to_webp; + var srcDataValue = getData(element, settings.data_src); + var bgDataValue = getData(element, settings.data_bg); + + if (srcDataValue) { + var setValue = replaceExtToWebp(srcDataValue, toWebpFlag); + element.style.backgroundImage = 'url("' + setValue + '")'; + } + + if (bgDataValue) { + var _setValue = replaceExtToWebp(bgDataValue, toWebpFlag); + element.style.backgroundImage = _setValue; + } + }; + + var setSourcesFunctions = { + IMG: setSourcesImg, + IFRAME: setSourcesIframe, + VIDEO: setSourcesVideo + }; + + var setSources = function setSources(element, instance) { + var settings = instance._settings; + var tagName = element.tagName; + var setSourcesFunction = setSourcesFunctions[tagName]; + if (setSourcesFunction) { + setSourcesFunction(element, settings); + instance._updateLoadingCount(1); + instance._elements = purgeOneElement(instance._elements, element); + return; + } + setSourcesBgImage(element, settings); + }; + + var addClass = function addClass(element, className) { + if (supportsClassList) { + element.classList.add(className); + return; + } + element.className += (element.className ? " " : "") + className; + }; + + var removeClass = function removeClass(element, className) { + if (supportsClassList) { + element.classList.remove(className); + return; + } + element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, ""); + }; + + var callbackIfSet = function callbackIfSet(callback, argument) { + if (callback) { + callback(argument); + } + }; + + var genericLoadEventName = "load"; + var mediaLoadEventName = "loadeddata"; + var errorEventName = "error"; + + var addEventListener = function addEventListener(element, eventName, handler) { + element.addEventListener(eventName, handler); + }; + + var removeEventListener = function removeEventListener(element, eventName, handler) { + element.removeEventListener(eventName, handler); + }; + + var addEventListeners = function addEventListeners(element, loadHandler, errorHandler) { + addEventListener(element, genericLoadEventName, loadHandler); + addEventListener(element, mediaLoadEventName, loadHandler); + addEventListener(element, errorEventName, errorHandler); + }; + + var removeEventListeners = function removeEventListeners(element, loadHandler, errorHandler) { + removeEventListener(element, genericLoadEventName, loadHandler); + removeEventListener(element, mediaLoadEventName, loadHandler); + removeEventListener(element, errorEventName, errorHandler); + }; + + var eventHandler = function eventHandler(event, success, instance) { + var settings = instance._settings; + var className = success ? settings.class_loaded : settings.class_error; + var callback = success ? settings.callback_load : settings.callback_error; + var element = event.target; + + removeClass(element, settings.class_loading); + addClass(element, className); + callbackIfSet(callback, element); + + instance._updateLoadingCount(-1); + }; + + var addOneShotEventListeners = function addOneShotEventListeners(element, instance) { + var loadHandler = function loadHandler(event) { + eventHandler(event, true, instance); + removeEventListeners(element, loadHandler, errorHandler); + }; + var errorHandler = function errorHandler(event) { + eventHandler(event, false, instance); + removeEventListeners(element, loadHandler, errorHandler); + }; + addEventListeners(element, loadHandler, errorHandler); + }; + + var managedTags = ["IMG", "IFRAME", "VIDEO"]; + + var loadAndUnobserve = function loadAndUnobserve(element, observer, instance) { + revealElement(element, instance); + observer.unobserve(element); + }; + + var cancelDelayLoad = function cancelDelayLoad(element) { + var timeoutId = getTimeoutData(element); + if (!timeoutId) { + return; // do nothing if timeout doesn't exist + } + clearTimeout(timeoutId); + setTimeoutData(element, null); + }; + + var delayLoad = function delayLoad(element, observer, instance) { + var loadDelay = instance._settings.load_delay; + var timeoutId = getTimeoutData(element); + if (timeoutId) { + return; // do nothing if timeout already set + } + timeoutId = setTimeout(function () { + loadAndUnobserve(element, observer, instance); + cancelDelayLoad(element); + }, loadDelay); + setTimeoutData(element, timeoutId); + }; + + function revealElement(element, instance, force) { + var settings = instance._settings; + if (!force && getWasProcessedData(element)) { + return; // element has already been processed and force wasn't true + } + callbackIfSet(settings.callback_enter, element); + if (managedTags.indexOf(element.tagName) > -1) { + addOneShotEventListeners(element, instance); + addClass(element, settings.class_loading); + } + setSources(element, instance); + setWasProcessedData(element); + callbackIfSet(settings.callback_set, element); + } + + /* entry.isIntersecting needs fallback because is null on some versions of MS Edge, and + entry.intersectionRatio is not enough alone because it could be 0 on some intersecting elements */ + var isIntersecting = function isIntersecting(entry) { + return entry.isIntersecting || entry.intersectionRatio > 0; + }; + + var getObserverSettings = function getObserverSettings(settings) { + return { + root: settings.container === document ? null : settings.container, + rootMargin: settings.thresholds || settings.threshold + "px" + }; + }; + + var LazyLoad = function LazyLoad(customSettings, elements) { + this._settings = getInstanceSettings(customSettings); + this._setObserver(); + this._loadingCount = 0; + this.update(elements); + }; + + LazyLoad.prototype = { + _manageIntersection: function _manageIntersection(entry) { + var observer = this._observer; + var loadDelay = this._settings.load_delay; + var element = entry.target; + + // WITHOUT LOAD DELAY + if (!loadDelay) { + if (isIntersecting(entry)) { + loadAndUnobserve(element, observer, this); + } + return; + } + + // WITH LOAD DELAY + if (isIntersecting(entry)) { + delayLoad(element, observer, this); + } else { + cancelDelayLoad(element); + } + }, + + _onIntersection: function _onIntersection(entries) { + entries.forEach(this._manageIntersection.bind(this)); + }, + + _setObserver: function _setObserver() { + if (!supportsIntersectionObserver) { + return; + } + this._observer = new IntersectionObserver(this._onIntersection.bind(this), getObserverSettings(this._settings)); + }, + + _updateLoadingCount: function _updateLoadingCount(plusMinus) { + this._loadingCount += plusMinus; + if (this._elements.length === 0 && this._loadingCount === 0) { + callbackIfSet(this._settings.callback_finish); + } + }, + + update: function update(elements) { + var _this = this; + + var settings = this._settings; + var nodeSet = elements || settings.container.querySelectorAll(settings.elements_selector); + + this._elements = purgeProcessedElements(Array.prototype.slice.call(nodeSet) // NOTE: nodeset to array for IE compatibility + ); + + if (isBot || !this._observer) { + this.loadAll(); + return; + } + + this._elements.forEach(function (element) { + _this._observer.observe(element); + }); + }, + + destroy: function destroy() { + var _this2 = this; + + if (this._observer) { + this._elements.forEach(function (element) { + _this2._observer.unobserve(element); + }); + this._observer = null; + } + this._elements = null; + this._settings = null; + }, + + load: function load(element, force) { + revealElement(element, this, force); + }, + + loadAll: function loadAll() { + var _this3 = this; + + var elements = this._elements; + elements.forEach(function (element) { + _this3.load(element); + }); + } + }; + + /* Automatic instances creation if required (useful for async script loading) */ + if (runningOnBrowser) { + autoInitialize(LazyLoad, window.lazyLoadOptions); + } + + return LazyLoad; +}); \ No newline at end of file diff --git a/assets/js/lazyload-10.19.min.js b/assets/js/lazyload-10.19.min.js new file mode 100755 index 0000000..14979c8 --- /dev/null +++ b/assets/js/lazyload-10.19.min.js @@ -0,0 +1,2 @@ +var _extends=Object.assign||function(t){for(var e=1;e-1&&(N(t,e),I(t,o.class_loading)),E(t,e),a(t),C(o.callback_set,t))}var e={elements_selector:"img",container:document,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,callback_load:null,callback_error:null,callback_set:null,callback_enter:null,callback_finish:null,to_webp:!1},n=function(t){return _extends({},e,t)},o=function(t,e){return t.getAttribute("data-"+e)},r=function(t,e,n){var o="data-"+e;null!==n?t.setAttribute(o,n):t.removeAttribute(o)},a=function(t){return r(t,"was-processed","true")},i=function(t){return"true"===o(t,"was-processed")},s=function(t,e){return r(t,"ll-timeout",e)},c=function(t){return o(t,"ll-timeout")},l=function(t){return t.filter(function(t){return!i(t)})},u=function(t,e){return t.filter(function(t){return t!==e})},d=function(t,e){var n,o=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},f=function(t,e){return e?t.replace(/\.(jpe?g|png)/gi,".webp"):t},_="undefined"!=typeof window,v=_&&!("onscroll"in window)||/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),g=_&&"IntersectionObserver"in window,h=_&&"classList"in document.createElement("p"),b=_&&function(){var t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))&&0===t.toDataURL("image/webp").indexOf("data:image/webp")}(),m=function(t,e,n,r){for(var a,i=0;a=t.children[i];i+=1)if("SOURCE"===a.tagName){var s=o(a,n);p(a,e,s,r)}},p=function(t,e,n,o){n&&t.setAttribute(e,f(n,o))},y=function(t,e){var n=b&&e.to_webp,r=o(t,e.data_src),a=o(t,e.data_bg);if(r){var i=f(r,n);t.style.backgroundImage='url("'+i+'")'}if(a){var s=f(a,n);t.style.backgroundImage=s}},w={IMG:function(t,e){var n=b&&e.to_webp,r=e.data_srcset,a=t.parentNode;a&&"PICTURE"===a.tagName&&m(a,"srcset",r,n);var i=o(t,e.data_sizes);p(t,"sizes",i);var s=o(t,r);p(t,"srcset",s,n);var c=o(t,e.data_src);p(t,"src",c,n)},IFRAME:function(t,e){var n=o(t,e.data_src);p(t,"src",n)},VIDEO:function(t,e){var n=e.data_src,r=o(t,n);m(t,"src",n),p(t,"src",r),t.load()}},E=function(t,e){var n=e._settings,o=t.tagName,r=w[o];if(r)return r(t,n),e._updateLoadingCount(1),void(e._elements=u(e._elements,t));y(t,n)},I=function(t,e){h?t.classList.add(e):t.className+=(t.className?" ":"")+e},L=function(t,e){h?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},C=function(t,e){t&&t(e)},O=function(t,e,n){t.addEventListener(e,n)},k=function(t,e,n){t.removeEventListener(e,n)},x=function(t,e,n){O(t,"load",e),O(t,"loadeddata",e),O(t,"error",n)},A=function(t,e,n){k(t,"load",e),k(t,"loadeddata",e),k(t,"error",n)},z=function(t,e,n){var o=n._settings,r=e?o.class_loaded:o.class_error,a=e?o.callback_load:o.callback_error,i=t.target;L(i,o.class_loading),I(i,r),C(a,i),n._updateLoadingCount(-1)},N=function(t,e){var n=function n(r){z(r,!0,e),A(t,n,o)},o=function o(r){z(r,!1,e),A(t,n,o)};x(t,n,o)},R=["IMG","IFRAME","VIDEO"],S=function(e,n,o){t(e,o),n.unobserve(e)},M=function(t){var e=c(t);e&&(clearTimeout(e),s(t,null))},j=function(t,e,n){var o=n._settings.load_delay,r=c(t);r||(r=setTimeout(function(){S(t,e,n),M(t)},o),s(t,r))},D=function(t){return t.isIntersecting||t.intersectionRatio>0},T=function(t){return{root:t.container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}},U=function(t,e){this._settings=n(t),this._setObserver(),this._loadingCount=0,this.update(e)};return U.prototype={_manageIntersection:function(t){var e=this._observer,n=this._settings.load_delay,o=t.target;n?D(t)?j(o,e,this):M(o):D(t)&&S(o,e,this)},_onIntersection:function(t){t.forEach(this._manageIntersection.bind(this))},_setObserver:function(){g&&(this._observer=new IntersectionObserver(this._onIntersection.bind(this),T(this._settings)))},_updateLoadingCount:function(t){this._loadingCount+=t,0===this._elements.length&&0===this._loadingCount&&C(this._settings.callback_finish)},update:function(t){var e=this,n=this._settings,o=t||n.container.querySelectorAll(n.elements_selector);this._elements=l(Array.prototype.slice.call(o)),!v&&this._observer?this._elements.forEach(function(t){e._observer.observe(t)}):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(e,n){t(e,this,n)},loadAll:function(){var t=this;this._elements.forEach(function(e){t.load(e)})}},_&&function(t,e){if(e)if(e.length)for(var n,o=0;n=e[o];o+=1)d(t,n);else d(t,e)}(U,window.lazyLoadOptions),U}); +//# sourceMappingURL=lazyload-10.19.min.js.map diff --git a/assets/js/lazyload-10.19.min.js.map b/assets/js/lazyload-10.19.min.js.map new file mode 100755 index 0000000..2d6baa2 --- /dev/null +++ b/assets/js/lazyload-10.19.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["lazyload.js"],"names":["global","factory","exports","_typeof","module","define","amd","LazyLoad","this","revealElement","element","instance","force","callbackIfSet","settings","callback_enter","managedTags","tagName","setSources","setWasProcessedData","callback_set","defaultSettings","elements_selector","container","document","threshold","thresholds","data_src","data_srcset","data_sizes","data_bg","class_loading","class_loaded","class_error","load_delay","callback_load","callback_error","to_webp","customSettings","_extends","timeoutDataName","attribute","trueString","setData","getAttribute","dataPrefix","attrName","value","removeAttribute","getData","setTimeoutData","getWasProcessedData","getTimeoutData","elements","elementToPurge","createInstance","filter","classObj","options","event","detail","createEvent","initCustomEvent","window","replaceExtToWebp","condition","length","runningOnBrowser","detectWebp","createElement","navigator","userAgent","canvas","toDataURL","supportsClassList","supportsWebp","optionsItem","indexOf","setSourcesInChildren","parentTag","dataAttrName","toWebpFlag","childTag","i","children","attrValue","setAttributeIfValue","setAttribute","srcDataValue","bgDataValue","backgroundImage","setValue","style","IMG","IFRAME","srcsetDataName","parent","parentNode","sizesDataValue","srcsetDataValue","VIDEO","srcDataName","load","_settings","setSourcesFunction","setSourcesFunctions","_updateLoadingCount","purgeOneElement","_elements","setSourcesBgImage","className","classList","add","remove","replace","RegExp","callback","argument","genericLoadEventName","removeEventListener","eventName","addEventListeners","addEventListener","loadHandler","errorHandler","removeEventListeners","success","removeClass","addClass","addOneShotEventListeners","eventHandler","observer","loadAndUnobserve","cancelDelayLoad","timeoutId","clearTimeout","delayLoad","loadDelay","setTimeout","getObserverSettings","entry","isIntersecting","intersectionRatio","rootMargin","root","getInstanceSettings","_setObserver","_loadingCount","update","_manageIntersection","_observer","target","entries","forEach","bind","supportsIntersectionObserver","IntersectionObserver","_onIntersection","plusMinus","nodeSet","querySelectorAll","purgeProcessedElements","Array","prototype","slice","call","isBot","destroy","_this","observe","loadAll","_this2","unobserve","_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BnB0I,aAAKS,WACJA,IAMDnJ,KAlCmB8I,UAAA,IAAAM,qBA+BlBpJ,KAAKqJ,gBAAgBH,KAAKlJ,MAK5BkG,EAAqBlG,KAAA+F,cAInBG,oBAAA,SAAAoD,GACDtJ,KAzCmB2I,eAAAW,EAsCW,IAA1BtJ,KAAKoG,UAAU1C,QAAuC,IAAvB1D,KAAK2I,eAKzCC,EAAQ5I,KAAA+F,UAASlD,kBAEhB+F,OAAMW,SACL1G,GAAAA,IAAAA,EAAAA,KAFKvC,EAAWN,KAAK+F,UAKjBK,EAAYvD,GAFhBvC,EAASS,UAAUyI,iBAAiBlJ,EAASQ,mBAO7Cd,KAAAoG,UAAAqD,EACAC,MAAAC,UAAAC,MAAAC,KAAAN,KAGDO,GAAK1D,KAAU6C,UAKhBc,KAAAA,UAASd,QAAA,SAAA/I,GAAW8J,EAAAlB,UAAAmB,QAAA/J,KAJlBF,KAAAkK,WAOCH,QAAA,WAAA,IAAAI,EAAAnK,KADDA,KAAA8I,YAGA9I,KAAAoG,UAAA6C,QAAA,SAAA/I,GACAiK,EAAArB,UAAAsB,UAAAlK,KAEDF,KAAK+F,UAAY,MADjB/F,KAAKoG,UAAY,KAIlBN,KAAAA,UAAM,MAANA,KAAM,SAAS5F,EAASE,GAIxB8J,EAAShK,EAAAF,KAAWI,IACnB8J,QAAIrH,WAAW,IAAAwH,EAAArK,KACNiJ,KAAQ7C,UACXN,QAAK5F,SAAAA,GACVmK,EAFDvE,KAAA5F,OAQDoK,GAlXC,SAAArH,EAAAC,GACAC,GAAAA,EAGAA,GAAAA,EAAQnC,OAiBR,IAAK,IAAWoD,EAAPO,EAAI,EAAiBP,EAAclB,EAAQyB,GAAKA,GAAK,EAXhE5B,EAAAE,EAAAmB,QAJErB,EAAAE,EAAAC,GA6WDoH,CAAAvK,EAAAwD,OAAAgH,iBA7bDxK","file":"lazyload.min.js","sourcesContent":["(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.LazyLoad = factory());\n}(this, (function () { 'use strict';\n\nconst defaultSettings = {\n\telements_selector: \"img\",\n\tcontainer: document,\n\tthreshold: 300,\n\tthresholds: null,\n\tdata_src: \"src\",\n\tdata_srcset: \"srcset\",\n\tdata_sizes: \"sizes\",\n\tdata_bg: \"bg\",\n\tclass_loading: \"loading\",\n\tclass_loaded: \"loaded\",\n\tclass_error: \"error\",\n\tload_delay: 0,\n\tcallback_load: null,\n\tcallback_error: null,\n\tcallback_set: null,\n\tcallback_enter: null,\n\tcallback_finish: null,\n\tto_webp: false\n};\n\nvar getInstanceSettings = customSettings => {\n\treturn Object.assign({}, defaultSettings, customSettings);\n};\n\nconst dataPrefix = \"data-\";\nconst processedDataName = \"was-processed\";\nconst timeoutDataName = \"ll-timeout\";\nconst trueString = \"true\";\n\nconst getData = (element, attribute) => {\n\treturn element.getAttribute(dataPrefix + attribute);\n};\n\nconst setData = (element, attribute, value) => {\n\tvar attrName = dataPrefix + attribute;\n\tif (value === null) {\n\t\telement.removeAttribute(attrName);\n\t\treturn;\n\t}\n\telement.setAttribute(attrName, value);\n};\n\nconst setWasProcessedData = element =>\n\tsetData(element, processedDataName, trueString);\n\nconst getWasProcessedData = element =>\n\tgetData(element, processedDataName) === trueString;\n\nconst setTimeoutData = (element, value) =>\n\tsetData(element, timeoutDataName, value);\n\nconst getTimeoutData = element => getData(element, timeoutDataName);\n\nconst purgeProcessedElements = elements => {\n\treturn elements.filter(element => !getWasProcessedData(element));\n};\n\nconst purgeOneElement = (elements, elementToPurge) => {\n\treturn elements.filter(element => element !== elementToPurge);\n};\n\n/* Creates instance and notifies it through the window element */\nconst createInstance = function(classObj, options) {\n\tvar event;\n\tlet eventString = \"LazyLoad::Initialized\";\n\tlet instance = new classObj(options);\n\ttry {\n\t\t// Works in modern browsers\n\t\tevent = new CustomEvent(eventString, { detail: { instance } });\n\t} catch (err) {\n\t\t// Works in Internet Explorer (all versions)\n\t\tevent = document.createEvent(\"CustomEvent\");\n\t\tevent.initCustomEvent(eventString, false, false, { instance });\n\t}\n\twindow.dispatchEvent(event);\n};\n\n/* Auto initialization of one or more instances of lazyload, depending on the \n options passed in (plain object or an array) */\nfunction autoInitialize(classObj, options) {\n\tif (!options) {\n\t\treturn;\n\t}\n\tif (!options.length) {\n\t\t// Plain object\n\t\tcreateInstance(classObj, options);\n\t} else {\n\t\t// Array of objects\n\t\tfor (let i = 0, optionsItem; (optionsItem = options[i]); i += 1) {\n\t\t\tcreateInstance(classObj, optionsItem);\n\t\t}\n\t}\n}\n\nconst replaceExtToWebp = (value, condition) =>\n\tcondition ? value.replace(/\\.(jpe?g|png)/gi, \".webp\") : value;\n\nconst detectWebp = () => {\n\tvar webpString = \"image/webp\";\n\tvar canvas = document.createElement(\"canvas\");\n\n\tif (canvas.getContext && canvas.getContext(\"2d\")) {\n\t\treturn canvas.toDataURL(webpString).indexOf(`data:${webpString}`) === 0;\n\t}\n\n\treturn false;\n};\n\nconst runningOnBrowser = typeof window !== \"undefined\";\n\nconst isBot =\n\t(runningOnBrowser && !(\"onscroll\" in window)) ||\n\t/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent);\n\nconst supportsIntersectionObserver =\n\trunningOnBrowser && \"IntersectionObserver\" in window;\n\nconst supportsClassList =\n\trunningOnBrowser && \"classList\" in document.createElement(\"p\");\n\nconst supportsWebp = runningOnBrowser && detectWebp();\n\nconst setSourcesInChildren = function(\n\tparentTag,\n\tattrName,\n\tdataAttrName,\n\ttoWebpFlag\n) {\n\tfor (let i = 0, childTag; (childTag = parentTag.children[i]); i += 1) {\n\t\tif (childTag.tagName === \"SOURCE\") {\n\t\t\tlet attrValue = getData(childTag, dataAttrName);\n\t\t\tsetAttributeIfValue(childTag, attrName, attrValue, toWebpFlag);\n\t\t}\n\t}\n};\n\nconst setAttributeIfValue = function(\n\telement,\n\tattrName,\n\tvalue,\n\ttoWebpFlag\n) {\n\tif (!value) {\n\t\treturn;\n\t}\n\telement.setAttribute(attrName, replaceExtToWebp(value, toWebpFlag));\n};\n\nconst setSourcesImg = (element, settings) => {\n\tconst toWebpFlag = supportsWebp && settings.to_webp;\n\tconst srcsetDataName = settings.data_srcset;\n\tconst parent = element.parentNode;\n\n\tif (parent && parent.tagName === \"PICTURE\") {\n\t\tsetSourcesInChildren(parent, \"srcset\", srcsetDataName, toWebpFlag);\n\t}\n\tconst sizesDataValue = getData(element, settings.data_sizes);\n\tsetAttributeIfValue(element, \"sizes\", sizesDataValue);\n\tconst srcsetDataValue = getData(element, srcsetDataName);\n\tsetAttributeIfValue(element, \"srcset\", srcsetDataValue, toWebpFlag);\n\tconst srcDataValue = getData(element, settings.data_src);\n\tsetAttributeIfValue(element, \"src\", srcDataValue, toWebpFlag);\n};\n\nconst setSourcesIframe = (element, settings) => {\n\tconst srcDataValue = getData(element, settings.data_src);\n\n\tsetAttributeIfValue(element, \"src\", srcDataValue);\n};\n\nconst setSourcesVideo = (element, settings) => {\n\tconst srcDataName = settings.data_src;\n\tconst srcDataValue = getData(element, srcDataName);\n\n\tsetSourcesInChildren(element, \"src\", srcDataName);\n\tsetAttributeIfValue(element, \"src\", srcDataValue);\n\telement.load();\n};\n\nconst setSourcesBgImage = (element, settings) => {\n\tconst toWebpFlag = supportsWebp && settings.to_webp;\n\tconst srcDataValue = getData(element, settings.data_src);\n\tconst bgDataValue = getData(element, settings.data_bg);\n\n\tif (srcDataValue) {\n\t\tlet setValue = replaceExtToWebp(srcDataValue, toWebpFlag);\n\t\telement.style.backgroundImage = `url(\"${setValue}\")`;\n\t}\n\n\tif (bgDataValue) {\n\t\tlet setValue = replaceExtToWebp(bgDataValue, toWebpFlag);\n\t\telement.style.backgroundImage = setValue;\n\t}\n};\n\nconst setSourcesFunctions = {\n\tIMG: setSourcesImg,\n\tIFRAME: setSourcesIframe,\n\tVIDEO: setSourcesVideo\n};\n\nconst setSources = (element, instance) => {\n\tconst settings = instance._settings;\n\tconst tagName = element.tagName;\n\tconst setSourcesFunction = setSourcesFunctions[tagName];\n\tif (setSourcesFunction) {\n\t\tsetSourcesFunction(element, settings);\n\t\tinstance._updateLoadingCount(1);\n\t\tinstance._elements = purgeOneElement(instance._elements, element);\n\t\treturn;\n\t}\n\tsetSourcesBgImage(element, settings);\n};\n\nconst addClass = (element, className) => {\n\tif (supportsClassList) {\n\t\telement.classList.add(className);\n\t\treturn;\n\t}\n\telement.className += (element.className ? \" \" : \"\") + className;\n};\n\nconst removeClass = (element, className) => {\n\tif (supportsClassList) {\n\t\telement.classList.remove(className);\n\t\treturn;\n\t}\n\telement.className = element.className.\n\t\treplace(new RegExp(\"(^|\\\\s+)\" + className + \"(\\\\s+|$)\"), \" \").\n\t\treplace(/^\\s+/, \"\").\n\t\treplace(/\\s+$/, \"\");\n};\n\nconst callbackIfSet = (callback, argument) => {\n\tif (callback) {\n\t\tcallback(argument);\n\t}\n};\n\nconst genericLoadEventName = \"load\";\nconst mediaLoadEventName = \"loadeddata\";\nconst errorEventName = \"error\";\n\nconst addEventListener = (element, eventName, handler) => {\n\telement.addEventListener(eventName, handler);\n};\n\nconst removeEventListener = (element, eventName, handler) => {\n\telement.removeEventListener(eventName, handler);\n};\n\nconst addEventListeners = (element, loadHandler, errorHandler) => {\n\taddEventListener(element, genericLoadEventName, loadHandler);\n\taddEventListener(element, mediaLoadEventName, loadHandler);\n\taddEventListener(element, errorEventName, errorHandler);\n};\n\nconst removeEventListeners = (element, loadHandler, errorHandler) => {\n\tremoveEventListener(element, genericLoadEventName, loadHandler);\n\tremoveEventListener(element, mediaLoadEventName, loadHandler);\n\tremoveEventListener(element, errorEventName, errorHandler);\n};\n\nconst eventHandler = function(event, success, instance) {\n\tvar settings = instance._settings;\n\tconst className = success ? settings.class_loaded : settings.class_error;\n\tconst callback = success ? settings.callback_load : settings.callback_error;\n\tconst element = event.target;\n\n\tremoveClass(element, settings.class_loading);\n\taddClass(element, className);\n\tcallbackIfSet(callback, element);\n\n\tinstance._updateLoadingCount(-1);\n};\n\nconst addOneShotEventListeners = (element, instance) => {\n\tconst loadHandler = event => {\n\t\teventHandler(event, true, instance);\n\t\tremoveEventListeners(element, loadHandler, errorHandler);\n\t};\n\tconst errorHandler = event => {\n\t\teventHandler(event, false, instance);\n\t\tremoveEventListeners(element, loadHandler, errorHandler);\n\t};\n\taddEventListeners(element, loadHandler, errorHandler);\n};\n\nconst managedTags = [\"IMG\", \"IFRAME\", \"VIDEO\"];\n\nconst loadAndUnobserve = (element, observer, instance) => {\n\trevealElement(element, instance);\n\tobserver.unobserve(element);\n};\n\nconst cancelDelayLoad = element => {\n\tvar timeoutId = getTimeoutData(element);\n\tif (!timeoutId) {\n\t\treturn; // do nothing if timeout doesn't exist\n\t}\n\tclearTimeout(timeoutId);\n\tsetTimeoutData(element, null);\n};\n\nconst delayLoad = (element, observer, instance) => {\n\tvar loadDelay = instance._settings.load_delay;\n\tvar timeoutId = getTimeoutData(element);\n\tif (timeoutId) {\n\t\treturn; // do nothing if timeout already set\n\t}\n\ttimeoutId = setTimeout(function() {\n\t\tloadAndUnobserve(element, observer, instance);\n\t\tcancelDelayLoad(element);\n\t}, loadDelay);\n\tsetTimeoutData(element, timeoutId);\n};\n\nfunction revealElement(element, instance, force) {\n\tvar settings = instance._settings;\n\tif (!force && getWasProcessedData(element)) {\n\t\treturn; // element has already been processed and force wasn't true\n\t}\n\tcallbackIfSet(settings.callback_enter, element);\n\tif (managedTags.indexOf(element.tagName) > -1) {\n\t\taddOneShotEventListeners(element, instance);\n\t\taddClass(element, settings.class_loading);\n\t}\n\tsetSources(element, instance);\n\tsetWasProcessedData(element);\n\tcallbackIfSet(settings.callback_set, element);\n}\n\n/* entry.isIntersecting needs fallback because is null on some versions of MS Edge, and\n entry.intersectionRatio is not enough alone because it could be 0 on some intersecting elements */\nconst isIntersecting = entry =>\n\tentry.isIntersecting || entry.intersectionRatio > 0;\n\nconst getObserverSettings = settings => ({\n\troot: settings.container === document ? null : settings.container,\n\trootMargin: settings.thresholds || settings.threshold + \"px\"\n});\n\nconst LazyLoad = function(customSettings, elements) {\n\tthis._settings = getInstanceSettings(customSettings);\n\tthis._setObserver();\n\tthis._loadingCount = 0;\n\tthis.update(elements);\n};\n\nLazyLoad.prototype = {\n\t_manageIntersection: function(entry) {\n\t\tvar observer = this._observer;\n\t\tvar loadDelay = this._settings.load_delay;\n\t\tvar element = entry.target;\n\n\t\t// WITHOUT LOAD DELAY\n\t\tif (!loadDelay) {\n\t\t\tif (isIntersecting(entry)) {\n\t\t\t\tloadAndUnobserve(element, observer, this);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// WITH LOAD DELAY\n\t\tif (isIntersecting(entry)) {\n\t\t\tdelayLoad(element, observer, this);\n\t\t} else {\n\t\t\tcancelDelayLoad(element);\n\t\t}\n\t},\n\n\t_onIntersection: function(entries) {\n\t\tentries.forEach(this._manageIntersection.bind(this));\n\t},\n\n\t_setObserver: function() {\n\t\tif (!supportsIntersectionObserver) {\n\t\t\treturn;\n\t\t}\n\t\tthis._observer = new IntersectionObserver(\n\t\t\tthis._onIntersection.bind(this),\n\t\t\tgetObserverSettings(this._settings)\n\t\t);\n\t},\n\n\t_updateLoadingCount: function(plusMinus) {\n\t\tthis._loadingCount += plusMinus;\n\t\tif (this._elements.length === 0 && this._loadingCount === 0) {\n\t\t\tcallbackIfSet(this._settings.callback_finish);\n\t\t}\n\t},\n\n\tupdate: function(elements) {\n\t\tconst settings = this._settings;\n\t\tconst nodeSet =\n\t\t\telements ||\n\t\t\tsettings.container.querySelectorAll(settings.elements_selector);\n\n\t\tthis._elements = purgeProcessedElements(\n\t\t\tArray.prototype.slice.call(nodeSet) // NOTE: nodeset to array for IE compatibility\n\t\t);\n\n\t\tif (isBot || !this._observer) {\n\t\t\tthis.loadAll();\n\t\t\treturn;\n\t\t}\n\n\t\tthis._elements.forEach(element => {\n\t\t\tthis._observer.observe(element);\n\t\t});\n\t},\n\n\tdestroy: function() {\n\t\tif (this._observer) {\n\t\t\tthis._elements.forEach(element => {\n\t\t\t\tthis._observer.unobserve(element);\n\t\t\t});\n\t\t\tthis._observer = null;\n\t\t}\n\t\tthis._elements = null;\n\t\tthis._settings = null;\n\t},\n\n\tload: function(element, force) {\n\t\trevealElement(element, this, force);\n\t},\n\n\tloadAll: function() {\n\t\tvar elements = this._elements;\n\t\telements.forEach(element => {\n\t\t\tthis.load(element);\n\t\t});\n\t}\n};\n\n/* Automatic instances creation if required (useful for async script loading) */\nif (runningOnBrowser) {\n\tautoInitialize(LazyLoad, window.lazyLoadOptions);\n}\n\nreturn LazyLoad;\n\n})));\n"]} \ No newline at end of file diff --git a/assets/js/lazyload-10.3.5.js b/assets/js/lazyload-10.3.5.js deleted file mode 100755 index 6df7a24..0000000 --- a/assets/js/lazyload-10.3.5.js +++ /dev/null @@ -1,249 +0,0 @@ -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -(function (global, factory) { - (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory(); -})(this, function () { - 'use strict'; - - var defaultSettings = { - elements_selector: "img", - container: document, - threshold: 300, - data_src: "src", - data_srcset: "srcset", - class_loading: "loading", - class_loaded: "loaded", - class_error: "error", - callback_load: null, - callback_error: null, - callback_set: null - }; - - var dataPrefix = "data-"; - - var getData = function getData(element, attribute) { - return element.getAttribute(dataPrefix + attribute); - }; - - var setData = function setData(element, attribute, value) { - return element.setAttribute(dataPrefix + attribute, value); - }; - - var purgeElements = function purgeElements(elements) { - return elements.filter(function (element) { - return !getData(element, "was-processed"); - }); - }; - - /* Creates instance and notifies it through the window element */ - var createInstance = function createInstance(classObj, options) { - var event; - var eventString = "LazyLoad::Initialized"; - var instance = new classObj(options); - try { - // Works in modern browsers - event = new CustomEvent(eventString, { detail: { instance: instance } }); - } catch (err) { - // Works in Internet Explorer (all versions) - event = document.createEvent("CustomEvent"); - event.initCustomEvent(eventString, false, false, { instance: instance }); - } - window.dispatchEvent(event); - }; - - /* Auto initialization of one or more instances of lazyload, depending on the - options passed in (plain object or an array) */ - var autoInitialize = function autoInitialize(classObj, options) { - if (!options.length) { - // Plain object - createInstance(classObj, options); - } else { - // Array of objects - for (var i = 0, optionsItem; optionsItem = options[i]; i += 1) { - createInstance(classObj, optionsItem); - } - } - }; - - var setSourcesForPicture = function setSourcesForPicture(element, settings) { - var dataSrcSet = settings.data_srcset; - - var parent = element.parentNode; - if (parent.tagName !== "PICTURE") { - return; - } - for (var i = 0, pictureChild; pictureChild = parent.children[i]; i += 1) { - if (pictureChild.tagName === "SOURCE") { - var sourceSrcset = getData(pictureChild, dataSrcSet); - if (sourceSrcset) { - pictureChild.setAttribute("srcset", sourceSrcset); - } - } - } - }; - - var setSources = function setSources(element, settings) { - var dataSrc = settings.data_src, - dataSrcSet = settings.data_srcset; - - var tagName = element.tagName; - var elementSrc = getData(element, dataSrc); - if (tagName === "IMG") { - setSourcesForPicture(element, settings); - var imgSrcset = getData(element, dataSrcSet); - if (imgSrcset) { - element.setAttribute("srcset", imgSrcset); - } - if (elementSrc) { - element.setAttribute("src", elementSrc); - } - return; - } - if (tagName === "IFRAME") { - if (elementSrc) { - element.setAttribute("src", elementSrc); - } - return; - } - if (elementSrc) { - element.style.backgroundImage = 'url("' + elementSrc + '")'; - } - }; - - var supportsClassList = "classList" in document.createElement("p"); - - var addClass = function addClass(element, className) { - if (supportsClassList) { - element.classList.add(className); - return; - } - element.className += (element.className ? " " : "") + className; - }; - - var removeClass = function removeClass(element, className) { - if (supportsClassList) { - element.classList.remove(className); - return; - } - element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, ""); - }; - - var callCallback = function callCallback(callback, argument) { - if (callback) { - callback(argument); - } - }; - - var loadString = "load"; - var errorString = "error"; - - var removeListeners = function removeListeners(element, loadHandler, errorHandler) { - element.removeEventListener(loadString, loadHandler); - element.removeEventListener(errorString, errorHandler); - }; - - var addOneShotListeners = function addOneShotListeners(element, settings) { - var onLoad = function onLoad(event) { - onEvent(event, true, settings); - removeListeners(element, onLoad, onError); - }; - var onError = function onError(event) { - onEvent(event, false, settings); - removeListeners(element, onLoad, onError); - }; - element.addEventListener(loadString, onLoad); - element.addEventListener(errorString, onError); - }; - - var onEvent = function onEvent(event, success, settings) { - var element = event.target; - removeClass(element, settings.class_loading); - addClass(element, success ? settings.class_loaded : settings.class_error); // Setting loaded or error class - callCallback(success ? settings.callback_load : settings.callback_error, element); // Calling loaded or error callback - }; - - var revealElement = function revealElement(element, settings) { - if (["IMG", "IFRAME"].indexOf(element.tagName) > -1) { - addOneShotListeners(element, settings); - addClass(element, settings.class_loading); - } - setSources(element, settings); - setData(element, "was-processed", true); - callCallback(settings.callback_set, element); - }; - - var LazyLoad = function LazyLoad(instanceSettings, elements) { - this._settings = _extends({}, defaultSettings, instanceSettings); - this._setObserver(); - this.update(elements); - }; - - LazyLoad.prototype = { - _setObserver: function _setObserver() { - var _this = this; - - if (!("IntersectionObserver" in window)) { - return; - } - - var settings = this._settings; - var onIntersection = function onIntersection(entries) { - entries.forEach(function (entry) { - if (entry.intersectionRatio > 0) { - var element = entry.target; - revealElement(element, settings); - _this._observer.unobserve(element); - } - }); - _this._elements = purgeElements(_this._elements); - }; - this._observer = new IntersectionObserver(onIntersection, { - root: settings.container === document ? null : settings.container, - rootMargin: settings.threshold + "px" - }); - }, - - update: function update(elements) { - var _this2 = this; - - var settings = this._settings; - var nodeSet = elements || settings.container.querySelectorAll(settings.elements_selector); - - this._elements = purgeElements(Array.prototype.slice.call(nodeSet)); // nodeset to array for IE compatibility - if (this._observer) { - this._elements.forEach(function (element) { - _this2._observer.observe(element); - }); - return; - } - // Fallback: load all elements at once - this._elements.forEach(function (element) { - revealElement(element, settings); - }); - this._elements = purgeElements(this._elements); - }, - - destroy: function destroy() { - var _this3 = this; - - if (this._observer) { - purgeElements(this._elements).forEach(function (element) { - _this3._observer.unobserve(element); - }); - this._observer = null; - } - this._elements = null; - this._settings = null; - } - }; - - /* Automatic instances creation if required (useful for async script loading!) */ - var autoInitOptions = window.lazyLoadOptions; - if (autoInitOptions) { - autoInitialize(LazyLoad, autoInitOptions); - } - - return LazyLoad; -}); \ No newline at end of file diff --git a/assets/js/lazyload-10.3.5.min.js b/assets/js/lazyload-10.3.5.min.js deleted file mode 100755 index 80cac38..0000000 --- a/assets/js/lazyload-10.3.5.min.js +++ /dev/null @@ -1 +0,0 @@ -var _extends=Object.assign||function(e){for(var t=1;t-1&&(f(e,t),c(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),u(t.callback_set,e)},m=function(t,n){this._settings=_extends({},e,t),this._setObserver(),this.update(n)};m.prototype={_setObserver:function(){var e=this;if("IntersectionObserver"in window){var t=this._settings;this._observer=new IntersectionObserver(function(n){n.forEach(function(n){if(n.intersectionRatio>0){var r=n.target;_(r,t),e._observer.unobserve(r)}}),e._elements=r(e._elements)},{root:t.container===document?null:t.container,rootMargin:t.threshold+"px"})}},update:function(e){var t=this,n=this._settings,s=e||n.container.querySelectorAll(n.elements_selector);this._elements=r(Array.prototype.slice.call(s)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):(this._elements.forEach(function(e){_(e,n)}),this._elements=r(this._elements))},destroy:function(){var e=this;this._observer&&(r(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var b=window.lazyLoadOptions;return b&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)s(e,n);else s(e,t)}(m,b),m}); \ No newline at end of file diff --git a/assets/js/lazyload-10.8.js b/assets/js/lazyload-10.8.js deleted file mode 100755 index c6f1103..0000000 --- a/assets/js/lazyload-10.8.js +++ /dev/null @@ -1,273 +0,0 @@ -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -(function (global, factory) { - (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory(); -})(this, function () { - 'use strict'; - - var getInstanceSettings = function getInstanceSettings(customSettings) { - var defaultSettings = { - elements_selector: "img", - container: document, - threshold: 300, - data_src: "src", - data_srcset: "srcset", - class_loading: "loading", - class_loaded: "loaded", - class_error: "error", - callback_load: null, - callback_error: null, - callback_set: null, - callback_enter: null - }; - - return _extends({}, defaultSettings, customSettings); - }; - - var dataPrefix = "data-"; - - var getData = function getData(element, attribute) { - return element.getAttribute(dataPrefix + attribute); - }; - - var setData = function setData(element, attribute, value) { - return element.setAttribute(dataPrefix + attribute, value); - }; - - var purgeElements = function purgeElements(elements) { - return elements.filter(function (element) { - return !getData(element, "was-processed"); - }); - }; - - /* Creates instance and notifies it through the window element */ - var createInstance = function createInstance(classObj, options) { - var event; - var eventString = "LazyLoad::Initialized"; - var instance = new classObj(options); - try { - // Works in modern browsers - event = new CustomEvent(eventString, { detail: { instance: instance } }); - } catch (err) { - // Works in Internet Explorer (all versions) - event = document.createEvent("CustomEvent"); - event.initCustomEvent(eventString, false, false, { instance: instance }); - } - window.dispatchEvent(event); - }; - - /* Auto initialization of one or more instances of lazyload, depending on the - options passed in (plain object or an array) */ - var autoInitialize = function autoInitialize(classObj, options) { - if (!options.length) { - // Plain object - createInstance(classObj, options); - } else { - // Array of objects - for (var i = 0, optionsItem; optionsItem = options[i]; i += 1) { - createInstance(classObj, optionsItem); - } - } - }; - - var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName) { - for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) { - if (childTag.tagName === "SOURCE") { - var attributeValue = getData(childTag, dataAttrName); - if (attributeValue) { - childTag.setAttribute(attrName, attributeValue); - } - } - } - }; - - var setAttributeIfNotNullOrEmpty = function setAttributeIfNotNullOrEmpty(element, attrName, value) { - if (!value) { - return; - } - element.setAttribute(attrName, value); - }; - - var setSources = function setSources(element, settings) { - var dataAttrSrcName = settings.data_src; - var elementSrc = getData(element, dataAttrSrcName); - var tagName = element.tagName; - if (tagName === "IMG") { - var dataAttrSrcSetName = settings.data_srcset; - var elementSrcSet = getData(element, dataAttrSrcSetName); - var parent = element.parentNode; - if (parent && parent.tagName === "PICTURE") { - setSourcesInChildren(parent, "srcset", dataAttrSrcSetName); - } - setAttributeIfNotNullOrEmpty(element, "srcset", elementSrcSet); - setAttributeIfNotNullOrEmpty(element, "src", elementSrc); - return; - } - if (tagName === "IFRAME") { - setAttributeIfNotNullOrEmpty(element, "src", elementSrc); - return; - } - if (tagName === "VIDEO") { - setSourcesInChildren(element, "src", dataAttrSrcName); - setAttributeIfNotNullOrEmpty(element, "src", elementSrc); - return; - } - if (elementSrc) { - element.style.backgroundImage = 'url("' + elementSrc + '")'; - } - }; - - var runningOnBrowser = typeof window !== "undefined"; - - var supportsIntersectionObserver = runningOnBrowser && "IntersectionObserver" in window; - - var supportsClassList = runningOnBrowser && "classList" in document.createElement("p"); - - var addClass = function addClass(element, className) { - if (supportsClassList) { - element.classList.add(className); - return; - } - element.className += (element.className ? " " : "") + className; - }; - - var removeClass = function removeClass(element, className) { - if (supportsClassList) { - element.classList.remove(className); - return; - } - element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, ""); - }; - - var callCallback = function callCallback(callback, argument) { - if (callback) { - callback(argument); - } - }; - - var loadString = "load"; - var errorString = "error"; - - var removeListeners = function removeListeners(element, loadHandler, errorHandler) { - element.removeEventListener(loadString, loadHandler); - element.removeEventListener(errorString, errorHandler); - }; - - var addOneShotListeners = function addOneShotListeners(element, settings) { - var onLoad = function onLoad(event) { - onEvent(event, true, settings); - removeListeners(element, onLoad, onError); - }; - var onError = function onError(event) { - onEvent(event, false, settings); - removeListeners(element, onLoad, onError); - }; - element.addEventListener(loadString, onLoad); - element.addEventListener(errorString, onError); - }; - - var onEvent = function onEvent(event, success, settings) { - var element = event.target; - removeClass(element, settings.class_loading); - addClass(element, success ? settings.class_loaded : settings.class_error); // Setting loaded or error class - callCallback(success ? settings.callback_load : settings.callback_error, element); // Calling loaded or error callback - }; - - var revealElement = function revealElement(element, settings) { - callCallback(settings.callback_enter, element); - if (["IMG", "IFRAME", "VIDEO"].indexOf(element.tagName) > -1) { - addOneShotListeners(element, settings); - addClass(element, settings.class_loading); - } - setSources(element, settings); - setData(element, "was-processed", true); - callCallback(settings.callback_set, element); - }; - - /* entry.isIntersecting needs fallback because is null on some versions of MS Edge, and - entry.intersectionRatio is not enough alone because it could be 0 on some intersecting elements */ - var isIntersecting = function isIntersecting(element) { - return element.isIntersecting || element.intersectionRatio > 0; - }; - - var LazyLoad = function LazyLoad(customSettings, elements) { - this._settings = getInstanceSettings(customSettings); - this._setObserver(); - this.update(elements); - }; - - LazyLoad.prototype = { - _setObserver: function _setObserver() { - var _this = this; - - if (!supportsIntersectionObserver) { - return; - } - - var settings = this._settings; - var observerSettings = { - root: settings.container === document ? null : settings.container, - rootMargin: settings.threshold + "px" - }; - var revealIntersectingElements = function revealIntersectingElements(entries) { - entries.forEach(function (entry) { - if (isIntersecting(entry)) { - var element = entry.target; - revealElement(element, _this._settings); - _this._observer.unobserve(element); - } - }); - _this._elements = purgeElements(_this._elements); - }; - this._observer = new IntersectionObserver(revealIntersectingElements, observerSettings); - }, - - loadAll: function loadAll() { - var settings = this._settings; - // Fallback: load all elements at once - this._elements.forEach(function (element) { - revealElement(element, settings); - }); - this._elements = purgeElements(this._elements); - }, - - update: function update(elements) { - var _this2 = this; - - var settings = this._settings; - var nodeSet = elements || settings.container.querySelectorAll(settings.elements_selector); - - this._elements = purgeElements(Array.prototype.slice.call(nodeSet)); // nodeset to array for IE compatibility - if (this._observer) { - this._elements.forEach(function (element) { - _this2._observer.observe(element); - }); - return; - } - this.loadAll(); - }, - - destroy: function destroy() { - var _this3 = this; - - if (this._observer) { - purgeElements(this._elements).forEach(function (element) { - _this3._observer.unobserve(element); - }); - this._observer = null; - } - this._elements = null; - this._settings = null; - } - }; - - /* Automatic instances creation if required (useful for async script loading!) */ - var autoInitOptions = window.lazyLoadOptions; - if (runningOnBrowser && autoInitOptions) { - autoInitialize(LazyLoad, autoInitOptions); - } - - return LazyLoad; -}); \ No newline at end of file diff --git a/assets/js/lazyload-10.8.min.js b/assets/js/lazyload-10.8.min.js deleted file mode 100755 index 72dcc07..0000000 --- a/assets/js/lazyload-10.8.min.js +++ /dev/null @@ -1 +0,0 @@ -var _extends=Object.assign||function(e){for(var t=1;t-1&&(m(e,t),d(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),v(t.callback_set,e)},p=function(e){return e.isIntersecting||e.intersectionRatio>0},y=function(t,n){this._settings=e(t),this._setObserver(),this.update(n)};y.prototype={_setObserver:function(){var e=this;if(l){var t=this._settings,n={root:t.container===document?null:t.container,rootMargin:t.threshold+"px"};this._observer=new IntersectionObserver(function(t){t.forEach(function(t){if(p(t)){var n=t.target;h(n,e._settings),e._observer.unobserve(n)}}),e._elements=r(e._elements)},n)}},loadAll:function(){var e=this._settings;this._elements.forEach(function(t){h(t,e)}),this._elements=r(this._elements)},update:function(e){var t=this,n=this._settings,s=e||n.container.querySelectorAll(n.elements_selector);this._elements=r(Array.prototype.slice.call(s)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):this.loadAll()},destroy:function(){var e=this;this._observer&&(r(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var g=window.lazyLoadOptions;return c&&g&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)s(e,n);else s(e,t)}(y,g),y}); \ No newline at end of file diff --git a/assets/js/lazyload-8.17.js b/assets/js/lazyload-8.17.js new file mode 100755 index 0000000..871d484 --- /dev/null +++ b/assets/js/lazyload-8.17.js @@ -0,0 +1,480 @@ +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +(function (global, factory) { + (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory(); +})(this, function () { + 'use strict'; + + var getDefaultSettings = function getDefaultSettings() { + return { + elements_selector: "img", + container: window, + threshold: 300, + throttle: 150, + data_src: "src", + data_srcset: "srcset", + data_sizes: "sizes", + data_bg: "bg", + class_loading: "loading", + class_loaded: "loaded", + class_error: "error", + class_initial: "initial", + skip_invisible: true, + callback_load: null, + callback_error: null, + callback_set: null, + callback_enter: null, + callback_finish: null, + to_webp: false + }; + }; + + var dataPrefix = "data-"; + var processedDataName = "was-processed"; + var processedDataValue = "true"; + + var getData = function getData(element, attribute) { + return element.getAttribute(dataPrefix + attribute); + }; + + var setData = function setData(element, attribute, value) { + var attrName = dataPrefix + attribute; + if (value === null) { + element.removeAttribute(attrName); + return; + } + element.setAttribute(attrName, value); + }; + + var setWasProcessedData = function setWasProcessedData(element) { + return setData(element, processedDataName, processedDataValue); + }; + + var getWasProcessedData = function getWasProcessedData(element) { + return getData(element, processedDataName) === processedDataValue; + }; + + var purgeProcessedElements = function purgeProcessedElements(elements) { + return elements.filter(function (element) { + return !getWasProcessedData(element); + }); + }; + + var purgeOneElement = function purgeOneElement(elements, elementToPurge) { + return elements.filter(function (element) { + return element !== elementToPurge; + }); + }; + + var getTopOffset = function getTopOffset(element) { + return element.getBoundingClientRect().top + window.pageYOffset - element.ownerDocument.documentElement.clientTop; + }; + + var isBelowViewport = function isBelowViewport(element, container, threshold) { + var fold = container === window ? window.innerHeight + window.pageYOffset : getTopOffset(container) + container.offsetHeight; + return fold <= getTopOffset(element) - threshold; + }; + + var getLeftOffset = function getLeftOffset(element) { + return element.getBoundingClientRect().left + window.pageXOffset - element.ownerDocument.documentElement.clientLeft; + }; + + var isAtRightOfViewport = function isAtRightOfViewport(element, container, threshold) { + var documentWidth = window.innerWidth; + var fold = container === window ? documentWidth + window.pageXOffset : getLeftOffset(container) + documentWidth; + return fold <= getLeftOffset(element) - threshold; + }; + + var isAboveViewport = function isAboveViewport(element, container, threshold) { + var fold = container === window ? window.pageYOffset : getTopOffset(container); + return fold >= getTopOffset(element) + threshold + element.offsetHeight; + }; + + var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) { + var fold = container === window ? window.pageXOffset : getLeftOffset(container); + return fold >= getLeftOffset(element) + threshold + element.offsetWidth; + }; + + function isInsideViewport(element, container, threshold) { + return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold); + } + + /* Creates instance and notifies it through the window element */ + var createInstance = function createInstance(classObj, options) { + var event; + var eventString = "LazyLoad::Initialized"; + var instance = new classObj(options); + try { + // Works in modern browsers + event = new CustomEvent(eventString, { detail: { instance: instance } }); + } catch (err) { + // Works in Internet Explorer (all versions) + event = document.createEvent("CustomEvent"); + event.initCustomEvent(eventString, false, false, { instance: instance }); + } + window.dispatchEvent(event); + }; + + /* Auto initialization of one or more instances of lazyload, depending on the + options passed in (plain object or an array) */ + function autoInitialize(classObj, options) { + if (!options) { + return; + } + if (!options.length) { + // Plain object + createInstance(classObj, options); + } else { + // Array of objects + for (var i = 0, optionsItem; optionsItem = options[i]; i += 1) { + createInstance(classObj, optionsItem); + } + } + } + + var replaceExtToWebp = function replaceExtToWebp(value, condition) { + return condition ? value.replace(/\.(jpe?g|png)/gi, ".webp") : value; + }; + + var detectWebp = function detectWebp() { + var webpString = "image/webp"; + var canvas = document.createElement("canvas"); + + if (canvas.getContext && canvas.getContext("2d")) { + return canvas.toDataURL(webpString).indexOf('data:' + webpString) === 0; + } + + return false; + }; + + var runningOnBrowser = typeof window !== "undefined"; + + var isBot = runningOnBrowser && !("onscroll" in window) || /(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent); + var supportsClassList = runningOnBrowser && "classList" in document.createElement("p"); + + var supportsWebp = runningOnBrowser && detectWebp(); + + var addClass = function addClass(element, className) { + if (supportsClassList) { + element.classList.add(className); + return; + } + element.className += (element.className ? " " : "") + className; + }; + + var removeClass = function removeClass(element, className) { + if (supportsClassList) { + element.classList.remove(className); + return; + } + element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, ""); + }; + + var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName, toWebpFlag) { + for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) { + if (childTag.tagName === "SOURCE") { + var attrValue = getData(childTag, dataAttrName); + setAttributeIfValue(childTag, attrName, attrValue, toWebpFlag); + } + } + }; + + var setAttributeIfValue = function setAttributeIfValue(element, attrName, value, toWebpFlag) { + if (!value) { + return; + } + element.setAttribute(attrName, replaceExtToWebp(value, toWebpFlag)); + }; + + var setSourcesImg = function setSourcesImg(element, settings) { + var toWebpFlag = supportsWebp && settings.to_webp; + var srcsetDataName = settings.data_srcset; + var parent = element.parentNode; + + if (parent && parent.tagName === "PICTURE") { + setSourcesInChildren(parent, "srcset", srcsetDataName, toWebpFlag); + } + var sizesDataValue = getData(element, settings.data_sizes); + setAttributeIfValue(element, "sizes", sizesDataValue); + var srcsetDataValue = getData(element, srcsetDataName); + setAttributeIfValue(element, "srcset", srcsetDataValue, toWebpFlag); + var srcDataValue = getData(element, settings.data_src); + setAttributeIfValue(element, "src", srcDataValue, toWebpFlag); + }; + + var setSourcesIframe = function setSourcesIframe(element, settings) { + var srcDataValue = getData(element, settings.data_src); + + setAttributeIfValue(element, "src", srcDataValue); + }; + + var setSourcesVideo = function setSourcesVideo(element, settings) { + var srcDataName = settings.data_src; + var srcDataValue = getData(element, srcDataName); + + setSourcesInChildren(element, "src", srcDataName); + setAttributeIfValue(element, "src", srcDataValue); + element.load(); + }; + + var setSourcesBgImage = function setSourcesBgImage(element, settings) { + var toWebpFlag = supportsWebp && settings.to_webp; + var srcDataValue = getData(element, settings.data_src); + var bgDataValue = getData(element, settings.data_bg); + + if (srcDataValue) { + var setValue = replaceExtToWebp(srcDataValue, toWebpFlag); + element.style.backgroundImage = 'url("' + setValue + '")'; + } + + if (bgDataValue) { + var _setValue = replaceExtToWebp(bgDataValue, toWebpFlag); + element.style.backgroundImage = _setValue; + } + }; + + var setSourcesFunctions = { + IMG: setSourcesImg, + IFRAME: setSourcesIframe, + VIDEO: setSourcesVideo + }; + + var setSources = function setSources(element, instance) { + var settings = instance._settings; + var tagName = element.tagName; + var setSourcesFunction = setSourcesFunctions[tagName]; + if (setSourcesFunction) { + setSourcesFunction(element, settings); + instance._updateLoadingCount(1); + instance._elements = purgeOneElement(instance._elements, element); + return; + } + setSourcesBgImage(element, settings); + }; + + var callbackIfSet = function callbackIfSet(callback, argument) { + if (callback) { + callback(argument); + } + }; + + var genericLoadEventName = "load"; + var mediaLoadEventName = "loadeddata"; + var errorEventName = "error"; + + var addEventListener = function addEventListener(element, eventName, handler) { + element.addEventListener(eventName, handler); + }; + + var removeEventListener = function removeEventListener(element, eventName, handler) { + element.removeEventListener(eventName, handler); + }; + + var addAllEventListeners = function addAllEventListeners(element, loadHandler, errorHandler) { + addEventListener(element, genericLoadEventName, loadHandler); + addEventListener(element, mediaLoadEventName, loadHandler); + addEventListener(element, errorEventName, errorHandler); + }; + + var removeAllEventListeners = function removeAllEventListeners(element, loadHandler, errorHandler) { + removeEventListener(element, genericLoadEventName, loadHandler); + removeEventListener(element, mediaLoadEventName, loadHandler); + removeEventListener(element, errorEventName, errorHandler); + }; + + var eventHandler = function eventHandler(event, success, instance) { + var settings = instance._settings; + var className = success ? settings.class_loaded : settings.class_error; + var callback = success ? settings.callback_load : settings.callback_error; + var element = event.target; + + removeClass(element, settings.class_loading); + addClass(element, className); + callbackIfSet(callback, element); + + instance._updateLoadingCount(-1); + }; + + var addOneShotEventListeners = function addOneShotEventListeners(element, instance) { + var loadHandler = function loadHandler(event) { + eventHandler(event, true, instance); + removeAllEventListeners(element, loadHandler, errorHandler); + }; + var errorHandler = function errorHandler(event) { + eventHandler(event, false, instance); + removeAllEventListeners(element, loadHandler, errorHandler); + }; + addAllEventListeners(element, loadHandler, errorHandler); + }; + + var managedTags = ["IMG", "IFRAME", "VIDEO"]; + + function revealElement(element, instance, force) { + var settings = instance._settings; + if (!force && getWasProcessedData(element)) { + return; // element has already been processed and force wasn't true + } + callbackIfSet(settings.callback_enter, element); + if (managedTags.indexOf(element.tagName) > -1) { + addOneShotEventListeners(element, instance); + addClass(element, settings.class_loading); + } + setSources(element, instance); + setWasProcessedData(element); + callbackIfSet(settings.callback_set, element); + } + + var removeFromArray = function removeFromArray(elements, indexes) { + while (indexes.length) { + elements.splice(indexes.pop(), 1); + } + }; + + /* + * Constructor + */ + + var LazyLoad = function LazyLoad(instanceSettings) { + this._settings = _extends({}, getDefaultSettings(), instanceSettings); + this._loadingCount = 0; + this._queryOriginNode = this._settings.container === window ? document : this._settings.container; + + this._previousLoopTime = 0; + this._loopTimeout = null; + this._boundHandleScroll = this.handleScroll.bind(this); + + this._isFirstLoop = true; + window.addEventListener("resize", this._boundHandleScroll); + this.update(); + }; + + LazyLoad.prototype = { + _loopThroughElements: function _loopThroughElements(forceDownload) { + var settings = this._settings, + elements = this._elements, + elementsLength = !elements ? 0 : elements.length; + var i = void 0, + processedIndexes = [], + isFirstLoop = this._isFirstLoop; + + if (isFirstLoop) { + this._isFirstLoop = false; + } + + if (elementsLength === 0) { + this._stopScrollHandler(); + return; + } + + for (i = 0; i < elementsLength; i++) { + var element = elements[i]; + /* If must skip_invisible and element is invisible, skip it */ + if (settings.skip_invisible && element.offsetParent === null) { + continue; + } + + if (forceDownload || isInsideViewport(element, settings.container, settings.threshold)) { + if (isFirstLoop) { + addClass(element, settings.class_initial); + } + this.load(element); + processedIndexes.push(i); + } + } + + // Removing processed elements from this._elements. + removeFromArray(elements, processedIndexes); + }, + + _startScrollHandler: function _startScrollHandler() { + if (!this._isHandlingScroll) { + this._isHandlingScroll = true; + this._settings.container.addEventListener("scroll", this._boundHandleScroll); + } + }, + + _stopScrollHandler: function _stopScrollHandler() { + if (this._isHandlingScroll) { + this._isHandlingScroll = false; + this._settings.container.removeEventListener("scroll", this._boundHandleScroll); + } + }, + + _updateLoadingCount: function _updateLoadingCount(plusMinus) { + this._loadingCount += plusMinus; + if (this._elements.length === 0 && this._loadingCount === 0) { + callbackIfSet(this._settings.callback_finish); + } + }, + + handleScroll: function handleScroll() { + var throttle = this._settings.throttle; + + if (throttle !== 0) { + var now = Date.now(); + var remainingTime = throttle - (now - this._previousLoopTime); + if (remainingTime <= 0 || remainingTime > throttle) { + if (this._loopTimeout) { + clearTimeout(this._loopTimeout); + this._loopTimeout = null; + } + this._previousLoopTime = now; + this._loopThroughElements(); + } else if (!this._loopTimeout) { + this._loopTimeout = setTimeout(function () { + this._previousLoopTime = Date.now(); + this._loopTimeout = null; + this._loopThroughElements(); + }.bind(this), remainingTime); + } + } else { + this._loopThroughElements(); + } + }, + + loadAll: function loadAll() { + this._loopThroughElements(true); + }, + + update: function update(elements) { + var settings = this._settings; + var nodeSet = elements || this._queryOriginNode.querySelectorAll(settings.elements_selector); + + this._elements = purgeProcessedElements(Array.prototype.slice.call(nodeSet) // NOTE: nodeset to array for IE compatibility + ); + + if (isBot) { + this.loadAll(); + return; + } + + this._loopThroughElements(); + this._startScrollHandler(); + }, + + destroy: function destroy() { + window.removeEventListener("resize", this._boundHandleScroll); + if (this._loopTimeout) { + clearTimeout(this._loopTimeout); + this._loopTimeout = null; + } + this._stopScrollHandler(); + this._elements = null; + this._queryOriginNode = null; + this._settings = null; + }, + + load: function load(element, force) { + revealElement(element, this, force); + } + }; + + /* Automatic instances creation if required (useful for async script loading) */ + if (runningOnBrowser) { + autoInitialize(LazyLoad, window.lazyLoadOptions); + } + + return LazyLoad; +}); \ No newline at end of file diff --git a/assets/js/lazyload-8.17.min.js b/assets/js/lazyload-8.17.min.js new file mode 100755 index 0000000..a3214c9 --- /dev/null +++ b/assets/js/lazyload-8.17.min.js @@ -0,0 +1,2 @@ +var _extends=Object.assign||function(t){for(var e=1;e-1&&(x(t,e),y(t,o.class_loading)),H(t,e),s(t),C(o.callback_set,t))}var n=function(){return{elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_initial:"initial",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_enter:null,callback_finish:null,to_webp:!1}},o=function(t,e){return t.getAttribute("data-"+e)},i=function(t,e,n){var o="data-"+e;null!==n?t.setAttribute(o,n):t.removeAttribute(o)},s=function(t){return i(t,"was-processed","true")},r=function(t){return"true"===o(t,"was-processed")},l=function(t){return t.filter(function(t){return!r(t)})},a=function(t,e){return t.filter(function(t){return t!==e})},c=function(t){return t.getBoundingClientRect().top+window.pageYOffset-t.ownerDocument.documentElement.clientTop},u=function(t,e,n){return(e===window?window.innerHeight+window.pageYOffset:c(e)+e.offsetHeight)<=c(t)-n},d=function(t){return t.getBoundingClientRect().left+window.pageXOffset-t.ownerDocument.documentElement.clientLeft},f=function(t,e,n){var o=window.innerWidth;return(e===window?o+window.pageXOffset:d(e)+o)<=d(t)-n},_=function(t,e,n){return(e===window?window.pageYOffset:c(e))>=c(t)+n+t.offsetHeight},h=function(t,e,n){return(e===window?window.pageXOffset:d(e))>=d(t)+n+t.offsetWidth},p=function(t,e){var n,o=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},g=function(t,e){return e?t.replace(/\.(jpe?g|png)/gi,".webp"):t},m="undefined"!=typeof window,w=m&&!("onscroll"in window)||/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),v=m&&"classList"in document.createElement("p"),b=m&&function(){var t=document.createElement("canvas");return!(!t.getContext||!t.getContext("2d"))&&0===t.toDataURL("image/webp").indexOf("data:image/webp")}(),y=function(t,e){v?t.classList.add(e):t.className+=(t.className?" ":"")+e},E=function(t,e){v?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},L=function(t,e,n,i){for(var s,r=0;s=t.children[r];r+=1)if("SOURCE"===s.tagName){var l=o(s,n);T(s,e,l,i)}},T=function(t,e,n,o){n&&t.setAttribute(e,g(n,o))},S=function(t,e){var n=b&&e.to_webp,i=o(t,e.data_src),s=o(t,e.data_bg);if(i){var r=g(i,n);t.style.backgroundImage='url("'+r+'")'}if(s){var l=g(s,n);t.style.backgroundImage=l}},O={IMG:function(t,e){var n=b&&e.to_webp,i=e.data_srcset,s=t.parentNode;s&&"PICTURE"===s.tagName&&L(s,"srcset",i,n);var r=o(t,e.data_sizes);T(t,"sizes",r);var l=o(t,i);T(t,"srcset",l,n);var a=o(t,e.data_src);T(t,"src",a,n)},IFRAME:function(t,e){var n=o(t,e.data_src);T(t,"src",n)},VIDEO:function(t,e){var n=e.data_src,i=o(t,n);L(t,"src",n),T(t,"src",i),t.load()}},H=function(t,e){var n=e._settings,o=t.tagName,i=O[o];if(i)return i(t,n),e._updateLoadingCount(1),void(e._elements=a(e._elements,t));S(t,n)},C=function(t,e){t&&t(e)},k=function(t,e,n){t.addEventListener(e,n)},z=function(t,e,n){t.removeEventListener(e,n)},N=function(t,e,n){k(t,"load",e),k(t,"loadeddata",e),k(t,"error",n)},A=function(t,e,n){z(t,"load",e),z(t,"loadeddata",e),z(t,"error",n)},I=function(t,e,n){var o=n._settings,i=e?o.class_loaded:o.class_error,s=e?o.callback_load:o.callback_error,r=t.target;E(r,o.class_loading),y(r,i),C(s,r),n._updateLoadingCount(-1)},x=function(t,e){var n=function n(i){I(i,!0,e),A(t,n,o)},o=function o(i){I(i,!1,e),A(t,n,o)};N(t,n,o)},R=["IMG","IFRAME","VIDEO"],D=function(t,e){for(;e.length;)t.splice(e.pop(),1)},F=function(t){this._settings=_extends({},n(),t),this._loadingCount=0,this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()};return F.prototype={_loopThroughElements:function(e){var n=this._settings,o=this._elements,i=o?o.length:0,s=void 0,r=[],l=this._isFirstLoop;if(l&&(this._isFirstLoop=!1),0!==i){for(s=0;st?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=e,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},loadAll:function(){this._loopThroughElements(!0)},update:function(t){var e=this._settings,n=t||this._queryOriginNode.querySelectorAll(e.elements_selector);this._elements=l(Array.prototype.slice.call(n)),w?this.loadAll():(this._loopThroughElements(),this._startScrollHandler())},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null},load:function(t,n){e(t,this,n)}},m&&function(t,e){if(e)if(e.length)for(var n,o=0;n=e[o];o+=1)p(t,n);else p(t,e)}(F,window.lazyLoadOptions),F}); +//# sourceMappingURL=lazyload-8.17.min.js.map diff --git a/assets/js/lazyload-8.17.min.js.map b/assets/js/lazyload-8.17.min.js.map new file mode 100755 index 0000000..ff0ec79 --- /dev/null +++ b/assets/js/lazyload-8.17.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["lazyload.js"],"names":["global","factory","exports","_typeof","module","define","amd","LazyLoad","this","createInstance","element","classObj","isBelowViewport","eventString","container","threshold","isAboveViewport","isAtRightOfViewport","isAtLeftOfViewport","instanceSettings","settings","instance","_settings","force","_loadingCount","callbackIfSet","_previousLoopTime","callback_enter","managedTags","_loopTimeout","tagName","addOneShotEventListeners","handleScroll","addClass","class_loading","window","addEventListener","setWasProcessedData","callback_set","getDefaultSettings","elements_selector","throttle","data_src","data_srcset","data_sizes","data_bg","class_loaded","class_error","class_initial","skip_invisible","callback_load","callback_error","getData","attribute","dataPrefix","callback_finish","setData","value","attrName","removeAttribute","getWasProcessedData","purgeProcessedElements","processedDataName","elements","filter","purgeOneElement","elementToPurge","getTopOffset","getBoundingClientRect","top","pageYOffset","ownerDocument","documentElement","clientTop","fold","left","pageXOffset","getLeftOffset","documentWidth","innerWidth","offsetWidth","event","initCustomEvent","options","CustomEvent","dispatchEvent","detail","autoInitialize","document","createEvent","replaceExtToWebp","condition","replace","className","isBot","test","navigator","userAgent","supportsClassList","runningOnBrowser","removeClass","remove","getContext","createElement","detectWebp","classList","add","childTag","parentTag","children","setAttributeIfValue","RegExp","setSourcesInChildren","dataAttrName","toWebpFlag","parent","i","attrValue","setSourcesVideo","setSourcesFunction","setSourcesFunctions","to_webp","_updateLoadingCount","srcDataValue","setValue","setSourcesBgImage","callback","bgDataValue","argument","genericLoadEventName","IMG","srcDataName","parentNode","srcsetDataValue","srcsetDataName","backgroundImage","IFRAME","VIDEO","setSourcesImg","setSourcesIframe","setSources","removeEventListener","addAllEventListeners","_elements","loadHandler","eventName","handler","eventHandler","success","removeAllEventListeners","errorHandler","revealElement","length","splice","indexes","pop","_loopThroughElements","_extends","elementsLength","_queryOriginNode","_boundHandleScroll","offsetParent","_isFirstLoop","update","prototype","forceDownload","processedIndexes","push","removeFromArray","isFirstLoop","_startScrollHandler","_isHandlingScroll","remainingTime","_stopScrollHandler","loadAll","plusMinus","destroy","Date","now","clearTimeout","setTimeout","load","bind","nodeSet","querySelectorAll","Array","slice","call","optionsItem","webpString","lazyLoadOptions"],"mappings":"kYAAC,SAAUA,EAAQC,GACC,YAAnB,oBAAOC,QAAP,YAAAC,QAAOD,WAA0C,oBAAXE,OAAyBA,OAAOF,QAAUD,IAC9D,mBAAXI,QAAyBA,OAAOC,IAAMD,OAAOJ,GACnDD,EAAOO,SAAWN,IAHnB,CAAAO,KAAA,WAAkBP,aAkHnB,SAAMQ,EAAiBC,EAAjBD,EAA0BE,GAC/B,QACAC,EAAIC,EAAcC,EAAAC,IAClBC,EAAeN,EAAIC,EAAnBI,IACAE,EAAIP,EAAAI,EAAAC,IACHG,EAAAR,EAAAI,EAAAC,IAoPF,SAAMR,EAAWG,EAAXH,EAAoBY,GACzB,IAAAC,EAAAC,EAAiBC,WACjBC,GAAKC,EAALd,KAMAe,EAAKC,EAALC,eAAAjB,GACAkB,EAAKC,QAAenB,EAApBoB,UAAA,IACAC,EAAArB,EAA+BsB,GA3B9BC,EAASvB,EAASU,EAASc,gBA8B5BC,EAAOC,EAAAA,GACPC,EAAA3B,GACAe,EAfDL,EAAAkB,aAAA5B,IAvWC,IAAC6B,EAAmB,WAAA,OAAEC,kBAAA,MAItB1B,UAAWqB,OAFZpB,UAAIwB,IAAqBE,SAAO,IAC/BD,SAAAA,MACA1B,YAAWqB,SACXpB,WAAAA,QACA0B,QAAAA,KACAC,cAAU,UACVC,aAAAA,SACAC,YAAAA,QACAC,cAR+B,UAS/BX,gBAAAA,E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KAAM,SAAS3K,EAASa,GACvBgI,EAAc7I,EAASF,KAAMe,KAK3B4E,GA5XD1F,SAAeE,EAAUiL,GACzB,GAAAzG,EAPF,GAAKA,EAAQqE,OAcd,IAAMhD,IAAaoF,EAAbpF,EAAAA,EAAAA,EAAmBrB,EAAAiC,GAAAA,GAAA,EACxB3G,EAAIoL,EAAaD,QAJOnL,EACxBkF,EAAkBC,GAuXlBL,CAAehF,EAAU4B,OAAO2J,iBAG1BvL","file":"lazyload.min.js","sourcesContent":["(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.LazyLoad = factory());\n}(this, (function () { 'use strict';\n\nvar getDefaultSettings = () => ({\n\telements_selector: \"img\",\n\tcontainer: window,\n\tthreshold: 300,\n\tthrottle: 150,\n\tdata_src: \"src\",\n\tdata_srcset: \"srcset\",\n\tdata_sizes: \"sizes\",\n\tdata_bg: \"bg\",\n\tclass_loading: \"loading\",\n\tclass_loaded: \"loaded\",\n\tclass_error: \"error\",\n\tclass_initial: \"initial\",\n\tskip_invisible: true,\n\tcallback_load: null,\n\tcallback_error: null,\n\tcallback_set: null,\n\tcallback_enter: null,\n\tcallback_finish: null,\n\tto_webp: false\n});\n\nconst dataPrefix = \"data-\";\nconst processedDataName = \"was-processed\";\nconst processedDataValue = \"true\";\n\nconst getData = (element, attribute) => {\n\treturn element.getAttribute(dataPrefix + attribute);\n};\n\nconst setData = (element, attribute, value) => {\n\tvar attrName = dataPrefix + attribute;\n\tif (value === null) {\n\t\telement.removeAttribute(attrName);\n\t\treturn;\n\t}\n\telement.setAttribute(attrName, value);\n};\n\nconst setWasProcessedData = element =>\n\tsetData(element, processedDataName, processedDataValue);\n\nconst getWasProcessedData = element =>\n\tgetData(element, processedDataName) === processedDataValue;\n\nconst purgeProcessedElements = elements => {\n\treturn elements.filter(element => !getWasProcessedData(element));\n};\n\nconst purgeOneElement = (elements, elementToPurge) => {\n\treturn elements.filter(element => element !== elementToPurge);\n};\n\nconst getTopOffset = function(element) {\n\treturn (\n\t\telement.getBoundingClientRect().top +\n\t\twindow.pageYOffset -\n\t\telement.ownerDocument.documentElement.clientTop\n\t);\n};\n\nconst isBelowViewport = function(element, container, threshold) {\n\tconst fold =\n\t\tcontainer === window\n\t\t\t? window.innerHeight + window.pageYOffset\n\t\t\t: getTopOffset(container) + container.offsetHeight;\n\treturn fold <= getTopOffset(element) - threshold;\n};\n\nconst getLeftOffset = function(element) {\n\treturn (\n\t\telement.getBoundingClientRect().left +\n\t\twindow.pageXOffset -\n\t\telement.ownerDocument.documentElement.clientLeft\n\t);\n};\n\nconst isAtRightOfViewport = function(element, container, threshold) {\n\tconst documentWidth = window.innerWidth;\n\tconst fold =\n\t\tcontainer === window\n\t\t\t? documentWidth + window.pageXOffset\n\t\t\t: getLeftOffset(container) + documentWidth;\n\treturn fold <= getLeftOffset(element) - threshold;\n};\n\nconst isAboveViewport = function(element, container, threshold) {\n\tconst fold =\n\t\tcontainer === window ? window.pageYOffset : getTopOffset(container);\n\treturn fold >= getTopOffset(element) + threshold + element.offsetHeight;\n};\n\nconst isAtLeftOfViewport = function(element, container, threshold) {\n\tconst fold =\n\t\tcontainer === window ? window.pageXOffset : getLeftOffset(container);\n\treturn fold >= getLeftOffset(element) + threshold + element.offsetWidth;\n};\n\nfunction isInsideViewport(element, container, threshold) {\n\treturn (\n\t\t!isBelowViewport(element, container, threshold) &&\n\t\t!isAboveViewport(element, container, threshold) &&\n\t\t!isAtRightOfViewport(element, container, threshold) &&\n\t\t!isAtLeftOfViewport(element, container, threshold)\n\t);\n}\n\n/* Creates instance and notifies it through the window element */\nconst createInstance = function(classObj, options) {\n\tvar event;\n\tlet eventString = \"LazyLoad::Initialized\";\n\tlet instance = new classObj(options);\n\ttry {\n\t\t// Works in modern browsers\n\t\tevent = new CustomEvent(eventString, { detail: { instance } });\n\t} catch (err) {\n\t\t// Works in Internet Explorer (all versions)\n\t\tevent = document.createEvent(\"CustomEvent\");\n\t\tevent.initCustomEvent(eventString, false, false, { instance });\n\t}\n\twindow.dispatchEvent(event);\n};\n\n/* Auto initialization of one or more instances of lazyload, depending on the \n options passed in (plain object or an array) */\nfunction autoInitialize(classObj, options) {\n\tif (!options) {\n\t\treturn;\n\t}\n\tif (!options.length) {\n\t\t// Plain object\n\t\tcreateInstance(classObj, options);\n\t} else {\n\t\t// Array of objects\n\t\tfor (let i = 0, optionsItem; (optionsItem = options[i]); i += 1) {\n\t\t\tcreateInstance(classObj, optionsItem);\n\t\t}\n\t}\n}\n\nconst replaceExtToWebp = (value, condition) =>\n\tcondition ? value.replace(/\\.(jpe?g|png)/gi, \".webp\") : value;\n\nconst detectWebp = () => {\n\tvar webpString = \"image/webp\";\n\tvar canvas = document.createElement(\"canvas\");\n\n\tif (canvas.getContext && canvas.getContext(\"2d\")) {\n\t\treturn canvas.toDataURL(webpString).indexOf(`data:${webpString}`) === 0;\n\t}\n\n\treturn false;\n};\n\nconst runningOnBrowser = typeof window !== \"undefined\";\n\nconst isBot =\n\t(runningOnBrowser && !(\"onscroll\" in window)) ||\n\t/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent);\nconst supportsClassList =\n\trunningOnBrowser && \"classList\" in document.createElement(\"p\");\n\nconst supportsWebp = runningOnBrowser && detectWebp();\n\nconst addClass = (element, className) => {\n\tif (supportsClassList) {\n\t\telement.classList.add(className);\n\t\treturn;\n\t}\n\telement.className += (element.className ? \" \" : \"\") + className;\n};\n\nconst removeClass = (element, className) => {\n\tif (supportsClassList) {\n\t\telement.classList.remove(className);\n\t\treturn;\n\t}\n\telement.className = element.className.\n\t\treplace(new RegExp(\"(^|\\\\s+)\" + className + \"(\\\\s+|$)\"), \" \").\n\t\treplace(/^\\s+/, \"\").\n\t\treplace(/\\s+$/, \"\");\n};\n\nconst setSourcesInChildren = function(\n\tparentTag,\n\tattrName,\n\tdataAttrName,\n\ttoWebpFlag\n) {\n\tfor (let i = 0, childTag; (childTag = parentTag.children[i]); i += 1) {\n\t\tif (childTag.tagName === \"SOURCE\") {\n\t\t\tlet attrValue = getData(childTag, dataAttrName);\n\t\t\tsetAttributeIfValue(childTag, attrName, attrValue, toWebpFlag);\n\t\t}\n\t}\n};\n\nconst setAttributeIfValue = function(\n\telement,\n\tattrName,\n\tvalue,\n\ttoWebpFlag\n) {\n\tif (!value) {\n\t\treturn;\n\t}\n\telement.setAttribute(attrName, replaceExtToWebp(value, toWebpFlag));\n};\n\nconst setSourcesImg = (element, settings) => {\n\tconst toWebpFlag = supportsWebp && settings.to_webp;\n\tconst srcsetDataName = settings.data_srcset;\n\tconst parent = element.parentNode;\n\n\tif (parent && parent.tagName === \"PICTURE\") {\n\t\tsetSourcesInChildren(parent, \"srcset\", srcsetDataName, toWebpFlag);\n\t}\n\tconst sizesDataValue = getData(element, settings.data_sizes);\n\tsetAttributeIfValue(element, \"sizes\", sizesDataValue);\n\tconst srcsetDataValue = getData(element, srcsetDataName);\n\tsetAttributeIfValue(element, \"srcset\", srcsetDataValue, toWebpFlag);\n\tconst srcDataValue = getData(element, settings.data_src);\n\tsetAttributeIfValue(element, \"src\", srcDataValue, toWebpFlag);\n};\n\nconst setSourcesIframe = (element, settings) => {\n\tconst srcDataValue = getData(element, settings.data_src);\n\n\tsetAttributeIfValue(element, \"src\", srcDataValue);\n};\n\nconst setSourcesVideo = (element, settings) => {\n\tconst srcDataName = settings.data_src;\n\tconst srcDataValue = getData(element, srcDataName);\n\n\tsetSourcesInChildren(element, \"src\", srcDataName);\n\tsetAttributeIfValue(element, \"src\", srcDataValue);\n\telement.load();\n};\n\nconst setSourcesBgImage = (element, settings) => {\n\tconst toWebpFlag = supportsWebp && settings.to_webp;\n\tconst srcDataValue = getData(element, settings.data_src);\n\tconst bgDataValue = getData(element, settings.data_bg);\n\n\tif (srcDataValue) {\n\t\tlet setValue = replaceExtToWebp(srcDataValue, toWebpFlag);\n\t\telement.style.backgroundImage = `url(\"${setValue}\")`;\n\t}\n\n\tif (bgDataValue) {\n\t\tlet setValue = replaceExtToWebp(bgDataValue, toWebpFlag);\n\t\telement.style.backgroundImage = setValue;\n\t}\n};\n\nconst setSourcesFunctions = {\n\tIMG: setSourcesImg,\n\tIFRAME: setSourcesIframe,\n\tVIDEO: setSourcesVideo\n};\n\nconst setSources = (element, instance) => {\n\tconst settings = instance._settings;\n\tconst tagName = element.tagName;\n\tconst setSourcesFunction = setSourcesFunctions[tagName];\n\tif (setSourcesFunction) {\n\t\tsetSourcesFunction(element, settings);\n\t\tinstance._updateLoadingCount(1);\n\t\tinstance._elements = purgeOneElement(instance._elements, element);\n\t\treturn;\n\t}\n\tsetSourcesBgImage(element, settings);\n};\n\nconst callbackIfSet = function(callback, argument) {\n\tif (callback) {\n\t\tcallback(argument);\n\t}\n};\n\nconst genericLoadEventName = \"load\";\nconst mediaLoadEventName = \"loadeddata\";\nconst errorEventName = \"error\";\n\nconst addEventListener = (element, eventName, handler) => {\n\telement.addEventListener(eventName, handler);\n};\n\nconst removeEventListener = (element, eventName, handler) => {\n\telement.removeEventListener(eventName, handler);\n};\n\nconst addAllEventListeners = (element, loadHandler, errorHandler) => {\n\taddEventListener(element, genericLoadEventName, loadHandler);\n\taddEventListener(element, mediaLoadEventName, loadHandler);\n\taddEventListener(element, errorEventName, errorHandler);\n};\n\nconst removeAllEventListeners = (element, loadHandler, errorHandler) => {\n\tremoveEventListener(element, genericLoadEventName, loadHandler);\n\tremoveEventListener(element, mediaLoadEventName, loadHandler);\n\tremoveEventListener(element, errorEventName, errorHandler);\n};\n\nconst eventHandler = function(event, success, instance) {\n\tvar settings = instance._settings;\n\tconst className = success ? settings.class_loaded : settings.class_error;\n\tconst callback = success ? settings.callback_load : settings.callback_error;\n\tconst element = event.target;\n\n\tremoveClass(element, settings.class_loading);\n\taddClass(element, className);\n\tcallbackIfSet(callback, element);\n\n\tinstance._updateLoadingCount(-1);\n};\n\nconst addOneShotEventListeners = (element, instance) => {\n\tconst loadHandler = event => {\n\t\teventHandler(event, true, instance);\n\t\tremoveAllEventListeners(element, loadHandler, errorHandler);\n\t};\n\tconst errorHandler = event => {\n\t\teventHandler(event, false, instance);\n\t\tremoveAllEventListeners(element, loadHandler, errorHandler);\n\t};\n\taddAllEventListeners(element, loadHandler, errorHandler);\n};\n\nconst managedTags = [\"IMG\", \"IFRAME\", \"VIDEO\"];\n\nfunction revealElement(element, instance, force) {\n\tvar settings = instance._settings;\n\tif (!force && getWasProcessedData(element)) {\n\t\treturn; // element has already been processed and force wasn't true\n\t}\n\tcallbackIfSet(settings.callback_enter, element);\n\tif (managedTags.indexOf(element.tagName) > -1) {\n\t\taddOneShotEventListeners(element, instance);\n\t\taddClass(element, settings.class_loading);\n\t}\n\tsetSources(element, instance);\n\tsetWasProcessedData(element);\n\tcallbackIfSet(settings.callback_set, element);\n}\n\nconst removeFromArray = (elements, indexes) => {\n\twhile (indexes.length) {\n\t\telements.splice(indexes.pop(), 1);\n\t}\n};\n\n/*\n * Constructor\n */\n\nconst LazyLoad = function(instanceSettings) {\n\tthis._settings = Object.assign({}, getDefaultSettings(), instanceSettings);\n\tthis._loadingCount = 0;\n\tthis._queryOriginNode =\n\t\tthis._settings.container === window\n\t\t\t? document\n\t\t\t: this._settings.container;\n\n\tthis._previousLoopTime = 0;\n\tthis._loopTimeout = null;\n\tthis._boundHandleScroll = this.handleScroll.bind(this);\n\n\tthis._isFirstLoop = true;\n\twindow.addEventListener(\"resize\", this._boundHandleScroll);\n\tthis.update();\n};\n\nLazyLoad.prototype = {\n\t_loopThroughElements: function(forceDownload) {\n\t\tconst settings = this._settings,\n\t\t\telements = this._elements,\n\t\t\telementsLength = !elements ? 0 : elements.length;\n\t\tlet i,\n\t\t\tprocessedIndexes = [],\n\t\t\tisFirstLoop = this._isFirstLoop;\n\n\t\tif (isFirstLoop) {\n\t\t\tthis._isFirstLoop = false;\n\t\t}\n\n\t\tif (elementsLength === 0) {\n\t\t\tthis._stopScrollHandler();\n\t\t\treturn;\n\t\t}\n\n\t\tfor (i = 0; i < elementsLength; i++) {\n\t\t\tlet element = elements[i];\n\t\t\t/* If must skip_invisible and element is invisible, skip it */\n\t\t\tif (settings.skip_invisible && element.offsetParent === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tforceDownload ||\n\t\t\t\tisInsideViewport(\n\t\t\t\t\telement,\n\t\t\t\t\tsettings.container,\n\t\t\t\t\tsettings.threshold\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif (isFirstLoop) {\n\t\t\t\t\taddClass(element, settings.class_initial);\n\t\t\t\t}\n\t\t\t\tthis.load(element);\n\t\t\t\tprocessedIndexes.push(i);\n\t\t\t}\n\t\t}\n\n\t\t// Removing processed elements from this._elements.\n\t\tremoveFromArray(elements, processedIndexes);\n\t},\n\n\t_startScrollHandler: function() {\n\t\tif (!this._isHandlingScroll) {\n\t\t\tthis._isHandlingScroll = true;\n\t\t\tthis._settings.container.addEventListener(\n\t\t\t\t\"scroll\",\n\t\t\t\tthis._boundHandleScroll\n\t\t\t);\n\t\t}\n\t},\n\n\t_stopScrollHandler: function() {\n\t\tif (this._isHandlingScroll) {\n\t\t\tthis._isHandlingScroll = false;\n\t\t\tthis._settings.container.removeEventListener(\n\t\t\t\t\"scroll\",\n\t\t\t\tthis._boundHandleScroll\n\t\t\t);\n\t\t}\n\t},\n\n\t_updateLoadingCount: function(plusMinus) {\n\t\tthis._loadingCount += plusMinus;\n\t\tif (this._elements.length === 0 && this._loadingCount === 0) {\n\t\t\tcallbackIfSet(this._settings.callback_finish);\n\t\t}\n\t},\n\n\thandleScroll: function() {\n\t\tconst throttle = this._settings.throttle;\n\n\t\tif (throttle !== 0) {\n\t\t\tlet now = Date.now();\n\t\t\tlet remainingTime = throttle - (now - this._previousLoopTime);\n\t\t\tif (remainingTime <= 0 || remainingTime > throttle) {\n\t\t\t\tif (this._loopTimeout) {\n\t\t\t\t\tclearTimeout(this._loopTimeout);\n\t\t\t\t\tthis._loopTimeout = null;\n\t\t\t\t}\n\t\t\t\tthis._previousLoopTime = now;\n\t\t\t\tthis._loopThroughElements();\n\t\t\t} else if (!this._loopTimeout) {\n\t\t\t\tthis._loopTimeout = setTimeout(\n\t\t\t\t\tfunction() {\n\t\t\t\t\t\tthis._previousLoopTime = Date.now();\n\t\t\t\t\t\tthis._loopTimeout = null;\n\t\t\t\t\t\tthis._loopThroughElements();\n\t\t\t\t\t}.bind(this),\n\t\t\t\t\tremainingTime\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tthis._loopThroughElements();\n\t\t}\n\t},\n\n\tloadAll: function() {\n\t\tthis._loopThroughElements(true);\n\t},\n\n\tupdate: function(elements) {\n\t\tconst settings = this._settings;\n\t\tconst nodeSet =\n\t\t\telements ||\n\t\t\tthis._queryOriginNode.querySelectorAll(settings.elements_selector);\n\n\t\tthis._elements = purgeProcessedElements(\n\t\t\tArray.prototype.slice.call(nodeSet) // NOTE: nodeset to array for IE compatibility\n\t\t);\n\n\t\tif (isBot) {\n\t\t\tthis.loadAll();\n\t\t\treturn;\n\t\t}\n\n\t\tthis._loopThroughElements();\n\t\tthis._startScrollHandler();\n\t},\n\n\tdestroy: function() {\n\t\twindow.removeEventListener(\"resize\", this._boundHandleScroll);\n\t\tif (this._loopTimeout) {\n\t\t\tclearTimeout(this._loopTimeout);\n\t\t\tthis._loopTimeout = null;\n\t\t}\n\t\tthis._stopScrollHandler();\n\t\tthis._elements = null;\n\t\tthis._queryOriginNode = null;\n\t\tthis._settings = null;\n\t},\n\n\tload: function(element, force) {\n\t\trevealElement(element, this, force);\n\t}\n};\n\n/* Automatic instances creation if required (useful for async script loading) */\nif (runningOnBrowser) {\n\tautoInitialize(LazyLoad, window.lazyLoadOptions);\n}\n\nreturn LazyLoad;\n\n})));\n"]} \ No newline at end of file diff --git a/assets/js/lazyload-8.2.js b/assets/js/lazyload-8.2.js deleted file mode 100755 index f1c3df5..0000000 --- a/assets/js/lazyload-8.2.js +++ /dev/null @@ -1,354 +0,0 @@ -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - -(function (global, factory) { - (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory(); -})(this, function () { - 'use strict'; - - var defaultSettings = { - elements_selector: "img", - container: window, - threshold: 300, - throttle: 150, - data_src: "original", - data_srcset: "original-set", - class_loading: "loading", - class_loaded: "loaded", - class_error: "error", - class_initial: "initial", - skip_invisible: true, - callback_load: null, - callback_error: null, - callback_set: null, - callback_processed: null - }; - - var isBot = !("onscroll" in window) || /glebot/.test(navigator.userAgent); - - var callCallback = function callCallback(callback, argument) { - if (callback) { - callback(argument); - } - }; - - var getTopOffset = function getTopOffset(element) { - return element.getBoundingClientRect().top + window.pageYOffset - element.ownerDocument.documentElement.clientTop; - }; - - var isBelowViewport = function isBelowViewport(element, container, threshold) { - var fold = container === window ? window.innerHeight + window.pageYOffset : getTopOffset(container) + container.offsetHeight; - return fold <= getTopOffset(element) - threshold; - }; - - var getLeftOffset = function getLeftOffset(element) { - return element.getBoundingClientRect().left + window.pageXOffset - element.ownerDocument.documentElement.clientLeft; - }; - - var isAtRightOfViewport = function isAtRightOfViewport(element, container, threshold) { - var documentWidth = window.innerWidth; - var fold = container === window ? documentWidth + window.pageXOffset : getLeftOffset(container) + documentWidth; - return fold <= getLeftOffset(element) - threshold; - }; - - var isAboveViewport = function isAboveViewport(element, container, threshold) { - var fold = container === window ? window.pageYOffset : getTopOffset(container); - return fold >= getTopOffset(element) + threshold + element.offsetHeight; - }; - - var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) { - var fold = container === window ? window.pageXOffset : getLeftOffset(container); - return fold >= getLeftOffset(element) + threshold + element.offsetWidth; - }; - - var isInsideViewport = function isInsideViewport(element, container, threshold) { - return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold); - }; - - /* Creates instance and notifies it through the window element */ - var createInstance = function createInstance(classObj, options) { - var instance = new classObj(options); - var event = new CustomEvent("LazyLoad::Initialized", { detail: { instance: instance } }); - window.dispatchEvent(event); - }; - - /* Auto initialization of one or more instances of lazyload, depending on the - options passed in (plain object or an array) */ - var autoInitialize = function autoInitialize(classObj, options) { - var optsLength = options.length; - if (!optsLength) { - // Plain object - createInstance(classObj, options); - } else { - // Array of objects - for (var i = 0; i < optsLength; i++) { - createInstance(classObj, options[i]); - } - } - }; - - var dataPrefix = "data-"; - - var getData = function getData(element, attribute) { - return element.getAttribute(dataPrefix + attribute); - }; - - var setData = function setData(element, attribute, value) { - return element.setAttribute(dataPrefix + attribute, value); - }; - - var setSourcesForPicture = function setSourcesForPicture(element, srcsetDataAttribute) { - var parent = element.parentElement; - if (parent.tagName !== "PICTURE") { - return; - } - for (var i = 0; i < parent.children.length; i++) { - var pictureChild = parent.children[i]; - if (pictureChild.tagName === "SOURCE") { - var sourceSrcset = getData(pictureChild, srcsetDataAttribute); - if (sourceSrcset) { - pictureChild.setAttribute("srcset", sourceSrcset); - } - } - } - }; - - var setSources = function setSources(element, srcsetDataAttribute, srcDataAttribute) { - var tagName = element.tagName; - var elementSrc = getData(element, srcDataAttribute); - if (tagName === "IMG") { - setSourcesForPicture(element, srcsetDataAttribute); - var imgSrcset = getData(element, srcsetDataAttribute); - if (imgSrcset) { - element.setAttribute("srcset", imgSrcset); - } - if (elementSrc) { - element.setAttribute("src", elementSrc); - } - return; - } - if (tagName === "IFRAME") { - if (elementSrc) { - element.setAttribute("src", elementSrc); - } - return; - } - if (elementSrc) { - element.style.backgroundImage = 'url("' + elementSrc + '")'; - } - }; - - var supportsClassList = !!document.body.classList; - - var addClass = function addClass(element, className) { - if (supportsClassList) { - element.classList.add(className); - return; - } - element.className += (element.className ? " " : "") + className; - }; - - var removeClass = function removeClass(element, className) { - if (supportsClassList) { - element.classList.remove(className); - return; - } - element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, ""); - }; - - /* - * Constructor - */ - - var LazyLoad = function LazyLoad(instanceSettings) { - this._settings = _extends({}, defaultSettings, instanceSettings); - this._queryOriginNode = this._settings.container === window ? document : this._settings.container; - - this._previousLoopTime = 0; - this._loopTimeout = null; - this._boundHandleScroll = this.handleScroll.bind(this); - - this._isFirstLoop = true; - window.addEventListener("resize", this._boundHandleScroll); - this.update(); - }; - - LazyLoad.prototype = { - - /* - * Private methods - */ - - _reveal: function _reveal(element) { - var settings = this._settings; - - var errorCallback = function errorCallback() { - /* As this method is asynchronous, it must be protected against external destroy() calls */ - if (!settings) { - return; - } - element.removeEventListener("load", loadCallback); - element.removeEventListener("error", errorCallback); - removeClass(element, settings.class_loading); - addClass(element, settings.class_error); - callCallback(settings.callback_error, element); - }; - - var loadCallback = function loadCallback() { - /* As this method is asynchronous, it must be protected against external destroy() calls */ - if (!settings) { - return; - } - removeClass(element, settings.class_loading); - addClass(element, settings.class_loaded); - element.removeEventListener("load", loadCallback); - element.removeEventListener("error", errorCallback); - /* Calling LOAD callback */ - callCallback(settings.callback_load, element); - }; - - if (element.tagName === "IMG" || element.tagName === "IFRAME") { - element.addEventListener("load", loadCallback); - element.addEventListener("error", errorCallback); - addClass(element, settings.class_loading); - } - - setSources(element, settings.data_srcset, settings.data_src); - /* Calling SET callback */ - callCallback(settings.callback_set, element); - }, - - _loopThroughElements: function _loopThroughElements() { - var settings = this._settings, - elements = this._elements, - elementsLength = !elements ? 0 : elements.length; - var i = void 0, - processedIndexes = [], - firstLoop = this._isFirstLoop; - - for (i = 0; i < elementsLength; i++) { - var element = elements[i]; - /* If must skip_invisible and element is invisible, skip it */ - if (settings.skip_invisible && element.offsetParent === null) { - continue; - } - - if (isBot || isInsideViewport(element, settings.container, settings.threshold)) { - if (firstLoop) { - addClass(element, settings.class_initial); - } - /* Start loading the image */ - this._reveal(element); - /* Marking the element as processed. */ - processedIndexes.push(i); - setData(element, "was-processed", true); - } - } - /* Removing processed elements from this._elements. */ - while (processedIndexes.length) { - elements.splice(processedIndexes.pop(), 1); - /* Calling the end loop callback */ - callCallback(settings.callback_processed, elements.length); - } - /* Stop listening to scroll event when 0 elements remains */ - if (elementsLength === 0) { - this._stopScrollHandler(); - } - /* Sets isFirstLoop to false */ - if (firstLoop) { - this._isFirstLoop = false; - } - }, - - _purgeElements: function _purgeElements() { - var elements = this._elements, - elementsLength = elements.length; - var i = void 0, - elementsToPurge = []; - - for (i = 0; i < elementsLength; i++) { - var element = elements[i]; - /* If the element has already been processed, skip it */ - if (getData(element, "was-processed")) { - elementsToPurge.push(i); - } - } - /* Removing elements to purge from this._elements. */ - while (elementsToPurge.length > 0) { - elements.splice(elementsToPurge.pop(), 1); - } - }, - - _startScrollHandler: function _startScrollHandler() { - if (!this._isHandlingScroll) { - this._isHandlingScroll = true; - this._settings.container.addEventListener("scroll", this._boundHandleScroll); - } - }, - - _stopScrollHandler: function _stopScrollHandler() { - if (this._isHandlingScroll) { - this._isHandlingScroll = false; - this._settings.container.removeEventListener("scroll", this._boundHandleScroll); - } - }, - - /* - * Public methods - */ - - handleScroll: function handleScroll() { - var throttle = this._settings.throttle; - - if (throttle !== 0) { - var now = Date.now(); - var remainingTime = throttle - (now - this._previousLoopTime); - if (remainingTime <= 0 || remainingTime > throttle) { - if (this._loopTimeout) { - clearTimeout(this._loopTimeout); - this._loopTimeout = null; - } - this._previousLoopTime = now; - this._loopThroughElements(); - } else if (!this._loopTimeout) { - this._loopTimeout = setTimeout(function () { - this._previousLoopTime = Date.now(); - this._loopTimeout = null; - this._loopThroughElements(); - }.bind(this), remainingTime); - } - } else { - this._loopThroughElements(); - } - }, - - update: function update() { - // Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector - this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)); - this._purgeElements(); - this._loopThroughElements(); - this._startScrollHandler(); - }, - - destroy: function destroy() { - window.removeEventListener("resize", this._boundHandleScroll); - if (this._loopTimeout) { - clearTimeout(this._loopTimeout); - this._loopTimeout = null; - } - this._stopScrollHandler(); - this._elements = null; - this._queryOriginNode = null; - this._settings = null; - } - }; - - /* Automatic instances creation if required (useful for async script loading!) */ - var autoInitOptions = window.lazyLoadOptions; - if (autoInitOptions) { - autoInitialize(LazyLoad, autoInitOptions); - } - - return LazyLoad; -}); \ No newline at end of file diff --git a/assets/js/lazyload-8.2.min.js b/assets/js/lazyload-8.2.min.js deleted file mode 100755 index 7765db5..0000000 --- a/assets/js/lazyload-8.2.min.js +++ /dev/null @@ -1 +0,0 @@ -var _extends=Object.assign||function(e){for(var t=1;t=o(e)+n+e.offsetHeight},a=function(e,t,n){return(t===window?window.pageXOffset:s(t))>=s(e)+n+e.offsetWidth},c=function(e,t,n){return!(i(e,t,n)||l(e,t,n)||r(e,t,n)||a(e,t,n))},u=function(e,t){var n=new e(t),o=new CustomEvent("LazyLoad::Initialized",{detail:{instance:n}});window.dispatchEvent(o)},d=function(e,t){return e.getAttribute("data-"+t)},h=function(e,t,n){return e.setAttribute("data-"+t,n)},f=function(e,t){var n=e.parentElement;if("PICTURE"===n.tagName)for(var o=0;o0;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||n>e?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var w=window.lazyLoadOptions;return w&&function(e,t){var n=t.length;if(n)for(var o=0;o= getTopOffset(element) + threshold + element.offsetHeight; - }; - - var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) { - var fold = container === window ? window.pageXOffset : getLeftOffset(container); - return fold >= getLeftOffset(element) + threshold + element.offsetWidth; - }; - - var isInsideViewport = function isInsideViewport(element, container, threshold) { - return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold); - }; - - /* Creates instance and notifies it through the window element */ - var createInstance = function createInstance(classObj, options) { - var event; - var eventString = "LazyLoad::Initialized"; - var instance = new classObj(options); - try { - // Works in modern browsers - event = new CustomEvent(eventString, { detail: { instance: instance } }); - } catch (err) { - // Works in Internet Explorer (all versions) - event = document.createEvent("CustomEvent"); - event.initCustomEvent(eventString, false, false, { instance: instance }); - } - window.dispatchEvent(event); - }; - - /* Auto initialization of one or more instances of lazyload, depending on the - options passed in (plain object or an array) */ - var autoInitialize = function autoInitialize(classObj, options) { - var optsLength = options.length; - if (!optsLength) { - // Plain object - createInstance(classObj, options); - } else { - // Array of objects - for (var i = 0; i < optsLength; i++) { - createInstance(classObj, options[i]); - } - } - }; - - var dataPrefix = "data-"; - - var getData = function getData(element, attribute) { - return element.getAttribute(dataPrefix + attribute); - }; - - var setData = function setData(element, attribute, value) { - return element.setAttribute(dataPrefix + attribute, value); - }; - - var setSourcesForPicture = function setSourcesForPicture(element, srcsetDataAttribute) { - var parent = element.parentNode; - if (parent.tagName !== "PICTURE") { - return; - } - for (var i = 0; i < parent.children.length; i++) { - var pictureChild = parent.children[i]; - if (pictureChild.tagName === "SOURCE") { - var sourceSrcset = getData(pictureChild, srcsetDataAttribute); - if (sourceSrcset) { - pictureChild.setAttribute("srcset", sourceSrcset); - } - } - } - }; - - var setSources = function setSources(element, srcsetDataAttribute, srcDataAttribute) { - var tagName = element.tagName; - var elementSrc = getData(element, srcDataAttribute); - if (tagName === "IMG") { - setSourcesForPicture(element, srcsetDataAttribute); - var imgSrcset = getData(element, srcsetDataAttribute); - if (imgSrcset) { - element.setAttribute("srcset", imgSrcset); - } - if (elementSrc) { - element.setAttribute("src", elementSrc); - } - return; - } - if (tagName === "IFRAME") { - if (elementSrc) { - element.setAttribute("src", elementSrc); - } - return; - } - if (elementSrc) { - element.style.backgroundImage = 'url("' + elementSrc + '")'; - } - }; - - var supportsClassList = "classList" in document.createElement("p"); - - var addClass = function addClass(element, className) { - if (supportsClassList) { - element.classList.add(className); - return; - } - element.className += (element.className ? " " : "") + className; - }; - - var removeClass = function removeClass(element, className) { - if (supportsClassList) { - element.classList.remove(className); - return; - } - element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, ""); - }; - - /* - * Constructor - */ - - var LazyLoad = function LazyLoad(instanceSettings) { - this._settings = _extends({}, defaultSettings, instanceSettings); - this._queryOriginNode = this._settings.container === window ? document : this._settings.container; - - this._previousLoopTime = 0; - this._loopTimeout = null; - this._boundHandleScroll = this.handleScroll.bind(this); - - this._isFirstLoop = true; - window.addEventListener("resize", this._boundHandleScroll); - this.update(); - }; - - LazyLoad.prototype = { - - /* - * Private methods - */ - - _reveal: function _reveal(element) { - var settings = this._settings; - - var errorCallback = function errorCallback() { - /* As this method is asynchronous, it must be protected against external destroy() calls */ - if (!settings) { - return; - } - element.removeEventListener("load", loadCallback); - element.removeEventListener("error", errorCallback); - removeClass(element, settings.class_loading); - addClass(element, settings.class_error); - callCallback(settings.callback_error, element); - }; - - var loadCallback = function loadCallback() { - /* As this method is asynchronous, it must be protected against external destroy() calls */ - if (!settings) { - return; - } - removeClass(element, settings.class_loading); - addClass(element, settings.class_loaded); - element.removeEventListener("load", loadCallback); - element.removeEventListener("error", errorCallback); - /* Calling LOAD callback */ - callCallback(settings.callback_load, element); - }; - - if (element.tagName === "IMG" || element.tagName === "IFRAME") { - element.addEventListener("load", loadCallback); - element.addEventListener("error", errorCallback); - addClass(element, settings.class_loading); - } - - setSources(element, settings.data_srcset, settings.data_src); - /* Calling SET callback */ - callCallback(settings.callback_set, element); - }, - - _loopThroughElements: function _loopThroughElements() { - var settings = this._settings, - elements = this._elements, - elementsLength = !elements ? 0 : elements.length; - var i = void 0, - processedIndexes = [], - firstLoop = this._isFirstLoop; - - for (i = 0; i < elementsLength; i++) { - var element = elements[i]; - /* If must skip_invisible and element is invisible, skip it */ - if (settings.skip_invisible && element.offsetParent === null) { - continue; - } - - if (isBot || isInsideViewport(element, settings.container, settings.threshold)) { - if (firstLoop) { - addClass(element, settings.class_initial); - } - /* Start loading the image */ - this._reveal(element); - /* Marking the element as processed. */ - processedIndexes.push(i); - setData(element, "was-processed", true); - } - } - /* Removing processed elements from this._elements. */ - while (processedIndexes.length) { - elements.splice(processedIndexes.pop(), 1); - /* Calling the end loop callback */ - callCallback(settings.callback_processed, elements.length); - } - /* Stop listening to scroll event when 0 elements remains */ - if (elementsLength === 0) { - this._stopScrollHandler(); - } - /* Sets isFirstLoop to false */ - if (firstLoop) { - this._isFirstLoop = false; - } - }, - - _purgeElements: function _purgeElements() { - var elements = this._elements, - elementsLength = elements.length; - var i = void 0, - elementsToPurge = []; - - for (i = 0; i < elementsLength; i++) { - var element = elements[i]; - /* If the element has already been processed, skip it */ - if (getData(element, "was-processed")) { - elementsToPurge.push(i); - } - } - /* Removing elements to purge from this._elements. */ - while (elementsToPurge.length > 0) { - elements.splice(elementsToPurge.pop(), 1); - } - }, - - _startScrollHandler: function _startScrollHandler() { - if (!this._isHandlingScroll) { - this._isHandlingScroll = true; - this._settings.container.addEventListener("scroll", this._boundHandleScroll); - } - }, - - _stopScrollHandler: function _stopScrollHandler() { - if (this._isHandlingScroll) { - this._isHandlingScroll = false; - this._settings.container.removeEventListener("scroll", this._boundHandleScroll); - } - }, - - /* - * Public methods - */ - - handleScroll: function handleScroll() { - var throttle = this._settings.throttle; - - if (throttle !== 0) { - var now = Date.now(); - var remainingTime = throttle - (now - this._previousLoopTime); - if (remainingTime <= 0 || remainingTime > throttle) { - if (this._loopTimeout) { - clearTimeout(this._loopTimeout); - this._loopTimeout = null; - } - this._previousLoopTime = now; - this._loopThroughElements(); - } else if (!this._loopTimeout) { - this._loopTimeout = setTimeout(function () { - this._previousLoopTime = Date.now(); - this._loopTimeout = null; - this._loopThroughElements(); - }.bind(this), remainingTime); - } - } else { - this._loopThroughElements(); - } - }, - - update: function update() { - // Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector - this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)); - this._purgeElements(); - this._loopThroughElements(); - this._startScrollHandler(); - }, - - destroy: function destroy() { - window.removeEventListener("resize", this._boundHandleScroll); - if (this._loopTimeout) { - clearTimeout(this._loopTimeout); - this._loopTimeout = null; - } - this._stopScrollHandler(); - this._elements = null; - this._queryOriginNode = null; - this._settings = null; - } - }; - - /* Automatic instances creation if required (useful for async script loading!) */ - var autoInitOptions = window.lazyLoadOptions; - if (autoInitOptions) { - autoInitialize(LazyLoad, autoInitOptions); - } - - return LazyLoad; -}); \ No newline at end of file diff --git a/assets/js/lazyload-8.5.2.min.js b/assets/js/lazyload-8.5.2.min.js deleted file mode 100755 index df081d6..0000000 --- a/assets/js/lazyload-8.5.2.min.js +++ /dev/null @@ -1 +0,0 @@ -var _extends=Object.assign||function(e){for(var t=1;t=o(e)+n+e.offsetHeight},a=function(e,t,n){return(t===window?window.pageXOffset:s(t))>=s(e)+n+e.offsetWidth},c=function(e,t,n){return!(i(e,t,n)||l(e,t,n)||r(e,t,n)||a(e,t,n))},u=function(e,t){var n,o=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},d=function(e,t){return e.getAttribute("data-"+t)},h=function(e,t,n){return e.setAttribute("data-"+t,n)},f=function(e,t){var n=e.parentNode;if("PICTURE"===n.tagName)for(var o=0;o0;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||n>e?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var w=window.lazyLoadOptions;return w&&function(e,t){var n=t.length;if(n)for(var o=0;o= getTopOffset(element) + threshold + element.offsetHeight; - }; - - var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) { - var fold = container === window ? window.pageXOffset : getLeftOffset(container); - return fold >= getLeftOffset(element) + threshold + element.offsetWidth; - }; - - var isInsideViewport = function isInsideViewport(element, container, threshold) { - return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold); - }; - - /* Creates instance and notifies it through the window element */ - var createInstance = function createInstance(classObj, options) { - var event; - var eventString = "LazyLoad::Initialized"; - var instance = new classObj(options); - try { - // Works in modern browsers - event = new CustomEvent(eventString, { detail: { instance: instance } }); - } catch (err) { - // Works in Internet Explorer (all versions) - event = document.createEvent("CustomEvent"); - event.initCustomEvent(eventString, false, false, { instance: instance }); - } - window.dispatchEvent(event); - }; - - /* Auto initialization of one or more instances of lazyload, depending on the - options passed in (plain object or an array) */ - var autoInitialize = function autoInitialize(classObj, options) { - var optsLength = options.length; - if (!optsLength) { - // Plain object - createInstance(classObj, options); - } else { - // Array of objects - for (var i = 0; i < optsLength; i++) { - createInstance(classObj, options[i]); - } - } - }; - - var dataPrefix = "data-"; - - var getData = function getData(element, attribute) { - return element.getAttribute(dataPrefix + attribute); - }; - - var setData = function setData(element, attribute, value) { - return element.setAttribute(dataPrefix + attribute, value); - }; - - var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName) { - for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) { - if (childTag.tagName === "SOURCE") { - var attributeValue = getData(childTag, dataAttrName); - if (attributeValue) { - childTag.setAttribute(attrName, attributeValue); - } - } - } - }; - - var setAttributeIfNotNullOrEmpty = function setAttributeIfNotNullOrEmpty(element, attrName, value) { - if (!value) { - return; - } - element.setAttribute(attrName, value); - }; - - function setSources(element, settings) { - var dataAttrSrcName = settings.data_src; - var elementSrc = getData(element, dataAttrSrcName); - var tagName = element.tagName; - if (tagName === "IMG") { - var dataAttrSrcSetName = settings.data_srcset; - var elementSrcSet = getData(element, dataAttrSrcSetName); - var parent = element.parentNode; - if (parent && parent.tagName === "PICTURE") { - setSourcesInChildren(parent, "srcset", dataAttrSrcSetName); - } - setAttributeIfNotNullOrEmpty(element, "srcset", elementSrcSet); - setAttributeIfNotNullOrEmpty(element, "src", elementSrc); - return; - } - if (tagName === "IFRAME") { - setAttributeIfNotNullOrEmpty(element, "src", elementSrc); - return; - } - if (tagName === "VIDEO") { - setSourcesInChildren(element, "src", dataAttrSrcName); - setAttributeIfNotNullOrEmpty(element, "src", elementSrc); - return; - } - if (elementSrc) { - element.style.backgroundImage = 'url("' + elementSrc + '")'; - } - } - - var runningOnBrowser = typeof window !== "undefined"; - - var supportsClassList = runningOnBrowser && "classList" in document.createElement("p"); - - var addClass = function addClass(element, className) { - if (supportsClassList) { - element.classList.add(className); - return; - } - element.className += (element.className ? " " : "") + className; - }; - - var removeClass = function removeClass(element, className) { - if (supportsClassList) { - element.classList.remove(className); - return; - } - element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, ""); - }; - - /* - * Constructor - */ - - var LazyLoad = function LazyLoad(instanceSettings) { - this._settings = _extends({}, getDefaultSettings(), instanceSettings); - this._queryOriginNode = this._settings.container === window ? document : this._settings.container; - - this._previousLoopTime = 0; - this._loopTimeout = null; - this._boundHandleScroll = this.handleScroll.bind(this); - - this._isFirstLoop = true; - window.addEventListener("resize", this._boundHandleScroll); - this.update(); - }; - - LazyLoad.prototype = { - - /* - * Private methods - */ - - _reveal: function _reveal(element) { - var settings = this._settings; - - var errorCallback = function errorCallback() { - /* As this method is asynchronous, it must be protected against external destroy() calls */ - if (!settings) { - return; - } - element.removeEventListener("load", loadCallback); - element.removeEventListener("error", errorCallback); - removeClass(element, settings.class_loading); - addClass(element, settings.class_error); - callCallback(settings.callback_error, element); - }; - - var loadCallback = function loadCallback() { - /* As this method is asynchronous, it must be protected against external destroy() calls */ - if (!settings) { - return; - } - removeClass(element, settings.class_loading); - addClass(element, settings.class_loaded); - element.removeEventListener("load", loadCallback); - element.removeEventListener("error", errorCallback); - callCallback(settings.callback_load, element); - }; - - callCallback(settings.callback_enter, element); - if (["IMG", "IFRAME", "VIDEO"].indexOf(element.tagName) > -1) { - element.addEventListener("load", loadCallback); - element.addEventListener("error", errorCallback); - addClass(element, settings.class_loading); - } - setSources(element, settings); - callCallback(settings.callback_set, element); - }, - - _loopThroughElements: function _loopThroughElements(forceDownload) { - var settings = this._settings, - elements = this._elements, - elementsLength = !elements ? 0 : elements.length; - var i = void 0, - processedIndexes = [], - firstLoop = this._isFirstLoop; - - for (i = 0; i < elementsLength; i++) { - var element = elements[i]; - /* If must skip_invisible and element is invisible, skip it */ - if (settings.skip_invisible && element.offsetParent === null) { - continue; - } - - if (isBot || forceDownload || isInsideViewport(element, settings.container, settings.threshold)) { - if (firstLoop) { - addClass(element, settings.class_initial); - } - /* Start loading the image */ - this._reveal(element); - /* Marking the element as processed. */ - processedIndexes.push(i); - setData(element, "was-processed", true); - } - } - /* Removing processed elements from this._elements. */ - while (processedIndexes.length) { - elements.splice(processedIndexes.pop(), 1); - callCallback(settings.callback_processed, elements.length); - } - /* Stop listening to scroll event when 0 elements remains */ - if (elementsLength === 0) { - this._stopScrollHandler(); - } - /* Sets isFirstLoop to false */ - if (firstLoop) { - this._isFirstLoop = false; - } - }, - - _purgeElements: function _purgeElements() { - var elements = this._elements, - elementsLength = elements.length; - var i = void 0, - elementsToPurge = []; - - for (i = 0; i < elementsLength; i++) { - var element = elements[i]; - /* If the element has already been processed, skip it */ - if (getData(element, "was-processed")) { - elementsToPurge.push(i); - } - } - /* Removing elements to purge from this._elements. */ - while (elementsToPurge.length > 0) { - elements.splice(elementsToPurge.pop(), 1); - } - }, - - _startScrollHandler: function _startScrollHandler() { - if (!this._isHandlingScroll) { - this._isHandlingScroll = true; - this._settings.container.addEventListener("scroll", this._boundHandleScroll); - } - }, - - _stopScrollHandler: function _stopScrollHandler() { - if (this._isHandlingScroll) { - this._isHandlingScroll = false; - this._settings.container.removeEventListener("scroll", this._boundHandleScroll); - } - }, - - /* - * Public methods - */ - - handleScroll: function handleScroll() { - var throttle = this._settings.throttle; - - if (throttle !== 0) { - var now = Date.now(); - var remainingTime = throttle - (now - this._previousLoopTime); - if (remainingTime <= 0 || remainingTime > throttle) { - if (this._loopTimeout) { - clearTimeout(this._loopTimeout); - this._loopTimeout = null; - } - this._previousLoopTime = now; - this._loopThroughElements(); - } else if (!this._loopTimeout) { - this._loopTimeout = setTimeout(function () { - this._previousLoopTime = Date.now(); - this._loopTimeout = null; - this._loopThroughElements(); - }.bind(this), remainingTime); - } - } else { - this._loopThroughElements(); - } - }, - - loadAll: function loadAll() { - this._loopThroughElements(true); - }, - - update: function update() { - // Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector - this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)); - this._purgeElements(); - this._loopThroughElements(); - this._startScrollHandler(); - }, - - destroy: function destroy() { - window.removeEventListener("resize", this._boundHandleScroll); - if (this._loopTimeout) { - clearTimeout(this._loopTimeout); - this._loopTimeout = null; - } - this._stopScrollHandler(); - this._elements = null; - this._queryOriginNode = null; - this._settings = null; - } - }; - - /* Automatic instances creation if required (useful for async script loading!) */ - var autoInitOptions = window.lazyLoadOptions; - if (runningOnBrowser && autoInitOptions) { - autoInitialize(LazyLoad, autoInitOptions); - } - - return LazyLoad; -}); \ No newline at end of file diff --git a/assets/js/lazyload-8.9.min.js b/assets/js/lazyload-8.9.min.js deleted file mode 100755 index 4bb336c..0000000 --- a/assets/js/lazyload-8.9.min.js +++ /dev/null @@ -1 +0,0 @@ -var _extends=Object.assign||function(e){for(var t=1;t=i(e)+n+e.offsetHeight},c=function(e,t,n){return(t===window?window.pageXOffset:l(t))>=l(e)+n+e.offsetWidth},u=function(e,t,n){return!(s(e,t,n)||a(e,t,n)||r(e,t,n)||c(e,t,n))},d=function(e,t){var n,o=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},h=function(e,t){return e.getAttribute("data-"+t)},f=function(e,t,n){return e.setAttribute("data-"+t,n)},_=function(e,t,n){for(var o,i=0;o=e.children[i];i+=1)if("SOURCE"===o.tagName){var s=h(o,n);s&&o.setAttribute(t,s)}},p=function(e,t,n){n&&e.setAttribute(t,n)},m="undefined"!=typeof window,g=m&&"classList"in document.createElement("p"),v=function(e,t){g?e.classList.add(t):e.className+=(e.className?" ":"")+t},w=function(e,t){g?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},b=function(e){this._settings=_extends({},t(),e),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()};b.prototype={_reveal:function(t){var n=this._settings,i=function e(){n&&(t.removeEventListener("load",s),t.removeEventListener("error",e),w(t,n.class_loading),v(t,n.class_error),o(n.callback_error,t))},s=function e(){n&&(w(t,n.class_loading),v(t,n.class_loaded),t.removeEventListener("load",e),t.removeEventListener("error",i),o(n.callback_load,t))};o(n.callback_enter,t),["IMG","IFRAME","VIDEO"].indexOf(t.tagName)>-1&&(t.addEventListener("load",s),t.addEventListener("error",i),v(t,n.class_loading)),e(t,n),o(n.callback_set,t)},_loopThroughElements:function(e){var t=this._settings,i=this._elements,s=i?i.length:0,l=void 0,r=[],a=this._isFirstLoop;for(l=0;l0;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||n>e?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},loadAll:function(){this._loopThroughElements(!0)},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null}};var y=window.lazyLoadOptions;return m&&y&&function(e,t){var n=t.length;if(n)for(var o=0;o=5.4.0" + "php": ">=5.4.0", + "league/container": "^2.4", + "wp-media/rocket-lazyload-common": "^1.0.0" }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4", diff --git a/composer.lock b/composer.lock index 77cd6b5..7b0cb4e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,196 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "7c228b400ab5d5e970dd8644a803bb40", - "packages": [], + "content-hash": "f29400f3ee27894ea8fb972d21229ce3", + "packages": [ + { + "name": "container-interop/container-interop", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/container-interop/container-interop.git", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "shasum": "" + }, + "require": { + "psr/container": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Interop\\Container\\": "src/Interop/Container/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", + "homepage": "https://github.com/container-interop/container-interop", + "time": "2017-02-14T19:40:03+00:00" + }, + { + "name": "league/container", + "version": "2.4.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/container.git", + "reference": "43f35abd03a12977a60ffd7095efd6a7808488c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/container/zipball/43f35abd03a12977a60ffd7095efd6a7808488c0", + "reference": "43f35abd03a12977a60ffd7095efd6a7808488c0", + "shasum": "" + }, + "require": { + "container-interop/container-interop": "^1.2", + "php": "^5.4.0 || ^7.0" + }, + "provide": { + "container-interop/container-interop-implementation": "^1.2", + "psr/container-implementation": "^1.0" + }, + "replace": { + "orno/di": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev", + "dev-1.x": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Container\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Phil Bennett", + "email": "philipobenito@gmail.com", + "homepage": "http://www.philipobenito.com", + "role": "Developer" + } + ], + "description": "A fast and intuitive dependency injection container.", + "homepage": "https://github.com/thephpleague/container", + "keywords": [ + "container", + "dependency", + "di", + "injection", + "league", + "provider", + "service" + ], + "time": "2017-05-10T09:20:27+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, + { + "name": "wp-media/rocket-lazyload-common", + "version": "v1.2", + "source": { + "type": "git", + "url": "https://github.com/wp-media/rocket-lazyload-common.git", + "reference": "db45190dd9fb3dddcdc335e180fa522d6789d0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/wp-media/rocket-lazyload-common/zipball/db45190dd9fb3dddcdc335e180fa522d6789d0bc", + "reference": "db45190dd9fb3dddcdc335e180fa522d6789d0bc", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "RocketLazyload\\": "src" + } + }, + "license": [ + "GPLv3" + ], + "authors": [ + { + "name": "WP Media", + "email": "contact@wp-media.me" + } + ], + "description": "Common Code between WP Rocket and Lazyload by WP Rocket", + "support": { + "source": "https://github.com/wp-media/rocket-lazyload-common/tree/v1.2", + "issues": "https://github.com/wp-media/rocket-lazyload-common/issues" + }, + "time": "2019-01-08T22:32:27+00:00" + } + ], "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -76,128 +264,237 @@ "time": "2017-12-06T16:27:17+00:00" }, { - "name": "squizlabs/php_codesniffer", - "version": "3.2.3", + "name": "phpcompatibility/php-compatibility", + "version": "9.1.1", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "4842476c434e375f9d3182ff7b89059583aa8b27" + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "2b63c5d284ab8857f7b1d5c240ddb507a6b2293c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27", - "reference": "4842476c434e375f9d3182ff7b89059583aa8b27", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/2b63c5d284ab8857f7b1d5c240ddb507a6b2293c", + "reference": "2b63c5d284ab8857f7b1d5c240ddb507a6b2293c", "shasum": "" }, "require": { - "ext-simplexml": "*", - "ext-tokenizer": "*", - "ext-xmlwriter": "*", - "php": ">=5.4.0" + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" }, - "bin": [ - "bin/phpcs", - "bin/phpcbf" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.x-dev" - } + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, + "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "LGPL-3.0-or-later" ], "authors": [ { - "name": "Greg Sherwood", + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + }, + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", "role": "lead" } ], - "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", "keywords": [ + "compatibility", "phpcs", "standards" ], - "time": "2018-02-20T21:35:23+00:00" + "time": "2018-12-30T23:16:27+00:00" }, { - "name": "wimg/php-compatibility", - "version": "8.1.0", + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/wimg/PHPCompatibility.git", - "reference": "4ac01e4fe8faaa4f8d3b3cd06ea92e5418ce472e" + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "9160de79fcd683b5c99e9c4133728d91529753ea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/4ac01e4fe8faaa4f8d3b3cd06ea92e5418ce472e", - "reference": "4ac01e4fe8faaa4f8d3b3cd06ea92e5418ce472e", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/9160de79fcd683b5c99e9c4133728d91529753ea", + "reference": "9160de79fcd683b5c99e9c4133728d91529753ea", "shasum": "" }, "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.2 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" + "phpcompatibility/php-compatibility": "^9.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0" + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", - "autoload": { - "psr-4": { - "PHPCompatibility\\": "PHPCompatibility/" + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards" + ], + "time": "2018-12-16T19:10:44+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "cb303f0067cd5b366a41d4fb0e254fb40ff02efd" }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/cb303f0067cd5b366a41d4fb0e254fb40ff02efd", + "reference": "cb303f0067cd5b366a41d4fb0e254fb40ff02efd", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", "license": [ - "LGPL-3.0" + "LGPL-3.0-or-later" ], "authors": [ { "name": "Wim Godden", "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" } ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", "keywords": [ "compatibility", + "phpcs", + "standards", + "wordpress" + ], + "time": "2018-10-07T18:31:37+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "379deb987e26c7cd103a7b387aea178baec96e48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", + "reference": "379deb987e26c7cd103a7b387aea178baec96e48", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ "phpcs", "standards" ], - "time": "2017-12-27T21:58:38+00:00" + "time": "2018-12-19T23:57:18+00:00" }, { "name": "wp-coding-standards/wpcs", - "version": "0.14.1", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", - "reference": "cf6b310caad735816caef7573295f8a534374706" + "reference": "f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706", - "reference": "cf6b310caad735816caef7573295f8a534374706", + "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c", + "reference": "f328bcafd97377e8e5e5d7b244d5ddbf301a3a5c", "shasum": "" }, "require": { "php": ">=5.3", "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" }, + "require-dev": { + "phpcompatibility/php-compatibility": "^9.0" + }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -216,7 +513,7 @@ "standards", "wordpress" ], - "time": "2018-02-16T01:57:48+00:00" + "time": "2018-12-18T09:43:51+00:00" } ], "aliases": [], @@ -224,6 +521,8 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=5.4.0" + }, "platform-dev": [] } diff --git a/main.php b/main.php new file mode 100644 index 0000000..6dab495 --- /dev/null +++ b/main.php @@ -0,0 +1,11 @@ + + @@ -15,15 +16,7 @@ *.js /vendor/* /assets/* - - - - - - - - - + @@ -31,12 +24,7 @@ - - - - - - + diff --git a/readme.txt b/readme.txt index ae39d63..c980c39 100644 --- a/readme.txt +++ b/readme.txt @@ -2,9 +2,9 @@ Contributors: creativejuiz, tabrisrp, wp_media Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar, youtube Requires at least: 4.7 -Tested up to: 4.9 +Tested up to: 5.0.2 Requires PHP: 5.4 -Stable tag: 1.4.9 +Stable tag: 2.0 Lazy Load your images and iframes, replace Youtube videos by a preview thumbnail. @@ -69,7 +69,26 @@ add_filter( 'rocket_lazyload_threshold', 'rocket_lazyload_custom_threshold' ); Some plugins are not compatible without lazy loading. Please open a support thread, and we will see how we can solve the issue by excluding lazy loading for this plugin. += How can I lazyload a background-image? = + +The element you want to apply lazyload on must have this specific markup: + +`
` + +The element must have the class `rocket-lazyload-bg`, and a `data-bg` attribute, which value is the CSS url for the image. + == Changelog == += 2.0 = +* Enhancement: Lazyload is now applied on the template_redirect hook, which should allow the plugin to apply the optimization on more images and encountering less conflicts at the same time +* Enhancement: Specifically target with the lazyload script images/iframes elements with a data-lazy-src attribute +* Enhancement: Update lazyload script to the latest version +* Enhancement: Possibility to apply lazyload on background-images with a specific markup, see FAQ +* Enhancement: Use a svg image as placeholder instead of a base64 gif +* Bugfix: Only use MutationObserver if available in the browser +* Bugfix: When using the Youtube thumbnail option, correctly format the Youtube query if the video URL is encoded +* Bugfix: Improve iframe matching to prevent unexpected results +* Bugfix: Update CSS for the Youtube thumbnail option to prevent issue with the Gutenberg embeds block + = 1.4.9 = * Enhancement: Update lazyload script to the latest available version * Enhancement: Use lazy-sizes to prevent W3C validation error when sizes is defined but srcset is not diff --git a/rocket-lazy-load.php b/rocket-lazy-load.php index d89417e..1a793b4 100644 --- a/rocket-lazy-load.php +++ b/rocket-lazy-load.php @@ -3,13 +3,13 @@ * Plugin Name: Lazy Load by WP Rocket * Plugin URI: http://wordpress.org/plugins/rocket-lazy-load/ * Description: The tiny Lazy Load script for WordPress without jQuery or others libraries. - * Version: 1.4.9 + * Version: 2.0 * Author: WP Media * Author URI: https://wp-rocket.me * Text Domain: rocket-lazy-load * Domain Path: /languages * - * Copyright 2015-2017 WP Media + * Copyright 2015-2019 WP Media * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,592 +25,52 @@ * along with this program. If not, see . */ -defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' ); +defined('ABSPATH') || die('Cheatin\' uh?'); -define( 'ROCKET_LL_VERSION', '1.4.9' ); -define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' ); -define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' ); -define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' ); -define( 'ROCKET_LL_FRONT_JS_URL', ROCKET_LL_ASSETS_URL . 'js/' ); +define('ROCKET_LL_VERSION', '2.0'); +define('ROCKET_LL_WP_VERSION', '4.7'); +define('ROCKET_LL_PHP_VERSION', '5.4'); +define('ROCKET_LL_BASENAME', plugin_basename(__FILE__)); +define('ROCKET_LL_PATH', realpath(plugin_dir_path(__FILE__)) . '/'); +define('ROCKET_LL_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); +define('ROCKET_LL_FRONT_JS_URL', ROCKET_LL_ASSETS_URL . 'js/'); +define('ROCKET_LL_INT_MAX', PHP_INT_MAX - 15); +require ROCKET_LL_PATH . 'src/rocket-lazyload-requirements-check.php'; /** - * Initialize the plugin. + * Loads plugin translations * - * @since 1.1 - * @return void - */ -function rocket_lazyload_init() { - load_plugin_textdomain( 'rocket-lazy-load', false, basename( dirname( __FILE__ ) ) . '/languages/' ); - - require ROCKET_LL_3RD_PARTY_PATH . '3rd-party.php'; - - if ( is_admin() ) { - require ROCKET_LL_PATH . 'admin/actions.php'; - require ROCKET_LL_PATH . 'admin/notices.php'; - require ROCKET_LL_PATH . 'admin/admin.php'; - } -} - -if ( version_compare( PHP_VERSION, '5.3', '<' ) ) { - /** - * Warning if PHP version is less than 5.3. - * - * @since 1.3 - */ - function rocket_lazyload_php_warning() { - echo '

' . esc_html( __( 'Rocket LazyLoad requires PHP 5.3 to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'rocket-lazy-load' ) ) . '

'; - if ( isset( $_GET['activate'] ) ) { // WPCS: CSRF ok. - unset( $_GET['activate'] ); - } - } - add_action( 'admin_notices', 'rocket_lazyload_php_warning' ); - - /** - * Deactivate plugin if needed. - * - * @since 1.3 - */ - function rocket_lazyload_deactivate_self() { - deactivate_plugins( plugin_basename( __FILE__ ) ); - } - add_action( 'admin_init', 'rocket_lazyload_deactivate_self' ); - - return; -} else { - add_action( 'plugins_loaded', 'rocket_lazyload_init' ); -} - -/** - * A wrapper to easily get rocket lazyload option - * - * @since 1.1 + * @since 2.0 * @author Remy Perona * - * @param string $option The option name. - * @param bool $default (default: false) The default value of option. - * @return mixed The option value - */ -function rocket_lazyload_get_option( $option, $default = false ) { - $options = get_option( 'rocket_lazyload_options' ); - return isset( $options[ $option ] ) && '' !== $options[ $option ] ? $options[ $option ] : $default; -} - -/** - * Set lazyload options - * - * @since 1.0 - */ -function rocket_lazyload_script() { - if ( ! rocket_lazyload_get_option( 'images' ) && ! rocket_lazyload_get_option( 'iframes' ) || ! apply_filters( 'do_rocket_lazyload', true ) ) { - return; - } - - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; - - /** - * Filters the threshold at which lazyload is triggered - * - * @since 1.2 - * @author Remy Perona - * - * @param int $threshold Threshold value. - */ - $threshold = apply_filters( 'rocket_lazyload_threshold', 300 ); - - $elements = []; - - if ( rocket_lazyload_get_option( 'images' ) ) { - $elements[] = 'img'; - } - - if ( rocket_lazyload_get_option( 'iframes' ) ) { - $elements[] = 'iframe'; - } - - echo ''; - - if ( rocket_lazyload_get_option( 'youtube' ) ) { - /** - * Filters the resolution of the YouTube thumbnail - * - * @since 1.4.8 - * @author Arun Basil Lal - * - * @param string $thumbnail_resolution The resolution of the thumbnail. Accepted values: default, mqdefault, sddefault, hqdefault, maxresdefault - */ - $thumbnail_resolution = apply_filters( 'rocket_lazyload_youtube_thumbnail_resolution', 'hqdefault' ); - - echo <<function lazyLoadThumb(e){var t='',a='
';return t.replace("ID",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement("iframe"),t="https://www.youtube.com/embed/ID?autoplay=1";t+=0===this.dataset.query.length?'':'&'+this.dataset.query;e.setAttribute("src",t.replace("ID",this.dataset.id)),e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","1"),this.parentNode.replaceChild(e,this)}document.addEventListener("DOMContentLoaded",function(){var e,t,a=document.getElementsByClassName("rll-youtube-player");for(t=0;t -HTML; - } -} -add_action( 'wp_footer', 'rocket_lazyload_script', PHP_INT_MAX ); - -/** - * Enqueue the lazyload script - * - * @since 1.2 - * @author Remy Perona - */ -function rocket_lazyload_enqueue() { - if ( ! rocket_lazyload_get_option( 'images' ) && ! rocket_lazyload_get_option( 'iframes' ) || ! apply_filters( 'do_rocket_lazyload', true ) ) { - return; - } - - if ( rocket_lazyload_get_option( 'youtube' ) ) { - $css = '.rll-youtube-player{position:relative;padding-bottom:56.23%;height:0;overflow:hidden;max-width:100%;background:#000;margin:5px}.rll-youtube-player iframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;background:0 0}.rll-youtube-player img{bottom:0;display:block;left:0;margin:auto;max-width:100%;width:100%;position:absolute;right:0;top:0;border:none;height:auto;cursor:pointer;-webkit-transition:.4s all;-moz-transition:.4s all;transition:.4s all}.rll-youtube-player img:hover{-webkit-filter:brightness(75%)}.rll-youtube-player .play{height:72px;width:72px;left:50%;top:50%;margin-left:-36px;margin-top:-36px;position:absolute;background:url(' . ROCKET_LL_ASSETS_URL . 'img/youtube.png) no-repeat;cursor:pointer}'; - - wp_register_style( 'rocket-lazyload', false ); - wp_enqueue_style( 'rocket-lazyload' ); - wp_add_inline_style( 'rocket-lazyload', $css ); - } -} -add_action( 'wp_enqueue_scripts', 'rocket_lazyload_enqueue', PHP_INT_MAX ); - -/** - * Replace Gravatar, thumbnails, images in post content and in widget text by LazyLoad - * - * @since 1.1 Support for get_image_tag filter. - * @since 1.0 - * - * @param string $html HTML code to parse. - * @return string Updated HTML code - */ -function rocket_lazyload_images( $html ) { - // Don't LazyLoad if the thumbnail is in admin, a feed, REST API or a post preview. - if ( ! rocket_lazyload_get_option( 'images' ) || is_admin() || is_feed() || is_preview() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || empty( $html ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) || wp_script_is( 'twentytwenty-twentytwenty', 'enqueued' ) ) { - return $html; - } - - // You can stop the LalyLoad process with a hook. - if ( ! apply_filters( 'do_rocket_lazyload', true ) ) { - return $html; - } - - return preg_replace_callback( '#]*) src=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))([^>]*)>#', 'rocket_lazyload_replace_callback', $html ); -} -add_filter( 'get_avatar', 'rocket_lazyload_images', PHP_INT_MAX ); -add_filter( 'the_content', 'rocket_lazyload_images', PHP_INT_MAX ); -add_filter( 'widget_text', 'rocket_lazyload_images', PHP_INT_MAX ); -add_filter( 'get_image_tag', 'rocket_lazyload_images', PHP_INT_MAX ); -add_filter( 'post_thumbnail_html', 'rocket_lazyload_images', PHP_INT_MAX ); - -/** - * Used to check if we have to LazyLoad this or not - * - * @since 1.1 Don't apply LazyLoad on images from WP Retina x2 - * @since 1.0.1 - * - * @param string $matches a string matching the pattern to find images in HTML code. - * @return string Updated string with lazyload data - */ -function rocket_lazyload_replace_callback( $matches ) { - if ( function_exists( 'wr2x_picture_rewrite' ) ) { - if ( wr2x_get_retina( trailingslashit( ABSPATH ) . wr2x_get_pathinfo_from_image_src( trim( $matches[2], '"' ) ) ) ) { - return $matches[0]; - } - } - $excluded_attributes = apply_filters( 'rocket_lazyload_excluded_attributes', array( - 'data-no-lazy=', - 'data-lazy-original=', - 'data-lazy-src=', - 'data-src=', - 'data-lazysrc=', - 'data-lazyload=', - 'data-bgposition=', - 'data-envira-src=', - 'fullurl=', - 'lazy-slider-img=', - 'data-srcset=', - 'class="ls-l', - 'class="ls-bg', - ) ); - - $excluded_src = apply_filters( 'rocket_lazyload_excluded_src', array( - '/wpcf7_captcha/', - 'timthumb.php?src', - ) ); - - if ( rocket_is_excluded_lazyload( $matches[1] . $matches[3], $excluded_attributes ) || rocket_is_excluded_lazyload( $matches[2], $excluded_src ) ) { - return $matches[0]; - } - - /** - * Filter the LazyLoad placeholder on src attribute - * - * @since 1.1 - * - * @param string $placeholder Placeholder that will be printed. - */ - $placeholder = apply_filters( 'rocket_lazyload_placeholder', '' ); - - $img = sprintf( '', $matches[1], $matches[2], $matches[3], $placeholder ); - - $img_noscript = sprintf( '', $matches[1], $matches[2], $matches[3] ); - - /** - * Filter the LazyLoad HTML output - * - * @since 1.0.2 - * - * @param array $img Output that will be printed - */ - $img = apply_filters( 'rocket_lazyload_html', $img, true ); - - return $img . $img_noscript; -} - -/** - * Determine if the current image should be excluded from lazyload - * - * @since 1.1 - * @author Remy Perona - * - * @param string $string String to search. - * @param array $excluded_values Array of excluded values to search in the string. - * @return bool True if one of the excluded values was found, false otherwise - */ -function rocket_is_excluded_lazyload( $string, $excluded_values ) { - foreach ( $excluded_values as $excluded_value ) { - if ( strpos( $string, $excluded_value ) !== false ) { - return true; - } - } - return false; -} - -/** - * Compatibility with images with srcset attribute - * - * @since 1.1 - * @author Geoffrey Crofte (code from WP Rocket plugin) - * - * @param string $html the HTML code to parse. - * @return string the updated HTML code - */ -function rocket_lazyload_on_srcset( $html ) { - if ( preg_match( '/srcset=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))/i', $html ) ) { - $html = str_replace( 'srcset=', 'data-lazy-srcset=', $html ); - } - - if ( preg_match( '/sizes=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))/i', $html ) ) { - $html = str_replace( 'sizes=', 'data-lazy-sizes=', $html ); - } - - return $html; -} -add_filter( 'rocket_lazyload_html', 'rocket_lazyload_on_srcset' ); - -/** - * Applies lazyload on images displayed using wp_get_attachment_image() - * - * @since 1.4.8 - * @author Remy Perona - * - * @param array $attr Attributes for the image markup. - * @return array - */ -function rocket_lazyload_get_attachment_image( $attr ) { - // Don't LazyLoad if the thumbnail is in admin, a feed, REST API or a post preview. - if ( ! rocket_lazyload_get_option( 'images' ) || is_admin() || is_feed() || is_preview() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || empty( $attr ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) || wp_script_is( 'twentytwenty-twentytwenty', 'enqueued' ) ) { - return $attr; - } - - // You can stop the LalyLoad process with a hook. - if ( ! apply_filters( 'do_rocket_lazyload', true ) ) { - return $attr; - } - - $attr['data-lazy-src'] = $attr['src']; - $attr['src'] = apply_filters( 'rocket_lazyload_placeholder', '' ); - - if ( isset( $attr['srcset'] ) ) { - $attr['data-lazy-srcset'] = $attr['srcset']; - unset( $attr['srcset'] ); - } - - if ( isset( $attr['sizes'] ) ) { - $attr['data-lazy-sizes'] = $attr['sizes']; - unset( $attr['sizes'] ); - } - - return $attr; -} -add_filter( 'wp_get_attachment_image_attributes', 'rocket_lazyload_get_attachment_image', 11 ); - -/** - * Replace WordPress smilies by Lazy Load - * - * @since 1.0 - */ -function rocket_lazyload_smilies() { - if ( ! rocket_lazyload_get_option( 'images' ) || ! apply_filters( 'do_rocket_lazyload', true ) ) { - return; - } - - remove_filter( 'the_content', 'convert_smilies' ); - remove_filter( 'the_excerpt', 'convert_smilies' ); - remove_filter( 'comment_text', 'convert_smilies', 20 ); - - add_filter( 'the_content', 'rocket_convert_smilies' ); - add_filter( 'the_excerpt', 'rocket_convert_smilies' ); - add_filter( 'comment_text', 'rocket_convert_smilies', 20 ); -} -add_action( 'init', 'rocket_lazyload_smilies' ); - -/** - * Convert text equivalent of smilies to images. - * - * @source convert_smilies() in /wp-includes/formattings.php - * @since 1.0 - * - * @param string $text Text to process. - * @return string Modified text - */ -function rocket_convert_smilies( $text ) { - global $wp_smiliessearch; - - if ( ! get_option( 'use_smilies' ) || empty( $wp_smiliessearch ) ) { - return $text; - } - - $output = ''; - // HTML loop taken from texturize function, could possible be consolidated. - $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between. - $stop = count( $textarr );// loop stuff. - - // Ignore proessing of specific tags. - $tags_to_ignore = 'code|pre|style|script|textarea'; - $ignore_block_element = ''; - - for ( $i = 0; $i < $stop; $i++ ) { - $content = $textarr[ $i ]; - - // If we're in an ignore block, wait until we find its closing tag. - if ( '' === $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')>/', $content, $matches ) ) { - $ignore_block_element = $matches[1]; - } - - // If it's not a tag and not in ignore block. - if ( '' === $ignore_block_element && strlen( $content ) > 0 && '<' !== $content[0] ) { - $content = preg_replace_callback( $wp_smiliessearch, 'rocket_translate_smiley', $content ); - } - - // did we exit ignore block. - if ( '' !== $ignore_block_element && '' === $content ) { - $ignore_block_element = ''; - } - - $output .= $content; - } - - return $output; -} - -/** - * Convert one smiley code to the icon graphic file equivalent. - * - * @source translate_smiley() in /wp-includes/formattings.php - * @since 1.0 - * - * @param array $matches An array of matching content. - * @return string HTML code for smiley + * @return void */ -function rocket_translate_smiley( $matches ) { - global $wpsmiliestrans; - - if ( count( $matches ) === 0 ) { - return ''; - } - - $smiley = trim( reset( $matches ) ); - $img = $wpsmiliestrans[ $smiley ]; - - $matches = array(); - $ext = preg_match( '/\.([^.]+)$/', $img, $matches ) ? strtolower( $matches[1] ) : false; - $image_exts = array( 'jpg', 'jpeg', 'jpe', 'gif', 'png' ); - - // Don't convert smilies that aren't images - they're probably emoji. - if ( ! in_array( $ext, $image_exts, true ) ) { - return $img; - } - - /** - * Filter the Smiley image URL before it's used in the image element. - * - * @since 2.9.0 - * - * @param string $smiley_url URL for the smiley image. - * @param string $img Filename for the smiley image. - * @param string $site_url Site URL, as returned by site_url(). - */ - $src_url = apply_filters( 'smilies_src', includes_url( "images/smilies/$img" ), $img, site_url() ); - - // Don't LazyLoad if process is stopped for these reasons. - if ( ! apply_filters( 'do_rocket_lazyload', true ) || is_feed() || is_preview() ) { - return sprintf( ' %s ', esc_url( $src_url ), esc_attr( $smiley ) ); - } +function rocket_lazyload_textdomain() +{ + // Load translations from the languages directory. + $locale = get_locale(); - /** This filter is documented in inc/front/lazyload.php */ - $placeholder = apply_filters( 'rocket_lazyload_placeholder', '' ); + // This filter is documented in /wp-includes/l10n.php. + $locale = apply_filters('plugin_locale', $locale, 'rocket-lazy-load'); // WPCS: prefix ok. + load_textdomain('rocket-lazy-load', WP_LANG_DIR . '/plugins/rocket-lazy-load-' . $locale . '.mo'); - return sprintf( ' %s ', $placeholder, esc_url( $src_url ), esc_attr( $smiley ) ); + load_plugin_textdomain('rocket-lazy-load', false, dirname(plugin_basename(__FILE__)) . '/languages/'); } -/** - * Replace iframes by LazyLoad - * - * @since 1.1 - * @author Geoffrey Crofte (code from WP Rocket plugin) - * - * @param string $html the HTML code to parse. - * @return string the updated HTML code - */ -function rocket_lazyload_iframes( $html ) { - // Don't LazyLoad if process is stopped for these reasons. - if ( ! rocket_lazyload_get_option( 'iframes' ) || ! apply_filters( 'do_rocket_lazyload_iframes', true ) || is_feed() || is_preview() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || empty( $html ) || ( defined( 'DONOTLAZYLOAD' ) && DONOTLAZYLOAD ) ) { - return $html; - } - - preg_match_all( '/\s*<\/iframe>)/iU', $html, $matches, PREG_SET_ORDER ); - - if ( empty( $matches ) ) { - return $html; - } - - foreach ( $matches as $iframe ) { - // Don't mess with the Gravity Forms ajax iframe. - if ( strpos( $iframe[0], 'gform_ajax_frame' ) ) { - continue; - } - - // Don't lazyload if iframe has data-no-lazy attribute. - if ( strpos( $iframe[0], 'data-no-lazy=' ) ) { - continue; - } - - if ( rocket_lazyload_get_option( 'youtube' ) && false !== strpos( $iframe[1], 'youtube' ) ) { - $youtube_id = rocket_lazyload_get_youtube_id_from_url( $iframe[1] ); +add_action('plugins_loaded', 'rocket_lazyload_textdomain'); - if ( ! $youtube_id ) { - continue; - } +$rocket_lazyload_requirement_checks = new Rocket_Lazyload_Requirements_Check( + array( + 'plugin_name' => 'Lazy Load by WP Rocket', + 'plugin_version' => ROCKET_LL_VERSION, + 'wp_version' => ROCKET_LL_WP_VERSION, + 'php_version' => ROCKET_LL_PHP_VERSION, + ) +); - $query = wp_parse_url( $iframe[1], PHP_URL_QUERY ); - - /** - * Filter the LazyLoad HTML output on Youtube iframes - * - * @since 1.4.3 - * - * @param array $html Output that will be printed. - */ - $youtube_lazyload = apply_filters( 'rocket_lazyload_youtube_html', '
' ); - $youtube_lazyload .= ''; - - $html = str_replace( $iframe[0], $youtube_lazyload, $html ); - - continue; - } - - /** - * Filter the LazyLoad placeholder on src attribute - * - * @since 1.1 - * - * @param string $placeholder placeholder that will be printed. - */ - $placeholder = apply_filters( 'rocket_lazyload_placeholder', 'about:blank' ); - - $iframe_noscript = ''; - - $iframe_lazyload = str_replace( $iframe[1], $placeholder, $iframe[0] ); - - $iframe_lazyload = str_replace( $iframe[2], ' data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . esc_url( $iframe[1] ) . '"' . $iframe[2], $iframe[0] ); - /** - * Filter the LazyLoad HTML output on iframes - * - * @since 1.1 - * - * @param array $html Output that will be printed. - */ - $iframe_lazyload = apply_filters( 'rocket_lazyload_iframe_html', $iframe_lazyload ); - $iframe_lazyload .= $iframe_noscript; - - $html = str_replace( $iframe[0], $iframe_lazyload, $html ); - } - - return $html; +if ($rocket_lazyload_requirement_checks->check()) { + require ROCKET_LL_PATH . 'main.php'; } -add_filter( 'the_content', 'rocket_lazyload_iframes', PHP_INT_MAX ); -add_filter( 'widget_text', 'rocket_lazyload_iframes', PHP_INT_MAX ); -/** - * Gets youtube video ID from URL - * - * @author Remy Perona - * @since 1.4 - * - * @param string $url URL to parse. - * @return string Youtube video id or false if none found. - */ -function rocket_lazyload_get_youtube_id_from_url( $url ) { - $pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be|youtube\.com|youtube-nocookie\.com)/(?:embed/|v/|watch/?\?v=)([\w-]{11})#iU'; - $result = preg_match( $pattern, $url, $matches ); - - if ( ! $result ) { - return false; - } - - if ( 'videoseries' === $matches[1] ) { - return false; - } - - return $matches[1]; -} +unset($rocket_lazyload_requirement_checks); diff --git a/src/Admin/AdminPage.php b/src/Admin/AdminPage.php new file mode 100644 index 0000000..3e57629 --- /dev/null +++ b/src/Admin/AdminPage.php @@ -0,0 +1,170 @@ +options = $options; + $this->option_array = $option_array; + $this->template_path = $template_path; + } + + /** + * Registers plugin settings with WordPress + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function configure() + { + register_setting($this->getSlug(), $this->options->getOptionName('_options')); + } + + /** + * Gets the settings page title + * + * @since 2.0 + * @author Remy Perona + * + * @return string + */ + public function getPageTitle() + { + return __('LazyLoad by WP Rocket', 'rocket-lazy-load'); + } + + /** + * Gets the settings submenu title + * + * @since 2.0 + * @author Remy Perona + * + * @return string + */ + public function getMenuTitle() + { + return __('LazyLoad', 'rocket-lazy-load'); + } + + /** + * Gets the plugin slug + * + * @since 2.0 + * @author Remy Perona + * + * @return string + */ + public function getSlug() + { + return $this->slug; + } + + /** + * Gets the plugin required capability + * + * @since 2.0 + * @author Remy Perona + * + * @return string + */ + public function getCapability() + { + return 'manage_options'; + } + + /** + * Renders the admin page template + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function renderPage() + { + $this->renderTemplate('admin-page'); + } + + /** + * Renders the given template if it's readable. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $template Template name. + */ + protected function renderTemplate($template) + { + $template_path = $this->template_path . $template . '.php'; + + if (!is_readable($template_path)) { + return; + } + + include $template_path; + } +} diff --git a/src/Admin/ImagifyNotice.php b/src/Admin/ImagifyNotice.php new file mode 100644 index 0000000..8456d4f --- /dev/null +++ b/src/Admin/ImagifyNotice.php @@ -0,0 +1,66 @@ +template_path = $template_path; + } + + /** + * Renders the Imagify notice + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function displayNotice() + { + $this->renderTemplate('imagify-notice'); + } + + /** + * Renders the given template if it's readable. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $template Template name. + */ + protected function renderTemplate($template) + { + $template_path = $this->template_path . $template . '.php'; + + if (!is_readable($template_path)) { + return; + } + + include $template_path; + } +} diff --git a/src/EventManagement/EventManager.php b/src/EventManagement/EventManager.php new file mode 100644 index 0000000..0bce49f --- /dev/null +++ b/src/EventManagement/EventManager.php @@ -0,0 +1,139 @@ + + */ +class EventManager +{ + /** + * Adds a callback to a specific hook of the WordPress plugin API. + * + * @uses add_filter() + * + * @param string $hook_name Name of the hook. + * @param callable $callback Callback function. + * @param int $priority Priority. + * @param int $accepted_args Number of arguments. + */ + public function addCallback($hook_name, $callback, $priority = 10, $accepted_args = 1) + { + add_filter($hook_name, $callback, $priority, $accepted_args); + } + + /** + * Add an event subscriber. + * + * The event manager registers all the hooks that the given subscriber + * wants to register with the WordPress Plugin API. + * + * @param SubscriberInterface $subscriber SubscriberInterface implementation. + */ + public function addSubscriber(SubscriberInterface $subscriber) + { + if ($subscriber instanceof EventManagerAwareSubscriberInterface) { + $subscriber->setEventManager($this); + } + + foreach ($subscriber->getSubscribedEvents() as $hook_name => $parameters) { + $this->addSubscriberCallback($subscriber, $hook_name, $parameters); + } + } + + /** + * Checks the WordPress plugin API to see if the given hook has + * the given callback. The priority of the callback will be returned + * or false. If no callback is given will return true or false if + * there's any callbacks registered to the hook. + * + * @uses has_filter() + * + * @param string $hook_name Hook name. + * @param mixed $callback Callback. + * + * @return bool|int + */ + public function hasCallback($hook_name, $callback = false) + { + return has_filter($hook_name, $callback); + } + + /** + * Removes the given callback from the given hook. The WordPress plugin API only + * removes the hook if the callback and priority match a registered hook. + * + * @uses remove_filter() + * + * @param string $hook_name Hook name. + * @param callable $callback Callback. + * @param int $priority Priority. + * + * @return bool + */ + public function removeCallback($hook_name, $callback, $priority = 10) + { + return remove_filter($hook_name, $callback, $priority); + } + + /** + * Remove an event subscriber. + * + * The event manager removes all the hooks that the given subscriber + * wants to register with the WordPress Plugin API. + * + * @param SubscriberInterface $subscriber SubscriberInterface implementation. + */ + public function removeSubscriber(SubscriberInterface $subscriber) + { + foreach ($subscriber->getSubscribedEvents() as $hook_name => $parameters) { + $this->removeSubscriberCallback($subscriber, $hook_name, $parameters); + } + } + + /** + * Adds the given subscriber's callback to a specific hook + * of the WordPress plugin API. + * + * @param SubscriberInterface $subscriber SubscriberInterface implementation. + * @param string $hook_name Hook name. + * @param mixed $parameters Parameters, can be a string, an array or a multidimensional array. + */ + private function addSubscriberCallback(SubscriberInterface $subscriber, $hook_name, $parameters) + { + if (is_string($parameters)) { + $this->addCallback($hook_name, [ $subscriber, $parameters ]); + } elseif (is_array($parameters) && count($parameters) !== count($parameters, COUNT_RECURSIVE)) { + foreach ($parameters as $parameter) { + $this->addSubscriberCallback($subscriber, $hook_name, $parameter); + } + } elseif (is_array($parameters) && isset($parameters[0])) { + $this->addCallback($hook_name, [ $subscriber, $parameters[0] ], isset($parameters[1]) ? $parameters[1] : 10, isset($parameters[2]) ? $parameters[2] : 1); + } + } + + /** + * Removes the given subscriber's callback to a specific hook + * of the WordPress plugin API. + * + * @param SubscriberInterface $subscriber SubscriberInterface implementation. + * @param string $hook_name Hook name. + * @param mixed $parameters Parameters, can be a string, an array or a multidimensional array. + */ + private function removeSubscriberCallback(SubscriberInterface $subscriber, $hook_name, $parameters) + { + if (is_string($parameters)) { + $this->removeCallback($hook_name, [ $subscriber, $parameters ]); + } elseif (is_array($parameters) && count($parameters) !== count($parameters, COUNT_RECURSIVE)) { + foreach ($parameters as $parameter) { + $this->removeSubscriberCallback($subscriber, $hook_name, $parameter); + } + } elseif (is_array($parameters) && isset($parameters[0])) { + $this->removeCallback($hook_name, [ $subscriber, $parameters[0] ], isset($parameters[1]) ? $parameters[1] : 10); + } + } +} diff --git a/src/EventManagement/EventManagerAwareSubscriberInterface.php b/src/EventManagement/EventManagerAwareSubscriberInterface.php new file mode 100644 index 0000000..cbdd667 --- /dev/null +++ b/src/EventManagement/EventManagerAwareSubscriberInterface.php @@ -0,0 +1,15 @@ + + */ +interface SubscriberInterface +{ + /** + * Returns an array of events that this subscriber wants to listen to. + * + * The array key is the event name. The value can be: + * + * * The method name + * * An array with the method name and priority + * * An array with the method name, priority and number of accepted arguments + * + * For instance: + * + * * array('hook_name' => 'method_name') + * * array('hook_name' => array('method_name', $priority)) + * * array('hook_name' => array('method_name', $priority, $accepted_args)) + * * array('hook_name' => array(array('method_name_1', $priority_1, $accepted_args_1)), array('method_name_2', $priority_2, $accepted_args_2))) + * + * @return array + */ + public function getSubscribedEvents(); +} diff --git a/src/Options/AbstractOptions.php b/src/Options/AbstractOptions.php new file mode 100644 index 0000000..7ebe2a6 --- /dev/null +++ b/src/Options/AbstractOptions.php @@ -0,0 +1,63 @@ +get($name); + } +} diff --git a/src/Options/OptionArray.php b/src/Options/OptionArray.php new file mode 100644 index 0000000..6de8a29 --- /dev/null +++ b/src/Options/OptionArray.php @@ -0,0 +1,105 @@ +options = $options; + } + + /** + * Checks if the provided key exists in the option data array. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $key key name. + * @return boolean + */ + public function has($key) + { + return isset($this->options[ $key ]); + } + + /** + * Gets the value associated with a specific key. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $key key name. + * @param mixed $default default value to return if key doesn't exist. + * @return mixed + */ + public function get($key, $default = '') + { + if (! $this->has($key)) { + return $default; + } + + return $this->options[ $key ]; + } + + /** + * Sets the value associated with a specific key. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $key key name. + * @param mixed $value Value to set. + * @return void + */ + public function set($key, $value) + { + $this->options[ $key ] = $value; + } + + /** + * Sets multiple values. + * + * @since 2.0 + * @author Remy Perona + * + * @param array $options An array of key/value pairs to set. + * @return void + */ + public function setValues($options) + { + foreach ($options as $key => $value) { + $this->set($key, $value); + } + } + + /** + * Gets the option array. + * + * @since 2.0 + * @author Remy Perona + * + * @return array + */ + public function getOptions() + { + return $this->options; + } +} diff --git a/src/Options/Options.php b/src/Options/Options.php new file mode 100644 index 0000000..267eec8 --- /dev/null +++ b/src/Options/Options.php @@ -0,0 +1,97 @@ +prefix = $prefix; + } + + /** + * Gets the option name used to store the option in the WordPress database. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $name Unprefixed name of the option. + * + * @return string + */ + public function getOptionName($name) + { + return $this->prefix . $name; + } + + /** + * Gets the option for the given name. Returns the default value if the value does not exist. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $name Name of the option to get. + * @param mixed $default Default value to return if the value does not exist. + * + * @return mixed + */ + public function get($name, $default = null) + { + $option = get_option($this->getOptionName($name), $default); + + if (is_array($default) && ! is_array($option)) { + $option = (array) $option; + } + + return $option; + } + + /** + * Sets the value of an option. Update the value if the option for the given name already exists. + * + * @since 2.0 + * @author Remy Perona + * @param string $name Name of the option to set. + * @param mixed $value Value to set for the option. + * + * @return void + */ + public function set($name, $value) + { + update_option($this->getOptionName($name), $value); + } + + /** + * Deletes the option with the given name. + * + * @since 2.0 + * @author Remy Perona + * + * @param string $name Name of the option to delete. + * + * @return void + */ + public function delete($name) + { + delete_option($this->getOptionName($name)); + } +} diff --git a/src/Plugin.php b/src/Plugin.php new file mode 100644 index 0000000..8e05f93 --- /dev/null +++ b/src/Plugin.php @@ -0,0 +1,91 @@ +loaded; + } + + /** + * Loads the plugin in WordPress + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function load() + { + if ($this->isLoaded()) { + return; + } + + $container = new Container; + + $container->add('template_path', ROCKET_LL_PATH . 'views/'); + $container->add('plugin_basename', ROCKET_LL_BASENAME); + + $container->add('options', function () { + return new Options('rocket_lazyload'); + }); + + $container->add('event_manager', function () { + return new EventManager(); + }); + + $service_providers = [ + 'RocketLazyLoadPlugin\ServiceProvider\OptionServiceProvider', + 'RocketLazyLoadPlugin\ServiceProvider\AdminServiceProvider', + 'RocketLazyLoadPlugin\ServiceProvider\ImagifyNoticeServiceProvider', + 'RocketLazyLoadPlugin\ServiceProvider\LazyloadServiceProvider', + 'RocketLazyLoadPlugin\ServiceProvider\SubscribersServiceProvider' + ]; + + foreach ($service_providers as $service) { + $container->addServiceProvider($service); + } + + $subscribers = [ + 'RocketLazyLoadPlugin\Subscriber\ThirdParty\AMPSubscriber', + 'RocketLazyLoadPlugin\Subscriber\AdminPageSubscriber', + 'RocketLazyLoadPlugin\Subscriber\ImagifyNoticeSubscriber', + 'RocketLazyLoadPlugin\Subscriber\LazyloadSubscriber', + ]; + + foreach ($subscribers as $subscriber) { + $container->get('event_manager')->addSubscriber($container->get($subscriber)); + } + + $this->loaded = true; + } +} diff --git a/src/ServiceProvider/AdminServiceProvider.php b/src/ServiceProvider/AdminServiceProvider.php new file mode 100644 index 0000000..0a1dd12 --- /dev/null +++ b/src/ServiceProvider/AdminServiceProvider.php @@ -0,0 +1,41 @@ +getContainer()->add('RocketLazyLoadPlugin\Admin\AdminPage') + ->withArgument($this->getContainer()->get('options')) + ->withArgument($this->getContainer()->get('RocketLazyLoadPlugin\Options\OptionArray')) + ->withArgument($this->getContainer()->get('template_path')); + } +} diff --git a/src/ServiceProvider/ImagifyNoticeServiceProvider.php b/src/ServiceProvider/ImagifyNoticeServiceProvider.php new file mode 100644 index 0000000..b442964 --- /dev/null +++ b/src/ServiceProvider/ImagifyNoticeServiceProvider.php @@ -0,0 +1,39 @@ +getContainer()->add('RocketLazyLoadPlugin\Admin\ImagifyNotice') + ->withArgument($this->getContainer()->get('template_path')); + } +} diff --git a/src/ServiceProvider/LazyloadServiceProvider.php b/src/ServiceProvider/LazyloadServiceProvider.php new file mode 100644 index 0000000..a4da262 --- /dev/null +++ b/src/ServiceProvider/LazyloadServiceProvider.php @@ -0,0 +1,42 @@ +getContainer()->add('RocketLazyload\Assets'); + $this->getContainer()->add('RocketLazyload\Image'); + $this->getContainer()->add('RocketLazyload\Iframe'); + } +} diff --git a/src/ServiceProvider/OptionServiceProvider.php b/src/ServiceProvider/OptionServiceProvider.php new file mode 100644 index 0000000..58c7253 --- /dev/null +++ b/src/ServiceProvider/OptionServiceProvider.php @@ -0,0 +1,39 @@ +getContainer()->add('RocketLazyLoadPlugin\Options\OptionArray') + ->withArgument($this->getContainer()->get('options')->get('_options')); + } +} diff --git a/src/ServiceProvider/SubscribersServiceProvider.php b/src/ServiceProvider/SubscribersServiceProvider.php new file mode 100644 index 0000000..f5f9acc --- /dev/null +++ b/src/ServiceProvider/SubscribersServiceProvider.php @@ -0,0 +1,54 @@ +getContainer()->add('RocketLazyLoadPlugin\Subscriber\ThirdParty\AMPSubscriber'); + + $this->getContainer()->add('RocketLazyLoadPlugin\Subscriber\AdminPageSubscriber') + ->withArgument($this->getContainer()->get('RocketLazyLoadPlugin\Admin\AdminPage')) + ->withArgument($this->getContainer()->get('plugin_basename')); + + $this->getContainer()->add('RocketLazyLoadPlugin\Subscriber\ImagifyNoticeSubscriber') + ->withArgument($this->getContainer()->get('RocketLazyLoadPlugin\Admin\ImagifyNotice')); + + $this->getContainer()->add('RocketLazyLoadPlugin\Subscriber\LazyloadSubscriber') + ->withArgument($this->getContainer()->get('RocketLazyLoadPlugin\Options\OptionArray')) + ->withArgument($this->getContainer()->get('RocketLazyload\Assets')) + ->withArgument($this->getContainer()->get('RocketLazyload\Image')) + ->withArgument($this->getContainer()->get('RocketLazyload\Iframe')); + } +} diff --git a/src/Subscriber/AdminPageSubscriber.php b/src/Subscriber/AdminPageSubscriber.php new file mode 100644 index 0000000..42a56b0 --- /dev/null +++ b/src/Subscriber/AdminPageSubscriber.php @@ -0,0 +1,136 @@ +page = $page; + $this->plugin_basename = $plugin_basename; + } + + /** + * @inheritDoc + */ + public function getSubscribedEvents() + { + return [ + 'admin_init' => 'configure', + 'admin_menu' => 'addAdminPage', + 'plugin_action_links_' . $this->plugin_basename => 'addPluginPageLink', + 'admin_enqueue_scripts' => 'enqueueAdminStyle', + ]; + } + + /** + * Registers the plugin settings in WordPress + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function configure() + { + $this->page->configure(); + } + + /** + * Adds the admin page to the settings menu + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function addAdminPage() + { + add_options_page( + $this->page->getPageTitle(), + $this->page->getMenuTitle(), + $this->page->getCapability(), + $this->page->getSlug(), + [ $this->page, 'renderPage' ] + ); + } + + /** + * Adds a link to the plugin settings on the plugins page + * + * @since 2.0 + * @author Remy Perona + * + * @param array $actions Actions for the plugin. + * @return array + */ + public function addPluginPageLink($actions) + { + array_unshift( + $actions, + sprintf( + '%s', + admin_url('options-general.php?page=' . $this->page->getSlug()), + __('Settings', 'rocket-lazy-load') + ) + ); + + return $actions; + } + + /** + * Enqueue the css for the option page + * + * @since 2.0 + * @author Remy Perona + * + * @param string $hook_suffix Current page hook. + */ + public function enqueueAdminStyle($hook_suffix) + { + if ('settings_page_rocket_lazyload' !== $hook_suffix) { + return; + } + + wp_enqueue_style('rocket-lazyload', ROCKET_LL_ASSETS_URL . 'css/admin.css', null, ROCKET_LL_VERSION); + } +} diff --git a/src/Subscriber/ImagifyNoticeSubscriber.php b/src/Subscriber/ImagifyNoticeSubscriber.php new file mode 100644 index 0000000..40c1028 --- /dev/null +++ b/src/Subscriber/ImagifyNoticeSubscriber.php @@ -0,0 +1,144 @@ +imagify_notice = $imagify_notice; + } + + /** + * @inheritDoc + */ + public function getSubscribedEvents() + { + return [ + 'admin_notices' => 'imagifyNotice', + 'admin_footer-settings_page_rocket_lazyload' => 'dismissNoticeJS', + 'wp_ajax_rocket_lazyload_ignore' => 'dismissBoxes', + 'admin_post_rocket_lazyload_ignore' => 'dismissBoxes', + ]; + } + + /** + * Displays the Imagify notice + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function imagifyNotice() + { + $current_screen = get_current_screen(); + + if ('admin_notices' === current_filter() && (isset($current_screen) && 'settings_page_rocket_lazyload' !== $current_screen->base)) { + return; + } + + $boxes = get_user_meta(get_current_user_id(), 'rocket_lazyload_boxes', true); + + if (defined('IMAGIFY_VERSION') || in_array('rocket_lazyload_imagify_notice', (array) $boxes, true) || 1 === get_option('rocket_lazyload_dismiss_imagify_notice') || ! current_user_can('manage_options')) { + return; + } + + $this->imagify_notice->displayNotice(); + } + + /** + * Inserts the javascript to dismiss the notice + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function dismissNoticeJS() + { + echo ""; + } + + /** + * Saves the dismiss for the user + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function dismissBoxes() + { + if (! isset($_GET['box'], $_GET['action'], $_GET['_wpnonce'])) { + return; + } + + if (! wp_verify_nonce($_GET['_wpnonce'], $_GET['action'] . '_' . $_GET['box'])) { + if (defined('DOING_AJAX')) { + wp_send_json(array('error' => 1)); + } else { + wp_nonce_ays(''); + } + } + + if ('rocket_lazyload_imagify_notice' === $_GET['box']) { + update_option('rocket_lazyload_dismiss_imagify_notice', 0); + } + + $actual = get_user_meta(get_current_user_id(), 'rocket_lazyload_boxes', true); + $actual = array_merge((array) $actual, array( $_GET['box'] )); + $actual = array_filter($actual); + $actual = array_unique($actual); + + update_user_meta(get_current_user_id(), 'rocket_lazyload_boxes', $actual); + delete_transient($_GET['box']); + + if (empty($GLOBALS['pagenow']) || 'admin-post.php' !== $GLOBALS['pagenow']) { + return; + } + + if (defined('DOING_AJAX')) { + wp_send_json(array('error' => 0)); + } else { + wp_safe_redirect(esc_url_raw(wp_get_referer())); + die(); + } + } +} diff --git a/src/Subscriber/LazyloadSubscriber.php b/src/Subscriber/LazyloadSubscriber.php new file mode 100644 index 0000000..513af78 --- /dev/null +++ b/src/Subscriber/LazyloadSubscriber.php @@ -0,0 +1,333 @@ +option_array = $option_array; + $this->assets = $assets; + $this->image = $image; + $this->iframe = $iframe; + } + + /** + * @inheritDoc + */ + public function getSubscribedEvents() + { + return [ + 'wp_footer' => [ + [ 'insertLazyloadScript', ROCKET_LL_INT_MAX ], + ['insertYoutubeThumbnailScript', ROCKET_LL_INT_MAX ], + ], + 'wp_enqueue_scripts' => ['insertYoutubeThumbnailStyle', ROCKET_LL_INT_MAX], + 'template_redirect' => ['lazyload', ROCKET_LL_INT_MAX], + 'rocket_lazyload_html' => 'lazyloadResponsive', + 'init' => 'lazyloadSmilies', + ]; + } + + /** + * Inserts the lazyload script in the footer + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function insertLazyloadScript() + { + if (! $this->option_array->get('images') && ! $this->option_array->get('iframes')) { + return; + } + + if (! $this->shouldlazyload()) { // WPCS: prefix ok. + return; + } + + /** + * Filters the threshold at which lazyload is triggered + * + * @since 1.2 + * @author Remy Perona + * + * @param int $threshold Threshold value. + */ + $threshold = apply_filters('rocket_lazyload_threshold', 300); + + $args = [ + 'base_url' => ROCKET_LL_FRONT_JS_URL, + 'suffix' => defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min', + 'threshold' => $threshold, + 'version' => '10.19', + 'fallback' => '8.17', + ]; + + if ($this->option_array->get('images')) { + $args['elements']['image'] = 'img[data-lazy-src]'; + $args['elements']['background_image'] = '.rocket-lazyload-bg'; + } + + if ($this->option_array->get('iframes')) { + $args['elements']['iframe'] = 'iframe[data-lazy-src]'; + } + + /** + * Filters the arguments array for the lazyload script options + * + * @since 2.0 + * @author Remy Perona + * + * @param array $args Arguments used for the lazyload script options. + */ + $args = apply_filters('rocket_lazyload_script_args', $args); + + $this->assets->insertLazyloadScript($args); + } + + /** + * Inserts the Youtube thumbnail script in the footer + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function insertYoutubeThumbnailScript() + { + if (! $this->option_array->get('youtube')) { + return; + } + + if (! $this->shouldlazyload()) { // WPCS: prefix ok. + return; + } + + /** + * Filters the resolution of the YouTube thumbnail + * + * @since 1.4.8 + * @author Arun Basil Lal + * + * @param string $thumbnail_resolution The resolution of the thumbnail. Accepted values: default, mqdefault, sddefault, hqdefault, maxresdefault + */ + $thumbnail_resolution = apply_filters('rocket_lazyload_youtube_thumbnail_resolution', 'hqdefault'); + + $this->assets->insertYoutubeThumbnailScript( + [ + 'resolution' => $thumbnail_resolution, + ] + ); + } + + /** + * Inserts the Youtube thumbnail CSS in the header + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function insertYoutubeThumbnailStyle() + { + if (! $this->option_array->get('youtube')) { + return; + } + + if (! $this->shouldlazyload()) { + return; + } + + $this->assets->insertYoutubeThumbnailCSS( + [ + 'base_url' => ROCKET_LL_ASSETS_URL, + ] + ); + } + + /** + * Checks if lazyload should be applied + * + * @since 2.0 + * @author Remy Perona + * + * @return bool + */ + private function shouldLazyload() + { + if (is_admin() || is_feed() || is_preview() || (defined('REST_REQUEST') && REST_REQUEST) || (defined('DONOTLAZYLOAD') && DONOTLAZYLOAD)) { + return false; + } + + /** + * Filters the lazyload application + * + * @since 2.0 + * @author Remy Perona + * + * @param bool $do_rocket_lazyload True to apply lazyload, false otherwise. + */ + if (! apply_filters('do_rocket_lazyload', true)) { // WPCS: prefix ok. + return false; + } + + return true; + } + + /** + * Gets the content to lazyload + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function lazyload() + { + if (! $this->shouldLazyload()) { + return; + } + + ob_start([$this, 'lazyloadBuffer']); + } + + /** + * Applies lazyload on the provided content + * + * @since 2.0 + * @author Remy Perona + * + * @param string $html HTML content + * @return string + */ + public function lazyloadBuffer($html) + { + if ($this->option_array->get('images')) { + $html = $this->image->lazyloadImages($html); + } + + if ($this->option_array->get('iframes')) { + $args = [ + 'youtube' => $this->option_array->get('youtube'), + ]; + + $html = $this->iframe->lazyloadIframes($html, $args); + } + + return $html; + } + + /** + * Applies lazyload on responsive images attributes srcset and sizes + * + * @since 2.0 + * @author Remy Perona + * + * @param string $html Image HTML. + * @return string + */ + public function lazyloadResponsive($html) + { + return $this->image->lazyloadResponsiveAttributes($html); + } + + /** + * Applies lazyload on WordPress smilies + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function lazyloadSmilies() + { + if (! $this->shouldLazyload()) { + return; + } + + if (! $this->option_array->get('images')) { + return; + } + + $filters = [ + 'the_content' => 10, + 'the_excerpt' => 10, + 'comment_text' => 20, + ]; + + foreach ($filters as $filter => $prio) { + if (! has_filter($filter)) { + continue; + } + + remove_filter($filter, 'convert_smilies', $prio); + add_filter($filter, [$this->image, 'convertSmilies'], $prio); + } + } +} diff --git a/src/Subscriber/ThirdParty/AMPSubscriber.php b/src/Subscriber/ThirdParty/AMPSubscriber.php new file mode 100644 index 0000000..72ab298 --- /dev/null +++ b/src/Subscriber/ThirdParty/AMPSubscriber.php @@ -0,0 +1,60 @@ +isAmpEndpoint()) { + $events['do_rocket_lazyload'] = 'returnFalse'; + $events['do_rocket_lazyload_iframes'] = 'returnFalse'; + } + + return $events; + } + + /** + * Checks if current page uses AMP + * + * @since 2.0 + * @author Remy Perona + * + * @return boolean + */ + private function isAmpEndpoint() + { + if (function_exists('is_amp_endpoint') && \is_amp_endpoint()) { + return true; + } + + return false; + } + + /** + * Returns false + * + * @since 2.0 + * @author Remy Perona + * + * @return void + */ + public function returnFalse() + { + \__return_false(); + } +} diff --git a/src/rocket-lazyload-requirements-check.php b/src/rocket-lazyload-requirements-check.php new file mode 100644 index 0000000..08d01e6 --- /dev/null +++ b/src/rocket-lazyload-requirements-check.php @@ -0,0 +1,137 @@ +$setting = $args[ $setting ]; + } + } + } + + /** + * Checks if all requirements are ok, if not, display a notice and the rollback + * + * @since 3.0 + * @author Remy Perona + * + * @return bool + */ + public function check() + { + if (! $this->phpPasses() || ! $this->wpPasses()) { + add_action('admin_notices', array($this, 'notice')); + + return false; + } + + return true; + } + + /** + * Checks if the current PHP version is equal or superior to the required PHP version + * + * @since 3.0 + * @author Remy Perona + * + * @return bool + */ + private function phpPasses() + { + return version_compare(PHP_VERSION, $this->php_version) >= 0; + } + + /** + * Checks if the current WordPress version is equal or superior to the required PHP version + * + * @since 3.0 + * @author Remy Perona + * + * @return bool + */ + private function wpPasses() + { + global $wp_version; + + return version_compare($wp_version, $this->wp_version) >= 0; + } + + /** + * Displays a notice if requirements are not met. + * + * @since 2.0 + * @author Remy Perona + */ + public function notice() + { + if (! current_user_can('manage_options')) { + return; + } + + // Translators: %1$s = Plugin name, %2$s = Plugin version. + $message = '

' . sprintf(__('To function properly, %1$s %2$s requires at least:', 'rocket-lazy-load'), $this->plugin_name, $this->plugin_version) . '

    '; + + if (! $this->phpPasses()) { + // Translators: %1$s = PHP version required. + $message .= '
  • ' . sprintf(__('PHP %1$s. To use this %2$s version, please ask your web host how to upgrade your server to PHP %1$s or higher.', 'rocket-lazy-load'), $this->php_version, $this->plugin_name) . '
  • '; + } + + if (! $this->wpPasses()) { + // Translators: %1$s = WordPress version required. + $message .= '
  • ' . sprintf(__('WordPress %1$s. To use this %2$s version, please upgrade WordPress to version %1$s or higher.', 'rocket-lazy-load'), $this->wp_version, $this->plugin_name) . '
  • '; + } + + echo '
    ' . $message . '
    '; + } +} diff --git a/views/admin-page.php b/views/admin-page.php new file mode 100644 index 0000000..467d6e8 --- /dev/null +++ b/views/admin-page.php @@ -0,0 +1,118 @@ + [ + 'label' => __('Images', 'rocket-lazy-load'), + ], + 'iframes' => [ + 'label' => __('Iframes & Videos', 'rocket-lazy-load'), + ], + 'youtube' => [ + 'label' => __('Replace Youtube videos by thumbnail', 'rocket-lazy-load'), + ], +]; // WPCS: prefix ok. + +?> +
    + + = 0 ? 'h1' : 'h2'; // WPCS: prefix ok. ?> + < class="screen-reader-text">> +
    +
    +

    <?php echo esc_attr(get_admin_page_title()); ?>

    +

    +
    + +

    + tag, %2$s is
    , %3$s is the complete link tag to Rocket Lazy Load review form, %4$s is the closing tag. + printf(__('%1$sDo you like this plugin?%2$s Please take a few seconds to %3$srate it on WordPress.org%4$s!', 'rocket-lazy-load'), '', '
    ', '', ''); + ?> +
    + ', 5); ?> +

    +
    +
    +
    +
    + +

    +

    +
      + $infos) : // WPCS: prefix ok. ?> +
    • + option_array->get($slug, 0), 1); ?> aria-labelledby="describe-lazyload-"> + +
    • + + + +
    +
    + + + +
    + +
    +

    +

    + + +

    + +
    + +
    +
    + +
    +
      +
    • ', '') + ?>
    • +
    • ', '') + ?>
    • +
    • ', '') + ?>
    • +
    • ', '') + ?>
    • +
    • ', '') + ?>
    • +
    • ', '') + ?>
    • +
    • ', '') + ?>
    • +
    +
    + +
    + + +

    + +

    +
    +
    +
    \ No newline at end of file diff --git a/views/imagify-notice.php b/views/imagify-notice.php new file mode 100644 index 0000000..993131b --- /dev/null +++ b/views/imagify-notice.php @@ -0,0 +1,33 @@ + 'install-plugin', + 'plugin' => 'imagify', + ], + admin_url('update.php') + ), + 'install-plugin_imagify' +); // WPCS: prefix ok. + +$dismiss_url = wp_nonce_url( + admin_url('admin-post.php?action=rocket_lazyload_ignore&box=rocket_lazyload_imagify_notice'), + 'rocket_lazyload_ignore_rocket_lazyload_imagify_notice' +); // WPCS: prefix ok. + +?> +
    + + + +

    + +

    +

    + +

    +
    \ No newline at end of file