Commit 7e39c856 authored by tobiasmeyrick's avatar tobiasmeyrick
Browse files

Modified showHide.js to use jQuery

parent 981bf1a1
Pipeline #4097 passed with stage
in 17 seconds
This diff is collapsed.
......@@ -10,7 +10,7 @@ var PrintCart = (function() {
Otherwise print out a list of cart items
*/
if (window.sessionStorage.getItem("cartlist") == null) {
div.innerHTML = "<p>There are currently no items in your cart.</p>";
$(div).append("<p>There are currently no items in your cart.</p>");
$(form).css("display", "none");
} else {
/* Make a heading */
......
......@@ -6,16 +6,16 @@ var ShowHide = (function() {
"use strict";
var paragraphs, p, img;
/*jshint -W040*/
paragraphs = this.parentNode.getElementsByTagName("p");
img = this.parentNode.getElementsByTagName("img");
paragraphs = $(this).parent().find("p");
img = $(this).parent().find("img");
/*jshint +W040*/
for (p = 0; p < paragraphs.length; p += 1) {
if (paragraphs[p].style.display === "none") {
paragraphs[p].style.display = "block";
img[0].style.display = "block";
for (let paragraph of paragraphs) {
if ($(paragraph).css("display") === "none") {
$(paragraph).css("display", "block");
$(img).css("display", "block");
} else {
paragraphs[p].style.display = "none";
img[0].style.display = "none";
$(paragraph).css("display", "none");
$(img).css("display", "none");
}
}
......@@ -25,22 +25,18 @@ var ShowHide = (function() {
pub.setup = function() {
"use strict";
var films, f, title;
films = document.getElementsByClassName("film");
for (f = 0; f < films.length; f += 1) {
title = films[f].getElementsByTagName("h3")[0];
title.style.cursor = "pointer";
title.onclick = showHideDetails;
films = $(".film");
for (let film of films) {
title = $(film).find("h3")[0];
$(title).css("cursor", "pointer");
$(title).click(showHideDetails);
}
};
return pub;
}());
if (window.addEventListener) {
window.addEventListener('load', ShowHide.setup);
} else if (window.attachEvent) {
window.attachEvent('onload', ShowHide.setup);
}
$(document).ready(ShowHide.setup);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment