mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
multiple modules resolution
This commit is contained in:
parent
1da48cd363
commit
3377042ad3
4 changed files with 3 additions and 3 deletions
67
src/components/layoutManager.js
Normal file
67
src/components/layoutManager.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
define(['browser', 'appSettings', 'events'], function (browser, appSettings, events) {
|
||||
'use strict';
|
||||
|
||||
function setLayout(instance, layout, selectedLayout) {
|
||||
|
||||
if (layout === selectedLayout) {
|
||||
instance[layout] = true;
|
||||
document.documentElement.classList.add('layout-' + layout);
|
||||
} else {
|
||||
instance[layout] = false;
|
||||
document.documentElement.classList.remove('layout-' + layout);
|
||||
}
|
||||
}
|
||||
|
||||
function LayoutManager() {
|
||||
|
||||
}
|
||||
|
||||
LayoutManager.prototype.setLayout = function (layout, save) {
|
||||
|
||||
if (!layout || layout === 'auto') {
|
||||
this.autoLayout();
|
||||
|
||||
if (save !== false) {
|
||||
appSettings.set('layout', '');
|
||||
}
|
||||
} else {
|
||||
setLayout(this, 'mobile', layout);
|
||||
setLayout(this, 'tv', layout);
|
||||
setLayout(this, 'desktop', layout);
|
||||
|
||||
if (save !== false) {
|
||||
appSettings.set('layout', layout);
|
||||
}
|
||||
}
|
||||
|
||||
events.trigger(this, 'modechange');
|
||||
};
|
||||
|
||||
LayoutManager.prototype.getSavedLayout = function (layout) {
|
||||
|
||||
return appSettings.get('layout');
|
||||
};
|
||||
|
||||
LayoutManager.prototype.autoLayout = function () {
|
||||
|
||||
// Take a guess at initial layout. The consuming app can override
|
||||
if (browser.mobile) {
|
||||
this.setLayout('mobile', false);
|
||||
} else if (browser.tv || browser.xboxOne) {
|
||||
this.setLayout('tv', false);
|
||||
} else {
|
||||
this.setLayout(this.defaultLayout || 'tv', false);
|
||||
}
|
||||
};
|
||||
|
||||
LayoutManager.prototype.init = function () {
|
||||
var saved = this.getSavedLayout();
|
||||
if (saved) {
|
||||
this.setLayout(saved, false);
|
||||
} else {
|
||||
this.autoLayout();
|
||||
}
|
||||
};
|
||||
|
||||
return new LayoutManager();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue