Sha256: f13bd4115b7669ca72c1e26cd2fb4d11ae049c6003354ac58ad70c44429651c4

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

ready = ->
  
  jQuery.fn.apply_edit_mode_add_button_classes = ->

    # The 'save' and the 'cancel' button are only to be shown in edit mode.
    # In order to receive the proper 'edit', 'save', 'cancel' events, they also have to be .editable.
    this.find( ".save_button,.cancel_button" ).addClass( "show_only_in_edit_mode editable" )
    
    # The 'edit' button is only to be shown when not in edit mode.
    this.find( ".edit_button" ).addClass( "do_not_show_in_edit_mode editable" )
    
    # The buttons trigger the correspondig events of the surrounding edit_mode_group.
    this.on( "click", ".edit_button", (e) ->
      $( this ).closest( ".edit_mode_group" ).trigger( "edit" )
      e.preventDefault()
    )
    this.on( "click", ".save_button", (e) ->
      $( this ).closest( ".edit_mode_group" ).trigger( "save" )
      e.preventDefault()
    )
    this.on( "click", ".cancel_button", (e) ->
      $( this ).closest( ".edit_mode_group" ).trigger( "cancel" )
      e.preventDefault()
    )

    return this

  $( document ).apply_edit_mode_add_button_classes()


$(document).ready(ready)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
edit_mode-1.0.1 lib/assets/javascripts/edit_mode/tool_buttons.js.coffee