<commit_before>/*global $:true,jQuery:true*/
/*jslint debug: true, devel: true, evil: true, vars: true, undef: true */
if (typeof DEBUG === 'undefined') { DEBUG = true; } // removed on uglify
(function ($) {
    
    // global variables setup
    var globals = {};
    
    var getSettings = function () {
        return globals;
    };
    
    var setSettings = function (options) {
        // public / defaults
        globals = $.extend({
            'content'           : '',
            'immediateDisplay'  : false,
            'modalTopPadding'   : 75,
            'modalHomeBg'       : 'jhm-modal-bg',
            'modalHomeDiv'      : 'jhm-modal',
            'modalHomeClose'    : 'jhm-modal-close',
            'modalHomeLoader'  : 'jhm-modal-loading',
            'modalHomeContent'  : 'jhm-modal-content',
            'modalHomeOpenEvent'    : 'jhm.modal.open',
            'modalHomeCloseEvent'   : 'jhm.modal.close'
        }, options);
        
        return globals;
    };

	var methods = {
		init : function (options) {
			var settings = setSettings(options);
            
            if (DEBUG) { console.log(this, settings); }
            
            if (this.length > 0 && this.html() !== '') {
                settings.content = this.html();
                setSettings(settings);
            }

            var modalBG = $('.' + settings.modalHomeBg),
                modal = $('.' + settings.modalHomeDiv);
            
            if (modalBG.length === 0) {
                modalBG = createBg();
            }
            if (modal.length === 0) {
                modal = createModal();
            }
            
            // load static html
            if (settings.content.length > 0) {
                settings.immediateDisplay = true;
                populateModal(settings.content);
            }
            
            $('.' + settings.modalHomeClose).on('click', function () {
                if (DEBUG) { console.log('close click'); }
                modal.trigger(settings.modalHomeCloseEvent);
            });
            
            if (DEBUG) {console.log('setup events'); }
            // close event
            modal.on(settings.modalHomeCloseEvent, function () {
                if (DEBUG) { console.log(settings.modalHomeCloseEvent + ' event'); }
                hideModal(modal);
                modal.off(settings.modalHomeCloseEvent);
            });
            // open event
            modal.on(settings.modalHomeOpenEvent, function () {
				if (DEBUG) { console.log(settings.modalHomeOpenEvent + ' event'); }
                revealModal(modal);
                modal.off(settings.modalHomeOpenEvent);
            });
            // esc press event
            $('body').on('keyup', function (e) {
                if (e.which === 27) {
                    modal.trigger(settings.modalHomeCloseEvent);
                }
			});
            // bg click close
            $('.' + settings.modalHomeBg).on('click', function () {
                modal.trigger(settings.modalHomeCloseEvent);
            });
            
            // show immediately
            if (settings.immediateDisplay === true) {
                modal.trigger(settings.modalHomeOpenEvent);
            }
            
            return { 'modal': modal, 'modalBg': modalBG };
		},
        ajax: function (options) {
            if (DEBUG) { console.log('ajax init'); }
            var container = $.fn.modalHome(options),
                settings = getSettings();
            
            showLoader();
            container.modal.trigger(settings.modalHomeOpenEvent);
            
            $.ajax({
                url: options.url
            }).done(function (data) {
                
                if (DEBUG) { console.log('ajax success'); }
                populateModal(data);
                if ($.isFunction(options.success)) {
                    options.success(data);
                }
                hideLoader();
            }).error(function (data) {
                if (DEBUG) { console.log('ajax failure', data, data.statusCode()); }
                populateModal('Failed to load resource');
                if ($.isFunction(options.failure)) {
                    options.failure(data);
                }<commit_msg>Updated failure message to use plugin settings for content instead of hard coded message.<commit_after>/*global $:true,jQuery:true*/
/*jslint debug: true, devel: true, evil: true, vars: true, undef: true */
if (typeof DEBUG === 'undefined') { DEBUG = true; } // removed on uglify
(function ($) {
    
    // global variables setup
    var globals = {};
    
    var getSettings = function () {
        return globals;
    };
    
    var setSettings = function (options) {
        // public / defaults
        globals = $.extend({
            'content'           : '',
            'immediateDisplay'  : false,
            'modalTopPadding'   : 75,
            'modalHomeBg'       : 'jhm-modal-bg',
            'modalHomeDiv'      : 'jhm-modal',
            'modalHomeClose'    : 'jhm-modal-close',
            'modalHomeLoader'  : 'jhm-modal-loading',
            'modalHomeContent'  : 'jhm-modal-content',
            'modalHomeOpenEvent'    : 'jhm.modal.open',
            'modalHomeCloseEvent'   : 'jhm.modal.close',
            'ajaxFailureContent'    : 'Failed to load resource'
        }, options);
        
        return globals;
    };

	var methods = {
		init : function (options) {
			var settings = setSettings(options);
            
            if (DEBUG) { console.log(this, settings); }
            
            if (this.length > 0 && this.html() !== '') {
                settings.content = this.html();
                setSettings(settings);
            }

            var modalBG = $('.' + settings.modalHomeBg),
                modal = $('.' + settings.modalHomeDiv);
            
            if (modalBG.length === 0) {
                modalBG = createBg();
            }
            if (modal.length === 0) {
                modal = createModal();
            }
            
            // load static html
            if (settings.content.length > 0) {
                settings.immediateDisplay = true;
                populateModal(settings.content);
            }
            
            $('.' + settings.modalHomeClose).on('click', function () {
                if (DEBUG) { console.log('close click'); }
                modal.trigger(settings.modalHomeCloseEvent);
            });
            
            if (DEBUG) {console.log('setup events'); }
            // close event
            modal.on(settings.modalHomeCloseEvent, function () {
                if (DEBUG) { console.log(settings.modalHomeCloseEvent + ' event'); }
                hideModal(modal);
                modal.off(settings.modalHomeCloseEvent);
            });
            // open event
            modal.on(settings.modalHomeOpenEvent, function () {
				if (DEBUG) { console.log(settings.modalHomeOpenEvent + ' event'); }
                revealModal(modal);
                modal.off(settings.modalHomeOpenEvent);
            });
            // esc press event
            $('body').on('keyup', function (e) {
                if (e.which === 27) {
                    modal.trigger(settings.modalHomeCloseEvent);
                }
			});
            // bg click close
            $('.' + settings.modalHomeBg).on('click', function () {
                modal.trigger(settings.modalHomeCloseEvent);
            });
            
            // show immediately
            if (settings.immediateDisplay === true) {
                modal.trigger(settings.modalHomeOpenEvent);
            }
            
            return { 'modal': modal, 'modalBg': modalBG };
		},
        ajax: function (options) {
            if (DEBUG) { console.log('ajax init'); }
            var container = $.fn.modalHome(options),
                settings = getSettings();
            
            showLoader();
            container.modal.trigger(settings.modalHomeOpenEvent);
            
            $.ajax({
                url: options.url
            }).done(function (data) {
                
                if (DEBUG) { console.log('ajax success'); }
                populateModal(data);
                if ($.isFunction(options.success)) {
                    options.success(data);
                }
                hideLoader();
            }).error(function (data) {
                if (DEBUG) { console.log('ajax failure', data, data.statusCode()); }
                populateModal(settings.ajaxFailureContent);
                if ($.isFunction(options.failure)) {
                    options.failure(data);
                }
{'fraction_non_alphanumeric': 0.12835580135960364, 'fraction_numerical': 0.0018435303606406269, 'mean_word_length': 1.3859263331500824, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5274574', 'n_tokens_mistral': 2271, 'n_tokens_neox': 2150, 'n_words': 429}