jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/prompt/nativeprompt.js

27 lines
581 B
JavaScript
Raw Normal View History

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