Difference between revisions of "Team:NYMU-Taipei/js-test"

(original template js)
 
(wiki trytry js)
Line 4: Line 4:
 
$(document).ready(function() {
 
$(document).ready(function() {
  
$("#HQ_page").attr('id','');
+
$("#HQ_page").attr('id','');});
 
 
  
//highlight current page on the menu
+
function dropdown1(){
highlight_current_page_menu();
+
document.getElementById('dropdowncontent1').classList.toggle('notshow');
+
console.log('here!')
//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 dropdown2(){
 +
document.getElementById('dropdowncontent2').classList.toggle('notshow');
 +
}
  
function highlight_current_page_menu() {
+
function dropdown3(){
+
document.getElementById('dropdowncontent3').classList.toggle('notshow');
var page_url="https://2018.igem.org/";
+
}
page_url = page_url + wgPageName;
+
function dropdown4(){
$("a[href$='"+ page_url +"']").children().addClass("current_page");
+
document.getElementById('dropdowncontent4').classList.toggle('notshow');
+
}
//if the page is in a submenu, open the submenu and make the appropiate changes
+
function dropdown5(){
if( $( ".current_page" ).hasClass( "submenu_item" )){
+
document.getElementById('dropdowncontent5').classList.toggle('notshow');
+
}
$(".current_page").parent().parent().fadeToggle(400);
+
$(".current_page").parent().parent().prev().addClass("current_page");
+
$(".menu_item.current_page > .submenu_control_icon").toggleClass("open");
+
+
}
+
}
+
  
  
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
 
 +
window.onclick = function(event){
 +
var contents = document.getElementsByClassName("dropdowncontent");
 +
var buttons = document.getElementsByClassName("dropdownbutton");
 +
for (var i = contents.length - 1; i >= 0; i--) {
 +
if(!(event.target.id==buttons[i].id)){
 +
if (!contents[i].classList.contains('notshow')) {
 +
contents[i].classList.add('notshow');
 +
}
 +
}
 +
}
 +
}
 +
 
 
</script>
 
</script>

Revision as of 06:37, 24 May 2018

<script> ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$(document).ready(function() {

$("#HQ_page").attr('id',);});


function dropdown1(){ document.getElementById('dropdowncontent1').classList.toggle('notshow'); console.log('here!') }

function dropdown2(){ document.getElementById('dropdowncontent2').classList.toggle('notshow'); }

function dropdown3(){ document.getElementById('dropdowncontent3').classList.toggle('notshow'); } function dropdown4(){ document.getElementById('dropdowncontent4').classList.toggle('notshow'); } function dropdown5(){ document.getElementById('dropdowncontent5').classList.toggle('notshow'); }


window.onclick = function(event){ var contents = document.getElementsByClassName("dropdowncontent"); var buttons = document.getElementsByClassName("dropdownbutton"); for (var i = contents.length - 1; i >= 0; i--) { if(!(event.target.id==buttons[i].id)){ if (!contents[i].classList.contains('notshow')) { contents[i].classList.add('notshow'); } } } }

</script>