#= require jquery #= require jquery_ujs #= require jquery.form #= require jquery-ui/sortable #= require jquery-ui/widget #= require jquery.iframe-transport #= require jquery.fileupload #= require jquery_nested_form #= require underscore #= require underscore.string #= require underscore.inflection #= require backbone #= require backbone.marionette #= require moment #= require character_editor #= require redactor #= require_self #= require ./character/generic/module #= require ./character/settings/module #= require ./character/posts/module #= require ./character/images/module #= require ./character/pages/module #= require ./character/dashboard/module @Character ||= {} _.mixin(_.str.exports()) # # Unsuck Your Backbone # https://speakerdeck.com/ammeep/unsuck-your-backbone # # # Marionette.js Application Documentation # https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.application.md # @chr = new Backbone.Marionette.Application() # App Layout # /app/views/character.html.erb @chr.addRegions menu: '#menu' content: '#content' API = addMenuItem: (path, icon, title) -> $menuItems = $('#menu_items') $menuItems.append """
#{ responseText }" $('#chr_error_close').on 'click', -> chr.execute('closeError') $overlay.addClass('open') $container.addClass('error-open') closeError: -> $('#chr_error').removeClass('open') $('#character').removeClass('error-open') $('#chr_error_close').off 'click' _.map API, (method, name) => @chr.commands.setHandler(name, method) @chr.on "before:start", (@options) -> # maps options! # shortcuts window.shortcuts = new window.keypress.Listener() # close dialogs and details view on esc window.shortcuts.register_combo keys: 'esc' is_exclusive: true on_keyup: (event) -> if $('#chr_images').hasClass 'open' chr.execute('hideImages') else if $('#chr_error').hasClass 'open' chr.execute('closeError') else chr.execute('closeDetailsView') @chr.on "start", -> # start history if Backbone.history Backbone.history.start() # jump to first menu item when login to admin if location.hash == '' location.hash = $('#menu a:eq(1)').attr('href') # disable default action for browser when drop image to window $(document).bind 'drop dragover', (e) -> e.preventDefault()