Remove inline event handlers from resource template.

This allows us to use a strict CSP on explorer pages.
This commit is contained in:
Samuel Reed
2014-08-24 11:17:03 -04:00
parent 9b0aa32941
commit 7a91117b6f
4 changed files with 34 additions and 14 deletions

View File

@@ -20,7 +20,12 @@ class ResourceView extends Backbone.View
operation.nickname = id
operation.parentId = @model.id
@addOperation operation
@
$('.toggleEndpointList', @el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'))
$('.collapseResource', @el).click(this.callDocs.bind(this, 'collapseOperationsForResource'))
$('.expandResource', @el).click(this.callDocs.bind(this, 'expandOperationsForResoruce'))
return @
addOperation: (operation) ->
@@ -30,4 +35,12 @@ class ResourceView extends Backbone.View
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint', swaggerOptions: @options.swaggerOptions})
$('.endpoints', $(@el)).append operationView.render().el
@number++
@number++
#
# Generic Event handler (`Docs` is global)
#
callDocs: (fnName, e) ->
e.preventDefault()
Docs[fnName](e.currentTarget.getAttribute('data-id'))