updated files
This commit is contained in:
@@ -6,12 +6,22 @@ class MainView extends Backbone.View
|
||||
$(@el).html(Handlebars.templates.main(@model))
|
||||
|
||||
# Render each resource
|
||||
@addResource resource for resource in @model.apisArray
|
||||
|
||||
resources = {}
|
||||
counter = 0
|
||||
for resource in @model.apisArray
|
||||
id = resource.name
|
||||
while typeof resources[id] isnt 'undefined'
|
||||
id = id + "_" + counter
|
||||
counter += 1
|
||||
resource.id = id
|
||||
resources[id] = resource
|
||||
@addResource resource
|
||||
@
|
||||
|
||||
addResource: (resource) ->
|
||||
# Render a resource and add it to resources li
|
||||
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.name, className: 'resource'})
|
||||
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource'})
|
||||
$('#resources').append resourceView.render().el
|
||||
|
||||
clear: ->
|
||||
|
||||
@@ -2,10 +2,10 @@ class OperationView extends Backbone.View
|
||||
invocationUrl: null
|
||||
|
||||
events: {
|
||||
'submit .sandbox' : 'submitOperation'
|
||||
'click .submit' : 'submitOperation'
|
||||
'click .response_hider' : 'hideResponse'
|
||||
'click .toggleOperation' : 'toggleOperationContent'
|
||||
'submit .sandbox' : 'submitOperation'
|
||||
'click .submit' : 'submitOperation'
|
||||
'click .response_hider' : 'hideResponse'
|
||||
'click .toggleOperation' : 'toggleOperationContent'
|
||||
}
|
||||
|
||||
initialize: ->
|
||||
@@ -314,5 +314,5 @@ class OperationView extends Backbone.View
|
||||
hljs.highlightBlock($('.response_body', $(@el))[0])
|
||||
|
||||
toggleOperationContent: ->
|
||||
elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content")
|
||||
elem = $('#' + Docs.escapeResourceName(@model.parentId) + "_" + @model.nickname + "_" + @model.method + "_content")
|
||||
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)
|
||||
|
||||
@@ -4,10 +4,22 @@ class ResourceView extends Backbone.View
|
||||
render: ->
|
||||
$(@el).html(Handlebars.templates.resource(@model))
|
||||
|
||||
@number = 0
|
||||
methods = {}
|
||||
|
||||
# Render each operation
|
||||
@addOperation operation for operation in @model.operationsArray
|
||||
for operation in @model.operationsArray
|
||||
counter = 0
|
||||
|
||||
id = operation.nickname
|
||||
while typeof methods[id] isnt 'undefined'
|
||||
id = id + "_" + counter
|
||||
counter += 1
|
||||
|
||||
methods[id] = operation
|
||||
|
||||
operation.nickname = id
|
||||
operation.parentId = @model.id
|
||||
@addOperation operation
|
||||
@
|
||||
|
||||
addOperation: (operation) ->
|
||||
|
||||
Reference in New Issue
Block a user