message_block 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +46 -79
- data/README.rdoc +2 -56
- data/Rakefile +25 -0
- data/lib/message_block/helpers.rb +6 -4
- data/lib/message_block/version.rb +1 -1
- data/lib/tasks/message_block.rake +1 -10
- data/spec/message_block/helpers_spec.rb +7 -4
- metadata +52 -105
- data/assets/javascripts/message_block.js +0 -37
data/Gemfile.lock
CHANGED
@@ -1,94 +1,70 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
message_block (1.0.
|
4
|
+
message_block (1.0.4)
|
5
5
|
rails (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
10
|
abstract (1.0.0)
|
11
|
-
actionmailer (3.0.
|
12
|
-
actionpack (= 3.0.
|
13
|
-
mail (~> 2.2.
|
14
|
-
actionpack (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
11
|
+
actionmailer (3.0.3)
|
12
|
+
actionpack (= 3.0.3)
|
13
|
+
mail (~> 2.2.9)
|
14
|
+
actionpack (3.0.3)
|
15
|
+
activemodel (= 3.0.3)
|
16
|
+
activesupport (= 3.0.3)
|
17
17
|
builder (~> 2.1.2)
|
18
18
|
erubis (~> 2.6.6)
|
19
|
-
i18n (~> 0.4
|
19
|
+
i18n (~> 0.4)
|
20
20
|
rack (~> 1.2.1)
|
21
|
-
rack-mount (~> 0.6.
|
22
|
-
rack-test (~> 0.5.
|
21
|
+
rack-mount (~> 0.6.13)
|
22
|
+
rack-test (~> 0.5.6)
|
23
23
|
tzinfo (~> 0.3.23)
|
24
|
-
activemodel (3.0.
|
25
|
-
activesupport (= 3.0.
|
24
|
+
activemodel (3.0.3)
|
25
|
+
activesupport (= 3.0.3)
|
26
26
|
builder (~> 2.1.2)
|
27
|
-
i18n (~> 0.4
|
28
|
-
activerecord (3.0.
|
29
|
-
activemodel (= 3.0.
|
30
|
-
activesupport (= 3.0.
|
31
|
-
arel (~>
|
27
|
+
i18n (~> 0.4)
|
28
|
+
activerecord (3.0.3)
|
29
|
+
activemodel (= 3.0.3)
|
30
|
+
activesupport (= 3.0.3)
|
31
|
+
arel (~> 2.0.2)
|
32
32
|
tzinfo (~> 0.3.23)
|
33
|
-
activeresource (3.0.
|
34
|
-
activemodel (= 3.0.
|
35
|
-
activesupport (= 3.0.
|
36
|
-
activesupport (3.0.
|
37
|
-
arel (
|
38
|
-
activesupport (~> 3.0.0)
|
33
|
+
activeresource (3.0.3)
|
34
|
+
activemodel (= 3.0.3)
|
35
|
+
activesupport (= 3.0.3)
|
36
|
+
activesupport (3.0.3)
|
37
|
+
arel (2.0.10)
|
39
38
|
builder (2.1.2)
|
40
|
-
capybara (0.3.9)
|
41
|
-
culerity (>= 0.2.4)
|
42
|
-
mime-types (>= 1.16)
|
43
|
-
nokogiri (>= 1.3.3)
|
44
|
-
rack (>= 1.0.0)
|
45
|
-
rack-test (>= 0.5.4)
|
46
|
-
selenium-webdriver (>= 0.0.3)
|
47
|
-
childprocess (0.0.7)
|
48
|
-
ffi (~> 0.6.3)
|
49
|
-
cucumber (0.9.2)
|
50
|
-
builder (~> 2.1.2)
|
51
|
-
diff-lcs (~> 1.1.2)
|
52
|
-
gherkin (~> 2.2.5)
|
53
|
-
json (~> 1.4.6)
|
54
|
-
term-ansicolor (~> 1.0.5)
|
55
|
-
culerity (0.2.12)
|
56
39
|
diff-lcs (1.1.2)
|
57
40
|
erubis (2.6.6)
|
58
41
|
abstract (>= 1.0.0)
|
59
|
-
|
60
|
-
|
61
|
-
gherkin (2.2.8)
|
62
|
-
json (~> 1.4.6)
|
63
|
-
term-ansicolor (~> 1.0.5)
|
64
|
-
i18n (0.4.1)
|
65
|
-
json (1.4.6)
|
66
|
-
json_pure (1.4.6)
|
67
|
-
mail (2.2.7)
|
42
|
+
i18n (0.6.0)
|
43
|
+
mail (2.2.19)
|
68
44
|
activesupport (>= 2.3.6)
|
69
|
-
|
70
|
-
|
45
|
+
i18n (>= 0.4.0)
|
46
|
+
mime-types (~> 1.16)
|
47
|
+
treetop (~> 1.4.8)
|
71
48
|
mime-types (1.16)
|
72
|
-
|
73
|
-
polyglot (0.3.1)
|
49
|
+
polyglot (0.3.3)
|
74
50
|
rack (1.2.1)
|
75
|
-
rack-mount (0.6.
|
51
|
+
rack-mount (0.6.14)
|
76
52
|
rack (>= 1.0.0)
|
77
53
|
rack-test (0.5.6)
|
78
54
|
rack (>= 1.0)
|
79
|
-
rails (3.0.
|
80
|
-
actionmailer (= 3.0.
|
81
|
-
actionpack (= 3.0.
|
82
|
-
activerecord (= 3.0.
|
83
|
-
activeresource (= 3.0.
|
84
|
-
activesupport (= 3.0.
|
85
|
-
bundler (~> 1.0
|
86
|
-
railties (= 3.0.
|
87
|
-
railties (3.0.
|
88
|
-
actionpack (= 3.0.
|
89
|
-
activesupport (= 3.0.
|
90
|
-
rake (>= 0.8.
|
91
|
-
thor (~> 0.14.
|
55
|
+
rails (3.0.3)
|
56
|
+
actionmailer (= 3.0.3)
|
57
|
+
actionpack (= 3.0.3)
|
58
|
+
activerecord (= 3.0.3)
|
59
|
+
activeresource (= 3.0.3)
|
60
|
+
activesupport (= 3.0.3)
|
61
|
+
bundler (~> 1.0)
|
62
|
+
railties (= 3.0.3)
|
63
|
+
railties (3.0.3)
|
64
|
+
actionpack (= 3.0.3)
|
65
|
+
activesupport (= 3.0.3)
|
66
|
+
rake (>= 0.8.7)
|
67
|
+
thor (~> 0.14.4)
|
92
68
|
rake (0.8.7)
|
93
69
|
rspec (2.0.0)
|
94
70
|
rspec-core (= 2.0.0)
|
@@ -100,26 +76,17 @@ GEM
|
|
100
76
|
rspec-mocks (2.0.0)
|
101
77
|
rspec-core (= 2.0.0)
|
102
78
|
rspec-expectations (= 2.0.0)
|
103
|
-
rubyzip (0.9.4)
|
104
|
-
selenium-webdriver (0.0.29)
|
105
|
-
childprocess (>= 0.0.7)
|
106
|
-
ffi (~> 0.6.3)
|
107
|
-
json_pure
|
108
|
-
rubyzip
|
109
79
|
sqlite3-ruby (1.3.1)
|
110
|
-
|
111
|
-
|
112
|
-
|
80
|
+
thor (0.14.6)
|
81
|
+
treetop (1.4.10)
|
82
|
+
polyglot
|
113
83
|
polyglot (>= 0.3.1)
|
114
|
-
tzinfo (0.3.
|
84
|
+
tzinfo (0.3.33)
|
115
85
|
|
116
86
|
PLATFORMS
|
117
87
|
ruby
|
118
88
|
|
119
89
|
DEPENDENCIES
|
120
|
-
capybara (~> 0.3.9)
|
121
|
-
cucumber (~> 0.9.2)
|
122
90
|
message_block!
|
123
|
-
rails (>= 3.0.0)
|
124
91
|
rspec (~> 2.0)
|
125
92
|
sqlite3-ruby (~> 1.3.1)
|
data/README.rdoc
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
{<img src="https://secure.travis-ci.org/rubiety/message_block.png?branch=master" alt="Build Status" />}[http://travis-ci.org/rubiety/message_block]
|
2
|
+
|
1
3
|
== Message Block
|
2
4
|
|
3
5
|
Implements the common view pattern by which a list of messages are shown at the top,
|
@@ -76,59 +78,3 @@ given that both user and comment fail ActiveRecord validation:
|
|
76
78
|
</div>
|
77
79
|
|
78
80
|
Note that instead of manually specifying models you wish to report errors on, you can instead use the special <tt>:all</tt> value which will automatically use all view assign values that contain an ActiveModel::Errors "errors" method.
|
79
|
-
|
80
|
-
=== Ajax & JavaScript Integration
|
81
|
-
|
82
|
-
Sometimes you'll want to use the message block pattern within JavaScript. Wouldn't it be nice to just populate
|
83
|
-
the message_block DOM tree based on a JavaScript object not unlike Rails flash?
|
84
|
-
|
85
|
-
Included in the plugin is a Prototype JS implementation to make this easier. Note that this file is *not* automatically
|
86
|
-
copied when the plugin is installed. Currently this only works with prototype, but will be converted to jQuery before long:
|
87
|
-
|
88
|
-
assets/javascripts/message_block.js
|
89
|
-
|
90
|
-
Example Usage:
|
91
|
-
|
92
|
-
<div id="something">
|
93
|
-
<%= message_block :on => :job %>
|
94
|
-
</div>
|
95
|
-
|
96
|
-
<script type="text/javascript">
|
97
|
-
document.observe('dom:loaded', function() {
|
98
|
-
message_block = new MessageBlock('message_block'); // Default ID is message_block, being explicit
|
99
|
-
|
100
|
-
// Updates with two errors and one confirmation
|
101
|
-
message_block.update({
|
102
|
-
error: ['Error One', 'Error Two'],
|
103
|
-
confirm: ['Confirmation Message']
|
104
|
-
});
|
105
|
-
|
106
|
-
// Clears the message block
|
107
|
-
message_block.clear();
|
108
|
-
|
109
|
-
// Same as above...
|
110
|
-
message_block.update({});
|
111
|
-
});
|
112
|
-
</script>
|
113
|
-
|
114
|
-
This could be useful if you're interacting with stuff via Ajax, for example:
|
115
|
-
|
116
|
-
# In Controller
|
117
|
-
wants.json do
|
118
|
-
render :status => :unprocessable_entity, :json => { 'error' => @job.errors.full_messages }
|
119
|
-
end
|
120
|
-
|
121
|
-
# JavaScript Ajax
|
122
|
-
new Ajax.Request("/jobs", {
|
123
|
-
method: 'get',
|
124
|
-
|
125
|
-
onFailure: function(transport) {
|
126
|
-
this.message_block.update(transport.responseJSON);
|
127
|
-
},
|
128
|
-
|
129
|
-
onSuccess: function(transport) {
|
130
|
-
this.message_block.clear();
|
131
|
-
|
132
|
-
// Do something...
|
133
|
-
}
|
134
|
-
});
|
data/Rakefile
CHANGED
@@ -2,6 +2,29 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
|
5
|
+
require 'rubygems'
|
6
|
+
require 'bundler/setup'
|
7
|
+
|
8
|
+
require 'rake'
|
9
|
+
require 'rspec/core/rake_task'
|
10
|
+
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
desc 'Default: run unit tests.'
|
14
|
+
task :default => [:clean, :test]
|
15
|
+
|
16
|
+
desc "Run Specs"
|
17
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
18
|
+
end
|
19
|
+
|
20
|
+
task :test => :spec
|
21
|
+
|
22
|
+
desc "Clean up files."
|
23
|
+
task :clean do |t|
|
24
|
+
FileUtils.rm_rf "tmp"
|
25
|
+
Dir.glob("message_block-*.gem").each {|f| FileUtils.rm f }
|
26
|
+
end
|
27
|
+
|
5
28
|
desc "Generate documentation for the plugin."
|
6
29
|
Rake::RDocTask.new(:rdoc) do |rdoc|
|
7
30
|
rdoc.rdoc_dir = "rdoc"
|
@@ -12,3 +35,5 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
12
35
|
end
|
13
36
|
|
14
37
|
Dir["#{File.dirname(__FILE__)}/lib/tasks/*.rake"].sort.each { |ext| load ext }
|
38
|
+
|
39
|
+
|
@@ -43,10 +43,12 @@ module MessageBlock
|
|
43
43
|
"<ul class=\"#{type}\">" + flash_messages[type.to_sym].map {|message| "<li>#{message}</li>" }.join + "</ul>"
|
44
44
|
end.join
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
unless contents.blank?
|
47
|
+
if options[:container]
|
48
|
+
content_tag(options[:container], contents, options[:html], false)
|
49
|
+
else
|
50
|
+
contents
|
51
|
+
end
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -5,11 +5,9 @@ namespace :message_block do
|
|
5
5
|
|
6
6
|
images_source = File.join(File.dirname(__FILE__), "..", "..", "assets", "images")
|
7
7
|
stylesheets_source = File.join(File.dirname(__FILE__), "..", "..", "assets", "stylesheets", "message_block.css")
|
8
|
-
javascripts_source = File.join(File.dirname(__FILE__), "..", "..", "assets", "javascripts", "message_block.js")
|
9
8
|
|
10
9
|
images_target = Rails.root.join("public", "images", "message_block")
|
11
10
|
stylesheets_target = Rails.root.join("public", "stylesheets", "message_block.css")
|
12
|
-
javascripts_target = Rails.root.join("public", "javascripts", "message_block.js")
|
13
11
|
|
14
12
|
unless File.exists?(images_target)
|
15
13
|
FileUtils.cp_r(images_source, images_target)
|
@@ -25,12 +23,5 @@ namespace :message_block do
|
|
25
23
|
puts " Stylesheet appears to already be installed, not copying"
|
26
24
|
end
|
27
25
|
|
28
|
-
unless File.exists?(javascripts_target)
|
29
|
-
FileUtils.cp(javascripts_source, javascripts_target)
|
30
|
-
puts " Copied Javascript"
|
31
|
-
else
|
32
|
-
puts " Javascript appears to already be installed, not copying"
|
33
|
-
end
|
34
|
-
|
35
26
|
end
|
36
|
-
end
|
27
|
+
end
|
@@ -22,7 +22,7 @@ describe MessageBlock::Helpers do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should show nothing with no errors" do
|
25
|
-
message_block.should
|
25
|
+
message_block.should be_nil
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should automatically find post errors with posts controller" do
|
@@ -67,18 +67,21 @@ describe MessageBlock::Helpers do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should be able to specify id for containing div" do
|
70
|
+
@controller = posts_controller
|
70
71
|
output = message_block(:id => "messages")
|
71
|
-
output.should == %(<div class="message_block" id="messages"></div>)
|
72
|
+
output.should == %(<div class="message_block" id="messages"><ul class="error"><li>name can't be blank</li></ul></div>)
|
72
73
|
end
|
73
74
|
|
74
75
|
it "should be able to specify class for containing div" do
|
76
|
+
@controller = posts_controller
|
75
77
|
output = message_block(:class => "messages")
|
76
|
-
output.should == %(<div class="messages" id="message_block"></div>)
|
78
|
+
output.should == %(<div class="messages" id="message_block"><ul class="error"><li>name can't be blank</li></ul></div>)
|
77
79
|
end
|
78
80
|
|
79
81
|
it "should be able to specify html options for containing div" do
|
82
|
+
@controller = posts_controller
|
80
83
|
output = message_block(:html => {:id => "block", :class => "messages"})
|
81
|
-
output.should == %(<div class="messages" id="block"></div>)
|
84
|
+
output.should == %(<div class="messages" id="block"><ul class="error"><li>name can't be blank</li></ul></div>)
|
82
85
|
end
|
83
86
|
|
84
87
|
it "should be able to specify container option as false" do
|
metadata
CHANGED
@@ -1,111 +1,72 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: message_block
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 4
|
10
|
-
version: 1.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Ben Hughes
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-08-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: rails
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 7
|
30
|
-
segments:
|
31
|
-
- 3
|
32
|
-
- 0
|
33
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 3.0.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rspec
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
41
33
|
none: false
|
42
|
-
requirements:
|
34
|
+
requirements:
|
43
35
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 0
|
49
|
-
version: "2.0"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '2.0'
|
50
38
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: cucumber
|
54
39
|
prerelease: false
|
55
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
41
|
none: false
|
57
|
-
requirements:
|
42
|
+
requirements:
|
58
43
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
- 2
|
65
|
-
version: 0.9.2
|
66
|
-
type: :development
|
67
|
-
version_requirements: *id003
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: capybara
|
70
|
-
prerelease: false
|
71
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '2.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: sqlite3-ruby
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
72
49
|
none: false
|
73
|
-
requirements:
|
50
|
+
requirements:
|
74
51
|
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
78
|
-
- 0
|
79
|
-
- 3
|
80
|
-
- 9
|
81
|
-
version: 0.3.9
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.3.1
|
82
54
|
type: :development
|
83
|
-
version_requirements: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: sqlite3-ruby
|
86
55
|
prerelease: false
|
87
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
57
|
none: false
|
89
|
-
requirements:
|
58
|
+
requirements:
|
90
59
|
- - ~>
|
91
|
-
- !ruby/object:Gem::Version
|
92
|
-
hash: 25
|
93
|
-
segments:
|
94
|
-
- 1
|
95
|
-
- 3
|
96
|
-
- 1
|
60
|
+
- !ruby/object:Gem::Version
|
97
61
|
version: 1.3.1
|
98
|
-
|
99
|
-
|
100
|
-
|
62
|
+
description: Implements the common view pattern by which a list of messages are shown
|
63
|
+
at the top, often a combination of flash messages and ActiveRecord validation issues
|
64
|
+
on one or more models.
|
101
65
|
email: ben@railsgarden.com
|
102
66
|
executables: []
|
103
|
-
|
104
67
|
extensions: []
|
105
|
-
|
106
68
|
extra_rdoc_files: []
|
107
|
-
|
108
|
-
files:
|
69
|
+
files:
|
109
70
|
- lib/message_block/helpers.rb
|
110
71
|
- lib/message_block/railtie.rb
|
111
72
|
- lib/message_block/version.rb
|
@@ -119,7 +80,6 @@ files:
|
|
119
80
|
- assets/images/info.gif
|
120
81
|
- assets/images/notice.gif
|
121
82
|
- assets/images/warn.gif
|
122
|
-
- assets/javascripts/message_block.js
|
123
83
|
- assets/stylesheets/message_block.css
|
124
84
|
- rails/init.rb
|
125
85
|
- Gemfile
|
@@ -128,41 +88,28 @@ files:
|
|
128
88
|
- Rakefile
|
129
89
|
- README.rdoc
|
130
90
|
- init.rb
|
131
|
-
has_rdoc: true
|
132
91
|
homepage: http://github.com/rubiety/message_block
|
133
92
|
licenses: []
|
134
|
-
|
135
93
|
post_install_message:
|
136
94
|
rdoc_options: []
|
137
|
-
|
138
|
-
require_paths:
|
95
|
+
require_paths:
|
139
96
|
- lib
|
140
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
98
|
none: false
|
142
|
-
requirements:
|
143
|
-
- -
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
|
146
|
-
|
147
|
-
- 0
|
148
|
-
version: "0"
|
149
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
104
|
none: false
|
151
|
-
requirements:
|
152
|
-
- -
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
hash: 19
|
155
|
-
segments:
|
156
|
-
- 1
|
157
|
-
- 3
|
158
|
-
- 4
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
159
108
|
version: 1.3.4
|
160
109
|
requirements: []
|
161
|
-
|
162
110
|
rubyforge_project: message_block
|
163
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.22
|
164
112
|
signing_key:
|
165
113
|
specification_version: 3
|
166
114
|
summary: Flash message and error_messages_for handling with a common interface.
|
167
115
|
test_files: []
|
168
|
-
|
@@ -1,37 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Message Block JavaScript Interface
|
3
|
-
*
|
4
|
-
* Allows for updating a message block with JSON errors
|
5
|
-
**/
|
6
|
-
|
7
|
-
var MessageBlock = Class.create({
|
8
|
-
initialize: function(message_block) {
|
9
|
-
this.message_block = $(message_block ? message_block : "message_block");
|
10
|
-
},
|
11
|
-
|
12
|
-
clear: function() {
|
13
|
-
this.message_block.update("");
|
14
|
-
new Effect.Fade(this.message_block);
|
15
|
-
},
|
16
|
-
|
17
|
-
update: function(errors) {
|
18
|
-
if (!errors || Object.keys(errors).size() == 0) {
|
19
|
-
new Effect.Fade(this.message_block);
|
20
|
-
return;
|
21
|
-
}
|
22
|
-
|
23
|
-
this.message_block.update("");
|
24
|
-
|
25
|
-
for (error_type in errors) {
|
26
|
-
$(this.message_block).appendChild(
|
27
|
-
Builder.node('ul', { 'class': error_type },
|
28
|
-
$A(errors[error_type]).map(function(error) {
|
29
|
-
return Builder.node('li', error);
|
30
|
-
})
|
31
|
-
)
|
32
|
-
);
|
33
|
-
}
|
34
|
-
|
35
|
-
new Effect.Appear(this.message_block);
|
36
|
-
}
|
37
|
-
});
|