lib/storefront/helpers/component_helper.rb in storefront-0.2.1 vs lib/storefront/helpers/component_helper.rb in storefront-0.2.7

- old
+ new

@@ -1,35 +1,50 @@ module Storefront # Encapsulates common browser hacks module ComponentHelper - def component_image_tag + def rich_image_tag(label, path, options = {}) capture_haml do haml_tag :span - haml_concat image_tag() + haml_concat image_tag(label, path, options) end end - def popup_button(label, path, message, subtitle, submit = nil, kind = :group) - link_to "<span>#{label}</span>", path, :class => "delete", "data-message" => message, "data-subtitle" => subtitle, "data-model" => kind.to_s, "data-submit" => submit.to_s - end + def rich_button(*args, &block) + attributes = args.extract_options! + label = args.shift + path = args.shift + tag = attributes.delete(:as) - def component_button(*args, &block) - options = args.extract_options! - button_options = options.delete(:button_options) || {} + #locale_options = attributes.delete(:locale_options) || {} + #label = t?(label, locale_options.reverse_merge(:scope => :"buttons")) + + inner_html = attributes.delete(:inner_html) || {} + outer_html = attributes.delete(:outer_html) || {} + + inner_html.merge! clone_attributes(attributes) + outer_html.merge! clone_attributes(attributes.except(:rel, :target)) + + merge_class! outer_html, "button" - if block_given? - content = capture(&block) - else - label = args.shift - path = args.shift - content = link_to(label, path, button_options) - end - capture_haml do - haml_tag :button, options.merge(:class => ["button", options[:class]].compact.uniq.join(" ")) do - haml_concat content - haml_tag :span + haml_tag :div, :<, outer_html do + result = succeed "<span></span>".html_safe do + if block_given? + haml_concat capture_haml(&block).gsub("\n", "").strip + else + if tag + haml_tag tag, :>, :<, inner_html + else + haml_concat link_to(label, path, inner_html) + end + end + end + haml_concat result end end + end + + def rich_input(*args, &block) + end end end