From e0c039b0e50c7bb5a177a962466a36dece9b2ad4 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Tue, 30 Oct 2012 14:47:38 +0100 Subject: [PATCH] [IMP] mail: convert dom search on_scroll by filter js bzr revid: chm@openerp.com-20121030134738-h5ypheuze05ohy20 --- addons/mail/static/src/js/mail.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 42976eff1a5..799f14c2116 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -830,6 +830,9 @@ openerp.mail = function (session) { event.stopPropagation(); var self=this; var button = self.$('.oe_star:first'); + + console.log(window); + return this.ds_message.call('favorite_toggle', [[self.id]]) .then(function (star) { self.is_favorite=star; @@ -841,7 +844,6 @@ openerp.mail = function (session) { self.check_for_destroy(); } }); - return false; }, /** @@ -948,19 +950,18 @@ openerp.mail = function (session) { /* When the expandable object is visible on screen (with scrolling) * then the on_expandable function is launch */ - on_scroll: function (event) { - if (event)event.stopPropagation(); - $last = this.$('> .oe_msg_expandable:last'); - if ($last.hasClass('oe_max_limit')) { - var pos = $last.position(); + on_scroll: function () { + var expandables = + _.each( _.filter(this.messages, function (val) {return val.id < 0;}), function (val) { + var pos = val.$el.position(); if (pos.top) { /* bottom of the screen */ var bottom = $(window).scrollTop()+$(window).height()+200; if (bottom > pos.top) { - $last.find('.oe_msg_more_message').click(); + val.on_expandable(); } } - } + }); }, /**