Sha256: c6e3b1d82e8178778416b5158459cb764e6af1035a92d7793623789e9ad0f046

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# Page controller for the 'edit' screen for pages.
class @PageEditPage extends modularity.Module

  constructor: ->
    super 'body'

    # The list of blocks.
    @block_list = new BlockList @$('.block_list')
    @block_list.on 'sorting_finished', @sorting_finished

    # The 'save' button.
    @save_button = @$('#save')
    @save_button.click @save_button_clicked

    @$('.switch').on 'switch-change', @active_switch_changed


  # Called when the 'active' checkbox of a block is changed.
  active_switch_changed: =>
    @save_button.fadeIn()


  # Called when the 'save' button is clicked.
  save_button_clicked: =>
    @save_changes_to_server()


  # Save the changes to the server.
  save_changes_to_server: ->
    $.ajax
      url: document.url
      method: 'PUT'
      contentType: 'application/json'
      data: JSON.stringify({block_data: @block_list.get_data()})
      success: =>
        @save_button.fadeOut()


  # Called when the user has changed the sorting of the blocks.
  sorting_finished: =>
    @save_button.fadeIn()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flms-0.9.0 app/assets/javascripts/flms/admin/pages/edit/edit.coffee
flms-0.1.0 app/assets/javascripts/flms/admin/pages/edit/edit.coffee