Sha256: 8b8bd35354efe7d4022a15eac4316d74fc05a4ed2596e634a3051a707210ceb5

Contents?: true

Size: 1.24 KB

Versions: 60

Compression:

Stored size: 1.24 KB

Contents

class NumberFieldUpdater
  @hideReadOnly: (id) ->
    toggleReadOnly(id, false)
    resetInput(id)

  @showReadOnly: (id) ->
    toggleReadOnly(id, true)

  @showForm: (id) ->
    toggleForm(id, true)

  @hideForm: (id) ->
    toggleForm(id, false)

  @successHandler: (id, newNumber) ->
    $("#number-update-#{id} span").text(newNumber)
    @hideForm(id)
    @showReadOnly(id)

  toggleReadOnly = (id, show) ->
    toggleButtonVisibility('edit', id, show)
    toggleButtonVisibility('trash', id, show)
    cssDisplay = if show then 'block' else 'none'
    $("#number-update-#{id} span").css('display', cssDisplay)

  toggleForm = (id, show) ->
    toggleButtonVisibility('void', id, show)
    toggleButtonVisibility('check', id, show)
    cssDisplay = if show then 'block' else 'none'
    $("#number-update-#{id} input[type='number']").css('display', cssDisplay)

  toggleButtonVisibility = (buttonIcon, id, show) ->
    cssDisplay = if show then 'inline-block' else 'none'
    $(".fa-#{buttonIcon}[data-id='#{id}']").css('display', cssDisplay)

  resetInput = (id) ->
    tableCell = $("#number-update-#{id}")
    countText = tableCell.find('span').text().trim()
    tableCell.find("input[type='number']").val(countText)

Spree.NumberFieldUpdater = NumberFieldUpdater

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
solidus_backend-2.3.1 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.2.2 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.1.1 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.0.3 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-1.4.2 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-1.3.2 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-1.2.3 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-1.1.4 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-1.0.7 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.3.0 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.3.0.rc3 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.3.0.rc2 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.3.0.rc1 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.3.0.beta1 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.0.2 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-1.4.1 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.2.1 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.2.0 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.2.0.rc1 app/assets/javascripts/spree/backend/number_field_updater.coffee
solidus_backend-2.2.0.beta1 app/assets/javascripts/spree/backend/number_field_updater.coffee