assets/lib/alertifyjs/src/js/notifier.js
/**
        * creates a new notification message
        *
        * @param  {DOMElement} message	The notifier message element
        * @param  {Number} wait   Time (in ms) to wait before the message is dismissed, a value of 0 means keep open till clicked.
        * @param  {Function} callback A callback function to be invoked when the message is dismissed.
        *
        * @return {undefined}
        */
creates a new notification message

@param  {DOMElement} message  The notifier message element
@param  {Number} wait   Time (in ms) to wait before the message is dismissed, a value of 0 means keep open till clicked.
@param  {Function} callback A callback function to be invoked when the message is dismissed.

@return {undefined}
creates a new notification message @param { DOMElement } message The notifier message element @param { Number } wait Time ( in ms ) to wait before the message is dismissed a value of 0 means keep open till clicked . @param { Function } callback A callback function to be invoked when the message is dismissed . @return { undefined }
function create(div, callback) {
            function clickDelegate(event, instance) {
                instance.dismiss(true);
            }
            function transitionDone(event, instance) {
                off(instance.element, transition.type, transitionDone);
                element.removeChild(instance.element);
            }
            function initialize(instance) {
                if (!instance.__internal) {
                    instance.__internal = {
                        pushed: false,
                        delay : undefined,
                        timer: undefined,
                        clickHandler: undefined,
                        transitionEndHandler: undefined,
                        transitionTimeout: undefined
                    };
                    instance.__internal.clickHandler = delegate(instance, clickDelegate);
                    instance.__internal.transitionEndHandler = delegate(instance, transitionDone);
                }
                return instance;
            }
            function clearTimers(instance) {
                clearTimeout(instance.__internal.timer);
                clearTimeout(instance.__internal.transitionTimeout);
            }
            return initialize({
                element: div,
                push: function (_content, _wait) {
                    if (!this.__internal.pushed) {
                        pushInstance(this);
                        clearTimers(this);
                        var content, wait;
                        switch (arguments.length) {
                        case 0:
                            wait = this.__internal.delay;
                            break;
                        case 1:
                            if (typeof (_content) === 'number') {
                                wait = _content;
                            } else {
                                content = _content;
                                wait = this.__internal.delay;
                            }
                            break;
                        case 2:
                            content = _content;
                            wait = _wait;
                            break;
                        }
                        if (typeof content !== 'undefined') {
                            this.setContent(content);
                        }
                        if (notifier.__internal.position.indexOf('top') < 0) {
                            element.appendChild(this.element);
                        } else {
                            element.insertBefore(this.element, element.firstChild);
                        }
                        reflow = this.element.offsetWidth;
                        addClass(this.element, classes.visible);
                        on(this.element, 'click', this.__internal.clickHandler);
                        return this.delay(wait);
                    }
                    return this;
                },
                ondismiss: function () { },
                callback: callback,
                dismiss: function (clicked) {
                    if (this.__internal.pushed) {
                        clearTimers(this);
                        if (!(typeof this.ondismiss === 'function' && this.ondismiss.call(this) === false)) {
                            off(this.element, 'click', this.__internal.clickHandler);
                            if (typeof this.element !== 'undefined' && this.element.parentNode === element) {
                                this.__internal.transitionTimeout = setTimeout(this.__internal.transitionEndHandler, transition.supported ? 1000 : 100);
                                removeClass(this.element, classes.visible);
                                if (typeof this.callback === 'function') {
                                    this.callback.call(this, clicked);
                                }
                            }
                            popInstance(this);
                        }
                    }
                    return this;
                },
                delay: function (wait) {
                    clearTimers(this);
                    this.__internal.delay = typeof wait !== 'undefined' && !isNaN(+wait) ? +wait : notifier.__internal.delay;
                    if (this.__internal.delay > 0) {
                        var  self = this;
                        this.__internal.timer = setTimeout(function () { self.dismiss(); }, this.__internal.delay * 1000);
                    }
                    return this;
                },
                setContent: function (content) {
                    if (typeof content === 'string') {
                        clearContents(this.element);
                        this.element.innerHTML = content;
                    } else if (content instanceof window.HTMLElement && this.element.firstChild !== content) {
                        clearContents(this.element);
                        this.element.appendChild(content);
                    }
                    return this;
                },
                dismissOthers: function () {
                    notifier.dismissAll(this);
                    return this;
                }
            });
        }
function create ( div , callback ) { function clickDelegate ( event , instance ) { instance . dismiss ( true ) ; } function transitionDone ( event , instance ) { off ( instance . element , transition . type , transitionDone ) ; element . removeChild ( instance . element ) ; } function initialize ( instance ) { if ( ! instance . __internal ) { instance . __internal = { pushed : false , delay : undefined , timer : undefined , clickHandler : undefined , transitionEndHandler : undefined , transitionTimeout : undefined } ; instance . __internal . clickHandler = delegate ( instance , clickDelegate ) ; instance . __internal . transitionEndHandler = delegate ( instance , transitionDone ) ; } return instance ; } function clearTimers ( instance ) { clearTimeout ( instance . __internal . timer ) ; clearTimeout ( instance . __internal . transitionTimeout ) ; } return initialize ( { element : div , push : function ( _content , _wait ) { if ( ! this . __internal . pushed ) { pushInstance ( this ) ; clearTimers ( this ) ; var content , wait ; switch ( arguments . length ) { case 0 : wait = this . __internal . delay ; break ; case 1 : if ( typeof ( _content ) === 'number' ) { wait = _content ; } else { content = _content ; wait = this . __internal . delay ; } break ; case 2 : content = _content ; wait = _wait ; break ; } if ( typeof content !== 'undefined' ) { this . setContent ( content ) ; } if ( notifier . __internal . position . indexOf ( 'top' ) < 0 ) { element . appendChild ( this . element ) ; } else { element . insertBefore ( this . element , element . firstChild ) ; } reflow = this . element . offsetWidth ; addClass ( this . element , classes . visible ) ; on ( this . element , 'click' , this . __internal . clickHandler ) ; return this . delay ( wait ) ; } return this ; } , ondismiss : function ( ) { } , callback : callback , dismiss : function ( clicked ) { if ( this . __internal . pushed ) { clearTimers ( this ) ; if ( ! ( typeof this . ondismiss === 'function' && this . ondismiss . call ( this ) === false ) ) { off ( this . element , 'click' , this . __internal . clickHandler ) ; if ( typeof this . element !== 'undefined' && this . element . parentNode === element ) { this . __internal . transitionTimeout = setTimeout ( this . __internal . transitionEndHandler , transition . supported ? 1000 : 100 ) ; removeClass ( this . element , classes . visible ) ; if ( typeof this . callback === 'function' ) { this . callback . call ( this , clicked ) ; } } popInstance ( this ) ; } } return this ; } , delay : function ( wait ) { clearTimers ( this ) ; this . __internal . delay = typeof wait !== 'undefined' && ! isNaN ( + wait ) ? + wait : notifier . __internal . delay ; if ( this . __internal . delay > 0 ) { var self = this ; this . __internal . timer = setTimeout ( function ( ) { self . dismiss ( ) ; } , this . __internal . delay * 1000 ) ; } return this ; } , setContent : function ( content ) { if ( typeof content === 'string' ) { clearContents ( this . element ) ; this . element . innerHTML = content ; } else if ( content instanceof window . HTMLElement && this . element . firstChild !== content ) { clearContents ( this . element ) ; this . element . appendChild ( content ) ; } return this ; } , dismissOthers : function ( ) { notifier . dismissAll ( this ) ; return this ; } } ) ; }
creates a new notification message
creates a new notification message
// unbind event
 // remove the message
 /* notification DOM element*/ /*
                 * Pushes a notification message 
                 * @param {string or DOMElement} content The notification message content
                 * @param {Number} wait The time (in seconds) to wait before the message is dismissed, a value of 0 means keep open till clicked.
                 * 
                 */ // set contents
 // append or insert
 // attach click event
 /*
                 * {Function} callback function to be invoked before dismissing the notification message.
                 * Remarks: A return value === 'false' will cancel the dismissal
                 * 
                 */ /*
                 * {Function} callback function to be invoked when the message is dismissed.
                 * 
                 */ /*
                 * Dismisses the notification message 
                 * @param {Boolean} clicked A flag indicating if the dismissal was caused by a click.
                 * 
                 */ //detach click event
 // ensure element exists
 //transition end or fallback
 // custom callback on dismiss
 /*
                 * Delays the notification message dismissal
                 * @param {Number} wait The time (in seconds) to wait before the message is dismissed, a value of 0 means keep open till clicked.
                 * 
                 */ /*
                 * Sets the notification message contents
                 * @param {string or DOMElement} content The notification message content
                 * 
                 */ /*
                 * Dismisses all open notifications except this.
                 * 
                 */