message_block 1.0.1 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,37 @@
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
+ });
@@ -0,0 +1,44 @@
1
+ .message_block {
2
+ clear: both;
3
+ margin-top: 0.2em;
4
+ margin-bottom: 0.3em;
5
+ }
6
+
7
+ .message_block ul {
8
+ margin-bottom: 0;
9
+ list-style: none;
10
+ padding: 10px;
11
+ }
12
+ .message_block ul li {
13
+ margin-left: 3em;
14
+ }
15
+
16
+ .message_block ul.error {
17
+ border-top: 1px solid #ecd757;
18
+ border-bottom: 1px solid #ecd757;
19
+ background: #fcf6d0 url(../../images/message_block/error_m.gif) 1em 50% no-repeat;
20
+ }
21
+
22
+ .message_block ul.info {
23
+ border-top: 1px solid #ecd757;
24
+ border-bottom: 1px solid #ecd757;
25
+ background: #fcf6d0 url(../../images/message_block/info_m.gif) 1em 50% no-repeat;
26
+ }
27
+
28
+ .message_block ul.notice {
29
+ border-top: 1px solid #ecd757;
30
+ border-bottom: 1px solid #ecd757;
31
+ background: #fcf6d0 url(../../images/message_block/notice_m.gif) 1em 50% no-repeat;
32
+ }
33
+
34
+ .message_block ul.confirm {
35
+ border-top: 1px solid #ecd757;
36
+ border-bottom: 1px solid #ecd757;
37
+ background: #fcf6d0 url(../../images/message_block/confirmation_m.gif) 1em 50% no-repeat;
38
+ }
39
+
40
+ .message_block ul.warn {
41
+ border-top: 1px solid #ecd757;
42
+ border-bottom: 1px solid #ecd757;
43
+ background: #fcf6d0 url(../../images/message_block/warn_m.gif) 1em 50% no-repeat;
44
+ }
@@ -1,3 +1,3 @@
1
1
  module MessageBlock
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -0,0 +1,3 @@
1
+ require "message_block"
2
+
3
+ MessageBlock::Railtie.insert
@@ -121,4 +121,10 @@ describe MessageBlock::Helpers do
121
121
  output.should == %(<div class="message_block" id="message_block"><ul class="error"><li>Error A</li><li>Author name can't be empty</li></ul></div>)
122
122
  end
123
123
 
124
+ it "should be safe for html inside flash messages" do
125
+ flash[:error] = ["Error <strong>A</strong>", "Error <strong>B</strong>"]
126
+ output = message_block
127
+ output.should == %(<div class="message_block" id="message_block"><ul class="error"><li>Error <strong>A</strong></li><li>Error <strong>B</strong></li></ul></div>)
128
+ end
129
+
124
130
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: message_block
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Hughes
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-14 00:00:00 +08:00
18
+ date: 2010-10-27 00:00:00 +03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -113,6 +113,21 @@ files:
113
113
  - lib/tasks/message_block.rake
114
114
  - spec/message_block/helpers_spec.rb
115
115
  - spec/spec_helper.rb
116
+ - assets/images/back.gif
117
+ - assets/images/back_m.gif
118
+ - assets/images/confirmation.gif
119
+ - assets/images/confirmation_m.gif
120
+ - assets/images/error.gif
121
+ - assets/images/error_m.gif
122
+ - assets/images/info.gif
123
+ - assets/images/info_m.gif
124
+ - assets/images/notice.gif
125
+ - assets/images/notice_m.gif
126
+ - assets/images/warn.gif
127
+ - assets/images/warn_m.gif
128
+ - assets/javascripts/message_block.js
129
+ - assets/stylesheets/message_block.css
130
+ - rails/init.rb
116
131
  - CHANGELOG.rdoc
117
132
  - Gemfile
118
133
  - Gemfile.lock