From 7ba916397d48557fc5211e80da5e30666e5f9aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20van=20der=20Essen?= Date: Mon, 16 Dec 2013 16:57:23 +0100 Subject: [PATCH] [FIX] point_of_sale: drag & dropping the debug widget bzr revid: fva@openerp.com-20131216155723-nnlv8223v9fr70nn --- addons/point_of_sale/static/src/js/widgets.js | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/widgets.js b/addons/point_of_sale/static/src/js/widgets.js index 105e65e8bed..0b795b9bdc5 100644 --- a/addons/point_of_sale/static/src/js/widgets.js +++ b/addons/point_of_sale/static/src/js/widgets.js @@ -705,10 +705,53 @@ function openerp_pos_widgets(instance, module){ //module is instance.point_of_sa 'payment_status', ], minimized: false, + init: function(parent,options){ + this._super(parent,options); + var self = this; + + this.minimized = false; + + // for dragging the debug widget around + this.dragging = false; + this.drag_x = 0; + this.drag_y = 0; + + this.mouseleave_handler = function(event){ + self.dragging = false; + }; + this.mouseup_handler = function(event){ + self.dragging = false; + }; + this.mousedown_handler = function(event){ + self.dragging = true; + self.drag_x = event.screenX; + self.drag_y = event.screenY; + }; + this.mousemove_handler = function(event){ + if(self.dragging){ + var top = this.offsetTop; + var left = this.offsetLeft; + var dx = event.screenX - self.drag_x; + var dy = event.screenY - self.drag_y; + + self.drag_x = event.screenX; + self.drag_y = event.screenY; + + this.style.right = 'auto'; + this.style.bottom = 'auto'; + this.style.left = left + dx + 'px'; + this.style.top = top + dy + 'px'; + } + }; + }, start: function(){ var self = this; - this.$el.draggable(); + this.el.addEventListener('mouseleave', this.mouseleave_handler); + this.el.addEventListener('mouseup', this.mouseup_handler); + this.el.addEventListener('mousedown', this.mousedown_handler); + this.el.addEventListener('mousemove', this.mousemove_handler); + this.$('.toggle').click(function(){ var content = self.$('.content'); var bg = self.$el;