Sha256: 3ddd4cb96c100538a0d9d1525ab245ba52baf1eb65a9b188ac8e854b3c07a8a4

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# Page controller for the 'index' page for blocks.
class @BlocksIndexPage 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.0.3 app/assets/javascripts/flms/blocks/index/index.coffee
flms-0.0.2 app/assets/javascripts/flms/blocks/index/index.coffee