1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/prompt/nativeprompt.js

28 lines
599 B
JavaScript
Raw Normal View History

2016-02-04 15:51:13 -05:00
define([], function () {
2016-10-18 01:06:48 -04:00
'use strict';
2016-02-04 15:51:13 -05:00
2016-02-22 23:20:13 -05:00
function replaceAll(str, find, replace) {
return str.split(find).join(replace);
}
2016-02-04 15:51:13 -05:00
return function (options) {
2016-02-22 13:25:45 -05:00
if (typeof options === 'string') {
options = {
label: '',
text: options
};
}
2016-02-04 15:51:13 -05:00
2016-02-22 23:20:13 -05:00
var label = replaceAll(options.label || '', '<br/>', '\n');
var result = prompt(label, options.text || '');
2016-02-04 15:51:13 -05:00
2016-02-22 13:25:45 -05:00
if (result) {
return Promise.resolve(result);
} else {
return Promise.reject(result);
}
2016-02-04 15:51:13 -05:00
};
});