<commit_before>_ = require 'underscore'
sd = require('sharify').data
Backbone = require 'backbone'
Backbone.$ = $
mediator = require '../../../lib/mediator.coffee'
ZeroClipboard = require 'zeroclipboard'

shareTemplate = -> require('../templates/share_link.jade') arguments...

module.exports = class ShareLinkView extends Backbone.View

  events:
    'click .channel--share-generate' : 'generateShareLink'
    'click .channel--share-unshare'  : 'removeShareLink'

  initialize: ->
    @setupZeroClipboard()
    @model.on 'change:share_link', @render, @

  generateShareLink: ->
    @model.generateShareLink()

  removeShareLink: ->
    @model.removeShareLink()

  render: ->
    @setupZeroClipboard()
    @$el.html shareTemplate channel: @model

  setupZeroClipboard: ->
    ZeroClipboard.config swfPath: "../swf/ZeroClipboard.swf"
    @clip = new ZeroClipboard @$(".channel--share-copy-link")
    @clip.on 'ready', ( client, args ) =>
      @clip.on 'copy', ( client, args ) =>
        @$('.channel--share-success').addClass 'is-active'
        @$('.channel--share-copy-link').hide()
<commit_msg>share link<commit_after>_ = require 'underscore'
sd = require('sharify').data
Backbone = require 'backbone'
Backbone.$ = $
mediator = require '../../../lib/mediator.coffee'
ZeroClipboard = require 'zeroclipboard'
analytics = require '../../../lib/analytics.coffee'

shareTemplate = -> require('../templates/share_link.jade') arguments...

module.exports = class ShareLinkView extends Backbone.View

  events:
    'click .channel--share-generate' : 'generateShareLink'
    'click .channel--share-unshare'  : 'removeShareLink'

  initialize: ->
    @setupZeroClipboard()
    @model.on 'change:share_link', @render, @

  generateShareLink: ->
    analytics.track.click "Share link generated"
    @model.generateShareLink()

  removeShareLink: ->
    analytics.track.click "Share link removed"
    @model.removeShareLink()

  render: ->
    @setupZeroClipboard()
    @$el.html shareTemplate channel: @model

  setupZeroClipboard: ->
    ZeroClipboard.config swfPath: "../swf/ZeroClipboard.swf"
    @clip = new ZeroClipboard @$(".channel--share-copy-link")
    @clip.on 'ready', ( client, args ) =>
      @clip.on 'copy', ( client, args ) =>
        @$('.channel--share-success').addClass 'is-active'
        @$('.channel--share-copy-link').hide()

{'fraction_non_alphanumeric': 0.16830414352840667, 'fraction_numerical': 0.0, 'mean_word_length': 3.495201535508637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6434010', 'n_tokens_mistral': 746, 'n_tokens_neox': 731, 'n_words': 140}