1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

use shared prompt

This commit is contained in:
Luke Pulverenti 2016-02-04 15:51:13 -05:00
parent 4c2a7ed02d
commit adb3a60373
10 changed files with 215 additions and 36 deletions

View file

@ -15,12 +15,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.0.60",
"_release": "1.0.60",
"version": "1.0.65",
"_release": "1.0.65",
"_resolution": {
"type": "version",
"tag": "1.0.60",
"commit": "a55e4324dc88ec5cfa9640d1f5d59228a4c7c8c8"
"tag": "1.0.65",
"commit": "2117b3bb2d88bef07f2c150101683db8857021dd"
},
"_source": "git://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "~1.0.0",

View file

@ -0,0 +1,41 @@
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!--
`iron-icons` is a utility import that includes the definition for the `iron-icon` element, `iron-iconset-svg` element, as well as an import for the default icon set.
The `iron-icons` directory also includes imports for additional icon sets that can be loaded into your project.
Example loading icon set:
<link rel="import" href="../iron-icons/maps-icons.html">
To use an icon from one of these sets, first prefix your `iron-icon` with the icon set name, followed by a colon, ":", and then the icon id.
Example using the directions-bus icon from the maps icon set:
<iron-icon icon="maps:directions-bus"></iron-icon>
See [iron-icon](#iron-icon) for more information about working with icons.
See [iron-iconset](#iron-iconset) and [iron-iconset-svg](#iron-iconset-svg) for more information about how to create a custom iconset.
@group Iron Elements
@element iron-icons
@demo demo/index.html
-->
<iron-iconset-svg name="dialog" size="24">
<svg>
<defs>
<g id="arrow-back"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" /></g>
<g id="check"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" /></g>
</defs>
</svg>
</iron-iconset-svg>

View file

@ -0,0 +1,24 @@
define([], function () {
return function (options) {
return new Promise(function (resolve, reject) {
if (typeof options === 'string') {
options = {
title: '',
text: options
};
}
var result = prompt(options.title || '', options.text || '');
if (result) {
resolve(result);
} else {
reject(result);
}
});
};
});

View file

@ -0,0 +1,84 @@
define(['paperdialoghelper', 'layoutManager', 'html!./icons.html', 'css!./style.css', 'paper-button', 'paper-input'], function (paperdialoghelper, layoutManager) {
function show(options, resolve, reject) {
var dialogOptions = {
removeOnClose: true
};
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
}
var dlg = paperdialoghelper.createDialog(dialogOptions);
dlg.classList.add('promptDialog');
var html = '';
var submitValue = '';
html += '<div style="margin:0;padding:0;width:50%;text-align:left;">';
html += '<paper-icon-button tabindex="-1" icon="dialog:arrow-back" class="btnPromptExit"></paper-icon-button>';
if (options.title) {
html += '<h1 style="margin-bottom:0;">';
html += options.title;
html += '</h1>';
}
html += '<paper-input autoFocus class="txtPromptValue"></paper-input>';
// TODO: An actual form element should probably be added
html += '<br/>';
html += '<paper-button raised class="block paperSubmit"><iron-icon icon="dialog:check"></iron-icon><span>' + Globalize.translate('core#ButtonOk') + '</span></paper-button>';
html += '</div>';
dlg.innerHTML = html;
if (options.text) {
dlg.querySelector('.txtPromptValue').value = options.text;
}
document.body.appendChild(dlg);
dlg.querySelector('.paperSubmit').addEventListener('click', function (e) {
submitValue = dlg.querySelector('.txtPromptValue').value;
paperdialoghelper.close(dlg);
});
dlg.querySelector('.btnPromptExit').addEventListener('click', function (e) {
paperdialoghelper.close(dlg);
});
dlg.addEventListener('iron-overlay-closed', function () {
var value = submitValue;
if (value) {
resolve(value);
} else {
reject();
}
});
paperdialoghelper.open(dlg);
}
return function (options) {
return new Promise(function (resolve, reject) {
if (typeof options === 'string') {
options = {
title: '',
text: options
};
}
show(options, resolve, reject);
});
};
});

View file

@ -0,0 +1,20 @@
.promptDialog {
flex-direction: column;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}
.btnPromptExit {
z-index: 1002;
position: absolute;
top: .5em;
left: .5em;
width: 5.2vh;
height: 5.2vh;
}
.txtPromptValue label {
font-size: 200%;
}

View file

@ -10,8 +10,10 @@
// Some 1080- videos are reported as 1912?
if (maxAllowedWidth >= 1900) {
options.push({ name: '1080p - 50Mbps', maxHeight: 1080, bitrate: 40000000 });
options.push({ name: '1080p - 45Mbps', maxHeight: 1080, bitrate: 40000000 });
options.push({ name: '1080p - 60Mbps', maxHeight: 1080, bitrate: 60000000 });
options.push({ name: '1080p - 55Mbps', maxHeight: 1080, bitrate: 55000000 });
options.push({ name: '1080p - 50Mbps', maxHeight: 1080, bitrate: 50000000 });
options.push({ name: '1080p - 45Mbps', maxHeight: 1080, bitrate: 45000000 });
options.push({ name: '1080p - 40Mbps', maxHeight: 1080, bitrate: 40000000 });
options.push({ name: '1080p - 35Mbps', maxHeight: 1080, bitrate: 35000000 });
options.push({ name: '1080p - 30Mbps', maxHeight: 1080, bitrate: 30000000 });

View file

@ -29,14 +29,14 @@
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
},
"ignore": [],
"homepage": "https://github.com/PolymerElements/iron-behaviors",
"homepage": "https://github.com/polymerelements/iron-behaviors",
"_release": "1.0.12",
"_resolution": {
"type": "version",
"tag": "v1.0.12",
"commit": "657f526a2382a659cdf4e13be87ecc89261588a3"
},
"_source": "git://github.com/PolymerElements/iron-behaviors.git",
"_source": "git://github.com/polymerelements/iron-behaviors.git",
"_target": "^1.0.0",
"_originalSource": "PolymerElements/iron-behaviors"
"_originalSource": "polymerelements/iron-behaviors"
}

View file

@ -1,10 +0,0 @@
define([], function () {
return function (options) {
var result = prompt(options.text, options.defaultText || '');
if (options.callback) {
options.callback(result);
}
};
});

View file

@ -1810,10 +1810,8 @@ var AppInfo = {};
return obj;
}
function initRequire() {
var urlArgs = "v=" + (window.dashboardVersion || new Date().getDate());
function getBowerPath() {
var bowerPath = "bower_components";
// Put the version into the bower path since we can't easily put a query string param on html imports
@ -1822,6 +1820,15 @@ var AppInfo = {};
bowerPath += window.dashboardVersion;
}
return bowerPath;
}
function initRequire() {
var urlArgs = "v=" + (window.dashboardVersion || new Date().getDate());
var bowerPath = getBowerPath();
var apiClientBowerPath = bowerPath + "/emby-apiclient";
var embyWebComponentsBowerPath = bowerPath + '/emby-webcomponents';
@ -1870,14 +1877,12 @@ var AppInfo = {};
if (Dashboard.isRunningInCordova()) {
paths.dialog = "cordova/dialog";
paths.prompt = "cordova/prompt";
paths.sharingwidget = "cordova/sharingwidget";
paths.serverdiscovery = "cordova/serverdiscovery";
paths.wakeonlan = "cordova/wakeonlan";
paths.actionsheet = "cordova/actionsheet";
} else {
paths.dialog = "components/dialog";
paths.prompt = "components/prompt";
paths.sharingwidget = "components/sharingwidget";
paths.serverdiscovery = apiClientBowerPath + "/serverdiscovery";
paths.wakeonlan = apiClientBowerPath + "/wakeonlan";
@ -2035,6 +2040,21 @@ var AppInfo = {};
});
}
function initRequireWithBrowser(browser) {
var bowerPath = getBowerPath();
var embyWebComponentsBowerPath = bowerPath + '/emby-webcomponents';
if (Dashboard.isRunningInCordova()) {
define("prompt", ["cordova/prompt"], returnFirstDependency);
} else if (browser.mobile) {
define("prompt", [embyWebComponentsBowerPath + "/prompt/nativeprompt"], returnFirstDependency);
} else {
define("prompt", [embyWebComponentsBowerPath + "/prompt/prompt"], returnFirstDependency);
}
}
function init(hostingAppInfo) {
if (Dashboard.isRunningInCordova() && browserInfo.android) {
@ -2448,6 +2468,8 @@ var AppInfo = {};
require(initialDependencies, function (browser, appStorage) {
initRequireWithBrowser(browser);
window.browserInfo = browser;
window.appStorage = appStorage;

View file

@ -343,18 +343,14 @@
require(['prompt'], function (prompt) {
prompt({
text: Globalize.translate('LabelTag'),
title: Globalize.translate('HeaderAddTag'),
callback: function(value) {
if (value) {
var tags = getBlockedTagsFromPage(page);
title: Globalize.translate('LabelTag')
if (tags.indexOf(value) == -1) {
tags.push(value);
loadBlockedTags(page, tags);
}
}
}).then(function (value) {
var tags = getBlockedTagsFromPage(page);
if (tags.indexOf(value) == -1) {
tags.push(value);
loadBlockedTags(page, tags);
}
});