move unloadCss from util.js
parent
b394ebeac0
commit
aaa7d6548e
|
@ -16,8 +16,9 @@ interface Lichess {
|
|||
requestIdleCallback(f: () => void): void
|
||||
loadCss(path: string): void
|
||||
loadCssPath(path: string): void
|
||||
unloadCss(path: string): void
|
||||
loadedCss: [string];
|
||||
loadedCss: {
|
||||
[key: string]: boolean;
|
||||
}
|
||||
escapeHtml(str: string): string
|
||||
toYouTubeEmbedUrl(url: string): string
|
||||
debounce(func: (...args: any[]) => void, wait: number, immediate?: boolean): (...args: any[]) => void;
|
||||
|
|
|
@ -247,7 +247,16 @@ function forceInnerCoords(ctrl: AnalyseCtrl, v: boolean) {
|
|||
const pref = ctrl.data.pref.coords;
|
||||
if (!pref) return;
|
||||
if (v) li.loadCss(innerCoordsCss);
|
||||
else if (pref === 2) li.unloadCss(innerCoordsCss);
|
||||
else if (pref === 2) unloadCss(innerCoordsCss);
|
||||
}
|
||||
|
||||
function unloadCss(url) {
|
||||
if (li.loadedCss[url]) {
|
||||
delete li.loadedCss[url];
|
||||
$('head link[rel=stylesheet]')
|
||||
.filter(function(this: HTMLLinkElement) { return this.href.includes(url) })
|
||||
.remove();
|
||||
}
|
||||
}
|
||||
|
||||
let firstRender = true;
|
||||
|
@ -280,7 +289,7 @@ export default function(ctrl: AnalyseCtrl): VNode {
|
|||
},
|
||||
postpatch(old, vnode) {
|
||||
if (old.data!.gaugeOn !== gaugeOn) {
|
||||
window.lichess.dispatchEvent(document.body, 'chessground.resize');
|
||||
li.dispatchEvent(document.body, 'chessground.resize');
|
||||
}
|
||||
vnode.data!.gaugeOn = gaugeOn;
|
||||
}
|
||||
|
@ -345,7 +354,7 @@ export default function(ctrl: AnalyseCtrl): VNode {
|
|||
ctrl.opts.chat && h('section.mchat', {
|
||||
hook: onInsert(_ => {
|
||||
ctrl.opts.chat.parseMoves = true;
|
||||
window.lichess.makeChat(ctrl.opts.chat);
|
||||
li.makeChat(ctrl.opts.chat);
|
||||
})
|
||||
}),
|
||||
h('div.analyse__underchat', {
|
||||
|
|
|
@ -223,14 +223,6 @@ lichess.loadCss = function(url) {
|
|||
lichess.loadedCss[url] = true;
|
||||
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', lichess.assetUrl(url)));
|
||||
};
|
||||
lichess.unloadCss = function(url) {
|
||||
if (lichess.loadedCss[url]) {
|
||||
lichess.loadedCss[url] = false;
|
||||
$('head link[rel=stylesheet]')
|
||||
.filter(function() { return this.href.includes(url) })
|
||||
.remove();
|
||||
}
|
||||
}
|
||||
lichess.loadCssPath = function(key) {
|
||||
lichess.loadCss('css/' + key + '.' + $('body').data('theme') + '.' + ($('body').data('dev') ? 'dev' : 'min') + '.css');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue