Sha256: d27df7512afd14a4e1b9ee0b7d1e9da491c5a5a6248344397cb8119360866844

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

jQuery ->

  # The <span class="edit_mode_group"></span> elements receive 'edit', 'save' and 'cancel' events,
  # when the user clicks the corresponding buttons '.edit_button', '.save_button' or '.cancel_button'.
  # The edit_mode_group has to pass these events down to the contained .editable elements.
  $( ".edit_mode_group" ).bind( "edit", (e) ->
    unless $( this ).hasClass( "currently_in_edit_mode" )
      $( this ).addClass( "currently_in_edit_mode" )

      $( $( this ).find( ".editable" ).get().reverse() ).each ->
        $( this ).trigger( "edit" )
  )

  $( ".edit_mode_group" ).bind( "save", ->

    if $( this ).hasClass( "currently_in_edit_mode" )
      $( this ).removeClass( "currently_in_edit_mode" )

      edit_mode_group = $( this )
      button_effect( $( this ).find( ".save_button" ), ->
        edit_mode_group.find( ".editable" ).trigger( "save" )
      )

  )

  $( ".edit_mode_group" ).bind( "cancel", ->

    if $( this ).hasClass( "currently_in_edit_mode" )
      $( this ).removeClass( "currently_in_edit_mode" )

      edit_mode_group = $( this )
      button_effect( $( this ).find( ".cancel_button" ), ->
        edit_mode_group.find( ".editable" ).trigger( "cancel" )
      )

  )



  button_effect = ( button, callback ) ->
    button.effect( "pulsate", { times: 2 }, "fast", callback )

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
edit_mode-0.0.7 lib/assets/javascripts/edit_mode/edit_mode_group.js.coffee
edit_mode-0.0.6 lib/assets/javascripts/edit_mode/edit_mode_group.js.coffee
edit_mode-0.0.5 lib/assets/javascripts/edit_mode/edit_mode_group.js.coffee