mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Unminify using 1.5.323
Repo with tag: https://github.com/MediaBrowser/emby-webcomponents/tree/1.5.323
This commit is contained in:
parent
4678528d00
commit
de6ac33ec1
289 changed files with 78483 additions and 54701 deletions
|
@ -1,82 +1,183 @@
|
|||
define(["viewcontainer", "focusManager", "queryString", "layoutManager"], function(viewcontainer, focusManager, queryString, layoutManager) {
|
||||
"use strict";
|
||||
define(['viewcontainer', 'focusManager', 'queryString', 'layoutManager'], function (viewcontainer, focusManager, queryString, layoutManager) {
|
||||
'use strict';
|
||||
|
||||
var currentView;
|
||||
var dispatchPageEvents;
|
||||
|
||||
viewcontainer.setOnBeforeChange(function (newView, isRestored, options) {
|
||||
|
||||
var lastView = currentView;
|
||||
if (lastView) {
|
||||
|
||||
var beforeHideResult = dispatchViewEvent(lastView, null, 'viewbeforehide', true);
|
||||
|
||||
if (!beforeHideResult) {
|
||||
// todo: cancel
|
||||
}
|
||||
}
|
||||
|
||||
var eventDetail = getViewEventDetail(newView, options, isRestored);
|
||||
|
||||
if (!newView.initComplete) {
|
||||
newView.initComplete = true;
|
||||
|
||||
if (options.controllerFactory) {
|
||||
|
||||
// Use controller method
|
||||
var controller = new options.controllerFactory(newView, eventDetail.detail.params);
|
||||
}
|
||||
|
||||
if (!options.controllerFactory || dispatchPageEvents) {
|
||||
dispatchViewEvent(newView, eventDetail, 'viewinit');
|
||||
}
|
||||
}
|
||||
|
||||
dispatchViewEvent(newView, eventDetail, 'viewbeforeshow');
|
||||
});
|
||||
|
||||
function onViewChange(view, options, isRestore) {
|
||||
|
||||
var lastView = currentView;
|
||||
lastView && dispatchViewEvent(lastView, null, "viewhide"), currentView = view;
|
||||
if (lastView) {
|
||||
dispatchViewEvent(lastView, null, 'viewhide');
|
||||
}
|
||||
|
||||
currentView = view;
|
||||
|
||||
var eventDetail = getViewEventDetail(view, options, isRestore);
|
||||
isRestore ? layoutManager.mobile || (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement) ? focusManager.focus(view.activeElement) : focusManager.autoFocus(view)) : !1 !== options.autoFocus && focusManager.autoFocus(view), view.dispatchEvent(new CustomEvent("viewshow", eventDetail)), dispatchPageEvents && view.dispatchEvent(new CustomEvent("pageshow", eventDetail))
|
||||
|
||||
if (!isRestore) {
|
||||
if (options.autoFocus !== false) {
|
||||
focusManager.autoFocus(view);
|
||||
}
|
||||
}
|
||||
else if (!layoutManager.mobile) {
|
||||
if (view.activeElement && document.body.contains(view.activeElement) && focusManager.isCurrentlyFocusable(view.activeElement)) {
|
||||
focusManager.focus(view.activeElement);
|
||||
} else {
|
||||
focusManager.autoFocus(view);
|
||||
}
|
||||
}
|
||||
|
||||
view.dispatchEvent(new CustomEvent('viewshow', eventDetail));
|
||||
|
||||
if (dispatchPageEvents) {
|
||||
view.dispatchEvent(new CustomEvent('pageshow', eventDetail));
|
||||
}
|
||||
}
|
||||
|
||||
function getProperties(view) {
|
||||
var props = view.getAttribute("data-properties");
|
||||
return props ? props.split(",") : []
|
||||
var props = view.getAttribute('data-properties');
|
||||
|
||||
if (props) {
|
||||
return props.split(',');
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function dispatchViewEvent(view, eventInfo, eventName, isCancellable) {
|
||||
eventInfo || (eventInfo = {
|
||||
detail: {
|
||||
type: view.getAttribute("data-type"),
|
||||
properties: getProperties(view)
|
||||
},
|
||||
bubbles: !0,
|
||||
cancelable: isCancellable
|
||||
}), eventInfo.cancelable = isCancellable || !1;
|
||||
|
||||
if (!eventInfo) {
|
||||
eventInfo = {
|
||||
detail: {
|
||||
type: view.getAttribute('data-type'),
|
||||
properties: getProperties(view)
|
||||
},
|
||||
bubbles: true,
|
||||
cancelable: isCancellable
|
||||
};
|
||||
}
|
||||
|
||||
eventInfo.cancelable = isCancellable || false;
|
||||
|
||||
var eventResult = view.dispatchEvent(new CustomEvent(eventName, eventInfo));
|
||||
return dispatchPageEvents && (eventInfo.cancelable = !1, view.dispatchEvent(new CustomEvent(eventName.replace("view", "page"), eventInfo))), eventResult
|
||||
|
||||
if (dispatchPageEvents) {
|
||||
eventInfo.cancelable = false;
|
||||
view.dispatchEvent(new CustomEvent(eventName.replace('view', 'page'), eventInfo));
|
||||
}
|
||||
|
||||
return eventResult;
|
||||
}
|
||||
|
||||
function getViewEventDetail(view, options, isRestore) {
|
||||
var url = options.url,
|
||||
index = url.indexOf("?"),
|
||||
params = -1 === index ? {} : queryString.parse(url.substring(index + 1));
|
||||
|
||||
var url = options.url;
|
||||
var index = url.indexOf('?');
|
||||
var params = index === -1 ? {} : queryString.parse(url.substring(index + 1));
|
||||
|
||||
return {
|
||||
detail: {
|
||||
type: view.getAttribute("data-type"),
|
||||
type: view.getAttribute('data-type'),
|
||||
properties: getProperties(view),
|
||||
params: params,
|
||||
isRestored: isRestore,
|
||||
state: options.state,
|
||||
|
||||
// The route options
|
||||
options: options.options || {}
|
||||
},
|
||||
bubbles: !0,
|
||||
cancelable: !1
|
||||
}
|
||||
bubbles: true,
|
||||
cancelable: false
|
||||
};
|
||||
}
|
||||
|
||||
function resetCachedViews() {
|
||||
viewcontainer.reset()
|
||||
// Reset all cached views whenever the skin changes
|
||||
viewcontainer.reset();
|
||||
}
|
||||
|
||||
function ViewManager() {}
|
||||
var currentView, dispatchPageEvents;
|
||||
return viewcontainer.setOnBeforeChange(function(newView, isRestored, options) {
|
||||
document.addEventListener('skinunload', resetCachedViews);
|
||||
|
||||
function ViewManager() {
|
||||
}
|
||||
|
||||
ViewManager.prototype.loadView = function (options) {
|
||||
|
||||
var lastView = currentView;
|
||||
|
||||
// Record the element that has focus
|
||||
if (lastView) {
|
||||
dispatchViewEvent(lastView, null, "viewbeforehide", !0)
|
||||
lastView.activeElement = document.activeElement;
|
||||
}
|
||||
var eventDetail = getViewEventDetail(newView, options, isRestored);
|
||||
if (!newView.initComplete) {
|
||||
if (newView.initComplete = !0, options.controllerFactory) {
|
||||
new options.controllerFactory(newView, eventDetail.detail.params)
|
||||
}
|
||||
options.controllerFactory && !dispatchPageEvents || dispatchViewEvent(newView, eventDetail, "viewinit")
|
||||
|
||||
if (options.cancel) {
|
||||
return;
|
||||
}
|
||||
dispatchViewEvent(newView, eventDetail, "viewbeforeshow")
|
||||
}), document.addEventListener("skinunload", resetCachedViews), ViewManager.prototype.loadView = function(options) {
|
||||
var lastView = currentView;
|
||||
lastView && (lastView.activeElement = document.activeElement), options.cancel || viewcontainer.loadView(options).then(function(view) {
|
||||
onViewChange(view, options)
|
||||
})
|
||||
}, ViewManager.prototype.tryRestoreView = function(options, onViewChanging) {
|
||||
return options.cancel ? Promise.reject({
|
||||
cancelled: !0
|
||||
}) : (currentView && (currentView.activeElement = document.activeElement), viewcontainer.tryRestoreView(options).then(function(view) {
|
||||
onViewChanging(), onViewChange(view, options, !0)
|
||||
}))
|
||||
}, ViewManager.prototype.currentView = function() {
|
||||
return currentView
|
||||
}, ViewManager.prototype.dispatchPageEvents = function(value) {
|
||||
dispatchPageEvents = value
|
||||
}, new ViewManager
|
||||
});
|
||||
|
||||
viewcontainer.loadView(options).then(function (view) {
|
||||
|
||||
onViewChange(view, options);
|
||||
});
|
||||
};
|
||||
|
||||
ViewManager.prototype.tryRestoreView = function (options, onViewChanging) {
|
||||
|
||||
if (options.cancel) {
|
||||
return Promise.reject({ cancelled: true });
|
||||
}
|
||||
|
||||
// Record the element that has focus
|
||||
if (currentView) {
|
||||
currentView.activeElement = document.activeElement;
|
||||
}
|
||||
|
||||
return viewcontainer.tryRestoreView(options).then(function (view) {
|
||||
|
||||
onViewChanging();
|
||||
onViewChange(view, options, true);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
ViewManager.prototype.currentView = function () {
|
||||
return currentView;
|
||||
};
|
||||
|
||||
ViewManager.prototype.dispatchPageEvents = function (value) {
|
||||
dispatchPageEvents = value;
|
||||
};
|
||||
|
||||
return new ViewManager();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue