2010-02-01 09:31:50 +01:00
|
|
|
DialogSystem = {
|
2010-02-12 03:23:26 +01:00
|
|
|
_layers: []
|
2010-02-01 09:31:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
DialogSystem.showDialog = function(elmt, onCancel) {
|
|
|
|
var overlay = $('<div> </div>')
|
2010-02-12 03:23:26 +01:00
|
|
|
.addClass("dialog-overlay")
|
2010-02-01 09:31:50 +01:00
|
|
|
.css("z-index", 101 + DialogSystem._layers.length * 2)
|
|
|
|
.appendTo(document.body);
|
|
|
|
|
|
|
|
var container = $('<div></div>')
|
|
|
|
.addClass("dialog-container")
|
|
|
|
.css("z-index", 102 + DialogSystem._layers.length * 2)
|
|
|
|
.appendTo(document.body);
|
|
|
|
|
|
|
|
elmt.css("visibility", "hidden").appendTo(container);
|
|
|
|
container.css("top", Math.round((overlay.height() - elmt.height()) / 2) + "px");
|
|
|
|
elmt.css("visibility", "visible");
|
|
|
|
|
2010-03-08 22:50:53 +01:00
|
|
|
container.draggable({ handle: '.dialog-header', cursor: 'move' });
|
|
|
|
|
2010-02-01 09:31:50 +01:00
|
|
|
var layer = {
|
|
|
|
overlay: overlay,
|
|
|
|
container: container,
|
|
|
|
onCancel: onCancel
|
|
|
|
};
|
|
|
|
DialogSystem._layers.push(layer);
|
|
|
|
|
|
|
|
var level = DialogSystem._layers.length;
|
|
|
|
return level;
|
|
|
|
};
|
|
|
|
|
|
|
|
DialogSystem.dismissAll = function() {
|
|
|
|
DialogSystem.dismissUntil(0);
|
|
|
|
};
|
|
|
|
|
|
|
|
DialogSystem.dismissUntil = function(level) {
|
|
|
|
for (var i = DialogSystem._layers.length - 1; i >= level; i--) {
|
|
|
|
var layer = DialogSystem._layers[i];
|
|
|
|
layer.overlay.remove();
|
|
|
|
layer.container.remove();
|
2010-10-17 22:49:54 +02:00
|
|
|
layer.container.unbind();
|
2010-02-01 09:31:50 +01:00
|
|
|
|
|
|
|
if (layer.onCancel) {
|
|
|
|
try {
|
|
|
|
layer.onCancel();
|
|
|
|
} catch (e) {
|
2010-09-23 00:55:28 +02:00
|
|
|
Refine.reportException(e);
|
2010-02-01 09:31:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DialogSystem._layers = DialogSystem._layers.slice(0, level);
|
|
|
|
};
|
|
|
|
|
|
|
|
DialogSystem.createDialog = function() {
|
|
|
|
return $('<div></div>').addClass("dialog-frame");
|
|
|
|
};
|
|
|
|
|
2010-02-19 18:38:47 +01:00
|
|
|
DialogSystem.showBusy = function(message) {
|
|
|
|
var frame = DialogSystem.createDialog();
|
2010-03-23 20:30:50 +01:00
|
|
|
frame.addClass("dialog-busy-frame");
|
2010-02-19 18:38:47 +01:00
|
|
|
|
|
|
|
var body = $('<div>').addClass("dialog-busy-body").appendTo(frame);
|
|
|
|
$('<img>').attr("src", "images/large-spinner.gif").appendTo(body);
|
|
|
|
$('<span>').text(" " + (message || "Working...")).appendTo(body);
|
|
|
|
|
|
|
|
var level = DialogSystem.showDialog(frame);
|
|
|
|
|
|
|
|
return function() {
|
|
|
|
DialogSystem.dismissUntil(level - 1);
|
|
|
|
};
|
|
|
|
};
|