Sha256: 97c05916b0d7d2d005462dbb36bafd412b8a9d098d181f6f63997d594d1477f2

Contents?: true

Size: 1.78 KB

Versions: 12

Compression:

Stored size: 1.78 KB

Contents

# Initialize all onload scripts at once.
#
# Called at jQuery ready event and Turbolinks page change event.
#
Alchemy.Initializer = ->

  # We obviously have javascript enabled.
  $('html').removeClass('no-js')

  # Initialize the GUI.
  Alchemy.GUI.init()

  # Fade all growl notifications.
  if $('#flash_notices').length > 0
    Alchemy.Growler.fade()

  # Add observer for please wait overlay.
  $('a.please_wait, #main_navi a.main_navi_entry, div.button_with_label form :submit, #sub_navigation .subnavi_tab a, .pagination a')
    .not('*[data-alchemy-confirm], #subnav_additions .subnavi_tab button')
    .click ->
      unless Alchemy.isPageDirty()
        Alchemy.pleaseWaitOverlay()

  # Hack for enabling tab focus for <a>'s styled as button.
  $('a.button').attr({tabindex: 0})

  # Locale select handler
  $('select#change_locale').on 'change', (e) ->
    url = window.location.pathname
    delimiter = if url.match(/\?/) then '&' else '?'
    window.location.href = "#{url}#{delimiter}locale=#{$(this).val()}"

  # Submit forms of selects with `data-autosubmit="true"`
  $('select[data-auto-submit="true"]').on 'change', (e) ->
    Alchemy.pleaseWaitOverlay()
    $(this.form).submit()

  # Attaches the image loader on all images
  Alchemy.ImageLoader('#main_content')

  # Override the filter of keymaster.js so we can blur the fields on esc key.
  key.filter = (event) ->
    tagName = (event.target || event.srcElement).tagName
    key.isPressed('esc') || !(tagName == 'INPUT' || tagName == 'SELECT' || tagName == 'TEXTAREA')

  # Sticky table headers
  $('table.list').floatThead
    useAbsolutePositioning: false,
    scrollingTop: 122,
    zIndex: 1

# Enabling the Turbolinks Progress Bar
Turbolinks.enableProgressBar()

# Turbolinks DOM Ready
$(document).on 'page:change', ->
  Alchemy.Initializer()

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
alchemy_cms-3.1.3 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.2.0.beta app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.1 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.rc3 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.rc2 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.rc1 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.beta6 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.beta5 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.beta4 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.beta3 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee
alchemy_cms-3.1.0.beta2 app/assets/javascripts/alchemy/alchemy.initializer.js.coffee