/** * jGrowl 1.4.5 * * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * Written by Stan Lemon * Last updated: 2015.02.01 */ (function($) { /** jGrowl Wrapper - Establish a base jGrowl Container for compatibility with older releases. **/ $.jGrowl = function( m , o ) { // To maintain compatibility with older version that only supported one instance we'll create the base container. if ( $('#jGrowl').length === 0 ) $('
').addClass( (o && o.position) ? o.position : $.jGrowl.defaults.position ).appendTo( (o && o.appendTo) ? o.appendTo : $.jGrowl.defaults.appendTo ); // Create a notification on the container. $('#jGrowl').jGrowl(m,o); }; /** Raise jGrowl Notification on a jGrowl Container **/ $.fn.jGrowl = function( m , o ) { // Short hand for passing in just an object to this method if ( o === undefined && $.isPlainObject(m) ) { o = m; m = o.message; } if ( $.isFunction(this.each) ) { var args = arguments; return this.each(function() { /** Create a jGrowl Instance on the Container if it does not exist **/ if ( $(this).data('jGrowl.instance') === undefined ) { $(this).data('jGrowl.instance', $.extend( new $.fn.jGrowl(), { notifications: [], element: null, interval: null } )); $(this).data('jGrowl.instance').startup( this ); } /** Optionally call jGrowl instance methods, or just raise a normal notification **/ if ( $.isFunction($(this).data('jGrowl.instance')[m]) ) { $(this).data('jGrowl.instance')[m].apply( $(this).data('jGrowl.instance') , $.makeArray(args).slice(1) ); } else { $(this).data('jGrowl.instance').create( m , o ); } }); } }; $.extend( $.fn.jGrowl.prototype , { /** Default JGrowl Settings **/ defaults: { pool: 0, header: '', group: '', sticky: false, position: 'top-right', appendTo: 'body', glue: 'after', theme: 'default', themeState: 'highlight', corners: '10px', check: 250, life: 3000, closeDuration: 'normal', openDuration: 'normal', easing: 'swing', closer: true, closeTemplate: '×', closerTemplate: '
[ close all ]
', log: function() {}, beforeOpen: function() {}, afterOpen: function() {}, open: function() {}, beforeClose: function() {}, close: function() {}, click: function() {}, animateOpen: { opacity: 'show' }, animateClose: { opacity: 'hide' } }, notifications: [], /** jGrowl Container Node **/ element: null, /** Interval Function **/ interval: null, /** Create a Notification **/ create: function( message , options ) { var o = $.extend({}, this.defaults, options); /* To keep backward compatibility with 1.24 and earlier, honor 'speed' if the user has set it */ if (typeof o.speed !== 'undefined') { o.openDuration = o.speed; o.closeDuration = o.speed; } this.notifications.push({ message: message , options: o }); o.log.apply( this.element , [this.element,message,o] ); }, render: function( n ) { var self = this; var message = n.message; var o = n.options; // Support for jQuery theme-states, if this is not used it displays a widget header o.themeState = (o.themeState === '') ? '' : 'ui-state-' + o.themeState; var notification = $('
') .addClass('jGrowl-notification alert ' + o.themeState + ' ui-corner-all' + ((o.group !== undefined && o.group !== '') ? ' ' + o.group : '')) .append($('