updated files

This commit is contained in:
Tony Tam
2014-02-27 23:35:36 -08:00
parent 7b77ffd079
commit dc7b663239
8 changed files with 289 additions and 292 deletions

132
dist/swagger-ui.js vendored
View File

@@ -91,7 +91,7 @@ var Docs = {
switch (fragments.length) { switch (fragments.length) {
case 1: case 1:
// Expand all operations for the resource and scroll to it // Expand all operations for the resource and scroll to it
// log('shebang resource:' + fragments[0]); log('shebang resource:' + fragments[0]);
var dom_id = 'resource_' + fragments[0]; var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]); Docs.expandEndpointListForResource(fragments[0]);
@@ -99,7 +99,7 @@ var Docs = {
break; break;
case 2: case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search // Refer to the endpoint DOM element, e.g. #words_get_search
// log('shebang endpoint: ' + fragments.join('_')); log('shebang endpoint: ' + fragments.join('_'));
// Expand Resource // Expand Resource
Docs.expandEndpointListForResource(fragments[0]); Docs.expandEndpointListForResource(fragments[0]);
@@ -109,8 +109,8 @@ var Docs = {
var li_dom_id = fragments.join('_'); var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content"; var li_content_dom_id = li_dom_id + "_content";
// log("li_dom_id " + li_dom_id); log("li_dom_id " + li_dom_id);
// log("li_content_dom_id " + li_content_dom_id); log("li_content_dom_id " + li_content_dom_id);
Docs.expandOperation($('#'+li_content_dom_id)); Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false}); $('#'+li_dom_id).slideto({highlight: false});
@@ -185,9 +185,7 @@ var Docs = {
collapseOperation: function(elem) { collapseOperation: function(elem) {
elem.slideUp(); elem.slideUp();
} }
};(function() {
};
(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) { templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0']; this.compilerInfo = [4,'>= 1.0.0'];
@@ -365,96 +363,56 @@ function program11(depth0,data) {
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ " operation' id='"; + " operation' id='";
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "_"; + "_";
if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/"; + "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "/"; + "/";
if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "' class=\"toggleOperation\">"; + "' class=\"toggleOperation\">";
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "</a>\n </span>\n <span class='path'>\n <a href='#!/"; + "</a>\n </span>\n <span class='path'>\n <a href='#!/";
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "/"; + "/";
if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "' class=\"toggleOperation\">"; + "' class=\"toggleOperation\">";
if (stack1 = helpers.path) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.path) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.path; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.path; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/"; + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "/"; + "/";
if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "' class=\"toggleOperation\">"; + "' class=\"toggleOperation\">";
if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='"; buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";
if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "_"; + "_";
if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_";
if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "_content' style='display:none'>\n "; + "_content' style='display:none'>\n ";
stack1 = helpers['if'].call(depth0, depth0.notes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); stack1 = helpers['if'].call(depth0, depth0.notes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
@@ -1047,12 +1005,12 @@ function program1(depth0,data) {
} }
buffer += "<div class='heading'>\n <h2>\n <a href='#!/"; buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "' onclick=\"Docs.toggleEndpointListForResource('"; + "' onclick=\"Docs.toggleEndpointListForResource('";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "');\">"; + "');\">";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
@@ -1068,32 +1026,32 @@ function program1(depth0,data) {
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/"; buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "' id='endpointListTogger_"; + "' id='endpointListTogger_";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'\n onclick=\"Docs.toggleEndpointListForResource('"; + "'\n onclick=\"Docs.toggleEndpointListForResource('";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('"; + "');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('"; + "'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='"; + "'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='"; + "'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1) buffer += escapeExpression(stack1)
+ "_endpoint_list' style='display:none'>\n\n</ul>\n"; + "_endpoint_list' style='display:none'>\n\n</ul>\n";
return buffer; return buffer;
@@ -1410,11 +1368,20 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
MainView.prototype.initialize = function() {}; MainView.prototype.initialize = function() {};
MainView.prototype.render = function() { MainView.prototype.render = function() {
var resource, _i, _len, _ref3; var counter, id, resource, resources, _i, _len, _ref3;
$(this.el).html(Handlebars.templates.main(this.model)); $(this.el).html(Handlebars.templates.main(this.model));
resources = {};
counter = 0;
_ref3 = this.model.apisArray; _ref3 = this.model.apisArray;
for (_i = 0, _len = _ref3.length; _i < _len; _i++) { for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
resource = _ref3[_i]; resource = _ref3[_i];
id = resource.name;
while (typeof resources[id] !== 'undefined') {
id = id + "_" + counter;
counter += 1;
}
resource.id = id;
resources[id] = resource;
this.addResource(resource); this.addResource(resource);
} }
return this; return this;
@@ -1425,7 +1392,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
resourceView = new ResourceView({ resourceView = new ResourceView({
model: resource, model: resource,
tagName: 'li', tagName: 'li',
id: 'resource_' + resource.name, id: 'resource_' + resource.id,
className: 'resource' className: 'resource'
}); });
return $('#resources').append(resourceView.render().el); return $('#resources').append(resourceView.render().el);
@@ -1450,12 +1417,21 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
ResourceView.prototype.initialize = function() {}; ResourceView.prototype.initialize = function() {};
ResourceView.prototype.render = function() { ResourceView.prototype.render = function() {
var operation, _i, _len, _ref4; var counter, id, methods, operation, _i, _len, _ref4;
$(this.el).html(Handlebars.templates.resource(this.model)); $(this.el).html(Handlebars.templates.resource(this.model));
this.number = 0; methods = {};
_ref4 = this.model.operationsArray; _ref4 = this.model.operationsArray;
for (_i = 0, _len = _ref4.length; _i < _len; _i++) { for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
operation = _ref4[_i]; operation = _ref4[_i];
counter = 0;
id = operation.nickname;
while (typeof methods[id] !== 'undefined') {
id = id + "_" + counter;
counter += 1;
}
methods[id] = operation;
operation.nickname = id;
operation.parentId = this.model.id;
this.addOperation(operation); this.addOperation(operation);
} }
return this; return this;
@@ -1866,7 +1842,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
OperationView.prototype.toggleOperationContent = function() { OperationView.prototype.toggleOperationContent = function() {
var elem; var elem;
elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.method + "_" + this.model.number + "_content"); elem = $('#' + Docs.escapeResourceName(this.model.parentId) + "_" + this.model.nickname + "_" + this.model.method + "_content");
if (elem.is(':visible')) { if (elem.is(':visible')) {
return Docs.collapseOperation(elem); return Docs.collapseOperation(elem);
} else { } else {

File diff suppressed because one or more lines are too long

View File

@@ -6,12 +6,22 @@ class MainView extends Backbone.View
$(@el).html(Handlebars.templates.main(@model)) $(@el).html(Handlebars.templates.main(@model))
# Render each resource # 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) -> addResource: (resource) ->
# Render a resource and add it to resources li # 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 $('#resources').append resourceView.render().el
clear: -> clear: ->

View File

@@ -314,5 +314,5 @@ class OperationView extends Backbone.View
hljs.highlightBlock($('.response_body', $(@el))[0]) hljs.highlightBlock($('.response_body', $(@el))[0])
toggleOperationContent: -> 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) if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)

View File

@@ -4,10 +4,22 @@ class ResourceView extends Backbone.View
render: -> render: ->
$(@el).html(Handlebars.templates.resource(@model)) $(@el).html(Handlebars.templates.resource(@model))
@number = 0 methods = {}
# Render each operation # 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) -> addOperation: (operation) ->

View File

@@ -91,7 +91,7 @@ var Docs = {
switch (fragments.length) { switch (fragments.length) {
case 1: case 1:
// Expand all operations for the resource and scroll to it // Expand all operations for the resource and scroll to it
// log('shebang resource:' + fragments[0]); log('shebang resource:' + fragments[0]);
var dom_id = 'resource_' + fragments[0]; var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]); Docs.expandEndpointListForResource(fragments[0]);
@@ -99,7 +99,7 @@ var Docs = {
break; break;
case 2: case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search // Refer to the endpoint DOM element, e.g. #words_get_search
// log('shebang endpoint: ' + fragments.join('_')); log('shebang endpoint: ' + fragments.join('_'));
// Expand Resource // Expand Resource
Docs.expandEndpointListForResource(fragments[0]); Docs.expandEndpointListForResource(fragments[0]);
@@ -109,8 +109,8 @@ var Docs = {
var li_dom_id = fragments.join('_'); var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content"; var li_content_dom_id = li_dom_id + "_content";
// log("li_dom_id " + li_dom_id); log("li_dom_id " + li_dom_id);
// log("li_content_dom_id " + li_content_dom_id); log("li_content_dom_id " + li_content_dom_id);
Docs.expandOperation($('#'+li_content_dom_id)); Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false}); $('#'+li_dom_id).slideto({highlight: false});
@@ -185,5 +185,4 @@ var Docs = {
collapseOperation: function(elem) { collapseOperation: function(elem) {
elem.slideUp(); elem.slideUp();
} }
}; };

View File

@@ -1,22 +1,22 @@
<ul class='operations' > <ul class='operations' >
<li class='{{method}} operation' id='{{resourceName}}_{{nickname}}_{{method}}_{{number}}'> <li class='{{method}} operation' id='{{parentId}}_{{nickname}}'>
<div class='heading'> <div class='heading'>
<h3> <h3>
<span class='http_method'> <span class='http_method'>
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{method}}</a> <a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{method}}</a>
</span> </span>
<span class='path'> <span class='path'>
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{path}}</a> <a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{path}}</a>
</span> </span>
</h3> </h3>
<ul class='options'> <ul class='options'>
<li> <li>
<a href='#!/{{resourceName}}/{{nickname}}_{{method}}_{{number}}' class="toggleOperation">{{{summary}}}</a> <a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{{summary}}}</a>
</li> </li>
</ul> </ul>
</div> </div>
<div class='content' id='{{resourceName}}_{{nickname}}_{{method}}_{{number}}_content' style='display:none'> <div class='content' id='{{parentId}}_{{nickname}}_content' style='display:none'>
{{#if notes}} {{#if notes}}
<h4>Implementation Notes</h4> <h4>Implementation Notes</h4>
<p>{{{notes}}}</p> <p>{{{notes}}}</p>

View File

@@ -1,19 +1,19 @@
<div class='heading'> <div class='heading'>
<h2> <h2>
<a href='#!/{{name}}' onclick="Docs.toggleEndpointListForResource('{{name}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}} <a href='#!/{{id}}' onclick="Docs.toggleEndpointListForResource('{{id}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
</h2> </h2>
<ul class='options'> <ul class='options'>
<li> <li>
<a href='#!/{{name}}' id='endpointListTogger_{{name}}' <a href='#!/{{id}}' id='endpointListTogger_{{id}}'
onclick="Docs.toggleEndpointListForResource('{{name}}');">Show/Hide</a> onclick="Docs.toggleEndpointListForResource('{{id}}');">Show/Hide</a>
</li> </li>
<li> <li>
<a href='#' onclick="Docs.collapseOperationsForResource('{{name}}'); return false;"> <a href='#' onclick="Docs.collapseOperationsForResource('{{id}}'); return false;">
List Operations List Operations
</a> </a>
</li> </li>
<li> <li>
<a href='#' onclick="Docs.expandOperationsForResource('{{name}}'); return false;"> <a href='#' onclick="Docs.expandOperationsForResource('{{id}}'); return false;">
Expand Operations Expand Operations
</a> </a>
</li> </li>
@@ -22,6 +22,6 @@
</li> </li>
</ul> </ul>
</div> </div>
<ul class='endpoints' id='{{name}}_endpoint_list' style='display:none'> <ul class='endpoints' id='{{id}}_endpoint_list' style='display:none'>
</ul> </ul>