Sha256: b48126bb3cd4f9e231b7a800b4e427be1bf4b2955987d534a43615a86158ec02

Contents?: true

Size: 1.13 KB

Versions: 12

Compression:

Stored size: 1.13 KB

Contents

submitAfterTyping = null

$(window).ready ->
  $('body').on "change", "._submit-on-change", (event) ->
    $(event.target).closest('form').submit()
    false

  # TODO: consider refactoring so that all of this is handled by _submit-on-change

  # submit form if user stops typing for a second
  $('body').on "input", "._submit-after-typing", (event) ->
    form = $(event.target).closest('form')
    form.slot().find(".autosubmit-success-notification").remove()
    clearTimeout(submitAfterTyping) if submitAfterTyping
    submitAfterTyping = setTimeout ->
        $(event.target).closest('form').submit()
        submitAfterTyping = null
      , 1000

  # if "enter/return" is pressed, submit right away
  $('body').on "keydown", "._submit-after-typing", (event) ->
    if event.which == 13 # enter/return
      clearTimeout(submitAfterTyping) if submitAfterTyping
      submitAfterTyping = null
      $(event.target).closest('form').submit()
      false

  $('body').on "change", "._edit-item", (event) ->
    cb = $(event.target)
    cb.attr "name", (cb.is(":checked") && "add_item" || "drop_item")
    $(event.target).closest('form').submit()
    false

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-mod-edit-0.18.1 assets/script/components.js.coffee
card-mod-edit-0.18.0 assets/script/components.js.coffee
card-mod-edit-0.17.0 assets/script/components.js.coffee
card-mod-edit-0.16.0 assets/script/components.js.coffee
card-mod-edit-0.15.6 assets/script/components.js.coffee
card-mod-edit-0.15.5 assets/script/components.js.coffee
card-mod-edit-0.15.4 assets/script/components.js.coffee
card-mod-edit-0.15.3 assets/script/components.js.coffee
card-mod-edit-0.15.2.pre1 assets/script/components.js.coffee
card-mod-edit-0.15.1.1 assets/script/components.js.coffee
card-mod-edit-0.15.1 assets/script/components.js.coffee
card-mod-edit-0.15.0 assets/script/components.js.coffee