|
1 | 1 | // ==UserScript== |
2 | 2 | // @name Vertical Tabs Pane |
3 | | -// @version 1.6.3 |
| 3 | +// @version 1.6.4 |
4 | 4 | // @author aminomancer |
5 | 5 | // @homepage https://github.com/aminomancer/uc.css.js |
6 | 6 | // @description Create a vertical pane across from the sidebar that functions |
|
567 | 567 | this._onCommand(e, tab); |
568 | 568 | break; |
569 | 569 | case "mouseover": |
570 | | - this._warmupRowTab(e, tab); |
| 570 | + this._onMouseOver(e, tab); |
| 571 | + break; |
| 572 | + case "mouseout": |
| 573 | + this._onMouseOut(e); |
571 | 574 | break; |
572 | 575 | case "mouseenter": |
573 | 576 | this._onMouseEnter(e); |
|
898 | 901 | }); |
899 | 902 | if (this.className) row.classList.add(this.className); |
900 | 903 | row.tab = tab; |
| 904 | + row.mOverSecondaryButton = false; |
901 | 905 | row.addEventListener("command", this); |
902 | 906 | row.addEventListener("mousedown", this); |
903 | 907 | row.addEventListener("mouseup", this); |
904 | 908 | row.addEventListener("click", this); |
905 | 909 | row.addEventListener("mouseover", this); |
| 910 | + row.addEventListener("mouseout", this); |
906 | 911 | this.tabToElement.set(tab, row); |
907 | 912 |
|
908 | 913 | // main button |
|
1189 | 1194 | gBrowser.clearMultiSelectedTabs(); |
1190 | 1195 | } |
1191 | 1196 | gBrowser.addRangeToMultiSelectedTabs(lastSelectedTab, tab); |
1192 | | - e.preventDefault(); |
1193 | 1197 | } else if (accelKey) { |
1194 | 1198 | if (tab.multiselected) gBrowser.removeFromMultiSelectedTabs(tab); |
1195 | 1199 | else if (tab != gBrowser.selectedTab) { |
1196 | 1200 | gBrowser.addToMultiSelectedTabs(tab); |
1197 | 1201 | gBrowser.lastMultiSelectedTab = tab; |
1198 | 1202 | } |
1199 | | - e.preventDefault(); |
1200 | 1203 | } else { |
1201 | 1204 | if (!tab.selected && tab.multiselected) gBrowser.lockClearMultiSelectionOnce(); |
1202 | 1205 | if ( |
|
1211 | 1214 | else gBrowser.tabContainer._handleTabSelect(); |
1212 | 1215 | } |
1213 | 1216 | } |
| 1217 | + if (e.target.closest(".all-tabs-item")?.mOverSecondaryButton) { |
| 1218 | + e.stopPropagation(); |
| 1219 | + e.preventDefault(); |
| 1220 | + } |
1214 | 1221 | } |
1215 | 1222 | // when the mouse is released, clear the multiselection and perform some |
1216 | 1223 | // drag/drop cleanup. if middle mouse button was clicked, then close the |
|
1225 | 1232 | }); |
1226 | 1233 | return; |
1227 | 1234 | } |
1228 | | - let accelKey = AppConstants.platform == "macosx" ? e.metaKey : e.ctrlKey; |
1229 | | - if (e.shiftKey || accelKey || e.target.classList.contains("all-tabs-secondary-button")) |
| 1235 | + if ( |
| 1236 | + e.shiftKey || |
| 1237 | + (AppConstants.platform == "macosx" ? e.metaKey : e.ctrlKey) || |
| 1238 | + e.target.classList.contains("all-tabs-secondary-button") |
| 1239 | + ) { |
1230 | 1240 | return; |
| 1241 | + } |
1231 | 1242 | delete tab.noCanvas; |
1232 | 1243 | gBrowser.unlockClearMultiSelection(); |
1233 | 1244 | gBrowser.clearMultiSelectedTabs(); |
|
1294 | 1305 | // "click" events work kind of like "mouseup" events, but in this case we're |
1295 | 1306 | // only using this to prevent the click event yielding a command event. |
1296 | 1307 | _onClick(e) { |
1297 | | - if (e.button !== 0 || e.target.classList.contains("all-tabs-secondary-button")) return; |
1298 | | - e.preventDefault(); |
| 1308 | + if (e.button === 0) { |
| 1309 | + if ( |
| 1310 | + e.target.classList.contains("all-tabs-secondary-button") && |
| 1311 | + !e.shiftKey && |
| 1312 | + !(AppConstants.platform == "macosx" ? e.metaKey : e.ctrlKey) |
| 1313 | + ) |
| 1314 | + return; |
| 1315 | + e.preventDefault(); |
| 1316 | + } |
1299 | 1317 | } |
1300 | 1318 | // "command" events happen on click or on spacebar/enter. we want the |
1301 | 1319 | // buttons to be keyboard accessible too. so this is how the mute button and |
|
1492 | 1510 | ? item.setAttribute("multiselected", true) |
1493 | 1511 | : item.removeAttribute("multiselected"); |
1494 | 1512 | } |
1495 | | - // invoked when mousing over a row. we want to speculatively warm up a tab |
1496 | | - // when the user hovers it since it's possible they will click it. there's a |
1497 | | - // cache for this with a maximum limit, so if the user mouses over 3 tabs |
1498 | | - // without clicking them, then a 4th, it will clear the 1st to make room. |
1499 | | - // this is the same thing the built-in tab bar does so we're just mimicking |
1500 | | - // vanilla behavior here. this can be disabled with |
1501 | | - // browser.tabs.remote.warmup.enabled |
1502 | | - _warmupRowTab(e, tab) { |
| 1513 | + // invoked when mousing over a row. we use this to set a flag |
| 1514 | + // mOverSecondaryButton on the row, which our drag handlers reference. we |
| 1515 | + // want to speculatively warm up a tab when the user hovers it since it's |
| 1516 | + // possible they will click it. there's a cache for this with a maximum |
| 1517 | + // limit, so if the user mouses over 3 tabs without clicking them, then a |
| 1518 | + // 4th, it will clear the 1st to make room. this is the same thing the |
| 1519 | + // built-in tab bar does so we're just mimicking vanilla behavior here. this |
| 1520 | + // can be disabled with browser.tabs.remote.warmup.enabled |
| 1521 | + _onMouseOver(e, tab) { |
1503 | 1522 | let row = this._findRow(e.target); |
1504 | 1523 | SessionStore.speculativeConnectOnTabHover(tab); |
1505 | | - if (row.closeButton.matches(":hover")) tab = gBrowser._findTabToBlurTo(tab); |
| 1524 | + if (e.target.classList.contains("all-tabs-secondary-button")) { |
| 1525 | + row.mOverSecondaryButton = true; |
| 1526 | + } |
| 1527 | + if (e.target.hasAttribute("close-button")) { |
| 1528 | + tab = gBrowser._findTabToBlurTo(tab); |
| 1529 | + } |
1506 | 1530 | gBrowser.warmupTab(tab); |
1507 | 1531 | } |
| 1532 | + // invoked when mousing out of an element. |
| 1533 | + _onMouseOut (e) { |
| 1534 | + let row = e.target.closest(".all-tabs-item"); |
| 1535 | + if (e.target.classList.contains("all-tabs-secondary-button")) { |
| 1536 | + row.mOverSecondaryButton = false; |
| 1537 | + } |
| 1538 | + } |
1508 | 1539 | // generate tooltip labels and decide where to anchor the tooltip. invoked |
1509 | 1540 | // when the vertical-tabs-tooltip is about to be shown. |
1510 | 1541 | createTabTooltip(e) { |
|
0 commit comments