wip: Global user interface improvment

* The quarantine manager is done
* The webmail is not yet completed
* Cleanup
* More...
This commit is contained in:
Antoine Nguyen
2012-03-27 12:02:46 +02:00
parent 4dae056d87
commit e10bba2d4e
38 changed files with 746 additions and 461 deletions
+25
View File
@@ -2,6 +2,14 @@ body {
padding-top: 60px;
}
#fixed_content {
position: absolute;
top: 60px;
right: 0;
left: 0;
overflow: hidden;
}
#bottom-bar {
position: fixed;
left: 0;
@@ -46,6 +54,19 @@ body {
margin-bottom: 8px;
}
.dropdown-menu .radio {
padding: 3px 33px;
}
.no-margin {
margin: 0;
}
.dropdown-menu label:hover {
background-color: #0088CC;
color: white;
}
.spaced select,
.spaced input[type="text"] {
margin-bottom: 8px;
@@ -62,3 +83,7 @@ body {
.buttons_list .active {
display: block;
}
.tr-selected {
background-color: #F5F5F5;
}
-15
View File
@@ -233,21 +233,6 @@ function searchbox_init() {
}
};
// The following code prevents a bug under IE7 because fullpath is
// returned instead of a relative one. (even if mootools uses
// getAttribute("href", 2), this is not working for AJAX requests)
gethref = function(obj) {
var url = obj.get("href");
var re = new RegExp("^(https?):");
var scheme = re.exec(url);
if (scheme != null) {
var baseurl = scheme[0] + "://" + location.host + location.pathname;
return url.replace(baseurl, "");
}
return url;
};
/*function saveparams(id, message) {
$("#update").click(function(evt) {
evt.preventDefault();
+8 -8
View File
@@ -12,20 +12,20 @@ function navbarcallback(event) {
}
function updatelisting(resp) {
if ($defined(resp.url)) {
current_anchor.baseurl(resp.url).update();
if (resp.url != undefined) {
history.baseurl(resp.url).update();
return;
}
if ($defined(resp.menu)) {
/*if (resp.menu != undefined) {
$("menubar").set("html", resp.menu);
parse_menubar("menubar");
}*/
if (resp.listing != undefined) {
$("#listing").html(resp.listing);
}
if ($defined(resp.listing)) {
$("listing").set("html", resp.listing);
}
if ($defined(resp.navbar)) {
/*if ($defined(resp.navbar)) {
$("navbar").set("html", resp.navbar);
$$("#navbar a").addEvent("click", navbarcallback);
}
}*/
}
+35 -15
View File
@@ -1,16 +1,5 @@
var History = function(options) {
this.options = $.extend({}, this.defaults, options);
this.callbacks = {};
this.params = {};
this.base = '';
this.serialized = null;
this.updatenext = true;
this.reset_loading_infos();
if (this.options.defcallback) {
this.register_callback("default", this.options.defcallback);
this.check_id =
setInterval($.proxy(this.check, this), this.options.checkinterval);
}
this.initialize(options);
};
History.prototype = {
@@ -24,6 +13,34 @@ History.prototype = {
defcallback: null
},
initialize: function(options) {
this.options = $.extend({}, this.defaults, options);
this.callbacks = {};
this.base = '';
this.serialized = null;
this.updatenext = true;
this.load_params();
this.reset_loading_infos();
if (this.options.defcallback) {
this.register_callback("default", this.options.defcallback);
this.check_id =
setInterval($.proxy(this.check, this), this.options.checkinterval);
}
},
load_params: function() {
var rawqs = window.location.hash.substr(1);
if (rawqs.indexOf('?')) {
this.params = {};
return;
}
var tmp = rawqs.split('?');
rawqs = (tmp.length == 1) ? tmp[0] : tmp[1];
this.params = parse_qs(rawqs.split('&'));
},
paramslength: function() {
return Object.keys(this.params).length;
},
@@ -34,7 +51,7 @@ History.prototype = {
},
reset: function() {
this.base = null;
this.base = "";
this.params = {};
return this;
},
@@ -100,7 +117,9 @@ History.prototype = {
},
deleteParam: function(str) {
this.params.erase(str);
if (this.params[str] != undefined) {
delete this.params[str];
}
},
updateparams: function(str) {
@@ -111,6 +130,7 @@ History.prototype = {
for (var i = 0; i < elems.length; i++) {
this.setparamfromstring(elems[i]);
}
return this;
},
setparamfromstring: function(str) {
@@ -124,7 +144,7 @@ History.prototype = {
},
setparams: function(params) {
this.params.extend(params);
this.params = $.extend({}, this.params, params);
return this;
},
+127
View File
@@ -0,0 +1,127 @@
(function($) {
var HtmlTable = function(element, options) {
this.initialize(element, options);
};
HtmlTable.prototype = {
constructor: HtmlTable,
initialize: function(element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.htmltable.defaults, options);
this.shift_pressed = false;
this.last_selection = null;
this.prev_dir = null;
this.listen();
this.$element.css({
"-moz-user-select": "-moz-none",
"-khtml-user-select": "none",
"-webkit-user-select": "none",
"-ms-user-select": "none",
"user-select": "none"
});
this.$element.attr("unselectable", "on");
},
listen: function() {
$(document).on("click", "tbody>tr",
$.proxy(this.toggle_select, this));
$(document).on("keydown", "body", $.proxy(this.keydown, this));
$(document).on("keyup", "body", $.proxy(this.keyup, this));
},
_toggle_select: function($tr) {
this.last_selection = $tr;
if ($tr.hasClass(this.options.tr_selected_class)) {
$tr.removeClass(this.options.tr_selected_class);
} else {
$tr.addClass(this.options.tr_selected_class);
}
},
toggle_select: function(e) {
e.preventDefault();
var $tr = $(e.target).parent();
if (this.shift_pressed && this.last_selection) {
var itfunc = ($tr.index() >= this.last_selection.index())
? "next" : "prev";
var $curtr = null;
if (this.prev_dir && itfunc != this.prev_dir) {
$curtr = this.last_selection;
} else {
$curtr = this.last_selection[itfunc]("tr");
}
for (; $curtr.length; $curtr = $curtr[itfunc]("tr")) {
this._toggle_select($curtr);
if ($tr.attr("id") == $curtr.attr("id")) {
break;
}
}
this.prev_dir = itfunc;
return;
}
this._toggle_select($tr);
},
current_selection: function() {
return $("tr[class*=" + this.options.tr_selected_class + "]");
},
/*
* Cancel the current selection
*/
clear_selection: function() {
this.current_selection().removeClass(this.options.tr_selected_class);
},
/*
* Manually select a table row
*/
select_row: function($row) {
$row.addClass(this.options.tr_selected_class);
},
keydown: function(e) {
switch (e.which) {
case 16:
e.preventDefault();
this.shift_pressed = true;
break;
}
},
keyup: function(e) {
switch (e.which) {
case 16:
e.preventDefault();
this.shift_pressed = false;
break;
}
}
};
$.fn.htmltable = function(method) {
var args = arguments;
return this.each(function() {
var $this = $(this),
data = $this.data('htmltable'),
options = typeof method === "object" && method;
if (!data) {
$this.data('htmltable', new HtmlTable(this, options));
data = $this.data('htmltable');
}
if (typeof method === "string") {
data[method].apply(data, Array.prototype.slice.call(args, 1));
}
});
};
$.fn.htmltable.defaults = {
tr_selected_class: 'tr-selected'
};
})(jQuery);
+68
View File
@@ -0,0 +1,68 @@
(function($) {
var SearchBar = function(element, options) {
this.initialize(element, options);
};
SearchBar.prototype = {
constructor: SearchBar,
initialize: function(element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.searchbar.defaults, options);
this.$element.change($.proxy(this.pattern_change, this));
this.$element.click(function(e) {
$(this).select();
});
this.$element.blur(function(e) {
var $this = $(this);
if ($this.attr("value") == "") {
$this.attr("value", gettext("Search..."));
}
});
if (this.options.navobj.params.pattern != undefined) {
this.$element.attr("value", this.options.navobj.params.pattern);
}
if (this.options.navobj.params.criteria != undefined) {
$("#crit_" + this.options.navobj.params.criteria).attr("checked", "checked");
}
},
pattern_change: function(e) {
var $input = $(e.target);
var criteria = $("input[name=scriteria]:checked").attr("value");
var pattern = $input.attr("value");
if (pattern != "") {
this.options.navobj.setparams({
pattern: pattern,
criteria: criteria
});
} else {
this.options.navobj.deleteParam("pattern");
this.options.navobj.deleteParam("criteria");
this.options.navobj.deleteParam("page");
}
this.options.navobj.update();
}
};
$.fn.searchbar = function(method) {
return this.each(function() {
var $this = $(this),
data = $this.data('searchbar'),
options = typeof method === "object" && method;
if (!data) {
$this.data('searchbar', new SearchBar(this, options));
}
if (typeof method === "string") {
data[method]();
}
});
};
$.fn.searchbar.defaults = {
navobj: null
};
})(jQuery);
+36
View File
@@ -123,6 +123,42 @@ function simple_ajax_form_post(e, options) {
});
}
/*
* The following code prevents a bug under IE7 because fullpath is
* returned instead of a relative one. (even if mootools uses
* getAttribute("href", 2), this is not working for AJAX requests)
*/
function gethref(obj) {
var url = $(obj).attr("href");
var re = new RegExp("^(https?):");
var scheme = re.exec(url);
if (scheme != null) {
var baseurl = scheme[0] + "://" + location.host + location.pathname;
return url.replace(baseurl, "");
}
return url;
};
/*
* Extract the current URL parameters into a dictionnary.
*
* Ref:
* http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript
*/
function parse_qs(raw) {
if (raw == "") return {};
var res = {};
for (var i = 0; i < raw.length; i++) {
var p = raw[i].split('=');
if (p.length != 2) continue;
res[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return res;
}
/*
* Simple wrapper around Request.JSON. We just ensure that
* redirections are correctly catched. (on session timeout for