diff --git a/.doit.db.db b/.doit.db.db index 9505a32..37d2620 100644 Binary files a/.doit.db.db and b/.doit.db.db differ diff --git a/files/assets/js/gancio-events-detect.js b/files/assets/js/gancio-events-detect.js index 6837ce8..ed6d533 100644 --- a/files/assets/js/gancio-events-detect.js +++ b/files/assets/js/gancio-events-detect.js @@ -2,8 +2,8 @@ * Detect no next Gancio events and deactivate Next events */ -function GetNextEventsCount() { - const entryComponent = document.querySelector('#nextevents'); +function GetNextEventsCount(ge_id) { + const entryComponent = document.querySelector('#' + ge_id); const shadowRoot = entryComponent.shadowRoot; const app = shadowRoot.querySelector('div'); if (app != null) { @@ -13,11 +13,11 @@ function GetNextEventsCount() { } } -function ActivePastEvents() { - const nexttab = document.getElementById("tab-0"); - const next = document.getElementById("tab-pane-0"); - const pasttab = document.getElementById("tab-1"); - const past = document.getElementById("tab-pane-1"); +function ActivePastEvents(tab_next, tab_past) { + const nexttab = document.getElementById("tab-" + tab_next); + const next = document.getElementById("tab-pane-" + tab_next); + const pasttab = document.getElementById("tab-" + tab_past); + const past = document.getElementById("tab-pane-" + tab_past); if (nexttab != null && next !== null){ next.classList.remove("active"); nexttab.classList.remove("active"); @@ -30,8 +30,8 @@ function ActivePastEvents() { } } -function ActivePastEventsIfNotNexts() { - if (GetNextEventsCount() == 0) { - ActivePastEvents(); +function ActivePastEventsIfNotNexts(ge_id, tab_next, tab_past) { + if (GetNextEventsCount(ge_id) == 0) { + ActivePastEvents(tab_next, tab_past); } } diff --git a/pages/events.md b/pages/events.md index f2f9cb1..d34cdc1 100644 --- a/pages/events.md +++ b/pages/events.md @@ -22,4 +22,4 @@ -{{% gancio-events-detect %}} +{{% gancio-events-detect ge_id='nextevents' tab_next='0' tab_past='1' %}} diff --git a/shortcodes/gancio-events-detect.tmpl b/shortcodes/gancio-events-detect.tmpl index 9f196fb..3418b29 100644 --- a/shortcodes/gancio-events-detect.tmpl +++ b/shortcodes/gancio-events-detect.tmpl @@ -1,6 +1,28 @@ <%doc> Load gancio-events-detect.js and call ActivePastEventsIfNotNexts() when page is load + +Template engine: Mako + +Usage: +tab_next, tab_past + {{% gancio-events-detect ge_id= [tab_next=] [tab_past=] %}} + +where is the ID of past gancio-events HTML tag, tab_next and tab_past are the number of tabs for next and past events +% if tab_next is UNDEFINED: + <% tn = '0' %> +% else: + <% tn = tab_next %> +% endif +% if tab_past is UNDEFINED: + <% tp = '1' %> +% else: + <% tp = tab_past %> +% endif + <% site.template_hooks['body_end'].append('') %> -<% site.template_hooks['body_end'].append('') %> + +<% params = '\"' + ge_id + '\", \"' + tn + '\", \"' + tp + '\"' %> + +<% site.template_hooks['body_end'].append('') %> diff --git a/shortcodes/tabpannel.tmpl b/shortcodes/tabpannel.tmpl index 1360b72..058a7b5 100644 --- a/shortcodes/tabpannel.tmpl +++ b/shortcodes/tabpannel.tmpl @@ -23,7 +23,6 @@ separate each tab from the next with two blank lines. Where is the numb <% tabs = data.split('\n\n\n') %> -## <% lines = [item for item in lines if item != ''] %> <% ntabs = len(tabs) %> % if active is UNDEFINED: <% act = None %>