storefront 0.5.1 → 0.5.2
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/storefront.rb +1 -0
- data/lib/storefront/components/form.rb +2 -4
- data/lib/storefront/components/form/base.rb +40 -38
- data/lib/storefront/components/form/builder.rb +98 -96
- data/lib/storefront/components/form/errors.rb +22 -20
- data/lib/storefront/components/form/field.rb +75 -73
- data/lib/storefront/components/form/fieldset.rb +32 -30
- data/lib/storefront/components/form/hint.rb +23 -21
- data/lib/storefront/components/form/input.rb +143 -141
- data/lib/storefront/components/form/inputs.rb +4 -2
- data/lib/storefront/components/form/inputs/checkbox.rb +8 -6
- data/lib/storefront/components/form/inputs/date.rb +9 -7
- data/lib/storefront/components/form/inputs/file.rb +8 -6
- data/lib/storefront/components/form/inputs/hidden.rb +7 -5
- data/lib/storefront/components/form/inputs/radio.rb +6 -4
- data/lib/storefront/components/form/inputs/range.rb +8 -6
- data/lib/storefront/components/form/inputs/select.rb +52 -50
- data/lib/storefront/components/form/inputs/string.rb +64 -62
- data/lib/storefront/components/form/inputs/submit.rb +17 -15
- data/lib/storefront/components/form/inputs/textarea.rb +13 -11
- data/lib/storefront/components/form/inputs/value.rb +11 -9
- data/lib/storefront/components/form/label.rb +24 -22
- metadata +1 -1
@@ -1,19 +1,21 @@
|
|
1
1
|
module Storefront
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
module Components
|
3
|
+
class Form
|
4
|
+
# attributes: maxlength, placeholder, required, wrap, readonly
|
5
|
+
class Textarea < Input
|
6
|
+
resolves :text, :textarea, :watched
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
def initialize(options = {})
|
9
|
+
super
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
@value = attributes.delete(:value)
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
def textarea_input(options = {})
|
15
|
+
base_input :textarea, value, options
|
16
|
+
end
|
17
|
+
alias_method :text_input, :textarea_input
|
15
18
|
end
|
16
|
-
alias_method :text_input, :textarea_input
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module Storefront
|
2
|
-
|
3
|
-
class
|
4
|
-
|
2
|
+
module Components
|
3
|
+
class Form
|
4
|
+
class Value < Input
|
5
|
+
resolves :value
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
def initialize(options = {})
|
8
|
+
super
|
9
|
+
@value = attributes.delete(:value)
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
def value_input
|
13
|
+
base_input :output, value
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -1,31 +1,33 @@
|
|
1
1
|
module Storefront
|
2
|
-
|
3
|
-
class
|
4
|
-
|
5
|
-
|
2
|
+
module Components
|
3
|
+
class Form
|
4
|
+
class Label < Storefront::Components::Form::Base
|
5
|
+
def initialize(options = {})
|
6
|
+
super
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
attributes.merge!(options[:label_html]) if options[:label_html]
|
9
|
+
attributes.delete :label_html
|
10
|
+
attributes.delete :label
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
unless options[:label] == false
|
13
|
+
merge_class! attributes, config.label_class
|
14
|
+
attributes[:id] ||= attribute.to_id(:type => :error, :index => index, :parent_index => parent_index) if config.id_enabled_on.include?("label")
|
15
|
+
attributes[:for] ||= attribute.to_id(:type => :input, :index => index, :parent_index => parent_index) if config.id_enabled_on.include?("input")
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
@value = localize(:labels, attribute.name, options[:label].is_a?(::String) ? options[:label] : nil)
|
18
|
+
@value = attribute.to_label if @value.blank?
|
19
|
+
end
|
18
20
|
end
|
19
|
-
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
def render(&block)
|
23
|
+
template.capture_haml do
|
24
|
+
template.haml_tag :label, attributes do
|
25
|
+
template.haml_tag :span, value
|
26
|
+
if attribute.required?
|
27
|
+
template.haml_tag :abbr, config.required_abbr, :title => config.required_title, :class => config.required_class
|
28
|
+
else
|
29
|
+
template.haml_tag :abbr, config.optional_abbr, :title => config.optional_title, :class => config.optional_class
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|