Sha256: c42f817b257ecc541ad09b58614f4f31d811f2f31559a9591b03589d5f2c7d4e

Contents?: true

Size: 1.29 KB

Versions: 11

Compression:

Stored size: 1.29 KB

Contents

# coding: utf-8
module SocialShareButton
  module Helper
    def social_share_button_tag(title = "", opts = {})
      opts[:allow_sites] ||= SocialShareButton.config.allow_sites

      extra_data = {}
      rel = opts[:rel]
      html = []
      html << "<div class='social-share-button' data-title='#{h title}' data-img='#{opts[:image]}'"
      html << "data-url='#{opts[:url]}' data-desc='#{opts[:desc]}' data-via='#{opts[:via]}'>"

      opts[:allow_sites].each do |name|
        extra_data = opts.select { |k, _| k.to_s.start_with?('data') } if name.eql?('tumblr')
        special_data = opts.select { |k, _| k.to_s.start_with?('data-' + name) }
        
        special_data["data-wechat-footer"] = t "social_share_button.wechat_footer" if name == "wechat"

        link_title = t "social_share_button.share_to", :name => t("social_share_button.#{name.downcase}")
        html << link_to("", "#", { :rel => ["nofollow", rel],
                                   "data-site" => name,
                                   :class => "ssb-icon ssb-#{name}",
                                   :onclick => "return SocialShareButton.share(this);",
                                   :title => h(link_title) }.merge(extra_data).merge(special_data))
      end
      html << "</div>"
      raw html.join("\n")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
social-share-button-0.8.8 lib/social_share_button/helper.rb
social-share-button-0.8.7 lib/social_share_button/helper.rb
social-share-button-0.8.6 lib/social_share_button/helper.rb
social-share-button-0.8.5 lib/social_share_button/helper.rb
social-share-button-0.8.4 lib/social_share_button/helper.rb
social-share-button-0.8.2 lib/social_share_button/helper.rb
social-share-button-0.8.1 lib/social_share_button/helper.rb
social-share-button-0.8.0 lib/social_share_button/helper.rb
social-share-button-0.7.0 lib/social_share_button/helper.rb
social-share-button-0.6.0 lib/social_share_button/helper.rb
social-share-button-0.5.0 lib/social_share_button/helper.rb