direct_address 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -64,7 +64,7 @@ Either way produces the same exact thing. Take note that this does require loadi
64
64
 
65
65
  ...
66
66
  <% form... %>
67
- <%= f.country_select %>
67
+ <%= f.country_select(:include_labels => true) %> // include_labels adds a country and region label before each selector respectively
68
68
  <% end %>
69
69
  ...
70
70
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{direct_address}
8
- s.version = "0.0.8"
8
+ s.version = "0.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mike Nelson"]
12
- s.date = %q{2010-03-01}
12
+ s.date = %q{2010-03-03}
13
13
  s.description = %q{Direct Address provides a rails app with simple address features. This is a streamlined implementation of address functionality. Direct Address provides you with address, country, and region classes. It also provides a generator which generates the necessary javascript and rake tasks to implement properly. You'll also get form helpers to easily implement Direct Address in your views. A rake task is provided that allows up to date country and region information to be downloaded from geoname.org.}
14
14
  s.email = %q{mdnelson30@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -9,10 +9,13 @@ module ActionView
9
9
  end
10
10
 
11
11
  module InstanceMethods
12
- def country_select
12
+ def country_select(options = {})
13
13
  @countries ||= Country.all
14
14
  sanitized_object_id = self.object_name.split('[').collect{|s| (s = s.gsub(']','')) && s.size > 0 && s || nil}.compact.join('_')
15
- html = self.select(:country_id, ([['Select a Country', nil]] + @countries.collect{|country| [country.name, country.id]}))
15
+ html = ''
16
+ html << self.label(:country) if options[:include_labels]
17
+ html << self.select(:country_id, ([['Select a Country', nil]] + @countries.collect{|country| [country.name, country.id]}))
18
+ html << self.label(:region) if options[:include_labels]
16
19
  html << self.select(:region_id, ([['Select a Region', nil]] + (self.object && self.object.country && self.object.country.regions.collect{|region| [region.name, region.id]} || [])))
17
20
  html << "<script type=\"text/javascript\">if(typeof(Prototype) != 'undefined'){Element.observe(window, 'load', function(){if(typeof(CountrySelect) == 'undefined'){try{console.log('country_select.js not loaded.');} catch (e) {};return;};new CountrySelect({country_select_id : '#{sanitized_object_id}_country_id', region_select_id : '#{sanitized_object_id}_region_id'})});}else{document.getElementById('#{sanitized_object_id}_country_id').style.display = 'none';document.getElementById('#{sanitized_object_id}_region_id').style.display = 'none';}</script>"
18
21
  html
@@ -10,14 +10,17 @@ module ActionView
10
10
  end
11
11
 
12
12
  module InstanceMethods
13
- def country_select_tag(object_string, country_id = nil, region_id = nil)
13
+ def country_select_tag(object_string, country_id = nil, region_id = nil, options = {})
14
14
  object_string = object_string.to_s
15
15
  object_id = object_string.split('[').collect{|s| (s = s.gsub(']','')) && s.size > 0 && s || nil}.compact.join('_')
16
16
  @countries ||= Country.all
17
17
  @regions = !country_id.nil? && Region.by_country(country_id) || []
18
18
  country_options = options_for_select([['Select a Country', nil]] + @countries.collect{|country| [country.name, country.id]}, country_id)
19
19
  region_options = options_for_select([['Select a Region', nil]] + @regions.collect{|region| [region.name, region.id]}, region_id)
20
- html = select_tag("#{object_string}[country_id]", country_options, :id => "#{object_id}_country_id")
20
+ html = ''
21
+ html << label_tag("#{object_string}[country_id]", 'Country') if options[:include_labels]
22
+ html << select_tag("#{object_string}[country_id]", country_options, :id => "#{object_id}_country_id")
23
+ html << label_tag("#{object_string}[region_id]", 'Region') if options[:include_labels]
21
24
  html << select_tag("#{object_string}[region_id]", region_options, :id => "#{object_id}_region_id")
22
25
  html << "<script type=\"text/javascript\">if(typeof(Prototype) != 'undefined'){Element.observe(window, 'load', function(){if(typeof(CountrySelect) == 'undefined'){try{console.log('country_select.js not loaded.');} catch (e) {};return;};new CountrySelect({country_select_id : '#{object_id}_country_id', region_select_id : '#{object_id}_region_id'});});}else{document.getElementById('#{object_id}_country_id').style.display = 'none';document.getElementById('#{object_id}_region_id').style.display = 'none';}</script>"
23
26
  html
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: direct_address
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-01 00:00:00 -05:00
12
+ date: 2010-03-03 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency