Created
May 10, 2014 15:05
-
-
Save jasonLaster/e07c8c865f5c75505058 to your computer and use it in GitHub Desktop.
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
/* | |
* active-math | |
* ---------- | |
* A view that lets you view and edit LaTeX blocks | |
* | |
*/ | |
var ActiveMathView = Marionette.Layout.extend({ | |
template: gistbookTemplates.activeMath, | |
className: 'gistblock gistblock-math gistblock-active', | |
initialize: function() { | |
_.bindAll(this, 'onEdit', 'onMove', 'onDelete'); | |
}, | |
regions: { | |
wrapper: '.gistblock-wrapper' | |
}, | |
onEdit: function() { | |
console.log('The parent has been told to edit'); | |
// Remove handlers; the child is about to be destroyed | |
this.showEdit(); | |
}, | |
showEdit: function() { | |
this.stopListening(); | |
this.getRegion('wrapper').show( | |
new MenuWrapper({ | |
InertView: InertMathView, | |
model: this.model | |
}) | |
); | |
this.currentView = this.getRegion('wrapper').currentView; | |
this._configurePreviewListeners(); | |
}, | |
showPreview: function() { | |
this.stopListening(); | |
var region = this.getRegion('wrapper'); | |
region.show( | |
new EditWrapper({ | |
model: this.model | |
}) | |
); | |
this.currentView = region.currentView; | |
this._configureEditListeners(); | |
}, | |
onMove: function() { | |
console.log('The parent has been told to move'); | |
}, | |
onDelete: function() { | |
this.model.collection.remove(this.model); | |
}, | |
onCode: function() { | |
console.log('The parent has been told to show the code'); | |
}, | |
onPreview: function() { | |
console.log('The parent has been told to show the preview'); | |
}, | |
onCancel: function() { | |
console.log('The parent has been told to cancel'); | |
this.showPreview(); | |
}, | |
onUpdate: function() { | |
console.log('The parent has been told to update'); | |
}, | |
// Show the edit view with the InertView as the | |
// display | |
onRender: function() { | |
this.showPreview(); | |
}, | |
_configureEditListeners: function() { | |
this.listenTo(this.currentView, 'code', this.onCode); | |
this.listenTo(this.currentView, 'preview', this.onPreview); | |
this.listenTo(this.currentView, 'cancel', this.onCancel); | |
this.listenTo(this.currentView, 'update', this.onUpdate); | |
}, | |
_configurePreviewListeners: function() { | |
this.listenTo(this.currentView, 'edit', this.onEdit); | |
this.listenTo(this.currentView, 'delete', this.onDelete); | |
this.listenTo(this.currentView, 'move', this.onMove); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment