From cb1355120af647d16ce993d9f871ebd356b8f04c 2018-01-10 15:04:16 From: James Polley Date: 2018-01-10 15:04:16 Subject: [PATCH] Make the per-day tabs work --- diff --git a/pinaxcon/templates/symposion/schedule/schedule_conference.html b/pinaxcon/templates/symposion/schedule/schedule_conference.html index 7b8d92bf0ae87af5c2ce74097ef06ed5c54d2fbd..70dfa0a7843bfe8d67aaf579421f768f78929d61 100644 --- a/pinaxcon/templates/symposion/schedule/schedule_conference.html +++ b/pinaxcon/templates/symposion/schedule/schedule_conference.html @@ -18,35 +18,38 @@ {% block breadcrumbs %}{% endblock %} -
-
- -
-
+
+
+
-
+ + +
+
{% for section in sections %} {% cache 600 "schedule-table" section.schedule.section %} {% for timetable in section.days %} -
+

{{ section.schedule.section.name }} — {{ timetable.day.date|date:"l" }}, {{ timetable.day.date }}

{% include "symposion/schedule/_grid.html" %}
{% endfor %} {% endcache %} {% endfor %} -
{% endblock %} @@ -80,46 +83,31 @@ } } - document.addEventListener("DOMContentLoaded", function(event) { + document.addEventListener("hashchange", function(event) { + fragment = window.location.hash.toLowerCase().substring(1); if (!fragment) { return; - } - - fragmentSwitch = "schedule_day_" + fragment; - - switches = document.getElementsByClassName("panel--tab-switch"); - tabs = document.getElementsByClassName("panel--tab-content"); + }; - for (i = 0; i < switches.length; i++) { - - if (switches[i].id == fragmentSwitch) { - switches[i].classList.add("is-active"); - tabs[i].classList.add("is-active"); - } else { - switches[i].classList.remove("is-active"); - tabs[i].classList.remove("is-active"); - } - } + fragmentid = "#schedule_day_" + fragment + "-tab"; + $(fragmentid).tab('show'); }); - window.addEventListener("load", function(event) { - - $(".panel--tab-switch").click(function(event) { + $(".nav-item").click(function(event) { // This updates the window location fragment so that // the URL bar is updated, and so that when you go // back, it loads the right page. // len("schedule_day_") == 13 - day = event.target.id.substring(13); + day_tab = event.target.id.substring(13); + day = day_tab.substr(0, day_tab.length-4); if(history.pushState) { history.pushState(null, null, "#" + day); } }); - }); - {{ block.super }} {% endblock %}