Sha256: 50a33d25a47294fa9a51b796b5e8b1c784bdca8d13505abb4d810b0c24f71071

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

$(window).ready ->
  doubleClickActiveMap = { off: false, on: true, signed_in: decko.currentUserId }

  doubleClickActive = () ->
    doubleClickActiveMap[decko.doubleClick]

  if doubleClickActive()
    $('body').on 'dblclick', 'div', (_event) ->
      if doubleClickApplies $(this)
        triggerDoubleClickEditingOn $(this)
      false # don't propagate up to next slot

  # else alert "illegal configuration: " + decko.doubleClick

doubleClickApplies = (el) ->
  return false if ['.nodblclick', '.d0-card-header', '.card-editor'].some (klass) ->
    el.closest(klass)[0]
    # double click inactive inside header, editor, or tag with "nodblclick" class
  !el.slot().find('.card-editor')[0]?

triggerDoubleClickEditingOn = (el)->
  slot = el.slot()
  edit_link = slotEditLink(slot)

  if edit_link
    edit_link.click()
  else
    edit_view = slotEditView(slot)
    url = decko.path("~#{slot.data('cardId')}?view=#{edit_view}")
    slot.slotReload url

slotEditLink = (slot) ->
  edit_links =
    slot.find(".edit-link").filter (i, el) ->
      $(el).slot().data('slotId') == slot.data('slotId')

  if edit_links[0] then $(edit_links[0]) else false

slotEditView = (slot) ->
  switch slot.data("slot").edit
    when "inline" then "edit_inline"
    when "full"   then "bridge"
    else "edit"

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
card-mod-edit-0.15.4 assets/script/doubleclick.js.coffee
card-mod-edit-0.15.3 assets/script/doubleclick.js.coffee
card-mod-edit-0.15.2.pre1 assets/script/doubleclick.js.coffee
card-mod-edit-0.15.1.1 assets/script/doubleclick.js.coffee
card-mod-edit-0.15.1 assets/script/doubleclick.js.coffee
card-mod-edit-0.15.0 assets/script/doubleclick.js.coffee