webs 0.1.42 → 0.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/config/initializers/intl_select.rb +40 -0
- data/lib/webs.rb +1 -1
- data/webs.gemspec +1 -1
- metadata +5 -3
data/Rakefile
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
# adds the fw:intl tag to options values
|
2
|
+
module ActionView
|
3
|
+
module Helpers
|
4
|
+
class FormBuilder
|
5
|
+
def intl_select(method, choices, options = {}, html_options = {})
|
6
|
+
@template.intl_select(@object_name, method, choices, options.merge(:object => @object), html_options)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
module FormOptionsHelper
|
10
|
+
def intl_options_for_select(container, selected = nil)
|
11
|
+
container = container.to_a if Hash === container
|
12
|
+
|
13
|
+
options_for_select = container.inject([]) do |options, element|
|
14
|
+
text, value = option_text_and_value(element)
|
15
|
+
selected_attribute = ' selected="selected"' if option_value_selected?(value, selected)
|
16
|
+
options << %(<option value="#{html_escape(value.to_s)}"#{selected_attribute}><fw:intl>#{html_escape(text.to_s)}</fw:intl></option>)
|
17
|
+
end
|
18
|
+
|
19
|
+
options_for_select.join("\n")
|
20
|
+
end
|
21
|
+
def intl_select(object, method, choices, options = {}, html_options = {})
|
22
|
+
InstanceTag.new(object, method, self, nil, options.delete(:object)).to_intl_select_tag(choices, options, html_options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class InstanceTag #:nodoc:
|
27
|
+
include FormOptionsHelper
|
28
|
+
|
29
|
+
def to_intl_select_tag(choices, options, html_options)
|
30
|
+
html_options = html_options.stringify_keys
|
31
|
+
add_default_name_and_id(html_options)
|
32
|
+
value = value(object)
|
33
|
+
selected_value = options.has_key?(:selected) ? options[:selected] : value
|
34
|
+
content_tag("select", add_options(intl_options_for_select(choices, selected_value), options, selected_value), html_options)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
data/lib/webs.rb
CHANGED
data/webs.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 77
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 43
|
10
|
+
version: 0.1.43
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Chuck Olczak
|
@@ -34,6 +34,7 @@ extra_rdoc_files:
|
|
34
34
|
- lib/views/shared/_webs_info.html.erb
|
35
35
|
- lib/cache/cache.rb
|
36
36
|
- lib/config/initializers/http_accept_patch.rb
|
37
|
+
- lib/config/initializers/intl_select.rb
|
37
38
|
- lib/config/initializers/webs_view_path.rb
|
38
39
|
- lib/config/webs_constants.rb
|
39
40
|
- lib/config/webs_initializer.rb
|
@@ -58,6 +59,7 @@ files:
|
|
58
59
|
- lib/views/shared/_webs_info.html.erb
|
59
60
|
- lib/cache/cache.rb
|
60
61
|
- lib/config/initializers/http_accept_patch.rb
|
62
|
+
- lib/config/initializers/intl_select.rb
|
61
63
|
- lib/config/initializers/webs_view_path.rb
|
62
64
|
- lib/config/webs_constants.rb
|
63
65
|
- lib/config/webs_initializer.rb
|