Plugin Directory

Changeset 2771982


Ignore:
Timestamp:
08/18/2022 08:34:04 AM (4 years ago)
Author:
john1302
Message:

JS ios < 14

Location:
wp-lozad/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-lozad/trunk/js/initLozad.js

    r2760300 r2771982  
    11class InitLozad {
    22    // verify the existence of the file
    3     useIfFileExists = false; // todo handle
    4 
    5     init = () => {
    6         this.__handle();
     3    constructor() {
     4        this.useIfFileExists = false; // todo handle
    75    }
    86
    9     __handle = () => {
     7    init() {
     8        this.handle();
     9    }
     10
     11    handle() {
    1012        if (typeof lozad !== 'function') {
    11             this.__image2x();
     13            this.image2x();
    1214            return;
    1315        }
    1416
    15         this.__initLazyload();
     17        this.initLazyload();
    1618    }
    1719
    18     __initLazyload = () => {
     20    initLazyload() {
    1921        lozad('.lazyload', {
    2022            loaded: (el) => {
     
    2325        }).observe();
    2426
    25         this.__image2x();
     27        this.image2x();
    2628
    27         window.load = () => {
     29        window.load = function() {
    2830            window.scrollTo(window.scrollX, window.scrollY);
    2931        };
    3032    }
    3133
    32     __urlExists = (url) => {
     34    urlExists(url) {
    3335        const http = new XMLHttpRequest();
    3436        http.open('HEAD', url, false);
     
    3739    }
    3840
    39     __replaceImgTo2Img = (currentString) => {
     41    replaceImgTo2Img(currentString) {
    4042        if (!currentString) {
    4143            return '';
     
    4749    }
    4850
    49     __handleBgImageTo2xBg = () => {
     51    handleBgImageTo2xBg() {
    5052        let o = this;
    5153
    5254        const replaceBgImageTo2xBg = (element) => {
    53             element.setAttribute('data-background-image', o.__replaceImgTo2Img(element.getAttribute('data-background-image')));
     55            element.setAttribute('data-background-image', o.replaceImgTo2Img(element.getAttribute('data-background-image')));
    5456        };
    5557
     
    5860
    5961            if (o.useIfFileExists) {
    60                 if (o.__urlExists(o.__replaceImgTo2Img(dataBackgroundImage.substring(5, (dataBackgroundImage.length - 2))))) {
     62                if (o.urlExists(o.replaceImgTo2Img(dataBackgroundImage.substring(5, (dataBackgroundImage.length - 2))))) {
    6163                    replaceBgImageTo2xBg(element);
    6264                }
     
    6870    }
    6971
    70     __image2x = () => {
     72    image2x() {
    7173        const replaceSiblingsSourceElements = (currentElement) => {
    7274            currentElement.parentNode.childNodes.forEach((item) => {
     
    7779                    return;
    7880                }
    79                 item.setAttribute('srcset', this.__replaceImgTo2Img(item.getAttribute('srcset')))
     81                item.setAttribute('srcset', this.replaceImgTo2Img(item.getAttribute('srcset')))
    8082            });
    8183        };
     
    8486
    8587        if (pixelRatio > 1) {
    86             this.__handleBgImageTo2xBg();
     88            this.handleBgImageTo2xBg();
    8789
    8890            const els = document.querySelectorAll('img.image2x');
     
    9395                replaceSiblingsSourceElements(currentElement);
    9496
    95                 const src = this.__replaceImgTo2Img(currentElement.getAttribute('src'));
    96                 if (this.useIfFileExists && !this.__urlExists(src)) {
     97                const src = this.replaceImgTo2Img(currentElement.getAttribute('src'));
     98                if (this.useIfFileExists && !this.urlExists(src)) {
    9799                    return;
    98100                }
    99101
    100102                currentElement.setAttribute('src', src);
    101                 currentElement.setAttribute('srcset', this.__replaceImgTo2Img(currentElement.getAttribute('srcset')));
    102                 currentElement.setAttribute('data-srcset', this.__replaceImgTo2Img(currentElement.getAttribute('data-srcset')));
    103                 currentElement.setAttribute('data-src', this.__replaceImgTo2Img(currentElement.getAttribute('data-src')));
     103                currentElement.setAttribute('srcset', this.replaceImgTo2Img(currentElement.getAttribute('srcset')));
     104                currentElement.setAttribute('data-srcset', this.replaceImgTo2Img(currentElement.getAttribute('data-srcset')));
     105                currentElement.setAttribute('data-src', this.replaceImgTo2Img(currentElement.getAttribute('data-src')));
    104106            }
    105107        }
  • wp-lozad/trunk/lozad.php

    r2760300 r2771982  
    44Description: lazy loading of images by baroda algorithm
    55Author: Evgeniy Kozenok
    6 Version: 1.6.1
     6Version: 1.6.2
    77*/
    88
  • wp-lozad/trunk/readme.txt

    r2760300 r2771982  
    44Requires at least: 5.0
    55Tested up to: 6.0
    6 Stable tag: 1.6.1
     6Stable tag: 1.6.2
    77License: GPL2
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2424
    2525== Changelog ==
     26= 1.6.2 =
     27* 2022-08-18: JS ios < 14
     28
    2629= 1.6.1 =
    2730* 2022-07-22: fix js private identifier in cache
Note: See TracChangeset for help on using the changeset viewer.