use $root more
This commit is contained in:
parent
d25ef97205
commit
1372236cc1
|
@ -1,4 +1,4 @@
|
||||||
/* global $ $create $remove getEventKeyName */// dom.js
|
/* global $ $create $remove $root getEventKeyName */// dom.js
|
||||||
/* global CodeMirror */
|
/* global CodeMirror */
|
||||||
/* global baseInit */// base.js
|
/* global baseInit */// base.js
|
||||||
/* global prefs */
|
/* global prefs */
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
title: t('optionsCustomizePopup') + '\n' + POPUP_HOTKEY,
|
title: t('optionsCustomizePopup') + '\n' + POPUP_HOTKEY,
|
||||||
onclick: embedPopup,
|
onclick: embedPopup,
|
||||||
});
|
});
|
||||||
document.documentElement.appendChild(btn);
|
$root.appendChild(btn);
|
||||||
baseInit.domReady.then(() => {
|
baseInit.domReady.then(() => {
|
||||||
document.body.appendChild(btn);
|
document.body.appendChild(btn);
|
||||||
// Adding a dummy command to show in keymap help popup
|
// Adding a dummy command to show in keymap help popup
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global $ $$ $create $remove focusAccessibility toggleDataset */// dom.js
|
/* global $ $$ $create $remove $root focusAccessibility toggleDataset */// dom.js
|
||||||
/* global CodeMirror */
|
/* global CodeMirror */
|
||||||
/* global chromeLocal */// storage-util.js
|
/* global chromeLocal */// storage-util.js
|
||||||
/* global colorMimicry */
|
/* global colorMimicry */
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
undoHistory: [],
|
undoHistory: [],
|
||||||
|
|
||||||
searchInApplies: !document.documentElement.classList.contains('usercss'),
|
searchInApplies: !editor.isUsercss,
|
||||||
};
|
};
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
|
@ -588,7 +588,7 @@
|
||||||
input: colorMimicry($('input:not(:disabled)'), {bg: 'backgroundColor'}),
|
input: colorMimicry($('input:not(:disabled)'), {bg: 'backgroundColor'}),
|
||||||
icon: colorMimicry($$('svg.info')[1], {fill: 'fill'}),
|
icon: colorMimicry($$('svg.info')[1], {fill: 'fill'}),
|
||||||
};
|
};
|
||||||
document.documentElement.appendChild(
|
$root.appendChild(
|
||||||
$(DIALOG_STYLE_SELECTOR) ||
|
$(DIALOG_STYLE_SELECTOR) ||
|
||||||
$create('style' + DIALOG_STYLE_SELECTOR)
|
$create('style' + DIALOG_STYLE_SELECTOR)
|
||||||
).textContent = `
|
).textContent = `
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global $ $create messageBoxProxy */// dom.js
|
/* global $ $create $root messageBoxProxy */// dom.js
|
||||||
/* global CodeMirror */
|
/* global CodeMirror */
|
||||||
/* global MozSectionFinder */
|
/* global MozSectionFinder */
|
||||||
/* global colorMimicry */
|
/* global colorMimicry */
|
||||||
|
@ -218,7 +218,7 @@ function MozSectionWidget(cm, finder = MozSectionFinder(cm)) {
|
||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
document.documentElement.appendChild(actualStyle);
|
$root.appendChild(actualStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global $ $create $remove messageBoxProxy */// dom.js
|
/* global $ $create $remove $root messageBoxProxy */// dom.js
|
||||||
/* global API */// msg.js
|
/* global API */// msg.js
|
||||||
/* global CodeMirror */
|
/* global CodeMirror */
|
||||||
/* global RX_META debounce */// toolbox.js
|
/* global RX_META debounce */// toolbox.js
|
||||||
|
@ -25,7 +25,6 @@ function SectionsEditor() {
|
||||||
updateMeta();
|
updateMeta();
|
||||||
rerouteHotkeys.toggle(true); // enabled initially because we don't always focus a CodeMirror
|
rerouteHotkeys.toggle(true); // enabled initially because we don't always focus a CodeMirror
|
||||||
editor.livePreview.init();
|
editor.livePreview.init();
|
||||||
container.classList.add('section-editor');
|
|
||||||
$('#to-mozilla').on('click', showMozillaFormat);
|
$('#to-mozilla').on('click', showMozillaFormat);
|
||||||
$('#to-mozilla-help').on('click', showToMozillaHelp);
|
$('#to-mozilla-help').on('click', showToMozillaHelp);
|
||||||
$('#from-mozilla').on('click', () => showMozillaFormatImport());
|
$('#from-mozilla').on('click', () => showMozillaFormatImport());
|
||||||
|
@ -397,7 +396,7 @@ function SectionsEditor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function lockPageUI(locked) {
|
function lockPageUI(locked) {
|
||||||
document.documentElement.style.pointerEvents = locked ? 'none' : '';
|
$root.style.pointerEvents = locked ? 'none' : '';
|
||||||
if (popup.codebox) {
|
if (popup.codebox) {
|
||||||
popup.classList.toggle('ready', locked ? false : !popup.codebox.isBlank());
|
popup.classList.toggle('ready', locked ? false : !popup.codebox.isBlank());
|
||||||
popup.codebox.options.readOnly = locked;
|
popup.codebox.options.readOnly = locked;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global $ $create getEventKeyName messageBoxProxy moveFocus */// dom.js
|
/* global $ $create $root getEventKeyName messageBoxProxy moveFocus */// dom.js
|
||||||
/* global CodeMirror */
|
/* global CodeMirror */
|
||||||
/* global editor */
|
/* global editor */
|
||||||
/* global prefs */
|
/* global prefs */
|
||||||
|
@ -195,7 +195,7 @@ function showCodeMirrorPopup(title, html, options) {
|
||||||
}, options));
|
}, options));
|
||||||
cm.focus();
|
cm.focus();
|
||||||
|
|
||||||
document.documentElement.style.pointerEvents = 'none';
|
$root.style.pointerEvents = 'none';
|
||||||
popup.style.pointerEvents = 'auto';
|
popup.style.pointerEvents = 'auto';
|
||||||
|
|
||||||
const onKeyDown = event => {
|
const onKeyDown = event => {
|
||||||
|
@ -210,7 +210,7 @@ function showCodeMirrorPopup(title, html, options) {
|
||||||
|
|
||||||
window.on('closeHelp', () => {
|
window.on('closeHelp', () => {
|
||||||
window.off('keydown', onKeyDown, true);
|
window.off('keydown', onKeyDown, true);
|
||||||
document.documentElement.style.removeProperty('pointer-events');
|
$root.style.removeProperty('pointer-events');
|
||||||
cm = popup.codebox = null;
|
cm = popup.codebox = null;
|
||||||
}, {once: true});
|
}, {once: true});
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
$
|
$
|
||||||
$$
|
$$
|
||||||
$create
|
$create
|
||||||
|
$root
|
||||||
animateElement
|
animateElement
|
||||||
setupLivePrefs
|
setupLivePrefs
|
||||||
waitForSelector
|
waitForSelector
|
||||||
|
@ -36,7 +37,7 @@ Object.assign(newUI, {
|
||||||
ids: Object.keys(newUI),
|
ids: Object.keys(newUI),
|
||||||
prefKeyForId: id => `manage.newUI.${id}`.replace(/\.enabled$/, ''),
|
prefKeyForId: id => `manage.newUI.${id}`.replace(/\.enabled$/, ''),
|
||||||
renderClass: () => {
|
renderClass: () => {
|
||||||
const cl = document.documentElement.classList;
|
const cl = $root.classList;
|
||||||
cl.toggle('newUI', newUI.enabled);
|
cl.toggle('newUI', newUI.enabled);
|
||||||
cl.toggle('oldUI', !newUI.enabled);
|
cl.toggle('oldUI', !newUI.enabled);
|
||||||
},
|
},
|
||||||
|
@ -128,7 +129,7 @@ function onRuntimeMessage(msg) {
|
||||||
|
|
||||||
async function toggleEmbeddedOptions(state) {
|
async function toggleEmbeddedOptions(state) {
|
||||||
const el = $('#stylus-embedded-options') ||
|
const el = $('#stylus-embedded-options') ||
|
||||||
state && document.documentElement.appendChild($create('iframe', {
|
state && $root.appendChild($create('iframe', {
|
||||||
id: 'stylus-embedded-options',
|
id: 'stylus-embedded-options',
|
||||||
src: '/options.html',
|
src: '/options.html',
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global $ $create messageBoxProxy onDOMready */// dom.js
|
/* global $ $create $root messageBoxProxy onDOMready */// dom.js
|
||||||
/* global installed */// manage.js
|
/* global installed */// manage.js
|
||||||
/* global prefs */
|
/* global prefs */
|
||||||
/* global t */// localization.js
|
/* global t */// localization.js
|
||||||
|
@ -172,11 +172,11 @@ const sorter = (() => {
|
||||||
|
|
||||||
function updateColumnCount() {
|
function updateColumnCount() {
|
||||||
let newValue = 1;
|
let newValue = 1;
|
||||||
for (let el = document.documentElement.lastElementChild;
|
for (let el = $root.lastElementChild;
|
||||||
el.localName === 'style';
|
el.localName === 'style';
|
||||||
el = el.previousElementSibling) {
|
el = el.previousElementSibling) {
|
||||||
if (el.textContent.includes('--columns:')) {
|
if (el.textContent.includes('--columns:')) {
|
||||||
newValue = Math.max(1, getComputedStyle(document.documentElement).getPropertyValue('--columns') | 0);
|
newValue = Math.max(1, getComputedStyle($root).getPropertyValue('--columns') | 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* global $ $$ $create setupLivePrefs */// dom.js
|
/* global $ $$ $create $root setupLivePrefs */// dom.js
|
||||||
/* global ABOUT_BLANK getStyleDataMerged preinit */// preinit.js
|
/* global ABOUT_BLANK getStyleDataMerged preinit */// preinit.js
|
||||||
/* global API msg */// msg.js
|
/* global API msg */// msg.js
|
||||||
/* global Events */
|
/* global Events */
|
||||||
|
@ -38,7 +38,7 @@ preinit.then(({frames, styles, url}) => {
|
||||||
msg.onExtension(onRuntimeMessage);
|
msg.onExtension(onRuntimeMessage);
|
||||||
|
|
||||||
prefs.subscribe('popup.stylesFirst', (key, stylesFirst) => {
|
prefs.subscribe('popup.stylesFirst', (key, stylesFirst) => {
|
||||||
document.documentElement.classList.toggle('styles-last', !stylesFirst);
|
$root.classList.toggle('styles-last', !stylesFirst);
|
||||||
}, {runNow: true});
|
}, {runNow: true});
|
||||||
if (CHROME_POPUP_BORDER_BUG) {
|
if (CHROME_POPUP_BORDER_BUG) {
|
||||||
prefs.subscribe('popup.borders', toggleSideBorders, {runNow: true});
|
prefs.subscribe('popup.borders', toggleSideBorders, {runNow: true});
|
||||||
|
@ -70,7 +70,7 @@ function setPopupWidth(_key, width) {
|
||||||
|
|
||||||
function toggleSideBorders(_key, state) {
|
function toggleSideBorders(_key, state) {
|
||||||
// runs before <body> is parsed
|
// runs before <body> is parsed
|
||||||
const style = document.documentElement.style;
|
const style = $root.style;
|
||||||
if (state) {
|
if (state) {
|
||||||
style.cssText +=
|
style.cssText +=
|
||||||
'border-left: 2px solid white !important;' +
|
'border-left: 2px solid white !important;' +
|
||||||
|
|
Loading…
Reference in New Issue
Block a user