Auto merge of #115669 - GuillaumeGomez:js-anonymous-functions, r=notriddle
rustdoc: Change syntax for anonymous functions set in JS This function is not very useful in itself but it slightly reduces the JS size so it's always that I suppose... No changes in behaviour. r? `@notriddle`
This commit is contained in:
commit
5ede940894
@ -852,14 +852,14 @@ function preLoadCss(cssUrl) {
|
|||||||
window.CURRENT_TOOLTIP_ELEMENT = wrapper;
|
window.CURRENT_TOOLTIP_ELEMENT = wrapper;
|
||||||
window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE = e;
|
window.CURRENT_TOOLTIP_ELEMENT.TOOLTIP_BASE = e;
|
||||||
clearTooltipHoverTimeout(window.CURRENT_TOOLTIP_ELEMENT);
|
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 this is a synthetic touch event, ignore it. A click event will be along shortly.
|
||||||
if (ev.pointerType !== "mouse") {
|
if (ev.pointerType !== "mouse") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
clearTooltipHoverTimeout(e);
|
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 this is a synthetic touch event, ignore it. A click event will be along shortly.
|
||||||
if (ev.pointerType !== "mouse") {
|
if (ev.pointerType !== "mouse") {
|
||||||
return;
|
return;
|
||||||
@ -963,38 +963,38 @@ function preLoadCss(cssUrl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onEachLazy(document.getElementsByClassName("tooltip"), e => {
|
onEachLazy(document.getElementsByClassName("tooltip"), e => {
|
||||||
e.onclick = function() {
|
e.onclick = () => {
|
||||||
this.TOOLTIP_FORCE_VISIBLE = this.TOOLTIP_FORCE_VISIBLE ? false : true;
|
e.TOOLTIP_FORCE_VISIBLE = e.TOOLTIP_FORCE_VISIBLE ? false : true;
|
||||||
if (window.CURRENT_TOOLTIP_ELEMENT && !this.TOOLTIP_FORCE_VISIBLE) {
|
if (window.CURRENT_TOOLTIP_ELEMENT && !e.TOOLTIP_FORCE_VISIBLE) {
|
||||||
hideTooltip(true);
|
hideTooltip(true);
|
||||||
} else {
|
} else {
|
||||||
showTooltip(this);
|
showTooltip(e);
|
||||||
window.CURRENT_TOOLTIP_ELEMENT.setAttribute("tabindex", "0");
|
window.CURRENT_TOOLTIP_ELEMENT.setAttribute("tabindex", "0");
|
||||||
window.CURRENT_TOOLTIP_ELEMENT.focus();
|
window.CURRENT_TOOLTIP_ELEMENT.focus();
|
||||||
window.CURRENT_TOOLTIP_ELEMENT.onblur = tooltipBlurHandler;
|
window.CURRENT_TOOLTIP_ELEMENT.onblur = tooltipBlurHandler;
|
||||||
}
|
}
|
||||||
return false;
|
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 this is a synthetic touch event, ignore it. A click event will be along shortly.
|
||||||
if (ev.pointerType !== "mouse") {
|
if (ev.pointerType !== "mouse") {
|
||||||
return;
|
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 this is a synthetic touch event, ignore it. A click event will be along shortly.
|
||||||
if (ev.pointerType !== "mouse") {
|
if (ev.pointerType !== "mouse") {
|
||||||
return;
|
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 this is a synthetic touch event, ignore it. A click event will be along shortly.
|
||||||
if (ev.pointerType !== "mouse") {
|
if (ev.pointerType !== "mouse") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.TOOLTIP_FORCE_VISIBLE &&
|
if (!e.TOOLTIP_FORCE_VISIBLE &&
|
||||||
!elemIsInParent(ev.relatedTarget, window.CURRENT_TOOLTIP_ELEMENT)) {
|
!elemIsInParent(ev.relatedTarget, window.CURRENT_TOOLTIP_ELEMENT)) {
|
||||||
// Tooltip pointer leave gesture:
|
// 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.
|
* Pass "true" to reset focus for tooltip popovers.
|
||||||
*/
|
*/
|
||||||
window.hideAllModals = function(switchFocus) {
|
window.hideAllModals = switchFocus => {
|
||||||
hideSidebar();
|
hideSidebar();
|
||||||
window.hidePopoverMenus();
|
window.hidePopoverMenus();
|
||||||
hideTooltip(switchFocus);
|
hideTooltip(switchFocus);
|
||||||
@ -1148,7 +1148,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
|
|||||||
/**
|
/**
|
||||||
* Hide all the popover menus.
|
* Hide all the popover menus.
|
||||||
*/
|
*/
|
||||||
window.hidePopoverMenus = function() {
|
window.hidePopoverMenus = () => {
|
||||||
onEachLazy(document.querySelectorAll(".search-form .popover"), elem => {
|
onEachLazy(document.querySelectorAll(".search-form .popover"), elem => {
|
||||||
elem.style.display = "none";
|
elem.style.display = "none";
|
||||||
});
|
});
|
||||||
|
@ -59,8 +59,8 @@
|
|||||||
if (settingValue !== null) {
|
if (settingValue !== null) {
|
||||||
toggle.checked = settingValue === "true";
|
toggle.checked = settingValue === "true";
|
||||||
}
|
}
|
||||||
toggle.onchange = function() {
|
toggle.onchange = () => {
|
||||||
changeSetting(this.id, this.checked);
|
changeSetting(toggle.id, toggle.checked);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
onEachLazy(settingsElement.querySelectorAll("input[type=\"radio\"]"), elem => {
|
onEachLazy(settingsElement.querySelectorAll("input[type=\"radio\"]"), elem => {
|
||||||
@ -224,14 +224,14 @@
|
|||||||
|
|
||||||
if (isSettingsPage) {
|
if (isSettingsPage) {
|
||||||
// We replace the existing "onclick" callback to do nothing if clicked.
|
// We replace the existing "onclick" callback to do nothing if clicked.
|
||||||
getSettingsButton().onclick = function(event) {
|
getSettingsButton().onclick = event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// We replace the existing "onclick" callback.
|
// We replace the existing "onclick" callback.
|
||||||
const settingsButton = getSettingsButton();
|
const settingsButton = getSettingsButton();
|
||||||
const settingsMenu = document.getElementById("settings");
|
const settingsMenu = document.getElementById("settings");
|
||||||
settingsButton.onclick = function(event) {
|
settingsButton.onclick = event => {
|
||||||
if (elemIsInParent(event.target, settingsMenu)) {
|
if (elemIsInParent(event.target, settingsMenu)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user