PageSourceSearch

https://www.pro-treino.com/theme/js/jquery.jgrowl.js

js pro-treino.com collected 2026-10-02 00:19:14 UTC 15,332 bytes, 399 lines download raw bytes

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