Created
April 4, 2013 09:50
-
-
Save davidvanleeuwen/5309171 to your computer and use it in GitHub Desktop.
This file contains 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
unless Backbone? | |
throw new Error("Backbone is not defined. Please include | |
the latest version from http://documentcloud.github.com/backbone/backbone.js") | |
class Backbone.Modal extends Backbone.View | |
constructor: -> | |
args = Array.prototype.slice.apply(arguments) | |
Backbone.View.prototype.constructor.apply(this, args) | |
render: -> | |
@setUIElements() | |
@delegateModalEvents() | |
return this | |
setUIElements: -> | |
template = @getOption('template') | |
@views = @getOption('views') | |
@viewContainer = @getOption('viewContainer') | |
if _.isUndefined(@template) and _.isUndefined(@views) | |
throw new Error('No template or views defined for Backbone.Modal') | |
if @template and @views and _.isUndefined(@viewContainer) | |
throw new Error('No viewContainer defined for Backbone.Modal') | |
getOption: (option) -> | |
return unless option | |
if @options and option in @options and @options[option]? | |
return @options[option] | |
else | |
return @[option] | |
delegateModalEvents: -> | |
cancelEl = @getOption('cancelEl') | |
submitEl = @getOption('submitEl') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment