<commit_before>/*
 *  Popup.js
 *
*/


(function ( $ ) {

    $.fn.lzyPopup = function( options ) {
        var id = createPopupContainer( options );
        populatePopupContainer(id, options);
        setSpecialOptions(id, options);
        setupTrigger(id, options);
        initEsc();
    };

}( jQuery ));


function createPopupContainer(options) {
    var id = (options.id) ? options.id : 'lzy-popup' + options.index;

    if ($('#' + id).length == 0) {
        $('#lzy-popup-template').after('<div id="' + id + '" class="lzy-popup-widget" style="display:none;"></div>');
        id = '#' + id;

        $(id).html($('#lzy-popup-template').html());   // initialize or reset popup

        var $popup = $(id + ' .lzy-popup-wrapper');

        if (options.class) {
            $popup.addClass(options.class);
        }
        if (options.width) {
            $popup.css('width', options.width);
        }
        if (options.height) {
            $popup.css('min-height', options.height);
        }

    } else {
        id = '#' + id;
        var $popup = $(id + ' .lzy-popup-wrapper');
    }

    $('.lzy-popup-close-button', $popup).click(function() {
        $( this ).closest('.lzy-popup-widget').hide();
    });

    if (options.lightbox && (options.triggerEvent != 'hover')) {   // lightbox not compatible with hover
        $(id).addClass('lzy-lightbox');
    }
    return id;
}


function populatePopupContainer(id, options)
{
    var $popup = $(id + ' .lzy-popup-wrapper');
    var text = '';
    if (options.text) {     // text provided in options
        text = options.text;
    }
    if (options.contentFrom) {   // text to be retrieved
        text = text +  $( options.contentFrom ).html();
        $( options.contentFrom ).remove();
    }

    $('.lzy-popup-body', $popup).html(text);
    $('.lzy-popup-header', $popup).text( options.header );
}



function setSpecialOptions(id, options)
{
    var $popup = $(id + ' .lzy-popup-wrapper');
    if (options.draggable) {
        $('.lzy-popup-header', $popup).panzoom({ $set: $popup }); // -> only draggable by header, not content
        // note: this is it avoid conflicts with forms in popup-body
    }

    $('.lzy-popup-close-button', $popup).click(function() {
        $( this ).closest('.lzy-popup-widget').hide();
    });
}




function openPopup(id, options) {
    positionPopup(id, options);
    if ((typeof options.delay != 'undefined') && (options.delay != '0')) {
        setTimeout(function() { $(id).show(); }, parseInt(options.delay));<commit_msg>popup: permit HTML in header definition<commit_after>/*
 *  Popup.js
 *
*/


(function ( $ ) {

    $.fn.lzyPopup = function( options ) {
        var id = createPopupContainer( options );
        populatePopupContainer(id, options);
        setSpecialOptions(id, options);
        setupTrigger(id, options);
        initEsc();
    };

}( jQuery ));


function createPopupContainer(options) {
    var id = (options.id) ? options.id : 'lzy-popup' + options.index;

    if ($('#' + id).length == 0) {
        $('#lzy-popup-template').after('<div id="' + id + '" class="lzy-popup-widget" style="display:none;"></div>');
        id = '#' + id;

        $(id).html($('#lzy-popup-template').html());   // initialize or reset popup

        var $popup = $(id + ' .lzy-popup-wrapper');

        if (options.class) {
            $popup.addClass(options.class);
        }
        if (options.width) {
            $popup.css('width', options.width);
        }
        if (options.height) {
            $popup.css('min-height', options.height);
        }

    } else {
        id = '#' + id;
        var $popup = $(id + ' .lzy-popup-wrapper');
    }

    $('.lzy-popup-close-button', $popup).click(function() {
        $( this ).closest('.lzy-popup-widget').hide();
    });

    if (options.lightbox && (options.triggerEvent != 'hover')) {   // lightbox not compatible with hover
        $(id).addClass('lzy-lightbox');
    }
    return id;
}


function populatePopupContainer(id, options)
{
    var $popup = $(id + ' .lzy-popup-wrapper');
    var text = '';
    if (options.text) {     // text provided in options
        text = options.text;
    }
    if (options.contentFrom) {   // text to be retrieved
        text = text +  $( options.contentFrom ).html();
        $( options.contentFrom ).remove();
    }

    $('.lzy-popup-body', $popup).html(text);
    $('.lzy-popup-header', $popup).html( options.header );
}



function setSpecialOptions(id, options)
{
    var $popup = $(id + ' .lzy-popup-wrapper');
    if (options.draggable) {
        $('.lzy-popup-header', $popup).panzoom({ $set: $popup }); // -> only draggable by header, not content
        // note: this is it avoid conflicts with forms in popup-body
    }

    $('.lzy-popup-close-button', $popup).click(function() {
        $( this ).closest('.lzy-popup-widget').hide();
    });
}




function openPopup(id, options) {
    positionPopup(id, options);
    if ((typeof options.delay != 'undefined') && (options.delay != '0')) {
        setTimeout(function() { $(id).show(); }, parseInt(options.delay));
{'fraction_non_alphanumeric': 0.1919449901768173, 'fraction_numerical': 0.0007858546168958742, 'mean_word_length': 2.3894806924101197, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1139103', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1590, 'n_words': 324}