see #55: folders manipulation. Work in progress.

This commit adds the following features:
 * Folder creation,
 * Folder modification,
 * Folder removal.

There are still issues with subfolders but they should not be too complicated to fix.

I've also done some javascript refactoring.
This commit is contained in:
Antoine Nguyen
2011-03-17 17:41:10 +01:00
parent 4adecda984
commit 67357e66af
17 changed files with 504 additions and 141 deletions
+75 -52
View File
@@ -1,59 +1,82 @@
window.addEvent("domready", function() {
ajax_submit = function(event, error_callbacks) {
var form = event.target;
var myid = form.get("id");
var error_callbacks = {
mbaliasform: function() {
if ($("id_domain").value == 0) {
$("id_mboxes").set("html", "");
}
mbaliasform_init();
},
permform: function() {
if ($defined($("id_domain"))) {
$("id_domain").options[0].setProperty("selected", "selected");
domadminform_init();
}
}
};
event.stop();
form.set('send', {
onSuccess: function(responseText) {
var response = JSON.decode(responseText);
var extra_data_callbacks = {
if (response.status == "ko") {
$(document.body).set("html", response.content);
$(document.body).addEvent("submit", default_submit);
if ($defined(error_callbacks[myid])) {
error_callbacks[myid]();
}
} else {
if (response.url != "") {
parent.location.href = response.url;
}
parent.SqueezeBox.close();
};
function register_callback(hash, name, callback) {
if ($defined(hash[name])) {
return false;
}
hash[name] = callback;
return true;
}
function register_error_callback(name, callback) {
return register_callback(error_callbacks, name, callback);
}
function register_extra_data_callback(name, callback) {
return register_callback(extra_data_callbacks, name, callback);
}
function ajax_submit(event) {
var form = event.target;
var myid = form.get("id");
var data = form.toQueryString();
event.stop();
if ($defined(extra_data_callbacks[myid])) {
if (data != "") {
data += "&";
}
data += extra_data_callbacks[myid]();
}
new Request({
method: form.get("method"),
data: data,
onSuccess: function(responseText) {
var response = JSON.decode(responseText);
if (response.status == "ko") {
$(document.body).set("html", response.content);
$(document.body).addEvent("submit", ajax_submit);
if ($defined(error_callbacks[myid])) {
error_callbacks[myid]();
}
} else {
if ($defined(response.url) && response.url != "") {
parent.location.href = response.url;
}
if ($defined(response.ajaxnav)) {
parent.current_anchor.update(1);
}
},
onFailure: function(xhr) {
parent.document.getElement('iframe').setStyles({width: 800, height: 600});
$(document.body).set("html", xhr.responseText);
}
});
form.send();
};
parent.SqueezeBox.close();
}
},
onFailure: function(xhr) {
parent.document.getElement('iframe').setStyles({width: 800, height: 600});
$(document.body).set("html", xhr.responseText);
}
}).send();
}
default_submit = function(event) {
var error_callbacks = {
mbaliasform: function() {
if ($("id_domain").value == 0) {
$("id_mboxes").set("html", "");
}
mbaliasform_init();
},
armform: function() {
new Calendar({id_untildate: "Y-m-d"}, {
tweak: {x: -100, y:-100}
});
},
permform: function() {
if ($defined($("id_domain"))) {
$("id_domain").options[0].setProperty("selected", "selected");
domadminform_init();
}
}
};
ajax_submit(event, error_callbacks);
};
$(document.body).addEvent("submit", default_submit);
window.addEvent("domready", function() {
$(document.body).addEvent("submit", ajax_submit);
$$("input[type!=submit]", "select").addEvents({
focus: function(evt) {
Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B