Sha256: 4b3e4c06835b7161f162fd242bb9460cd6601493e4f56f13f15c342adbd165a2

Contents?: true

Size: 1.97 KB

Versions: 1

Compression:

Stored size: 1.97 KB

Contents

class AffiliateProgram
  @scrollTo: (selector, offset = 100, animation_time = 600)->
    dom = $(selector)
    if dom.length > 0
      _top = $('html > body').offset().top + dom.offset().top - offset
      $('html, body').animate({scrollTop: _top}, animation_time)

  @social: ->
    $("#referal_share a").sharingpopup()

  @invite: ->
    button = $(".action-copy")
    input = $("#invite_url")

    clip = new ZeroClipboard(button.get(0), { moviePath: "/assets/ZeroClipboard.swf"})

    clip.on "complete", (client, args) ->
      button.text(button.data("success"))

    input.click ->
      input.select()

  @table: (options={})->
    defaults =
      showOn: "button",
      buttonImage: "/assets/cabinet/calendar_icon.png",
      buttonImageOnly: true,
      buttonText: "Select date",
      showButtonPanel: true,
      closeText: ""
      onSelect: (date) ->
        if $(this).attr("id") == "start_date"
          $("#end_date").datepicker("option", "minDate",  date)
        else
          $("#start_date").datepicker("option", "maxDate", date)

    defaults = $.extend(defaults, options)

    $('.table_date_item > input').datepicker(defaults)
    $('.uniform').uniform()

  @removeCopyButton: ->
    button = $(".action-copy")
    button.hide()

  @describeBrowser: ->
    if $.browser.ipad || $.browser.iphone
      @removeCopyButton()
    else
      @invite()

  @clearButton: ->
    $('.table_filters .button_clear').on 'click', (e)=>
      if window.location?.search?.length == 0
        e.preventDefault()
        $('.table_filters input[type="text"]').val('')
        $('.table_filters [type="checkbox"]').prop('checked', false).uniform('update')
        $('#end_date').datepicker('option', 'minDate', undefined)
        $('#start_date').datepicker('option', 'maxDate', undefined)
        @scrollTo('.table_filters')

  @init: (options={})->
    $(document).ready =>
      @clearButton()
      @social()
      @describeBrowser()
      @table(options)


window.AffiliateProgram = AffiliateProgram

Version data entries

1 entries across 1 versions & 1 rubygems

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