diff --git a/web/app/static/js/nopaque.js b/web/app/static/js/nopaque.js index 7677b06d..a8cad6ae 100644 --- a/web/app/static/js/nopaque.js +++ b/web/app/static/js/nopaque.js @@ -32,8 +32,13 @@ nopaque.socket.init = function() { // Add event handlers nopaque.socket.on("user_data_stream_init", function(msg) { nopaque.user = JSON.parse(msg); - for (let subscriber of nopaque.corporaSubscribers) {subscriber._init(nopaque.user.corpora);} - for (let subscriber of nopaque.jobsSubscribers) {subscriber._init(nopaque.user.jobs);} + for (let subscriber of nopaque.corporaSubscribers) { + subscriber._init(nopaque.user.corpora); + } + for (let subscriber of nopaque.jobsSubscribers) { + subscriber._init(nopaque.user.jobs); + } + RessourceList.modifyTooltips(false) }); nopaque.socket.on("user_data_stream_update", function(msg) { @@ -43,8 +48,12 @@ nopaque.socket.init = function() { nopaque.user = jsonpatch.apply_patch(nopaque.user, patch); corpora_patch = patch.filter(operation => operation.path.startsWith("/corpora")); jobs_patch = patch.filter(operation => operation.path.startsWith("/jobs")); - for (let subscriber of nopaque.corporaSubscribers) {subscriber._update(corpora_patch);} - for (let subscriber of nopaque.jobsSubscribers) {subscriber._update(jobs_patch);} + for (let subscriber of nopaque.corporaSubscribers) { + subscriber._update(corpora_patch); + } + for (let subscriber of nopaque.jobsSubscribers) { + subscriber._update(jobs_patch); + } if (["all", "end"].includes(nopaque.user.settings.job_status_site_notifications)) { for (operation of jobs_patch) { /* "/jobs/{jobId}/..." -> ["{jobId}", ...] */ @@ -59,8 +68,13 @@ nopaque.socket.init = function() { nopaque.socket.on("foreign_user_data_stream_init", function(msg) { nopaque.foreignUser = JSON.parse(msg); - for (let subscriber of nopaque.foreignCorporaSubscribers) {subscriber._init(nopaque.foreignUser.corpora);} - for (let subscriber of nopaque.foreignJobsSubscribers) {subscriber._init(nopaque.foreignUser.jobs);} + for (let subscriber of nopaque.foreignCorporaSubscribers) { + subscriber._init(nopaque.foreignUser.corpora); + } + for (let subscriber of nopaque.foreignJobsSubscribers) { + subscriber._init(nopaque.foreignUser.jobs); + } + RessourceList.modifyTooltips(false) }); nopaque.socket.on("foreign_user_data_stream_update", function(msg) { diff --git a/web/app/static/js/nopaque.lists.js b/web/app/static/js/nopaque.lists.js index 2fad01ab..2cfb6fd9 100644 --- a/web/app/static/js/nopaque.lists.js +++ b/web/app/static/js/nopaque.lists.js @@ -60,9 +60,28 @@ class RessourceList extends List { addRessources(ressources) { this.add(ressources.map(x => RessourceList.dataMapper[this.type](x))); } + + // Use this to modify tooltips to show after 750ms. If loaded is set to + // true (default) tooltips will only be initialized if DOMContentLoaded event + // triggered. If you do not want to wait for this event set pass false. + static modifyTooltips(waitForDOMContentLoaded=true) { + if (waitForDOMContentLoaded) { + document.addEventListener('DOMContentLoaded', function() { + var elems = document.querySelectorAll('.tooltipped'); + console.log(elems); + var instances = M.Tooltip.init(elems, {enterDelay: 750}); + }); + } else { + var elems = document.querySelectorAll('.tooltipped'); + console.log(elems); + var instances = M.Tooltip.init(elems, {enterDelay: 750}); + } + } } + + RessourceList.dataMapper = { // ### Mapping Genera Info //The Mapping describes entitys rendered per row. One key value pair holds @@ -163,10 +182,16 @@ RessourceList.options = {