mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-23 06:38:40 +02:00
First version of the sieve plugin is over \o/ It needs more testing but all functionalities are implemented. Maybe some extra sieve extensions would be nice but I'll see that based on user feedback.
I also include some general refactoring in this commit. see #139
This commit is contained in:
+1
-1
@@ -73,7 +73,7 @@ td.even {
|
||||
|
||||
.title h1 {
|
||||
float: left;
|
||||
margin: 5px 10px;
|
||||
margin: 5px;
|
||||
font-size: medium;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Class that implements a simple anchor based navigation system for
|
||||
* AJAX applications.
|
||||
*/
|
||||
var AnchorNavigation = new Class({
|
||||
Implements: [Options],
|
||||
|
||||
options: {
|
||||
checkinterval: 300,
|
||||
defloadingtext: gettext("Loading..."),
|
||||
defloadingcolor: "gray",
|
||||
defcallback: null
|
||||
},
|
||||
|
||||
initialize: function(deflocation, options) {
|
||||
this.setOptions(options);
|
||||
|
||||
this.deflocation = deflocation;
|
||||
this.callbacks = {};
|
||||
this.params = $H();
|
||||
this.base = '';
|
||||
this.serialized = null;
|
||||
this.reset_loading_infos();
|
||||
if (this.options.defcallback) {
|
||||
this.register_callback("default", this.options.defcallback);
|
||||
this.ca_id =
|
||||
this.check_anchor.bind(this).periodical(this.options.checkinterval);
|
||||
}
|
||||
},
|
||||
|
||||
reset_loading_infos: function() {
|
||||
this.loading_message = this.options.defloadingtext;
|
||||
this.loading_color = this.options.defloadingcolor;
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
this.base = null;
|
||||
this.params.empty();
|
||||
return this;
|
||||
},
|
||||
|
||||
parse_string: function(value, reset) {
|
||||
var splits = (value.charAt(0) == '#')
|
||||
? value.substring(1).split('?') : value.split('?');
|
||||
|
||||
if (splits.length == 0) {
|
||||
return this;
|
||||
}
|
||||
if (!$defined(reset)) {
|
||||
reset = false;
|
||||
}
|
||||
if (reset) {
|
||||
this.reset();
|
||||
}
|
||||
this.base = (splits[0] == "") ? this.deflocation : splits[0];
|
||||
|
||||
var re = new RegExp("/$");
|
||||
if (!this.base.match(re)) {
|
||||
this.base += '/';
|
||||
}
|
||||
if (splits.length > 1) {
|
||||
var params = splits[1].split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var tmp = params[i].split('=');
|
||||
this.setparam(tmp[0], tmp[1]);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
from_string: function(value, reset) {
|
||||
this.parse_string(value);
|
||||
this.serialized = value;
|
||||
return this;
|
||||
},
|
||||
|
||||
serialize: function() {
|
||||
var res = this.base;
|
||||
|
||||
if (this.params.getLength() != 0) {
|
||||
res += "?" + this.params.toQueryString();
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
update: function(force) {
|
||||
window.fireEvent("pageRefresh");
|
||||
location.hash = this.serialize();
|
||||
if ($defined(force)) {
|
||||
this.force = force;
|
||||
}
|
||||
},
|
||||
|
||||
deleteParam: function(str) {
|
||||
this.params.erase(str);
|
||||
},
|
||||
|
||||
updateparams: function(str) {
|
||||
if (str.charAt(0) == '?') {
|
||||
str = str.substring(1);
|
||||
}
|
||||
var elems = str.split('&');
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
this.setparamfromstring(elems[i]);
|
||||
}
|
||||
},
|
||||
|
||||
setparamfromstring: function(str) {
|
||||
var def = str.split('=');
|
||||
this.params.set(def[0], def[1]);
|
||||
},
|
||||
|
||||
setparam: function(name, value) {
|
||||
this.params.set(name, value);
|
||||
return this;
|
||||
},
|
||||
|
||||
setparams: function(params) {
|
||||
this.params.extend(params);
|
||||
return this;
|
||||
},
|
||||
|
||||
getparam: function(name) {
|
||||
if (!this.params.has(name)) {
|
||||
return "";
|
||||
}
|
||||
return this.params.get(name);
|
||||
},
|
||||
|
||||
baseurl: function(value, noreset) {
|
||||
if (!$defined(noreset) || noreset == 0) {
|
||||
this.reset();
|
||||
}
|
||||
this.base = value;
|
||||
var re = new RegExp("/$");
|
||||
if (!this.base.match(re)) {
|
||||
this.base += '/';
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
addbaseurl: function(value) {
|
||||
var newbase = this.base + value;
|
||||
return this.baseurl(newbase);
|
||||
},
|
||||
|
||||
getbaseurl: function() {
|
||||
return this.base.substr(0, this.base.length - 1);
|
||||
},
|
||||
|
||||
delparam: function(name) {
|
||||
if (!this.params.has(name)) {
|
||||
return false;
|
||||
}
|
||||
this.params.erase(name);
|
||||
return this;
|
||||
},
|
||||
|
||||
register_callback: function(name, callback) {
|
||||
this.callbacks[name] = callback;
|
||||
},
|
||||
|
||||
get_callback: function(name) {
|
||||
return this.callbacks[name];
|
||||
},
|
||||
|
||||
set_default_callback: function(callback) {
|
||||
this.register_callback("default", callback);
|
||||
if (!$defined(this.ca_id)) {
|
||||
this.ca_id =
|
||||
this.check_anchor.bind(this).periodical(this.options.checkinterval);
|
||||
}
|
||||
},
|
||||
|
||||
check_anchor: function() {
|
||||
if (this.serialized == location.hash
|
||||
&& !$defined(this.force)) {
|
||||
return;
|
||||
}
|
||||
delete(this.force);
|
||||
this.from_string(location.hash);
|
||||
if (!this.serialized) {
|
||||
location.hash = this.deflocation;
|
||||
return;
|
||||
}
|
||||
|
||||
var query = this.serialized.substring(1);
|
||||
|
||||
infobox.show(this.loading_message, {
|
||||
profile: this.loading_color,
|
||||
spinner: true
|
||||
});
|
||||
new Request.JSON({
|
||||
url: query,
|
||||
noCache : true,
|
||||
onSuccess: function(resp) {
|
||||
var callback = ($defined(resp.callback)) ? resp.callback : "default";
|
||||
this.callbacks[callback](resp);
|
||||
infobox.info(gettext("Done"));
|
||||
infobox.hide(1);
|
||||
this.reset_loading_infos();
|
||||
}.bind(this),
|
||||
onFailure: function(xhr) {
|
||||
$(document.body).set("html", xhr.responseText);
|
||||
$(document.body).setStyle("overflow", "auto");
|
||||
}
|
||||
}).get();
|
||||
}
|
||||
});
|
||||
@@ -9,7 +9,6 @@ window.addEvent('domready', function(){
|
||||
});
|
||||
|
||||
var media_url = "";
|
||||
callbacks = {};
|
||||
|
||||
/*
|
||||
* A simple function to initialize the value of the global variable
|
||||
@@ -27,202 +26,6 @@ function static_url(value) {
|
||||
return media_url + value;
|
||||
}
|
||||
|
||||
function register_callback(name, callback) {
|
||||
callbacks[name] = callback;
|
||||
};
|
||||
|
||||
get_callback = function(name) {
|
||||
return callbacks[name];
|
||||
};
|
||||
|
||||
/*
|
||||
* AJAX anchor based navigation
|
||||
*/
|
||||
var current_anchor = null;
|
||||
|
||||
function check_anchor() {
|
||||
if (current_anchor.serialized == location.hash
|
||||
&& !$defined(current_anchor.force)) {
|
||||
return;
|
||||
}
|
||||
delete(current_anchor.force);
|
||||
current_anchor.from_string(location.hash);
|
||||
if (!current_anchor.serialized) {
|
||||
location.hash = current_anchor.deflocation;
|
||||
return;
|
||||
}
|
||||
|
||||
var query = current_anchor.serialized.substring(1);
|
||||
|
||||
infobox.show(current_anchor.loading_message, {
|
||||
profile: current_anchor.loading_color,
|
||||
spinner: true
|
||||
});
|
||||
new Request.JSON({
|
||||
url: query,
|
||||
noCache : true,
|
||||
onSuccess: function(resp) {
|
||||
var callback = ($defined(resp.callback)) ? resp.callback : "default";
|
||||
callbacks[callback](resp);
|
||||
infobox.info(gettext("Done"));
|
||||
infobox.hide(1);
|
||||
current_anchor.reset_loading_infos();
|
||||
},
|
||||
onFailure: function(xhr) {
|
||||
$(document.body).set("html", xhr.responseText);
|
||||
$(document.body).setStyle("overflow", "auto");
|
||||
}
|
||||
}).get();
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize the AJAX anchor based navigation
|
||||
*/
|
||||
function ajaxListener(deflocation, defcallback) {
|
||||
current_anchor = new HashWrapper(deflocation);
|
||||
register_callback("default", defcallback);
|
||||
check_anchor.periodical(300);
|
||||
};
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
function HashWrapper(deflocation) {
|
||||
this.deflocation = deflocation;
|
||||
this.params = $H();
|
||||
this.base = '';
|
||||
this.serialized = null;
|
||||
|
||||
this.reset_loading_infos = function() {
|
||||
this.loading_message = gettext("Loading...");
|
||||
this.loading_color = "gray";
|
||||
};
|
||||
this.reset_loading_infos();
|
||||
|
||||
this.reset = function() {
|
||||
this.base = null;
|
||||
this.params.empty();
|
||||
return this;
|
||||
};
|
||||
|
||||
this.parse_string = function(value, reset) {
|
||||
var splits = (value.charAt(0) == '#')
|
||||
? value.substring(1).split('?') : value.split('?');
|
||||
|
||||
if (splits.length == 0) {
|
||||
return this;
|
||||
}
|
||||
if (!$defined(reset)) {
|
||||
reset = false;
|
||||
}
|
||||
if (reset) {
|
||||
this.reset();
|
||||
}
|
||||
this.base = (splits[0] == "") ? this.deflocation : splits[0];
|
||||
|
||||
var re = new RegExp("/$");
|
||||
if (!this.base.match(re)) {
|
||||
this.base += '/';
|
||||
}
|
||||
if (splits.length > 1) {
|
||||
var params = splits[1].split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var tmp = params[i].split('=');
|
||||
this.setparam(tmp[0], tmp[1]);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
this.from_string = function(value, reset) {
|
||||
this.parse_string(value);
|
||||
this.serialized = value;
|
||||
return this;
|
||||
};
|
||||
|
||||
this.serialize = function() {
|
||||
var res = this.base;
|
||||
|
||||
if (this.params.getLength() != 0) {
|
||||
res += "?" + this.params.toQueryString();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
this.update = function(force) {
|
||||
window.fireEvent("pageRefresh");
|
||||
location.hash = this.serialize();
|
||||
if ($defined(force)) {
|
||||
this.force = force;
|
||||
}
|
||||
};
|
||||
|
||||
this.deleteParam = function(str) {
|
||||
this.params.erase(str);
|
||||
};
|
||||
|
||||
this.updateparams = function(str) {
|
||||
if (str.charAt(0) == '?') {
|
||||
str = str.substring(1);
|
||||
}
|
||||
var elems = str.split('&');
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
this.setparamfromstring(elems[i]);
|
||||
}
|
||||
};
|
||||
|
||||
this.setparamfromstring = function(str) {
|
||||
var def = str.split('=');
|
||||
this.params.set(def[0], def[1]);
|
||||
};
|
||||
|
||||
this.setparam = function(name, value) {
|
||||
this.params.set(name, value);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.setparams = function(params) {
|
||||
this.params.extend(params);
|
||||
return this;
|
||||
};
|
||||
|
||||
this.getparam = function(name) {
|
||||
if (!this.params.has(name)) {
|
||||
return "";
|
||||
}
|
||||
return this.params.get(name);
|
||||
};
|
||||
|
||||
this.baseurl = function(value, noreset) {
|
||||
if (!$defined(noreset) || noreset == 0) {
|
||||
this.reset();
|
||||
}
|
||||
this.base = value;
|
||||
var re = new RegExp("/$");
|
||||
if (!this.base.match(re)) {
|
||||
this.base += '/';
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
this.addbaseurl = function(value) {
|
||||
var newbase = this.base + value;
|
||||
return this.baseurl(newbase);
|
||||
};
|
||||
|
||||
this.getbaseurl = function() {
|
||||
return this.base.substr(0, this.base.length - 1);
|
||||
};
|
||||
|
||||
this.delparam = function(name) {
|
||||
if (!this.params.has(name)) {
|
||||
return false;
|
||||
}
|
||||
this.params.erase(name);
|
||||
return this;
|
||||
};
|
||||
};
|
||||
|
||||
function parse_menubar(id) {
|
||||
if ($(id)) {
|
||||
$(id).getElements('li.dropdown').each(function(elem){
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
window.addEvent('domready', function() {
|
||||
var handlers = new Array();
|
||||
|
||||
if ($defined($("domcontent"))) {
|
||||
SqueezeBox.assign($("domcontent").getElements('a[class=boxed]'), {
|
||||
parse: 'rel'
|
||||
});
|
||||
}
|
||||
if ($defined($("subcontent"))) {
|
||||
SqueezeBox.assign($("subcontent").getElements('a[class=boxed]'), {
|
||||
parse: 'rel'
|
||||
|
||||
@@ -10,6 +10,7 @@ var DynamicTextInput = new Class({
|
||||
if (!$defined(targets) || !targets.length) {
|
||||
return;
|
||||
}
|
||||
this.fields_cnt = 0;
|
||||
for (var cpt = 0; cpt < targets.length; cpt++) {
|
||||
var target = targets[cpt];
|
||||
var btn;
|
||||
@@ -18,31 +19,28 @@ var DynamicTextInput = new Class({
|
||||
btn = new Element("img", {
|
||||
src: parent.static_url("pics/add.png")
|
||||
});
|
||||
btn.addEvent("click", this.newinput.bind(this));
|
||||
btn.addEvent("click", this.newelement.bind(this));
|
||||
} else {
|
||||
var btnid = "btn_" + cpt;
|
||||
btn = new Element("img", {
|
||||
src: parent.static_url("pics/remove.png"),
|
||||
id: btnid
|
||||
});
|
||||
btn.addEvent("click", this.removeinput.bind(this));
|
||||
btn.addEvent("click", this.removeelement.bind(this));
|
||||
}
|
||||
btn.setStyles({
|
||||
"float": "right",
|
||||
"margin-top": "2px"
|
||||
});
|
||||
btn.inject(target, "after");
|
||||
this.fields_cnt++;
|
||||
}
|
||||
this.nextid = targets.length;
|
||||
this.target = targets[0];
|
||||
this.setOptions(options);
|
||||
},
|
||||
|
||||
newinput: function(event) {
|
||||
if (this.target.get("value") == "") {
|
||||
return;
|
||||
}
|
||||
var coords = this.target.getCoordinates();
|
||||
createfield: function() {
|
||||
var div = new Element("div").addClass("row");
|
||||
var label = new Element("label").inject(div);
|
||||
var ninput = new Element("input", {
|
||||
@@ -51,6 +49,15 @@ var DynamicTextInput = new Class({
|
||||
name: this.target.get("name"),
|
||||
value: this.target.get("value")
|
||||
}).inject(div);
|
||||
|
||||
return [div, ninput];
|
||||
},
|
||||
|
||||
newelement: function(event) {
|
||||
if (this.target.get("value") == "") {
|
||||
return;
|
||||
}
|
||||
var field = this.createfield();
|
||||
var delbtn = new Element("img", {
|
||||
id: "delbtn_" + this.nextid,
|
||||
src: parent.static_url("pics/remove.png")
|
||||
@@ -61,17 +68,19 @@ var DynamicTextInput = new Class({
|
||||
"float" : "right",
|
||||
"margin-top": "2px"
|
||||
});
|
||||
div.inject(this.target.getParent(), "after");
|
||||
delbtn.inject(ninput, "after");
|
||||
delbtn.addEvent("click", this.removeinput.bind(this));
|
||||
field[0].inject(this.target.getParent(), "after");
|
||||
delbtn.inject(field[1], "after");
|
||||
delbtn.addEvent("click", this.removeelement.bind(this));
|
||||
this.target.set("value", "");
|
||||
this.fields_cnt++;
|
||||
},
|
||||
|
||||
removeinput: function(event) {
|
||||
removeelement: function(event) {
|
||||
var id = (event.target.get("id").split("_"))[1];
|
||||
var input = $("id_" + this.target.get("name") + "_" + id);
|
||||
|
||||
input.destroy();
|
||||
event.target.destroy();
|
||||
this.fields_cnt--;
|
||||
}
|
||||
});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 683 B |
Binary file not shown.
|
After Width: | Height: | Size: 652 B |
Reference in New Issue
Block a user