1"use strict"; 2 3// GLOBAL JAVASCRIPT FOR BUSWAYS PUBLIC SITE 4(function ($, Drupal) { 5 // NB DO NOT USE 6 // $(document).ready(function(){}); 7 // IN DRUPAL INSTEAD YOU MUST USE 8 // Drupal.behaviors.uniqueModuleName = { 9 // attach: function(context, settings) { --INSERT JAVASCRIPT-- } } 10 Drupal.behaviors.global = { 11 attach: function (context, settings) { 12 /* 13 homepage alert functionality, 14 on page load hide the down caret if the ellipsis is not show 15 */ 16 if ($(".homepage-alert a").length > 0 && $(".homepage-alert a")[0].offsetWidth >= $(".homepage-alert a")[0].scrollWidth) { 17 // ellipsis is showing 18 $(".homepage-alert span.fa-caret-down").hide(); 19 } 20 /* 21 if the message has the ellipsis showing then expand the accordion 22 on first click. Otherwise go to the news item. Always go to the news 23 item on the second click. 24 */ 25 26 $(".homepage-alert-link").click(function (event) { 27 var alert = $(".homepage-alert a"); 28 if (alert.length > 0 && alert[0].offsetWidth < alert[0].scrollWidth) { 29 // ellipsis is showing 30 event.preventDefault(); 31 $(".homepage-alert").addClass("alert-expanded"); 32 } 33 }); // check if this is a state specific page with the second menu bar, add an 34 // extra class to the body so that it doesn't hide content 35 36 if (/\/((SA)|(sa)|(NSW)|(nsw))\//.test(window.location.pathname) || /\/((SA)|(sa)|(NSW)|(nsw))$/.test(window.location.pathname)) { 37 $("body").addClass("state-page"); 38 } 39 /* 40 check for window scrolling and modify the main menu as required 41 NB Dont do this on the front page, we have a slightly different event 42 because of the transparent background 43 */ 44 45 var menuClasses = '#block-globalmainnav, #block-sastatemainnav, #block-mainmenu'; 46 var last_scroll = $(window).scrollTop(); 47 var last_direction = "up"; 48 if (window.location.pathname != "/") { 49 $(window).on("scroll", function (event) { 50 if (window.innerWidth <= 1199 && !$(".main-menu-bar").hasClass("main-menu-hidden")) { 51 return false; 52 } 53 var new_scroll = $(window).scrollTop(); 54 if (new_scroll < last_scroll && last_direction == "down" || new_scroll <= 0) { 55 // new_scroll <= 0 required for iOS devices because apple decided to allow the devices to go into a negative top value when scrolling super fast 56 // change to up 57 $(menuClasses).removeClass("offscreen"); 58 last_direction = "up"; 59 } else if (new_scroll > last_scroll && last_direction == "up") { 60 // change to down 61 $(menuClasses).addClass("offscreen"); 62 last_direction = "down"; // also close search if applicable 63 64 if (window.innerWidth > 1199) { 65 if ($("#main-menu-search-container").is(":visible")) { 66 $("#main-menu-search-container").slideToggle(); 67 $("#search-icon").toggleClass("fa-search fa-times"); 68 } 69 } 70 } 71 last_scroll = new_scroll; 72 }); 73 } // on page load, hide the menu if it isnt at the top 74 75 $(document).ready(function () { 76 if ($(window).scrollTop() != 0) { 77 $(menuClasses).addClass("offscreen").removeClass("at-top"); 78 } 79 }); 80 $(window).on('resize', function () { 81 // clear the classes for the menu on window resize 82 $(".main-menu-open").removeClass("main-menu-open").find("ul").slideUp(400); 83 $(".mouse-over").removeClass("mouse-over"); 84 $(".main-menu-bar ul li ul").removeAttr("style"); // also on window resize if the ellipsis status of the homepage alert 85 // changes then modify the down caret as needed 86 87 if ($(".homepage-alert a").length > 0) { 88 if ($(".homepage-alert a")[0].offsetWidth < $(".homepage-alert a")[0].scrollWidth) { 89 // ellipsis is showing 90 $(".homepage-alert span.fa-caret-down").show(); 91 } else { 92 $(".homepage-alert span.fa-caret-down").hide(); 93 } 94 } 95 }); // in mobile show the nav menu 96 97 $(once('menu-toggle', 'span.fa-bars', context)).on("click", function () { 98 $(".main-menu-bar").toggleClass("main-menu-hidden"); 99 $(".main-menu-logo span.fas").toggleClass("fa-times fa-bars"); 100 }); // toggle the accordion for the main menu in mobile/tablet only 101 102 $(".main-menu-bar li.menu-item--expanded").on('click touch', function (event) { 103 event.stopPropagation(); 104 if (window.innerWidth <= 1199) { 105 // if this is a link then dont modify the accordion 106 if (!$(event.target).is("a")) { 107 if (!$(this).is($(".main-menu-bar li.main-menu-open"))) { 108 // different menu item 109 // close any other open menus 110 // $(".main-menu-bar > ul > li.main-menu-open").removeClass("main-menu-open").find("ul").slideUp(400); 111 // toggle their icons 112 // $(".main-menu-bar > ul > li span.fa-caret-up").addClass("fa-caret-down").removeClass("fa-caret-up"); 113 // now toggle icons for selected menu item 114 $(this).find("span.fas").first().removeClass("fa-caret-down").addClass("fa-caret-up"); // slide down the selected menu 115 116 $(this).addClass("main-menu-open").find("ul").first().slideDown(400); 117 } else { 118 // same as what is already open, close it 119 // first toggle its icons 120 $(this).find("span.fas").first().removeClass("fa-caret-up").addClass("fa-caret-down"); // slide up the open menu 121 122 $(this).removeClass("main-menu-open").find("ul").first().slideUp(400); 123 } 124 } 125 } 126 }); // toggle the hover over for the main menu in desktop only 127 128 $(".main-menu-bar > ul > li.menu-item--expanded").hover(function () { 129 if (window.innerWidth > 1199) { 130 $(this).addClass("mouse-over"); 131 $(this).closest("nav").addClass("mouse-over"); 132 } 133 }, function () { 134 if (window.innerWidth > 1199) { 135 $(".mouse-over").removeClass("mouse-over"); 136 } 137 }); // toggle the search bar when the search icon is clicked in desktop 138 139 $("nav .fa-search").click(function () { 140 if (window.innerWidth > 1199) { 141 $("#block-globalmainnav #main-menu-search-container").slideToggle(); 142 $(this).toggleClass("fa-search fa-times"); 143 } 144 }); // toggle the accordion for the site map in the footer in mobile only 145 146 $(once('footer-toggle', '#block-footer div.footer-sub-menu h2', context)).on('click', function () { 147 if (window.innerWidth <= 1199) { 148 if (!$(this).is($("#block-footer div.footer-sub-menu h2 span.fa-caret-up").parent())) { 149 $("#block-footer div.footer-sub-menu ul").slideUp(400, function () { 150 $(this).removeAttr("style"); 151 }); 152 $("#block-footer div.footer-sub-menu h2 span.fa-caret-up").toggleClass("fa-caret-down").toggleClass("fa-caret-up"); 153 } 154 $(this).find("span.fas").toggleClass("fa-caret-down").toggleClass("fa-caret-up"); 155 $(this).next("ul").slideToggle(400, function () { 156 if (!$(this).is(':visible')) { 157 $(this).removeAttr("style"); 158 } 159 }); 160 } 161 }); // global JS for sub page nav menus 162 163 /* NB for this to work the page needs to be in the format 164 <nav class="page-sub-menu"> 165 <ul> 166 <li data-tab-id="div-id-1" class="active-tab">Tab 1<span class="fas fa-caret-down"></span></li> (add class "active-tab" to the first one) 167 <li data-tab-id="div-id-2">Tab 2<span class="fas fa-caret-down"></span></li> 168 <li data-page-link="/internal-link">Internal Link</li> 169 </ul> 170 </nav> 171 <div class="page-tab" id="div-id-1"> 172 {{content}} 173 </div> 174 <div class="page-tab" id="div-id-2"> 175 {{content}} 176 </div> 177 */ 178 // first hide subsequent tabs 179 // NB DONT DO THIS ON CAREERS PAGE, SLIGHTLY DIFFERENT FUNCTIONALITY 180 181 if (window.location.pathname != "/about-us/careers" && window.location.pathname != "/about-us/our-networks") { 182 $(once('page-load-tabs', 'div.page-tab', context)).slice(1).hide(); 183 $("nav.page-sub-menu:not(.skip-js) > ul > li").click(function () { 184 var $link = $(this); 185 if ($link.hasClass("active-tab")) { 186 if (window.innerWidth <= 900) { 187 $link.closest("nav.page-sub-menu").toggleClass("nav-menu-open"); 188 } 189 } else if ($link.data("page-link") != undefined) { 190 $link.closest("nav.page-sub-menu.nav-menu-open").removeClass("nav-menu-open"); 191 $link.closest("nav.page-sub-menu").find(".active-tab").removeClass("active-tab"); 192 $(this).addClass("active-tab"); 193 window.location = $link.data("page-link"); 194 } else { 195 $link.closest("nav.page-sub-menu.nav-menu-open").removeClass("nav-menu-open"); 196 $link.closest("nav.page-sub-menu").find(".active-tab").removeClass("active-tab"); 197 $(this).addClass("active-tab"); 198 $(".page-tab").fadeOut(500).promise().done(function () { 199 $("#" + $link.data("tab-id")).fadeIn(500); 200 }); 201 } 202 }); 203 } // global JS for changing the header image pictures 204 // NB daytime image is set on the css as fallack for no j
204avascrpt 205 206 var date = new Date(); 207 var hours = date.getHours(); 208 if (hours > 5 && hours < 18) { 209 $("div.header-image-inner").css("bottom", "100%"); 210 } else { 211 $("div.header-image-inner").css("bottom", "0%"); 212 } 213 } 214 }; 215})(jQuery, Drupal); 216function getParameterByName(name, url) { 217 // https://stackoverflow.com/a/901144 218 if (!url) url = window.location.href; 219 name = name.replace(/[\[\]]/g, '\\$&'); 220 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), 221 results = regex.exec(url); 222 if (!results) return null; 223 if (!results[2]) return ''; 224 return decodeURIComponent(results[2].replace(/\+/g, ' ')); 225}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.