app/assets/javascripts/api_taster/app.js in api_taster-0.2.0 vs app/assets/javascripts/api_taster/app.js in api_taster-0.2.1
- old
+ new
@@ -1,12 +1,12 @@
var ApiTaster = {
formAction: '',
disableUrlParams: function() {
- $("#url-params input").prop("disabled", true);
+ $("fieldset[ref=url-params] input").prop("disabled", true);
},
enableUrlParams: function() {
- $("#url-params input").prop("disabled", false);
+ $("fieldset[ref=url-params] input").prop("disabled", false);
},
storeFormActionFor: function(form) {
ApiTaster.formAction = form.attr("action")
},
restoreFormActionFor: function(form) {
@@ -30,22 +30,42 @@
var replacedAction = ApiTaster.formAction.replace(regex, paramValue);
form.attr("action", replacedAction);
}
});
+ },
+ enableNavTabsFor: function(contentElement) {
+ var container = this;
+
+ $("ul.nav-tabs a", container).click(function(e) {
+ e.preventDefault();
+
+ $(this).parent().siblings().removeClass("active");
+ $(this).parent().addClass("active");
+
+ $(contentElement, container).hide();
+ $(contentElement + "[ref=" + $(this).attr("id") + "]", container).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) {
e.preventDefault();
$("a.show-api").parent().removeClass("active");
$(this).parent().addClass("active");
- $("#show-api-div").load(this.href, function() {
+ $("#show-api-div .div-container").load(this.href, function() {
prettyPrint();
+
+ $("#show-api-div form").enableNavTabsFor("fieldset");
+ $("#show-api-div form").displayOnlySelectedParamsFieldset();
});
});
$("#show-api-div").on("click", "#submit-api", function() {
$(this).parents("form").submit(function() {
@@ -72,17 +92,9 @@
);
prettyPrint();
});
- $("#show-api-response-div ul.nav-tabs a").click(function(e) {
- e.preventDefault();
-
- $(this).parent().siblings().removeClass("active");
- $(this).parent().addClass("active");
-
- $("pre", "#show-api-response-div").hide();
- $("pre[ref=" + $(this).attr("id") + "]", "#show-api-response-div").show();
- });
+ $("#show-api-response-div").enableNavTabsFor("pre");
});
});