helper_methods 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -24,6 +24,7 @@ Included helpers:
24
24
  flash_messages
25
25
  mobile_device?
26
26
  youtube('z8WXgoBGRb4')
27
+ youtube('z8WXgoBGRb4', 720, 480)
27
28
  youtube_link('z8WXgoBGRb4')
28
29
  icon('th-large icon-white')
29
30
  active_link_to 'some string', some_path
@@ -42,6 +43,10 @@ And it will become:
42
43
  allowfullscreen>
43
44
  </iframe>
44
45
 
46
+ You can pass width and height to.
47
+
48
+ youtube('z8WXgoBGRb4', 720, 480)
49
+
45
50
  If you want the complete link, use:
46
51
 
47
52
  youtube_link('z8WXgoBGRb4')
@@ -58,9 +63,11 @@ In your forms use:
58
63
 
59
64
  And it will return:
60
65
 
61
- <ul class="alert alert-error">
62
- <li>Error description</li>
63
- </ul>
66
+ <div class="alert alert-error">
67
+ <button type="button" class="close" data-dismiss="alert">×</button>
68
+ <p>Error description 1</p>
69
+ <p>Error description 2</p>
70
+ </div>
64
71
 
65
72
  Optionaly, you can pass a css class for ul element:
66
73
 
@@ -68,9 +75,11 @@ Optionaly, you can pass a css class for ul element:
68
75
 
69
76
  And it will return:
70
77
 
71
- <ul class="my_css_class">
72
- <li>Error description</li>
73
- </ul>
78
+ <div class="my_css_class">
79
+ <button type="button" class="close" data-dismiss="alert">×</button>
80
+ <p>Error description 1</p>
81
+ <p>Error description 2</p>
82
+ </div>
74
83
 
75
84
  ### View helpers
76
85
 
@@ -87,18 +96,20 @@ And in your controller, use:
87
96
 
88
97
  This will return
89
98
 
90
- <p class="alert alert-success">Your success message</p>
91
- <p class="alert alert-notice">Your alert message</p>
92
- <p class="alert alert-error">Your error message</p>
93
- <p class="alert alert-info">Your info message</p>
99
+ <p class="alert alert-success">Your success message is green</p>
100
+ <p class="alert alert-notice">Your alert message is yellow</p>
101
+ <p class="alert alert-error">Your error message is red</p>
102
+ <p class="alert alert-info">Your info message is blue</p>
94
103
 
95
104
  In your views, use
96
105
 
97
106
  icon('th-large icon-white')
107
+ icon('th-large icon-white', 'Some text')
98
108
 
99
109
  This will return
100
110
 
101
111
  <i class="th-large icon-white"></i>
112
+ <i class="th-large icon-white"></i> Some text
102
113
 
103
114
  Made for twitter-bootstrap.
104
115
 
@@ -1,3 +1,3 @@
1
1
  module HelperMethods
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -1,33 +1,42 @@
1
+ # encoding: UTF-8
2
+
1
3
  require "helper_methods/version"
2
4
 
3
5
  module HelperMethods
4
6
 
5
7
  def error_messages_for(resource, css_class = "alert alert-error")
6
8
  if resource.errors.any?
7
- error_list = resource.errors.collect do |key, value|
8
- content = %(<a class="close" data-dismiss="alert" href="#">&times;</a>)
9
- content += value
10
- content_tag :div, content.html_safe, class: css_class, data: { dismiss: "alert" }
9
+ content = %(<button type="button" class="close" data-dismiss="alert">×</button>)
10
+ content += %(<ul>)
11
+ resource.errors.collect do |key, value|
12
+ content += content_tag :li, value
11
13
  end.join
12
-
13
- error_list.html_safe
14
+ content += %(</ul>)
15
+ content_tag :div, content.html_safe, class: css_class
14
16
  end
15
17
  end
16
18
 
17
19
  def flash_messages
18
- flash.collect do |key, value|
19
- close_icon = %(<a class="close" data-dismiss="alert" href="#">&times;</a>).html_safe
20
- content = close_icon + value
21
- content_tag(:p, content, :class => "alert alert-#{key}", :data => { :dismiss => "alert"} ) unless [true, false, nil].include? value
22
- end.join.html_safe
20
+ if flash.any?
21
+ content = %(<button type="button" class="close" data-dismiss="alert">×</button>)
22
+
23
+ flash.collect do |key, value|
24
+ unless [true, false, nil].include?(value)
25
+ key = :success if key == :notice
26
+ content += value
27
+ content_tag(:div, content.html_safe, class: "alert alert-#{key}")
28
+ end
29
+ end.join.html_safe
30
+ #content_tag :div, content.html_safe
31
+ end
23
32
  end
24
33
 
25
34
  def mobile_device?
26
35
  request.user_agent =~ /Mobile|webOS/
27
36
  end
28
37
 
29
- def youtube(video)
30
- "<iframe width='580' height='420' src='http://www.youtube.com/embed/#{video}' frameborder='0' allowfullscreen></iframe>".html_safe
38
+ def youtube(video, width = 580, height = 420)
39
+ "<iframe width='#{width}' height='#{height}' src='http://www.youtube.com/embed/#{video}' frameborder='0' allowfullscreen></iframe>".html_safe
31
40
  end
32
41
 
33
42
  def youtube_link(video)
@@ -39,21 +48,6 @@ module HelperMethods
39
48
  return "#{text} <i class='icon-#{icon}'></i>".html_safe if direction == 'r'
40
49
  end
41
50
 
42
- def nav_link_to(text, path, css_class=nil, li_properties = {}, a_properties = {})
43
- lp = li_properties.collect do |k, v|
44
- %( #{k}="#{v}") unless k == :class
45
- end.join
46
-
47
- ap = a_properties.collect do |k, v|
48
- %( #{k}="#{v}") unless k == :class
49
- end.join
50
-
51
- tag_class = %( class="#{css_class unless css_class.nil? }#{' ' if current_page? path and !css_class.nil?}#{'active' if current_page? path}") if current_page? path or !css_class.nil?
52
-
53
- %(<li#{tag_class}#{lp}>#{link_to text, path, a_properties}</li>).html_safe
54
- end
55
-
56
-
57
51
  def active_link_to(*args, &block)
58
52
  if block_given?
59
53
  name = capture(&block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helper_methods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-26 00:00:00.000000000 Z
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: There are a small collection of simple methods
15
15
  email: