I think the refactoring is over :-) I need to add specifec events that will allow plugins to define their own roles inside the hierarchy.

Otherwise, the graphical part needs some improvment, actually it's not really pretty :p
This commit is contained in:
tonio
2010-11-26 17:35:23 +01:00
parent eff3c7d815
commit bd32445e3e
13 changed files with 250 additions and 137 deletions
+15 -15
View File
@@ -12,11 +12,11 @@ callbacks = {};
register_callback = function(name, callback) {
callbacks[name] = callback;
}
};
get_callback = function(name) {
return callbacks[name];
}
};
current_anchor = null;
@@ -43,13 +43,13 @@ check_anchor = function() {
infobox.info(gettext("Done"));
infobox.hide(1);
}}).get();
}
};
ajaxListener = function(deflocation, defcallback) {
current_anchor = new HashWrapper(deflocation);
register_callback("default", defcallback);
check_anchor.periodical(300);
}
};
/*
*
@@ -154,7 +154,7 @@ function HashWrapper(deflocation) {
return "";
}
return this.params.get(name);
}
};
this.baseurl = function(value) {
this.reset();
@@ -213,7 +213,7 @@ parse_menubar = function(id) {
parse: 'rel'
});
}
}
};
get_iframe_body = function(id) {
var saf = navigator.userAgent.match(/Safari/i);
@@ -233,7 +233,7 @@ get_iframe_body = function(id) {
data = targetif.contentWindow.document.body;
}
return (data);
}
};
confirmation = function(question, action, callback) {
SqueezeBox.initialize({
@@ -259,7 +259,7 @@ confirmation = function(question, action, callback) {
}
});
SqueezeBox.open("/modoboa/userprefs/confirm/?question=" + question);
}
};
setDivHeight = function(id, extrah, modulo) {
var contentsize = $(document.body).getSize().y
@@ -272,7 +272,7 @@ setDivHeight = function(id, extrah, modulo) {
contentsize -= contentsize % modulo;
}
$(id).setStyle("height", contentsize + "px");
}
};
bindRows = function(rooturl, page) {
$$("tr").addEvent("click", function(event) {
@@ -282,20 +282,20 @@ bindRows = function(rooturl, page) {
location.href = url;
}
});
}
};
toggleSelection = function(id, value) {
$$("input[name=" + id + "]").each(function(obj) {
obj.checked = value;
});
}
};
checkTableSelection = function(text) {
if (!$$("tr[class*=table-tr-selected]").length) {
return false;
}
return confirm(text);
}
};
searchbox_init = function() {
var myFx = new Fx.Slide($("searchparams"));
@@ -343,7 +343,7 @@ searchbox_init = function() {
$("crit_" + params.criteria).checked = true;
}
}
}
};
// The following code prevents a bug under IE7 because fullpath is
// returned instead of a relative one. (even if mootools uses
@@ -358,7 +358,7 @@ gethref = function(obj) {
return url.replace(baseurl, "");
}
return url;
}
};
saveparams = function(id, message) {
$$("input[name=update]").addEvent("click", function(evt) {
@@ -373,4 +373,4 @@ saveparams = function(id, message) {
}
}).send();
});
}
};
+3 -3
View File
@@ -4,15 +4,15 @@ window.addEvent('domready', function() {
if ($defined($("domcontent"))) {
SqueezeBox.assign($("domcontent").getElements('a[class=boxed]'), {
parse: 'rel',
parse: 'rel'
});
}
if ($defined($("subcontent"))) {
SqueezeBox.assign($("subcontent").getElements('a[class=boxed]'), {
parse: 'rel',
parse: 'rel'
});
}
if ($$("a[name=deleteDom]"))
$$("a[name=deleteDom]").addEvent('click', function(event) {
if (!confirm(gettext("Delete this domain?")))
+15 -15
View File
@@ -17,36 +17,36 @@ window.addEvent("domready", function() {
}
});
obj.send();
}
};
generic_submit = function(obj, event, id, callback, onerror) {
event.stop();
sqbsubmit(obj, "content", id, callback, onerror);
}
domain_submit = function(event) {
generic_submit(this, event, "domform", domain_submit);
}
mailbox_submit = function(event) {
generic_submit(this, event, "mboxform", mailbox_submit);
}
alias_submit = function(event) {
generic_submit(this, event, "aliasform", alias_submit);
}
};
domain_submit = function(event) {
generic_submit(this, event, "domform", domain_submit);
};
mailbox_submit = function(event) {
generic_submit(this, event, "mboxform", mailbox_submit);
};
alias_submit = function(event) {
generic_submit(this, event, "aliasform", alias_submit);
};
permission_submit = function(event) {
generic_submit(this, event, "permform", permission_submit);
}
};
chpassword_submit = function(event) {
generic_submit(this, event, "chpwdform", chpassword_submit);
}
};
arm_onerror = function() {
new Calendar({id_untildate: "Y-m-d"}, {
tweak: {x: -100, y:-100}
});
}
};
arm_submit = function(event) {
generic_submit(this, event, "armform", arm_submit, arm_onerror);
}
};
if ($("domform"))
$("domform").addEvent("submit", domain_submit);
+1 -1
View File
@@ -101,7 +101,7 @@ var InfoBox = new Class({
}
this.box.setStyle("display", "block");
},
hide: function(timer) {
if ($defined(timer)) {
this.timer = this.hide.periodical(timer * 1000, this);
+37 -5
View File
@@ -1,12 +1,12 @@
window.addEvent('domready', function() {
var tip = new Tips($$(".Tips"));
var addperm_url = "";
var current_role = "";
var accordion = new Accordion('h3.atStart', 'div.atStart', {
opacity: true,
onActive: function(toggler, element){
toggler.setStyle('color', '#ff3300');
addperm_url = element.get("name");
current_role = element.get("id");
},
onBackground: function(toggler, element) {
@@ -16,13 +16,45 @@ window.addEvent('domready', function() {
$$("a[name=addperm]").addEvent("click", function(evt) {
evt.stop();
if (addperm_url == "") {
return;
}
SqueezeBox.initialize({
size: {x: 300, y: 280},
handler: 'iframe'
});
var addperm_url = evt.target.get("href") + "?role=" + current_role;
SqueezeBox.open(addperm_url);
});
$$("a[name=delperms]").addEvent("click", function(evt) {
evt.stop();
var selection = $(current_role).getElements("input[id=selection]:checked");
if (selection.length == 0) {
return;
}
if (!confirm(gettext("Remove this selection?"))) {
return;
}
var sr_selection = "";
selection.each(function(item) {
if (sr_selection != "") {
sr_selection += ",";
}
sr_selection += item.get("value");
});
new Request.JSON({
url : evt.target.get("href"),
onSuccess: function(response) {
if (response.status == "ok") {
$(current_role).set("html", response.content);
infobox.info(response.message);
} else {
infobox.error(response.message);
}
infobox.hide(2);
}
}).send({
method: "get",
data: "role=" + current_role + "&selection=" + sr_selection
});
});
});
+1 -7
View File
@@ -1,10 +1,4 @@
window.addEvent('domready', function() {
if ($$("a[name=deletePerm]"))
$$("a[name=deletePerm]").addEvent('click', function(event) {
if (!confirm(gettext("Remove this permission?")))
event.stop();
});
var tip = new Tips($$(".Tips"));
var accordion = new Accordion('h3.atStart', 'div.atStart', {
@@ -12,7 +6,7 @@ window.addEvent('domready', function() {
onActive: function(toggler, element){
toggler.setStyle('color', '#ff3300');
},
onBackground: function(toggler, element){
toggler.setStyle('color', '#222');
}