1/** 2 * 3 * GWT theme scripts. 4 * 5 */ 6 7// Cookie handler, non-$ style 8// function createCookie(name, value, days) { 9// if (days) { 10// var date = new Date(); 11// date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000); 12// var expires = "; expires=" + date.toGMTString(); 13// } else var expires = ""; 14// document.cookie = name + "=" + value + expires + "; path=/"; 15// console.log(document.cookie); 16// } 17 18function createCookie(name, value, days) { 19 let cookie = `${name}=${encodeURIComponent(value)}`; 20 21 // Add expiry date 22 if (days) { 23 const expiry = new Date(); 24 expiry.setTime(expiry.getTime() + days * 24 * 60 * 60 * 1000); 25 cookie += `; expires=${expiry.toUTCString()}`; 26 } 27 // Add Secure 28 cookie += `; secure`; 29 cookie += `; HttpOnly`; 30 // Set an HTTP cookie 31 document.cookie = cookie; 32 console.log(document.cookie); 33 console.log(cookie); 34} 35 36function readCookie(name) { 37 var nameEQ = name + "="; 38 var ca = document.cookie.split(";"); 39 for (var i = 0; i < ca.length; i++) { 40 var c = ca[i]; 41 while (c.charAt(0) == " ") c = c.substring(1, c.length); 42 if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); 43 } 44 return null; 45} 46 47function eraseCookie(name) { 48 createCookie(name, ""); 49} 50 51(function (jQuery, Foundation) { 52 // Orbit Slider play/pause options 53 Foundation.Orbit.defaults.controls = true; 54 Foundation.Orbit.defaults.controlClass = "orbit-button-controls"; 55 Foundation.Orbit.defaults.controlPauseText = "Pause"; 56 Foundation.Orbit.defaults.controlPlayText = "Play"; 57 58 Foundation.Orbit.prototype.initControls = function () { 59 var _this = this; 60 var statusElement = document.createElement("button"); 61 var buttonControl = document.createElement("span"); 62 if (this.options.accessible) { 63 var srText = document.createElement("span"); 64 $(srText).addClass("show-for-sr").text(this.options.controlPauseText); 65 $(statusElement).append(srText); 66 } 67 $(buttonControl).addClass("orbit-button-text").html("❙❙"); 68 $(statusElement) 69 .addClass(this.options.controlClass) 70 .append(buttonControl) 71 .attr("title", this.options.controlPlayText); 72 $(this.$element).prepend(statusElement); 73 if (this.options.autoPlay) { 74 this.controlPlay(); 75 } 76 77 this.$button = this.$element.find("." + this.options.controlClass); 78 79 this.$button.on("click.zf.orbit", function () { 80 _this.options.pauseOnHover = false; 81 _this.$element.off("mouseenter.zf.orbit"); 82 _this.$element.off("mouseleave.zf.orbit"); 83 if (_this.options.autoPlay) { 84 _this.options.autoPlay = false; 85 _this.controlPause(); 86 } else { 87 _this.options.autoPlay = true; 88 _this.controlPlay(); 89 } 90 }); 91 }; 92 93 Foundation.Orbit.prototype.controlPause = function () { 94 this.timer.restart(); 95 this.timer.pause(); 96 this.$wrapper = this.$element.find("." + this.options.controlClass); 97 this.$wrapper.attr("title", this.options.controlPlayText); 98 this.$buttonText = this.$element.find( 99 "." + this.options.controlClass + " .orbit-button-text" 100 ); 101 this.$srText = this.$element.find( 102 "." + this.options.controlClass + " .show-for-sr" 103 ); 104 if (this.options.accessible) { 105 $(this.$srText).text(this.options.controlPlayText); 106 } 107 $(this.$buttonText).html("<i class='fa fa-play' aria-hidden='true'></i>"); 108 }; 109 110 Foundation.Orbit.prototype.controlPlay = function () { 111 this.timer.restart(); 112 this.timer.start(); 113 this.$wrapper = this.$element.find("." + this.options.controlClass); 114 this.$wrapper.attr("title", this.options.controlPauseText); 115 this.$buttonText = this.$element.find( 116 "." + this.options.controlClass + " .orbit-button-text" 117 ); 118 this.$srText = this.$element.find( 119 "." + this.options.controlClass + " .show-for-sr" 120 ); 121 if (this.options.accessible) { 122 $(this.$srText).text(this.options.controlPauseText); 123 } 124 $(this.$buttonText).html("<i class='fa fa-pause' aria-hidden='true'></i>"); 125 }; 126 127 $("[data-orbit]").on("init.zf.orbit", function (e) { 128 $(e.target).foundation("initControls"); 129 }); 130 131 jQuery(document).ready(function ($) { 132 // Transparency Seal 133 $("#tp-seal").parent().parent().addClass("text-center"); 134 135 // High contrast handler 136 if (readCookie("a11y-high-contrast")) { 137 $("body").addClass("contrast"); 138 $("head").append( 139 $( 140 "<link href='" + 141 template_directory + 142 "/accessibility/a11y-contrast.css' id='highContrastStylesheet' rel='stylesheet' type='text/css' />" 143 ) 144 ); 145 $("#accessibility-contrast") 146 .attr("aria-checked", true) 147 .addClass("active"); 148 } 149 $(".toggle-contrast").on("click", function () { 150 if (!$(this).hasClass("active")) { 151 $("head").append( 152 $( 153 "<link href='" + 154 template_directory + 155 "/accessibility/a11y-contrast.css' id='highContrastStylesheet' rel='stylesheet' type='text/css' />" 156 ) 157 ); 158 $("body").addClass("contrast"); 159 // createCookie("a11y-high-contrast", "1"); 160 $(this).attr("aria-checked", true).addClass("active"); 161 return false;
162 } else { 163 $("#highContrastStylesheet").remove(); 164 $("body").removeClass("contrast"); 165 $(this).removeAttr("aria-checked").removeClass("active"); 166 // eraseCookie("a11y-high-contrast"); 167 return false; 168 } 169 }); 170 171 // Saturation handler 172 if (readCookie("a11y-desaturated")) { 173 $("body").addClass("desaturated"); 174 $("head").append( 175 $( 176 "<link href='" + 177 template_directory + 178 "/accessibility/a11y-desaturate.css' id='desaturateStylesheet' rel='stylesheet' type='text/css' />" 179 ) 180 ); 181 $("#accessibility-grayscale") 182 .attr("aria-checked", true) 183 .addClass("active"); 184 } 185 $(".toggle-grayscale").on("click", function () { 186 if (!$(this).hasClass("active")) { 187 $("head").append( 188 $( 189 "<link href='" + 190 template_directory + 191 "/accessibility/a11y-desaturate.css' id='desaturateStylesheet' rel='stylesheet' type='text/css' />" 192 ) 193 ); 194 $("body").addClass("desaturated"); 195 $(this).attr("aria-checked", true).addClass("active"); 196 createCookie("a11y-desaturated", "1"); 197 return false; 198 } else { 199 $("#desaturateStylesheet").remove(); 200 $("body").removeClass("desaturated"); 201 $(this).removeAttr("aria-checked").removeClass("active"); 202 eraseCookie("a11y-desaturated"); 203 return false; 204 } 205 }); 206 207 // Fontsize handler 208 if (readCookie("a11y-larger-fontsize")) { 209 $("body").addClass("fontsize"); 210 $("head").append( 211 $( 212 "<link href='" + 213 template_directory + 214 "/accessibility/a11y-fontsize.css' id='fontsizeStylesheet' rel='stylesheet' type='text/css' />" 215 ) 216 ); 217 $("#accessibility-fontsize") 218 .attr("aria-checked", true) 219 .addClass("active"); 220 } 221 $(".toggle-fontsize").on("click", function () { 222 if (!$(this).hasClass("active")) { 223 $("head").append( 224 $( 225 "<link href='" + 226 template_directory + 227 "/accessibility/a11y-fontsize.css' id='fontsizeStylesheet' rel='stylesheet' type='text/css' />" 228 ) 229 ); 230 $("body").addClass("fontsize"); 231 $(this).attr("aria-checked", true).addClass("active"); 232 createCookie("a11y-larger-fontsize", "1"); 233 return false; 234 } else { 235 $("#fontsizeStylesheet").remove(); 236 $("body").removeClass("fontsize"); 237 $(this).removeAttr("aria-checked").removeClass("active"); 238 eraseCookie("a11y-larger-fontsize"); 239 return false; 240 } 241 }); 242 243 // Back to top elavator 244 var offset = 220; 245 var duration = 500; 246 $(window).scroll(function () { 247 if ($(this).scrollTop() > offset) { 248 $("#back-to-top").fadeIn(duration); 249 } else { 250 $("#back-to-top").fadeOut(duration); 251 } 252 }); 253 $("#back-to-top").click(function (event) { 254 event.preventDefault(); 255 $("html, body").animate({ scrollTop: 0 }, duration); 256 return false; 257 }); 258 259 // Skip to Content handler 260 // var stc = $('#main-content').position().top; 261 // b = $('.sticky ').height(); 262 // c = stc-58; 263 $("#accessibility-skip-content").click(function (event) { 264 var stc = $("#main-content").position().top; 265 b = $(".sticky ").height(); 266 c = stc - 58; 267 event.preventDefault(); 268 $("html, body").animate({ scrollTop: c }, duration); 269 return false; 270 }); 271 272 // Skip to Footer handler 273 // var stf = $('#gwt-standard-footer').position().top; 274 $("#accessibility-skip-footer").click(function (event) { 275 var stf = $("#gwt-standard-footer").position().top; 276 event.preventDefault(); 277 $("html, body").animate({ scrollTop: stf }, duration); 278 return false; 279 }); 280 281 // For Testing 282 // Adjust Text Sizing 283 var zoom = 0; 284 $("p").each(function () { 285 var el = $(this), 286 size = parseInt(el.css("font-size")); 287 el.data("font-size", size); 288 }); 289 // For font text default size 290 $("#text-default").click(function (event) { 291 event.preventDefault(); 292 zoom = 0; 293 $("p").each(function () { 294 var el = $(this), 295 size = el.data("font-size"); 296 el.css("font-size", Math.max(size + zoom, 0) + "px"); 297 }); 298 }); 299 // For font text size reducer 300 $("#text-reduce").click(function (event) { 301 event.preventDefault(); 302 zoom--; 303 $("p").each(function () { 304 var el = $(this), 305 size = el.data("font-size"); 306 el.css("font-size", Math.max(size + zoom, 0) + "px"); 307 }); 308 }); 309 // For font text size enlarger 310 $("#text-enlarge").click(function (event) { 311 event.preventDefault(); 312 zoom++; 313 $("p").each(function () { 314 var el = $(this), 315 size = el.data("font-size"); 316 el.css("font-size", Math.max(size + zoom, 0) + "px"); 317 }); 318 }); 319 // End for Adjust Text Sizing 320 321 $("#openNav").click(function (event) { 322 event.preventDefault(); 323 document.getElementById("mySidenav").style.width = "250px"; 324 document.getElementById("main").style.marginLeft = "250px"; 325 }); 326 327 $("#closeNav").click(function (event) { 328 event.preventDefault(); 329 document.getElementById("mySidenav").style.width = "0"; 330 document.getElementById("main").style.marginLeft = "0"; 331 }); 332 // End for Testing 333 }); 334})(jQuery, Foundation); 335$(document).foundation();
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.