vendor: 4,706 bytes, lines 1-142
1/** 2 * jGrowl 1.2.5 3 4 */ 5(function(jQuery) { 6 7 /** jGrowl Wrapper - Establish a base jGrowl Container for compatibility with older releases. **/ 8 jQuery.jGrowl = function( m , o ) { 9 // To maintain compatibility with older version that only supported one instance we'll create the base container. 10 if ( jQuery('#jGrowl').size() == 0 ) 11 jQuery('<div id="jGrowl"></div>').addClass( (o && o.position) ? o.position : jQuery.jGrowl.defaults.position ).appendTo('body'); 12 13 // Create a notification on the container. 14 jQuery('#jGrowl').jGrowl(m,o); 15 }; 16 17 18 19 /** Raise jGrowl Notification on a jGrowl Container **/ 20 jQuery.fn.jGrowl = function( m , o ) { 21 if ( jQuery.isFunction(this.each) ) { 22 var args = arguments; 23 24 return this.each(function() { 25 var self = this; 26 27 /** Create a jGrowl Instance on the Container if it does not exist **/ 28 if ( jQuery(this).data('jGrowl.instance') == undefined ) { 29 jQuery(this).data('jGrowl.instance', jQuery.extend( new jQuery.fn.jGrowl(), { notifications: [], element: null, interval: null } )); 30 jQuery(this).data('jGrowl.instance').startup( this ); 31 } 32 33 /** Optionally call jGrowl instance methods, or just raise a normal notification **/ 34 if ( jQuery.isFunction(jQuery(this).data('jGrowl.instance')[m]) ) { 35 jQuery(this).data('jGrowl.instance')[m].apply( jQuery(this).data('jGrowl.instance') , jQuery.makeArray(args).slice(1) ); 36 } else { 37 jQuery(this).data('jGrowl.instance').create( m , o ); 38 } 39 }); 40 }; 41 }; 42 43 jQuery.extend( jQuery.fn.jGrowl.prototype , { 44 45 /** Default JGrowl Settings **/ 46 defaults: { 47 pool: 0, 48 header: '', 49 group: '', 50 sticky: false, 51 position: 'top-right', 52 glue: 'after', 53 theme: 'default', 54 themeState: 'highlight', 55 corners: '10px', 56 check: 250, 57 life: 3000, 58 closeDuration: 'normal', 59 openDuration: 'normal', 60 easing: 'swing', 61 closer: true, 62 closeTemplate: '×', 63 closerTemplate: '', 64 log: function(e,m,o) {}, 65 beforeOpen: function(e,m,o) {}, 66 afterOpen: function(e,m,o) {}, 67 open: function(e,m,o) {}, 68 beforeClose: function(e,m,o) {}, 69 close: function(e,m,o) {}, 70 dont_close: false, 71 animateOpen: { 72 opacity: 'show' 73 }, 74 animateClose: { 75 opacity: 'hide' 76 } 77 }, 78 79 notifications: [], 80 81 /** jGrowl Container Node **/ 82 element: null, 83 84 /** Interval Function **/ 85 interval: null, 86 87 /** Create a Notification **/ 88 create: function( message , o ) { 89 var o = jQuery.extend({}, this.defaults, o); 90 91 /* To keep backward compatibility with 1.24 and earlier, honor 'speed' if the user has set it */ 92 if (typeof o.speed !== 'undefined') { 93 o.openDuration = o.speed; 94 o.closeDuration = o.speed; 95 } 96 97 this.notifications.push({ message: message , options: o }); 98 99 o.log.apply( this.element , [this.element,message,o] ); 100 }, 101 102 render: function( notification ) { 103 var document_width = ( $(document).width() ); 104 var self = this; 105 var message = notification.message; 106 var o = notification.options; 107 108 var notification = jQuery( 109 '<div class="jGrowl-notification ' + o.themeState + ' ui-corner-all' + 110 ((o.group != undefined && o.group != '') ? ' ' + o.group : '') + '">' + 111 '<div class="jGrowl-close">' + o.closeTemplate + '</div>' + 112 '<div class="jGrowl-header">' + o.header + '</div>' + 113 '<div class="jGrowl-message"></div></div>' 114 ).data("jGrowl", o).addClass(o.theme).children('div.jGrowl-close').bind("click.jGrowl", function() { 115 jQuery(this).parent().trigger('jGrowl.close'); 116 }).parent(); 117 118 if(o.dont_close) { 119 notification.addClass("dont_close"); 120 } 121 122 notification.find('div.jGrowl-message').append(message); 123 notification.find('div.jGrowl-close').click(o.close); 124 125 /** Notification Actions **/ 126 jQuery(notification).bind("mouseover.jGrowl", function() { 127 jQuery('div.jGrowl-notification', self.element).data("jGrowl.pause", true); 128 }).bind("mouseout.jGrowl", function() { 129 jQuery('div.jGrowl-notification', self.element).data("jGrowl.pause", false); 130 }).bind('jGrowl.beforeOpen', function() { 131 if ( o.beforeOpen.apply( notification , [notification,message,o,self.element] ) != false ) { 132 jQuery(this).trigger('jGrowl.open'); 133 } 134 }).bind('jGrowl.open', function() { 135 if ( o.open.apply( notification , [notification,message,o,self.element] ) != false ) { 136 if ( o.glue == 'after' ) { 137 jQuery('div.jGrowl-notification:last', self.element).after(notification); 138 } else { 139 jQuery('div.jGrowl-notification:first', self.element).before(notification); 140 } 141 142 jQuery(this).animate(o.animateOpen, o.openDuration, o.easing, function() {
143 // Fixes some anti-aliasing issues with IE filters. 144 if (jQuery.browser.msie && (parseInt(jQuery(this).css('opacity'), 10) === 1 || parseInt(jQuery(this).css('opacity'), 10) === 0)) 145 this.style.removeAttribute('filter'); 146 147 jQuery(this).data("jGrowl").created = new Date(); 148 149 jQuery(this).trigger('jGrowl.afterOpen'); 150 }); 151 } 152 }).bind('jGrowl.afterOpen', function() { 153 o.afterOpen.apply( notification , [notification,message,o,self.element] ); 154 }).bind('jGrowl.beforeClose', function() { 155 if ( o.beforeClose.apply( notification , [notification,message,o,self.element] ) != false ) 156 jQuery(this).trigger('jGrowl.close'); 157 }).bind('jGrowl.close', function() { 158 // Pause the notification, lest during the course of animation another close event gets called. 159 jQuery(this).data('jGrowl.pause', true); 160 jQuery(this).animate(o.animateClose, o.closeDuration, o.easing, function() { 161 jQuery(this).remove(); 162 var close = o.close.apply( notification , [notification,message,o,self.element] ); 163 164 if ( jQuery.isFunction(close) ) 165 close.apply( notification , [notification,message,o,self.element] ); 166 }); 167 }).trigger('jGrowl.beforeOpen'); 168 169 /** Optional Corners Plugin **/ 170 if ( o.corners != '' && jQuery.fn.corner != undefined ) jQuery(notification).corner( o.corners ); 171 172 /** Add a Global Closer if more than one notification exists **/ 173 if ( jQuery('div.jGrowl-notification:parent', self.element).size() > 1 && 174 jQuery('div.jGrowl-closer', self.element).size() == 0 && this.defaults.closer != false ) { 175 // CUSTOM 176 if (this.defaults.closerTemplate == '') this.defaults.closerTemplate = '<div>[ ' + getLabel('js-label-jgrowl-close-all') + ' ]</div>'; 177 // CUSTOM 178 jQuery(this.defaults.closerTemplate).addClass('jGrowl-closer ui-state-highlight ui-corner-all').addClass(this.defaults.theme) 179 .appendTo(self.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing) 180 .bind("click.jGrowl", function() { 181 jQuery(this).siblings(":not(.dont_close)").trigger("jGrowl.beforeClose"); 182 if ( jQuery.isFunction( self.defaults.closer ) ) { 183 self.defaults.closer.apply( jQuery(this).parent()[0] , [jQuery(this).parent()[0]] ); 184 } 185 }); 186 }; 187 188 //if( $.browser.msie ) { 189 //$(this.element).css('left', (document_width - $(this.element).width()-50) + 'px'); 190 //} 191 }, 192 193 /** Update the jGrowl Container, removing old jGrowl notifications **/ 194 update: function() { 195 jQuery(this.element).find('div.jGrowl-notification:parent').each( function() { 196 if ( jQuery(this).data("jGrowl") != undefined && jQuery(this).data("jGrowl").created != undefined && jQuery(this).data("jGrowl").dont_close==false && 197 (jQuery(this).data("jGrowl").created.getTime() + parseInt(jQuery(this).data("jGrowl").life)) < (new Date()).getTime() && 198 jQuery(this).data("jGrowl").sticky != true && 199 (jQuery(this).data("jGrowl.pause") == undefined || jQuery(this).data("jGrowl.pause") != true) ) { 200 201 // Pause the notification, lest during the course of animation another close event gets called. 202 jQuery(this).trigger('jGrowl.beforeClose'); 203 } 204 }); 205 206 if ( this.notifications.length > 0 && 207 (this.defaults.pool == 0 || jQuery(this.element).find('div.jGrowl-notification:parent').size() < this.defaults.pool) ) 208 this.render( this.notifications.shift() ); 209 210 if ( jQuery(this.element).find('div.jGrowl-notification:parent').size() < 2 ) { 211 jQuery(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose, this.defaults.speed, this.defaults.easing, function() { 212 jQuery(this).remove(); 213 }); 214 } 215 }, 216 217 /** Setup the jGrowl Notification Container **/ 218 startup: function(e) { 219 this.element = jQuery(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>'); 220 this.interval = setInterval( function() { 221 jQuery(e).data('jGrowl.instance').update(); 222 }, parseInt(this.defaults.check)); 223
224 if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7 && !window["XMLHttpRequest"]) { 225 jQuery(this.element).addClass('ie6'); 226 } 227 228 229 }, 230 231 /** Shutdown jGrowl, removing it and clearing the interval **/ 232 shutdown: function() { 233 jQuery(this.element).removeClass('jGrowl').find('div.jGrowl-notification').remove(); 234 clearInterval( this.interval ); 235 }, 236 237 close: function() { 238 jQuery(this.element).find('div.jGrowl-notification').each(function(){ 239 jQuery(this).trigger('jGrowl.beforeClose'); 240 }); 241 }, 242 243 closeAllNow: function() { 244 jQuery(this.element).find('div.jGrowl-notification').each(function(){ 245 jQuery(this).trigger('jGrowl.beforeClose'); 246 jQuery(this).remove(); 247 }); 248 } 249 }); 250 251 /** Reference the Defaults Object for compatibility with older versions of jGrowl **/ 252 jQuery.jGrowl.defaults = jQuery.fn.jGrowl.prototype.defaults; 253 254})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.