diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index cb653d6b8df..a5ae988f348 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -852,14 +852,14 @@ function preLoadCss(cssUrl) { window.CURRENT_TOOLTIP_ELEMENT = wrapper; window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE = e; clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT); - wrapper.onpointerenter = function(ev) { + wrapper.onpointerenter = ev => { // If this is a synthetic touch event, ignore it. A click event will be along shortly. if (ev.pointerType !== "mouse") { return; } clearTooltipHoverTimeout(e); }; - wrapper.onpointerleave = function(ev) { + wrapper.onpointerleave = ev => { // If this is a synthetic touch event, ignore it. A click event will be along shortly. if (ev.pointerType !== "mouse") { return; @@ -963,38 +963,38 @@ function preLoadCss(cssUrl) { } onEachLazy(document.getElementsByClassName("tooltip"), e => { - e.onclick = function() { - this.TOOLTIP_FORCE_VISIBLE = this.TOOLTIP_FORCE_VISIBLE ? false : true; - if (window.CURRENT_TOOLTIP_ELEMENT && !this.TOOLTIP_FORCE_VISIBLE) { + e.onclick = () => { + e.TOOLTIP_FORCE_VISIBLE = e.TOOLTIP_FORCE_VISIBLE ? false : true; + if (window.CURRENT_TOOLTIP_ELEMENT && !e.TOOLTIP_FORCE_VISIBLE) { hideTooltip(true); } else { - showTooltip(this); + showTooltip(e); window.CURRENT_TOOLTIP_ELEMENT.setAttribute("tabindex", "0"); window.CURRENT_TOOLTIP_ELEMENT.focus(); window.CURRENT_TOOLTIP_ELEMENT.onblur = tooltipBlurHandler; } return false; }; - e.onpointerenter = function(ev) { + e.onpointerenter = ev => { // If this is a synthetic touch event, ignore it. A click event will be along shortly. if (ev.pointerType !== "mouse") { return; } - setTooltipHoverTimeout(this, true); + setTooltipHoverTimeout(e, true); }; - e.onpointermove = function(ev) { + e.onpointermove = ev => { // If this is a synthetic touch event, ignore it. A click event will be along shortly. if (ev.pointerType !== "mouse") { return; } - setTooltipHoverTimeout(this, true); + setTooltipHoverTimeout(e, true); }; - e.onpointerleave = function(ev) { + e.onpointerleave = ev => { // If this is a synthetic touch event, ignore it. A click event will be along shortly. if (ev.pointerType !== "mouse") { return; } - if (!this.TOOLTIP_FORCE_VISIBLE && + if (!e.TOOLTIP_FORCE_VISIBLE && !elemIsInParent(ev.relatedTarget, window.CURRENT_TOOLTIP_ELEMENT)) { // Tooltip pointer leave gesture: // @@ -1139,7 +1139,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\ * * Pass "true" to reset focus for tooltip popovers. */ - window.hideAllModals = function(switchFocus) { + window.hideAllModals = switchFocus => { hideSidebar(); window.hidePopoverMenus(); hideTooltip(switchFocus); @@ -1148,7 +1148,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\ /** * Hide all the popover menus. */ - window.hidePopoverMenus = function() { + window.hidePopoverMenus = () => { onEachLazy(document.querySelectorAll(".search-form .popover"), elem => { elem.style.display = "none"; }); diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js index 2cba32c1b50..63947789c54 100644 --- a/src/librustdoc/html/static/js/settings.js +++ b/src/librustdoc/html/static/js/settings.js @@ -59,8 +59,8 @@ if (settingValue !== null) { toggle.checked = settingValue === "true"; } - toggle.onchange = function() { - changeSetting(this.id, this.checked); + toggle.onchange = () => { + changeSetting(toggle.id, toggle.checked); }; }); onEachLazy(settingsElement.querySelectorAll("input[type=\"radio\"]"), elem => { @@ -224,14 +224,14 @@ if (isSettingsPage) { // We replace the existing "onclick" callback to do nothing if clicked. - getSettingsButton().onclick = function(event) { + getSettingsButton().onclick = event => { event.preventDefault(); }; } else { // We replace the existing "onclick" callback. const settingsButton = getSettingsButton(); const settingsMenu = document.getElementById("settings"); - settingsButton.onclick = function(event) { + settingsButton.onclick = event => { if (elemIsInParent(event.target, settingsMenu)) { return; }