app/assets/javascripts/api_taster/app.js in api_taster-0.2.2 vs app/assets/javascripts/api_taster/app.js in api_taster-0.3.0

- old
+ new

@@ -1,32 +1,40 @@ var ApiTaster = { + formAction: '', + disableUrlParams: function() { $("fieldset[ref=url-params] input").prop("disabled", true); }, + enableUrlParams: function() { $("fieldset[ref=url-params] input").prop("disabled", false); }, + storeFormActionFor: function(form) { ApiTaster.formAction = form.attr("action") }, + restoreFormActionFor: function(form) { $(form).attr("action", ApiTaster.formAction); }, + detectContentType: function(response) { var contentType = response.getResponseHeader("Content-Type"); var detectedContentType = null if (contentType.match(/application\/json/)) { detectedContentType = 'json'; } return detectedContentType; } + }; $.fn.extend({ + replaceUrlParams: function(params) { var form = this; $.each(params, function(i, param) { var matches = param["name"].match(/\[api_taster_url_params\](.*)/) @@ -41,10 +49,11 @@ form.attr("action", replacedAction); } }); }, + enableNavTabsFor: function(contentElement) { var container = this; $("ul.nav-tabs a", container).click(function(e) { e.preventDefault(); @@ -54,28 +63,31 @@ $(contentElement, container).hide(); $(contentElement + "[ref=" + $(this).attr("id") + "]", container).show(); }); }, + showNavTab: function(name) { $("ul.nav-tabs li", this).removeClass("active"); $("ul.nav-tabs li a#response-" + name, this).parent().show().addClass("active"); $("pre", this).hide(); return $("pre[ref=response-" + name + "]", this).show(); }, + displayOnlySelectedParamsFieldset: function() { $("fieldset", this).hide(); $("fieldset[ref=" + $("ul.nav-tabs li.active a").attr("id") + "]", this).show(); } + }); jQuery(function($) { - $("a.show-api").click(function(e) { + $("#list-api-div a").click(function(e) { e.preventDefault(); - $("a.show-api").parent().removeClass("active"); + $(this).parent().siblings().removeClass("active"); $(this).parent().addClass("active"); $("#show-api-div .div-container").load(this.href, function() { prettyPrint();