From 6b98fef679235507155062801c736510371964c0 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 23 May 2018 12:01:03 +0200 Subject: [PATCH] Remove ES6 code in kanban --- www/kanban/jkanban.js | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/www/kanban/jkanban.js b/www/kanban/jkanban.js index 029e86074..65dc24d2e 100644 --- a/www/kanban/jkanban.js +++ b/www/kanban/jkanban.js @@ -116,12 +116,23 @@ // TODO: update board object board order console.log("Drop " + $(el).attr("data-id") + " just before " + (sibling ? $(sibling).attr("data-id") : " end ")); - var index1 = self.options.boards.findIndex(function (element) { - return element.id == $(el).attr("data-id"); + var index1, index2; + self.options.boards.some(function (element, index) { + if (element.id === $(el).attr("data-id")) { + index1 = index; + return true; + } }); - var index2 = sibling ? self.options.boards.findIndex(function (element) { - return element.id == $(sibling).attr("data-id"); - }) : self.options.boards.length; + if (sibling) { + self.options.boards.some(function (element, index) { + if (element.id === $(sibling).attr("data-id")) { + index2 = index; + return true; + } + }) + } else { + index2 = self.options.boards.length; + } console.log("Switch " + index1 + " and " + index2); if (index1 < index2) index2 = index2 - 1; @@ -177,11 +188,17 @@ console.log("In drop"); // TODO: update board object board order - var board1 = self.options.boards.find(function (element) { - return element.id == $(source.parentNode).attr("data-id"); + var board1; + self.options.boards.some(function (element) { + if (element.id === $(source.parentNode).attr("data-id")) { + return board1 = element; + } }); - var board2 = self.options.boards.find(function (element) { - return element.id == $(target.parentNode).attr("data-id"); + var board2; + self.options.boards.some(function (element) { + if (element.id === $(target.parentNode).attr("data-id")) { + return board2 = element; + } }); var pos1 = self.dragItemPos; var pos2 = (sibling) ? self.findElementPosition(sibling) : (board2.item.length + 1);