Sha256: ac3bead0581b2ccb0046311f6ca282a84d3cee39aee0aae83a5026e361f69699

Contents?: true

Size: 1.67 KB

Versions: 13

Compression:

Stored size: 1.67 KB

Contents

checkNameAfterTyping = null

$(window).ready ->
  $('body').on 'click', '.renamer-updater', ->
    $(this).closest('form').find('#card_update_referers').val 'true'

  $('body').on 'submit', '.edit_name-view .card-form, .name_form-view .card-form', ->
    confirmer = $(this).find '.alert'
    if confirmer.is ':hidden'
      if $(this).find('#referers').val() > 0
        $(this).find('.renamer-updater').show()

      confirmer.show 'blind'
      false

  $('body').on 'keyup', '.name-editor input', (event) ->
    clearTimeout(checkNameAfterTyping) if checkNameAfterTyping
    input = $(this)
    if event.which == 13
      checkName(input)
      checkNameAfterTyping = null
    else
      checkNameAfterTyping = setTimeout ->
          checkName(input)
          checkNameAfterTyping = null
        , 400

checkName = (box) ->
  name = box.val()
  decko.pingName name, (data)->
    return null if box.val() != name # avert race conditions
    status = data['status']
    if status
      ed = box.parent()
      leg = box.closest('fieldset').find('legend')
      msg = leg.find '.name-messages'
      unless msg[0]
        msg = $('<span class="name-messages"></span>')
        leg.append msg?
      ed.removeClass 'real-name virtual-name known-name'

      # use id to avoid warning when renaming to name variant
      slot_id = box.slot().data 'cardId'
      if status != 'unknown' and !(slot_id && parseInt(slot_id) == data['id'])
        ed.addClass status + '-name known-name'
        qualifier = if status == 'virtual' then 'in virtual' else 'already in'
        href = decko.path(data['url_key'])
        msg.html "\"<a href='#{href}'>#{name}</a>\" #{qualifier} use"
      else
        msg.html ''

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
card-mod-script-0.11.4 lib/javascript/decko/name_editor.js.coffee
card-mod-script-0.11.3 lib/javascript/decko/name_editor.js.coffee
card-mod-script-0.11.2 lib/javascript/decko/name_editor.js.coffee
card-mod-script-0.11.1 lib/javascript/decko/name_editor.js.coffee
card-mod-script-0.11.0 lib/javascript/decko/name_editor.js.coffee
card-1.100.0 mod/machines/lib/javascript/decko/name_editor.js.coffee
card-1.99.6 mod/machines/lib/javascript/decko/name_editor.js.coffee
card-1.99.5 mod/machines/lib/javascript/decko/name_editor.js.coffee
card-1.99.4 mod/machines/lib/javascript/decko/name_editor.js.coffee
card-1.99.3 mod/machines/lib/javascript/decko/name_editor.js.coffee
card-1.99.2 mod/machines/lib/javascript/decko/name_editor.js.coffee
card-1.99.1 mod/machines/lib/javascript/decko/name_editor.js.coffee
card-1.99.0 mod/machines/lib/javascript/decko/name_editor.js.coffee