{"size": 2379, "ext": "js", "max_stars_repo_path": "source/assets/js/crucial-modules/lazysizes.js", "max_stars_repo_name": "d-derks/rb-dDwebpage", "max_stars_repo_stars_event_min_datetime": "2017-01-13T21:37:37.000Z", "max_stars_repo_stars_event_max_datetime": "2017-01-13T21:37:37.000Z", "max_issues_repo_path": "source/assets/js/crucial-modules/lazysizes.js", "max_issues_repo_name": "d-derks/rb-dDwebpage", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/assets/js/crucial-modules/lazysizes.js", "max_forks_repo_name": "d-derks/rb-dDwebpage", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.6626506024, "max_line_length": 110, "alphanum_fraction": 0.6158049601}
import 'lazysizes';
import 'lazysizes/plugins/respimg/ls.respimg';
import 'lazysizes/plugins/optimumx/ls.optimumx';

// require('lazysizes/plugins/parent-fit/ls.parent-fit');

let rbLiveClass, rbClickClass;

const rb = window.rb;
const lazyloadClass = 'lazyload';
const importedModules = {};
const lazySizesConfig = window.lazySizesConfig || {};

lazySizesConfig.hFac = 1;
lazySizesConfig.constrainPixelDensity = true;
lazySizesConfig.loadMode = 1;

if(!window.lazySizesConfig){
    window.lazySizesConfig = lazySizesConfig;
}

function configureMediaQueries(){
    const cssConfig = rb.cssConfig;
    const nameSeparator = cssConfig.nameSeparator || rb.nameSeparator || '-';

    document.removeEventListener('lazyunveilread', configureMediaQueries);
    Object.assign(lazySizesConfig.customMedia, cssConfig.mqs);

    rbLiveClass = ['js', 'rb', 'live'].join(nameSeparator);
    rbClickClass = ['js', 'rb', 'click'].join(nameSeparator);
}

function importModule(module){
    if(!importedModules[module] && (!rb.components || !rb.components[module])){
        const importModule = ()=> {
            if(rb.live){
                rb.live.import(module);
                rb.$(`[data-module="${module}"].${rbClickClass}.${lazyloadClass}`).removeClass(lazyloadClass);
            } else {
                setTimeout(importModule, 99);
            }
        };

        const start = ()=>{
            window.lazySizes.rAF(importModule);
        };

        if(rb.ready && rb.ready){
            rb.ready.then(start);
        } else {
            setTimeout(start, 99);
        }
    }

    importedModules[module] = true;
}

document.addEventListener('lazyunveilread', configureMediaQueries);

document.addEventListener('lazyunveilread', (e)=> {
    const container = e.target;
    const module = container.getAttribute('data-module');

    if(module) {
        if(container.classList.contains(rbClickClass)){
            importModule(module);
        } else {
            if(rb.getComponent && rb.ready.isDone && rb.components[module]){
                rb.getComponent(container, module);
            } else {
                window.lazySizes.rAF(()=> {
                    container.classList.add(rbLiveClass);
                    importModule(module);
                });
            }
        }
    }
});

if(document.querySelector(`.${lazyloadClass}`)){
    lazySizes.init();
}
