// version 4.21 (2015-10-28) $anujq(document).ready(function(){ $anujq('html').removeClass('no-js'); // flatten the parents: $anujq('.gw-mega-mobile-list ul').hide(); //add javascript link for actions on list items with a sublist $anujq('.gw-mega-mobile-list ul').parent('li').children('a').attr("onclick", "showMegaMenuChild($anujq(this), 1); return false;"); //and add the 'parent' class to those list items, so they get styled $anujq('.gw-mega-mobile-list ul').parent('li').children('a').addClass('gw-parent'); $anujq('.gw-mega-mobile-list ul').parent('li').children('a').append("»"); //hook into the body, update and footer so they will hide the mega menu if clicked on. $anujq('#bnr-wrap').click(function() {hideMegaMenu();}); $anujq('#body-wrap').click(function() {hideMegaMenu();}); $anujq('#update-wrap').click(function() {hideMegaMenu();}); $anujq('#footer-wrap').click(function() {hideMegaMenu();}); // $anujq('.bnr-gw2-search #srch-sel-cont').click(function() { // searchArrowClick(); // return false; // }); // // // $anujq('.bnr-gw2-search #srch-sel-cont1').click(function() { // searchArrowClick(); // return false; // }); // // $anujq('.bnr-gw2-search .srch-sel-site li, #gw-mobile-menu-wrap .srch-sel-site li').click(function() { // searchSelClick($anujq(this)); // return false; // }); $anujq('#gw-mobile-menu-wrap .mobile-menu-toggle').click(function() { slideIn('#gw-mobile-menu-wrap #menu0'); return false; }); $anujq('#gw-mobile-menu-wrap .mobile-search-toggle').click(function() { slideIn('#gw-mobile-menu-wrap #mobilesearch'); return false; }); redoMMSelect(); /* myCookie = getCookie('anuMobile'); if(myCookie){ showID('#menu'); } if ($anujq('#menu').is(':visible')) { $anujq('#menuword').html('Close'); } else { $anujq('#menuword').html('Menu'); } */ }); function redoMMSelect() { // $anujq('.gw-t1-select').removeClass('gw-t1-select'); // $anujq('.gw-t2-select').removeClass('gw-t2-select'); // $anujq('.gw-select').removeClass('gw-select'); if(!$anujq('body').hasClass('acton')){ //do following only if not running on drupal... docURL = document.URL; //remove any double // except in the http:// bit. docURL = docURL.replace(/[^\:]\/\/+/, "/"); docURL = docURL.replace(/index.php/,""); hostName = location.protocol + '//' + location.hostname; //// // docURL = 'http://about.anu.edu.au/performance/blah/blah/'; var haveSetT2 = 0; $anujq('#gw-megas-tabs .gw-mega-t2 li a').each(function(){ var linkurl = $anujq(this).attr('href'); linkurl = linkurl.replace(/index.php/,""); if (docURL.indexOf(linkurl) == 0 || docURL.indexOf(hostName + linkurl) == 0) { $anujq(this).addClass('gw-select'); haveSetT2 = 1; } }); if (haveSetT2 == 0) { $anujq('#gw-megas-tabs .gw-mega-t1 .gw-mega-t1').each(function(){ var linkurl = $anujq('h1 a', this).attr('href'); linkurl = linkurl.replace(/index.php/,""); if (docURL.indexOf(linkurl) == 0 || docURL.indexOf(hostName + linkurl) == 0) { $anujq(this).addClass('gw-select'); } }); } $anujq('#tabs-wrap ul li a').each(function(){ var linkurl = $anujq(this).attr('href'); linkurl = linkurl.replace(/index.php/,""); if (docURL.indexOf(linkurl) == 0 || docURL.indexOf(hostName + linkurl) == 0) { $anujq(this).addClass('gw-select'); } }); // The mobile menu lists $anujq('.gw-mega-mobile-list li a').each(function(){ var linkurl = $anujq(this).attr('href'); linkurl = linkurl.replace(/index.php/,""); if (docURL.indexOf(linkurl) == 0 || docURL.indexOf(hostName + linkurl) == 0 ) { $anujq(this).addClass('gw-select'); // showMegaMenuChild($anujq(this), 0); } }); $anujq('.bnr-gw-util-wrap .bnr-gw-util li a').each(function(){ var linkurl = $anujq(this).attr('href'); linkurl = linkurl.replace(/index.php/,""); if (docURL.indexOf(linkurl) == 0 || docURL.indexOf(hostName + linkurl) == 0 ) { $anujq(this).addClass('gw-select'); // showMegaMenuChild($anujq(this), 0); } }); } // end stuff for non-drupal $anujq('.gw-select').each(function(){ showMegaMenuChild($anujq(this), 0); }); } function slideUpID(id) { $anujq(id).stop(true,true).slideUp('fast'); } //Move a menu or search box in from the right. Slide a current menu out to the left at the same time. function slideIn(id) { //if the menu or search is already visible, close it: if ($anujq(id).is(':visible')) { //set the button wording appropriately: if (id == "#gw-mobile-menu-wrap #menu0" ) { $anujq('#gw-mobile-menu-wrap #menuword').html('Menu');} if (id == "#gw-mobile-menu-wrap #mobilesearch") { $anujq('#gw-mobile-menu-wrap #searchword').html(''); if ($anujq('.srch-sel-site').css('display') != 'none') { $anujq('.srch-sel-site').hide(); $anujq('#srch-sel-arrow1').attr('src', '//style.anu.edu.au/_anu/4/images/buttons/arrow-down-black.png'); $anujq('#srch-sel-arrow').attr('src', '//style.anu.edu.au/_anu/4/images/buttons/arrow-down-black.png'); } } //slide off to the right: /* $anujq(id).animate({'left':$anujq("#gw-menuslidecover").css('width')}, { duration: 'fast', easing: 'swing', //Once the slide is complete, hide it, and reset the height of the menu backing to 0. complete: function() {$anujq(id).hide(); $anujq("#gw-menuslidecover").animate({'height':'0'}, 'fast'); }, queue: false }); */ $anujq("#gw-menuslidecover").animate({'height':'0'}, {duration: 'fast', complete: function() {$anujq(id).hide();}}); $anujq('.gw-menuslide').hide(); //Destroy any sub menus that were active. When the menu opens again, we start from the home menu. //$anujq('#gw-menuslidecover .gw-menuslide:gt(0)').remove(); } else { // Else the menu is not visible, so we open it: //For the menu list if (id == "#gw-mobile-menu-wrap #menu0" ) { //close the search menu if it's open: if ($anujq('#gw-mobile-menu-wrap #mobilesearch').is(':visible')) { $anujq('#gw-mobile-menu-wrap #searchword').html(''); $anujq('#gw-mobile-menu-wrap #mobilesearch').hide(); } if ($anujq('.srch-sel-site').css('display') != 'none') { $anujq('.srch-sel-site').hide(); $anujq('#srch-sel-arrow1').attr('src', '//style.anu.edu.au/_anu/4/images/buttons/arrow-down-black.png'); $anujq('#srch-sel-arrow').attr('src', '//style.anu.edu.au/_anu/4/images/buttons/arrow-down-black.png'); } //$anujq("#gw-menuslidecover").css({'overflow': 'hidden'}); $anujq('.gw-menuslide').show(); //Set the button for closing next: $anujq('#gw-mobile-menu-wrap #menuword').html('Close'); hopen = $anujq('#gw-menuslidecover .gw-menuslide').last().css('height'); } // else, if it's the search box else if (id == "#gw-mobile-menu-wrap #mobilesearch" ) { //close the menu list if it's open: if ($anujq('#gw-mobile-menu-wrap #menu0').is(':visible')) { $anujq('#gw-mobile-menu-wrap #menuword').html('Menu'); $anujq('#gw-mobile-menu-wrap #menu0').hide(); // $anujq('#gw-menuslidecover .gw-menuslide:gt(0)').remove(); } $anujq('.gw-menuslide').hide(); //Set the button for closing the search next: $anujq('#gw-mobile-menu-wrap #searchword').html('Close'); hopen = $anujq(id).css('height'); } $anujq(id).show(); $anujq("#gw-menuslidecover").animate({'height': hopen}, { duration: 'fast', easing: 'swing', complete: function() { // $anujq("#gw-menuslidecover").height("auto"); } }); /* //move menu to off screen right, we will slide it in from there: $anujq(id).css({ 'left':$anujq("#gw-menuslidecover").css('width') }).show(); //set the height of menu cover to be height of menu $anujq("#gw-menuslidecover").animate({'height': $anujq(id).css('height')}, { duration: 'fast', easing: 'swing', complete: function() { //Slide the menu in from the right (once the height is set) $anujq(id).animate({'left':'0'}, 'fast', 'swing'); }, queue: false}); */ } } function hideMegaMenu() { if ($anujq('.gw-mega-wrap').is(':visible')) { $anujq('#gw-nav a').removeClass('gw-mega-select'); $anujq('#tabs-nav a').removeClass('gw-mega-select'); $anujq('#gw-mega-under').slideUp('fast'); $anujq('.gw-mega-wrap').slideUp('fast'); } } function showMegaMenu(id) { $anujq('#gw-nav a').removeClass('gw-mega-select'); //$anujq('#gw-nav-tabs a').removeClass('gw-mega-select'); if ($anujq('#gw-mega-' + id).is(':visible')) { $anujq('#gw-mega-under').slideUp('fast'); $anujq('.gw-mega-wrap').slideUp('fast'); // slideUpID('#gw-mega-' + id); } else { if ($anujq('.gw-mega-wrap').is(':visible')) { $anujq('.gw-mega-wrap').fadeOut('fast'); $anujq('#gw-mega-' + id).fadeIn('fast'); $anujq('#gw-nav-wrap #gw-nav a:eq(' + (id - 1) + ')').addClass('gw-mega-select'); $anujq('#tabs-wrap #gw-nav #gw-mega-tab-' + (id) + '').addClass('gw-mega-select'); } else { $anujq('#gw-nav-wrap #gw-nav a:eq(' + (id - 1) + ')').addClass('gw-mega-select'); $anujq('#tabs-wrap #gw-nav #gw-mega-tab-' + (id) + '').addClass('gw-mega-select'); $anujq('#gw-mega-under').slideDown('fast'); $anujq('#gw-mega-' + id).stop(true,true).slideDown('fast', function() {}); } } } function showMegaMenuChild(id, anim) { thisul = $anujq(id).parent().children('ul'); if (thisul.length == 0) {return;} //Clone the child list