Sha256: 77663bb2498ad4b2fe2dcdaa22a62a08b94c433302d0d5477e298e0d0ade29e8

Contents?: true

Size: 1.11 KB

Versions: 79

Compression:

Stored size: 1.11 KB

Contents

class Tenon.features.RecordBooleanToggle
  constructor: ->
    $(document).on 'click', 'a.toggle', @_toggleRecordBoolean

  _toggleRecordBoolean: (e) =>
    e.preventDefault()
    @$link = $(e.currentTarget)
    @trueIcon = 'fa-' + @$link.data('trueicon')
    @falseIcon = 'fa-' + @$link.data('falseicon')
    @trueTooltip = @$link.data('truetooltip')
    @falseTooltip = @$link.data('falsetooltip')
    @_startIconLoad()
    @_setTooltip('Loading...')
    $.getJSON(@$link.attr('href'))
      .done(@_finishToggle)
      .fail((data)-> console.log(data))

  _finishToggle:  =>
    @$link.toggleClass('true false')
    if @$link.hasClass('true')
      @_setTooltip(@trueTooltip)
      @$link.find('i').toggleClass('fa-spin fa-gear ' + @trueIcon)
    else
      @_setTooltip(@falseTooltip)
      @$link.find('i').toggleClass('fa-spin fa-gear ' + @falseIcon)

  _startIconLoad: =>
    @$link.find('i')
      .removeClass(@trueIcon + ' ' + @falseIcon)
      .addClass('fa-spin fa-gear')

  _setTooltip: (tooltip) =>
    @$link
      .tooltip('hide')
      .attr('data-original-title', tooltip)
      .tooltip('fixTitle')
      .tooltip('show')

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
tenon-1.1.4 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.1.3 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.1.2 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.1.1 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.76 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.75 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.74 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.73 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.72 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.71 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.70 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.69 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.68 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.67 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.66 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.65 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.64 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.63 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.62 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
tenon-1.0.61 app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee