-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf52fc3
commit 8e9af17
Showing
10 changed files
with
448 additions
and
1 deletion.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
Echelon/Profile Folder/chrome/JS/echelon_urlbar-view.uc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// ==UserScript== | ||
// @name Echelon :: URLbar Autocomplete | ||
// @description Adds additional attributions for styling purposes | ||
// @author Travis | ||
// @include main | ||
// ==/UserScript== | ||
|
||
|
||
function setURLbarViewAttr() { | ||
let e = gURLBar.view.panel; | ||
|
||
let popupDirection = null; | ||
|
||
if (!e.style.direction) { | ||
popupDirection = e.ownerGlobal.getComputedStyle(e).direction; | ||
} | ||
|
||
e.style.removeProperty(`--urlbarView-width`); | ||
|
||
let documentRect = ownerGlobal.document.documentElement.getBoundingClientRect(); | ||
let width = documentRect.right - documentRect.left; | ||
e.style.setProperty( | ||
`--urlbarView-width`, | ||
width + "px" | ||
); | ||
|
||
let elementRect = e.getBoundingClientRect(); | ||
if (elementRect.left != "0") { | ||
if (popupDirection == "rtl") { | ||
let offset = elementRect.right - documentRect.right; | ||
e.style.marginRight = offset + "px"; | ||
} else { | ||
let offset = documentRect.left - elementRect.left; | ||
e.style.marginLeft = offset + "px"; | ||
} | ||
} | ||
|
||
let needsHandleOverUnderflow = false; | ||
let boundToCheck = popupDirection == "rtl" ? "right" : "left"; | ||
let inputRect = e.getBoundingClientRect(); | ||
let startOffset = Math.abs(inputRect[boundToCheck] - documentRect[boundToCheck]); | ||
let alignSiteIcons = startOffset / width <= 0.3 || startOffset <= 250; | ||
let margins = null; | ||
if (alignSiteIcons) { | ||
// Calculate the end margin if we have a start margin. | ||
let boundToCheckEnd = popupDirection == "rtl" ? "left" : "right"; | ||
let endOffset = Math.abs(inputRect[boundToCheckEnd] - | ||
documentRect[boundToCheckEnd]); | ||
if (endOffset > startOffset * 2) { | ||
// Provide more space when aligning would result in an unbalanced | ||
// margin. This allows the location bar to be moved to the start | ||
// of the navigation toolbar to reclaim space for results. | ||
endOffset = startOffset; | ||
} | ||
let identityIcon = document.getElementById("identity-icon"); | ||
let identityRect = | ||
identityIcon.getBoundingClientRect(); | ||
let start = popupDirection == "rtl" ? | ||
documentRect.right - identityRect.right : | ||
identityRect.left; | ||
if (!margins || start != margins.start || | ||
endOffset != margins.end || | ||
width != margins.width) { | ||
margins = { start, end: endOffset, width }; | ||
needsHandleOverUnderflow = true; | ||
} | ||
} else if (margins) { | ||
// Reset the alignment so that the site icons are positioned | ||
// according to whatever's in the CSS. | ||
margins = undefined; | ||
needsHandleOverUnderflow = true; | ||
} | ||
|
||
// set attributes | ||
if (margins) { | ||
/* eslint-disable no-multi-spaces */ | ||
let paddingInCSS = | ||
4 // .autocomplete-richlistbox padding-left/right | ||
+ 6 // .ac-site-icon margin-inline-start | ||
+ 16 // .ac-site-icon width | ||
+ 6; // .ac-site-icon margin-inline-end | ||
/* eslint-enable no-multi-spaces */ | ||
let actualVal = Math.round(margins.start) - paddingInCSS; | ||
let actualValEnd = Math.round(margins.end); | ||
e.style.setProperty("--item-padding-start", actualVal + "px"); | ||
e.style.setProperty("--item-padding-end", actualValEnd + "px"); | ||
} else { | ||
e.style.removeProperty("--item-padding-start"); | ||
e.style.removeProperty("--item-padding-end"); | ||
} | ||
} | ||
|
||
waitForElement("#urlbar").then(e => { | ||
urlbar = e; | ||
let observer = new MutationObserver(setURLbarViewAttr); | ||
observer.observe(e, { attributes: true, attributeFilter: ["open"] }); | ||
}); |
6 changes: 6 additions & 0 deletions
6
...lon/Profile Folder/chrome/assets/images/firefox-56/skin/autocomplete-search.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
Echelon/Profile Folder/chrome/assets/images/firefox-56/skin/bookmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions
9
Echelon/Profile Folder/chrome/assets/images/firefox-56/skin/defaultFavicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
Echelon/Profile Folder/chrome/assets/images/firefox-56/skin/gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
Echelon/Profile Folder/chrome/assets/images/firefox-56/skin/history.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
Echelon/Profile Folder/chrome/assets/images/firefox-56/skin/urlbar-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.