gritter 0.6.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +80 -81
- data/app/assets/images/gritter-close.png +0 -0
- data/app/assets/images/gritter.png +0 -0
- data/app/assets/images/ie-spacer.gif +0 -0
- data/app/assets/javascripts/gritter.js +475 -19
- data/app/assets/stylesheets/gritter.css.scss +119 -0
- data/lib/generators/gritter/USAGE +7 -0
- data/lib/generators/gritter/locale_generator.rb +9 -0
- data/lib/{gritter/assets → generators/gritter/templates}/gflash.en.yml +1 -1
- data/lib/gritter.rb +0 -42
- data/lib/gritter/gflash.rb +32 -10
- data/lib/gritter/helpers.rb +6 -18
- data/lib/gritter/railtie.rb +0 -4
- data/lib/gritter/version.rb +1 -1
- metadata +11 -20
- data/app/assets/images/gritter-close-ie6.gif +0 -0
- data/app/assets/images/gritter-long.png +0 -0
- data/app/assets/stylesheets/gritter.css.erb +0 -94
- data/lib/gritter/assets/images/error.png +0 -0
- data/lib/gritter/assets/images/gritter-close-ie6.gif +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/javascripts/jquery.gritter.min.js +0 -19
- data/lib/gritter/assets/stylesheets/jquery.gritter.css +0 -94
- data/lib/tasks/gritter.rake +0 -6
@@ -0,0 +1,119 @@
|
|
1
|
+
#gritter-notice-wrapper {
|
2
|
+
position:fixed;
|
3
|
+
top:20px;
|
4
|
+
right:20px;
|
5
|
+
width:301px;
|
6
|
+
z-index:9999;
|
7
|
+
|
8
|
+
&.top-left {
|
9
|
+
left: 20px;
|
10
|
+
right: auto;
|
11
|
+
}
|
12
|
+
|
13
|
+
&.bottom-right {
|
14
|
+
top: auto;
|
15
|
+
left: auto;
|
16
|
+
bottom: 20px;
|
17
|
+
right: 20px;
|
18
|
+
}
|
19
|
+
|
20
|
+
&.bottom-left {
|
21
|
+
top: auto;
|
22
|
+
right: auto;
|
23
|
+
bottom: 20px;
|
24
|
+
left: 20px;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
.gritter-item-wrapper {
|
29
|
+
position:relative;
|
30
|
+
margin:0 0 10px 0;
|
31
|
+
background:url(image_path('ie-spacer.gif')); // ie7/8 fix
|
32
|
+
}
|
33
|
+
|
34
|
+
.gritter-top {
|
35
|
+
background:url(image_path('gritter.png')) no-repeat left -30px;
|
36
|
+
height:10px;
|
37
|
+
}
|
38
|
+
.hover .gritter-top {
|
39
|
+
background-position:right -30px;
|
40
|
+
}
|
41
|
+
.gritter-bottom {
|
42
|
+
background:url(image_path('gritter.png')) no-repeat left bottom;
|
43
|
+
height:8px;
|
44
|
+
margin:0;
|
45
|
+
}
|
46
|
+
.hover .gritter-bottom {
|
47
|
+
background-position: bottom right;
|
48
|
+
}
|
49
|
+
|
50
|
+
.gritter-item {
|
51
|
+
display:block;
|
52
|
+
color:#eee;
|
53
|
+
padding:2px 11px 8px 11px;
|
54
|
+
font-size: 11px;
|
55
|
+
font-family:verdana;
|
56
|
+
filter:inherit; // ie8 fix
|
57
|
+
|
58
|
+
&.gritter-css2 {
|
59
|
+
background:url(image_path('gritter.png')) no-repeat left -40px;
|
60
|
+
}
|
61
|
+
&.gritter-css3 {
|
62
|
+
background:rgba(0, 0, 0, 0.8);
|
63
|
+
-webkit-border-radius: 10px;
|
64
|
+
-moz-border-radius: 10px;
|
65
|
+
border-radius: 10px;
|
66
|
+
padding-top: 12px;
|
67
|
+
padding-bottom: 16px;
|
68
|
+
}
|
69
|
+
|
70
|
+
p {
|
71
|
+
padding:0;
|
72
|
+
margin:0;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
.hover .gritter-item.gritter-css2 {
|
76
|
+
background-position:right -40px;
|
77
|
+
}
|
78
|
+
.hover .gritter-item.gritter-css3 {
|
79
|
+
padding:10px 9px 14px 9px;
|
80
|
+
border: solid 2px #fff;
|
81
|
+
}
|
82
|
+
|
83
|
+
.gritter-close {
|
84
|
+
display:none;
|
85
|
+
position:absolute;
|
86
|
+
top:5px;
|
87
|
+
left:3px;
|
88
|
+
cursor:pointer;
|
89
|
+
width:30px;
|
90
|
+
height:30px;
|
91
|
+
filter:inherit; // ie8 fix
|
92
|
+
}
|
93
|
+
.gritter-css2 .gritter-close {
|
94
|
+
background:url(image_path('gritter.png')) no-repeat left top;
|
95
|
+
}
|
96
|
+
.gritter-css3 .gritter-close {
|
97
|
+
background:url(image_path('gritter-close.png')) no-repeat;
|
98
|
+
}
|
99
|
+
|
100
|
+
.gritter-title {
|
101
|
+
font-size:14px;
|
102
|
+
font-weight:bold;
|
103
|
+
padding:0 0 7px 0;
|
104
|
+
display:block;
|
105
|
+
text-shadow:1px 1px #000; /* Not supported by IE :( */
|
106
|
+
}
|
107
|
+
.gritter-image {
|
108
|
+
width:48px;
|
109
|
+
height:48px;
|
110
|
+
float:left;
|
111
|
+
}
|
112
|
+
.gritter-with-image,
|
113
|
+
.gritter-without-image {
|
114
|
+
padding:0 0 5px 0;
|
115
|
+
}
|
116
|
+
.gritter-with-image {
|
117
|
+
width:220px;
|
118
|
+
float:right;
|
119
|
+
}
|
data/lib/gritter.rb
CHANGED
@@ -9,50 +9,8 @@ module Gritter
|
|
9
9
|
raise "ActionController is not available yet." unless defined?(ActionController)
|
10
10
|
ActionController::Base.send(:helper, Gritter::Helpers)
|
11
11
|
ActionController::Base.send(:include, Gritter::Gflash)
|
12
|
-
Gritter.install_locales
|
13
|
-
Gritter.install_gritter if ::Rails.version < "3.1"
|
14
12
|
@initialized = true
|
15
13
|
end
|
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
|
-
|
26
|
-
def self.install_gritter
|
27
|
-
orig_javascripts = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'javascripts')
|
28
|
-
orig_stylesheets = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'stylesheets')
|
29
|
-
orig_images = File.join(File.dirname(__FILE__), 'gritter', 'assets', 'images')
|
30
|
-
dest_javascripts = File.join(Rails.root, 'public', 'javascripts', 'gritter')
|
31
|
-
dest_stylesheets = File.join(Rails.root, 'public', 'stylesheets', 'gritter')
|
32
|
-
dest_images = File.join(Rails.root, 'public', 'images', 'gritter')
|
33
|
-
|
34
|
-
gritter = File.join(dest_javascripts, 'jquery.gritter.min.js')
|
35
|
-
|
36
|
-
unless File.exists?(gritter) && FileUtils.identical?(File.join(orig_javascripts, 'jquery.gritter.min.js'), gritter)
|
37
|
-
begin
|
38
|
-
puts "Creating directory #{dest_javascripts}..."
|
39
|
-
FileUtils.mkdir_p dest_javascripts
|
40
|
-
puts "Creating directory #{dest_stylesheets}..."
|
41
|
-
FileUtils.mkdir_p dest_stylesheets
|
42
|
-
puts "Creating directory #{dest_images}..."
|
43
|
-
FileUtils.mkdir_p dest_images
|
44
|
-
puts "Copying gritter to #{dest_javascripts}..."
|
45
|
-
FileUtils.cp_r "#{orig_javascripts}/.", dest_javascripts
|
46
|
-
puts "Copying gritter to #{dest_stylesheets}..."
|
47
|
-
FileUtils.cp_r "#{orig_stylesheets}/.", dest_stylesheets
|
48
|
-
puts "Copying gritter to #{dest_images}..."
|
49
|
-
FileUtils.cp_r "#{orig_images}/.", dest_images
|
50
|
-
puts "Successfully installed gritter."
|
51
|
-
rescue
|
52
|
-
puts "ERROR: Problem installing gritter. Please copy the files manually."
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
14
|
end
|
57
15
|
|
58
16
|
if defined?(Rails::Railtie)
|
data/lib/gritter/gflash.rb
CHANGED
@@ -1,28 +1,50 @@
|
|
1
1
|
module Gritter
|
2
2
|
module Gflash
|
3
|
+
def redirect_to(options = {}, response_status_and_flash = {})
|
4
|
+
if response_status_and_flash.has_key?(:gflash)
|
5
|
+
gflash(response_status_and_flash[:gflash])
|
6
|
+
response_status_and_flash.delete(:gflash)
|
7
|
+
end
|
8
|
+
super(options, response_status_and_flash)
|
9
|
+
end
|
10
|
+
|
3
11
|
def gflash *args
|
4
12
|
session[:gflash] ||= {}
|
5
13
|
options = args.extract_options!
|
14
|
+
|
15
|
+
if args.present?
|
16
|
+
args.each do |key|
|
17
|
+
gflash_push(key, gflash_translation(key))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
6
21
|
options.each do |key, value|
|
7
22
|
if value.is_a?(Hash)
|
8
|
-
|
9
|
-
|
23
|
+
if value.has_key?(:value)
|
24
|
+
value[:value] = gflash_text(key, value[:value])
|
25
|
+
else
|
26
|
+
value[:value] = gflash_translation(key)
|
27
|
+
end
|
10
28
|
else
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
if session[:gflash].has_key?(key)
|
15
|
-
session[:gflash][key].push(gflash_value)
|
16
|
-
else
|
17
|
-
session[:gflash][key] = [gflash_value]
|
29
|
+
value = gflash_text(key, value)
|
18
30
|
end
|
31
|
+
gflash_push(key, value)
|
19
32
|
end
|
20
33
|
end
|
21
34
|
|
22
35
|
private
|
23
36
|
|
24
37
|
def gflash_text(key, value)
|
25
|
-
value == true ?
|
38
|
+
value == true ? gflash_translation(key) : value
|
39
|
+
end
|
40
|
+
|
41
|
+
def gflash_push(key, value)
|
42
|
+
session[:gflash][key] ||= []
|
43
|
+
session[:gflash][key].push(value)
|
44
|
+
end
|
45
|
+
|
46
|
+
def gflash_translation(key)
|
47
|
+
I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}")
|
26
48
|
end
|
27
49
|
end
|
28
50
|
end
|
data/lib/gritter/helpers.rb
CHANGED
@@ -1,22 +1,11 @@
|
|
1
1
|
module Gritter
|
2
2
|
module Helpers
|
3
|
-
def include_gritter *args
|
4
|
-
options = args.extract_options!
|
5
|
-
includes = [stylesheet_link_tag("gritter/jquery.gritter.css"), javascript_include_tag("gritter/jquery.gritter.min.js")]
|
6
|
-
includes.push(js(extend_gritter(options))) if options.present?
|
7
|
-
includes.join("\n").html_safe
|
8
|
-
end
|
9
|
-
|
10
|
-
def include_gritter_and_jquery *args
|
11
|
-
includes = [javascript_include_tag("http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"), include_gritter(*args)]
|
12
|
-
includes.join("\n").html_safe
|
13
|
-
end
|
14
|
-
|
15
3
|
def add_gritter text, *args
|
16
4
|
options = args.extract_options!
|
17
5
|
options[:title] = "Notification" if options[:title].blank?
|
18
6
|
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
|
-
notification = ["jQuery
|
7
|
+
notification = ["jQuery(function(){"]
|
8
|
+
notification.push("jQuery.gritter.add({")
|
20
9
|
notification.push("image:'#{options[:image]}',") if options[:image].present?
|
21
10
|
notification.push("sticky:#{options[:sticky]},") if options[:sticky].present?
|
22
11
|
notification.push("time:#{options[:time]},") if options[:time].present?
|
@@ -28,6 +17,7 @@ module Gritter
|
|
28
17
|
notification.push("title:'#{escape_javascript(options[:title])}',")
|
29
18
|
notification.push("text:'#{escape_javascript(text)}'")
|
30
19
|
notification.push("});")
|
20
|
+
notification.push("});")
|
31
21
|
text.present? ? notification.join.html_safe : nil
|
32
22
|
end
|
33
23
|
|
@@ -44,10 +34,12 @@ module Gritter
|
|
44
34
|
options = args.extract_options!
|
45
35
|
options[:fade_in_speed] = "'#{options[:fade_in_speed]}'" if options[:fade_in_speed].is_a?(String)
|
46
36
|
options[:fade_out_speed] = "'#{options[:fade_out_speed]}'" if options[:fade_out_speed].is_a?(String)
|
37
|
+
options[:position] = "'#{options[:position].to_s.gsub("_", "-")}'" if options[:position]
|
47
38
|
extended = ["jQuery.extend($.gritter.options,{"]
|
48
39
|
extended.push("fade_in_speed:#{options[:fade_in_speed]},") if options[:fade_in_speed].present?
|
49
40
|
extended.push("fade_out_speed:#{options[:fade_out_speed]},") if options[:fade_out_speed].present?
|
50
|
-
extended.push("time:#{options[:time]}") if options[:time].present?
|
41
|
+
extended.push("time:#{options[:time]},") if options[:time].present?
|
42
|
+
extended.push("position:#{options[:position]}") if options[:position].present?
|
51
43
|
extended.push("});")
|
52
44
|
extended.join.html_safe
|
53
45
|
end
|
@@ -81,10 +73,6 @@ module Gritter
|
|
81
73
|
|
82
74
|
private
|
83
75
|
|
84
|
-
def gflash_text(value)
|
85
|
-
value == true ? I18n.t("gflash.#{params[:controller]}.#{params[:action]}.#{key}") : value
|
86
|
-
end
|
87
|
-
|
88
76
|
def gflash_titles *args
|
89
77
|
options = args.extract_options!
|
90
78
|
titles = { :success => get_translation(:success), :warning => get_translation(:warning), :error => get_translation(:error), :notice => get_translation(:notice), :progress => get_translation(:progress) }
|
data/lib/gritter/railtie.rb
CHANGED
data/lib/gritter/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gritter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 0.6.3
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Robin Brouwer
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-11-
|
19
|
+
date: 2011-11-17 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -35,35 +35,26 @@ files:
|
|
35
35
|
- README.md
|
36
36
|
- Rakefile
|
37
37
|
- app/assets/images/error.png
|
38
|
-
- app/assets/images/gritter-close
|
39
|
-
- app/assets/images/gritter-long.png
|
38
|
+
- app/assets/images/gritter-close.png
|
40
39
|
- app/assets/images/gritter.png
|
40
|
+
- app/assets/images/ie-spacer.gif
|
41
41
|
- app/assets/images/notice.png
|
42
42
|
- app/assets/images/progress.gif
|
43
43
|
- app/assets/images/success.png
|
44
44
|
- app/assets/images/warning.png
|
45
45
|
- app/assets/javascripts/gritter.js
|
46
|
-
- app/assets/stylesheets/gritter.css.
|
46
|
+
- app/assets/stylesheets/gritter.css.scss
|
47
47
|
- gritter.gemspec
|
48
48
|
- init.rb
|
49
|
+
- lib/generators/gritter/USAGE
|
50
|
+
- lib/generators/gritter/locale_generator.rb
|
51
|
+
- lib/generators/gritter/templates/gflash.en.yml
|
49
52
|
- lib/gritter.rb
|
50
|
-
- lib/gritter/assets/gflash.en.yml
|
51
|
-
- lib/gritter/assets/images/error.png
|
52
|
-
- lib/gritter/assets/images/gritter-close-ie6.gif
|
53
|
-
- lib/gritter/assets/images/gritter-long.png
|
54
|
-
- lib/gritter/assets/images/gritter.png
|
55
|
-
- lib/gritter/assets/images/notice.png
|
56
|
-
- lib/gritter/assets/images/progress.gif
|
57
|
-
- lib/gritter/assets/images/success.png
|
58
|
-
- lib/gritter/assets/images/warning.png
|
59
|
-
- lib/gritter/assets/javascripts/jquery.gritter.min.js
|
60
|
-
- lib/gritter/assets/stylesheets/jquery.gritter.css
|
61
53
|
- lib/gritter/engine.rb
|
62
54
|
- lib/gritter/gflash.rb
|
63
55
|
- lib/gritter/helpers.rb
|
64
56
|
- lib/gritter/railtie.rb
|
65
57
|
- lib/gritter/version.rb
|
66
|
-
- lib/tasks/gritter.rake
|
67
58
|
has_rdoc: true
|
68
59
|
homepage: http://www.45north.nl
|
69
60
|
licenses: []
|
Binary file
|
Binary file
|
@@ -1,94 +0,0 @@
|
|
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
|
-
}
|