Chromium Code Reviews| 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); |
| +})(); |