WIP: add Embed
This commit is contained in:
parent
3ea7e45624
commit
f1cb26d102
|
@ -61,6 +61,7 @@ newUI.renderClass();
|
||||||
installed.on('mouseover', Events.lazyAddEntryTitle, {passive: true});
|
installed.on('mouseover', Events.lazyAddEntryTitle, {passive: true});
|
||||||
installed.on('mouseout', Events.lazyAddEntryTitle, {passive: true});
|
installed.on('mouseout', Events.lazyAddEntryTitle, {passive: true});
|
||||||
$('#manage-options-button').onclick = () => router.updateHash('#stylus-options');
|
$('#manage-options-button').onclick = () => router.updateHash('#stylus-options');
|
||||||
|
$('#execution-order-button').onclick = () => router.updateHash('#stylus-execution-order');
|
||||||
$('#sync-styles').onclick = () => router.updateHash('#stylus-options');
|
$('#sync-styles').onclick = () => router.updateHash('#stylus-options');
|
||||||
$$('#header a[href^="http"]').forEach(a => (a.onclick = Events.external));
|
$$('#header a[href^="http"]').forEach(a => (a.onclick = Events.external));
|
||||||
document.on('visibilitychange', handleVisibilityChange);
|
document.on('visibilitychange', handleVisibilityChange);
|
||||||
|
@ -100,7 +101,20 @@ newUI.renderClass();
|
||||||
|
|
||||||
msg.onExtension(onRuntimeMessage);
|
msg.onExtension(onRuntimeMessage);
|
||||||
window.on('closeOptions', () => router.updateHash(''));
|
window.on('closeOptions', () => router.updateHash(''));
|
||||||
router.watch({hash: '#stylus-options'}, toggleEmbeddedOptions);
|
router.watch(
|
||||||
|
{hash: '#stylus-options'},
|
||||||
|
Embed(() => $create('iframe', {
|
||||||
|
id: 'stylus-embedded-options',
|
||||||
|
src: '/options.html',
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
router.watch(
|
||||||
|
{hash: '#stylus-execution-order'},
|
||||||
|
Embed(() => $create('iframe', {
|
||||||
|
id: 'stylus-execution-order',
|
||||||
|
src: '/execution-order.html',
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
|
||||||
function onRuntimeMessage(msg) {
|
function onRuntimeMessage(msg) {
|
||||||
switch (msg.method) {
|
switch (msg.method) {
|
||||||
|
@ -123,17 +137,22 @@ function onRuntimeMessage(msg) {
|
||||||
setTimeout(sorter.updateStripes, 0, {onlyWhenColumnsChanged: true});
|
setTimeout(sorter.updateStripes, 0, {onlyWhenColumnsChanged: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggleEmbeddedOptions(state) {
|
function Embed(El) {
|
||||||
const el = $('#stylus-embedded-options') ||
|
let el;
|
||||||
state && document.documentElement.appendChild($create('iframe', {
|
return async state => {
|
||||||
id: 'stylus-embedded-options',
|
if (!state && !el) return;
|
||||||
src: '/options.html',
|
if (!el) el = El();
|
||||||
}));
|
|
||||||
if (state) {
|
if (state) {
|
||||||
|
if (!el.offsetParent) {
|
||||||
|
document.body.append(el);
|
||||||
|
}
|
||||||
el.focus();
|
el.focus();
|
||||||
} else if (el) {
|
} else {
|
||||||
|
if (el.contentDocument) {
|
||||||
el.contentDocument.body.classList.add('scaleout');
|
el.contentDocument.body.classList.add('scaleout');
|
||||||
|
}
|
||||||
await animateElement(el, 'fadeout');
|
await animateElement(el, 'fadeout');
|
||||||
el.remove();
|
el.remove();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user