Branch 'roundcubemail-plugins-kolab-3.1' - plugins/tasklist

Thomas Brüderli bruederli at kolabsys.com
Thu Apr 17 19:34:02 CEST 2014


 plugins/tasklist/skins/larry/tasklist.css            |    2 
 plugins/tasklist/skins/larry/templates/mainview.html |    2 
 plugins/tasklist/tasklist.js                         |   57 +++++++++++++++++++
 3 files changed, 59 insertions(+), 2 deletions(-)

New commits:
commit b0df04df9871a1dc1110509516a49b39d8732714
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Thu Apr 17 19:33:06 2014 +0200

    Implement auto-scrolling when dragging task items (#2687)

diff --git a/plugins/tasklist/skins/larry/tasklist.css b/plugins/tasklist/skins/larry/tasklist.css
index e3adcb2..05e57de 100644
--- a/plugins/tasklist/skins/larry/tasklist.css
+++ b/plugins/tasklist/skins/larry/tasklist.css
@@ -671,7 +671,7 @@ ul.toolbarmenu li span.delete {
 #rootdroppable {
 	display: none;
 	position: absolute;
-	top: 36px;
+	top: 2px;
 	left: 1em;
 	right: 1em;
 	height: 5px;
diff --git a/plugins/tasklist/skins/larry/templates/mainview.html b/plugins/tasklist/skins/larry/templates/mainview.html
index 03557bb..40ae7bd 100644
--- a/plugins/tasklist/skins/larry/templates/mainview.html
+++ b/plugins/tasklist/skins/larry/templates/mainview.html
@@ -68,8 +68,8 @@
 		<div class="scroller">
 			<roundcube:object name="plugin.tasks" id="thelist" />
 			<div id="listmessagebox"></div>
+			<div id="rootdroppable"></div>
 		</div>
-		<div id="rootdroppable"></div>
 	</div>
 	
 	</div>
diff --git a/plugins/tasklist/tasklist.js b/plugins/tasklist/tasklist.js
index a5cb799..41ec403 100644
--- a/plugins/tasklist/tasklist.js
+++ b/plugins/tasklist/tasklist.js
@@ -67,6 +67,13 @@ function rcube_tasklist_ui(settings)
     var completeness_slider;
     var task_draghelper;
     var tag_draghelper;
+    var task_drag_active = false;
+    var list_scroll_top = 0;
+    var scroll_delay = 400;
+    var scroll_step = 5;
+    var scroll_speed = 20;
+    var scroll_sensitivity = 40;
+    var scroll_timer;
     var me = this;
 
     // general datepicker settings
@@ -819,6 +826,7 @@ function rcube_tasklist_ui(settings)
                 appendTo: 'body',
                 start: task_draggable_start,
                 stop: task_draggable_stop,
+                drag: task_draggable_move,
                 revertDuration: 300
             });
 
@@ -981,12 +989,45 @@ function rcube_tasklist_ui(settings)
 
         $(this).parent().addClass('dragging');
         $('#rootdroppable').show();
+
+        // enable auto-scrolling of list container
+        var container = $(rcmail.gui_objects.resultlist);
+        if (container.height() > container.parent().height()) {
+            task_drag_active = true;
+            list_scroll_top = container.parent().scrollTop();
+        }
+    }
+
+    function task_draggable_move(event, ui)
+    {
+        var scroll = 0,
+            mouse = rcube_event.get_mouse_pos(event),
+            container = $(rcmail.gui_objects.resultlist);
+
+        mouse.y -= container.parent().offset().top;
+
+        if (mouse.y < scroll_sensitivity && list_scroll_top > 0) {
+            scroll = -1; // up
+        }
+        else if (mouse.y > container.parent().height() - scroll_sensitivity) {
+            scroll = 1; // down
+        }
+
+        if (task_drag_active && scroll != 0) {
+            if (!scroll_timer)
+                scroll_timer = window.setTimeout(function(){ tasklist_drag_scroll(container, scroll); }, scroll_delay);
+        }
+        else if (scroll_timer) {
+            window.clearTimeout(scroll_timer);
+            scroll_timer = null;
+        }
     }
 
     function task_draggable_stop(event, ui)
     {
         $(this).parent().removeClass('dragging');
         $('#rootdroppable').hide();
+        task_drag_active = false;
     }
 
     function task_droppable_accept(draggable)
@@ -1056,6 +1097,22 @@ function rcube_tasklist_ui(settings)
         }
     }
 
+    /**
+     * Scroll list container in the given direction
+     */
+    function tasklist_drag_scroll(container, dir)
+    {
+        if (!task_drag_active)
+            return;
+
+        var old_top = list_scroll_top;
+        container.parent().get(0).scrollTop += scroll_step * dir;
+        list_scroll_top = container.parent().scrollTop();
+        scroll_timer = null;
+
+        if (list_scroll_top != old_top)
+            scroll_timer = window.setTimeout(function(){ tasklist_drag_scroll(container, dir); }, scroll_speed);
+    }
 
     /**
      * Show task details in a dialog




More information about the commits mailing list