1/** 2 * jGrowl 1.3.0 3 * 4 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 5 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. 6 * 7 * Written by Stan Lemon <[email protected]> 8 * Last updated: 2014.04.18 9 * 10 * jGrowl is a jQuery plugin implementing unobtrusive userland notifications. These 11 * notifications function similarly to the Growl Framework available for 12 * Mac OS X (http://growl.info). 13 * 14 * To Do: 15 * - Move library settings to containers and allow them to be changed per container
vendor: 5,321 bytes, lines 15-135
15 16 * 17 * Changes in 1.3.0 18 * - Added non-vendor border-radius to stylesheet 19 * - Added grunt for generating minified js and css 20 * - Added npm package info 21 * - Added bower package info 22 * - Updates for jshint 23 * 24 * Changes in 1.2.13 25 * - Fixed clearing interval when the container shuts down 26 * 27 * Changes in 1.2.12 28 * - Added compressed versions using UglifyJS and Sqwish 29 * - Improved README with configuration options explanation 30 * - Added a source map 31 * 32 * Changes in 1.2.11 33 * - Fix artifacts left behind by the shutdown method and text-cleanup 34 * 35 * Changes in 1.2.10 36 * - Fix beforeClose to be called in click event 37 * 38 * Changes in 1.2.9 39 * - Fixed BC break in jQuery 2.0 beta 40 * 41 * Changes in 1.2.8 42 * - Fixes for jQuery 1.9 and the MSIE6 check, note that with jQuery 2.0 support 43 * jGrowl intends to drop support for IE6 altogether 44 * 45 * Changes in 1.2.6 46 * - Fixed js error when a notification is opening and closing at the same time 47 * 48 * Changes in 1.2.5 49 * - Changed wrapper jGrowl's options usage to "o" instead of $.jGrowl.defaults 50 * - Added themeState option to control 'highlight' or 'error' for jQuery UI 51 * - Ammended some CSS to provide default positioning for nested usage. 52 * - Changed some CSS to be prefixed with jGrowl- to prevent namespacing issues 53 * - Added two new options - openDuration and closeDuration to allow 54 * better control of notification open and close speeds, respectively 55 * Patch contributed by Jesse Vincet. 56 * - Added afterOpen callback. Patch contributed by Russel Branca. 57 * 58 * Changes in 1.2.4 59 * - Fixed IE bug with the close-all button 60 * - Fixed IE bug with the filter CSS attribute (special thanks to gotwic) 61 * - Update IE opacity CSS 62 * - Changed font sizes to use "em", and only set the base style 63 * 64 * Changes in 1.2.3 65 * - The callbacks no longer use the container as context, instead they use the actual notification 66 * - The callbacks now receive the container as a parameter after the options parameter 67 * - beforeOpen and beforeClose now check the return value, if it's false - the notification does 68 * not continue. The open callback will also halt execution if it returns false. 69 * - Fixed bug where containers would get confused 70 * - Expanded the pause functionality to pause an entire container. 71 * 72 * Changes in 1.2.2 73 * - Notification can now be theme rolled for jQuery UI, special thanks to Jeff Chan! 74 * 75 * Changes in 1.2.1 76 * - Fixed instance where the interval would fire the close method multiple times. 77 * - Added CSS to hide from print media 78 * - Fixed issue with closer button when div { position: relative } is set 79 * - Fixed leaking issue with multiple containers. Special thanks to Matthew Hanlon! 80 * 81 * Changes in 1.2.0 82 * - Added message pooling to limit the number of messages appearing at a given time. 83 * - Closing a notification is now bound to the notification object and triggered by the close button. 84 * 85 * Changes in 1.1.2 86 * - Added iPhone styled example 87 * - Fixed possible IE7 bug when determining if the ie6 class shoudl be applied. 88 * - Added template for the close button, so that it's content could be customized. 89 * 90 * Changes in 1.1.1 91 * - Fixed CSS styling bug for ie6 caused by a mispelling 92 * - Changes height restriction on default notifications to min-height 93 * - Added skinned examples using a variety of images 94 * - Added the ability to customize the content of the [close all] box 95 * - Added jTweet, an example of using jGrowl + Twitter 96 * 97 * Changes in 1.1.0 98 * - Multiple container and instances. 99 * - Standard $.jGrowl() now wraps $.fn.jGrowl() by first establishing a generic jGrowl container. 100 * - Instance methods of a jGrowl container can be called by $.fn.jGrowl(methodName) 101 * - Added glue preferenced, which allows notifications to be inserted before or after nodes in the container 102 * - Added new log callback which is called before anything is done for the notification 103 * - Corner's attribute are now applied on an individual notification basis. 104 * 105 * Changes in 1.0.4 106 * - Various CSS fixes so that jGrowl renders correctly in IE6. 107 * 108 * Changes in 1.0.3 109 * - Fixed bug with options persisting across notifications 110 * - Fixed theme application bug 111 * - Simplified some selectors and manipulations. 112 * - Added beforeOpen and beforeClose callbacks 113 * - Reorganized some lines of code to be more readable 114 * - Removed unnecessary this.defaults context 115 * - If corners plugin is present, it's now customizable. 116 * - Customizable open animation. 117 * - Customizable close animation. 118 * - Customizable animation easing. 119 * - Added customizable positioning (top-left, top-right, bottom-left, bottom-right, center) 120 * 121 * Changes in 1.0.2 122 * - All CSS styling is now external. 123 * - Added a theme parameter which specifies a secondary class for styling, such 124 * that notifications can be customized in appearance on a per message basis. 125 * - Notification life span is now customizable on a per message basis. 126 * - Added the ability to disable the global closer, enabled by default. 127 * - Added callbacks for when a notification is opened or closed. 128 * - Added callback for the global closer. 129 * - Customizable animation speed. 130 * - jGrowl now set itself up and tears itself down. 131 * 132 * Changes in 1.0.1: 133 * - Removed dependency on metadata plugin in favor of .data() 134 * - Namespaced all events 135 */
136(function($) { 137 /** Compatibility holdover for 1.9 to check IE6 **/ 138 var $ie6 = (function(){ 139 return false === $.support.boxModel && $.support.objectAll && $.support.leadingWhitespace; 140 })(); 141 142 /** jGrowl Wrapper - Establish a base jGrowl Container for compatibility with older releases. **/ 143 $.jGrowl = function( m , o ) { 144 // To maintain compatibility with older version that only supported one instance we'll create the base container. 145 if ( $('#jGrowl').size() === 0 ) 146 $('<div id="jGrowl"></div>').addClass( (o && o.position) ? o.position : $.jGrowl.defaults.position ).appendTo('body'); 147 148 // Create a notification on the container. 149 $('#jGrowl').jGrowl(m,o); 150 }; 151 152 153 /** Raise jGrowl Notification on a jGrowl Container **/ 154 $.fn.jGrowl = function( m , o ) { 155 if ( $.isFunction(this.each) ) { 156 var args = arguments; 157 158 return this.each(function() { 159 /** Create a jGrowl Instance on the Container if it does not exist **/ 160 if ( $(this).data('jGrowl.instance') === undefined ) { 161 $(this).data('jGrowl.instance', $.extend( new $.fn.jGrowl(), { notifications: [], element: null, interval: null } )); 162 $(this).data('jGrowl.instance').startup( this ); 163 } 164 165 /** Optionally call jGrowl instance methods, or just raise a normal notification **/ 166 if ( $.isFunction($(this).data('jGrowl.instance')[m]) ) { 167 $(this).data('jGrowl.instance')[m].apply( $(this).data('jGrowl.instance') , $.makeArray(args).slice(1) ); 168 } else { 169 $(this).data('jGrowl.instance').create( m , o ); 170 } 171 }); 172 } 173 }; 174 175 $.extend( $.fn.jGrowl.prototype , { 176 177 /** Default JGrowl Settings **/ 178 defaults: { 179 pool: 0, 180 header: '', 181 group: '', 182 sticky: false, 183 position: 'top-right', 184 glue: 'after', 185 theme: 'default', 186 themeState: 'highlight', 187 corners: '10px', 188 check: 250, 189 life: 3000,
vendor: 8,512 bytes, lines 190-372
190 closeDuration: 'normal', 191 openDuration: 'normal', 192 easing: 'swing', 193 closer: true, 194 closeTemplate: '×', 195 closerTemplate: '<div>[ close all ]</div>', 196 log: function() {}, 197 beforeOpen: function() {}, 198 afterOpen: function() {}, 199 open: function() {}, 200 beforeClose: function() {}, 201 close: function() {}, 202 animateOpen: { 203 opacity: 'show' 204 }, 205 animateClose: { 206 opacity: 'hide' 207 } 208 }, 209 210 notifications: [], 211 212 /** jGrowl Container Node **/ 213 element: null, 214 215 /** Interval Function **/ 216 interval: null, 217 218 /** Create a Notification **/ 219 create: function( message , options ) { 220 var o = $.extend({}, this.defaults, options); 221 222 /* To keep backward compatibility with 1.24 and earlier, honor 'speed' if the user has set it */ 223 if (typeof o.speed !== 'undefined') { 224 o.openDuration = o.speed; 225 o.closeDuration = o.speed; 226 } 227 228 this.notifications.push({ message: message , options: o }); 229 230 o.log.apply( this.element , [this.element,message,o] ); 231 }, 232 233 render: function( n ) { 234 var self = this; 235 var message = n.message; 236 var o = n.options; 237 238 // Support for jQuery theme-states, if this is not used it displays a widget header 239 o.themeState = (o.themeState === '') ? '' : 'ui-state-' + o.themeState; 240 241 var notification = $('<div/>') 242 .addClass('jGrowl-notification ' + o.themeState + ' ui-corner-all' + ((o.group !== undefined && o.group !== '') ? ' ' + o.group : '')) 243 .append($('<div/>').addClass('jGrowl-close').html(o.closeTemplate)) 244 .append($('<div/>').addClass('jGrowl-header').html(o.header)) 245 .append($('<div/>').addClass('jGrowl-message').html(message)) 246 .data("jGrowl", o).addClass(o.theme).children('div.jGrowl-close').bind("click.jGrowl", function() { 247 $(this).parent().trigger('jGrowl.beforeClose'); 248 }) 249 .parent(); 250 251 252 /** Notification Actions **/ 253 $(notification).bind("mouseover.jGrowl", function() { 254 $('div.jGrowl-notification', self.element).data("jGrowl.pause", true); 255 }).bind("mouseout.jGrowl", function() { 256 $('div.jGrowl-notification', self.element).data("jGrowl.pause", false); 257 }).bind('jGrowl.beforeOpen', function() { 258 if ( o.beforeOpen.apply( notification , [notification,message,o,self.element] ) !== false ) { 259 $(this).trigger('jGrowl.open'); 260 } 261 }).bind('jGrowl.open', function() { 262 if ( o.open.apply( notification , [notification,message,o,self.element] ) !== false ) { 263 if ( o.glue == 'after' ) { 264 $('div.jGrowl-notification:last', self.element).after(notification); 265 } else { 266 $('div.jGrowl-notification:first', self.element).before(notification); 267 } 268 269 $(this).animate(o.animateOpen, o.openDuration, o.easing, function() { 270 // Fixes some anti-aliasing issues with IE filters. 271 if ($.support.opacity === false) 272 this.style.removeAttribute('filter'); 273 274 if ( $(this).data("jGrowl") !== null ) // Happens when a notification is closing before it's open. 275 $(this).data("jGrowl").created = new Date(); 276 277 $(this).trigger('jGrowl.afterOpen'); 278 }); 279 } 280 }).bind('jGrowl.afterOpen', function() { 281 o.afterOpen.apply( notification , [notification,message,o,self.element] ); 282 }).bind('jGrowl.beforeClose', function() { 283 if ( o.beforeClose.apply( notification , [notification,message,o,self.element] ) !== false ) 284 $(this).trigger('jGrowl.close'); 285 }).bind('jGrowl.close', function() { 286 // Pause the notification, lest during the course of animation another close event gets called. 287 $(this).data('jGrowl.pause', true); 288 $(this).animate(o.animateClose, o.closeDuration, o.easing, function() { 289 if ( $.isFunction(o.close) ) { 290 if ( o.close.apply( notification , [notification,message,o,self.element] ) !== false ) 291 $(this).remove(); 292 } else { 293 $(this).remove(); 294 } 295 }); 296 }).trigger('jGrowl.beforeOpen'); 297 298 /** Optional Corners Plugin **/ 299 if ( o.corners !== '' && $.fn.corner !== undefined ) $(notification).corner( o.corners ); 300 301 /** Add a Global Closer if more than one notification exists **/ 302 if ($('div.jGrowl-notification:parent', self.element).size() > 1 && 303 $('div.jGrowl-closer', self.element).size() === 0 && this.defaults.closer !== false ) { 304 $(this.defaults.closerTemplate).addClass('jGrowl-closer ' + this.defaults.themeState + ' ui-corner-all').addClass(this.defaults.theme) 305 .appendTo(self.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing) 306 .bind("click.jGrowl", function() { 307 $(this).siblings().trigger("jGrowl.beforeClose"); 308 309 if ( $.isFunction( self.defaults.closer ) ) { 310 self.defaults.closer.apply( $(this).parent()[0] , [$(this).parent()[0]] ); 311 } 312 }); 313 } 314 }, 315 316 /** Update the jGrowl Container, removing old jGrowl notifications **/ 317 update: function() { 318 $(this.element).find('div.jGrowl-notification:parent').each( function() { 319 if ($(this).data("jGrowl") !== undefined && $(this).data("jGrowl").created !== undefined && 320 ($(this).data("jGrowl").created.getTime() + parseInt($(this).data("jGrowl").life, 10)) < (new Date()).getTime() && 321 $(this).data("jGrowl").sticky !== true && 322 ($(this).data("jGrowl.pause") === undefined || $(this).data("jGrowl.pause") !== true) ) { 323 324 // Pause the notification, lest during the course of animation another close event gets called. 325 $(this).trigger('jGrowl.beforeClose'); 326 } 327 }); 328 329 if (this.notifications.length > 0 && 330 (this.defaults.pool === 0 || $(this.element).find('div.jGrowl-notification:parent').size() < this.defaults.pool) ) 331 this.render( this.notifications.shift() ); 332 333 if ($(this.element).find('div.jGrowl-notification:parent').size() < 2 ) { 334 $(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose, this.defaults.speed, this.defaults.easing, function() { 335 $(this).remove(); 336 }); 337 } 338 }, 339 340 /** Setup the jGrowl Notification Container **/ 341 startup: function(e) { 342 this.element = $(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>'); 343 this.interval = setInterval( function() { 344 $(e).data('jGrowl.instance').update(); 345 }, parseInt(this.defaults.check, 10)); 346 347 if ($ie6) { 348 $(this.element).addClass('ie6'); 349 } 350 }, 351 352 /** Shutdown jGrowl, removing it and clearing the interval **/ 353 shutdown: function() { 354 $(this.element).removeClass('jGrowl') 355 .find('div.jGrowl-notification').trigger('jGrowl.close') 356 .parent().empty() 357 ; 358 359 clearInterval(this.interval); 360 }, 361 362 close: function() { 363 $(this.element).find('div.jGrowl-notification').each(function(){ 364 $(this).trigger('jGrowl.beforeClose'); 365 }); 366 } 367 }); 368 369 /** Reference the Defaults Object for compatibility with older versions of jGrowl **/ 370 $.jGrowl.defaults = $.fn.jGrowl.prototype.defaults; 371 372})(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.