Sha256: b3d73d0c242b8c4dcc68ddba83b3638c04f0c1dc9f3a544f37d8dc3281cffe32

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

#= require jquery.qrcode.min

window.SocialShareWeChatButton =
  init: (opts={}) ->
    $wDialog = "<div id='ss-wechat-dialog' class='ss-wechat-dialog'>
                  <div class='wechat-popup-header'>
                    <span>#{opts.header}</span>
                    <a href='#' onclick='return false;' class='wechat-popup-close'>×</a>
                  </div>
                  <div id='ss-wechat-dialog-qr' class='wechat-dialog-qr'></div>
                  <div class='wechat-popup-footer'>
                    #{opts.footer}
                  </div>
               </div>"

    $("body").append($wDialog)

   bindEvents: ()->
     $wContainer = $("#ss-wechat-dialog")
     $wContainer.find(".wechat-popup-close").on "click", (e) ->
       $wContainer.hide()

   qrcode: (opts={}) ->
     unless $("#ss-wechat-dialog").length
       @init(opts)
       @bindEvents()

     $wBody = $('#ss-wechat-dialog-qr')
     $wBody.empty()
     $wBody.qrcode
       width: 200
       height: 200
       text: location.href

     $wContainer = $("#ss-wechat-dialog")
     top = ($(window).height() - $wContainer.height()) / 2
     top = 100 if top < 100
     left = ($(window).width() - $wContainer.width()) / 2

     $wContainer.css
       top: top
       left: left

     $wContainer.show()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
social-share-button-0.8.0 app/assets/javascripts/social-share-button/wechat.coffee
social-share-button-0.7.0 app/assets/javascripts/social-share-button/wechat.coffee
social-share-button-0.6.0 app/assets/javascripts/social-share-button/wechat.coffee
social-share-button-0.5.0 app/assets/javascripts/social-share-button/wechat.coffee