mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
+ added settingshelper to site defines
~ convert subtitles controller to es6 module + added support for class controller Signed-off-by: Christoph Potas <christoph286@googlemail.com>
This commit is contained in:
parent
6f0843cc6d
commit
658710e982
4 changed files with 64 additions and 45 deletions
|
@ -6,7 +6,7 @@ import focusManager from 'focusManager';
|
||||||
import loading from 'loading';
|
import loading from 'loading';
|
||||||
import connectionManager from 'connectionManager';
|
import connectionManager from 'connectionManager';
|
||||||
import subtitleAppearanceHelper from 'subtitleAppearanceHelper';
|
import subtitleAppearanceHelper from 'subtitleAppearanceHelper';
|
||||||
import settingsHelper from '../settingshelper';
|
import settingsHelper from 'settingsHelper';
|
||||||
import dom from 'dom';
|
import dom from 'dom';
|
||||||
import events from 'events';
|
import events from 'events';
|
||||||
import 'listViewStyle';
|
import 'listViewStyle';
|
||||||
|
|
|
@ -25,6 +25,10 @@ define(['viewContainer', 'focusManager', 'queryString', 'layoutManager'], functi
|
||||||
|
|
||||||
// Use controller method
|
// Use controller method
|
||||||
var controller = new options.controllerFactory(newView, eventDetail.detail.params);
|
var controller = new options.controllerFactory(newView, eventDetail.detail.params);
|
||||||
|
} else if (typeof options.controllerFactory === 'object') {
|
||||||
|
|
||||||
|
// Use controller class
|
||||||
|
var controller = new options.controllerFactory.default(newView, eventDetail.detail.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.controllerFactory || dispatchPageEvents) {
|
if (!options.controllerFactory || dispatchPageEvents) {
|
||||||
|
|
|
@ -1,49 +1,63 @@
|
||||||
define(["subtitleSettings", "userSettings", "autoFocuser"], function (SubtitleSettings, userSettings, autoFocuser) {
|
import subtitleSettings from 'subtitleSettings';
|
||||||
"use strict";
|
import * as userSettings from 'userSettings';
|
||||||
|
import autoFocuser from 'autoFocuser';
|
||||||
|
|
||||||
return function (view, params) {
|
export class SubtitleController {
|
||||||
function onBeforeUnload(e) {
|
constructor(view, params) {
|
||||||
if (hasChanges) {
|
this.userId = params.userId || ApiClient.getCurrentUserId();
|
||||||
e.returnValue = "You currently have unsaved changes. Are you sure you wish to leave?";
|
this.currentSettings = this.userId === ApiClient.getCurrentUserId() ? userSettings : new userSettings();
|
||||||
}
|
this.hasChanges = false;
|
||||||
|
this.subtitleSettingsInstance = null;
|
||||||
|
this.view = view;
|
||||||
|
|
||||||
|
view.addEventListener("viewshow", this.viewShow.bind(this));
|
||||||
|
view.addEventListener("change", this.change.bind(this));
|
||||||
|
view.addEventListener("viewbeforehide", this.viewBeforeHide.bind(this));
|
||||||
|
view.addEventListener("viewdestroy", this.viewDestroy.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
viewShow() {
|
||||||
|
window.addEventListener("beforeunload", this.beforeUnload.bind(this));
|
||||||
|
|
||||||
|
if (this.subtitleSettingsInstance) {
|
||||||
|
this.subtitleSettingsInstance.loadData();
|
||||||
|
} else {
|
||||||
|
this.subtitleSettingsInstance = new subtitleSettings({
|
||||||
|
serverId: ApiClient.serverId(),
|
||||||
|
userId: this.userId,
|
||||||
|
element: this.view.querySelector(".settingsContainer"),
|
||||||
|
userSettings: this.currentSettings,
|
||||||
|
enableSaveButton: false,
|
||||||
|
enableSaveConfirmation: false,
|
||||||
|
autoFocus: autoFocuser.isEnabled()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var subtitleSettingsInstance;
|
viewDestroy() {
|
||||||
var hasChanges;
|
if (this.subtitleSettingsInstance) {
|
||||||
var userId = params.userId || ApiClient.getCurrentUserId();
|
this.subtitleSettingsInstance.destroy();
|
||||||
var currentSettings = userId === ApiClient.getCurrentUserId() ? userSettings : new userSettings();
|
this.subtitleSettingsInstance = null;
|
||||||
view.addEventListener("viewshow", function () {
|
}
|
||||||
window.addEventListener("beforeunload", onBeforeUnload);
|
}
|
||||||
|
|
||||||
if (subtitleSettingsInstance) {
|
viewBeforeHide() {
|
||||||
subtitleSettingsInstance.loadData();
|
this.hasChanges = false;
|
||||||
} else {
|
|
||||||
subtitleSettingsInstance = new SubtitleSettings.default({
|
|
||||||
serverId: ApiClient.serverId(),
|
|
||||||
userId: userId,
|
|
||||||
element: view.querySelector(".settingsContainer"),
|
|
||||||
userSettings: currentSettings,
|
|
||||||
enableSaveButton: false,
|
|
||||||
enableSaveConfirmation: false,
|
|
||||||
autoFocus: autoFocuser.isEnabled()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
view.addEventListener("change", function () {
|
|
||||||
hasChanges = true;
|
|
||||||
});
|
|
||||||
view.addEventListener("viewbeforehide", function () {
|
|
||||||
hasChanges = false;
|
|
||||||
|
|
||||||
if (subtitleSettingsInstance) {
|
if (this.subtitleSettingsInstance) {
|
||||||
subtitleSettingsInstance.submit();
|
this.subtitleSettingsInstance.submit();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
view.addEventListener("viewdestroy", function () {
|
|
||||||
if (subtitleSettingsInstance) {
|
change() {
|
||||||
subtitleSettingsInstance.destroy();
|
this.hasChanges = true;
|
||||||
subtitleSettingsInstance = null;
|
}
|
||||||
}
|
|
||||||
});
|
beforeUnload(e) {
|
||||||
};
|
if (this.hasChanges) {
|
||||||
});
|
e.returnValue = "You currently have unsaved changes. Are you sure you wish to leave?";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SubtitleController;
|
||||||
|
|
|
@ -831,6 +831,7 @@ var AppInfo = {};
|
||||||
define("upNextDialog", [componentsPath + "/upnextdialog/upnextdialog"], returnFirstDependency);
|
define("upNextDialog", [componentsPath + "/upnextdialog/upnextdialog"], returnFirstDependency);
|
||||||
define("subtitleAppearanceHelper", [componentsPath + "/subtitlesettings/subtitleappearancehelper"], returnFirstDependency);
|
define("subtitleAppearanceHelper", [componentsPath + "/subtitlesettings/subtitleappearancehelper"], returnFirstDependency);
|
||||||
define("subtitleSettings", [componentsPath + "/subtitlesettings/subtitlesettings"], returnFirstDependency);
|
define("subtitleSettings", [componentsPath + "/subtitlesettings/subtitlesettings"], returnFirstDependency);
|
||||||
|
define("settingsHelper", [componentsPath + "/settingshelper"], returnFirstDependency);
|
||||||
define("displaySettings", [componentsPath + "/displaysettings/displaysettings"], returnFirstDependency);
|
define("displaySettings", [componentsPath + "/displaysettings/displaysettings"], returnFirstDependency);
|
||||||
define("playbackSettings", [componentsPath + "/playbacksettings/playbacksettings"], returnFirstDependency);
|
define("playbackSettings", [componentsPath + "/playbacksettings/playbacksettings"], returnFirstDependency);
|
||||||
define("homescreenSettings", [componentsPath + "/homescreensettings/homescreensettings"], returnFirstDependency);
|
define("homescreenSettings", [componentsPath + "/homescreensettings/homescreensettings"], returnFirstDependency);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue