From 23c9f70dade651f3774d7c3c3ec942bccc4c33bb Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Tue, 21 Oct 2014 15:21:23 +0000 Subject: [PATCH] Implement to set proper lable for dragging item on the drag helper --- phpgwapi/js/egw_action/egw_action_dragdrop.js | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/phpgwapi/js/egw_action/egw_action_dragdrop.js b/phpgwapi/js/egw_action/egw_action_dragdrop.js index de9a9e6b81..fe12d96268 100644 --- a/phpgwapi/js/egw_action/egw_action_dragdrop.js +++ b/phpgwapi/js/egw_action/egw_action_dragdrop.js @@ -97,6 +97,8 @@ function egwDragActionImplementation() var rows = []; // Maximum number of rows to show var maxRows = 3; + // item label + var itemLabel = egw.lang(egw.link_get_registry(egw.app_name(),_selected.length > 1?'entries':'entry')||egw.app_name()); var index = 0; for (var i = 0; i < _selected.length;i++) @@ -114,11 +116,9 @@ function egwDragActionImplementation() var spanCnt = $j(document.createElement('span')) .addClass('et2_egw_action_ddHelper_itemsCnt') .appendTo(div); - - // TODO: get the right drag item next to the number - var itemLabel = ''; - spanCnt.text(_selected.length + itemLabel); + spanCnt.text(_selected.length +' '+ itemLabel); + // Number of not shown rows var restRows = _selected.length - maxRows; if (restRows) { @@ -134,7 +134,7 @@ function egwDragActionImplementation() // Add notice of Ctrl key, if supported if('draggable' in document.createElement('span') && - navigator && navigator.userAgent.indexOf('Chrome') >= 0) + navigator && navigator.userAgent.indexOf('Chrome') >= 0 && egw.app_name() == 'filemanager') // currently only filemanager supports drag out { var key = ["Mac68K","MacPPC","MacIntel"].indexOf(window.navigator.platform) < 0 ? 'Ctrl' : 'Command'; text.text(egw.lang('Hold %1 to drag %2 to your computer',key, itemLabel)); @@ -298,6 +298,32 @@ function egwDragActionImplementation() "start": function(e) { return ai.helper != null; }, + revert: function(valid) + { + var dTarget = this; + if (!valid) + { + // Tolerance value of pixels arround the draggable target + // to distinguish whether the action was intended for dragging or selecting content. + var tipTelorance = 10; + var helperTop = ai.helper.position().top; + + if (helperTop >= dTarget.offset().top + && helperTop <= (dTarget.height() + dTarget.offset().top) + tipTelorance) + { + var key = ["Mac68K","MacPPC","MacIntel"].indexOf(window.navigator.platform) < 0 ? 'Ctrl' : 'Command'; + // Comment this out ATM till we get the ctrl and content selection functionality working + //egw.message(egw.lang('Hold %1 key to select content.', key),'info'); + } + // Invalid target + return true; + } + else + { + // Valid target + return false; + } + }, // Solves problem with scroll position changing in the grid // component "refreshPositions": true,