module ShButton::Helper

Constants

SH_BUTTON_NOT_POPUP

Public Instance Methods

sh_button_tag(title = "", opts = {}) click to toggle source
# File lib/sh_button/helper.rb, line 6
def sh_button_tag(title = "", opts = {})
  opts[:allow_sites] ||= ShButton.config.allow_sites

  html = []
  html << "<div class='sh-button'>"

  opts[:allow_sites].each do |site|
    link_title = t "sh_button.share_to", name: t("sh_button.#{site.downcase}")

    anchor_classes = "sh-button-item sh-button-#{site}"
    anchor_classes << ' sh-button-popup' unless SH_BUTTON_NOT_POPUP.include? site

    html << link_to(tag(:span, class: "sh-button-icon-#{site}"),share_link(site, title, opts[:url], opts[:image]),
                    class: anchor_classes, title: link_title,)
  end
  html << "</div>"
  raw html.join("\n")
end

Private Instance Methods