From 58d5a35bcefc8319775d8da91a4e61cd0bdb2959 Mon Sep 17 00:00:00 2001 From: Ayush Gupta Date: Tue, 28 Aug 2012 17:05:35 +0530 Subject: [PATCH] closes #45 --- src/main/javascript/doc.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/javascript/doc.js b/src/main/javascript/doc.js index 48fb384cd26..595d89f13a6 100644 --- a/src/main/javascript/doc.js +++ b/src/main/javascript/doc.js @@ -107,7 +107,7 @@ var Docs = { }, toggleEndpointListForResource: function(resource) { - var elem = $('li#resource_' + resource + ' ul.endpoints'); + var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); if (elem.is(':visible')) { Docs.collapseEndpointListForResource(resource); } else { @@ -119,7 +119,7 @@ var Docs = { expandEndpointListForResource: function(resource) { $('#resource_' + resource).addClass('active'); - var elem = $('li#resource_' + resource + ' ul.endpoints'); + var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); elem.slideDown(); }, @@ -127,14 +127,14 @@ var Docs = { collapseEndpointListForResource: function(resource) { $('#resource_' + resource).removeClass('active'); - var elem = $('li#resource_' + resource + ' ul.endpoints'); + var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); elem.slideUp(); }, expandOperationsForResource: function(resource) { // Make sure the resource container is open.. Docs.expandEndpointListForResource(resource); - $('li#resource_' + resource + ' li.operation div.content').each(function() { + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { Docs.expandOperation($(this)); }); }, @@ -142,11 +142,15 @@ var Docs = { collapseOperationsForResource: function(resource) { // Make sure the resource container is open.. Docs.expandEndpointListForResource(resource); - $('li#resource_' + resource + ' li.operation div.content').each(function() { + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { Docs.collapseOperation($(this)); }); }, + escapeResourceName: function(resource) { + return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&") + }, + expandOperation: function(elem) { elem.slideDown(); },