From 9c4a25f8f94fffd2ffc2b854822b2e7ef6a02dbb Mon Sep 17 00:00:00 2001 From: Gauthier Bastien Date: Fri, 27 Nov 2020 17:16:42 +0100 Subject: [PATCH] Renamed JS function `loadCollapsibleContent` to `loadContent` as it can be used outside of `collapsible` scope. --- CHANGES.rst | 3 +++ src/imio/helpers/browser/static/helpers.js | 16 +++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2e18e4d..ff83760 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,6 +13,9 @@ Changelog - Fixed `content.richtextval` `outputMimeType` parameter to use `text/x-html-safe` instead `text/html`. [gbastien] +- Renamed JS function `loadCollapsibleContent` to `loadContent` as it can be + used outside of `collapsible` scope. + [gbastien] 0.35 (2020-11-18) ----------------- diff --git a/src/imio/helpers/browser/static/helpers.js b/src/imio/helpers/browser/static/helpers.js index 8e954e2..44d054a 100644 --- a/src/imio/helpers/browser/static/helpers.js +++ b/src/imio/helpers/browser/static/helpers.js @@ -68,11 +68,11 @@ function toggleDetails(id, toggle_parent_active=true, parent_tag=null, load_view } inner_content_tag = $('div.collapsible-inner-content', tag)[0]; if (load_view && !inner_content_tag.dataset.loaded) { - loadCollapsibleContent(tag, load_view, async=true, base_url) + loadContent(inner_content_tag, load_view, async=true, base_url, event_name="toggle_details_ajax_success") } } -function loadCollapsibleContent(tag, load_view, async=true, base_url=null) { +function loadContent(tag, load_view, async=true, base_url=null, event_name=null) { // load content in the collapsible-inner-content div var url = base_url || canonical_url(); url = url + '/' + load_view; @@ -83,13 +83,15 @@ function loadCollapsibleContent(tag, load_view, async=true, base_url=null) { cache: false, async: async, success: function(data) { - inner_content_tag.innerHTML = data; - inner_content_tag.dataset.loaded = true; + tag.innerHTML = data; + tag.dataset.loaded = true; /* trigger event when ajax success, this let's register some JS * initialization in returned HTML */ - $.event.trigger({ - type: "toggle_details_ajax_success", - tag: tag}); + if (event_name) { + $.event.trigger({ + type: event_name, + tag: tag}); + } }, error: function(jqXHR, textStatus, errorThrown) { /*console.log(textStatus);*/