Created
September 21, 2015 16:43
-
-
Save ravikiranj/d525fc7a07f1339147ed to your computer and use it in GitHub Desktop.
RAML with Permalinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/dist/scripts/api-console.js b/dist/scripts/api-console.js | |
index d18b436..7f11586 100644 | |
--- a/dist/scripts/api-console.js | |
+++ b/dist/scripts/api-console.js | |
@@ -2039,6 +2039,49 @@ | |
setPromise(ramlParser.load(raml)); | |
}; | |
+ var showEndpointDoc = function() { | |
+ var hash = window.location.hash | |
+ , endpointName | |
+ , endpointElem | |
+ , qLocation | |
+ ; | |
+ if (!hash) { | |
+ return; | |
+ } | |
+ qLocation = hash.indexOf("?"); | |
+ endpointName = qLocation > 0 ? hash.substring(0, qLocation) : hash; | |
+ endpointElem = jQuery(endpointName + " .raml-console-tab-list .raml-console-tab").first(); | |
+ | |
+ if (endpointElem.length < 1) { | |
+ return; | |
+ } | |
+ endpointElem.trigger("click"); | |
+ }; | |
+ | |
+ var addPermalinks = function() { | |
+ var endpoints = jQuery("li.raml-console-resource-list-item.ng-scope") | |
+ , elem | |
+ , elemHeader | |
+ , subendpointHeader | |
+ , permalinkElem | |
+ ; | |
+ if (endpoints.length < 1) { | |
+ return; | |
+ } | |
+ endpoints.each(function() { | |
+ elem = jQuery(this); | |
+ elemHeader = elem.find("header.raml-console-resource"); | |
+ subendpointHeader = elem.find("div.raml-console-resource"); | |
+ | |
+ permalinkElem = jQuery("<a>", {href: "#" + elem.attr("id"), "class": "permalink", "text": "permalink"}); | |
+ if (elemHeader.length > 0) { | |
+ elemHeader.append(permalinkElem); | |
+ } else if (subendpointHeader.length > 0) { | |
+ subendpointHeader.append(permalinkElem); | |
+ } | |
+ }); | |
+ }; | |
+ | |
var onParseSuccess = function(cb) { | |
ramlProcessor = function() { | |
cb.apply(this, arguments); | |
@@ -2046,6 +2089,8 @@ | |
// handle aggressive digesters! | |
$rootScope.$digest(); | |
} | |
+ showEndpointDoc(); | |
+ addPermalinks(); | |
}; | |
if (whenParsed) { | |
diff --git a/dist/styles/api-console-light-theme.css b/dist/styles/api-console-light-theme.css | |
index db2ab13..5336ecb 100644 | |
--- a/dist/styles/api-console-light-theme.css | |
+++ b/dist/styles/api-console-light-theme.css | |
@@ -4840,3 +4837,23 @@ view-port | |
.cm-s-raml-console .CodeMirror-activeline-background { | |
background: rgba(0, 0, 0, 0.10); | |
} | |
+ | |
+/* Custom Rules */ | |
+.raml-console-resource a.permalink { | |
+ display: block; | |
+ font-size: 10px; | |
+ margin-top: 8px; | |
+ margin-right: 32px; | |
+ color: #888; | |
+ text-decoration: none; | |
+ font-weight: bold; | |
+} | |
+ | |
+.raml-console-resource a.permalink:hover { | |
+ text-decoration: underline; | |
+} | |
+ | |
+.raml-console-resource.raml-console-is-active a.permalink { | |
+ margin-top: 3px; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like you changed something or missed the last line when copying this. You need to change line 70 to this:
You may have missed a blank line at the end of the diff or so.