jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/prompt/nativeprompt.js
2016-02-22 23:20:13 -05:00

27 lines
581 B
JavaScript

define([], function () {
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);
}
};
});