Sha256: 026e84dba19c6e6c5ec53440008c5fd669366fb0ff2409e3e1537dcba14e5582

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

window.RailsScript ||= {}
window.App ||= {}
window.Element ||= {}
window.Utility ||= {}

# Initializer
$(document).on "ready.rails_script page:load.rails_script turbolinks:load.rails_script",  ->
  controller = $('#rails-script').data('controller')
  action = $('#rails-script').data('action')
  Utility.RailsVars = $('#rails-script').data('vars')

  window.$this = new (App[controller] || App.Base)()

  if typeof $this.beforeAction == 'function'
    $this.beforeAction action
  if typeof $this[action] == 'function'
    $this[action]()
  if typeof $this.afterAction == 'function'
    $this.afterAction action

# Clear event handlers on navigation
RailsScript.setClearEventHandlers = ->
  jQuery(document).on 'page:before-change turbolinks:before-visit', ->
    for element in [window, document]
      for event, handlers of (jQuery._data(element, 'events') || {})
        for handler in handlers
          if handler? && handler.namespace == ''
            jQuery(element).off event, handler.handler

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_script-2.0.1 vendor/assets/javascripts/rails_script/init.coffee