best_in_placeish 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -10
- data/best_in_placeish-0.2.2.gem +0 -0
- data/best_in_placeish-0.2.3.gem +0 -0
- data/best_in_placeish.gemspec +27 -0
- data/lib/best_in_placeish.rb +8 -0
- data/lib/{best_in_place → best_in_placeish}/display_methods.rb +1 -1
- data/lib/{best_in_place → best_in_placeish}/helper.rb +7 -7
- data/lib/{best_in_place → best_in_placeish}/test_helpers.rb +5 -5
- data/lib/{best_in_place → best_in_placeish}/utils.rb +4 -4
- data/lib/best_in_placeish/version.rb +3 -0
- data/lib/generators/best_in_placeish/setup_generator.rb +11 -0
- data/public/javascripts/{best_in_place.js → best_in_placeish.js} +1 -1
- data/public/javascripts/jquery-1.4.4.js +7179 -0
- data/public/javascripts/jquery.purr.js +161 -0
- metadata +16 -10
- data/lib/best_in_place.rb +0 -8
- data/lib/best_in_place/version.rb +0 -3
@@ -0,0 +1,161 @@
|
|
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)
|
5
|
+
*
|
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
|
9
|
+
*
|
10
|
+
* @requires jquery.js (tested with 1.2.6)
|
11
|
+
*
|
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
|
22
|
+
*/
|
23
|
+
|
24
|
+
(function($) {
|
25
|
+
|
26
|
+
$.purr = function(notice, options)
|
27
|
+
{
|
28
|
+
// Convert notice to a jQuery object
|
29
|
+
notice = $(notice);
|
30
|
+
|
31
|
+
// Add a class to denote the notice as not sticky
|
32
|
+
notice.addClass('purr');
|
33
|
+
|
34
|
+
// Get the container element from the page
|
35
|
+
var cont = document.getElementById('purr-container');
|
36
|
+
|
37
|
+
// If the container doesn't yet exist, we need to create it
|
38
|
+
if (!cont)
|
39
|
+
{
|
40
|
+
cont = '<div id="purr-container"></div>';
|
41
|
+
}
|
42
|
+
|
43
|
+
// Convert cont to a jQuery object
|
44
|
+
cont = $(cont);
|
45
|
+
|
46
|
+
// Add the container to the page
|
47
|
+
$('body').append(cont);
|
48
|
+
|
49
|
+
notify();
|
50
|
+
|
51
|
+
function notify ()
|
52
|
+
{
|
53
|
+
// Set up the close button
|
54
|
+
var close = document.createElement('a');
|
55
|
+
$(close).attr({
|
56
|
+
className: 'close',
|
57
|
+
href: '#close'
|
58
|
+
}).appendTo(notice).click(function() {
|
59
|
+
removeNotice();
|
60
|
+
return false;
|
61
|
+
});
|
62
|
+
|
63
|
+
// If ESC is pressed remove notice
|
64
|
+
$(document).keyup(function(e) {
|
65
|
+
if (e.keyCode == 27) {
|
66
|
+
removeNotice();
|
67
|
+
}
|
68
|
+
});
|
69
|
+
|
70
|
+
// Add the notice to the page and keep it hidden initially
|
71
|
+
notice.appendTo(cont).hide();
|
72
|
+
|
73
|
+
if (jQuery.browser.msie && options.usingTransparentPNG)
|
74
|
+
{
|
75
|
+
// IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
|
76
|
+
// notice style, we'll just skip the fading in.
|
77
|
+
notice.show();
|
78
|
+
}
|
79
|
+
else
|
80
|
+
{
|
81
|
+
//Fade in the notice we just added
|
82
|
+
notice.fadeIn(options.fadeInSpeed);
|
83
|
+
}
|
84
|
+
|
85
|
+
// Set up the removal interval for the added notice if that notice is not a sticky
|
86
|
+
if (!options.isSticky)
|
87
|
+
{
|
88
|
+
var topSpotInt = setInterval(function() {
|
89
|
+
// Check to see if our notice is the first non-sticky notice in the list
|
90
|
+
if (notice.prevAll('.purr').length == 0)
|
91
|
+
{
|
92
|
+
// Stop checking once the condition is met
|
93
|
+
clearInterval(topSpotInt);
|
94
|
+
|
95
|
+
// Call the close action after the timeout set in options
|
96
|
+
setTimeout(function() {
|
97
|
+
removeNotice();
|
98
|
+
}, options.removeTimer);
|
99
|
+
}
|
100
|
+
}, 200);
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
function removeNotice()
|
105
|
+
{
|
106
|
+
// IE7 and earlier can't handle the combination of opacity and transparent pngs, so if we're using transparent pngs in our
|
107
|
+
// notice style, we'll just skip the fading out.
|
108
|
+
if (jQuery.browser.msie && options.usingTransparentPNG)
|
109
|
+
{
|
110
|
+
notice.css({ opacity: 0 }).animate({ height: '0px'},
|
111
|
+
{
|
112
|
+
duration: options.fadeOutSpeed,
|
113
|
+
complete: function ()
|
114
|
+
{
|
115
|
+
notice.remove();
|
116
|
+
}
|
117
|
+
}
|
118
|
+
);
|
119
|
+
}
|
120
|
+
else
|
121
|
+
{
|
122
|
+
// Fade the object out before reducing its height to produce the sliding effect
|
123
|
+
notice.animate({ opacity: '0' },
|
124
|
+
{
|
125
|
+
duration: options.fadeOutSpeed,
|
126
|
+
complete: function ()
|
127
|
+
{
|
128
|
+
notice.animate({ height: '0px' },
|
129
|
+
{
|
130
|
+
duration: options.fadeOutSpeed,
|
131
|
+
complete: function()
|
132
|
+
{
|
133
|
+
notice.remove();
|
134
|
+
}
|
135
|
+
}
|
136
|
+
);
|
137
|
+
}
|
138
|
+
}
|
139
|
+
);
|
140
|
+
}
|
141
|
+
};
|
142
|
+
};
|
143
|
+
|
144
|
+
$.fn.purr = function(options)
|
145
|
+
{
|
146
|
+
options = options || {};
|
147
|
+
options.fadeInSpeed = options.fadeInSpeed || 500;
|
148
|
+
options.fadeOutSpeed = options.fadeOutSpeed || 500;
|
149
|
+
options.removeTimer = options.removeTimer || 4000;
|
150
|
+
options.isSticky = options.isSticky || false;
|
151
|
+
options.usingTransparentPNG = options.usingTransparentPNG || false;
|
152
|
+
|
153
|
+
this.each(function()
|
154
|
+
{
|
155
|
+
new $.purr( this, options );
|
156
|
+
}
|
157
|
+
);
|
158
|
+
|
159
|
+
return this;
|
160
|
+
};
|
161
|
+
})( jQuery );
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: best_in_placeish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bernat Farrero
|
@@ -97,13 +97,19 @@ files:
|
|
97
97
|
- Gemfile
|
98
98
|
- README.md
|
99
99
|
- Rakefile
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
- lib/
|
104
|
-
- lib/
|
105
|
-
- lib/
|
106
|
-
-
|
100
|
+
- best_in_placeish-0.2.2.gem
|
101
|
+
- best_in_placeish-0.2.3.gem
|
102
|
+
- best_in_placeish.gemspec
|
103
|
+
- lib/best_in_placeish.rb
|
104
|
+
- lib/best_in_placeish/display_methods.rb
|
105
|
+
- lib/best_in_placeish/helper.rb
|
106
|
+
- lib/best_in_placeish/test_helpers.rb
|
107
|
+
- lib/best_in_placeish/utils.rb
|
108
|
+
- lib/best_in_placeish/version.rb
|
109
|
+
- lib/generators/best_in_placeish/setup_generator.rb
|
110
|
+
- public/javascripts/best_in_placeish.js
|
111
|
+
- public/javascripts/jquery-1.4.4.js
|
112
|
+
- public/javascripts/jquery.purr.js
|
107
113
|
- spec/helpers/best_in_place_spec.rb
|
108
114
|
- spec/integration/double_init_spec.rb
|
109
115
|
- spec/integration/js_spec.rb
|
data/lib/best_in_place.rb
DELETED