Difference between revisions of "Template:NUS Singapore-A"

Line 6: Line 6:
 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
 
</head>
 
</head>
<script>
 
  
  // This is the jquery part of your template. 
 
  // Try not modify any of this code too much since it makes your menu work.
 
  
  $(document).ready(function() {
+
<script>
 
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    $("#HQ_page").attr('id','');
+
 
+
    // call the functions that control the menu
+
    menu_functionality();
+
    hide_show_menu();
+
 
+
 
+
 
+
    //this function controls the expand and collapse buttons of the menu and changes the +/- symbols
+
    function menu_functionality() {
+
 
+
      //when clicking on a "menu_button", it will change the "+/-" accordingly and it will show/hide the corresponding submenu
+
      $(".menu_button").click(function(){
+
 
+
        // add or remove the class "open" , this class holds the "-"
+
        $(this).children().toggleClass("open");
+
        // show or hide the submenu   
+
        $(this).next('.submenu_wrapper').fadeToggle(400);
+
      });
+
 
+
      // when the screen size is smaller than 800px, the display_menu_control button appears and will show/hide the whole menu
+
      $("#display_menu_control").click(function(){
+
        $('#menu_content').fadeToggle(400);
+
      });
+
 
+
      // call the current page highlight function
+
      highlight_current_page();
+
    }
+
 
+
 
+
    // call the highlight current page function to show it on the menu with a different background color
+
    function highlight_current_page() {
+
 
+
      // select a page from the menu based on the id assigned to it and the current page name and add the class "current page" to make it change background color
+
      $("#"+  wgPageName.substring(wgPageName.lastIndexOf("/")+1, wgPageName.length ) + "_page").addClass("current_page");
+
 
+
      // now that the current_page class has been added to a menu item, make the submenu fade in
+
      $(".current_page").parents(".submenu_wrapper").fadeIn(400);
+
      // change the +/- symbol of the corresponding menu button
+
      $(".current_page").parents(".submenu_wrapper").prev().children().toggleClass("open");
+
     
+
    }
+
 
+
 
+
 
+
    // allow button on the black menu bar to show/hide the side menu
+
    function hide_show_menu() {
+
 
+
      // in case you preview mode is selected, the menu is hidden for better visibility
+
      if (window.location.href.indexOf("submit") >= 0) {
+
        $(".igem_2017_menu_wrapper").hide();
+
      }
+
 
+
      // if the black menu bar has been loaded
+
        if (document.getElementById('bars_item')) {
+
  
        // when the "bars_item" has been clicked
+
$(document).ready(function() {
        $("#bars_item").click(function() {
+
          $("#sideMenu").hide();
+
  
          // show/hide the menu wrapper
+
$("#HQ_page").attr('id','');
          $(".igem_2017_menu_wrapper").fadeToggle("100");
+
        });  
+
        }
+
  
      // because the black menu bars loads at a different time than the rest of the page, this function is set on a time out so it can run again in case it has not been loaded yet
+
//highlight current page on the menu
      else {
+
highlight_current_page_menu();
            setTimeout(hide_show_menu, 15);
+
      }
+
//accessing submenus
    }
+
$(".menu_item").click(function(){
 +
$(".submenu_control_icon", this).toggleClass("open");
 +
$(this).next(".submenu").fadeToggle(400);
 +
});
 +
 +
//mobile menu access
 +
$(".igem_2018_team_mobile_bar").click(function(){
 +
$(this).next().toggleClass("displaying_menu");
 +
});
 +
 +
});
  
  
  });
+
function highlight_current_page_menu() {
 +
 +
var page_url="https://2018.igem.org/";
 +
page_url = page_url + wgPageName;
 +
$("a[href$='"+ page_url +"']").children().addClass("current_page");
 +
 +
//if the page is in a submenu, open the submenu and make the appropiate changes
 +
if( $( ".current_page" ).hasClass( "submenu_item" )){
 +
 +
$(".current_page").parent().parent().fadeToggle(400);
 +
$(".current_page").parent().parent().prev().addClass("current_page");
 +
$(".menu_item.current_page > .submenu_control_icon").toggleClass("open");
 +
 +
}
 +
}
  
  
 +
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
</script>
 
</script>
  

Revision as of 12:57, 5 July 2018

EMAIL US AT NUSIGEM@GMAIL.COM
What's on?