Sha256: 018b8fbb75a7feada612ab47f03a4d42f8b1a4faa3cf0be726d753acc81eaa03

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

jQuery ->

  jQuery.fn.apply_best_in_place = ->
    this.best_in_place()
        .addClass( "editable ")
        .bind( "edit", (e) ->
          $( this ).data( 'bestInPlaceEditor' ).activate()
          $( this ).find( "*" ).unbind( 'blur' )
                               .unbind( 'click' )
                               .unbind( 'keyup' )
                               .unbind( 'submit' )
                               .bind( 'keyup', keyUpHandler )
          e.stopPropagation()
        )
        .bind( "cancel", (e) ->
          $( this ).data( 'bestInPlaceEditor' ).abort()
          e.stopPropagation()
        )
        .bind( "save", (e) ->
          $( this ).data( 'bestInPlaceEditor' ).update()
          e.stopPropagation()
        )
    return this

  $( ".best_in_place" ).apply_best_in_place()

  keyUpHandler = (event) ->
    if event.keyCode == 27
      $( this ).closest( ".edit_mode_group" ).trigger( "cancel" )
    if event.keyCode == 13
      unless $( event.target ).is( "textarea" )
        $( this ).closest( ".edit_mode_group" ).trigger( "save" )

Version data entries

2 entries across 2 versions & 1 rubygems

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