Skip to content

Commit

Permalink
Merge f526fef into 3103591
Browse files Browse the repository at this point in the history
  • Loading branch information
marykatefain committed Nov 5, 2018
2 parents 3103591 + f526fef commit 3604fba
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h6>Software</h6>
<div class="materials cards">
{% for course in course_materials %}
{% with course as course.specific %}
<div class="card" data-open="course-{{course.id}}-modal">
<div class="card" data-open="course-{{course.id}}-modal" id="{{ course.id }}">
<div class="card-divider">
<h2>{{ course.title }}</h2>
{{course.university }}
Expand Down Expand Up @@ -165,4 +165,5 @@ <h3>{{course.university }}</h3>

{% block extra_js %}
<script src="{% static "js/filters.js" %}"></script>
<script src="{% static "js/modals.js" %}">></script>
{% endblock %}
25 changes: 25 additions & 0 deletions project_tier/static/js/modals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Displays the element ID in the URL, and automatically opens the related modal if you navigate directly to the ID of the card


// Displays the ID ofthe card in the URL
function changeURL(e){
var hash = e.currentTarget.id;
window.location.hash = "#modal" + hash;
}

function getHashFromCards(){
var cards = document.querySelectorAll('.card');
for (i = 0; i < cards.length; i++) {
cards[i].addEventListener("click", changeURL);
}
}
getHashFromCards();


// Opens the modal on page load
function openModal(){
var location = window.location.hash.substring(6);;
var modal = "course-" + location + "-modal"
$("#" + modal).foundation("open");
}
openModal();

0 comments on commit 3604fba

Please sign in to comment.