Sha256: f3c8082bdb638e9ad923fdcd91f575d7904cc9eafd22ed795b83d8b18ad63a12

Contents?: true

Size: 1011 Bytes

Versions: 1

Compression:

Stored size: 1011 Bytes

Contents

root = this
$ = jQuery

$.fn.sharingpopup = (options = {}) ->
  @each ->
    $this = $(this)
    data = $this.data("sharingpopup")
    if (!data)
      $this.data("sharingpopup", new Sharingpopup(this, options))
    if (typeof options is 'string')
      data[options]()

class Sharingpopup

  constructor: (@link, options = {}) ->
    defaults =
      source: "href"
      onshow: null
      
    @options = $.extend defaults, options
    
    this._setup()
  
  _setup: ->
    @element = $ @link

    @element.data("sharingpopup", this)

    @element.unbind("click.sharing")
    @element.bind("click.sharing", (e) =>
      this.show()
      return false
    )

  show: ->
    width  = 575
    height = 400
    left   = ($(window).width()  - width)  / 2
    top    = ($(window).height() - height) / 2
    url    = @element.attr('href')
    opts   = 'status=1,width='+width+',height='+height+',top='+top+',left='+left

    ga('send', 'event', 'share', @element.attr('rel'))

    window.open(url, 'Sharing', opts)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_cms-0.1.5 app/assets/javascripts/sharingpopup.js.coffee