HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/baretube.com.new/templates/default_tube2019/js/jquery.modal.min.js
/*
 A simple jQuery modal (http://github.com/kylefox/jquery-modal)
 Version 0.9.2
 */

(function (factory) {
    // Making your jQuery plugin work better with npm tools
    // http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm
    if (typeof module === "object" && typeof module.exports === "object") {
        factory(require("jquery"), window, document);
    } else {
        factory(jQuery, window, document);
    }
}(function ($, window, document, undefined) {

    var modals = [],
            getCurrent = function () {
                return modals.length ? modals[modals.length - 1] : null;
            },
            selectCurrent = function () {
                var i,
                        selected = false;
                for (i = modals.length - 1; i >= 0; i--) {
                    if (modals[i].$blocker) {
                        modals[i].$blocker.toggleClass('current', !selected).toggleClass('behind', selected);
                        selected = true;
                    }
                }
            };

    $.jModal = function (el, options) {
        var remove, target;
        this.$body = $('body');
        this.options = $.extend({}, $.jModal.defaults, options);
        this.options.doFade = !isNaN(parseInt(this.options.fadeDuration, 10));
        this.$blocker = null;
        if (this.options.closeExisting)
            while ($.jModal.isActive())
                $.jModal.close(); // Close any open modals.
        modals.push(this);
        if (el.is('a')) {
            target = el.attr('href');
            this.anchor = el;
            //Select element by id from href
            if (/^#/.test(target)) {
                this.$elm = $(target);
                if (this.$elm.length !== 1)
                    return null;
                this.$body.append(this.$elm);
                this.open();
                //AJAX
            } else {
                this.$elm = $('<div>');
                this.$body.append(this.$elm);
                remove = function (event, modal) {
                    modal.elm.remove();
                };
                this.showSpinner();
                el.trigger($.jModal.AJAX_SEND);
                $.get(target).done(function (html) {
                    if (!$.jModal.isActive())
                        return;
                    el.trigger($.jModal.AJAX_SUCCESS);
                    var current = getCurrent();
                    current.$elm.empty().append(html).on($.jModal.CLOSE, remove);
                    current.hideSpinner();
                    current.open();
                    el.trigger($.jModal.AJAX_COMPLETE);
                }).fail(function () {
                    el.trigger($.jModal.AJAX_FAIL);
                    var current = getCurrent();
                    current.hideSpinner();
                    modals.pop(); // remove expected modal from the list
                    el.trigger($.jModal.AJAX_COMPLETE);
                });
            }
        } else {
            this.$elm = el;
            this.anchor = el;
            this.$body.append(this.$elm);
            this.open();
        }
    };

    $.jModal.prototype = {
        constructor: $.jModal,

        open: function () {
            var m = this;
            this.block();
            this.anchor.blur();
            if (this.options.doFade) {
                setTimeout(function () {
                    m.show();
                }, this.options.fadeDuration * this.options.fadeDelay);
            } else {
                this.show();
            }
            $(document).off('keydown.modal').on('keydown.modal', function (event) {
                var current = getCurrent();
                if (event.which === 27 && current.options.escapeClose)
                    current.close();
            });
            if (this.options.clickClose)
                this.$blocker.click(function (e) {
                    if (e.target === this)
                        $.jModal.close();
                });
        },

        close: function () {
            modals.pop();
            this.unblock();
            this.hide();
            if (!$.jModal.isActive())
                $(document).off('keydown.modal');
        },

        block: function () {
            this.$elm.trigger($.jModal.BEFORE_BLOCK, [this._ctx()]);
            this.$body.css('overflow', 'hidden');
            this.$blocker = $('<div class="' + this.options.blockerClass + ' jBlocker current"></div>').appendTo(this.$body);
            selectCurrent();
            if (this.options.doFade) {
                this.$blocker.css('opacity', 0).animate({opacity: 1}, this.options.fadeDuration);
            }
            this.$elm.trigger($.jModal.BLOCK, [this._ctx()]);
        },

        unblock: function (now) {
            if (!now && this.options.doFade)
                this.$blocker.fadeOut(this.options.fadeDuration, this.unblock.bind(this, true));
            else {
                this.$blocker.children().appendTo(this.$body);
                this.$blocker.remove();
                this.$blocker = null;
                selectCurrent();
                if (!$.jModal.isActive())
                    this.$body.css('overflow', '');
            }
        },

        show: function () {
            this.$elm.trigger($.jModal.BEFORE_OPEN, [this._ctx()]);
            if (this.options.showClose) {
                this.closeButton = $('<a href="#close-modal" rel="jModal:close" class="close-modal ' + this.options.closeClass + '">' + this.options.closeText + '</a>');
                this.$elm.append(this.closeButton);
            }
            this.$elm.addClass(this.options.modalClass).appendTo(this.$blocker);
            if (this.options.doFade) {
                this.$elm.css({opacity: 0, display: 'inline-block'}).animate({opacity: 1}, this.options.fadeDuration);
            } else {
                this.$elm.css('display', 'inline-block');
            }
            this.$elm.trigger($.jModal.OPEN, [this._ctx()]);
        },

        hide: function () {
            this.$elm.trigger($.jModal.BEFORE_CLOSE, [this._ctx()]);
            if (this.closeButton)
                this.closeButton.remove();
            var _this = this;
            if (this.options.doFade) {
                this.$elm.fadeOut(this.options.fadeDuration, function () {
                    _this.$elm.trigger($.jModal.AFTER_CLOSE, [_this._ctx()]);
                });
            } else {
                this.$elm.hide(0, function () {
                    _this.$elm.trigger($.jModal.AFTER_CLOSE, [_this._ctx()]);
                });
            }
            this.$elm.trigger($.jModal.CLOSE, [this._ctx()]);
        },

        showSpinner: function () {
            if (!this.options.showSpinner)
                return;
            this.spinner = this.spinner || $('<div class="' + this.options.modalClass + '-spinner"></div>')
                    .append(this.options.spinnerHtml);
            this.$body.append(this.spinner);
            this.spinner.show();
        },

        hideSpinner: function () {
            if (this.spinner)
                this.spinner.remove();
        },

        //Return context for custom events
        _ctx: function () {
            return {elm: this.$elm, $elm: this.$elm, $blocker: this.$blocker, options: this.options, $anchor: this.anchor};
        }
    };

    $.jModal.close = function (event) {
        if (!$.jModal.isActive())
            return;
        if (event)
            event.preventDefault();
        var current = getCurrent();
        current.close();
        return current.$elm;
    };

    // Returns if there currently is an active modal
    $.jModal.isActive = function () {
        return modals.length > 0;
    };

    $.jModal.getCurrent = getCurrent;

    $.jModal.defaults = {
        closeExisting: true,
        escapeClose: true,
        clickClose: true,
        closeText: 'Close',
        closeClass: '',
        modalClass: "jModal",
        blockerClass: "jquery-modal",
        spinnerHtml: '<div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div>',
        showSpinner: true,
        showClose: true,
        fadeDuration: null, // Number of milliseconds the fade animation takes.
        fadeDelay: 1.0        // Point during the overlay's fade-in that the modal begins to fade in (.5 = 50%, 1.5 = 150%, etc.)
    };

    // Event constants
    $.jModal.BEFORE_BLOCK = 'modal:before-block';
    $.jModal.BLOCK = 'modal:block';
    $.jModal.BEFORE_OPEN = 'modal:before-open';
    $.jModal.OPEN = 'modal:open';
    $.jModal.BEFORE_CLOSE = 'modal:before-close';
    $.jModal.CLOSE = 'modal:close';
    $.jModal.AFTER_CLOSE = 'modal:after-close';
    $.jModal.AJAX_SEND = 'modal:ajax:send';
    $.jModal.AJAX_SUCCESS = 'modal:ajax:success';
    $.jModal.AJAX_FAIL = 'modal:ajax:fail';
    $.jModal.AJAX_COMPLETE = 'modal:ajax:complete';

    $.fn.j_modal = function (options) {
        if (this.length === 1) {
            new $.jModal(this, options);
        }
        return this;
    };

    // Automatically bind links with rel="modal:close" to, well, close the modal.
    $(document).on('click.modal', 'a[rel~="jModal:close"]', $.jModal.close);
    $(document).on('click.modal', 'a[rel~="jModal:open"]', function (event) {
        event.preventDefault();
        $(this).j_modal();
    });
}));