Last active
August 29, 2015 14:19
-
-
Save ionox0/ced45a79066e9cfee9e4 to your computer and use it in GitHub Desktop.
Modal Dialog App w/ Marionette
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MM.module 'DialogApp', (DialogApp, App, Backbone, Marionette, $, _) -> | |
@on | |
'start': -> | |
$('#dialog-region').on 'click.anywhere', (evt) -> | |
API.hide() | |
'stop': -> | |
$(document).add(App.contextMenuRegion.el).off('.anywhere') | |
API.hide() | |
API = | |
show: (view) -> | |
DialogApp.Show.Controller.showDialog view | |
hide: -> | |
App.dialogRegion.close() | |
showAddToCollection: (items) -> | |
DialogApp.Show.Controller.showAddToCollection items | |
showAddToFamilyDrive: (items) -> | |
DialogApp.Show.Controller.showAddToFamilyDrive items | |
showPasswordConfirm: (model) -> | |
DialogApp.Show.Controller.showPasswordConfirm model | |
showReadonlyAlert: (type) -> | |
DialogApp.Show.Controller.showReadonlyAlert type | |
App.addInitializer -> | |
App.dialogRegion.on | |
show: -> | |
$(App.container.el).addClass 'fade-back' | |
$(App.header.el).addClass 'fade-back' | |
@$el.addClass 'active' | |
$(App.dialogRegion.el).find('#dialog').on 'click.anywhere', (evt) -> | |
evt.stopPropagation() | |
close: -> | |
$(App.container.el).removeClass 'fade-back' | |
$(App.header.el).removeClass 'fade-back' | |
@$el.removeClass 'active' | |
App.vent.on 'dialog:show', (view) -> | |
API.show view | |
App.vent.on 'dialog:fullscreen', -> | |
$el = $(App.dialogRegion.el) | |
$el.toggleClass('fullscreen') | |
# The following two methods should form the basis for all future dialog triggers | |
App.vent.on 'show:dialog:addToCollection', (items) -> | |
API.showAddToCollection items | |
App.vent.on 'show:dialog:addToFamilyDrive', (items) -> | |
API.showAddToFamilyDrive items | |
App.vent.on 'show:dialog:passwordConfirm', (account) -> | |
API.showPasswordConfirm account | |
App.vent.on 'system:readonly:on', -> | |
API.showReadonlyAlert 'system' | |
App.vent.on 'user:readonly:on', -> | |
API.showReadonlyAlert 'user' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment