Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

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