From 5f26d9bf3439dffa2e72939722697481a9df9200 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 27 Dec 2017 09:13:41 +0100 Subject: [PATCH] Prevent "calling draggable before initailization" errors Elastic skin disables dragging on folders list, so we have to check if it's still draggable before we call draggable() again. Otherwise it will throw an error. --- program/js/app.js | 4 +++- program/js/treelist.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/program/js/app.js b/program/js/app.js index 65e0bada88f..2fbe31bb294 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -7121,7 +7121,9 @@ function rcube_webmail() } // disable drag-n-drop temporarily - this.subscription_list.draggable('destroy').droppable('destroy'); + // some skins disable dragging in mobile mode, so we have to check if it is still draggable + if (this.subscription_list.is_draggable()) + this.subscription_list.draggable('destroy').droppable('destroy'); var row, n, tmp, tmp_name, rowid, collator, pos, p, parent = '', folders = [], list = [], slist = [], diff --git a/program/js/treelist.js b/program/js/treelist.js index d84cfaae891..1f932f30481 100644 --- a/program/js/treelist.js +++ b/program/js/treelist.js @@ -89,6 +89,7 @@ function rcube_treelist_widget(node, p) this.intersects = intersects; this.droppable = droppable; this.draggable = draggable; + this.is_draggable = is_draggable; this.update = update_node; this.insert = insert; this.remove = remove; @@ -1245,6 +1246,11 @@ function rcube_treelist_widget(node, p) return this; } + + function is_draggable() + { + return !!ui_draggable; + } } // use event processing functions from Roundcube's rcube_event_engine