var ConfirmBoxes = Class.create();
ConfirmBoxes.prototype = {
initialize: function() {
// void
},
init: function() {
this.apply('confirm');
this.apply('delete');
},
apply: function(sClass) {
var oLinks = getElementsByClass(sClass);
if (!oLinks) return;
var n = oLinks.length;
for (var i=0; i<n;i++) {
return this.create(oLinks[i]);
}
},
create: function(elm) {
var sTitle = elm.title;
Event.observe(elm, "click", this.ask(sTitle))
},
ask: function(sTitle) {
if (!sTitle) {
return confirm("Er du sikker?");
}
else {
return confirm(sTitle);
}
}
}
var myConfirmBoxes = new ConfirmBoxes();
Event.observe(window, "load", myConfirmBoxes.init);
|