neorails-view_fu 0.9.3 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module ViewFu
2
2
  module TagHelper
3
-
3
+
4
4
  # Writes a br tag
5
5
  def br
6
6
  "<br />"
@@ -22,8 +22,10 @@ module ViewFu
22
22
  end
23
23
 
24
24
  # Writes an anchor tag
25
- def anchor(anchor_name)
26
- "<a name='#{anchor_name}'></a>"
25
+ def anchor(anchor_name, options = {})
26
+ content_tag(:a, {:name => anchor_name}.reverse_merge(options)) do
27
+ ""
28
+ end
27
29
  end
28
30
 
29
31
  # Writes a clear tag
@@ -69,7 +71,18 @@ module ViewFu
69
71
  link_to(image_tag(image_path, :class => "vert-middle", :style => "#{vert_style}"), url, options)+"&nbsp;"+
70
72
  link_to(label, url, options)
71
73
  end
74
+
75
+ def add_class_if(css_class, condition)
76
+ if condition
77
+ {:class => css_class}
78
+ else
79
+ {}
80
+ end
81
+ end
72
82
 
83
+ def add_class_unless(css_class, condition)
84
+ add_class_if(css_class, !condition)
85
+ end
73
86
 
74
87
  # Return a hidden attribute hash if a condition evaluates to true
75
88
  def hide_if(condition)
@@ -130,7 +143,7 @@ module ViewFu
130
143
 
131
144
  # Display will_paginate paging links
132
145
  def paging(page_data, style = :sabros)
133
- return unless page_data.class == WillPaginate::Collection
146
+ return unless page_data.is_a? WillPaginate::Collection
134
147
  will_paginate(page_data, :class => "pagination #{style}", :inner_window => 3)
135
148
  end
136
149
 
@@ -143,5 +156,11 @@ module ViewFu
143
156
  def pixel(options = {})
144
157
  image_tag "pixel.png", options
145
158
  end
159
+
160
+ # check to see if an index is the first item in a collection
161
+ def is_first(i)
162
+ i.to_i.zero? ? {:class => "first"} : {}
163
+ end
164
+
146
165
  end
147
166
  end
data/view_fu.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'view_fu'
3
- s.version = '0.9.3'
4
- s.date = '2008-08-10'
3
+ s.version = '0.9.5'
4
+ s.date = '2008-11-15'
5
5
 
6
6
  s.summary = "Lots of handy Rails View helpers. Includes the functionality of Headliner, Styler, and Javascripter"
7
7
  s.description = "ViewFu is a Rails plugin that provides all the miscellaneous View tasks. It's a combination of the functionality of Styler, Javascripter, and Headline (from Patrick Crowley, the.railsi.st) - along with additional tweaks such as providing commonly used View Helpers Methods."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neorails-view_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Crocker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-10 00:00:00 -07:00
12
+ date: 2008-11-15 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency