mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Move prompt, confirm and sendcastapi to one module each
This commit is contained in:
parent
f50d709161
commit
cb97baa61a
6 changed files with 131 additions and 152 deletions
34
src/components/castSenderApi.js
Normal file
34
src/components/castSenderApi.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
define([], function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
if (window.appMode === "cordova" || window.appMode === "android") {
|
||||||
|
return {
|
||||||
|
load: function () {
|
||||||
|
window.chrome = window.chrome || {};
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
var ccLoaded = false;
|
||||||
|
return {
|
||||||
|
load: function () {
|
||||||
|
if (ccLoaded) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
var fileref = document.createElement("script");
|
||||||
|
fileref.setAttribute("type", "text/javascript");
|
||||||
|
|
||||||
|
fileref.onload = function () {
|
||||||
|
ccLoaded = true;
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
|
||||||
|
fileref.setAttribute("src", "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js");
|
||||||
|
document.querySelector("head").appendChild(fileref);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,8 +1,32 @@
|
||||||
define(['dialog', 'globalize'], function (dialog, globalize) {
|
define(["browser", "dialog", "globalize"], function(browser, dialog, globalize) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
return function (text, title) {
|
function replaceAll(str, find, replace) {
|
||||||
|
return str.split(find).join(replace);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser.tv && window.confirm) {
|
||||||
|
// Use the native confirm dialog
|
||||||
|
return function (options) {
|
||||||
|
if (typeof options === 'string') {
|
||||||
|
options = {
|
||||||
|
title: '',
|
||||||
|
text: options
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var text = replaceAll(options.text || '', '<br/>', '\n');
|
||||||
|
var result = confirm(text);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return Promise.resolve();
|
||||||
|
} else {
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Use our own dialog
|
||||||
|
return function (text, title) {
|
||||||
var options;
|
var options;
|
||||||
if (typeof text === 'string') {
|
if (typeof text === 'string') {
|
||||||
options = {
|
options = {
|
||||||
|
@ -37,4 +61,5 @@ define(['dialog', 'globalize'], function (dialog, globalize) {
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
define([], function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function replaceAll(str, find, replace) {
|
|
||||||
|
|
||||||
return str.split(find).join(replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (options) {
|
|
||||||
|
|
||||||
if (typeof options === 'string') {
|
|
||||||
options = {
|
|
||||||
title: '',
|
|
||||||
text: options
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var text = replaceAll(options.text || '', '<br/>', '\n');
|
|
||||||
var result = confirm(text);
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return Promise.resolve();
|
|
||||||
} else {
|
|
||||||
return Promise.reject();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
|
@ -1,28 +0,0 @@
|
||||||
define([], function () {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function replaceAll(str, find, replace) {
|
|
||||||
|
|
||||||
return str.split(find).join(replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
return function (options) {
|
|
||||||
|
|
||||||
if (typeof options === 'string') {
|
|
||||||
options = {
|
|
||||||
label: '',
|
|
||||||
text: options
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var label = replaceAll(options.label || '', '<br/>', '\n');
|
|
||||||
|
|
||||||
var result = prompt(label, options.text || '');
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
return Promise.resolve(result);
|
|
||||||
} else {
|
|
||||||
return Promise.reject(result);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
|
@ -1,6 +1,10 @@
|
||||||
define(['dialogHelper', 'layoutManager', 'scrollHelper', 'globalize', 'dom', 'require', 'material-icons', 'emby-button', 'paper-icon-button-light', 'emby-input', 'formDialogStyle'], function (dialogHelper, layoutManager, scrollHelper, globalize, dom, require) {
|
define(["browser", 'dialogHelper', 'layoutManager', 'scrollHelper', 'globalize', 'dom', 'require', 'material-icons', 'emby-button', 'paper-icon-button-light', 'emby-input', 'formDialogStyle'], function(browser, dialogHelper, layoutManager, scrollHelper, globalize, dom, require) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
function replaceAll(str, find, replace) {
|
||||||
|
return str.split(find).join(replace);
|
||||||
|
}
|
||||||
|
|
||||||
function setInputProperties(dlg, options) {
|
function setInputProperties(dlg, options) {
|
||||||
var txtInput = dlg.querySelector('#txtInput');
|
var txtInput = dlg.querySelector('#txtInput');
|
||||||
|
|
||||||
|
@ -13,7 +17,6 @@ define(['dialogHelper', 'layoutManager', 'scrollHelper', 'globalize', 'dom', 're
|
||||||
}
|
}
|
||||||
|
|
||||||
function showDialog(options, template) {
|
function showDialog(options, template) {
|
||||||
|
|
||||||
var dialogOptions = {
|
var dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
|
@ -71,7 +74,6 @@ define(['dialogHelper', 'layoutManager', 'scrollHelper', 'globalize', 'dom', 're
|
||||||
dlg.style.minWidth = (Math.min(400, dom.getWindowSize().innerWidth - 50)) + 'px';
|
dlg.style.minWidth = (Math.min(400, dom.getWindowSize().innerWidth - 50)) + 'px';
|
||||||
|
|
||||||
return dialogHelper.open(dlg).then(function () {
|
return dialogHelper.open(dlg).then(function () {
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
if (layoutManager.tv) {
|
||||||
scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
|
scrollHelper.centerFocus.off(dlg.querySelector('.formDialogContent'), false);
|
||||||
}
|
}
|
||||||
|
@ -86,11 +88,28 @@ define(['dialogHelper', 'layoutManager', 'scrollHelper', 'globalize', 'dom', 're
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((browser.tv || browser.xboxOne) && window.confirm) {
|
||||||
return function (options) {
|
return function (options) {
|
||||||
|
if (typeof options === 'string') {
|
||||||
|
options = {
|
||||||
|
label: '',
|
||||||
|
text: options
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var label = replaceAll(options.label || '', '<br/>', '\n');
|
||||||
|
var result = prompt(label, options.text || '');
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return Promise.resolve(result);
|
||||||
|
} else {
|
||||||
|
return Promise.reject(result);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return function (options) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
require(['text!./prompt.template.html'], function (template) {
|
require(['text!./prompt.template.html'], function (template) {
|
||||||
|
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
options = {
|
options = {
|
||||||
title: '',
|
title: '',
|
||||||
|
@ -101,4 +120,5 @@ define(['dialogHelper', 'layoutManager', 'scrollHelper', 'globalize', 'dom', 're
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -355,39 +355,6 @@ var AppInfo = {};
|
||||||
return headroom;
|
return headroom;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCastSenderApiLoader() {
|
|
||||||
var ccLoaded = false;
|
|
||||||
return {
|
|
||||||
load: function () {
|
|
||||||
if (ccLoaded) {
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
var fileref = document.createElement("script");
|
|
||||||
fileref.setAttribute("type", "text/javascript");
|
|
||||||
|
|
||||||
fileref.onload = function () {
|
|
||||||
ccLoaded = true;
|
|
||||||
resolve();
|
|
||||||
};
|
|
||||||
|
|
||||||
fileref.setAttribute("src", "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js");
|
|
||||||
document.querySelector("head").appendChild(fileref);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getDummyCastSenderApiLoader() {
|
|
||||||
return {
|
|
||||||
load: function () {
|
|
||||||
window.chrome = window.chrome || {};
|
|
||||||
return Promise.resolve();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function createSharedAppFooter(appFooter) {
|
function createSharedAppFooter(appFooter) {
|
||||||
return new appFooter({});
|
return new appFooter({});
|
||||||
}
|
}
|
||||||
|
@ -439,28 +406,16 @@ var AppInfo = {};
|
||||||
defineResizeObserver();
|
defineResizeObserver();
|
||||||
define("dialog", [componentsPath + "/dialog/dialog"], returnFirstDependency);
|
define("dialog", [componentsPath + "/dialog/dialog"], returnFirstDependency);
|
||||||
|
|
||||||
if (preferNativeAlerts && window.confirm) {
|
|
||||||
define("confirm", [componentsPath + "/confirm/nativeconfirm"], returnFirstDependency);
|
|
||||||
} else {
|
|
||||||
define("confirm", [componentsPath + "/confirm/confirm"], returnFirstDependency);
|
define("confirm", [componentsPath + "/confirm/confirm"], returnFirstDependency);
|
||||||
}
|
|
||||||
|
|
||||||
if ((preferNativeAlerts || browser.xboxOne) && window.confirm) {
|
|
||||||
define("prompt", [componentsPath + "/prompt/nativeprompt"], returnFirstDependency);
|
|
||||||
} else {
|
|
||||||
define("prompt", [componentsPath + "/prompt/prompt"], returnFirstDependency);
|
define("prompt", [componentsPath + "/prompt/prompt"], returnFirstDependency);
|
||||||
}
|
|
||||||
|
|
||||||
define("loading", [componentsPath + "/loading/loading"], returnFirstDependency);
|
define("loading", [componentsPath + "/loading/loading"], returnFirstDependency);
|
||||||
define("multi-download", [componentsPath + "/multidownload"], returnFirstDependency);
|
define("multi-download", [componentsPath + "/multidownload"], returnFirstDependency);
|
||||||
define("fileDownloader", [componentsPath + "/filedownloader"], returnFirstDependency);
|
define("fileDownloader", [componentsPath + "/filedownloader"], returnFirstDependency);
|
||||||
define("localassetmanager", [bowerPath + "/apiclient/localassetmanager"], returnFirstDependency);
|
define("localassetmanager", [bowerPath + "/apiclient/localassetmanager"], returnFirstDependency);
|
||||||
|
|
||||||
if ("cordova" === self.appMode || "android" === self.appMode) {
|
define("castSenderApiLoader", [componentsPath + "castSenderApi"], returnFirstDependency);
|
||||||
define("castSenderApiLoader", [], getDummyCastSenderApiLoader);
|
|
||||||
} else {
|
|
||||||
define("castSenderApiLoader", [], getCastSenderApiLoader);
|
|
||||||
}
|
|
||||||
|
|
||||||
define("transfermanager", [bowerPath + "/apiclient/sync/transfermanager"], returnFirstDependency);
|
define("transfermanager", [bowerPath + "/apiclient/sync/transfermanager"], returnFirstDependency);
|
||||||
define("filerepository", [bowerPath + "/apiclient/sync/filerepository"], returnFirstDependency);
|
define("filerepository", [bowerPath + "/apiclient/sync/filerepository"], returnFirstDependency);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue