2013-09-01 18:09:09 +00:00
|
|
|
define(["dom2"], function() {
|
|
|
|
|
|
|
|
return function(text, buttons, callback) {
|
|
|
|
if (typeof buttons == "function") {
|
|
|
|
callback = buttons;
|
|
|
|
buttons = ["ok", "cancel"];
|
|
|
|
}
|
2013-09-02 00:41:52 +00:00
|
|
|
/*var modal = document.createElement("div");
|
2013-09-01 18:09:09 +00:00
|
|
|
modal.className = "modal-overlay";
|
|
|
|
var dialog = document.createElement("div");
|
|
|
|
dialog.className = "dialog";
|
|
|
|
dialog.innerHTML = text;
|
|
|
|
var buttonRow = document.createElement("div");
|
|
|
|
buttonRow.className = "button-row";
|
|
|
|
modal.append(dialog);
|
2013-09-02 00:41:52 +00:00
|
|
|
dialog.append(buttonRow);*/
|
|
|
|
|
|
|
|
var modal = document.find("template#dialog").content.cloneNode(true).find(".modal-overlay");
|
|
|
|
|
|
|
|
var buttonRow = modal.find(".button-row");
|
|
|
|
var message = modal.find(".text");
|
|
|
|
message.innerHTML = text;
|
|
|
|
|
|
|
|
document.body.append(modal);
|
2013-09-01 18:09:09 +00:00
|
|
|
|
|
|
|
var clickButton = function() {
|
|
|
|
modal.remove();
|
2013-09-01 19:23:13 +00:00
|
|
|
var value = JSON.parse(this.value);
|
|
|
|
callback(value);
|
|
|
|
};
|
2013-09-01 18:09:09 +00:00
|
|
|
|
|
|
|
buttons.forEach(function(options) {
|
|
|
|
var button = document.createElement("button");
|
|
|
|
if (typeof options == "string") {
|
|
|
|
options = {
|
|
|
|
label: options,
|
2013-09-01 19:23:13 +00:00
|
|
|
value: JSON.stringify(options)
|
2013-09-01 18:09:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
button.innerHTML = options.label;
|
|
|
|
button.value = options.value;
|
|
|
|
buttonRow.append(button);
|
|
|
|
button.on("click", clickButton);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|