From b4ad7f8543dbed4f6e1a8f2aa9d351735b01eb47 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 4 Dec 2014 16:35:17 +0000 Subject: [PATCH] Bind swipe handler on grid view in order to be able to select nm rows on touch devices via swipe left/right --- etemplate/js/et2_dataview_view_aoi.js | 33 +++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/etemplate/js/et2_dataview_view_aoi.js b/etemplate/js/et2_dataview_view_aoi.js index 066eee2c05..8cbefc99cf 100644 --- a/etemplate/js/et2_dataview_view_aoi.js +++ b/etemplate/js/et2_dataview_view_aoi.js @@ -15,6 +15,7 @@ /*egw:uses egw_action.egw_action_common; egw_action.egw_action; + /phpgwapi/js/jquery/TouchSwipe/jquery.touchSwipe.js; */ /** @@ -53,7 +54,7 @@ function et2_dataview_rowAOI(_node) * * @memberOf et2_dataview_rowAOI */ - var selectHandler = function(e) { + var selectHandler = function(e, _params) { // Reset the focus so that keyboard navigation will work properly // after the element has been clicked egwUnfocus(); @@ -61,12 +62,25 @@ function et2_dataview_rowAOI(_node) // Reset the prevent selection code (in order to allow wanted // selection of text) _node.onselectstart = null; - + if (e.target != aoi.checkBox) { var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED); var state = egwGetShiftState(e); - + + if (_params) + { + if (egwIsMobile()) + { + switch (_params.swip) + { + case "left": + case "right": + state = 1; + break; + } + } + } switch (aoi.selectMode) { case EGW_SELECTMODE_DEFAULT: @@ -83,7 +97,18 @@ function et2_dataview_rowAOI(_node) }; if (egwIsMobile()) { - _node.ontouchend = selectHandler; + $j(_node).swipe({ + allowPageScroll: "vertical", + swipe: function (event, direction) + { + selectHandler(event, {swip:direction}); + }, + click: function (event) + { + selectHandler(event); + }, + + }); } else { $j(_node).click(selectHandler); }