wip: global UI refactoring

I'm almost done with the webmail :p
Mailboxes manipulation is working pretty well now.

see #204
This commit is contained in:
Antoine Nguyen
2012-04-19 15:21:18 +02:00
parent 4643f26e95
commit be2d5286ed
11 changed files with 336 additions and 146 deletions
-24
View File
@@ -3,30 +3,6 @@ $(document).ready(function() {
$(document).on('click', 'a[data-toggle="ajaxmodal-autowidth"]', modalbox_autowidth);
$(document).on('click', 'a[name=sendspam]', simple_ajax_request);
$(document).on('click', 'a[name=sendvirus]', simple_ajax_request);
//parse_menubar('#topmenubar');
//parse_menubar('#menubar');
/*infobox = new InfoBox({
parent : $("menubar"),
message : "Loading"
});*/
/* Specific javascript code for the demo... not the best place */
/*$$("a[name=sendspam], a[name=sendvirus]").addEvent("click", function(evt) {
evt.stop();
new Request.JSON({
url: this.get("href"),
onSuccess: function(response) {
if (response.status == "ok") {
infobox.info(gettext("Message sent"));
infobox.hide(1);
} else {
infobox.error(response.respmsg);
}
}
}).get();
});*/
});
var media_url = "";
+14 -4
View File
@@ -97,7 +97,13 @@ History.prototype = {
var res = this.base;
if (this.paramslength() != 0) {
res += "?" + $.param(this.params);
res += "?";
$.each(this.params, function(key, value) {
if (res != "?") {
res += "&";
}
res += key + "=" + encodeURIComponent(value);
});
}
return res;
},
@@ -144,9 +150,9 @@ History.prototype = {
return this;
},
getparam: function(name) {
getparam: function(name, defvalue) {
if (this.params[name] === undefined) {
return "";
return (defvalue != undefined) ? defvalue : undefined;
}
return this.params[name];
},
@@ -201,7 +207,7 @@ History.prototype = {
return;
}
delete(this.force);
this.from_string(location.hash);
this.from_string(decodeURIComponent(location.hash));
if (!this.serialized) {
location.hash = this.options.deflocation;
return;
@@ -222,6 +228,10 @@ History.prototype = {
} catch (e) {
resp = { status: 'ko', respmsg: gettext('Internal Error') };
}
if (resp.status == "ko") {
$("body").notify("error", resp.respmsg);
return;
}
var callback = (resp.callback != undefined) ? resp.callback : "default";
this.callbacks[callback](resp);
}, this)
+20 -1
View File
@@ -20,11 +20,30 @@ Poller.prototype = {
this.url = url;
this.options = $.extend({}, this.defaults, options);
this.running_request = false;
this.paused = false;
this.reset();
},
reset: function() {
setTimeout($.proxy(this.send_request, this), this.options.interval);
if (!this.paused) {
this.tid = setTimeout($.proxy(this.send_request, this), this.options.interval);
}
},
pause: function() {
this.paused = true;
if (!this.tid) {
return;
}
clearTimeout(this.tid);
},
resume: function() {
if (!this.paused) {
return;
}
this.paused = false;
this.reset();
},
send_request: function() {
+9 -8
View File
@@ -2,10 +2,12 @@
* Collection of functions that are accessible to every page.
*/
function modalbox(e, css, defhref, defcb) {
function modalbox(e, css, defhref, defcb, defclosecb) {
e.preventDefault();
var href = (defhref != undefined) ? defhref : $(this).attr('href');
var modalcb = (defcb != undefined) ? defcb : $(this).attr('modalcb');
var $this = $(this);
var href = (defhref != undefined) ? defhref : $this.attr('href');
var modalcb = (defcb != undefined) ? defcb : $this.attr('modalcb');
var closecb = (defclosecb != undefined) ? defclosecb : $this.attr("closecb");
if (href.indexOf('#') == 0) {
$(href).modal('open');
@@ -21,15 +23,14 @@ function modalbox(e, css, defhref, defcb) {
var $div = $('<div id="modalbox" class="modal" >' + data + '</div>')
.one('shown', function() {
if (modalcb != undefined) {
if (typeof modalcb === "function") {
modalcb();
} else {
eval(modalcb + '()');
}
if (typeof modalcb === "function") modalcb(); else eval(modalcb + '()');
}
})
.on('hidden', function() {
$("#modalbox").remove();
if (closecb != undefined) {
if (typeof closecb === "function") closecb(); else eval(closecb + '()');
}
})
.modal();