Sha256: 8bd62977fb35a6ec317634ee2b46166381269e8a2d1609b30a334c9ef28e0935

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

#= require jquery
#= require jquery.turbolinks
#= require jquery_ujs
#= require jquery-ui
#= require bootstrap-sprockets
#= require raphael
#= require morris
#= require nprogress
#= require nprogress-turbolinks
#= require gritter
#= require awesome_admin_layout
#= require ace/ace
#= require ace/worker-html
#= require ace/mode-liquid
#= require moment
#= require bootstrap-datetimepicker
#= require comable/admin/dispatcher
#= require_tree .
#= require_self
#= require turbolinks

# ---
# variables
# ---

# TODO: Install 'i18n-js' gem
window.beforeunload_message = 'The changes not saved. Are you sure you want to move from this page?'

# ---
# functions
# ---

add_beforeunload_event = ->
  $form = $('form[method!="get"]')
  $form.change(->
    $(window).bind('beforeunload', ->
      window.beforeunload_message
    )
    $(document).on('page:before-change', ->
      confirm(window.beforeunload_message)
    )
  )
  remove_beforeunload_function = ->
    $(window).unbind('beforeunload')
    $(document).off('page:before-change')
  $form.submit(remove_beforeunload_function)
  $(document).on('page:change', remove_beforeunload_function)

window.add_fields = (_this, association, content) ->
  new_id = new Date().getTime()
  regexp = new RegExp('new_' + association, 'g')
  $(_this).parent().before(content.replace(regexp, new_id))

# ---
# main
# ---

$(document).ready(->
  add_beforeunload_event()

  $('.btn-file :file').change(->
    $(this).closest('form').submit()
  )

  # datetimepicker setting
  $('.datetimepicker').datetimepicker(format: 'YYYY-MM-DD HH:mm')

  $('[data-toggle="tooltip"]').tooltip()
)

NProgress.configure(
  showSpinner: false,
  ease: 'ease',
  speed: 500,
  parent: '#wrapper'
)

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
comable-backend-0.7.0.beta1 app/assets/javascripts/comable/admin/application.coffee
comable-backend-0.6.0 app/assets/javascripts/comable/admin/application.coffee
comable_backend-0.5.0 app/assets/javascripts/comable/admin/application.coffee