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

498
dist/swagger-ui.js vendored
View File

@@ -1,193 +1,191 @@
$(function() { $(function() {
// Helper function for vertically aligning DOM elements // Helper function for vertically aligning DOM elements
// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
$.fn.vAlign = function() { $.fn.vAlign = function() {
return this.each(function(i){ return this.each(function(i){
var ah = $(this).height(); var ah = $(this).height();
var ph = $(this).parent().height(); var ph = $(this).parent().height();
var mh = (ph - ah) / 2; var mh = (ph - ah) / 2;
$(this).css('margin-top', mh); $(this).css('margin-top', mh);
}); });
}; };
$.fn.stretchFormtasticInputWidthToParent = function() { $.fn.stretchFormtasticInputWidthToParent = function() {
return this.each(function(i){ return this.each(function(i){
var p_width = $(this).closest("form").innerWidth(); var p_width = $(this).closest("form").innerWidth();
var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10); var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
$(this).css('width', p_width - p_padding - this_padding); $(this).css('width', p_width - p_padding - this_padding);
}); });
}; };
$('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
// Vertically center these paragraphs // Vertically center these paragraphs
// Parent may need a min-height for this to work.. // Parent may need a min-height for this to work..
$('ul.downplayed li div.content p').vAlign(); $('ul.downplayed li div.content p').vAlign();
// When a sandbox form is submitted.. // When a sandbox form is submitted..
$("form.sandbox").submit(function(){ $("form.sandbox").submit(function(){
var error_free = true; var error_free = true;
// Cycle through the forms required inputs // Cycle through the forms required inputs
$(this).find("input.required").each(function() { $(this).find("input.required").each(function() {
// Remove any existing error styles from the input // Remove any existing error styles from the input
$(this).removeClass('error'); $(this).removeClass('error');
// Tack the error style on if the input is empty.. // Tack the error style on if the input is empty..
if ($(this).val() == '') { if ($(this).val() == '') {
$(this).addClass('error'); $(this).addClass('error');
$(this).wiggle(); $(this).wiggle();
error_free = false; error_free = false;
} }
}); });
return error_free; return error_free;
}); });
}); });
function clippyCopiedCallback(a) { function clippyCopiedCallback(a) {
$('#api_key_copied').fadeIn().delay(1000).fadeOut(); $('#api_key_copied').fadeIn().delay(1000).fadeOut();
// var b = $("#clippy_tooltip_" + a); // var b = $("#clippy_tooltip_" + a);
// b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
// b.attr("title", "copy to clipboard") // b.attr("title", "copy to clipboard")
// }, // },
// 500)) // 500))
} }
// Logging function that accounts for browsers that don't have window.console // Logging function that accounts for browsers that don't have window.console
log = function(){ log = function(){
log.history = log.history || []; log.history = log.history || [];
log.history.push(arguments); log.history.push(arguments);
if(this.console){ if(this.console){
console.log( Array.prototype.slice.call(arguments) ); console.log( Array.prototype.slice.call(arguments) );
} }
}; };
// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
if (Function.prototype.bind && console && typeof console.log == "object") { if (Function.prototype.bind && console && typeof console.log == "object") {
[ [
"log","info","warn","error","assert","dir","clear","profile","profileEnd" "log","info","warn","error","assert","dir","clear","profile","profileEnd"
].forEach(function (method) { ].forEach(function (method) {
console[method] = this.bind(console[method], console); console[method] = this.bind(console[method], console);
}, Function.prototype.call); }, Function.prototype.call);
} }
var Docs = { var Docs = {
shebang: function() { shebang: function() {
// If shebang has an operation nickname in it.. // If shebang has an operation nickname in it..
// e.g. /docs/#!/words/get_search // e.g. /docs/#!/words/get_search
var fragments = $.param.fragment().split('/'); var fragments = $.param.fragment().split('/');
fragments.shift(); // get rid of the bang fragments.shift(); // get rid of the bang
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]);
$("#"+dom_id).slideto({highlight: false}); $("#"+dom_id).slideto({highlight: false});
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]);
$("#"+dom_id).slideto({highlight: false}); $("#"+dom_id).slideto({highlight: false});
// Expand operation // Expand operation
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});
break; break;
} }
}, },
toggleEndpointListForResource: function(resource) { toggleEndpointListForResource: function(resource) {
var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
if (elem.is(':visible')) { if (elem.is(':visible')) {
Docs.collapseEndpointListForResource(resource); Docs.collapseEndpointListForResource(resource);
} else { } else {
Docs.expandEndpointListForResource(resource); Docs.expandEndpointListForResource(resource);
} }
}, },
// Expand resource // Expand resource
expandEndpointListForResource: function(resource) { expandEndpointListForResource: function(resource) {
var resource = Docs.escapeResourceName(resource); var resource = Docs.escapeResourceName(resource);
if (resource == '') { if (resource == '') {
$('.resource ul.endpoints').slideDown(); $('.resource ul.endpoints').slideDown();
return; return;
} }
$('li#resource_' + resource).addClass('active'); $('li#resource_' + resource).addClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints'); var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideDown(); elem.slideDown();
}, },
// Collapse resource and mark as explicitly closed // Collapse resource and mark as explicitly closed
collapseEndpointListForResource: function(resource) { collapseEndpointListForResource: function(resource) {
var resource = Docs.escapeResourceName(resource); var resource = Docs.escapeResourceName(resource);
$('li#resource_' + resource).removeClass('active'); $('li#resource_' + resource).removeClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints'); var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideUp(); elem.slideUp();
}, },
expandOperationsForResource: function(resource) { expandOperationsForResource: function(resource) {
// Make sure the resource container is open.. // Make sure the resource container is open..
Docs.expandEndpointListForResource(resource); Docs.expandEndpointListForResource(resource);
if (resource == '') { if (resource == '') {
$('.resource ul.endpoints li.operation div.content').slideDown(); $('.resource ul.endpoints li.operation div.content').slideDown();
return; return;
} }
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.expandOperation($(this)); Docs.expandOperation($(this));
}); });
}, },
collapseOperationsForResource: function(resource) { collapseOperationsForResource: function(resource) {
// Make sure the resource container is open.. // Make sure the resource container is open..
Docs.expandEndpointListForResource(resource); Docs.expandEndpointListForResource(resource);
$('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.collapseOperation($(this)); Docs.collapseOperation($(this));
}); });
}, },
escapeResourceName: function(resource) { escapeResourceName: function(resource) {
return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
}, },
expandOperation: function(elem) { expandOperation: function(elem) {
elem.slideDown(); elem.slideDown();
}, },
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

@@ -2,10 +2,10 @@ class OperationView extends Backbone.View
invocationUrl: null invocationUrl: null
events: { events: {
'submit .sandbox' : 'submitOperation' 'submit .sandbox' : 'submitOperation'
'click .submit' : 'submitOperation' 'click .submit' : 'submitOperation'
'click .response_hider' : 'hideResponse' 'click .response_hider' : 'hideResponse'
'click .toggleOperation' : 'toggleOperationContent' 'click .toggleOperation' : 'toggleOperationContent'
} }
initialize: -> initialize: ->
@@ -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,18 +99,18 @@ 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]);
$("#"+dom_id).slideto({highlight: false}); $("#"+dom_id).slideto({highlight: false});
// Expand operation // Expand operation
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>