content/static: disable jump to modal when documentation is empty

Disables the jump to modal from opening when documentation
does not exist for the current page.

Change-Id: Ic67019003ae4adc9482a67a72f2f077eadb0363d
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/260720
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/content/static/js/jump.js b/content/static/js/jump.js
index 37c41f4..bd6bf6b 100644
--- a/content/static/js/jump.js
+++ b/content/static/js/jump.js
@@ -27,6 +27,7 @@
 const jumpList = jumpDialog.querySelector('.JumpDialog-list');
 const jumpFilter = jumpDialog.querySelector('.JumpDialog-input');
 const searchInput = document.querySelector('.js-searchFocus');
+const doc = document.querySelector('.js-documentation');
 
 if (!jumpDialog.showModal) {
   dialogPolyfill.registerDialog(jumpDialog);
@@ -44,7 +45,6 @@
 // a less precise method.
 function collectJumpListItems() {
   let items = [];
-  const doc = document.querySelector('.js-documentation');
   for (const el of doc.querySelectorAll('[data-kind]')) {
     items.push(newJumpListItem(el));
   }
@@ -256,7 +256,7 @@
 // Ignore a keypress if a dialog is already open, or if it is pressed on a
 // component that wants to consume it.
 document.addEventListener('keypress', function (e) {
-  if (jumpDialog.open || shortcutsDialog.open) {
+  if (jumpDialog.open || shortcutsDialog.open || !doc) {
     return;
   }
   const t = e.target.tagName;
diff --git a/content/static/js/jump.min.js b/content/static/js/jump.min.js
index b13f2b1..10f89e0 100644
--- a/content/static/js/jump.min.js
+++ b/content/static/js/jump.min.js
@@ -32,8 +32,8 @@
 (this.zIndexHigh_-this.zIndexLow_)/2-1)return!1;1===this.pendingDialogStack.unshift(a)&&this.blockDocument();this.updateStacking();return!0};k.DialogManager.prototype.removeDialog=function(a){a=this.pendingDialogStack.indexOf(a);-1!==a&&(this.pendingDialogStack.splice(a,1),0===this.pendingDialogStack.length&&this.unblockDocument(),this.updateStacking())};k.dm=new k.DialogManager;k.formSubmitter=null;k.useValue=null;if(void 0===window.HTMLDialogElement){var q=document.createElement("form");q.setAttribute("method",
 "dialog");if("dialog"!==q.method&&(q=Object.getOwnPropertyDescriptor(HTMLFormElement.prototype,"method"))){var u=q.get;q.get=function(){return f(this)?"dialog":u.call(this)};var v=q.set;q.set=function(a){return"string"===typeof a&&"dialog"===a.toLowerCase()?this.setAttribute("method",a):v.call(this,a)};Object.defineProperty(HTMLFormElement.prototype,"method",q)}document.addEventListener("click",function(a){k.formSubmitter=null;k.useValue=null;if(!a.defaultPrevented){var d=a.target;if(d&&f(d.form)){if(!("submit"===
 d.type&&-1<["button","input"].indexOf(d.localName))){if("input"!==d.localName||"image"!==d.type)return;k.useValue=a.offsetX+","+a.offsetY}c(d)&&(k.formSubmitter=d)}}},!1);var w=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(!f(this))return w.call(this);var a=c(this);a&&a.close()};document.addEventListener("submit",function(a){if(!a.defaultPrevented){var d=a.target;if(f(d)&&(a.preventDefault(),a=c(d))){var h=k.formSubmitter;h&&h.form===d?a.close(k.useValue||h.value):
-a.close();k.formSubmitter=null}}},!1)}return k});var jumpDialog=document.querySelector(".JumpDialog"),jumpBody=jumpDialog.querySelector(".JumpDialog-body"),jumpList=jumpDialog.querySelector(".JumpDialog-list"),jumpFilter=jumpDialog.querySelector(".JumpDialog-input"),searchInput=document.querySelector(".js-searchFocus");jumpDialog.showModal||dialogPolyfill.registerDialog(jumpDialog);var jumpListItems;
-function collectJumpListItems(){for(var b=[],c=document.querySelector(".js-documentation"),e=$jscomp.makeIterator(c.querySelectorAll("[data-kind]")),f=e.next();!f.done;f=e.next())b.push(newJumpListItem(f.value));0==b.length&&(b=collectJumpListItemsFallback(c));c=$jscomp.makeIterator(b);for(e=c.next();!e.done;e=c.next())e.value.link.addEventListener("click",function(){jumpDialog.close()});b.sort(function(g,m){return g.lower.localeCompare(m.lower)});return b}
+a.close();k.formSubmitter=null}}},!1)}return k});var jumpDialog=document.querySelector(".JumpDialog"),jumpBody=jumpDialog.querySelector(".JumpDialog-body"),jumpList=jumpDialog.querySelector(".JumpDialog-list"),jumpFilter=jumpDialog.querySelector(".JumpDialog-input"),searchInput=document.querySelector(".js-searchFocus"),doc=document.querySelector(".js-documentation");jumpDialog.showModal||dialogPolyfill.registerDialog(jumpDialog);var jumpListItems;
+function collectJumpListItems(){for(var b=[],c=$jscomp.makeIterator(doc.querySelectorAll("[data-kind]")),e=c.next();!e.done;e=c.next())b.push(newJumpListItem(e.value));0==b.length&&(b=collectJumpListItemsFallback(doc));c=$jscomp.makeIterator(b);for(e=c.next();!e.done;e=c.next())e.value.link.addEventListener("click",function(){jumpDialog.close()});b.sort(function(f,g){return f.lower.localeCompare(g.lower)});return b}
 function collectJumpListItemsFallback(b){var c=[],e={};b=$jscomp.makeIterator(b.querySelectorAll("*[id]"));for(var f=b.next();!f.done;f=b.next()){f=f.value;var g=f.getAttribute("id");!e[g]&&/^[^_][^-]*$/.test(g)&&(e[g]=!0,c.push(newJumpListItem(f)))}return c}
 function newJumpListItem(b){var c=document.createElement("a"),e=b.getAttribute("id");c.setAttribute("href","#"+e);c.setAttribute("tabindex","-1");var f=b.getAttribute("data-kind");f||(f=guessKind(b));return{link:c,name:e,kind:f,lower:e.toLowerCase()}}
 function guessKind(b){switch(b.getAttribute("class")){case "Documentation-functionHeader":case "Documentation-typeFuncHeader":return"function";case "Documentation-typeHeader":return"type";case "Documentation-typeMethodHeader":return"method";default:switch(b.closest("section").getAttribute("class")){case "Documentation-variables":return"variable";case "Documentation-constants":return"constant";case "Documentation-types":return"field";default:return""}}}var lastFilterValue,activeJumpItem=-1;
@@ -41,5 +41,5 @@
 0;0<jumpList.children.length&&setActiveJumpItem(0)}function setActiveJumpItem(b){var c=jumpList.children;0<=activeJumpItem&&c[activeJumpItem].classList.remove("JumpDialog-active");b>=c.length&&(b=c.length-1);if(0<=b){c[b].classList.add("JumpDialog-active");var e=c[b].offsetTop-c[0].offsetTop;c=e+c[b].clientHeight;e<jumpBody.scrollTop?jumpBody.scrollTop=e:c>jumpBody.scrollTop+jumpBody.clientHeight&&(jumpBody.scrollTop=c-jumpBody.clientHeight)}activeJumpItem=b}
 function incActiveJumpItem(b){0>activeJumpItem||(b=activeJumpItem+b,0>b&&(b=0),setActiveJumpItem(b))}jumpFilter.addEventListener("keyup",function(b){jumpFilter.value.toUpperCase()!=lastFilterValue.toUpperCase()&&updateJumpList(jumpFilter.value)});jumpFilter.addEventListener("keydown",function(b){switch(b.which){case 38:incActiveJumpItem(-1);b.preventDefault();break;case 40:incActiveJumpItem(1);b.preventDefault();break;case 13:0<=activeJumpItem&&jumpList.children[activeJumpItem].click()}});
 var shortcutsDialog=document.querySelector(".ShortcutsDialog");shortcutsDialog.showModal||dialogPolyfill.registerDialog(shortcutsDialog);
-document.addEventListener("keypress",function(b){if(!jumpDialog.open&&!shortcutsDialog.open){var c=b.target.tagName;if("INPUT"!=c&&"SELECT"!=c&&"TEXTAREA"!=c&&!(b.target.contentEditable&&"true"==b.target.contentEditable||b.metaKey||b.ctrlKey))switch(String.fromCharCode(b.which)){case "f":case "F":b.preventDefault();jumpFilter.value="";jumpDialog.showModal();updateJumpList("");break;case "?":shortcutsDialog.showModal();break;case "/":searchInput&&!window.navigator.userAgent.includes("Firefox")&&(b.preventDefault(),
-searchInput.focus())}}});var jumpOutlineInput=document.querySelector(".js-jumpToInput");jumpOutlineInput&&jumpOutlineInput.addEventListener("click",function(){jumpFilter.value="";jumpDialog.showModal();updateJumpList("")});
+document.addEventListener("keypress",function(b){if(!jumpDialog.open&&!shortcutsDialog.open&&doc){var c=b.target.tagName;if("INPUT"!=c&&"SELECT"!=c&&"TEXTAREA"!=c&&!(b.target.contentEditable&&"true"==b.target.contentEditable||b.metaKey||b.ctrlKey))switch(String.fromCharCode(b.which)){case "f":case "F":b.preventDefault();jumpFilter.value="";jumpDialog.showModal();updateJumpList("");break;case "?":shortcutsDialog.showModal();break;case "/":searchInput&&!window.navigator.userAgent.includes("Firefox")&&
+(b.preventDefault(),searchInput.focus())}}});var jumpOutlineInput=document.querySelector(".js-jumpToInput");jumpOutlineInput&&jumpOutlineInput.addEventListener("click",function(){jumpFilter.value="";jumpDialog.showModal();updateJumpList("")});