Skip to content

Commit

Permalink
moved functions to js file
Browse files Browse the repository at this point in the history
  • Loading branch information
alexh555 committed Mar 13, 2024
1 parent 8bad6e4 commit d9b09af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
23 changes: 18 additions & 5 deletions esp/public/media/scripts/program/modules/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ const MODIFIED_COLOR = "#0066ff22";

const FILTER_IDS = ["grade_filter", "difficulty_filter", "status_filter", "duration_filter"];

const materialIconsLink = document.createElement("link");
materialIconsLink.rel = "stylesheet";
materialIconsLink.href = "https://fonts.googleapis.com/icon?family=Material+Icons";
document.head.appendChild(materialIconsLink);

/**
Converts from hours to a formatted duration (eg. "0.05" -> "3 mins", "1.5" -> "1 hour 30 mins")
@param {string} numString - a duration as a float in a string (eg. "0.05")
Expand Down Expand Up @@ -171,4 +166,22 @@ function configure_addbuttons()
$j("input.addbutton").show();
}
}
function topFunction()
{
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}

window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
document.getElementById("topBtn").style.display = "block";
document.getElementById("topBtn").style.position = "fixed";
document.getElementById("topBtn").style.bottom = "20px";
} else {
document.getElementById("topBtn").style.display = "none";
}
}

$j(document).ready(configure_addbuttons);
22 changes: 3 additions & 19 deletions esp/templates/program/modules/studentclassregmodule/catalog.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
{% block stylesheets %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="/media/styles/catalog.css" />

<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">

<style>
a.disabled {
opacity: 0.5;
Expand All @@ -31,24 +33,6 @@
const hide_empty_cats = {{ "hide_empty_categories"|getBooleanTag|yesno:"true,false" }};
</script>

<script>
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}

window.onscroll = function() {scrollFunction()};

function scrollFunction() {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
document.getElementById("topBtn").style.display = "block";
document.getElementById("topBtn").style.position = "fixed";
document.getElementById("topBtn").style.bottom = "20px";
} else {
document.getElementById("topBtn").style.display = "none";
}
}
</script>

{% endblock %}

Expand Down

0 comments on commit d9b09af

Please sign in to comment.