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 }; var backButton = false; var raisedButtons = false; if (layoutManager.tv) { dialogOptions.size = 'fullscreen'; backButton = true; raisedButtons = true; } var dlg = paperdialoghelper.createDialog(dialogOptions); dlg.classList.add('promptDialog'); var html = ''; var submitValue = ''; html += '
'; if (backButton) { html += ''; } html += ''; // TODO: An actual form element should probably be added html += '
'; if (raisedButtons) { html += '' + Globalize.translate('core#ButtonOk') + ''; } else { html += '' + Globalize.translate('core#ButtonOk') + ''; html += '' + Globalize.translate('core#ButtonCancel') + ''; } html += '
'; dlg.innerHTML = html; if (options.text) { dlg.querySelector('.txtPromptValue').value = options.text; } if (options.title) { dlg.querySelector('.txtPromptValue').label = options.title; } document.body.appendChild(dlg); dlg.querySelector('.btnSubmit').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); }); }; });