Shift key to set all widths
This commit is contained in:
parent
374b3ff2b8
commit
5348d33920
|
@ -504,6 +504,10 @@
|
|||
"gettingStyles": {
|
||||
"message": "Getting all styles..."
|
||||
},
|
||||
"headerResizerHint": {
|
||||
"message": "Holding Shift key dragging will set the new size in all UI pages",
|
||||
"description": "Tooltip for the header panel resizer"
|
||||
},
|
||||
"helpAlt": {
|
||||
"message": "Help",
|
||||
"description": "Alternate text for help buttons"
|
||||
|
|
|
@ -466,7 +466,7 @@
|
|||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<div id="header-resizer"></div>
|
||||
<div id="header-resizer" i18n-title="headerResizerHint"></div>
|
||||
<div id="footer" class="hidden">
|
||||
<a href="https://github.com/openstyles/stylus/wiki/Usercss"
|
||||
i18n-text="externalUsercssDocument"
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div id="header-resizer"></div>
|
||||
<div id="header-resizer" i18n-title="headerResizerHint"></div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="warnings"></div>
|
||||
|
|
20
js/dom.js
20
js/dom.js
|
@ -471,18 +471,20 @@ const dom = {};
|
|||
}
|
||||
// set language for a) CSS :lang pseudo and b) hyphenation
|
||||
elHtml.setAttribute('lang', chrome.i18n.getUILanguage());
|
||||
// set header width and export stuff via `dom.headerResizer`
|
||||
if (/^.(edit|manage|install)/.test(location.pathname)) {
|
||||
const prefId = `${RegExp.$1 === 'edit' ? 'editor' : RegExp.$1}.headerWidth`;
|
||||
const HR = dom.headerResizer = {
|
||||
prefId,
|
||||
setDomProp(width) {
|
||||
width = Math.round(Math.max(200, Math.min(innerWidth / 2, width)));
|
||||
// set up header width resizer
|
||||
const HW = 'headerWidth.';
|
||||
const HWprefId = HW + location.pathname.match(/^.(\w*)/)[1];
|
||||
if (prefs.knownKeys.includes(HWprefId)) {
|
||||
Object.assign(dom, {
|
||||
HW,
|
||||
HWprefId,
|
||||
setHWProp(width) {
|
||||
width = Math.round(Math.max(200, Math.min(innerWidth / 2, Number(width) || 0)));
|
||||
elHtml.style.setProperty('--header-width', width + 'px');
|
||||
return width;
|
||||
},
|
||||
};
|
||||
prefs.ready.then(() => HR.setDomProp(prefs.get(prefId)));
|
||||
});
|
||||
prefs.ready.then(() => dom.setHWProp(prefs.get(HWprefId)));
|
||||
lazyScripts.push('/js/header-resizer');
|
||||
}
|
||||
// add favicon in FF
|
||||
|
|
|
@ -4,16 +4,14 @@
|
|||
'use strict';
|
||||
|
||||
(() => {
|
||||
const HR = dom.headerResizer;
|
||||
const el = $('#header-resizer');
|
||||
let curW, offset, active;
|
||||
prefs.subscribe(HR.prefId, (key, val) => {
|
||||
prefs.subscribe(dom.HWprefId, (key, val) => {
|
||||
if (!active && val !== curW) {
|
||||
getCurWidth();
|
||||
setWidth(val);
|
||||
}
|
||||
});
|
||||
el.onmousedown = e => {
|
||||
$('#header-resizer').onmousedown = e => {
|
||||
if (e.button) return;
|
||||
getCurWidth();
|
||||
offset = curW - e.clientX;
|
||||
|
@ -28,9 +26,10 @@
|
|||
|| $('#header').offsetWidth;
|
||||
}
|
||||
|
||||
function resize({clientX: x}) {
|
||||
if (setWidth(offset + x)) {
|
||||
debounce(save, 250);
|
||||
/** @param {MouseEvent} e */
|
||||
function resize(e) {
|
||||
if (setWidth(offset + e.clientX)) {
|
||||
debounce(save, 250, e.shiftKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,12 +40,18 @@
|
|||
active = false;
|
||||
}
|
||||
|
||||
function save() {
|
||||
prefs.set(HR.prefId, curW);
|
||||
function save(all) {
|
||||
if (all) {
|
||||
for (const k of prefs.knownKeys) {
|
||||
if (k.startsWith(dom.HW)) prefs.set(k, curW);
|
||||
}
|
||||
} else {
|
||||
prefs.set(dom.HWprefId, curW);
|
||||
}
|
||||
}
|
||||
|
||||
function setWidth(w) {
|
||||
const delta = (w = HR.setDomProp(w)) - curW;
|
||||
const delta = (w = dom.setHWProp(w)) - curW;
|
||||
if (delta) {
|
||||
curW = w;
|
||||
for (const el of $$('.CodeMirror-linewidget[style*="width:"]')) {
|
||||
|
|
|
@ -123,9 +123,11 @@
|
|||
'badgeDisabled': '#8B0000', // badge background color when disabled
|
||||
'badgeNormal': '#006666', // badge background color
|
||||
|
||||
'editor.headerWidth': 280,
|
||||
'install.headerWidth': 280,
|
||||
'manage.headerWidth': 280,
|
||||
/* Using separate values instead of a single {} to ensure type control.
|
||||
* Sub-key is the first word in the html's file name. */
|
||||
'headerWidth.edit': 280,
|
||||
'headerWidth.install': 280,
|
||||
'headerWidth.manage': 280,
|
||||
|
||||
'popupWidth': 246, // popup width in pixels
|
||||
|
||||
|
|
|
@ -354,7 +354,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="header-resizer"></div>
|
||||
<div id="header-resizer" i18n-title="headerResizerHint"></div>
|
||||
</div>
|
||||
|
||||
<div id="installed"></div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user