Sha256: d7073f3d7c30410a475de675a5790c04d07084ba64cb713311af44dad0aae92b

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

ready = ->

  # The <span class="edit_mode_group"></span> elements should be modal when in edit mode.
  # That means that everything else should be greyed out.
  # If the user clicks on the shaded (grey) area outside, the edit_mode_group is saved.

  $( document ).on( "edit", ".edit_mode_group", ->
    if $( document ).find( ".edit-mode-modal" ).size() == 0
      #unless $( this ).hasClass( "edit-mode-modal" )
      modal_edit_mode_group = $( this )
      $( this ).addClass( "edit-mode-modal" )
      $( "body" ).append( "<div class='edit-mode-modal-bg'></div>" )
      $( "div.edit-mode-modal-bg" ).hide().fadeIn().click( ->
        modal_edit_mode_group.trigger( "save" )
      )
  )

  $( document ).on( "save cancel", ".edit_mode_group", ->
    if $( this ).hasClass( "edit-mode-modal" )
      unless $( this ).hasClass( "animating" )
        $( this ).addClass( "animating" )
        setTimeout( ->
          $( "div.edit-mode-modal-bg" ).fadeOut( ->
            $( this ).remove()
            $( ".edit-mode-modal" ).removeClass( "edit-mode-modal animating" )
          )
        , 300 )
  )

$(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/make_modal.js.coffee