From 8bc8a6b08fe58796809ad24101c9680979c6c694 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 10 Mar 2020 17:38:49 +0100 Subject: [PATCH] Add link support --- www/kanban/inner.js | 10 ++++++++++ www/kanban/jkanban.js | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/www/kanban/inner.js b/www/kanban/inner.js index dd7518c2d..a9176adbf 100644 --- a/www/kanban/inner.js +++ b/www/kanban/inner.js @@ -541,6 +541,15 @@ define([ }).click(function (e) { e.stopPropagation(); }); }; + var openLink = function (href) { + if (/^\/[^\/]/.test(href)) { + var privateData = framework._.cpNfInner.metadataMgr.getPrivateData(); + href = privateData.origin + href; + } + framework._.sfCommon.openUnsafeURL(href); + }; + + var kanban = new window.jKanban({ element: '#cp-app-kanban-content', gutter: '5px', @@ -736,6 +745,7 @@ define([ addItemButton: true, getTextColor: getTextColor, getAvatar: getAvatar, + openLink: openLink, cursors: remoteCursors, boards: boards }); diff --git a/www/kanban/jkanban.js b/www/kanban/jkanban.js index 19c51b6f6..37c3b0772 100644 --- a/www/kanban/jkanban.js +++ b/www/kanban/jkanban.js @@ -57,6 +57,7 @@ list: [] }, getAvatar: function () {}, + openLink: function () {}, getTextColor: function () { return '#000'; }, cursors: {}, tags: [], @@ -395,6 +396,12 @@ var html = self.renderMd(element.body); var nodeBody = document.createElement('div'); nodeBody.classList.add('kanban-item-body'); + $(nodeBody).on('click', 'a', function (e) { + e.preventDefault(); + var a = e.target; + if (!a.href) { return; } + self.options.openLink(a.href); + }); nodeBody.onclick = function (e) { e.preventDefault(); };