Skip to content

Commit

Permalink
(JS) update findbar and misc mods.
Browse files Browse the repository at this point in the history
(CSS) update fira code stylistic sets, use ligatures on more elements.
fix new nightly issues with ctrl+tab panel and findbar.
add a variable to set findbar width.
update unified extensions menu.
fix a new issue with urlbar search mode icons.
(dev) update linting modules. if you use them, delete node_modules
and package-lock.json before calling npm i --production=false
  • Loading branch information
aminomancer committed Oct 20, 2022
1 parent 5e06928 commit 9748282
Show file tree
Hide file tree
Showing 151 changed files with 421 additions and 20,923 deletions.
4 changes: 1 addition & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = {
{
"endOfLine": "auto",
"arrowParens": "avoid",
"printWidth": 100,
"printWidth": 80,
"tabWidth": 2,
"trailingComma": "es5",
"quoteProps": "preserve",
Expand All @@ -57,8 +57,6 @@ module.exports = {
ignorePatterns: ["node_modules", "utils/boot.jsm"],
// Ignore eslint configurations in parent directories.
root: true,
// New rules and configurations should generally be added in
// tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js to
// allow external repositories that use the plugin to pick them up as well.
extends: ["plugin:mozilla/recommended"],
plugins: ["mozilla", "import"],
Expand Down
75 changes: 54 additions & 21 deletions JS/findbarMods.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Findbar Mods
// @version 1.3.3
// @version 1.3.4
// @author aminomancer
// @homepage https://github.com/aminomancer
// @description 1) Make a custom context menu for the findbar that lets you
Expand Down Expand Up @@ -104,7 +104,9 @@ class FindbarMods {
if (this.forceMiniFindbar) return true;
let file = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry)
.convertChromeURL(Services.io.newURI("chrome://userchrome/content/material/"))
.convertChromeURL(
Services.io.newURI("chrome://userchrome/content/material/")
)
?.QueryInterface(Ci.nsIFileURL)?.file;
return file?.exists() && file?.isDirectory();
});
Expand Down Expand Up @@ -309,7 +311,9 @@ class FindbarMods {
if (node == wrapper || node == foundMatches) continue;
node.hidden = showMinimalUI;
}
this.getElement("find-next").hidden = this.getElement("find-previous").hidden = showMinimalUI;
this.getElement("find-next").hidden = this.getElement(
"find-previous"
).hidden = showMinimalUI;
foundMatches.hidden = showMinimalUI || !foundMatches.value;
tinyIndicator.style.display = showMinimalUI ? "none" : "inline-block";
if (showMinimalUI) this._findField.classList.add("minimal");
Expand Down Expand Up @@ -364,9 +368,17 @@ class FindbarMods {
if (!node) return;
let findbar = node.tagName === "findbar" ? node : node.closest("findbar");
if (!findbar) return;
if (e.currentTarget !== this.contextMenu) return this.onSubmenuShowing(e, findbar);
this.contextMenu._menuitemHighlightAll.setAttribute("checked", !!findbar._highlightAll);
this.contextMenu._menuitemEntireWord.setAttribute("checked", !!findbar._entireWord);
if (e.currentTarget !== this.contextMenu) {
return this.onSubmenuShowing(e, findbar);
}
this.contextMenu._menuitemHighlightAll.setAttribute(
"checked",
!!findbar._highlightAll
);
this.contextMenu._menuitemEntireWord.setAttribute(
"checked",
!!findbar._entireWord
);
if (findbar._quickFindTimeout) {
clearTimeout(findbar._quickFindTimeout);
findbar._quickFindTimeout = null;
Expand All @@ -387,15 +399,22 @@ class FindbarMods {
onSubmenuShowing(e, findbar) {
if (e.target === this.contextMenu._menuMatchDiacriticsPopup) {
let diacriticsStatus =
Services.prefs.getIntPref("findbar.matchdiacritics", 0) || findbar._matchDiacritics;
let activeItem = this.contextMenu._menuMatchDiacriticsPopup.children[diacriticsStatus];
Services.prefs.getIntPref("findbar.matchdiacritics", 0) ||
findbar._matchDiacritics;
let activeItem = this.contextMenu._menuMatchDiacriticsPopup.children[
diacriticsStatus
];
activeItem.setAttribute("checked", true);
}
if (e.target === this.contextMenu._menuMatchCasePopup) {
let caseStatus =
Services.prefs.getIntPref("accessibility.typeaheadfind.casesensitive", 0) ||
findbar._typeAheadCaseSensitive;
let activeItem = this.contextMenu._menuMatchCasePopup.children[caseStatus];
Services.prefs.getIntPref(
"accessibility.typeaheadfind.casesensitive",
0
) || findbar._typeAheadCaseSensitive;
let activeItem = this.contextMenu._menuMatchCasePopup.children[
caseStatus
];
activeItem.setAttribute("checked", true);
}
}
Expand All @@ -412,9 +431,11 @@ class FindbarMods {
if (
e.keyCode == KeyEvent.DOM_VK_UP ||
(e.keyCode == KeyEvent.DOM_VK_LEFT &&
document.defaultView.getComputedStyle(this.parentNode).direction == "ltr") ||
document.defaultView.getComputedStyle(this.parentNode).direction ==
"ltr") ||
(e.keyCode == KeyEvent.DOM_VK_RIGHT &&
document.defaultView.getComputedStyle(this.parentNode).direction == "rtl")
document.defaultView.getComputedStyle(this.parentNode).direction ==
"rtl")
) {
e.preventDefault();
window.document.commandDispatcher.rewindFocus();
Expand All @@ -423,16 +444,26 @@ class FindbarMods {
if (
e.keyCode == KeyEvent.DOM_VK_DOWN ||
(e.keyCode == KeyEvent.DOM_VK_RIGHT &&
document.defaultView.getComputedStyle(this.parentNode).direction == "ltr") ||
document.defaultView.getComputedStyle(this.parentNode).direction ==
"ltr") ||
(e.keyCode == KeyEvent.DOM_VK_LEFT &&
document.defaultView.getComputedStyle(this.parentNode).direction == "rtl")
document.defaultView.getComputedStyle(this.parentNode).direction ==
"rtl")
) {
e.preventDefault();
window.document.commandDispatcher.advanceFocus();
return;
}
// handle access keys
if (!e.charCode || e.charCode <= 32 || e.altKey || e.ctrlKey || e.metaKey) return;
if (
!e.charCode ||
e.charCode <= 32 ||
e.altKey ||
e.ctrlKey ||
e.metaKey
) {
return;
}
const charLower = String.fromCharCode(e.charCode).toLowerCase();
if (this.accessKey.toLowerCase() == charLower) {
this.click();
Expand Down Expand Up @@ -471,7 +502,9 @@ class FindbarMods {
// rules similar to those in uc-findbar.css.
findbar._findField.style.width = "20em";
// we want the close button to be on the far right end of the findbar.
findbar._findField.parentNode.after(findbar.querySelector(".findbar-closebutton"));
findbar._findField.parentNode.after(
findbar.querySelector(".findbar-closebutton")
);
// put it after the input box so we can use the ~ squiggly combinator
findbar._findField.after(findbar._tinyIndicator);
// move the match-case and entire-word buttons into the text field.
Expand All @@ -485,10 +518,10 @@ class FindbarMods {
entireWordButton.addEventListener("keypress", onKey);
}
// for a given findbar, move its label into the proper position.
setLabelPosition(findbar) {
let getBounds = window.windowUtils.getBoundsWithoutFlushing;
updateLabelPosition(findbar) {
let distanceFromEdge =
getBounds(findbar).right - getBounds(findbar.querySelector(".findbar-textbox")).right;
findbar.getBoundingClientRect().right -
findbar.querySelector(".findbar-textbox").getBoundingClientRect().right;
findbar._tinyIndicator.style.right = `${distanceFromEdge + 1}px`;
}
// when a new tab is opened and the findbar somehow activated, a new findbar
Expand Down Expand Up @@ -543,7 +576,7 @@ class FindbarMods {
}
onFindbarOpen(e) {
if (e.target.findMode == e.target.FIND_NORMAL) {
setTimeout(() => e.target.ucFindbarMods.setLabelPosition(e.target), 1);
requestAnimationFrame(() => this.updateLabelPosition(e.target));
}
}
}
Expand Down
Loading

0 comments on commit 9748282

Please sign in to comment.