25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

2120 lines
82 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.responseMessages, {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 " multiple='multiple'";
  506. }
  507. function program3(depth0,data) {
  508. return "\n ";
  509. }
  510. function program5(depth0,data) {
  511. var buffer = "", stack1;
  512. buffer += "\n ";
  513. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(8, program8, data),fn:self.program(6, program6, data),data:data});
  514. if(stack1 || stack1 === 0) { buffer += stack1; }
  515. buffer += "\n ";
  516. return buffer;
  517. }
  518. function program6(depth0,data) {
  519. return "\n ";
  520. }
  521. function program8(depth0,data) {
  522. var buffer = "", stack1;
  523. buffer += "\n ";
  524. stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {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. return "\n ";
  531. }
  532. function program11(depth0,data) {
  533. return "\n <option selected=\"\" value=''></option>\n ";
  534. }
  535. function program13(depth0,data) {
  536. var buffer = "", stack1;
  537. buffer += "\n ";
  538. stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data});
  539. if(stack1 || stack1 === 0) { buffer += stack1; }
  540. buffer += "\n ";
  541. return buffer;
  542. }
  543. function program14(depth0,data) {
  544. var buffer = "", stack1;
  545. buffer += "\n <option selected=\"\" value='";
  546. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  547. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  548. buffer += escapeExpression(stack1)
  549. + "'>";
  550. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  551. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  552. buffer += escapeExpression(stack1)
  553. + " (default)</option>\n ";
  554. return buffer;
  555. }
  556. function program16(depth0,data) {
  557. var buffer = "", stack1;
  558. buffer += "\n <option value='";
  559. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  560. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  561. buffer += escapeExpression(stack1)
  562. + "'>";
  563. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  564. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  565. buffer += escapeExpression(stack1)
  566. + "</option>\n ";
  567. return buffer;
  568. }
  569. buffer += "<td class='code'>";
  570. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  571. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  572. buffer += escapeExpression(stack1)
  573. + "</td>\n<td>\n <select ";
  574. stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
  575. if(stack1 || stack1 === 0) { buffer += stack1; }
  576. buffer += " class='parameter' name='";
  577. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  578. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  579. buffer += escapeExpression(stack1)
  580. + "'>\n ";
  581. stack1 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(5, program5, data),fn:self.program(3, program3, data),data:data});
  582. if(stack1 || stack1 === 0) { buffer += stack1; }
  583. buffer += "\n ";
  584. stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
  585. if(stack2 || stack2 === 0) { buffer += stack2; }
  586. buffer += "\n </select>\n</td>\n<td>";
  587. if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
  588. else { stack2 = depth0.description; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
  589. if(stack2 || stack2 === 0) { buffer += stack2; }
  590. buffer += "</td>\n<td>";
  591. if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
  592. else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
  593. if(stack2 || stack2 === 0) { buffer += stack2; }
  594. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>";
  595. return buffer;
  596. });
  597. })();
  598. (function() {
  599. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  600. templates['param_readonly'] = template(function (Handlebars,depth0,helpers,partials,data) {
  601. this.compilerInfo = [4,'>= 1.0.0'];
  602. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  603. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  604. function program1(depth0,data) {
  605. var buffer = "", stack1;
  606. buffer += "\n <textarea class='body-textarea' readonly='readonly' name='";
  607. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  608. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  609. buffer += escapeExpression(stack1)
  610. + "'>";
  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. + "</textarea>\n ";
  615. return buffer;
  616. }
  617. function program3(depth0,data) {
  618. var buffer = "", stack1;
  619. buffer += "\n ";
  620. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
  621. if(stack1 || stack1 === 0) { buffer += stack1; }
  622. buffer += "\n ";
  623. return buffer;
  624. }
  625. function program4(depth0,data) {
  626. var buffer = "", stack1;
  627. buffer += "\n ";
  628. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  629. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  630. buffer += escapeExpression(stack1)
  631. + "\n ";
  632. return buffer;
  633. }
  634. function program6(depth0,data) {
  635. return "\n (empty)\n ";
  636. }
  637. buffer += "<td class='code'>";
  638. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  639. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  640. buffer += escapeExpression(stack1)
  641. + "</td>\n<td>\n ";
  642. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
  643. if(stack1 || stack1 === 0) { buffer += stack1; }
  644. buffer += "\n</td>\n<td>";
  645. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  646. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  647. if(stack1 || stack1 === 0) { buffer += stack1; }
  648. buffer += "</td>\n<td>";
  649. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  650. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  651. if(stack1 || stack1 === 0) { buffer += stack1; }
  652. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  653. return buffer;
  654. });
  655. })();
  656. (function() {
  657. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  658. templates['param_readonly_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
  659. this.compilerInfo = [4,'>= 1.0.0'];
  660. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  661. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  662. function program1(depth0,data) {
  663. var buffer = "", stack1;
  664. buffer += "\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";
  665. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  666. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  667. buffer += escapeExpression(stack1)
  668. + "'>";
  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. + "</textarea>\n ";
  673. return buffer;
  674. }
  675. function program3(depth0,data) {
  676. var buffer = "", stack1;
  677. buffer += "\n ";
  678. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
  679. if(stack1 || stack1 === 0) { buffer += stack1; }
  680. buffer += "\n ";
  681. return buffer;
  682. }
  683. function program4(depth0,data) {
  684. var buffer = "", stack1;
  685. buffer += "\n ";
  686. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  687. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  688. buffer += escapeExpression(stack1)
  689. + "\n ";
  690. return buffer;
  691. }
  692. function program6(depth0,data) {
  693. return "\n (empty)\n ";
  694. }
  695. buffer += "<td class='code required'>";
  696. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  697. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  698. buffer += escapeExpression(stack1)
  699. + "</td>\n<td>\n ";
  700. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
  701. if(stack1 || stack1 === 0) { buffer += stack1; }
  702. buffer += "\n</td>\n<td>";
  703. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  704. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  705. if(stack1 || stack1 === 0) { buffer += stack1; }
  706. buffer += "</td>\n<td>";
  707. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  708. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  709. if(stack1 || stack1 === 0) { buffer += stack1; }
  710. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  711. return buffer;
  712. });
  713. })();
  714. (function() {
  715. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  716. templates['param_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
  717. this.compilerInfo = [4,'>= 1.0.0'];
  718. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  719. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  720. function program1(depth0,data) {
  721. var buffer = "", stack1;
  722. buffer += "\n ";
  723. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data});
  724. if(stack1 || stack1 === 0) { buffer += stack1; }
  725. buffer += "\n ";
  726. return buffer;
  727. }
  728. function program2(depth0,data) {
  729. var buffer = "", stack1;
  730. buffer += "\n <input type=\"file\" 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. + "'/>\n ";
  735. return buffer;
  736. }
  737. function program4(depth0,data) {
  738. var buffer = "", stack1;
  739. buffer += "\n ";
  740. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
  741. if(stack1 || stack1 === 0) { buffer += stack1; }
  742. buffer += "\n ";
  743. return buffer;
  744. }
  745. function program5(depth0,data) {
  746. var buffer = "", stack1;
  747. buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
  748. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  749. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  750. buffer += escapeExpression(stack1)
  751. + "'>";
  752. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  753. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  754. buffer += escapeExpression(stack1)
  755. + "</textarea>\n ";
  756. return buffer;
  757. }
  758. function program7(depth0,data) {
  759. var buffer = "", stack1;
  760. buffer += "\n <textarea class='body-textarea' placeholder='(required)' 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. + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
  765. return buffer;
  766. }
  767. function program9(depth0,data) {
  768. var buffer = "", stack1;
  769. buffer += "\n ";
  770. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data});
  771. if(stack1 || stack1 === 0) { buffer += stack1; }
  772. buffer += "\n ";
  773. return buffer;
  774. }
  775. function program10(depth0,data) {
  776. var buffer = "", stack1;
  777. buffer += "\n <input class='parameter' class='required' type='file' 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. + "'/>\n ";
  782. return buffer;
  783. }
  784. function program12(depth0,data) {
  785. var buffer = "", stack1;
  786. buffer += "\n ";
  787. stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(15, program15, data),fn:self.program(13, program13, data),data:data});
  788. if(stack1 || stack1 === 0) { buffer += stack1; }
  789. buffer += "\n ";
  790. return buffer;
  791. }
  792. function program13(depth0,data) {
  793. var buffer = "", stack1;
  794. buffer += "\n <input class='parameter required' minlength='1' name='";
  795. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  796. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  797. buffer += escapeExpression(stack1)
  798. + "' placeholder='(required)' type='text' value='";
  799. if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  800. else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  801. buffer += escapeExpression(stack1)
  802. + "'/>\n ";
  803. return buffer;
  804. }
  805. function program15(depth0,data) {
  806. var buffer = "", stack1;
  807. buffer += "\n <input class='parameter required' minlength='1' name='";
  808. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  809. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  810. buffer += escapeExpression(stack1)
  811. + "' placeholder='(required)' type='text' value=''/>\n ";
  812. return buffer;
  813. }
  814. buffer += "<td class='code required'>";
  815. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  816. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  817. buffer += escapeExpression(stack1)
  818. + "</td>\n<td>\n ";
  819. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data});
  820. if(stack1 || stack1 === 0) { buffer += stack1; }
  821. buffer += "\n</td>\n<td>\n <strong>";
  822. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  823. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  824. if(stack1 || stack1 === 0) { buffer += stack1; }
  825. buffer += "</strong>\n</td>\n<td>";
  826. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  827. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  828. if(stack1 || stack1 === 0) { buffer += stack1; }
  829. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  830. return buffer;
  831. });
  832. })();
  833. (function() {
  834. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  835. templates['parameter_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  836. this.compilerInfo = [4,'>= 1.0.0'];
  837. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  838. var buffer = "", stack1, functionType="function", self=this;
  839. function program1(depth0,data) {
  840. var buffer = "", stack1;
  841. buffer += "\n ";
  842. stack1 = helpers.each.call(depth0, depth0.consumes, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  843. if(stack1 || stack1 === 0) { buffer += stack1; }
  844. buffer += "\n";
  845. return buffer;
  846. }
  847. function program2(depth0,data) {
  848. var buffer = "", stack1;
  849. buffer += "\n <option value=\"";
  850. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  851. if(stack1 || stack1 === 0) { buffer += stack1; }
  852. buffer += "\">";
  853. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  854. if(stack1 || stack1 === 0) { buffer += stack1; }
  855. buffer += "</option>\n ";
  856. return buffer;
  857. }
  858. function program4(depth0,data) {
  859. return "\n <option value=\"application/json\">application/json</option>\n";
  860. }
  861. buffer += "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
  862. stack1 = helpers['if'].call(depth0, depth0.consumes, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  863. if(stack1 || stack1 === 0) { buffer += stack1; }
  864. buffer += "\n</select>\n";
  865. return buffer;
  866. });
  867. })();
  868. (function() {
  869. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  870. templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) {
  871. this.compilerInfo = [4,'>= 1.0.0'];
  872. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  873. var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing;
  874. function program1(depth0,data) {
  875. return " : ";
  876. }
  877. buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
  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. + "' onclick=\"Docs.toggleEndpointListForResource('";
  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. + "');\">";
  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. + "</a> ";
  890. options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data};
  891. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, options); }
  892. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  893. if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
  894. if(stack1 || stack1 === 0) { buffer += stack1; }
  895. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  896. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  897. if(stack1 || stack1 === 0) { buffer += stack1; }
  898. buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
  899. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  900. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  901. buffer += escapeExpression(stack1)
  902. + "' id='endpointListTogger_";
  903. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  904. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  905. buffer += escapeExpression(stack1)
  906. + "'\n onclick=\"Docs.toggleEndpointListForResource('";
  907. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  908. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  909. buffer += escapeExpression(stack1)
  910. + "');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";
  911. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  912. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  913. buffer += escapeExpression(stack1)
  914. + "'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";
  915. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  916. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  917. buffer += escapeExpression(stack1)
  918. + "'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
  919. if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  920. else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  921. buffer += escapeExpression(stack1)
  922. + "'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";
  923. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  924. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  925. buffer += escapeExpression(stack1)
  926. + "_endpoint_list' style='display:none'>\n\n</ul>\n";
  927. return buffer;
  928. });
  929. })();
  930. (function() {
  931. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  932. templates['response_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  933. this.compilerInfo = [4,'>= 1.0.0'];
  934. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  935. var buffer = "", stack1, functionType="function", self=this;
  936. function program1(depth0,data) {
  937. var buffer = "", stack1;
  938. buffer += "\n ";
  939. stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  940. if(stack1 || stack1 === 0) { buffer += stack1; }
  941. buffer += "\n";
  942. return buffer;
  943. }
  944. function program2(depth0,data) {
  945. var buffer = "", stack1;
  946. buffer += "\n <option value=\"";
  947. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  948. if(stack1 || stack1 === 0) { buffer += stack1; }
  949. buffer += "\">";
  950. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  951. if(stack1 || stack1 === 0) { buffer += stack1; }
  952. buffer += "</option>\n ";
  953. return buffer;
  954. }
  955. function program4(depth0,data) {
  956. return "\n <option value=\"application/json\">application/json</option>\n";
  957. }
  958. buffer += "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
  959. stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  960. if(stack1 || stack1 === 0) { buffer += stack1; }
  961. buffer += "\n</select>\n";
  962. return buffer;
  963. });
  964. })();
  965. (function() {
  966. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  967. templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
  968. this.compilerInfo = [4,'>= 1.0.0'];
  969. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  970. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  971. 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 ";
  972. if (stack1 = helpers.signature) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  973. else { stack1 = depth0.signature; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  974. if(stack1 || stack1 === 0) { buffer += stack1; }
  975. buffer += "\n </div>\n\n <div class=\"snippet\">\n <pre><code>";
  976. if (stack1 = helpers.sampleJSON) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  977. else { stack1 = depth0.sampleJSON; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  978. buffer += escapeExpression(stack1)
  979. + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
  980. return buffer;
  981. });
  982. })();
  983. (function() {
  984. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  985. templates['status_code'] = template(function (Handlebars,depth0,helpers,partials,data) {
  986. this.compilerInfo = [4,'>= 1.0.0'];
  987. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  988. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  989. buffer += "<td width='15%' class='code'>";
  990. if (stack1 = helpers.code) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  991. else { stack1 = depth0.code; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  992. buffer += escapeExpression(stack1)
  993. + "</td>\n<td>";
  994. if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  995. else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  996. if(stack1 || stack1 === 0) { buffer += stack1; }
  997. buffer += "</td>\n";
  998. return buffer;
  999. });
  1000. })();
  1001. // Generated by CoffeeScript 1.5.0
  1002. (function() {
  1003. var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi,
  1004. __hasProp = {}.hasOwnProperty,
  1005. __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; };
  1006. SwaggerUi = (function(_super) {
  1007. __extends(SwaggerUi, _super);
  1008. function SwaggerUi() {
  1009. SwaggerUi.__super__.constructor.apply(this, arguments);
  1010. }
  1011. SwaggerUi.prototype.dom_id = "swagger_ui";
  1012. SwaggerUi.prototype.options = null;
  1013. SwaggerUi.prototype.api = null;
  1014. SwaggerUi.prototype.headerView = null;
  1015. SwaggerUi.prototype.mainView = null;
  1016. SwaggerUi.prototype.initialize = function(options) {
  1017. var _this = this;
  1018. if (options == null) {
  1019. options = {};
  1020. }
  1021. if (options.dom_id != null) {
  1022. this.dom_id = options.dom_id;
  1023. delete options.dom_id;
  1024. }
  1025. if ($('#' + this.dom_id) == null) {
  1026. $('body').append('<div id="' + this.dom_id + '"></div>');
  1027. }
  1028. this.options = options;
  1029. this.options.success = function() {
  1030. return _this.render();
  1031. };
  1032. this.options.progress = function(d) {
  1033. return _this.showMessage(d);
  1034. };
  1035. this.options.failure = function(d) {
  1036. return _this.onLoadFailure(d);
  1037. };
  1038. this.headerView = new HeaderView({
  1039. el: $('#header')
  1040. });
  1041. return this.headerView.on('update-swagger-ui', function(data) {
  1042. return _this.updateSwaggerUi(data);
  1043. });
  1044. };
  1045. SwaggerUi.prototype.updateSwaggerUi = function(data) {
  1046. this.options.url = data.url;
  1047. return this.load();
  1048. };
  1049. SwaggerUi.prototype.load = function() {
  1050. var url, _ref;
  1051. if ((_ref = this.mainView) != null) {
  1052. _ref.clear();
  1053. }
  1054. url = this.options.url;
  1055. if (url.indexOf("http") !== 0) {
  1056. url = this.buildUrl(window.location.href.toString(), url);
  1057. }
  1058. this.options.url = url;
  1059. this.headerView.update(url);
  1060. this.api = new SwaggerApi(this.options);
  1061. this.api.build();
  1062. return this.api;
  1063. };
  1064. SwaggerUi.prototype.render = function() {
  1065. var _this = this;
  1066. this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
  1067. this.mainView = new MainView({
  1068. model: this.api,
  1069. el: $('#' + this.dom_id)
  1070. }).render();
  1071. this.showMessage();
  1072. switch (this.options.docExpansion) {
  1073. case "full":
  1074. Docs.expandOperationsForResource('');
  1075. break;
  1076. case "list":
  1077. Docs.collapseOperationsForResource('');
  1078. }
  1079. if (this.options.onComplete) {
  1080. this.options.onComplete(this.api, this);
  1081. }
  1082. return setTimeout(function() {
  1083. return Docs.shebang();
  1084. }, 400);
  1085. };
  1086. SwaggerUi.prototype.buildUrl = function(base, url) {
  1087. var parts;
  1088. console.log("base is " + base);
  1089. parts = base.split("/");
  1090. base = parts[0] + "//" + parts[2];
  1091. if (url.indexOf("/") === 0) {
  1092. return base + url;
  1093. } else {
  1094. return base + "/" + url;
  1095. }
  1096. };
  1097. SwaggerUi.prototype.showMessage = function(data) {
  1098. if (data == null) {
  1099. data = '';
  1100. }
  1101. $('#message-bar').removeClass('message-fail');
  1102. $('#message-bar').addClass('message-success');
  1103. return $('#message-bar').html(data);
  1104. };
  1105. SwaggerUi.prototype.onLoadFailure = function(data) {
  1106. var val;
  1107. if (data == null) {
  1108. data = '';
  1109. }
  1110. $('#message-bar').removeClass('message-success');
  1111. $('#message-bar').addClass('message-fail');
  1112. val = $('#message-bar').html(data);
  1113. if (this.options.onFailure != null) {
  1114. this.options.onFailure(data);
  1115. }
  1116. return val;
  1117. };
  1118. return SwaggerUi;
  1119. })(Backbone.Router);
  1120. window.SwaggerUi = SwaggerUi;
  1121. HeaderView = (function(_super) {
  1122. __extends(HeaderView, _super);
  1123. function HeaderView() {
  1124. HeaderView.__super__.constructor.apply(this, arguments);
  1125. }
  1126. HeaderView.prototype.events = {
  1127. 'click #show-pet-store-icon': 'showPetStore',
  1128. 'click #show-wordnik-dev-icon': 'showWordnikDev',
  1129. 'click #explore': 'showCustom',
  1130. 'keyup #input_baseUrl': 'showCustomOnKeyup',
  1131. 'keyup #input_apiKey': 'showCustomOnKeyup'
  1132. };
  1133. HeaderView.prototype.initialize = function() {};
  1134. HeaderView.prototype.showPetStore = function(e) {
  1135. return this.trigger('update-swagger-ui', {
  1136. url: "http://petstore.swagger.wordnik.com/api/api-docs"
  1137. });
  1138. };
  1139. HeaderView.prototype.showWordnikDev = function(e) {
  1140. return this.trigger('update-swagger-ui', {
  1141. url: "http://api.wordnik.com/v4/resources.json"
  1142. });
  1143. };
  1144. HeaderView.prototype.showCustomOnKeyup = function(e) {
  1145. if (e.keyCode === 13) {
  1146. return this.showCustom();
  1147. }
  1148. };
  1149. HeaderView.prototype.showCustom = function(e) {
  1150. if (e != null) {
  1151. e.preventDefault();
  1152. }
  1153. return this.trigger('update-swagger-ui', {
  1154. url: $('#input_baseUrl').val(),
  1155. apiKey: $('#input_apiKey').val()
  1156. });
  1157. };
  1158. HeaderView.prototype.update = function(url, apiKey, trigger) {
  1159. if (trigger == null) {
  1160. trigger = false;
  1161. }
  1162. $('#input_baseUrl').val(url);
  1163. if (trigger) {
  1164. return this.trigger('update-swagger-ui', {
  1165. url: url
  1166. });
  1167. }
  1168. };
  1169. return HeaderView;
  1170. })(Backbone.View);
  1171. MainView = (function(_super) {
  1172. __extends(MainView, _super);
  1173. function MainView() {
  1174. MainView.__super__.constructor.apply(this, arguments);
  1175. }
  1176. MainView.prototype.initialize = function() {};
  1177. MainView.prototype.render = function() {
  1178. var resource, _i, _len, _ref;
  1179. $(this.el).html(Handlebars.templates.main(this.model));
  1180. _ref = this.model.apisArray;
  1181. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1182. resource = _ref[_i];
  1183. this.addResource(resource);
  1184. }
  1185. return this;
  1186. };
  1187. MainView.prototype.addResource = function(resource) {
  1188. var resourceView;
  1189. resourceView = new ResourceView({
  1190. model: resource,
  1191. tagName: 'li',
  1192. id: 'resource_' + resource.name,
  1193. className: 'resource'
  1194. });
  1195. return $('#resources').append(resourceView.render().el);
  1196. };
  1197. MainView.prototype.clear = function() {
  1198. return $(this.el).html('');
  1199. };
  1200. return MainView;
  1201. })(Backbone.View);
  1202. ResourceView = (function(_super) {
  1203. __extends(ResourceView, _super);
  1204. function ResourceView() {
  1205. ResourceView.__super__.constructor.apply(this, arguments);
  1206. }
  1207. ResourceView.prototype.initialize = function() {};
  1208. ResourceView.prototype.render = function() {
  1209. var operation, _i, _len, _ref;
  1210. console.log(this.model.description);
  1211. $(this.el).html(Handlebars.templates.resource(this.model));
  1212. this.number = 0;
  1213. _ref = this.model.operationsArray;
  1214. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1215. operation = _ref[_i];
  1216. this.addOperation(operation);
  1217. }
  1218. return this;
  1219. };
  1220. ResourceView.prototype.addOperation = function(operation) {
  1221. var operationView;
  1222. operation.number = this.number;
  1223. operationView = new OperationView({
  1224. model: operation,
  1225. tagName: 'li',
  1226. className: 'endpoint'
  1227. });
  1228. $('.endpoints', $(this.el)).append(operationView.render().el);
  1229. return this.number++;
  1230. };
  1231. return ResourceView;
  1232. })(Backbone.View);
  1233. OperationView = (function(_super) {
  1234. __extends(OperationView, _super);
  1235. function OperationView() {
  1236. OperationView.__super__.constructor.apply(this, arguments);
  1237. }
  1238. OperationView.prototype.invocationUrl = null;
  1239. OperationView.prototype.events = {
  1240. 'submit .sandbox': 'submitOperation',
  1241. 'click .submit': 'submitOperation',
  1242. 'click .response_hider': 'hideResponse',
  1243. 'click .toggleOperation': 'toggleOperationContent'
  1244. };
  1245. OperationView.prototype.initialize = function() {};
  1246. OperationView.prototype.render = function() {
  1247. var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
  1248. isMethodSubmissionSupported = true;
  1249. if (!isMethodSubmissionSupported) {
  1250. this.model.isReadOnly = true;
  1251. }
  1252. $(this.el).html(Handlebars.templates.operation(this.model));
  1253. if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
  1254. signatureModel = {
  1255. sampleJSON: this.model.responseSampleJSON,
  1256. isParam: false,
  1257. signature: this.model.responseClassSignature
  1258. };
  1259. responseSignatureView = new SignatureView({
  1260. model: signatureModel,
  1261. tagName: 'div'
  1262. });
  1263. $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
  1264. } else {
  1265. $('.model-signature', $(this.el)).html(this.model.type);
  1266. }
  1267. contentTypeModel = {
  1268. isParam: false
  1269. };
  1270. contentTypeModel.consumes = this.model.consumes;
  1271. contentTypeModel.produces = this.model.produces;
  1272. _ref = this.model.parameters;
  1273. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1274. param = _ref[_i];
  1275. type = param.type || param.dataType;
  1276. if (type.toLowerCase() === 'file') {
  1277. if (!contentTypeModel.consumes) {
  1278. console.log("set content type ");
  1279. contentTypeModel.consumes = 'multipart/form-data';
  1280. }
  1281. }
  1282. }
  1283. responseContentTypeView = new ResponseContentTypeView({
  1284. model: contentTypeModel
  1285. });
  1286. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  1287. _ref1 = this.model.parameters;
  1288. for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  1289. param = _ref1[_j];
  1290. this.addParameter(param, contentTypeModel.consumes);
  1291. }
  1292. _ref2 = this.model.responseMessages;
  1293. for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
  1294. statusCode = _ref2[_k];
  1295. this.addStatusCode(statusCode);
  1296. }
  1297. return this;
  1298. };
  1299. OperationView.prototype.addParameter = function(param, consumes) {
  1300. var paramView;
  1301. param.consumes = consumes;
  1302. paramView = new ParameterView({
  1303. model: param,
  1304. tagName: 'tr',
  1305. readOnly: this.model.isReadOnly
  1306. });
  1307. return $('.operation-params', $(this.el)).append(paramView.render().el);
  1308. };
  1309. OperationView.prototype.addStatusCode = function(statusCode) {
  1310. var statusCodeView;
  1311. statusCodeView = new StatusCodeView({
  1312. model: statusCode,
  1313. tagName: 'tr'
  1314. });
  1315. return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
  1316. };
  1317. OperationView.prototype.submitOperation = function(e) {
  1318. var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
  1319. if (e != null) {
  1320. e.preventDefault();
  1321. }
  1322. form = $('.sandbox', $(this.el));
  1323. error_free = true;
  1324. form.find("input.required").each(function() {
  1325. var _this = this;
  1326. $(this).removeClass("error");
  1327. if (jQuery.trim($(this).val()) === "") {
  1328. $(this).addClass("error");
  1329. $(this).wiggle({
  1330. callback: function() {
  1331. return $(_this).focus();
  1332. }
  1333. });
  1334. return error_free = false;
  1335. }
  1336. });
  1337. if (error_free) {
  1338. map = {};
  1339. opts = {
  1340. parent: this
  1341. };
  1342. isFileUpload = false;
  1343. _ref = form.find("input");
  1344. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1345. o = _ref[_i];
  1346. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1347. map[o.name] = o.value;
  1348. }
  1349. if (o.type === "file") {
  1350. isFileUpload = true;
  1351. }
  1352. }
  1353. _ref1 = form.find("textarea");
  1354. for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  1355. o = _ref1[_j];
  1356. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1357. map["body"] = o.value;
  1358. }
  1359. }
  1360. _ref2 = form.find("select");
  1361. for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
  1362. o = _ref2[_k];
  1363. val = this.getSelectedValue(o);
  1364. if ((val != null) && jQuery.trim(val).length > 0) {
  1365. map[o.name] = val;
  1366. }
  1367. }
  1368. opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
  1369. opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
  1370. $(".response_throbber", $(this.el)).show();
  1371. if (isFileUpload) {
  1372. return this.handleFileUpload(map, form);
  1373. } else {
  1374. return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
  1375. }
  1376. }
  1377. };
  1378. OperationView.prototype.success = function(response, parent) {
  1379. return parent.showCompleteStatus(response);
  1380. };
  1381. OperationView.prototype.handleFileUpload = function(map, form) {
  1382. var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3,
  1383. _this = this;
  1384. console.log("it's a file upload");
  1385. _ref = form.serializeArray();
  1386. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1387. o = _ref[_i];
  1388. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1389. map[o.name] = o.value;
  1390. }
  1391. }
  1392. bodyParam = new FormData();
  1393. _ref1 = this.model.parameters;
  1394. for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
  1395. param = _ref1[_j];
  1396. if (param.paramType === 'form') {
  1397. bodyParam.append(param.name, map[param.name]);
  1398. }
  1399. }
  1400. headerParams = {};
  1401. _ref2 = this.model.parameters;
  1402. for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
  1403. param = _ref2[_k];
  1404. if (param.paramType === 'header') {
  1405. headerParams[param.name] = map[param.name];
  1406. }
  1407. }
  1408. console.log(headerParams);
  1409. _ref3 = form.find('input[type~="file"]');
  1410. for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
  1411. el = _ref3[_l];
  1412. bodyParam.append($(el).attr('name'), el.files[0]);
  1413. }
  1414. console.log(bodyParam);
  1415. this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
  1416. $(".request_url", $(this.el)).html("<pre>" + this.invocationUrl + "</pre>");
  1417. obj = {
  1418. type: this.model.method,
  1419. url: this.invocationUrl,
  1420. headers: headerParams,
  1421. data: bodyParam,
  1422. dataType: 'json',
  1423. contentType: false,
  1424. processData: false,
  1425. error: function(data, textStatus, error) {
  1426. return _this.showErrorStatus(_this.wrap(data), _this);
  1427. },
  1428. success: function(data) {
  1429. return _this.showResponse(data, _this);
  1430. },
  1431. complete: function(data) {
  1432. return _this.showCompleteStatus(_this.wrap(data), _this);
  1433. }
  1434. };
  1435. if (window.authorizations) {
  1436. window.authorizations.apply(obj);
  1437. }
  1438. jQuery.ajax(obj);
  1439. return false;
  1440. };
  1441. OperationView.prototype.wrap = function(data) {
  1442. var o,
  1443. _this = this;
  1444. o = {};
  1445. o.content = {};
  1446. o.content.data = data.responseText;
  1447. o.getHeaders = function() {
  1448. return {
  1449. "Content-Type": data.getResponseHeader("Content-Type")
  1450. };
  1451. };
  1452. o.request = {};
  1453. o.request.url = this.invocationUrl;
  1454. o.status = data.status;
  1455. return o;
  1456. };
  1457. OperationView.prototype.getSelectedValue = function(select) {
  1458. var opt, options, _i, _len, _ref;
  1459. if (!select.multiple) {
  1460. return select.value;
  1461. } else {
  1462. options = [];
  1463. _ref = select.options;
  1464. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  1465. opt = _ref[_i];
  1466. if (opt.selected) {
  1467. options.push(opt.value);
  1468. }
  1469. }
  1470. if (options.length > 0) {
  1471. return options.join(",");
  1472. } else {
  1473. return null;
  1474. }
  1475. }
  1476. };
  1477. OperationView.prototype.hideResponse = function(e) {
  1478. if (e != null) {
  1479. e.preventDefault();
  1480. }
  1481. $(".response", $(this.el)).slideUp();
  1482. return $(".response_hider", $(this.el)).fadeOut();
  1483. };
  1484. OperationView.prototype.showResponse = function(response) {
  1485. var prettyJson;
  1486. prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
  1487. return $(".response_body", $(this.el)).html(escape(prettyJson));
  1488. };
  1489. OperationView.prototype.showErrorStatus = function(data, parent) {
  1490. return parent.showStatus(data);
  1491. };
  1492. OperationView.prototype.showCompleteStatus = function(data, parent) {
  1493. return parent.showStatus(data);
  1494. };
  1495. OperationView.prototype.formatXml = function(xml) {
  1496. var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
  1497. reg = /(>)(<)(\/*)/g;
  1498. wsexp = /[ ]*(.*)[ ]+\n/g;
  1499. contexp = /(<.+>)(.+\n)/g;
  1500. xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
  1501. pad = 0;
  1502. formatted = '';
  1503. lines = xml.split('\n');
  1504. indent = 0;
  1505. lastType = 'other';
  1506. transitions = {
  1507. 'single->single': 0,
  1508. 'single->closing': -1,
  1509. 'single->opening': 0,
  1510. 'single->other': 0,
  1511. 'closing->single': 0,
  1512. 'closing->closing': -1,
  1513. 'closing->opening': 0,
  1514. 'closing->other': 0,
  1515. 'opening->single': 1,
  1516. 'opening->closing': 0,
  1517. 'opening->opening': 1,
  1518. 'opening->other': 1,
  1519. 'other->single': 0,
  1520. 'other->closing': -1,
  1521. 'other->opening': 0,
  1522. 'other->other': 0
  1523. };
  1524. _fn = function(ln) {
  1525. var fromTo, j, key, padding, type, types, value;
  1526. types = {
  1527. single: Boolean(ln.match(/<.+\/>/)),
  1528. closing: Boolean(ln.match(/<\/.+>/)),
  1529. opening: Boolean(ln.match(/<[^!?].*>/))
  1530. };
  1531. type = ((function() {
  1532. var _results;
  1533. _results = [];
  1534. for (key in types) {
  1535. value = types[key];
  1536. if (value) {
  1537. _results.push(key);
  1538. }
  1539. }
  1540. return _results;
  1541. })())[0];
  1542. type = type === void 0 ? 'other' : type;
  1543. fromTo = lastType + '->' + type;
  1544. lastType = type;
  1545. padding = '';
  1546. indent += transitions[fromTo];
  1547. padding = ((function() {
  1548. var _j, _ref, _results;
  1549. _results = [];
  1550. for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
  1551. _results.push(' ');
  1552. }
  1553. return _results;
  1554. })()).join('');
  1555. if (fromTo === 'opening->closing') {
  1556. return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
  1557. } else {
  1558. return formatted += padding + ln + '\n';
  1559. }
  1560. };
  1561. for (_i = 0, _len = lines.length; _i < _len; _i++) {
  1562. ln = lines[_i];
  1563. _fn(ln);
  1564. }
  1565. return formatted;
  1566. };
  1567. OperationView.prototype.showStatus = function(data) {
  1568. var code, content, contentType, headers, pre, response_body;
  1569. content = data.content.data;
  1570. headers = data.getHeaders();
  1571. contentType = headers["Content-Type"];
  1572. if (content === void 0) {
  1573. code = $('<code />').text("no content");
  1574. pre = $('<pre class="json" />').append(code);
  1575. } else if (contentType.indexOf("application/json") === 0 || contentType.indexOf("application/hal+json") === 0) {
  1576. code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
  1577. pre = $('<pre class="json" />').append(code);
  1578. } else if (contentType.indexOf("application/xml") === 0) {
  1579. code = $('<code />').text(this.formatXml(content));
  1580. pre = $('<pre class="xml" />').append(code);
  1581. } else if (contentType.indexOf("text/html") === 0) {
  1582. code = $('<code />').html(content);
  1583. pre = $('<pre class="xml" />').append(code);
  1584. } else if (contentType.indexOf("image/") === 0) {
  1585. pre = $('<img>').attr('src', data.request.url);
  1586. } else {
  1587. code = $('<code />').text(content);
  1588. pre = $('<pre class="json" />').append(code);
  1589. }
  1590. response_body = pre;
  1591. $(".request_url", $(this.el)).html("<pre>" + data.request.url + "</pre>");
  1592. $(".response_code", $(this.el)).html("<pre>" + data.status + "</pre>");
  1593. $(".response_body", $(this.el)).html(response_body);
  1594. $(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(data.getHeaders(), null, " ").replace(/\n/g, "<br>") + "</pre>");
  1595. $(".response", $(this.el)).slideDown();
  1596. $(".response_hider", $(this.el)).show();
  1597. $(".response_throbber", $(this.el)).hide();
  1598. return hljs.highlightBlock($('.response_body', $(this.el))[0]);
  1599. };
  1600. OperationView.prototype.toggleOperationContent = function() {
  1601. var elem;
  1602. elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.method + "_" + this.model.number + "_content");
  1603. if (elem.is(':visible')) {
  1604. return Docs.collapseOperation(elem);
  1605. } else {
  1606. return Docs.expandOperation(elem);
  1607. }
  1608. };
  1609. return OperationView;
  1610. })(Backbone.View);
  1611. StatusCodeView = (function(_super) {
  1612. __extends(StatusCodeView, _super);
  1613. function StatusCodeView() {
  1614. StatusCodeView.__super__.constructor.apply(this, arguments);
  1615. }
  1616. StatusCodeView.prototype.initialize = function() {};
  1617. StatusCodeView.prototype.render = function() {
  1618. var template;
  1619. template = this.template();
  1620. $(this.el).html(template(this.model));
  1621. return this;
  1622. };
  1623. StatusCodeView.prototype.template = function() {
  1624. return Handlebars.templates.status_code;
  1625. };
  1626. return StatusCodeView;
  1627. })(Backbone.View);
  1628. ParameterView = (function(_super) {
  1629. __extends(ParameterView, _super);
  1630. function ParameterView() {
  1631. ParameterView.__super__.constructor.apply(this, arguments);
  1632. }
  1633. ParameterView.prototype.initialize = function() {};
  1634. ParameterView.prototype.render = function() {
  1635. var contentTypeModel, isParam, parameterContentTypeView, responseContentTypeView, signatureModel, signatureView, template, type;
  1636. type = this.model.type || this.model.dataType;
  1637. if (this.model.paramType === 'body') {
  1638. this.model.isBody = true;
  1639. }
  1640. if (type.toLowerCase() === 'file') {
  1641. this.model.isFile = true;
  1642. }
  1643. template = this.template();
  1644. $(this.el).html(template(this.model));
  1645. signatureModel = {
  1646. sampleJSON: this.model.sampleJSON,
  1647. isParam: true,
  1648. signature: this.model.signature
  1649. };
  1650. if (this.model.sampleJSON) {
  1651. signatureView = new SignatureView({
  1652. model: signatureModel,
  1653. tagName: 'div'
  1654. });
  1655. $('.model-signature', $(this.el)).append(signatureView.render().el);
  1656. } else {
  1657. $('.model-signature', $(this.el)).html(this.model.signature);
  1658. }
  1659. isParam = false;
  1660. if (this.model.isBody) {
  1661. isParam = true;
  1662. }
  1663. contentTypeModel = {
  1664. isParam: isParam
  1665. };
  1666. contentTypeModel.consumes = this.model.consumes;
  1667. if (isParam) {
  1668. parameterContentTypeView = new ParameterContentTypeView({
  1669. model: contentTypeModel
  1670. });
  1671. $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
  1672. } else {
  1673. responseContentTypeView = new ResponseContentTypeView({
  1674. model: contentTypeModel
  1675. });
  1676. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  1677. }
  1678. return this;
  1679. };
  1680. ParameterView.prototype.template = function() {
  1681. if (this.model.isList) {
  1682. return Handlebars.templates.param_list;
  1683. } else {
  1684. if (this.options.readOnly) {
  1685. if (this.model.required) {
  1686. return Handlebars.templates.param_readonly_required;
  1687. } else {
  1688. return Handlebars.templates.param_readonly;
  1689. }
  1690. } else {
  1691. if (this.model.required) {
  1692. return Handlebars.templates.param_required;
  1693. } else {
  1694. return Handlebars.templates.param;
  1695. }
  1696. }
  1697. }
  1698. };
  1699. return ParameterView;
  1700. })(Backbone.View);
  1701. SignatureView = (function(_super) {
  1702. __extends(SignatureView, _super);
  1703. function SignatureView() {
  1704. SignatureView.__super__.constructor.apply(this, arguments);
  1705. }
  1706. SignatureView.prototype.events = {
  1707. 'click a.description-link': 'switchToDescription',
  1708. 'click a.snippet-link': 'switchToSnippet',
  1709. 'mousedown .snippet': 'snippetToTextArea'
  1710. };
  1711. SignatureView.prototype.initialize = function() {};
  1712. SignatureView.prototype.render = function() {
  1713. var template;
  1714. template = this.template();
  1715. $(this.el).html(template(this.model));
  1716. this.switchToDescription();
  1717. this.isParam = this.model.isParam;
  1718. if (this.isParam) {
  1719. $('.notice', $(this.el)).text('Click to set as parameter value');
  1720. }
  1721. return this;
  1722. };
  1723. SignatureView.prototype.template = function() {
  1724. return Handlebars.templates.signature;
  1725. };
  1726. SignatureView.prototype.switchToDescription = function(e) {
  1727. if (e != null) {
  1728. e.preventDefault();
  1729. }
  1730. $(".snippet", $(this.el)).hide();
  1731. $(".description", $(this.el)).show();
  1732. $('.description-link', $(this.el)).addClass('selected');
  1733. return $('.snippet-link', $(this.el)).removeClass('selected');
  1734. };
  1735. SignatureView.prototype.switchToSnippet = function(e) {
  1736. if (e != null) {
  1737. e.preventDefault();
  1738. }
  1739. $(".description", $(this.el)).hide();
  1740. $(".snippet", $(this.el)).show();
  1741. $('.snippet-link', $(this.el)).addClass('selected');
  1742. return $('.description-link', $(this.el)).removeClass('selected');
  1743. };
  1744. SignatureView.prototype.snippetToTextArea = function(e) {
  1745. var textArea;
  1746. if (this.isParam) {
  1747. if (e != null) {
  1748. e.preventDefault();
  1749. }
  1750. textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
  1751. if ($.trim(textArea.val()) === '') {
  1752. return textArea.val(this.model.sampleJSON);
  1753. }
  1754. }
  1755. };
  1756. return SignatureView;
  1757. })(Backbone.View);
  1758. ContentTypeView = (function(_super) {
  1759. __extends(ContentTypeView, _super);
  1760. function ContentTypeView() {
  1761. ContentTypeView.__super__.constructor.apply(this, arguments);
  1762. }
  1763. ContentTypeView.prototype.initialize = function() {};
  1764. ContentTypeView.prototype.render = function() {
  1765. var template;
  1766. template = this.template();
  1767. $(this.el).html(template(this.model));
  1768. $('label[for=contentType]', $(this.el)).text('Response Content Type');
  1769. return this;
  1770. };
  1771. ContentTypeView.prototype.template = function() {
  1772. return Handlebars.templates.content_type;
  1773. };
  1774. return ContentTypeView;
  1775. })(Backbone.View);
  1776. ResponseContentTypeView = (function(_super) {
  1777. __extends(ResponseContentTypeView, _super);
  1778. function ResponseContentTypeView() {
  1779. ResponseContentTypeView.__super__.constructor.apply(this, arguments);
  1780. }
  1781. ResponseContentTypeView.prototype.initialize = function() {};
  1782. ResponseContentTypeView.prototype.render = function() {
  1783. var template;
  1784. template = this.template();
  1785. $(this.el).html(template(this.model));
  1786. $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
  1787. return this;
  1788. };
  1789. ResponseContentTypeView.prototype.template = function() {
  1790. return Handlebars.templates.response_content_type;
  1791. };
  1792. return ResponseContentTypeView;
  1793. })(Backbone.View);
  1794. ParameterContentTypeView = (function(_super) {
  1795. __extends(ParameterContentTypeView, _super);
  1796. function ParameterContentTypeView() {
  1797. ParameterContentTypeView.__super__.constructor.apply(this, arguments);
  1798. }
  1799. ParameterContentTypeView.prototype.initialize = function() {};
  1800. ParameterContentTypeView.prototype.render = function() {
  1801. var template;
  1802. template = this.template();
  1803. $(this.el).html(template(this.model));
  1804. $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
  1805. return this;
  1806. };
  1807. ParameterContentTypeView.prototype.template = function() {
  1808. return Handlebars.templates.parameter_content_type;
  1809. };
  1810. return ParameterContentTypeView;
  1811. })(Backbone.View);
  1812. }).call(this);