Plugin Directory

Changeset 3006502


Ignore:
Timestamp:
12/06/2023 11:39:41 PM (16 months ago)
Author:
firmcatalyst
Message:

defer fixed, wp 6.4 tested

Location:
fcp-lightest-lightbox/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • fcp-lightest-lightbox/trunk/assets/script.js

    r2764202 r3006502  
    171171    };
    172172
     173    // ******* print figcaption
     174
     175    const figcaption = d.createElement( 'div' );
     176    figcaption.className = 'fcplb-caption';
     177    holder.prepend( figcaption );
     178   
     179    function get_figcaption(a) {
     180        while ( a.parentNode ) {
     181            a = a.parentNode;
     182            if ( a === d ) { return false }
     183            if ( a.tagName.toLowerCase() !== 'figure' ) { continue }
     184            const caption = a.querySelector( 'figcaption' ),
     185                html = caption !== null && caption.innerHTML;
     186            return html;
     187        }
     188        return false;
     189    }
     190
     191    const open_figcapture = open;
     192    open = a => {
     193        const caption = get_figcaption( a );
     194        figcaption.innerHTML = caption || '';
     195        return open_figcapture( a );
     196    };
    173197
    174198    // ******* swipe & finger support
     
    244268                holder.classList.add( 'fcplb-swipe-return' ); // return to the center
    245269
     270                // ++prevent changing direction on diagonal move (only prev-next or only close, as started)
    246271                // ++add 2 fingers && 2 buttons to zoom
    247272                // ++doubleclick to restore the zoom lvl
     273                // ++add more styles
    248274            });
    249275
     
    269295        }
    270296    };
    271 
     297    //d.querySelector( p.selector ).dispatchEvent( new Event( 'click' ) ); // for easier testing
    272298})();
  • fcp-lightest-lightbox/trunk/assets/style.css

    r2764191 r3006502  
    1515#fcplb.fcplb-active {
    1616    opacity:1;
    17     z-index:99996;
     17    z-index:99995;
    1818    transition:opacity .2s ease-out, z-index 0s linear;
    1919}
     
    2121    max-width:94%;
    2222    max-height:95%;
    23     z-index:99997;
     23    z-index:99996;
    2424}
    2525
     
    153153    content:none;
    154154}
     155
     156/* caption figcaption */
     157.fcplb-caption {
     158    display:block;
     159    position:fixed;
     160    left:0;
     161    right:0;
     162    bottom:0;
     163    z-index:99996;
     164    padding:20px;
     165    box-sizing:border-box;
     166    text-align:center;
     167    color:#fff;
     168    background-color:#000000bb;
     169}
     170.fcplb-caption:empty {
     171    display:none;
     172}
  • fcp-lightest-lightbox/trunk/fcp-lightbox.php

    r2982111 r3006502  
    44Plugin Name: FCP Lightest Lightbox
    55Description: Super lightweight lighbox. It tracks the links to images and makes it open in a popup lightbox. It also adds prev-next navigation to galleries or image sequences.
    6 Version: 1.4.1
     6Version: 1.4.2
    77Requires at least: 5.7
    8 Tested up to: 6.3
     8Tested up to: 6.4
    99Requires PHP: 7.0.0
    1010Author: Firmcatalyst, Vadim Volkov
     
    1616defined( 'ABSPATH' ) || exit;
    1717
    18 define( 'FCPLB_DEV', true );
     18define( 'FCPLB_DEV', false );
    1919define( 'FCPLB_VER', get_file_data( __FILE__, [ 'ver' => 'Version' ] )[ 'ver' ] . ( FCPLB_DEV ? time() : '' ) );
    2020
     
    3535
    3636    // defer the script loading
    37     add_filter('script_loader_tag', function ($tag, $handle) {
    38         if ( $handle !== $loader_name || strpos( $tag, 'defer ' ) !== false) { return $tag; }
    39         return str_replace( ' src', ' defer src', $tag );
     37    add_filter('script_loader_tag', function ($tag, $handle) use ($loader_name) {
     38        if ( $handle !== $loader_name ) { return $tag; }
     39        return str_replace( [' defer', ' src'], [' ', ' defer src'], $tag );
    4040    }, 10, 2);
    4141   
  • fcp-lightest-lightbox/trunk/loader.js

    r2751155 r3006502  
    11'use strict';
    2 (function(){let a=setInterval(function(){if(document.readyState!=='complete'&&document.readyState!=='interactive'){return}clearInterval(a);a=null; // soft wait for dom ready
    32
    4     // check if the preferences exist & can load the lightbox
    5     const p = window.fcp_lightbox;
    6     if ( !p || !p.selector || !document.querySelector( p.selector ) ) { return }
     3// wait for DOM
     4(function(){let i=setInterval(function(){let r=document.readyState;if(r!=='complete'&&r!=='interactive'){return}clearInterval(i);i=null;r=null;
     5
     6    const { selector, loader, dev, ver } = window.fcp_lightbox;
     7
     8    // no images found
     9    if ( !document.querySelector( selector ) ) { return }
    710   
    8     // append the script
    9     const d = document,
    10           body = d.querySelector( 'body' );
     11    // get the url of the main script
     12    const self = document.getElementById( loader ),
     13          self_url = new URL( self.src ),
     14          load_url = new URL( 'assets/script'+(dev ? '' : '.min')+'.js'+'?'+ver, self_url ).href;
    1115
    12     const script = d.createElement( 'script' );
     16    // load the main script
     17    const script = document.createElement( 'script' );
    1318    Object.assign( script, {
    14             'id':'fcp-lightbox-js', 'type':'text/javascript', 'async':true,
    15             'src':p.path + 'assets/script' + (p.dev ? '' : '.min') + '.js?' + p.ver
     19            id: loader.replace( '-loader', '' ),
     20            type: 'text/javascript',
     21            defer: true,
     22            src: load_url
    1623    });
    17     body.append( script );
     24    self.parentElement.insertBefore( script, self );
    1825
    19 },300)})();
     26},100)})();
  • fcp-lightest-lightbox/trunk/readme.txt

    r2982111 r3006502  
    33Tags: lightbox, gallery, photography, images
    44Requires at least: 5.7
    5 Tested up to: 6.3
     5Tested up to: 6.4
    66Requires PHP: 7.0.0
    7 Stable tag: 1.4.1
     7Stable tag: 1.4.2
    88Author: Firmcatalyst, Vadim Volkov
    99Author URI: https://firmcatalyst.com
Note: See TracChangeset for help on using the changeset viewer.