Some fixes about the infinite scroll.

see #585
This commit is contained in:
Antoine Nguyen
2014-09-19 16:12:32 +02:00
parent cf77624e3c
commit 2d1ca0a9cd
5 changed files with 21 additions and 9 deletions
@@ -94,7 +94,6 @@ Webmail.prototype = {
this.resize(); this.resize();
this.setup_infinite_scroll();
this.init_droppables(); this.init_droppables();
this.register_navcallbacks(); this.register_navcallbacks();
this.listen(); this.listen();
@@ -174,6 +173,13 @@ Webmail.prototype = {
var content = $("#emails").html() + data.listing; var content = $("#emails").html() + data.listing;
$("#emails").html(content); $("#emails").html(content);
},
end_of_list_reached: function($element) {
$element.append(
$("<div class='alert alert-info text-center' />").html(
gettext("No more message in this mailbox.")
)
);
} }
}); });
}, },
@@ -911,6 +917,7 @@ Webmail.prototype = {
this.htmltable = $("#emails").data("htmltable"); this.htmltable = $("#emails").data("htmltable");
this.init_draggables(); this.init_draggables();
$("#listing").css("overflow", "auto"); $("#listing").css("overflow", "auto");
this.setup_infinite_scroll();
}, },
add_field: function(e, name) { add_field: function(e, name) {
@@ -1,8 +1,8 @@
{% load i18n %} {% load i18n %}
{% load webmail_tags %} {% load webmail_tags %}
<div id="emails"> {% if with_top_div %}<div id="emails">{% endif %}
{% for email in emails %} {% for email in email_list %}
<div id="{{ email.imapid }}" class="row email{% if email.style %} {{ email.style }}{% endif %}"> <div id="{{ email.imapid }}" class="row email{% if email.style %} {{ email.style }}{% endif %}">
<div class="hidden-xs col-sm-1"> <div class="hidden-xs col-sm-1">
<img name="drag" src="{{ STATIC_URL }}pics/grippy.png" class="draggable" /> <img name="drag" src="{{ STATIC_URL }}pics/grippy.png" class="draggable" />
@@ -21,4 +21,4 @@
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
</div> {% if with_top_div %}</div>{% endif %}
+8 -3
View File
@@ -345,13 +345,18 @@ def listmailbox(request, defmailbox="INBOX", update_session=True):
elems_per_page=int(parameters.get_user(request.user, "MESSAGES_PER_PAGE")), elems_per_page=int(parameters.get_user(request.user, "MESSAGES_PER_PAGE")),
**request.session["webmail_navparams"] **request.session["webmail_navparams"]
) )
page = lst.paginator.getpage(navparams.get('page')) page_id = int(navparams.get('page'))
page = lst.paginator.getpage(page_id)
if page is not None: if page is not None:
email_list = lst.mbc.fetch(
page.id_start, page.id_stop, mbox,
nbelems=int(parameters.get_user(request.user, "MESSAGES_PER_PAGE"))
)
content = _render_to_string(request, "webmail/email_list.html", { content = _render_to_string(request, "webmail/email_list.html", {
"emails": lst.mbc.fetch(page.id_start, page.id_stop, mbox, nbelems=40) "email_list": email_list, "with_top_div": page_id == 1
}) })
else: else:
content = "<div class='alert alert-info'>%s</div>" % _("Empty mailbox") content = ""
return {"listing": content, "length": len(content)} return {"listing": content, "length": len(content)}
#return lst.render(request, navparams.get('page')) #return lst.render(request, navparams.get('page'))
+1 -1
View File
@@ -44,7 +44,7 @@
$this.$options.process_results(data); $this.$options.process_results(data);
if (data.length === 0) { if (data.length === 0) {
$this.end_of_results = true; $this.end_of_results = true;
/*$this.$element.find('#end-of-results').removeClass('hide');*/ $this.$options.end_of_list_reached($this.$element);
} }
//$this.$element.find('.spinner').addClass('hide'); //$this.$element.find('.spinner').addClass('hide');
$this.executing = false; $this.executing = false;
+1 -1
View File
@@ -11,7 +11,7 @@
if (bid === undefined) { if (bid === undefined) {
bid = "notifybox"; bid = "notifybox";
} }
var div = $("<div class='alert' />", { var div = $("<div class='alert alert-dismissible' role='alert' />", {
id: bid, id: bid,
click: $.proxy(this.destroy_box, this) click: $.proxy(this.destroy_box, this)
}).css({ }).css({