Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(739)

Unified Diff: doc/res/js/docs.js

Issue 1926683002: docserver: Load JS async defer since it really isn't required and it was blocking the loading of th… (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: consolidate js Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « doc/Makefile ('k') | doc/templates/index.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: doc/res/js/docs.js
diff --git a/doc/res/js/docs.js b/doc/res/js/docs.js
new file mode 100644
index 0000000000000000000000000000000000000000..be5c6f1e7ebc0a5f42d8ade1314feb092df8a7cf
--- /dev/null
+++ b/doc/res/js/docs.js
@@ -0,0 +1,60 @@
+sk.DomReady.then(function() {
+ prettyPrint();
+
+ // Open the side drawer with the navigation menu.
+ $$$('button').addEventListener('click', function(e) {
+ $$$('#drawer').classList.add('opened');
+ e.stopPropagation();
+ });
+
+ // Close the side drawer.
+ $$$('body').addEventListener('click', function() {
+ $$$('#drawer').classList.remove('opened');
+ });
+
+ // highlightNav highlights where we are in the navigation.
+ var highlightNav = function() {
+ $$('#drawer li a').forEach(function(e) {
+ if (e.dataset.path == window.location.pathname) {
+ e.classList.add('selected');
+ $$$('title').innerText = e.innerText;
+ } else {
+ e.classList.remove('selected');
+ }
+ });
+ }
+
+ // Shortcut the links and handle them via XHR, that way we only
+ // pay the loading time once, yet still retain full URLs.
+ $$('#drawer li a').forEach(function(e) {
+ e.addEventListener('click', function(e) {
+ // Preserve query parameters as we navigate.
+ var q = window.location.search;
+ var url = e.target.dataset.path;
+ if (q != "") {
+ url += q;
+ }
+ sk.get('/_'+url).then(function(content) {
+ window.history.pushState(null, null, url);
+ highlightNav();
+ $$$('html #content').innerHTML = content;
+ $$$('html #page').scrollIntoView();
+ prettyPrint();
+ });
+ e.preventDefault();
+ });
+ });
+
+ highlightNav();
+});
+
+(function() {
+ var cx = '009791159600898516779:8-nlv0iznho';
+ var gcse = document.createElement('script');
+ gcse.type = 'text/javascript';
+ gcse.async = true;
+ gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
+ '//cse.google.com/cse.js?cx=' + cx;
+ var s = document.getElementsByTagName('script')[0];
dogben 2016/04/27 17:10:31 Is this referring to the script element that you r
jcgregorio 2016/04/27 17:17:30 No, this is just code that says add this new scrip
+ s.parentNode.insertBefore(gcse, s);
+})();
« no previous file with comments | « doc/Makefile ('k') | doc/templates/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698