gritter 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +104 -82
- data/app/assets/images/error.png +0 -0
- data/app/assets/images/gritter-close-ie6.gif +0 -0
- data/app/assets/images/gritter-long.png +0 -0
- data/app/assets/images/gritter.png +0 -0
- data/app/assets/images/notice.png +0 -0
- data/app/assets/images/progress.gif +0 -0
- data/app/assets/images/success.png +0 -0
- data/app/assets/images/warning.png +0 -0
- data/app/assets/javascripts/gritter.js +19 -0
- data/app/assets/stylesheets/gritter.css.erb +94 -0
- data/lib/gritter.rb +14 -7
- data/lib/gritter/assets/images/error.png +0 -0
- data/lib/gritter/assets/images/gritter-long.png +0 -0
- data/lib/gritter/assets/images/gritter.png +0 -0
- data/lib/gritter/assets/images/notice.png +0 -0
- data/lib/gritter/assets/images/progress.gif +0 -0
- data/lib/gritter/assets/images/success.png +0 -0
- data/lib/gritter/assets/images/warning.png +0 -0
- data/lib/gritter/assets/stylesheets/jquery.gritter.css +52 -52
- data/lib/gritter/engine.rb +7 -0
- data/lib/gritter/helpers.rb +2 -2
- data/lib/gritter/version.rb +1 -1
- metadata +14 -3
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# gritter
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
version 0.6.2
|
4
|
+
Robin Brouwer
|
5
|
+
Daniël Zwijnenburg
|
6
|
+
45north
|
7
7
|
|
8
8
|
This Ruby on Rails gem allows you to easily add Growl-like notifications to your application using a jQuery plugin called 'gritter'.
|
9
9
|
|
@@ -11,38 +11,55 @@ This Ruby on Rails gem allows you to easily add Growl-like notifications to your
|
|
11
11
|
|
12
12
|
You can use this gem by putting the following inside your Gemfile:
|
13
13
|
|
14
|
-
|
14
|
+
gem "gritter", "0.6.2"
|
15
15
|
|
16
16
|
You can also install this as a plugin with the following command:
|
17
17
|
|
18
|
-
|
18
|
+
rails plugin install git://github.com/RobinBrouwer/gritter.git
|
19
19
|
|
20
20
|
This is a Rails 3 gem. When you're using Rails 2 you should use version 0.3 (this is a plugin):
|
21
21
|
|
22
|
-
|
22
|
+
script/plugin install git://github.com/RobinBrouwer/gritter.git -r 'tag v0.3'
|
23
|
+
|
24
|
+
## Rails 3.1 installation
|
25
|
+
|
26
|
+
Gritter now also supports Rails 3.1, thanks to [finist](https://github.com/finist]).
|
27
|
+
Adding the JavaScript en CSS files is accomplished in a different way, because of the new 'assets' folder inside /app.
|
28
|
+
|
29
|
+
Add the following to /app/assets/javascripts/application.js:
|
30
|
+
|
31
|
+
//= require gritter
|
32
|
+
|
33
|
+
And the following to /app/assets/stylesheets/application.css:
|
34
|
+
|
35
|
+
*= require gritter
|
36
|
+
|
37
|
+
And that's it! It now works with Rails 3.1. No need to add `include_gritter` to your layout.
|
38
|
+
|
39
|
+
## Rails 3.0 installation
|
23
40
|
|
24
41
|
Start your server and you'll see that three folders are added to your /javascripts, /stylesheets and /images folders.
|
25
|
-
Now you can use gritter inside your Rails application.
|
42
|
+
Now you can use gritter inside your Rails 3.0 application.
|
26
43
|
|
27
44
|
Now add the following to your head-tag inside the layout:
|
28
45
|
|
29
|
-
|
46
|
+
<%= include_gritter %>
|
30
47
|
|
31
48
|
If you also want to add jQuery together with gritter (from googleapis.com) you can use the following helper:
|
32
49
|
|
33
|
-
|
50
|
+
<%= include_gritter_and_jquery %>
|
34
51
|
|
35
52
|
You can pass extra arguments to these functions to set the default options for gritter.
|
36
53
|
|
37
|
-
|
38
|
-
|
39
|
-
|
54
|
+
:fade_in_speed => "medium" # => Allows you to set the fade-in-speed. Can be String or Integer (in ms).
|
55
|
+
:fade_out_speed => 1000 # => Allows you to set the fade-out-speed. Can be String or Integer (in ms).
|
56
|
+
:time => 8000 # => Allows you to set the time the notification stays. Must be an Integer (in ms).
|
40
57
|
|
41
58
|
The :fade_in_speed and :fade_out_speed options accept the following Strings:
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
59
|
+
|
60
|
+
"slow"
|
61
|
+
"medium"
|
62
|
+
"fast"
|
46
63
|
|
47
64
|
Now you can use gritter inside your Rails application.
|
48
65
|
You should really check out the gflash helper. It's really handy!
|
@@ -50,31 +67,36 @@ You should really check out the gflash helper. It's really handy!
|
|
50
67
|
|
51
68
|
## Changes
|
52
69
|
|
70
|
+
Version 0.6.2 changes:
|
71
|
+
|
72
|
+
- Reduced the size of all images;
|
73
|
+
- Also works with Rails 3.1.
|
74
|
+
|
53
75
|
Version 0.6 changes:
|
54
76
|
|
55
|
-
|
56
|
-
|
77
|
+
- Added locales support for gflash (see README);
|
78
|
+
- README changes.
|
57
79
|
|
58
80
|
Version 0.5 changes:
|
59
81
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
82
|
+
- Works with Ruby 1.9 now (the Array.to_s was causing problems);
|
83
|
+
- Refactored a lot of code to make everything a bit more logical;
|
84
|
+
- The js helper doesn't add a semicolon (;) after the script anymore;
|
85
|
+
- The js helper accepts several scripts as options;
|
86
|
+
- Changed the way linebreaks (\n) are created;
|
87
|
+
- Added an 'e' variable for all the callbacks;
|
88
|
+
- Added String support for :fade_out_speed;
|
89
|
+
- Changed the README.
|
68
90
|
|
69
91
|
|
70
92
|
## Usage
|
71
93
|
|
72
94
|
There are several helpers you can use with gritter. All of them print out Javascript code without script-tags.
|
73
95
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
96
|
+
add_gritter
|
97
|
+
remove_gritter
|
98
|
+
extend_gritter
|
99
|
+
|
78
100
|
To add the script-tags we added another function called `js`. It allows you to easily add script-tags around your javascript.
|
79
101
|
It can be used in combination with gritter, but also other Javascript you want to run.
|
80
102
|
|
@@ -86,41 +108,41 @@ Since version 0.3 we also added a `gflash` helper. This helper supports locales
|
|
86
108
|
The `add_gritter` helper allows you to add a gritter notification to your application.
|
87
109
|
It outputs Javascript directly into your template. It works like this inside a `js.erb` file:
|
88
110
|
|
89
|
-
|
111
|
+
<%= add_gritter("This is a notification just for you!") %>
|
90
112
|
|
91
113
|
The `add_gritter` helper allows you to easily set the text for the notification.
|
92
114
|
When you want to change the title, just pass the `:title` argument to the helper:
|
93
115
|
|
94
|
-
|
116
|
+
<%= add_gritter("This is a notification just for you!", :title => "Please pay attention!") %>
|
95
117
|
|
96
118
|
There are many more arguments you can pass to the helper:
|
97
119
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
120
|
+
:title => "This is a title" # => Allows you to set the title for the notification.
|
121
|
+
:image => "/images/rails.png" # => Allows you to add an image to the notification.
|
122
|
+
:sticky => true # => Allows you to make the notification sticky.
|
123
|
+
:time => 4000 # => Allows you to set the time when the notification disappears (in ms).
|
124
|
+
:class_name => "gritter" # => Allows you to set a different classname.
|
125
|
+
:before_open => "alert('Opening!');" # => Execute javascript before opening.
|
126
|
+
:after_open => "alert('Opened!');" # => Execute javascript after opening.
|
127
|
+
:before_close => "alert('Closing!');" # => Execute javascript before closing.
|
128
|
+
:after_close => "alert('Closed!');" # => Execute javascript after closing.
|
107
129
|
|
108
130
|
The `:image` argument also allows you to easily set five different images:
|
109
131
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
132
|
+
:success
|
133
|
+
:warning
|
134
|
+
:notice
|
135
|
+
:error
|
136
|
+
:progress
|
115
137
|
|
116
138
|
It works like this in combination with flash[:notice] and the `js` helper:
|
117
139
|
|
118
|
-
|
140
|
+
<%= js add_gritter(flash[:notice], :image => :notice, :title => "Pay attention!", :sticky => true) %>
|
119
141
|
|
120
142
|
The js helper is almost the same as the javascript_tag helper. The difference is that you can pass several scripts at once.
|
121
143
|
You don't need to pass these scripts as an Array. The helper also adds a linebreak (\n) after each script.
|
122
144
|
|
123
|
-
|
145
|
+
<%= js add_gritter("See my notification"), add_gritter("Another one") %>
|
124
146
|
|
125
147
|
It puts all the scripts inside a single script-tag.
|
126
148
|
|
@@ -132,12 +154,12 @@ It's great for all kinds of notifications, including the flash notifications you
|
|
132
154
|
|
133
155
|
The `remove_gritter` helper removes all gritter notifications from the screen. You can use it inside a `js.erb` file:
|
134
156
|
|
135
|
-
|
157
|
+
<%= remove_gritter %>
|
136
158
|
|
137
159
|
You can pass two extra arguments to this helper.
|
138
160
|
|
139
|
-
|
140
|
-
|
161
|
+
:before_close => "alert('Closing!');" # => Execute javascript before closing.
|
162
|
+
:after_close => "alert('Closed!');" # => Execute javascript after closing.
|
141
163
|
|
142
164
|
You can also use the `js` helper to add script-tags around this helper.
|
143
165
|
|
@@ -155,60 +177,60 @@ You can also use the `js` helper to add script-tags around this helper.
|
|
155
177
|
The `gflash` helper is a different kind of `flash[:notice]` message. It uses the `add_gritter` helper and the default images used in this plugin.
|
156
178
|
It uses a session to remember the flash messages. Add the following inside your controller action:
|
157
179
|
|
158
|
-
|
159
|
-
|
160
|
-
|
180
|
+
def create
|
181
|
+
gflash :success => "The product has been created successfully!"
|
182
|
+
end
|
161
183
|
|
162
184
|
Now you can add the following to your layout view inside the body-tag:
|
163
185
|
|
164
|
-
|
165
|
-
|
186
|
+
<%= gflash %>
|
187
|
+
|
166
188
|
The flash-message will be shown with 'success.png' as the image and 'Success' as the title.
|
167
189
|
To change the title you can add the following to the `gflash` helper inside the layout:
|
168
190
|
|
169
|
-
|
170
|
-
|
191
|
+
<%= gflash :success => "It has been successful!" %>
|
192
|
+
|
171
193
|
Now the default title will be overwritten. You can use the following gflash options:
|
172
194
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
195
|
+
:success
|
196
|
+
:warning
|
197
|
+
:notice
|
198
|
+
:error
|
199
|
+
:progress
|
178
200
|
|
179
201
|
Each uses the corresponding image and title. You can also add multiple gritter notifications at once:
|
180
202
|
|
181
|
-
|
182
|
-
|
183
|
-
|
203
|
+
def create
|
204
|
+
gflash :success => "The product has been created successfully!", :notice => "This product doesn't have a category."
|
205
|
+
end
|
184
206
|
|
185
207
|
Besides passing the exact text inside the controller, gflash also supports locales (both for messages and titles).
|
186
208
|
When you start your server a new locale file will be added to /config/locales called `gflash.en.yml`.
|
187
209
|
Here you can set the locales for all your gflash messages and the titles. It works like this:
|
188
210
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
211
|
+
en:
|
212
|
+
gflash:
|
213
|
+
titles:
|
214
|
+
notice: "Custom notice title"
|
215
|
+
success: "Success"
|
216
|
+
warning: "Warning"
|
217
|
+
error: "Error"
|
218
|
+
progress: "Progress"
|
219
|
+
products: # => Controller name
|
220
|
+
create: # => Action name
|
221
|
+
notice: "Custom notice message"
|
200
222
|
|
201
223
|
Now you can do the following inside your Controller:
|
202
224
|
|
203
|
-
|
204
|
-
|
205
|
-
|
225
|
+
def create
|
226
|
+
gflash :notice => true
|
227
|
+
end
|
206
228
|
|
207
229
|
The locales for the `:notice` title and message will now be used. You can still pass a `String` to overwrite a locale.
|
208
230
|
|
209
231
|
You can also use gflash inside `js.erb` files:
|
210
232
|
|
211
|
-
|
233
|
+
<%= gflash :js => true %>
|
212
234
|
|
213
235
|
And that's how you add gflash to your Rails application.
|
214
236
|
Just remember that you can only set which gflash message you want shown inside the controller.
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
(function($){$.gritter={};$.gritter.options={fade_in_speed:'medium',fade_out_speed:1000,time:6000}
|
2
|
+
$.gritter.add=function(params){try{return Gritter.add(params||{});}catch(e){var err='Gritter Error: '+e;(typeof(console)!='undefined'&&console.error)?console.error(err,params):alert(err);}}
|
3
|
+
$.gritter.remove=function(id,params){Gritter.removeSpecific(id,params||{});}
|
4
|
+
$.gritter.removeAll=function(params){Gritter.stop(params||{});}
|
5
|
+
var Gritter={fade_in_speed:'',fade_out_speed:'',time:'',_custom_timer:0,_item_count:0,_is_setup:0,_tpl_close:'<div class="gritter-close"></div>',_tpl_item:'<div id="gritter-item-[[number]]" class="gritter-item-wrapper [[item_class]]" style="display:none"><div class="gritter-top"></div><div class="gritter-item">[[image]]<div class="[[class_name]]"><span class="gritter-title">[[username]]</span><p>[[text]]</p></div><div style="clear:both"></div></div><div class="gritter-bottom"></div></div>',_tpl_wrap:'<div id="gritter-notice-wrapper"></div>',add:function(params){if(!params.title||!params.text){throw'You need to fill out the first 2 params: "title" and "text"';}
|
6
|
+
if(!this._is_setup){this._runSetup();}
|
7
|
+
var user=params.title,text=params.text,image=params.image||'',sticky=params.sticky||false,item_class=params.class_name||'',time_alive=params.time||'';this._verifyWrapper();this._item_count++;var number=this._item_count,tmp=this._tpl_item;$(['before_open','after_open','before_close','after_close']).each(function(i,val){Gritter['_'+val+'_'+number]=($.isFunction(params[val]))?params[val]:function(){}});this._custom_timer=0;if(time_alive){this._custom_timer=time_alive;}
|
8
|
+
var image_str=(image!='')?'<img src="'+image+'" class="gritter-image" />':'',class_name=(image!='')?'gritter-with-image':'gritter-without-image';tmp=this._str_replace(['[[username]]','[[text]]','[[image]]','[[number]]','[[class_name]]','[[item_class]]'],[user,text,image_str,this._item_count,class_name,item_class],tmp);this['_before_open_'+number]();$('#gritter-notice-wrapper').append(tmp);var item=$('#gritter-item-'+this._item_count);item.fadeIn(this.fade_in_speed,function(){Gritter['_after_open_'+number]($(this));});if(!sticky){this._setFadeTimer(item,number);}
|
9
|
+
$(item).bind('mouseenter mouseleave',function(event){if(event.type=='mouseenter'){if(!sticky){Gritter._restoreItemIfFading($(this),number);}}
|
10
|
+
else{if(!sticky){Gritter._setFadeTimer($(this),number);}}
|
11
|
+
Gritter._hoverState($(this),event.type);});return number;},_countRemoveWrapper:function(unique_id,e){e.remove();this['_after_close_'+unique_id](e);if($('.gritter-item-wrapper').length==0){$('#gritter-notice-wrapper').remove();}},_fade:function(e,unique_id,params,unbind_events){var params=params||{},fade=(typeof(params.fade)!='undefined')?params.fade:true;fade_out_speed=params.speed||this.fade_out_speed;this['_before_close_'+unique_id](e);if(unbind_events){e.unbind('mouseenter mouseleave');}
|
12
|
+
if(fade){e.animate({opacity:0},fade_out_speed,function(){e.animate({height:0},300,function(){Gritter._countRemoveWrapper(unique_id,e);})})}
|
13
|
+
else{this._countRemoveWrapper(unique_id,e);}},_hoverState:function(e,type){if(type=='mouseenter'){e.addClass('hover');var find_img=e.find('img');(find_img.length)?find_img.before(this._tpl_close):e.find('span').before(this._tpl_close);e.find('.gritter-close').click(function(){var unique_id=e.attr('id').split('-')[2];Gritter.removeSpecific(unique_id,{},e,true);});}
|
14
|
+
else{e.removeClass('hover');e.find('.gritter-close').remove();}},removeSpecific:function(unique_id,params,e,unbind_events){if(!e){var e=$('#gritter-item-'+unique_id);}
|
15
|
+
this._fade(e,unique_id,params||{},unbind_events);},_restoreItemIfFading:function(e,unique_id){clearTimeout(this['_int_id_'+unique_id]);e.stop().css({opacity:''});},_runSetup:function(){for(opt in $.gritter.options){this[opt]=$.gritter.options[opt];}
|
16
|
+
this._is_setup=1;},_setFadeTimer:function(e,unique_id){var timer_str=(this._custom_timer)?this._custom_timer:this.time;this['_int_id_'+unique_id]=setTimeout(function(){Gritter._fade(e,unique_id);},timer_str);},stop:function(params){var before_close=($.isFunction(params.before_close))?params.before_close:function(){};var after_close=($.isFunction(params.after_close))?params.after_close:function(){};var wrap=$('#gritter-notice-wrapper');before_close(wrap);wrap.fadeOut(function(){$(this).remove();after_close();});},_str_replace:function(search,replace,subject,count){var i=0,j=0,temp='',repl='',sl=0,fl=0,f=[].concat(search),r=[].concat(replace),s=subject,ra=r instanceof Array,sa=s instanceof Array;s=[].concat(s);if(count){this.window[count]=0;}
|
17
|
+
for(i=0,sl=s.length;i<sl;i++){if(s[i]===''){continue;}
|
18
|
+
for(j=0,fl=f.length;j<fl;j++){temp=s[i]+'';repl=ra?(r[j]!==undefined?r[j]:''):r[0];s[i]=(temp).split(f[j]).join(repl);if(count&&s[i]!==temp){this.window[count]+=(temp.length-s[i].length)/f[j].length;}}}
|
19
|
+
return sa?s:s[0];},_verifyWrapper:function(){if($('#gritter-notice-wrapper').length==0){$('body').append(this._tpl_wrap);}}}})(jQuery);
|
@@ -0,0 +1,94 @@
|
|
1
|
+
/* ie6 trash */
|
2
|
+
* html #gritter-notice-wrapper {
|
3
|
+
position:absolute;
|
4
|
+
}
|
5
|
+
* html .gritter-top {
|
6
|
+
margin-bottom:-10px;
|
7
|
+
}
|
8
|
+
* html .gritter-item {
|
9
|
+
padding-bottom:0;
|
10
|
+
}
|
11
|
+
* html .gritter-bottom {
|
12
|
+
margin-bottom:0;
|
13
|
+
}
|
14
|
+
* html .gritter-close {
|
15
|
+
background:url(<%= asset_path('gritter-close-ie6.gif')%>);
|
16
|
+
width:22px;
|
17
|
+
height:22px;
|
18
|
+
top:7px;
|
19
|
+
left:7px;
|
20
|
+
}
|
21
|
+
|
22
|
+
/* the norm */
|
23
|
+
#gritter-notice-wrapper {
|
24
|
+
position:fixed;
|
25
|
+
text-align:left;
|
26
|
+
top:20px;
|
27
|
+
right:20px;
|
28
|
+
width:301px;
|
29
|
+
z-index:9999;
|
30
|
+
}
|
31
|
+
.gritter-item-wrapper {
|
32
|
+
position:relative;
|
33
|
+
margin:0 0 10px 0;
|
34
|
+
/* background:url('.'); /* ie7/8 fix */
|
35
|
+
}
|
36
|
+
.gritter-top {
|
37
|
+
background:url(<%= asset_path('gritter.png')%>) no-repeat left -30px;
|
38
|
+
height:10px;
|
39
|
+
}
|
40
|
+
.hover .gritter-top {
|
41
|
+
background-position:right -30px;
|
42
|
+
}
|
43
|
+
.gritter-bottom {
|
44
|
+
background:url(<%= asset_path('gritter.png')%>) no-repeat left bottom;
|
45
|
+
height:8px;
|
46
|
+
margin:0;
|
47
|
+
}
|
48
|
+
.hover .gritter-bottom {
|
49
|
+
background-position: bottom right;
|
50
|
+
}
|
51
|
+
.gritter-item {
|
52
|
+
display:block;
|
53
|
+
background:url(<%= asset_path('gritter.png')%>) no-repeat left -40px;
|
54
|
+
color:#eee;
|
55
|
+
padding:2px 11px 8px 11px;
|
56
|
+
font-size: 11px;
|
57
|
+
font-family:verdana;
|
58
|
+
}
|
59
|
+
.hover .gritter-item {
|
60
|
+
background-position:right -40px;
|
61
|
+
}
|
62
|
+
.gritter-item p {
|
63
|
+
padding:0;
|
64
|
+
margin:0;
|
65
|
+
}
|
66
|
+
.gritter-close {
|
67
|
+
position:absolute;
|
68
|
+
top:5px;
|
69
|
+
left:3px;
|
70
|
+
background:url(<%= asset_path('gritter.png')%>) no-repeat left top;
|
71
|
+
cursor:pointer;
|
72
|
+
width:30px;
|
73
|
+
height:30px;
|
74
|
+
}
|
75
|
+
.gritter-title {
|
76
|
+
font-size:14px;
|
77
|
+
font-weight:bold;
|
78
|
+
padding:0 0 7px 0;
|
79
|
+
display:block;
|
80
|
+
text-shadow:1px 1px #000; /* Not supported by IE :( */
|
81
|
+
}
|
82
|
+
.gritter-image {
|
83
|
+
width:48px;
|
84
|
+
height:48px;
|
85
|
+
float:left;
|
86
|
+
}
|
87
|
+
.gritter-with-image,
|
88
|
+
.gritter-without-image {
|
89
|
+
padding:0 0 5px 0;
|
90
|
+
}
|
91
|
+
.gritter-with-image {
|
92
|
+
width:220px;
|
93
|
+
float:right;
|
94
|
+
}
|
data/lib/gritter.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'gritter/helpers'
|
2
2
|
require 'gritter/gflash'
|
3
|
+
require 'gritter/engine'
|
4
|
+
require 'fileutils'
|
3
5
|
|
4
6
|
module Gritter
|
5
7
|
def self.initialize
|
@@ -7,20 +9,27 @@ module Gritter
|
|
7
9
|
raise "ActionController is not available yet." unless defined?(ActionController)
|
8
10
|
ActionController::Base.send(:helper, Gritter::Helpers)
|
9
11
|
ActionController::Base.send(:include, Gritter::Gflash)
|
10
|
-
Gritter.
|
12
|
+
Gritter.install_locales
|
13
|
+
Gritter.install_gritter if ::Rails.version < "3.1"
|
11
14
|
@initialized = true
|
12
15
|
end
|
13
16
|
|
17
|
+
def self.install_locales
|
18
|
+
orig_lang = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'gflash.en.yml')
|
19
|
+
dest_lang = File.join(Rails.root, 'config', 'locales', 'gflash.en.yml')
|
20
|
+
unless File.exists?(dest_lang)
|
21
|
+
puts "Copying language file to #{dest_lang}..."
|
22
|
+
FileUtils.cp_r orig_lang, dest_lang
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
14
26
|
def self.install_gritter
|
15
|
-
require 'fileutils'
|
16
27
|
orig_javascripts = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'javascripts')
|
17
28
|
orig_stylesheets = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'stylesheets')
|
18
29
|
orig_images = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'images')
|
19
|
-
orig_lang = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'gflash.en.yml')
|
20
30
|
dest_javascripts = File.join(Rails.root, 'public', 'javascripts', 'gritter')
|
21
31
|
dest_stylesheets = File.join(Rails.root, 'public', 'stylesheets', 'gritter')
|
22
32
|
dest_images = File.join(Rails.root, 'public', 'images', 'gritter')
|
23
|
-
dest_lang = File.join(Rails.root, 'config', 'locales', 'gflash.en.yml')
|
24
33
|
|
25
34
|
gritter = File.join(dest_javascripts, 'jquery.gritter.min.js')
|
26
35
|
|
@@ -38,8 +47,6 @@ module Gritter
|
|
38
47
|
FileUtils.cp_r "#{orig_stylesheets}/.", dest_stylesheets
|
39
48
|
puts "Copying gritter to #{dest_images}..."
|
40
49
|
FileUtils.cp_r "#{orig_images}/.", dest_images
|
41
|
-
puts "Copying language file to #{dest_lang}..."
|
42
|
-
FileUtils.cp_r orig_lang, dest_lang
|
43
50
|
puts "Successfully installed gritter."
|
44
51
|
rescue
|
45
52
|
puts "ERROR: Problem installing gritter. Please copy the files manually."
|
@@ -50,4 +57,4 @@ end
|
|
50
57
|
|
51
58
|
if defined?(Rails::Railtie)
|
52
59
|
require 'gritter/railtie'
|
53
|
-
end
|
60
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,94 +1,94 @@
|
|
1
1
|
/* ie6 trash */
|
2
2
|
* html #gritter-notice-wrapper {
|
3
|
-
|
3
|
+
position:absolute;
|
4
4
|
}
|
5
5
|
* html .gritter-top {
|
6
|
-
|
6
|
+
margin-bottom:-10px;
|
7
7
|
}
|
8
8
|
* html .gritter-item {
|
9
|
-
|
9
|
+
padding-bottom:0;
|
10
10
|
}
|
11
11
|
* html .gritter-bottom {
|
12
|
-
|
12
|
+
margin-bottom:0;
|
13
13
|
}
|
14
14
|
* html .gritter-close {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
background:url(/images/gritter/gritter-close-ie6.gif);
|
16
|
+
width:22px;
|
17
|
+
height:22px;
|
18
|
+
top:7px;
|
19
|
+
left:7px;
|
20
20
|
}
|
21
21
|
|
22
22
|
/* the norm */
|
23
23
|
#gritter-notice-wrapper {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
position:fixed;
|
25
|
+
text-align:left;
|
26
|
+
top:20px;
|
27
|
+
right:20px;
|
28
|
+
width:301px;
|
29
|
+
z-index:9999;
|
30
30
|
}
|
31
31
|
.gritter-item-wrapper {
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
position:relative;
|
33
|
+
margin:0 0 10px 0;
|
34
|
+
/* background:url('.'); /* ie7/8 fix */
|
35
35
|
}
|
36
36
|
.gritter-top {
|
37
|
-
|
38
|
-
|
37
|
+
background:url(/images/gritter/gritter.png) no-repeat left -30px;
|
38
|
+
height:10px;
|
39
39
|
}
|
40
40
|
.hover .gritter-top {
|
41
|
-
|
41
|
+
background-position:right -30px;
|
42
42
|
}
|
43
43
|
.gritter-bottom {
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
background:url(/images/gritter/gritter.png) no-repeat left bottom;
|
45
|
+
height:8px;
|
46
|
+
margin:0;
|
47
47
|
}
|
48
48
|
.hover .gritter-bottom {
|
49
|
-
|
49
|
+
background-position: bottom right;
|
50
50
|
}
|
51
51
|
.gritter-item {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
display:block;
|
53
|
+
background:url(/images/gritter/gritter.png) no-repeat left -40px;
|
54
|
+
color:#eee;
|
55
|
+
padding:2px 11px 8px 11px;
|
56
|
+
font-size: 11px;
|
57
|
+
font-family:verdana;
|
58
58
|
}
|
59
59
|
.hover .gritter-item {
|
60
|
-
|
60
|
+
background-position:right -40px;
|
61
61
|
}
|
62
62
|
.gritter-item p {
|
63
|
-
|
64
|
-
|
63
|
+
padding:0;
|
64
|
+
margin:0;
|
65
65
|
}
|
66
66
|
.gritter-close {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
position:absolute;
|
68
|
+
top:5px;
|
69
|
+
left:3px;
|
70
|
+
background:url(/images/gritter/gritter.png) no-repeat left top;
|
71
|
+
cursor:pointer;
|
72
|
+
width:30px;
|
73
|
+
height:30px;
|
74
74
|
}
|
75
75
|
.gritter-title {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
font-size:14px;
|
77
|
+
font-weight:bold;
|
78
|
+
padding:0 0 7px 0;
|
79
|
+
display:block;
|
80
|
+
text-shadow:1px 1px #000; /* Not supported by IE :( */
|
81
81
|
}
|
82
82
|
.gritter-image {
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
width:48px;
|
84
|
+
height:48px;
|
85
|
+
float:left;
|
86
86
|
}
|
87
87
|
.gritter-with-image,
|
88
88
|
.gritter-without-image {
|
89
|
-
|
89
|
+
padding:0 0 5px 0;
|
90
90
|
}
|
91
91
|
.gritter-with-image {
|
92
|
-
|
93
|
-
|
92
|
+
width:220px;
|
93
|
+
float:right;
|
94
94
|
}
|
data/lib/gritter/helpers.rb
CHANGED
@@ -15,13 +15,13 @@ module Gritter
|
|
15
15
|
def add_gritter text, *args
|
16
16
|
options = args.extract_options!
|
17
17
|
options[:title] = "Notification" if options[:title].blank?
|
18
|
-
options[:image] = "/images/gritter/#{options[:image]}.png" if %w(success warning error notice progress).include?(options[:image].to_s)
|
18
|
+
options[:image] = ::Rails.version < "3.1" ? "/images/gritter/#{options[:image]}.png" : asset_path("#{options[:image]}.png") if %w(success warning error notice progress).include?(options[:image].to_s)
|
19
19
|
notification = ["$.gritter.add({"]
|
20
20
|
notification.push("image:'#{options[:image]}',") if options[:image].present?
|
21
21
|
notification.push("sticky:#{options[:sticky]},") if options[:sticky].present?
|
22
22
|
notification.push("time:#{options[:time]},") if options[:time].present?
|
23
23
|
notification.push("class_name:'#{options[:class_name]}',") if options[:class_name].present?
|
24
|
-
|
24
|
+
notification.push("before_open:function(e){#{options[:before_open]}},") if options[:before_open].present?
|
25
25
|
notification.push("after_open:function(e){#{options[:after_open]}},") if options[:after_open].present?
|
26
26
|
notification.push("before_close:function(e){#{options[:before_close]}},") if options[:before_close].present?
|
27
27
|
notification.push("after_close:function(e){#{options[:after_close]}},") if options[:after_close].present?
|
data/lib/gritter/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 2
|
9
|
+
version: 0.6.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Robin Brouwer
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-30 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -33,6 +33,16 @@ files:
|
|
33
33
|
- Gemfile
|
34
34
|
- README.md
|
35
35
|
- Rakefile
|
36
|
+
- app/assets/images/error.png
|
37
|
+
- app/assets/images/gritter-close-ie6.gif
|
38
|
+
- app/assets/images/gritter-long.png
|
39
|
+
- app/assets/images/gritter.png
|
40
|
+
- app/assets/images/notice.png
|
41
|
+
- app/assets/images/progress.gif
|
42
|
+
- app/assets/images/success.png
|
43
|
+
- app/assets/images/warning.png
|
44
|
+
- app/assets/javascripts/gritter.js
|
45
|
+
- app/assets/stylesheets/gritter.css.erb
|
36
46
|
- gritter.gemspec
|
37
47
|
- init.rb
|
38
48
|
- lib/gritter.rb
|
@@ -47,6 +57,7 @@ files:
|
|
47
57
|
- lib/gritter/assets/images/warning.png
|
48
58
|
- lib/gritter/assets/javascripts/jquery.gritter.min.js
|
49
59
|
- lib/gritter/assets/stylesheets/jquery.gritter.css
|
60
|
+
- lib/gritter/engine.rb
|
50
61
|
- lib/gritter/gflash.rb
|
51
62
|
- lib/gritter/helpers.rb
|
52
63
|
- lib/gritter/railtie.rb
|