Module: EaselHelpers::Helpers::GridHelper
- Included in:
- EaselHelpers::Helpers
- Defined in:
- lib/easel_helpers/helpers/grid_helper.rb
Constant Summary collapse
- MULTIPLES =
{ :one_twentyfourth => (1/24.to_f), :one_twelfth => (1/12.to_f), :one_eigth => (1/8.to_f), :one_sixth => (1/6.to_f), :five_twentyfourths => (5/24.to_f), :one_fourth => (1/4.to_f), :seven_twentyfourths => (7/24.to_f), :one_third => (1/3.to_f), :three_eigths => (3/8.to_f), :five_twelfths => (5/12.to_f), :eleven_twentyfourths => (11/24.to_f), :one_half => (1/2.to_f), :half => (1/2.to_f), :thirteen_twentyfourths => (13/24.to_f), :seven_twelfths => (7/12.to_f), :five_eigths => (5/8.to_f), :two_thirds => (2/3.to_f), :seventeen_twentyfourths => (17/24.to_f), :three_fourths => (3/4.to_f), :nineteen_twentyfourths => (19/24.to_f), :five_sixths => (5/6.to_f), :seven_eigths => (7/8.to_f), :eleven_twelfths => (11/12.to_f), :twentythree_twentyfourths => (23/24.to_f), :full => (1.to_f) }.freeze
- MULTIPLE_FRACTIONS =
MULTIPLES.keys.map {|key| key.to_s }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #clean_column(classes, &block) ⇒ Object
- #column(*args, &block) ⇒ Object
- #container(size = nil, *args, &block) ⇒ Object
- #last_column ⇒ Object
- #method_missing_with_easel_widths(call, *args) ⇒ Object
Class Method Details
.blueprint_grid! ⇒ Object
38 39 40 41 |
# File 'lib/easel_helpers/helpers/grid_helper.rb', line 38 def self.blueprint_grid! @@last_column = "last" @@column_prefix = "span" end |
.easel_grid! ⇒ Object
33 34 35 36 |
# File 'lib/easel_helpers/helpers/grid_helper.rb', line 33 def self.easel_grid! @@last_column = "col-last" @@column_prefix = "col" end |
Instance Method Details
#clean_column(classes, &block) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/easel_helpers/helpers/grid_helper.rb', line 61 def clean_column(classes, &block) size = classes.scan(/#{column_prefix}-(\d+)/).flatten.last if size.nil? html = capture(&block) if block_given? && block_is_within_action_view?(block) concat(html) else html end else size = size.to_i increase_depth(size) html = capture(&block) if block_given? && block_is_within_action_view?(block) concat(html) decrease_depth(size) else decrease_depth(size) html end end end |
#column(*args, &block) ⇒ Object
49 50 51 52 |
# File 'lib/easel_helpers/helpers/grid_helper.rb', line 49 def column(*args, &block) @_easel_column_count ||= application_width col(*args, &block) end |
#container(size = nil, *args, &block) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/easel_helpers/helpers/grid_helper.rb', line 54 def container(size=nil, *args, &block) opts = args. opts.merge!(:suppress_col => true) if size.nil? args = args.insert(0, :container) column(size, *([args, opts].flatten), &block) end |
#last_column ⇒ Object
45 46 47 |
# File 'lib/easel_helpers/helpers/grid_helper.rb', line 45 def last_column @@last_column end |
#method_missing_with_easel_widths(call, *args) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/easel_helpers/helpers/grid_helper.rb', line 86 def method_missing_with_easel_widths(call, *args) # filter out any initial helper calls found = false MULTIPLE_FRACTIONS.each do |fraction| found = true and break if call.to_s.include?(fraction) end method_missing_without_easel_widths(call, *args) and return unless found # one of the widths is somewhere in the helper call; let's find it call.to_s =~ /^((append|prepend|#{column_prefix})_)?(.+)$/ class_name = $2 || column_prefix class_width = $3 if MULTIPLES.keys.include?(class_width.to_sym) width = @_easel_column_count || application_width "#{class_name}-#{(width*MULTIPLES[class_width.to_sym]).to_i}" else method_missing_without_easel_widths(call, *args) end end |