caisson 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/README.md +13 -1
  2. data/app/assets/javascripts/caisson/base.coffee +4 -0
  3. data/app/assets/javascripts/caisson/form/fields/base.coffee +115 -0
  4. data/app/assets/javascripts/caisson/form/fields/checkbox.coffee +13 -0
  5. data/app/assets/javascripts/caisson/form/fields/select.coffee +14 -0
  6. data/app/assets/javascripts/caisson/form/fields/text_field.coffee +22 -0
  7. data/app/assets/javascripts/caisson/form/fields/validator.coffee +116 -0
  8. data/app/assets/javascripts/caisson/form/form.coffee +119 -0
  9. data/app/assets/javascripts/caisson/form/form_caisson.coffee +30 -0
  10. data/app/assets/javascripts/caisson/index.js +2 -0
  11. data/app/assets/javascripts/caisson/module.coffee +8 -0
  12. data/app/assets/javascripts/caisson/orbit-slider.coffee +2 -1
  13. data/app/assets/stylesheets/caisson/base.css.scss +7 -0
  14. data/app/assets/stylesheets/caisson/index.css +3 -0
  15. data/lib/caisson/helpers/form/base.rb +195 -0
  16. data/lib/caisson/helpers/form/builder/base.rb +72 -0
  17. data/lib/caisson/helpers/form/builder/field/base.rb +168 -0
  18. data/lib/caisson/helpers/form/builder/field/checkbox.rb +15 -0
  19. data/lib/caisson/helpers/form/builder/field/money.rb +13 -0
  20. data/lib/caisson/helpers/form/builder/field/password.rb +13 -0
  21. data/lib/caisson/helpers/form/builder/field/percent.rb +13 -0
  22. data/lib/caisson/helpers/form/builder/field/select.rb +41 -0
  23. data/lib/caisson/helpers/form/builder/field/text.rb +13 -0
  24. data/lib/caisson/helpers/form/builder/field/textarea.rb +13 -0
  25. data/lib/caisson/helpers/form/builder/field_builder/base.rb +81 -0
  26. data/lib/caisson/helpers/form/builder/field_builder/nature.rb +85 -0
  27. data/lib/caisson/helpers/form/builder/interpreti.rb +107 -0
  28. data/lib/caisson/helpers/form/button.rb +62 -0
  29. data/lib/caisson/helpers/form/field/base.rb +43 -0
  30. data/lib/caisson/helpers/form/field/checkbox.rb +39 -0
  31. data/lib/caisson/helpers/form/field/money.rb +29 -0
  32. data/lib/caisson/helpers/form/field/password.rb +14 -0
  33. data/lib/caisson/helpers/form/field/percent.rb +23 -0
  34. data/lib/caisson/helpers/form/field/select.rb +34 -0
  35. data/lib/caisson/helpers/form/field/text.rb +17 -0
  36. data/lib/caisson/helpers/form/field/textarea.rb +16 -0
  37. data/lib/caisson/helpers/form.rb +30 -0
  38. data/lib/caisson/helpers/grid.rb +32 -0
  39. data/lib/caisson/helpers/orbit_slider.rb +16 -21
  40. data/lib/caisson/helpers.rb +26 -0
  41. data/lib/caisson/implants/mongoid.rb +67 -0
  42. data/lib/caisson/implants/railtie.rb +4 -0
  43. metadata +41 -6
@@ -0,0 +1,85 @@
1
+ #*************************************************************************************
2
+ # TOCOMMENT
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Builder::FieldBuilder
5
+ class Nature
6
+ #*************************************************************************************
7
+ # CONSTRUCTOR
8
+ #*************************************************************************************
9
+ def initialize(record, name)
10
+ @record = record
11
+ @name = name.to_s
12
+ end
13
+
14
+
15
+ #*************************************************************************************
16
+ # PUBLIC CLASS METHODS
17
+ #*************************************************************************************
18
+ def self.all
19
+ ['checkbox', 'password', 'percent', 'select', 'text', 'textarea']
20
+ #TODO
21
+ #'autocomplete', 'check-icon', 'country', 'file', 'money', 'static', 'switch', 'radio', 'upload', 'ticklist', 'time_field'
22
+ end
23
+
24
+
25
+ #*************************************************************************************
26
+ # PUBLIC INSTANCE METHODS
27
+ #*************************************************************************************
28
+ def get(options={})
29
+ options.reverse_merge!(force: nil)
30
+
31
+ if options[:force]
32
+ return force(options[:force])
33
+ elsif @record.fields[@name]
34
+ return case @record.fields[@name].options[:type].to_s.downcase
35
+ when 'array' then 'ticklist'
36
+ when 'boolean' then 'checkbox'
37
+ when 'percent' then 'percent'
38
+ when 'time' then 'time_field'
39
+ else nature_by_name
40
+ end
41
+ else
42
+ return nature_by_name
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ #*************************************************************************************
49
+ # PRIVATE INSTANCE METHODS
50
+ #*************************************************************************************
51
+ def field_has_options?(field_name)
52
+ model_obj = @record.class
53
+ if model_obj.respond_to?(:options_for)
54
+ return (not model_obj.options_for(field_name).empty?)
55
+ else
56
+ return false
57
+ end
58
+ end
59
+
60
+ def field_is_one_to_many?(field_name)
61
+ not @record.relations.select{ |k,v| v.key == field_name.to_s and v.macro == :referenced_in }.empty?
62
+ end
63
+
64
+ def field_is_select?(field_name)
65
+ field_has_options?(field_name) or field_is_one_to_many?(field_name)
66
+ end
67
+
68
+ def force(nature)
69
+ if Caisson::Helpers::Form::Builder::FieldBuilder::Nature.all.include?(nature)
70
+ return nature
71
+ else
72
+ raise "Caisson doesn't accept the field nature '#{nature}' for the field '#{@name}'. Accepted : #{Caisson::Helpers::Form::Builder::FieldBuilder::Nature.all}"
73
+ end
74
+ end
75
+
76
+ def nature_by_name
77
+ case
78
+ when @name.include?('country') then 'country'
79
+ when @name.include?('password') then 'password'
80
+ when field_is_select?(@name) then 'select'
81
+ else 'text'
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,107 @@
1
+ module Caisson::Helpers::Form::Builder
2
+ class Interpreti
3
+
4
+ def initialize(record)
5
+ @record = record
6
+ end
7
+
8
+ def field_choices(name, options={})
9
+ options.reverse_merge!(base_choices: nil, include_blank: false)
10
+
11
+ if options[:base_choices] and options[:base_choices][0].is_a? Array
12
+ choices = options[:base_choices]
13
+ elsif options[:base_choices] or model_obj.respond_to? :options_for
14
+ base_choices = [options[:base_choices] || model_obj.options_for(name.to_s)].compact.flatten
15
+ choices = base_choices.map { |k| [field_option(name, k), k] }
16
+ else
17
+ choices = []
18
+ end
19
+
20
+ choices.insert(0, blank_choice(name)) if options[:include_blank]
21
+
22
+ return choices
23
+ end
24
+
25
+ def field_errors(name)
26
+ []
27
+ #@core.errors[name].map{ |e| [I18n.translate_with_article('form.field'), field_label(name).downcase_utf8, e].join(' ')}
28
+ end
29
+
30
+ def field_hint(name)
31
+ field_translation(name, 'hint')
32
+ end
33
+
34
+ def field_label(name)
35
+ text = field_translation(name, 'label')
36
+ text = field_translation(name) if text.empty?
37
+
38
+ return text
39
+ end
40
+
41
+ def field_option(field_name, option_name, options={})
42
+ options.reverse_merge!(text: 'label')
43
+
44
+ text = field_translation(field_name, "options.#{option_name}.#{options[:text]}")
45
+ text = field_translation(field_name, "options.#{option_name}") if text.empty? and options[:text] == 'label'
46
+
47
+ return text
48
+ end
49
+
50
+ private
51
+
52
+ def base_path
53
+ "models.#{obj_name}"
54
+ end
55
+
56
+ def base_field_path
57
+ "#{base_path}.fields"
58
+ end
59
+
60
+ def blank_choice(name)
61
+ [I18n.translate('form.select'), '']
62
+ end
63
+
64
+ def field_translation(name, target=nil)
65
+ name_path = name.to_s.include?('[') ? name.gsub('[', '.hash.').gsub(']', '') : name
66
+ name_path = "#{name_path}.#{target}" if target
67
+
68
+ text = I18n.translate("#{base_field_path}.#{name_path}", default: '')
69
+ text = I18n.translate("#{parent_field_path}.#{name_path}", default: '') if translation_missing? text
70
+
71
+ return text
72
+ end
73
+
74
+ def has_parent?
75
+ false
76
+ #parent_object ? true : false
77
+ end
78
+
79
+ def model_obj
80
+ @record.class
81
+ end
82
+
83
+ def obj_name(class_obj=nil)
84
+ (class_obj ? class_obj : model_obj).to_s.pluralize.underscore
85
+ end
86
+
87
+ def parent_object
88
+ # TOFIX: This should be understood and fix.
89
+ position = @core.ancestors[1].to_s.include?('#<Module') ? 2 : 1
90
+ obj = @core.ancestors[position]
91
+
92
+ return ((not obj or obj.to_s.include?('Mongoid')) ? nil : obj)
93
+ end
94
+
95
+ def parent_path
96
+ "models." + (has_parent? ? obj_name(parent_object) : 'parent_undefined')
97
+ end
98
+
99
+ def parent_field_path
100
+ "#{parent_path}.fields"
101
+ end
102
+
103
+ def translation_missing?(text)
104
+ text.blank? or text.include? 'translation missing'
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,62 @@
1
+ #*************************************************************************************
2
+ # Build complex graphical button.
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form
5
+ class Button
6
+ #*************************************************************************************
7
+ # CONSTRUCTOR
8
+ #*************************************************************************************
9
+ def initialize(core)
10
+ @core = core
11
+ end
12
+
13
+
14
+ #*************************************************************************************
15
+ # PUBLIC INSTANCE METHODS
16
+ #*************************************************************************************
17
+ def build(text, options={})
18
+ options.reverse_merge!(class: '', confirm: nil, default: true, disabled: false, url: nil)
19
+
20
+ if options[:url]
21
+ return link(text, options.delete(:url), options)
22
+ else
23
+ return button(text, options)
24
+ end
25
+ end
26
+
27
+ def build_button_to(text, url, options={})
28
+ options.reverse_merge!(class: '', confirm: nil, disabled: false, method: 'get', url: nil, vars: {})
29
+
30
+ vars = options.delete(:vars)
31
+
32
+ return form_tag(url, method: options[:method], class: "button_to") do
33
+ (vars.map{ |k,v| hidden_field_tag(k, v) }.join("\n") + button(text, options)).html_safe
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ #*************************************************************************************
40
+ # PRIVATE INSTANCE METHODS
41
+ #*************************************************************************************
42
+ def build_options(options)
43
+ options['data-confirm'] = options.delete(:confirm) if options[:confirm]
44
+ options[:class] = ['button', (options[:default] ? 'default' : 'secondary'), options[:class]].compact.join(' ')
45
+ options.delete(:method)
46
+
47
+ return options
48
+ end
49
+
50
+ def button(text, options={})
51
+ options.reverse_merge!(class: '', confirm: nil, type: 'submit')
52
+
53
+ content_tag(:button, text, build_options(options)).html_safe
54
+ end
55
+
56
+ def link(text, url, options={})
57
+ link_to(text, url, build_options(options)).html_safe
58
+ end
59
+
60
+ def method_missing(*args, &block) return @core.send(*args, &block) end
61
+ end
62
+ end
@@ -0,0 +1,43 @@
1
+ #*************************************************************************************
2
+ # TOCOMMENT
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Field
5
+ class Base
6
+ #*************************************************************************************
7
+ # CONSTRUCTOR
8
+ #*************************************************************************************
9
+ def initialize(core)
10
+ @core = core
11
+ end
12
+
13
+ private
14
+
15
+ #*************************************************************************************
16
+ # PRIVATE INSTANCE METHODS
17
+ #*************************************************************************************
18
+ def parse_text_options(options)
19
+ options[:class] = ['text-field', options.delete(:class), options.delete(:field_size)].compact.join(' ')
20
+
21
+ if options[:validates]
22
+ options["data-validations"] = options.delete(:validates)
23
+
24
+ case
25
+ when options["data-validations"].include?('max-') then options[:maxlength] = options["data-validations"].match(/max-[0-9]+/).to_s.split('-').last.to_i
26
+ when options["data-validations"].include?('within-') then options[:maxlength] = options["data-validations"].match(/within-([0-9]+)-([0-9]+)/).to_s.split('-').last.to_i
27
+ when options["data-validations"].include?('creditcard-') then options[:maxlength] = 19
28
+ end
29
+ end
30
+
31
+ return options
32
+ end
33
+
34
+
35
+ def method_missing(*args, &block)
36
+ if [:check_box_tag, :content_tag, :hidden_field_tag, :options_for_select, :password_field_tag, :select_tag, :text_area_tag, :text_field_tag].include?(args.first)
37
+ return @core.send(*args, &block)
38
+ else
39
+ raise NoMethodError.new("undefined local variable or method '#{args.first}' for #{self.class}")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,39 @@
1
+ #*************************************************************************************
2
+ # TOCOMMENT
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Field
5
+ class Checkbox < Caisson::Helpers::Form::Field::Base
6
+ #*************************************************************************************
7
+ # PUBLIC INSTANCE METHODS
8
+ #*************************************************************************************
9
+ def build(name, selected, options={})
10
+ content = []
11
+ content << hidden_field_tag(name, '0', id: nil)
12
+ content << check_box_tag(name, '1', parse_selected(selected), generate_attributes(name, options))
13
+ content << options.delete(:label)
14
+
15
+ return content_tag(:label, content.join("\n").html_safe, :for => name.parameterize.underscore)
16
+ end
17
+
18
+ private
19
+
20
+ #*************************************************************************************
21
+ # PRIVATE INSTANCE METHODS
22
+ #*************************************************************************************
23
+ def generate_attributes(name, options)
24
+ attributes = { class: ['checkbox', 'customized', options.delete(:class)].compact.join(' ') }
25
+ attributes['title'] = options[:title] if options[:title]
26
+ attributes['data-submit'] = 1 if options[:submit]
27
+
28
+ return attributes
29
+ end
30
+
31
+ def parse_selected(selected)
32
+ case selected
33
+ when '0', 'false' then false
34
+ when '1', 'true' then true
35
+ else selected
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ #*************************************************************************************
2
+ # Build complex graphical input field.
3
+ #*************************************************************************************
4
+ module FormCandy::Field
5
+ class Money < FormCandy::Field::Base
6
+ #*************************************************************************************
7
+ # PUBLIC INSTANCE METHODS
8
+ #*************************************************************************************
9
+ def build(name, value, options={})
10
+ options = parse_text_options options
11
+
12
+ decimal = options[:decimal] ? options.delete(:decimal).to_i : 2
13
+ options[:class].gsub!('text-field', 'money-field')
14
+
15
+ options["data-validations"] = [options["data-validations"], 'numeric'].compact.join(' ')
16
+ options["data-decimal"] = decimal
17
+
18
+ content = text_field_tag('formatted-' + name, format_value(value, decimal), options)
19
+ content += content_tag(:span, '$', class: 'symbol currency')
20
+ content += hidden_field_tag(name, value, id: nil, class: 'dbdata')
21
+
22
+ return content.html_safe
23
+ end
24
+
25
+ def format_value(value, decimal)
26
+ value.blank? ? '' : sprintf("%0.0#{decimal}f", (value.to_f / (10 ** decimal)).round(decimal)).gsub('.', ',')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+ #*************************************************************************************
2
+ # Build complex graphical password field.
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Field
5
+ class Password < Caisson::Helpers::Form::Field::Base
6
+ #*************************************************************************************
7
+ # PUBLIC INSTANCE METHODS
8
+ #*************************************************************************************
9
+ def build(name, value, options={})
10
+ password_field_tag name, value, parse_text_options(options)
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ #*************************************************************************************
2
+ # Build complex graphical input field.
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Field
5
+ class Percent < Caisson::Helpers::Form::Field::Base
6
+ #*************************************************************************************
7
+ # PUBLIC INSTANCE METHODS
8
+ #*************************************************************************************
9
+ def build(name, value, options={})
10
+ #options = parse_text_options options
11
+
12
+
13
+ #return (text_field_tag(name, value.f_percent(symbol: false), options) + '<span class="postfix">%</span>'.html_safe).html_safe
14
+
15
+ content = '<div class="field-percent">'
16
+ content += text_field_tag(name, value.f_percent(symbol: false), options)
17
+ content += content_tag(:span, '%', class: 'postfix')
18
+ content += '</div>'
19
+
20
+ return content.html_safe
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,34 @@
1
+ #*************************************************************************************
2
+ # Build complex graphical input field.
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Field
5
+ class Select < Caisson::Helpers::Form::Field::Base
6
+ #*************************************************************************************
7
+ # PUBLIC INSTANCE METHODS
8
+ #*************************************************************************************
9
+ def build(name, choices, selection, options={})
10
+ options.reverse_merge!(class: nil, submit: false, translate: true)
11
+
12
+ choices = get_choices(choices, options[:translate])
13
+
14
+ return select_tag(name, options_for_select(choices, selection), generate_attributes(options))
15
+ end
16
+
17
+ private
18
+
19
+ def generate_attributes(options)
20
+ attributes = { class: ['select-field', options.delete(:class)].flatten.compact.join(' ') }
21
+ attributes['data-submit'] = 1 if options[:submit]
22
+
23
+ return attributes
24
+ end
25
+
26
+ def get_choices(choices, translate)
27
+ case
28
+ when translate then choices # TODO: Translate the fields
29
+ when (not choices.is_a?(Array)) then choices.choices_for_select # choices are a list of records
30
+ else choices
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,17 @@
1
+ #*************************************************************************************
2
+ # Build complex graphical input field.
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Field
5
+ class Text < Caisson::Helpers::Form::Field::Base
6
+ #*************************************************************************************
7
+ # PUBLIC INSTANCE METHODS
8
+ #*************************************************************************************
9
+ def build(name, value, options={})
10
+ options = parse_text_options options
11
+
12
+ value = value.join(';') if value.is_a? Array
13
+
14
+ return text_field_tag name, value, options
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ #*************************************************************************************
2
+ # Build complex graphical input field.
3
+ #*************************************************************************************
4
+ module Caisson::Helpers::Form::Field
5
+ class Textarea < Caisson::Helpers::Form::Field::Base
6
+ #*************************************************************************************
7
+ # PUBLIC INSTANCE METHODS
8
+ #*************************************************************************************
9
+ def build(name, value, options={})
10
+ value = options[:value] if options[:value]
11
+ value = value.join("\n") if value.is_a? Array
12
+
13
+ return text_area_tag(name, value, options)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ module Caisson::Helpers
2
+ module Form
3
+
4
+ end
5
+ end
6
+
7
+ require 'caisson/helpers/form/base'
8
+ require 'caisson/helpers/form/button'
9
+
10
+ require 'caisson/helpers/form/builder/base'
11
+ require 'caisson/helpers/form/builder/interpreti'
12
+
13
+ require 'caisson/helpers/form/builder/field/base'
14
+ require 'caisson/helpers/form/builder/field/checkbox'
15
+ require 'caisson/helpers/form/builder/field/password'
16
+ require 'caisson/helpers/form/builder/field/percent'
17
+ require 'caisson/helpers/form/builder/field/select'
18
+ require 'caisson/helpers/form/builder/field/text'
19
+ require 'caisson/helpers/form/builder/field/textarea'
20
+
21
+ require 'caisson/helpers/form/builder/field_builder/base'
22
+ require 'caisson/helpers/form/builder/field_builder/nature'
23
+
24
+ require 'caisson/helpers/form/field/base'
25
+ require 'caisson/helpers/form/field/checkbox'
26
+ require 'caisson/helpers/form/field/password'
27
+ require 'caisson/helpers/form/field/percent'
28
+ require 'caisson/helpers/form/field/select'
29
+ require 'caisson/helpers/form/field/text'
30
+ require 'caisson/helpers/form/field/textarea'
@@ -0,0 +1,32 @@
1
+ module Caisson::Helpers
2
+ class Grid
3
+ attr_reader :core
4
+
5
+ delegate :capture, to: :core
6
+ delegate :content_tag, to: :core
7
+
8
+ def initialize(core)
9
+ @core = core
10
+ end
11
+
12
+ def column(span, options={}, &block)
13
+ options.reverse_merge! class: nil, id: nil, small: nil, tag: :div
14
+
15
+ css_class = ['columns']
16
+ css_class << "large-#{span}"
17
+ css_class << "small-#{options[:small]}" if options[:small]
18
+ css_class << options[:class] if options[:class]
19
+
20
+ content_tag(options[:tag], capture(&block), class: css_class.join(' '), id: options[:id])
21
+ end
22
+
23
+ def row(options={}, &block)
24
+ options.reverse_merge! class: nil, id: nil, tag: :div
25
+
26
+ css_class = ['row']
27
+ css_class << options[:class] if options[:class]
28
+
29
+ content_tag(options[:tag], capture(&block), class: css_class.join(' '), id: options[:id])
30
+ end
31
+ end
32
+ end
@@ -19,6 +19,7 @@ module Caisson::Helpers
19
19
  private
20
20
 
21
21
  def build_options(options)
22
+ # DEPRECATED IN VERSION 4
22
23
  options.reverse_merge(
23
24
  advance_speed: 4000,
24
25
  animation: "horizontal-push",
@@ -41,21 +42,18 @@ module Caisson::Helpers
41
42
  timer: false)
42
43
  end
43
44
 
44
- def build_item(item, last=false, &block)
45
- css_class = ['column']
46
- css_class << get_column_size
47
- css_class << 'end' if last
48
45
 
49
- '<li class="' + css_class.join(' ') + '">' + capture(item, &block).to_s + '</li>'
46
+ def build_item(item, last=false, &block)
47
+ '<li>' + capture(item, &block).to_s + '</li>'
50
48
  end
51
49
 
52
50
  def build_slides(&block)
53
51
  slides = []
54
52
 
55
53
  @items.each_slice @options[:columns_per_slide] do |slice|
56
- content = '<div><ul class="row">'
54
+ content = '<li><div class="spacer"></div><ul class="wink small-block-grid-3 large-block-grid-' + @options[:columns_per_slide].to_s + '">'
57
55
  slice.each_with_index { |item,i| content << build_item(item, (i==slice.length-1), &block) }
58
- content << '</ul></div>'
56
+ content << '</ul><div class="spacer"></div></li>'
59
57
 
60
58
  slides << content
61
59
  end
@@ -63,17 +61,6 @@ module Caisson::Helpers
63
61
  return slides.join("\n")
64
62
  end
65
63
 
66
- def get_column_size
67
- case @options[:columns_per_slide]
68
- when 1 then 'twelve'
69
- when 2 then 'six'
70
- when 3 then 'four'
71
- when 4 then 'three'
72
- when 5,6 then 'two'
73
- else 'one'
74
- end
75
- end
76
-
77
64
  def parse_attribute_value(raw_value)
78
65
  case raw_value
79
66
  when true then '1'
@@ -82,19 +69,27 @@ module Caisson::Helpers
82
69
  end
83
70
  end
84
71
 
72
+ def stringify_options
73
+ results = []
74
+
75
+ @options.each { |k,v| results << "#{k}:#{v};" }
76
+
77
+ return results.join
78
+ end
79
+
85
80
  def wrap_slider(content)
86
- attributes = { 'data-caisson' => 'orbit-slider' }
81
+ attributes = { 'data-caisson' => 'orbit-slider', 'data-orbit' => '', 'data-options' => stringify_options }
87
82
 
88
83
  @options.each do |k,v|
89
84
  case k.to_s
90
85
  when 'id' then attributes[:id] = v
91
86
  when 'class' then attributes[:class] = ['slider', v].compact.join(' ')
92
87
  when 'columns_per_slide' then nil
93
- else attributes["data-#{k}".gsub('_', '-')] = parse_attribute_value(v)
88
+ else nil #attributes["data-#{k}".gsub('_', '-')] = parse_attribute_value(v)
94
89
  end
95
90
  end
96
91
 
97
- return content_tag(:div, content.html_safe, attributes)
92
+ return content_tag(:ul, content.html_safe, attributes)
98
93
  end
99
94
  end
100
95
  end
@@ -1,9 +1,35 @@
1
1
  module Caisson::Helpers
2
+ def caisson_header
3
+ '<meta name="viewport" content="width=device-width, initial-scale=1.0" />'.html_safe
4
+ end
5
+
6
+ def grid
7
+ @grid ||= Caisson::Helpers::Grid.new(self)
8
+ end
9
+
2
10
  def orbit_slider(items, options={}, &block)
3
11
  Caisson::Helpers::OrbitSlider.new(self, items, options).generate(&block)
4
12
  end
5
13
 
14
+ ActionView::Helpers::FormTagHelper.module_eval do
15
+ def caisson(record=nil)
16
+ if record
17
+ Caisson::Helpers::Form::Builder::Base.new(self, record)
18
+ else
19
+ Caisson::Helpers::Form::Base.new(self)
20
+ end
21
+ end
22
+ end
23
+
24
+ ActionView::Helpers::FormBuilder.module_eval do
25
+ def caisson
26
+ Caisson::Helpers::Form::Builder::Base.new(@template, @object)
27
+ end
28
+ end
29
+
6
30
  ::ActionView::Base.send :include, self
7
31
  end
8
32
 
33
+ require 'caisson/helpers/form'
34
+ require 'caisson/helpers/grid'
9
35
  require 'caisson/helpers/orbit_slider'