Skip to content

Commit

Permalink
JS & CSS Code Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumar-laxmi committed Mar 12, 2022
1 parent 8d7a67f commit 9249d99
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 42 deletions.
45 changes: 3 additions & 42 deletions Course/Courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,48 +260,9 @@ <h3>follow us</h3>
</main>
<!-- footer section ends -->
<script src="../app.js"></script>
<script>
let sidebar = document.querySelector(".sidebar");
let closeBtn = document.querySelector("#btn");
let searchBtn = document.querySelector(".bx-search");

closeBtn.addEventListener("click", () => {
sidebar.classList.toggle("open");
menuBtnChange(); //calling the function(optional)
});

searchBtn.addEventListener("click", () => { // Sidebar open when you click on the search iocn
sidebar.classList.toggle("open");
menuBtnChange(); //calling the function(optional)
});

// following are the code to change sidebar button(optional)
function menuBtnChange() {
if (sidebar.classList.contains("open")) {
closeBtn.classList.replace("bx-menu", "bx-menu-alt-right"); //replacing the iocns class
} else {
closeBtn.classList.replace("bx-menu-alt-right", "bx-menu"); //replacing the iocns class
}
}
</script>

<script>
// floating button to the top
$(document).ready(function() {
$(document).scroll(function(){
if($(this).scrollTop() > 100){
$("#scroll").fadeIn();
} else{
$("#scroll").fadeOut();
}
});
$("#scroll").click(function () {
$("html,body").animate({scrollTop:0},600);
return false;
});
});

</script>
<script src="./script1.js"></script> <!-- Code optimization -->

<script src="./script2.js"></script> <!-- Code optimization -->

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/5.4.5/js/swiper.min.js"></script>
<!-- custom js file link -->
Expand Down
22 changes: 22 additions & 0 deletions Course/script1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
let sidebar = document.querySelector(".sidebar");
let closeBtn = document.querySelector("#btn");
let searchBtn = document.querySelector(".bx-search");

closeBtn.addEventListener("click", () => {
sidebar.classList.toggle("open");
menuBtnChange(); //calling the function(optional)
});

searchBtn.addEventListener("click", () => { // Sidebar open when you click on the search iocn
sidebar.classList.toggle("open");
menuBtnChange(); //calling the function(optional)
});

// following are the code to change sidebar button(optional)
function menuBtnChange() {
if (sidebar.classList.contains("open")) {
closeBtn.classList.replace("bx-menu", "bx-menu-alt-right"); //replacing the iocns class
} else {
closeBtn.classList.replace("bx-menu-alt-right", "bx-menu"); //replacing the iocns class
}
}
14 changes: 14 additions & 0 deletions Course/script2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// floating button to the top
$(document).ready(function() {
$(document).scroll(function(){
if($(this).scrollTop() > 100){
$("#scroll").fadeIn();
} else{
$("#scroll").fadeOut();
}
});
$("#scroll").click(function () {
$("html,body").animate({scrollTop:0},600);
return false;
});
});

0 comments on commit 9249d99

Please sign in to comment.