" + "
" + this.dialogs.message.replace("{{message}}", item.message);
- if(item.type === "confirm" || item.type === "prompt") {
+ if(["confirm", "prompt", "password", "select"].indexOf(item.type) >= 0) {
btnTxt = this.dialogs.buttons.cancel + this.dialogs.buttons.ok;
}
@@ -90,6 +92,21 @@
html += this.dialogs.input;
}
+ if (item.type === "password") {
+ html += this.dialogs.input.replace("type='text'", "type='password'");
+ }
+
+ if (item.type == 'select') {
+ var select = this.dialogs.select;
+
+ for(var key in item.selectOptions) {
+ select += '';
+ }
+
+ select += '';
+ html += select;
+ }
+
html = (html + this.dialogs.buttons.holder + "
" + "
")
.replace("{{buttons}}", btnTxt)
.replace("{{ok}}", this.okLabel)
@@ -141,12 +158,13 @@
*
* @return {Object}
*/
- dialog: function(message, type, onOkay, onCancel) {
+ dialog: function(message, type, onOkay, onCancel, selectOptions) {
return this.setup({
type: type,
message: message,
onOkay: onOkay,
- onCancel: onCancel
+ onCancel: onCancel,
+ selectOptions: selectOptions
});
},
@@ -247,7 +265,7 @@
var btnOK = el.querySelector(".ok");
var btnCancel = el.querySelector(".cancel");
- var input = el.querySelector("input");
+ var input = el.querySelector("input,select");
var label = el.querySelector("label");
// Set default value/placeholder of input
@@ -333,7 +351,7 @@
this.parent.appendChild(el);
setTimeout(function() {
el.classList.remove("hide");
- if(input && item.type && item.type === "prompt") {
+ if(input && item.type && (item.type === "prompt" || item.type === "password")) {
input.select();
input.focus();
} else {
@@ -372,6 +390,7 @@
this.dialogs.buttons.ok = "