Migration of layoutManager and itemsrefresher to ES6 module

This commit is contained in:
Cameron 2020-08-04 13:47:40 +01:00
parent b5fab608c1
commit 73bb781c6a
3 changed files with 189 additions and 188 deletions

View file

@ -1,23 +1,22 @@
define(['browser', 'appSettings', 'events'], function (browser, appSettings, events) {
'use strict';
import browser from 'browser';
import appSettings from 'appSettings';
import events from 'events';
browser = browser.default || browser;
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 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);
}
class LayoutManager {
constructor() {
}
function LayoutManager() {
}
LayoutManager.prototype.setLayout = function (layout, save) {
setLayout(layout, save) {
if (!layout || layout === 'auto') {
this.autoLayout();
@ -35,13 +34,13 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
}
events.trigger(this, 'modechange');
};
}
LayoutManager.prototype.getSavedLayout = function (layout) {
getSavedLayout(layout) {
return appSettings.get('layout');
};
}
LayoutManager.prototype.autoLayout = function () {
autoLayout() {
// Take a guess at initial layout. The consuming app can override
if (browser.mobile) {
this.setLayout('mobile', false);
@ -50,16 +49,16 @@ define(['browser', 'appSettings', 'events'], function (browser, appSettings, eve
} else {
this.setLayout(this.defaultLayout || 'tv', false);
}
};
}
LayoutManager.prototype.init = function () {
var saved = this.getSavedLayout();
init() {
const saved = this.getSavedLayout();
if (saved) {
this.setLayout(saved, false);
} else {
this.autoLayout();
}
};
}
}
return new LayoutManager();
});
export default new LayoutManager();