# HG changeset patch
# User Adrián Romero <adrianromero@openbravo.com>
# Date 1510154078 -3600
#      Wed Nov 08 16:14:38 2017 +0100
# Node ID b80c6d75d9471dff7b91987b2f7714fbc998f011
# Parent  eb4f6d869f18fef5488838640fae8ff5ae31fd08
Adding touch scrolling functionality to *ScrollableTable* enyo component

diff --git a/web/org.openbravo.mobile.core/source/component/ob-scrollabletable.js b/web/org.openbravo.mobile.core/source/component/ob-scrollabletable.js
--- a/web/org.openbravo.mobile.core/source/component/ob-scrollabletable.js
+++ b/web/org.openbravo.mobile.core/source/component/ob-scrollabletable.js
@@ -7,7 +7,7 @@
  ************************************************************************************
  */
 
-/*global OB, enyo, _, $*/
+/*global OB, enyo, _, $, document */
 
 enyo.kind({
   name: 'OB.UI.ScrollableTableHeader',
@@ -24,9 +24,41 @@
     listStyle: null,
     selectionMode: 'single'
   },
+  statics: {
+    initScroll: function (component) {
+
+      var moving = false;
+
+      var isTouchDevice = function () {
+          var newElement = document.createElement('div');
+          newElement.setAttribute('ongesturestart', 'return;');
+          return newElement.ongesturestart instanceof Function;
+          };
+
+      if (!isTouchDevice()) {
+        component.handlers = component.handlers || {};
+        component.handlers.onmousedown = 'scrollMouseDown';
+        component.scrollMouseDown = function (inSender, inEvent) {
+          moving = true;
+        };
+        enyo.dispatcher.listen(document, 'mouseup', function (ev) {
+          moving = false;
+        });
+        enyo.dispatcher.listen(document, 'mousemove', function (ev) {
+          if (moving) {
+            component.hasNode().scrollTop = component.hasNode().scrollTop - ev.movementY;
+          }
+        });
+      }
+    }
+  },
   events: {
     onSetMultiSelection: ''
   },
+  initComponents: function () {
+    this.inherited(arguments);
+    OB.UI.ScrollableTable.initScroll(this.$.scrollArea);
+  },
   autoSelectOnReset: true,
   getValue: function (arg, lineIndex) {
     //Automated test
