Update GAE to 1.2.3 in thirdparty folder.
[Melange.git] / app / jquery / jquery-purr.js
blobca5955cd9bded5e7d7531f8d19d4e41ec630a95d
1 /**
2 * jquery.purr.js
3 * Copyright (c) 2008 Net Perspective (net-perspective.com)
4 * Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
6 * @author R.A. Ray
7 * @projectDescription jQuery plugin for dynamically displaying unobtrusive messages in the browser. Mimics the behavior of the MacOS program "Growl."
8 * @version 0.1.0
10 * @requires jquery.js (tested with 1.2.6)
12 * @param fadeInSpeed int - Duration of fade in animation in miliseconds
13 * default: 500
14 * @param fadeOutSpeed int - Duration of fade out animationin miliseconds
15 default: 500
16 * @param removeTimer int - Timeout, in miliseconds, before notice is removed once it is the top non-sticky notice in the list
17 default: 4000
18 * @param isSticky bool - Whether the notice should fade out on its own or wait to be manually closed
19 default: false
20 * @param usingTransparentPNG bool - Whether or not the notice is using transparent .png images in its styling
21 default: false
24 ( function( $ ) {
26 $.purr = function ( notice, options )
28 // Convert notice to a jQuery object
29 notice = $( notice );
31 // Add a class to denote the notice as not sticky
32 if ( !options.isSticky )
34 notice.addClass( 'not-sticky' );
37 // Get the container element from the page
38 var cont = document.getElementById( 'purr-container' );
40 // If the container doesn't yet exist, we need to create it
41 if ( !cont )
43 cont = '<div id="purr-container"></div>';
46 // Convert cont to a jQuery object
47 cont = $( cont );
49 // Add the container to the page
50 $( 'body' ).append( cont );
52 notify();
54 function notify ()
56 // Set up the close button
57 var close = document.createElement( 'a' );
58 $( close ).attr(
60 className: 'close',
61 href: '#close',
62 innerHTML: 'Close'
65 .appendTo( notice )
66 .click( function ()
68 removeNotice();
70 return false;
74 // Add the notice to the page and keep it hidden initially
75 notice.appendTo( cont )
76 .hide();
78 if ( jQuery.browser.msie && options.usingTransparentPNG )
80 // IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
81 // notice style, we'll just skip the fading in.
82 notice.show();
84 else
86 //Fade in the notice we just added
87 notice.fadeIn( options.fadeInSpeed );
90 // Set up the removal interval for the added notice if that notice is not a sticky
91 if ( !options.isSticky )
93 var topSpotInt = setInterval( function ()
95 // Check to see if our notice is the first non-sticky notice in the list
96 if ( notice.prevAll( '.not-sticky' ).length == 0 )
98 // Stop checking once the condition is met
99 clearInterval( topSpotInt );
101 // Call the close action after the timeout set in options
102 setTimeout( function ()
104 removeNotice();
105 }, options.removeTimer
108 }, 200 );
112 function removeNotice ()
114 // IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
115 // notice style, we'll just skip the fading out.
116 if ( jQuery.browser.msie && options.usingTransparentPNG )
118 notice.css( { opacity: 0 } )
119 .animate(
121 height: '0px'
124 duration: options.fadeOutSpeed,
125 complete: function ()
127 notice.remove();
132 else
134 // Fade the object out before reducing its height to produce the sliding effect
135 notice.animate(
137 opacity: '0'
140 duration: options.fadeOutSpeed,
141 complete: function ()
143 notice.animate(
145 height: '0px'
148 duration: options.fadeOutSpeed,
149 complete: function ()
151 notice.remove();
162 $.fn.purr = function ( options )
164 options = options || {};
165 options.fadeInSpeed = options.fadeInSpeed || 500;
166 options.fadeOutSpeed = options.fadeOutSpeed || 500;
167 options.removeTimer = options.removeTimer || 4000;
168 options.isSticky = options.isSticky || false;
169 options.usingTransparentPNG = options.usingTransparentPNG || false;
171 this.each( function()
173 new $.purr( this, options );
177 return this;
179 })( jQuery );