[WIP] point_of_sale: automatically scroll to bottom
authorFrédéric van der Essen <fva@openerp.com>
Wed, 9 Oct 2013 12:51:28 +0000 (14:51 +0200)
committerFrédéric van der Essen <fva@openerp.com>
Wed, 9 Oct 2013 12:51:28 +0000 (14:51 +0200)
bzr revid: fva@openerp.com-20131009125128-yydt3l8vi8z2ik8p

addons/point_of_sale/static/src/js/widgets.js

index 476534b..4ddbafd 100644 (file)
@@ -210,6 +210,15 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
         },
         renderElement: function() {
             var self = this;
+            var scroller = this.$('.order-scroller')[0];
+            var scrollbottom = true;
+            if(scroller){
+                var overflow_bottom = scroller.scrollHeight - scroller.clientHeight;
+                var scrollTop = scroller.scrollTop;
+                if( scrollTop < 0.9 * overflow_bottom){
+                    scrollbottom = false;
+                }
+            }
             this._super();
 
             // freeing subwidgets
@@ -240,6 +249,11 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa
             }, this));
             this.update_numpad();
             this.update_summary();
+
+            scroller = this.$('.order-scroller')[0];
+            if(scroller && scrollbottom){
+                scroller.scrollTop = scroller.scrollHeight - scroller.clientHeight;
+            }
         },
         update_summary: function(){
             var order = this.pos.get('selectedOrder');