From 782dab135b5226735bbf1b99b7cd9f9e0aadd139 Mon Sep 17 00:00:00 2001 From: "stefan.r" <stefan.r@551886.no-reply.drupal.org> Date: Thu, 29 Sep 2016 17:30:45 +0100 Subject: [PATCH] Issue #1261002 by LewisNyman, Pere Orga, nod_, Trey, quicksketch, jessebeach, mglaman, blueshadow2911, sabsbrain, Fabianx: Draggable tables do not work on touch screen devices --- CHANGELOG.txt | 1 + misc/tabledrag.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 002663290ff9..c2ce49df2bb1 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -6,6 +6,7 @@ Drupal 7.51, xxxx-xx-xx (development version) - Exceptions thrown in dblog_watchdog() are now caught and ignored. - Clarified the warning that appears when modules are missing or have moved. - If the page title is "0", it is now displayed. +- Draggable tables do now work on touch screen devices. - Numerous small performance improvements. - Numerous small bugfixes. - Numerous API documentation improvements. diff --git a/misc/tabledrag.js b/misc/tabledrag.js index 3cc270194f9b..416eed46ba6b 100644 --- a/misc/tabledrag.js +++ b/misc/tabledrag.js @@ -106,8 +106,10 @@ Drupal.tableDrag = function (table, tableSettings) { // Add mouse bindings to the document. The self variable is passed along // as event handlers do not have direct access to the tableDrag object. - $(document).bind('mousemove', function (event) { return self.dragRow(event, self); }); - $(document).bind('mouseup', function (event) { return self.dropRow(event, self); }); + $(document).bind('mousemove pointermove', function (event) { return self.dragRow(event, self); }); + $(document).bind('mouseup pointerup', function (event) { return self.dropRow(event, self); }); + $(document).bind('touchmove', function (event) { return self.dragRow(event.originalEvent.touches[0], self); }); + $(document).bind('touchend', function (event) { return self.dropRow(event.originalEvent.touches[0], self); }); }; /** @@ -274,7 +276,10 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) { }); // Add the mousedown action for the handle. - handle.mousedown(function (event) { + handle.bind('mousedown touchstart pointerdown', function (event) { + if(event.originalEvent.type == "touchstart"){ + event=event.originalEvent.touches[0]; + } // Create a new dragObject recording the event information. self.dragObject = {}; self.dragObject.initMouseOffset = self.getMouseOffset(item, event); -- GitLab