Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

1961 rader
78 KiB

  1. $(function() {
  2. // Helper function for vertically aligning DOM elements
  3. // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
  4. $.fn.vAlign = function() {
  5. return this.each(function(i){
  6. var ah = $(this).height();
  7. var ph = $(this).parent().height();
  8. var mh = (ph - ah) / 2;
  9. $(this).css('margin-top', mh);
  10. });
  11. };
  12. $.fn.stretchFormtasticInputWidthToParent = function() {
  13. return this.each(function(i){
  14. var p_width = $(this).closest("form").innerWidth();
  15. var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
  16. var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
  17. $(this).css('width', p_width - p_padding - this_padding);
  18. });
  19. };
  20. $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
  21. // Vertically center these paragraphs
  22. // Parent may need a min-height for this to work..
  23. $('ul.downplayed li div.content p').vAlign();
  24. // When a sandbox form is submitted..
  25. $("form.sandbox").submit(function(){
  26. var error_free = true;
  27. // Cycle through the forms required inputs
  28. $(this).find("input.required").each(function() {
  29. // Remove any existing error styles from the input
  30. $(this).removeClass('error');
  31. // Tack the error style on if the input is empty..
  32. if ($(this).val() == '') {
  33. $(this).addClass('error');
  34. $(this).wiggle();
  35. error_free = false;
  36. }
  37. });
  38. return error_free;
  39. });
  40. });
  41. function clippyCopiedCallback(a) {
  42. $('#api_key_copied').fadeIn().delay(1000).fadeOut();
  43. // var b = $("#clippy_tooltip_" + a);
  44. // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
  45. // b.attr("title", "copy to clipboard")
  46. // },
  47. // 500))
  48. }
  49. // Logging function that accounts for browsers that don't have window.console
  50. function log() {
  51. if (window.console) console.log.apply(console,arguments);
  52. }
  53. // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
  54. if (Function.prototype.bind && console && typeof console.log == "object") {
  55. [
  56. "log","info","warn","error","assert","dir","clear","profile","profileEnd"
  57. ].forEach(function (method) {
  58. console[method] = this.bind(console[method], console);
  59. }, Function.prototype.call);
  60. }
  61. var Docs = {
  62. shebang: function() {
  63. // If shebang has an operation nickname in it..
  64. // e.g. /docs/#!/words/get_search
  65. var fragments = $.param.fragment().split('/');
  66. fragments.shift(); // get rid of the bang
  67. switch (fragments.length) {
  68. case 1:
  69. // Expand all operations for the resource and scroll to it
  70. // log('shebang resource:' + fragments[0]);
  71. var dom_id = 'resource_' + fragments[0];
  72. Docs.expandEndpointListForResource(fragments[0]);
  73. $("#"+dom_id).slideto({highlight: false});
  74. break;
  75. case 2:
  76. // Refer to the endpoint DOM element, e.g. #words_get_search
  77. // log('shebang endpoint: ' + fragments.join('_'));
  78. // Expand Resource
  79. Docs.expandEndpointListForResource(fragments[0]);
  80. $("#"+dom_id).slideto({highlight: false});
  81. // Expand operation
  82. var li_dom_id = fragments.join('_');
  83. var li_content_dom_id = li_dom_id + "_content";
  84. // log("li_dom_id " + li_dom_id);
  85. // log("li_content_dom_id " + li_content_dom_id);
  86. Docs.expandOperation($('#'+li_content_dom_id));
  87. $('#'+li_dom_id).slideto({highlight: false});
  88. break;
  89. }
  90. },
  91. toggleEndpointListForResource: function(resource) {
  92. var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
  93. if (elem.is(':visible')) {
  94. Docs.collapseEndpointListForResource(resource);
  95. } else {
  96. Docs.expandEndpointListForResource(resource);
  97. }
  98. },
  99. // Expand resource
  100. expandEndpointListForResource: function(resource) {
  101. var resource = Docs.escapeResourceName(resource);
  102. if (resource == '') {
  103. $('.resource ul.endpoints').slideDown();
  104. return;
  105. }
  106. $('li#resource_' + resource).addClass('active');
  107. var elem = $('li#resource_' + resource + ' ul.endpoints');
  108. elem.slideDown();
  109. },
  110. // Collapse resource and mark as explicitly closed
  111. collapseEndpointListForResource: function(resource) {
  112. var resource = Docs.escapeResourceName(resource);
  113. $('li#resource_' + resource).removeClass('active');
  114. var elem = $('li#resource_' + resource + ' ul.endpoints');
  115. elem.slideUp();
  116. },
  117. expandOperationsForResource: function(resource) {
  118. // Make sure the resource container is open..
  119. Docs.expandEndpointListForResource(resource);
  120. if (resource == '') {
  121. $('.resource ul.endpoints li.operation div.content').slideDown();
  122. return;
  123. }
  124. $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
  125. Docs.expandOperation($(this));
  126. });
  127. },
  128. collapseOperationsForResource: function(resource) {
  129. // Make sure the resource container is open..
  130. Docs.expandEndpointListForResource(resource);
  131. $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
  132. Docs.collapseOperation($(this));
  133. });
  134. },
  135. escapeResourceName: function(resource) {
  136. return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
  137. },
  138. expandOperation: function(elem) {
  139. elem.slideDown();
  140. },
  141. collapseOperation: function(elem) {
  142. elem.slideUp();
  143. }
  144. };
  145. (function() {
  146. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  147. templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  148. this.compilerInfo = [4,'>= 1.0.0'];
  149. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  150. var buffer = "", stack1, functionType="function", self=this;
  151. function program1(depth0,data) {
  152. var buffer = "", stack1;
  153. buffer += "\n ";
  154. stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  155. if(stack1 || stack1 === 0) { buffer += stack1; }
  156. buffer += "\n";
  157. return buffer;
  158. }
  159. function program2(depth0,data) {
  160. var buffer = "", stack1;
  161. buffer += "\n <option value=\"";
  162. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  163. if(stack1 || stack1 === 0) { buffer += stack1; }
  164. buffer += "\">";
  165. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  166. if(stack1 || stack1 === 0) { buffer += stack1; }
  167. buffer += "</option>\n ";
  168. return buffer;
  169. }
  170. function program4(depth0,data) {
  171. return "\n <option value=\"application/json\">application/json</option>\n";
  172. }
  173. buffer += "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n";
  174. stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  175. if(stack1 || stack1 === 0) { buffer += stack1; }
  176. buffer += "\n</select>\n";
  177. return buffer;
  178. });
  179. })();
  180. (function() {
  181. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  182. templates['main'] = template(function (Handlebars,depth0,helpers,partials,data) {
  183. this.compilerInfo = [4,'>= 1.0.0'];
  184. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  185. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  186. function program1(depth0,data) {
  187. var buffer = "", stack1, stack2;
  188. buffer += "\n <div class=\"info_title\">"
  189. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  190. + "</div>\n <div class=\"info_description\">";
  191. stack2 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.description)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1);
  192. if(stack2 || stack2 === 0) { buffer += stack2; }
  193. buffer += "</div>\n ";
  194. stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  195. if(stack2 || stack2 === 0) { buffer += stack2; }
  196. buffer += "\n ";
  197. stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
  198. if(stack2 || stack2 === 0) { buffer += stack2; }
  199. buffer += "\n ";
  200. stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
  201. if(stack2 || stack2 === 0) { buffer += stack2; }
  202. buffer += "\n ";
  203. return buffer;
  204. }
  205. function program2(depth0,data) {
  206. var buffer = "", stack1;
  207. buffer += "<div class=\"info_tos\"><a href=\""
  208. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  209. + "\">Terms of service</a></div>";
  210. return buffer;
  211. }
  212. function program4(depth0,data) {
  213. var buffer = "", stack1;
  214. buffer += "<div class='info_contact'><a href=\"mailto:"
  215. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  216. + "\">Contact the developer</a></div>";
  217. return buffer;
  218. }
  219. function program6(depth0,data) {
  220. var buffer = "", stack1;
  221. buffer += "<div class='info_license'><a href='"
  222. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.licenseUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  223. + "'>"
  224. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  225. + "</a></div>";
  226. return buffer;
  227. }
  228. function program8(depth0,data) {
  229. var buffer = "", stack1;
  230. buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: ";
  231. if (stack1 = helpers.apiVersion) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  232. else { stack1 = depth0.apiVersion; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  233. buffer += escapeExpression(stack1)
  234. + "\n ";
  235. return buffer;
  236. }
  237. buffer += "<div class='info' id='api_info'>\n ";
  238. stack1 = helpers['if'].call(depth0, depth0.info, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
  239. if(stack1 || stack1 === 0) { buffer += stack1; }
  240. buffer += "\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
  241. if (stack1 = helpers.basePath) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  242. else { stack1 = depth0.basePath; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  243. buffer += escapeExpression(stack1)
  244. + "\n ";
  245. stack1 = helpers['if'].call(depth0, depth0.apiVersion, {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
  246. if(stack1 || stack1 === 0) { buffer += stack1; }
  247. buffer += "]</h4>\n </div>\n</div>\n";
  248. return buffer;
  249. });
  250. })();
  251. (function() {
  252. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  253. templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) {
  254. this.compilerInfo = [4,'>= 1.0.0'];
  255. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  256. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  257. function program1(depth0,data) {
  258. var buffer = "", stack1;
  259. buffer += "\n <h4>Implementation Notes</h4>\n <p>";
  260. if (stack1 = helpers.notes) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  261. else { stack1 = depth0.notes; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  262. if(stack1 || stack1 === 0) { buffer += stack1; }
  263. buffer += "</p>\n ";
  264. return buffer;
  265. }
  266. function program3(depth0,data) {
  267. return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
  268. }
  269. function program5(depth0,data) {
  270. return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\">Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
  271. }
  272. function program7(depth0,data) {
  273. return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
  274. }
  275. function program9(depth0,data) {
  276. return "\n ";
  277. }
  278. function program11(depth0,data) {
  279. return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";
  280. }
  281. buffer += "\n <ul class='operations' >\n <li class='";
  282. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  283. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  284. buffer += escapeExpression(stack1)
  285. + " operation' id='";
  286. if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  287. else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  288. buffer += escapeExpression(stack1)
  289. + "_";
  290. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  291. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  292. buffer += escapeExpression(stack1)
  293. + "_";
  294. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  295. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  296. buffer += escapeExpression(stack1)
  297. + "_";
  298. if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  299. else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  300. buffer += escapeExpression(stack1)
  301. + "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";
  302. if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  303. else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  304. buffer += escapeExpression(stack1)
  305. + "/";
  306. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  307. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  308. buffer += escapeExpression(stack1)
  309. + "_";
  310. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  311. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  312. buffer += escapeExpression(stack1)
  313. + "_";
  314. if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  315. else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  316. buffer += escapeExpression(stack1)
  317. + "' class=\"toggleOperation\">";
  318. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  319. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  320. buffer += escapeExpression(stack1)
  321. + "</a>\n </span>\n <span class='path'>\n <a href='#!/";
  322. if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  323. else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  324. buffer += escapeExpression(stack1)
  325. + "/";
  326. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  327. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  328. buffer += escapeExpression(stack1)
  329. + "_";
  330. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  331. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  332. buffer += escapeExpression(stack1)
  333. + "_";
  334. if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  335. else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  336. buffer += escapeExpression(stack1)
  337. + "' class=\"toggleOperation\">";
  338. if (stack1 = helpers.path) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  339. else { stack1 = depth0.path; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  340. buffer += escapeExpression(stack1)
  341. + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
  342. if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  343. else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  344. buffer += escapeExpression(stack1)
  345. + "/";
  346. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  347. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  348. buffer += escapeExpression(stack1)
  349. + "_";
  350. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  351. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  352. buffer += escapeExpression(stack1)
  353. + "_";
  354. if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  355. else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  356. buffer += escapeExpression(stack1)
  357. + "' class=\"toggleOperation\">";
  358. if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  359. else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  360. if(stack1 || stack1 === 0) { buffer += stack1; }
  361. buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";
  362. if (stack1 = helpers.resourceName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  363. else { stack1 = depth0.resourceName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  364. buffer += escapeExpression(stack1)
  365. + "_";
  366. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  367. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  368. buffer += escapeExpression(stack1)
  369. + "_";
  370. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  371. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  372. buffer += escapeExpression(stack1)
  373. + "_";
  374. if (stack1 = helpers.number) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  375. else { stack1 = depth0.number; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  376. buffer += escapeExpression(stack1)
  377. + "_content' style='display:none'>\n ";
  378. stack1 = helpers['if'].call(depth0, depth0.notes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
  379. if(stack1 || stack1 === 0) { buffer += stack1; }
  380. buffer += "\n ";
  381. stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
  382. if(stack1 || stack1 === 0) { buffer += stack1; }
  383. buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
  384. stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
  385. if(stack1 || stack1 === 0) { buffer += stack1; }
  386. buffer += "\n ";
  387. stack1 = helpers['if'].call(depth0, depth0.errorResponses, {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data});
  388. if(stack1 || stack1 === 0) { buffer += stack1; }
  389. buffer += "\n ";
  390. stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
  391. if(stack1 || stack1 === 0) { buffer += stack1; }
  392. buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
  393. return buffer;
  394. });
  395. })();
  396. (function() {
  397. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  398. templates['param'] = template(function (Handlebars,depth0,helpers,partials,data) {
  399. this.compilerInfo = [4,'>= 1.0.0'];
  400. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  401. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  402. function program1(depth0,data) {
  403. var buffer = "", stack1;
  404. buffer += "\n ";
  405. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data});
  406. if(stack1 || stack1 === 0) { buffer += stack1; }
  407. buffer += "\n ";
  408. return buffer;
  409. }
  410. function program2(depth0,data) {
  411. var buffer = "", stack1;
  412. buffer += "\n <input type=\"file\" name='";
  413. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  414. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  415. buffer += escapeExpression(stack1)
  416. + "'/>\n <div class=\"parameter-content-type\" />\n ";
  417. return buffer;
  418. }
  419. function program4(depth0,data) {
  420. var buffer = "", stack1;
  421. buffer += "\n ";
  422. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
  423. if(stack1 || stack1 === 0) { buffer += stack1; }
  424. buffer += "\n ";
  425. return buffer;
  426. }
  427. function program5(depth0,data) {
  428. var buffer = "", stack1;
  429. buffer += "\n <textarea class='body-textarea' name='";
  430. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  431. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  432. buffer += escapeExpression(stack1)
  433. + "'>";
  434. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  435. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  436. buffer += escapeExpression(stack1)
  437. + "</textarea>\n ";
  438. return buffer;
  439. }
  440. function program7(depth0,data) {
  441. var buffer = "", stack1;
  442. buffer += "\n <textarea class='body-textarea' name='";
  443. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  444. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  445. buffer += escapeExpression(stack1)
  446. + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
  447. return buffer;
  448. }
  449. function program9(depth0,data) {
  450. var buffer = "", stack1;
  451. buffer += "\n ";
  452. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data});
  453. if(stack1 || stack1 === 0) { buffer += stack1; }
  454. buffer += "\n ";
  455. return buffer;
  456. }
  457. function program10(depth0,data) {
  458. var buffer = "", stack1;
  459. buffer += "\n <input class='parameter' minlength='0' name='";
  460. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  461. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  462. buffer += escapeExpression(stack1)
  463. + "' placeholder='' type='text' value='";
  464. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  465. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  466. buffer += escapeExpression(stack1)
  467. + "'/>\n ";
  468. return buffer;
  469. }
  470. function program12(depth0,data) {
  471. var buffer = "", stack1;
  472. buffer += "\n <input class='parameter' minlength='0' name='";
  473. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  474. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  475. buffer += escapeExpression(stack1)
  476. + "' placeholder='' type='text' value=''/>\n ";
  477. return buffer;
  478. }
  479. buffer += "<td class='code'>";
  480. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  481. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  482. buffer += escapeExpression(stack1)
  483. + "</td>\n<td>\n\n ";
  484. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data});
  485. if(stack1 || stack1 === 0) { buffer += stack1; }
  486. buffer += "\n\n</td>\n<td>";
  487. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  488. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  489. if(stack1 || stack1 === 0) { buffer += stack1; }
  490. buffer += "</td>\n<td>";
  491. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  492. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  493. if(stack1 || stack1 === 0) { buffer += stack1; }
  494. buffer += "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n";
  495. return buffer;
  496. });
  497. })();
  498. (function() {
  499. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  500. templates['param_list'] = template(function (Handlebars,depth0,helpers,partials,data) {
  501. this.compilerInfo = [4,'>= 1.0.0'];
  502. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  503. var buffer = "", stack1, stack2, self=this, functionType="function", escapeExpression=this.escapeExpression;
  504. function program1(depth0,data) {
  505. return "\n ";
  506. }
  507. function program3(depth0,data) {
  508. var buffer = "", stack1;
  509. buffer += "\n ";
  510. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
  511. if(stack1 || stack1 === 0) { buffer += stack1; }
  512. buffer += "\n ";
  513. return buffer;
  514. }
  515. function program4(depth0,data) {
  516. return "\n ";
  517. }
  518. function program6(depth0,data) {
  519. return "\n <option selected=\"\" value=''></option>\n ";
  520. }
  521. function program8(depth0,data) {
  522. var buffer = "", stack1;
  523. buffer += "\n ";
  524. stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data});
  525. if(stack1 || stack1 === 0) { buffer += stack1; }
  526. buffer += "\n ";
  527. return buffer;
  528. }
  529. function program9(depth0,data) {
  530. var buffer = "", stack1;
  531. buffer += "\n <option value='";
  532. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  533. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  534. buffer += escapeExpression(stack1)
  535. + "'>";
  536. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  537. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  538. buffer += escapeExpression(stack1)
  539. + " (default)</option>\n ";
  540. return buffer;
  541. }
  542. function program11(depth0,data) {
  543. var buffer = "", stack1;
  544. buffer += "\n <option value='";
  545. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  546. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  547. buffer += escapeExpression(stack1)
  548. + "'>";
  549. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  550. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  551. buffer += escapeExpression(stack1)
  552. + "</option>\n ";
  553. return buffer;
  554. }
  555. buffer += "<td class='code'>";
  556. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  557. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  558. buffer += escapeExpression(stack1)
  559. + "</td>\n<td>\n <select class='parameter' name='";
  560. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  561. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  562. buffer += escapeExpression(stack1)
  563. + "'>\n ";
  564. stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
  565. if(stack1 || stack1 === 0) { buffer += stack1; }
  566. buffer += "\n ";
  567. stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
  568. if(stack2 || stack2 === 0) { buffer += stack2; }
  569. buffer += "\n </select>\n</td>\n<td>";
  570. if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
  571. else { stack2 = depth0.description; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
  572. if(stack2 || stack2 === 0) { buffer += stack2; }
  573. buffer += "</td>\n<td>";
  574. if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
  575. else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
  576. if(stack2 || stack2 === 0) { buffer += stack2; }
  577. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  578. return buffer;
  579. });
  580. })();
  581. (function() {
  582. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  583. templates['param_readonly'] = template(function (Handlebars,depth0,helpers,partials,data) {
  584. this.compilerInfo = [4,'>= 1.0.0'];
  585. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  586. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  587. function program1(depth0,data) {
  588. var buffer = "", stack1;
  589. buffer += "\n <textarea class='body-textarea' readonly='readonly' name='";
  590. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  591. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  592. buffer += escapeExpression(stack1)
  593. + "'>";
  594. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  595. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  596. buffer += escapeExpression(stack1)
  597. + "</textarea>\n ";
  598. return buffer;
  599. }
  600. function program3(depth0,data) {
  601. var buffer = "", stack1;
  602. buffer += "\n ";
  603. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
  604. if(stack1 || stack1 === 0) { buffer += stack1; }
  605. buffer += "\n ";
  606. return buffer;
  607. }
  608. function program4(depth0,data) {
  609. var buffer = "", stack1;
  610. buffer += "\n ";
  611. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  612. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  613. buffer += escapeExpression(stack1)
  614. + "\n ";
  615. return buffer;
  616. }
  617. function program6(depth0,data) {
  618. return "\n (empty)\n ";
  619. }
  620. buffer += "<td class='code'>";
  621. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  622. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  623. buffer += escapeExpression(stack1)
  624. + "</td>\n<td>\n ";
  625. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
  626. if(stack1 || stack1 === 0) { buffer += stack1; }
  627. buffer += "\n</td>\n<td>";
  628. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  629. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  630. if(stack1 || stack1 === 0) { buffer += stack1; }
  631. buffer += "</td>\n<td>";
  632. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  633. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  634. if(stack1 || stack1 === 0) { buffer += stack1; }
  635. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  636. return buffer;
  637. });
  638. })();
  639. (function() {
  640. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  641. templates['param_readonly_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
  642. this.compilerInfo = [4,'>= 1.0.0'];
  643. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  644. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  645. function program1(depth0,data) {
  646. var buffer = "", stack1;
  647. buffer += "\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";
  648. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  649. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  650. buffer += escapeExpression(stack1)
  651. + "'>";
  652. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  653. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  654. buffer += escapeExpression(stack1)
  655. + "</textarea>\n ";
  656. return buffer;
  657. }
  658. function program3(depth0,data) {
  659. var buffer = "", stack1;
  660. buffer += "\n ";
  661. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
  662. if(stack1 || stack1 === 0) { buffer += stack1; }
  663. buffer += "\n ";
  664. return buffer;
  665. }
  666. function program4(depth0,data) {
  667. var buffer = "", stack1;
  668. buffer += "\n ";
  669. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  670. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  671. buffer += escapeExpression(stack1)
  672. + "\n ";
  673. return buffer;
  674. }
  675. function program6(depth0,data) {
  676. return "\n (empty)\n ";
  677. }
  678. buffer += "<td class='code required'>";
  679. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  680. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  681. buffer += escapeExpression(stack1)
  682. + "</td>\n<td>\n ";
  683. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
  684. if(stack1 || stack1 === 0) { buffer += stack1; }
  685. buffer += "\n</td>\n<td>";
  686. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  687. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  688. if(stack1 || stack1 === 0) { buffer += stack1; }
  689. buffer += "</td>\n<td>";
  690. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  691. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  692. if(stack1 || stack1 === 0) { buffer += stack1; }
  693. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  694. return buffer;
  695. });
  696. })();
  697. (function() {
  698. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  699. templates['param_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
  700. this.compilerInfo = [4,'>= 1.0.0'];
  701. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  702. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  703. function program1(depth0,data) {
  704. var buffer = "", stack1;
  705. buffer += "\n ";
  706. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data});
  707. if(stack1 || stack1 === 0) { buffer += stack1; }
  708. buffer += "\n ";
  709. return buffer;
  710. }
  711. function program2(depth0,data) {
  712. var buffer = "", stack1;
  713. buffer += "\n <input type=\"file\" name='";
  714. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  715. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  716. buffer += escapeExpression(stack1)
  717. + "'/>\n ";
  718. return buffer;
  719. }
  720. function program4(depth0,data) {
  721. var buffer = "", stack1;
  722. buffer += "\n ";
  723. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
  724. if(stack1 || stack1 === 0) { buffer += stack1; }
  725. buffer += "\n ";
  726. return buffer;
  727. }
  728. function program5(depth0,data) {
  729. var buffer = "", stack1;
  730. buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
  731. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  732. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  733. buffer += escapeExpression(stack1)
  734. + "'>";
  735. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  736. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  737. buffer += escapeExpression(stack1)
  738. + "</textarea>\n ";
  739. return buffer;
  740. }
  741. function program7(depth0,data) {
  742. var buffer = "", stack1;
  743. buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
  744. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  745. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  746. buffer += escapeExpression(stack1)
  747. + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
  748. return buffer;
  749. }
  750. function program9(depth0,data) {
  751. var buffer = "", stack1;
  752. buffer += "\n ";
  753. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data});
  754. if(stack1 || stack1 === 0) { buffer += stack1; }
  755. buffer += "\n ";
  756. return buffer;
  757. }
  758. function program10(depth0,data) {
  759. var buffer = "", stack1;
  760. buffer += "\n <input class='parameter' class='required' type='file' name='";
  761. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  762. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  763. buffer += escapeExpression(stack1)
  764. + "'/>\n ";
  765. return buffer;
  766. }
  767. function program12(depth0,data) {
  768. var buffer = "", stack1;
  769. buffer += "\n ";
  770. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(15, program15, data),fn:self.program(13, program13, data),data:data});
  771. if(stack1 || stack1 === 0) { buffer += stack1; }
  772. buffer += "\n ";
  773. return buffer;
  774. }
  775. function program13(depth0,data) {
  776. var buffer = "", stack1;
  777. buffer += "\n <input class='parameter required' minlength='1' name='";
  778. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  779. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  780. buffer += escapeExpression(stack1)
  781. + "' placeholder='(required)' type='text' value='";
  782. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  783. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  784. buffer += escapeExpression(stack1)
  785. + "'/>\n ";
  786. return buffer;
  787. }
  788. function program15(depth0,data) {
  789. var buffer = "", stack1;
  790. buffer += "\n <input class='parameter required' minlength='1' name='";
  791. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  792. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  793. buffer += escapeExpression(stack1)
  794. + "' placeholder='(required)' type='text' value=''/>\n ";
  795. return buffer;
  796. }
  797. buffer += "<td class='code required'>";
  798. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  799. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  800. buffer += escapeExpression(stack1)
  801. + "</td>\n<td>\n ";
  802. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data});
  803. if(stack1 || stack1 === 0) { buffer += stack1; }
  804. buffer += "\n</td>\n<td>\n <strong>";
  805. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  806. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  807. if(stack1 || stack1 === 0) { buffer += stack1; }
  808. buffer += "</strong>\n</td>\n<td>";
  809. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  810. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  811. if(stack1 || stack1 === 0) { buffer += stack1; }
  812. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  813. return buffer;
  814. });
  815. })();
  816. (function() {
  817. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  818. templates['parameter_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  819. this.compilerInfo = [4,'>= 1.0.0'];
  820. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  821. var buffer = "", stack1, functionType="function", self=this;
  822. function program1(depth0,data) {
  823. var buffer = "", stack1;
  824. buffer += "\n ";
  825. stack1 = helpers.each.call(depth0, depth0.consumes, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  826. if(stack1 || stack1 === 0) { buffer += stack1; }
  827. buffer += "\n";
  828. return buffer;
  829. }
  830. function program2(depth0,data) {
  831. var buffer = "", stack1;
  832. buffer += "\n <option value=\"";
  833. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  834. if(stack1 || stack1 === 0) { buffer += stack1; }
  835. buffer += "\">";
  836. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  837. if(stack1 || stack1 === 0) { buffer += stack1; }
  838. buffer += "</option>\n ";
  839. return buffer;
  840. }
  841. function program4(depth0,data) {
  842. return "\n <option value=\"application/json\">application/json</option>\n";
  843. }
  844. buffer += "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
  845. stack1 = helpers['if'].call(depth0, depth0.consumes, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  846. if(stack1 || stack1 === 0) { buffer += stack1; }
  847. buffer += "\n</select>\n";
  848. return buffer;
  849. });
  850. })();
  851. (function() {
  852. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  853. templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) {
  854. this.compilerInfo = [4,'>= 1.0.0'];
  855. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  856. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  857. buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
  858. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  859. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  860. buffer += escapeExpression(stack1)
  861. + "' onclick=\"Docs.toggleEndpointListForResource('";
  862. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  863. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  864. buffer += escapeExpression(stack1)
  865. + "');\">";
  866. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  867. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  868. buffer += escapeExpression(stack1)
  869. + "</a>\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
  870. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  871. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  872. buffer += escapeExpression(stack1)
  873. + "' id='endpointListTogger_";
  874. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  875. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  876. buffer += escapeExpression(stack1)
  877. + "'\n onclick=\"Docs.toggleEndpointListForResource('";
  878. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  879. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  880. buffer += escapeExpression(stack1)
  881. + "');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";
  882. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  883. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  884. buffer += escapeExpression(stack1)
  885. + "'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";
  886. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  887. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  888. buffer += escapeExpression(stack1)
  889. + "'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
  890. if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  891. else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  892. buffer += escapeExpression(stack1)
  893. + "'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";
  894. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  895. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  896. buffer += escapeExpression(stack1)
  897. + "_endpoint_list' style='display:none'>\n\n</ul>\n";
  898. return buffer;
  899. });
  900. })();
  901. (function() {
  902. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  903. templates['response_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  904. this.compilerInfo = [4,'>= 1.0.0'];
  905. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  906. var buffer = "", stack1, functionType="function", self=this;
  907. function program1(depth0,data) {
  908. var buffer = "", stack1;
  909. buffer += "\n ";
  910. stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  911. if(stack1 || stack1 === 0) { buffer += stack1; }
  912. buffer += "\n";
  913. return buffer;
  914. }
  915. function program2(depth0,data) {
  916. var buffer = "", stack1;
  917. buffer += "\n <option value=\"";
  918. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  919. if(stack1 || stack1 === 0) { buffer += stack1; }
  920. buffer += "\">";
  921. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  922. if(stack1 || stack1 === 0) { buffer += stack1; }
  923. buffer += "</option>\n ";
  924. return buffer;
  925. }
  926. function program4(depth0,data) {
  927. return "\n <option value=\"application/json\">application/json</option>\n";
  928. }
  929. buffer += "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
  930. stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  931. if(stack1 || stack1 === 0) { buffer += stack1; }
  932. buffer += "\n</select>\n";
  933. return buffer;
  934. });
  935. })();
  936. (function() {
  937. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  938. templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
  939. this.compilerInfo = [4,'>= 1.0.0'];
  940. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  941. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  942. buffer += "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\">Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\">Model Schema</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
  943. if (stack1 = helpers.signature) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  944. else { stack1 = depth0.signature; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  945. if(stack1 || stack1 === 0) { buffer += stack1; }
  946. buffer += "\n </div>\n\n <div class=\"snippet\">\n <pre><code>";
  947. if (stack1 = helpers.sampleJSON) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  948. else { stack1 = depth0.sampleJSON; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  949. buffer += escapeExpression(stack1)
  950. + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
  951. return buffer;
  952. });
  953. })();
  954. (function() {
  955. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  956. templates['status_code'] = template(function (Handlebars,depth0,helpers,partials,data) {
  957. this.compilerInfo = [4,'>= 1.0.0'];
  958. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  959. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  960. buffer += "<td width='15%' class='code'>";
  961. if (stack1 = helpers.code) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  962. else { stack1 = depth0.code; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  963. buffer += escapeExpression(stack1)
  964. + "</td>\n<td>";
  965. if (stack1 = helpers.reason) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  966. else { stack1 = depth0.reason; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  967. if(stack1 || stack1 === 0) { buffer += stack1; }
  968. buffer += "</td>\n\n";
  969. return buffer;
  970. });
  971. })();
  972. // Generated by CoffeeScript 1.4.0
  973. (function() {
  974. var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi,
  975. __hasProp = {}.hasOwnProperty,
  976. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  977. SwaggerUi = (function(_super) {
  978. __extends(SwaggerUi, _super);
  979. function SwaggerUi() {
  980. return SwaggerUi.__super__.constructor.apply(this, arguments);
  981. }
  982. SwaggerUi.prototype.dom_id = "swagger_ui";
  983. SwaggerUi.prototype.options = null;
  984. SwaggerUi.prototype.api = null;
  985. SwaggerUi.prototype.headerView = null;
  986. SwaggerUi.prototype.mainView = null;
  987. SwaggerUi.prototype.initialize = function(options) {
  988. var _this = this;
  989. if (options == null) {
  990. options = {};
  991. }
  992. if (options.dom_id != null) {
  993. this.dom_id = options.dom_id;
  994. delete options.dom_id;
  995. }
  996. if (!($('#' + this.dom_id) != null)) {
  997. $('body').append('<div id="' + this.dom_id + '"></div>');
  998. }
  999. this.options = options;
  1000. this.options.success = function() {
  1001. return _this.render();
  1002. };
  1003. this.options.progress = function(d) {
  1004. return _this.showMessage(d);
  1005. };
  1006. this.options.failure = function(d) {
  1007. return _this.onLoadFailure(d);
  1008. };
  1009. this.headerView = new HeaderView({
  1010. el: $('#header')
  1011. });
  1012. return this.headerView.on('update-swagger-ui', function(data) {
  1013. return _this.updateSwaggerUi(data);
  1014. });
  1015. };
  1016. SwaggerUi.prototype.updateSwaggerUi = function(data) {
  1017. this.options.url = data.url;
  1018. return this.load();
  1019. };
  1020. SwaggerUi.prototype.load = function() {
  1021. var url, _ref;
  1022. if ((_ref = this.mainView) != null) {
  1023. _ref.clear();
  1024. }
  1025. url = this.options.url;
  1026. if (url.indexOf("http") !== 0) {
  1027. url = this.buildUrl(window.location.href.toString(), url);
  1028. }
  1029. this.options.url = url;
  1030. this.headerView.update(url);
  1031. this.api = new SwaggerApi(this.options);
  1032. this.api.build();
  1033. return this.api;
  1034. };
  1035. SwaggerUi.prototype.render = function() {
  1036. var _this = this;
  1037. this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
  1038. this.mainView = new MainView({
  1039. model: this.api,
  1040. el: $('#' + this.dom_id)
  1041. }).render();
  1042. this.showMessage();
  1043. switch (this.options.docExpansion) {
  1044. case "full":
  1045. Docs.expandOperationsForResource('');
  1046. break;
  1047. case "list":
  1048. Docs.collapseOperationsForResource('');
  1049. }
  1050. if (this.options.onComplete) {
  1051. this.options.onComplete(this.api, this);
  1052. }
  1053. return setTimeout(function() {
  1054. return Docs.shebang();
  1055. }, 400);
  1056. };
  1057. SwaggerUi.prototype.buildUrl = function(base, url) {
  1058. var parts;
  1059. console.log("base is " + base);
  1060. parts = base.split("/");
  1061. base = parts[0] + "//" + parts[2];
  1062. if (url.indexOf("/") === 0) {
  1063. return base + url;
  1064. } else {
  1065. return base + "/" + url;
  1066. }
  1067. };
  1068. SwaggerUi.prototype.showMessage = function(data) {
  1069. if (data == null) {
  1070. data = '';
  1071. }
  1072. $('#message-bar').removeClass('message-fail');
  1073. $('#message-bar').addClass('message-success');
  1074. return $('#message-bar').html(data);
  1075. };
  1076. SwaggerUi.prototype.onLoadFailure = function(data) {
  1077. var val;
  1078. if (data == null) {
  1079. data = '';
  1080. }
  1081. $('#message-bar').removeClass('message-success');
  1082. $('#message-bar').addClass('message-fail');
  1083. val = $('#message-bar').html(data);
  1084. if (this.options.onFailure != null) {
  1085. this.options.onFailure(data);
  1086. }
  1087. return val;
  1088. };
  1089. return SwaggerUi;
  1090. })(Backbone.Router);
  1091. window.SwaggerUi = SwaggerUi;
  1092. HeaderView = (function(_super) {
  1093. __extends(HeaderView, _super);
  1094. function HeaderView() {
  1095. return HeaderView.__super__.constructor.apply(this, arguments);
  1096. }
  1097. HeaderView.prototype.events = {
  1098. 'click #show-pet-store-icon': 'showPetStore',
  1099. 'click #show-wordnik-dev-icon': 'showWordnikDev',
  1100. 'click #explore': 'showCustom',
  1101. 'keyup #input_baseUrl': 'showCustomOnKeyup',
  1102. 'keyup #input_apiKey': 'showCustomOnKeyup'
  1103. };
  1104. HeaderView.prototype.initialize = function() {};
  1105. HeaderView.prototype.showPetStore = function(e) {
  1106. return this.trigger('update-swagger-ui', {
  1107. url: "http://petstore.swagger.wordnik.com/api/api-docs"
  1108. });
  1109. };
  1110. HeaderView.prototype.showWordnikDev = function(e) {
  1111. return this.trigger('update-swagger-ui', {
  1112. url: "http://api.wordnik.com/v4/resources.json"
  1113. });
  1114. };
  1115. HeaderView.prototype.showCustomOnKeyup = function(e) {
  1116. if (e.keyCode === 13) {
  1117. return this.showCustom();
  1118. }
  1119. };
  1120. HeaderView.prototype.showCustom = function(e) {
  1121. if (e != null) {
  1122. e.preventDefault();
  1123. }
  1124. return this.trigger('update-swagger-ui', {
  1125. url: $('#input_baseUrl').val(),
  1126. apiKey: $('#input_apiKey').val()
  1127. });
  1128. };
  1129. HeaderView.prototype.update = function(url, apiKey, trigger) {
  1130. if (trigger == null) {
  1131. trigger = false;
  1132. }
  1133. $('#input_baseUrl').val(url);
  1134. if (trigger) {
  1135. return this.trigger('update-swagger-ui', {
  1136. url: url
  1137. });
  1138. }
  1139. };
  1140. return HeaderView;
  1141. })(Backbone.View);
  1142. MainView = (function(_super) {
  1143. __extends(MainView, _super);
  1144. function MainView() {
  1145. return MainView.__super__.constructor.apply(this, arguments);
  1146. }
  1147. MainView.prototype.initialize = function() {};
  1148. MainView.prototype.render = function() {
  1149. var resource, _i, _len, _ref;
  1150. $(this.el).html(Handlebars.templates.main(this.model));
  1151. _ref = this.model.apisArray;
  1152. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1153. resource = _ref[_i];
  1154. this.addResource(resource);
  1155. }
  1156. return this;
  1157. };
  1158. MainView.prototype.addResource = function(resource) {
  1159. var resourceView;
  1160. resourceView = new ResourceView({
  1161. model: resource,
  1162. tagName: 'li',
  1163. id: 'resource_' + resource.name,
  1164. className: 'resource'
  1165. });
  1166. return $('#resources').append(resourceView.render().el);
  1167. };
  1168. MainView.prototype.clear = function() {
  1169. return $(this.el).html('');
  1170. };
  1171. return MainView;
  1172. })(Backbone.View);
  1173. ResourceView = (function(_super) {
  1174. __extends(ResourceView, _super);
  1175. function ResourceView() {
  1176. return ResourceView.__super__.constructor.apply(this, arguments);
  1177. }
  1178. ResourceView.prototype.initialize = function() {};
  1179. ResourceView.prototype.render = function() {
  1180. var operation, _i, _len, _ref;
  1181. $(this.el).html(Handlebars.templates.resource(this.model));
  1182. this.number = 0;
  1183. _ref = this.model.operationsArray;
  1184. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1185. operation = _ref[_i];
  1186. this.addOperation(operation);
  1187. }
  1188. return this;
  1189. };
  1190. ResourceView.prototype.addOperation = function(operation) {
  1191. var operationView;
  1192. operation.number = this.number;
  1193. operationView = new OperationView({
  1194. model: operation,
  1195. tagName: 'li',
  1196. className: 'endpoint'
  1197. });
  1198. $('.endpoints', $(this.el)).append(operationView.render().el);
  1199. return this.number++;
  1200. };
  1201. return ResourceView;
  1202. })(Backbone.View);
  1203. OperationView = (function(_super) {
  1204. __extends(OperationView, _super);
  1205. function OperationView() {
  1206. return OperationView.__super__.constructor.apply(this, arguments);
  1207. }
  1208. OperationView.prototype.events = {
  1209. 'submit .sandbox': 'submitOperation',
  1210. 'click .submit': 'submitOperation',
  1211. 'click .response_hider': 'hideResponse',
  1212. 'click .toggleOperation': 'toggleOperationContent'
  1213. };
  1214. OperationView.prototype.initialize = function() {};
  1215. OperationView.prototype.render = function() {
  1216. var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
  1217. isMethodSubmissionSupported = true;
  1218. if (!isMethodSubmissionSupported) {
  1219. this.model.isReadOnly = true;
  1220. }
  1221. $(this.el).html(Handlebars.templates.operation(this.model));
  1222. if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
  1223. signatureModel = {
  1224. sampleJSON: this.model.responseSampleJSON,
  1225. isParam: false,
  1226. signature: this.model.responseClassSignature
  1227. };
  1228. responseSignatureView = new SignatureView({
  1229. model: signatureModel,
  1230. tagName: 'div'
  1231. });
  1232. $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
  1233. } else {
  1234. $('.model-signature', $(this.el)).html(this.model.type);
  1235. }
  1236. contentTypeModel = {
  1237. isParam: false
  1238. };
  1239. contentTypeModel.consumes = this.model.consumes;
  1240. contentTypeModel.produces = this.model.produces;
  1241. _ref = this.model.parameters;
  1242. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1243. param = _ref[_i];
  1244. type = param.type || param.dataType;
  1245. if (type.toLowerCase() === 'file') {
  1246. if (!contentTypeModel.consumes) {
  1247. console.log("set content type ");
  1248. contentTypeModel.consumes = 'multipart/form-data';
  1249. }
  1250. }
  1251. }
  1252. responseContentTypeView = new ResponseContentTypeView({
  1253. model: contentTypeModel
  1254. });
  1255. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  1256. _ref1 = this.model.parameters;
  1257. for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  1258. param = _ref1[_j];
  1259. this.addParameter(param, contentTypeModel.consumes);
  1260. }
  1261. _ref2 = this.model.responseMessages;
  1262. for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
  1263. statusCode = _ref2[_k];
  1264. this.addStatusCode(statusCode);
  1265. }
  1266. return this;
  1267. };
  1268. OperationView.prototype.addParameter = function(param, consumes) {
  1269. var paramView;
  1270. param.consumes = consumes;
  1271. paramView = new ParameterView({
  1272. model: param,
  1273. tagName: 'tr',
  1274. readOnly: this.model.isReadOnly
  1275. });
  1276. return $('.operation-params', $(this.el)).append(paramView.render().el);
  1277. };
  1278. OperationView.prototype.addStatusCode = function(statusCode) {
  1279. var statusCodeView;
  1280. statusCodeView = new StatusCodeView({
  1281. model: statusCode,
  1282. tagName: 'tr'
  1283. });
  1284. return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
  1285. };
  1286. OperationView.prototype.submitOperation = function(e) {
  1287. var error_free, form, map, o, opts, _i, _j, _len, _len1, _ref, _ref1;
  1288. if (e != null) {
  1289. e.preventDefault();
  1290. }
  1291. form = $('.sandbox', $(this.el));
  1292. error_free = true;
  1293. form.find("input.required").each(function() {
  1294. var _this = this;
  1295. $(this).removeClass("error");
  1296. if (jQuery.trim($(this).val()) === "") {
  1297. $(this).addClass("error");
  1298. $(this).wiggle({
  1299. callback: function() {
  1300. return $(_this).focus();
  1301. }
  1302. });
  1303. return error_free = false;
  1304. }
  1305. });
  1306. if (error_free) {
  1307. map = {};
  1308. opts = {
  1309. parent: this
  1310. };
  1311. _ref = form.find("input");
  1312. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1313. o = _ref[_i];
  1314. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1315. map[o.name] = encodeURI(o.value);
  1316. }
  1317. }
  1318. _ref1 = form.find("textarea");
  1319. for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  1320. o = _ref1[_j];
  1321. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1322. map["body"] = o.value;
  1323. }
  1324. }
  1325. opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
  1326. opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
  1327. return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
  1328. }
  1329. };
  1330. OperationView.prototype.success = function(response, parent) {
  1331. return parent.showCompleteStatus(response);
  1332. };
  1333. OperationView.prototype.hideResponse = function(e) {
  1334. if (e != null) {
  1335. e.preventDefault();
  1336. }
  1337. $(".response", $(this.el)).slideUp();
  1338. return $(".response_hider", $(this.el)).fadeOut();
  1339. };
  1340. OperationView.prototype.showResponse = function(response) {
  1341. var prettyJson;
  1342. prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
  1343. return $(".response_body", $(this.el)).html(escape(prettyJson));
  1344. };
  1345. OperationView.prototype.showErrorStatus = function(data, parent) {
  1346. return parent.showStatus(data);
  1347. };
  1348. OperationView.prototype.showCompleteStatus = function(data, parent) {
  1349. return parent.showStatus(data);
  1350. };
  1351. OperationView.prototype.formatXml = function(xml) {
  1352. var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
  1353. reg = /(>)(<)(\/*)/g;
  1354. wsexp = /[ ]*(.*)[ ]+\n/g;
  1355. contexp = /(<.+>)(.+\n)/g;
  1356. xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
  1357. pad = 0;
  1358. formatted = '';
  1359. lines = xml.split('\n');
  1360. indent = 0;
  1361. lastType = 'other';
  1362. transitions = {
  1363. 'single->single': 0,
  1364. 'single->closing': -1,
  1365. 'single->opening': 0,
  1366. 'single->other': 0,
  1367. 'closing->single': 0,
  1368. 'closing->closing': -1,
  1369. 'closing->opening': 0,
  1370. 'closing->other': 0,
  1371. 'opening->single': 1,
  1372. 'opening->closing': 0,
  1373. 'opening->opening': 1,
  1374. 'opening->other': 1,
  1375. 'other->single': 0,
  1376. 'other->closing': -1,
  1377. 'other->opening': 0,
  1378. 'other->other': 0
  1379. };
  1380. _fn = function(ln) {
  1381. var fromTo, j, key, padding, type, types, value;
  1382. types = {
  1383. single: Boolean(ln.match(/<.+\/>/)),
  1384. closing: Boolean(ln.match(/<\/.+>/)),
  1385. opening: Boolean(ln.match(/<[^!?].*>/))
  1386. };
  1387. type = ((function() {
  1388. var _results;
  1389. _results = [];
  1390. for (key in types) {
  1391. value = types[key];
  1392. if (value) {
  1393. _results.push(key);
  1394. }
  1395. }
  1396. return _results;
  1397. })())[0];
  1398. type = type === void 0 ? 'other' : type;
  1399. fromTo = lastType + '->' + type;
  1400. lastType = type;
  1401. padding = '';
  1402. indent += transitions[fromTo];
  1403. padding = ((function() {
  1404. var _j, _ref, _results;
  1405. _results = [];
  1406. for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
  1407. _results.push(' ');
  1408. }
  1409. return _results;
  1410. })()).join('');
  1411. if (fromTo === 'opening->closing') {
  1412. return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
  1413. } else {
  1414. return formatted += padding + ln + '\n';
  1415. }
  1416. };
  1417. for (_i = 0, _len = lines.length; _i < _len; _i++) {
  1418. ln = lines[_i];
  1419. _fn(ln);
  1420. }
  1421. return formatted;
  1422. };
  1423. OperationView.prototype.showStatus = function(data) {
  1424. var code, content, contentType, headers, pre, response_body;
  1425. content = data.content.data;
  1426. headers = data.getHeaders();
  1427. contentType = headers["Content-Type"];
  1428. if (content === void 0) {
  1429. code = $('<code />').text("no content");
  1430. pre = $('<pre class="json" />').append(code);
  1431. } else if (contentType.indexOf("application/json") === 0) {
  1432. code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
  1433. pre = $('<pre class="json" />').append(code);
  1434. } else if (contentType.indexOf("application/xml") === 0) {
  1435. code = $('<code />').text(this.formatXml(content));
  1436. pre = $('<pre class="xml" />').append(code);
  1437. } else if (contentType.indexOf("text/html") === 0) {
  1438. code = $('<code />').html(content);
  1439. pre = $('<pre class="xml" />').append(code);
  1440. } else {
  1441. code = $('<code />').text(content);
  1442. pre = $('<pre class="json" />').append(code);
  1443. }
  1444. response_body = pre;
  1445. $(".request_url").html("<pre>" + data.request.url + "</pre>");
  1446. $(".response_code", $(this.el)).html("<pre>" + data.status + "</pre>");
  1447. $(".response_body", $(this.el)).html(response_body);
  1448. $(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(data.getHeaders()) + "</pre>");
  1449. $(".response", $(this.el)).slideDown();
  1450. $(".response_hider", $(this.el)).show();
  1451. $(".response_throbber", $(this.el)).hide();
  1452. return hljs.highlightBlock($('.response_body', $(this.el))[0]);
  1453. };
  1454. OperationView.prototype.toggleOperationContent = function() {
  1455. var elem;
  1456. elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.method + "_" + this.model.number + "_content");
  1457. if (elem.is(':visible')) {
  1458. return Docs.collapseOperation(elem);
  1459. } else {
  1460. return Docs.expandOperation(elem);
  1461. }
  1462. };
  1463. return OperationView;
  1464. })(Backbone.View);
  1465. StatusCodeView = (function(_super) {
  1466. __extends(StatusCodeView, _super);
  1467. function StatusCodeView() {
  1468. return StatusCodeView.__super__.constructor.apply(this, arguments);
  1469. }
  1470. StatusCodeView.prototype.initialize = function() {};
  1471. StatusCodeView.prototype.render = function() {
  1472. var template;
  1473. template = this.template();
  1474. $(this.el).html(template(this.model));
  1475. return this;
  1476. };
  1477. StatusCodeView.prototype.template = function() {
  1478. return Handlebars.templates.status_code;
  1479. };
  1480. return StatusCodeView;
  1481. })(Backbone.View);
  1482. ParameterView = (function(_super) {
  1483. __extends(ParameterView, _super);
  1484. function ParameterView() {
  1485. return ParameterView.__super__.constructor.apply(this, arguments);
  1486. }
  1487. ParameterView.prototype.initialize = function() {};
  1488. ParameterView.prototype.render = function() {
  1489. var contentTypeModel, isParam, parameterContentTypeView, responseContentTypeView, signatureModel, signatureView, template, type;
  1490. type = this.model.type || this.model.dataType;
  1491. if (this.model.paramType === 'body') {
  1492. this.model.isBody = true;
  1493. }
  1494. if (type.toLowerCase() === 'file') {
  1495. this.model.isFile = true;
  1496. }
  1497. template = this.template();
  1498. $(this.el).html(template(this.model));
  1499. signatureModel = {
  1500. sampleJSON: this.model.sampleJSON,
  1501. isParam: true,
  1502. signature: this.model.signature
  1503. };
  1504. if (this.model.sampleJSON) {
  1505. signatureView = new SignatureView({
  1506. model: signatureModel,
  1507. tagName: 'div'
  1508. });
  1509. $('.model-signature', $(this.el)).append(signatureView.render().el);
  1510. } else {
  1511. $('.model-signature', $(this.el)).html(this.model.signature);
  1512. }
  1513. isParam = false;
  1514. if (this.model.isBody) {
  1515. isParam = true;
  1516. }
  1517. contentTypeModel = {
  1518. isParam: isParam
  1519. };
  1520. contentTypeModel.consumes = this.model.consumes;
  1521. if (isParam) {
  1522. parameterContentTypeView = new ParameterContentTypeView({
  1523. model: contentTypeModel
  1524. });
  1525. $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
  1526. } else {
  1527. responseContentTypeView = new ResponseContentTypeView({
  1528. model: contentTypeModel
  1529. });
  1530. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  1531. }
  1532. return this;
  1533. };
  1534. ParameterView.prototype.template = function() {
  1535. if (this.model.isList) {
  1536. return Handlebars.templates.param_list;
  1537. } else {
  1538. if (this.options.readOnly) {
  1539. if (this.model.required) {
  1540. return Handlebars.templates.param_readonly_required;
  1541. } else {
  1542. return Handlebars.templates.param_readonly;
  1543. }
  1544. } else {
  1545. if (this.model.required) {
  1546. return Handlebars.templates.param_required;
  1547. } else {
  1548. return Handlebars.templates.param;
  1549. }
  1550. }
  1551. }
  1552. };
  1553. return ParameterView;
  1554. })(Backbone.View);
  1555. SignatureView = (function(_super) {
  1556. __extends(SignatureView, _super);
  1557. function SignatureView() {
  1558. return SignatureView.__super__.constructor.apply(this, arguments);
  1559. }
  1560. SignatureView.prototype.events = {
  1561. 'click a.description-link': 'switchToDescription',
  1562. 'click a.snippet-link': 'switchToSnippet',
  1563. 'mousedown .snippet': 'snippetToTextArea'
  1564. };
  1565. SignatureView.prototype.initialize = function() {};
  1566. SignatureView.prototype.render = function() {
  1567. var template;
  1568. template = this.template();
  1569. $(this.el).html(template(this.model));
  1570. this.switchToDescription();
  1571. this.isParam = this.model.isParam;
  1572. if (this.isParam) {
  1573. $('.notice', $(this.el)).text('Click to set as parameter value');
  1574. }
  1575. return this;
  1576. };
  1577. SignatureView.prototype.template = function() {
  1578. return Handlebars.templates.signature;
  1579. };
  1580. SignatureView.prototype.switchToDescription = function(e) {
  1581. if (e != null) {
  1582. e.preventDefault();
  1583. }
  1584. $(".snippet", $(this.el)).hide();
  1585. $(".description", $(this.el)).show();
  1586. $('.description-link', $(this.el)).addClass('selected');
  1587. return $('.snippet-link', $(this.el)).removeClass('selected');
  1588. };
  1589. SignatureView.prototype.switchToSnippet = function(e) {
  1590. if (e != null) {
  1591. e.preventDefault();
  1592. }
  1593. $(".description", $(this.el)).hide();
  1594. $(".snippet", $(this.el)).show();
  1595. $('.snippet-link', $(this.el)).addClass('selected');
  1596. return $('.description-link', $(this.el)).removeClass('selected');
  1597. };
  1598. SignatureView.prototype.snippetToTextArea = function(e) {
  1599. var textArea;
  1600. if (this.isParam) {
  1601. if (e != null) {
  1602. e.preventDefault();
  1603. }
  1604. textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
  1605. if ($.trim(textArea.val()) === '') {
  1606. return textArea.val(this.model.sampleJSON);
  1607. }
  1608. }
  1609. };
  1610. return SignatureView;
  1611. })(Backbone.View);
  1612. ContentTypeView = (function(_super) {
  1613. __extends(ContentTypeView, _super);
  1614. function ContentTypeView() {
  1615. return ContentTypeView.__super__.constructor.apply(this, arguments);
  1616. }
  1617. ContentTypeView.prototype.initialize = function() {};
  1618. ContentTypeView.prototype.render = function() {
  1619. var template;
  1620. template = this.template();
  1621. $(this.el).html(template(this.model));
  1622. $('label[for=contentType]', $(this.el)).text('Response Content Type');
  1623. return this;
  1624. };
  1625. ContentTypeView.prototype.template = function() {
  1626. return Handlebars.templates.content_type;
  1627. };
  1628. return ContentTypeView;
  1629. })(Backbone.View);
  1630. ResponseContentTypeView = (function(_super) {
  1631. __extends(ResponseContentTypeView, _super);
  1632. function ResponseContentTypeView() {
  1633. return ResponseContentTypeView.__super__.constructor.apply(this, arguments);
  1634. }
  1635. ResponseContentTypeView.prototype.initialize = function() {};
  1636. ResponseContentTypeView.prototype.render = function() {
  1637. var template;
  1638. template = this.template();
  1639. $(this.el).html(template(this.model));
  1640. $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
  1641. return this;
  1642. };
  1643. ResponseContentTypeView.prototype.template = function() {
  1644. return Handlebars.templates.response_content_type;
  1645. };
  1646. return ResponseContentTypeView;
  1647. })(Backbone.View);
  1648. ParameterContentTypeView = (function(_super) {
  1649. __extends(ParameterContentTypeView, _super);
  1650. function ParameterContentTypeView() {
  1651. return ParameterContentTypeView.__super__.constructor.apply(this, arguments);
  1652. }
  1653. ParameterContentTypeView.prototype.initialize = function() {};
  1654. ParameterContentTypeView.prototype.render = function() {
  1655. var template;
  1656. template = this.template();
  1657. $(this.el).html(template(this.model));
  1658. $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
  1659. return this;
  1660. };
  1661. ParameterContentTypeView.prototype.template = function() {
  1662. return Handlebars.templates.parameter_content_type;
  1663. };
  1664. return ParameterContentTypeView;
  1665. })(Backbone.View);
  1666. }).call(this);