1(function(salk, $, undefined) { 2 'use strict'; 3 4 if ( navigator.appVersion.indexOf("MSIE 10") !== -1 ) { 5 $('body').addClass('ie10'); // detect IE10 only 6 } 7 8 salk.templatepath = location.protocol + '//' + location.host + '/wp-content/themes/salk'; 9 10 salk.page = function(regex, callback) { 11 var match = new RegExp(regex), 12 url = location.pathname + location.search + location.hash; 13 return match.test(url) && callback(); 14 } 15 16 salk.scrollto = function(element, options, callback) { 17 var options = $.extend({}, { speed: 1200, offset: 0, easing: "easeOutExpo" }, options), 18 element = $(element); 19 20 if ( element.length ) { 21 $('html, body').animate({ scrollTop: element.offset().top + options.offset }, options.speed, options.easing, function(){ 22 callback && callback(); 23 }); 24 } 25 } 26 27 $.fn.shift = function() { 28 var a = this.get(0); 29 this.splice(0,1); 30 return a; 31 }; 32 33 $.fn.toggletext = function(a, b) { 34 if ( this.text() === a ) { this.text(b); } 35 else { this.text(a); } 36 }; 37 38 $.fn.handleform = function() { 39 var form = $(this), 40 role = form.data("role"), 41 response = form.find(".response"), 42 submit = form.find("[type='submit']"), 43 fields = form.serializeArray(); 44 45 fields.push({ name: "role", value: role }); 46 47 submit.attr("disabled", "disabled"); 48 response.html('<i class="fa fa-asterisk fa-spin"></i> One moment').wrapInner('<p />'); 49 50 $.post(salk.templatepath + "/response.php", fields, function(data) { 51 52 submit.removeAttr("disabled"); 53 response.html(""); 54 55 if ( 'validation' in data ) { 56 response.html(data.validation).wrapInner("<p>"); 57 }; 58 59 if ( 'confirmation' in data ) { 60 response.html(data.confirmation).wrapInner("<p>"); 61 form[0].reset(); 62 }; 63 }); 64 }; 65 66 salk.reveal = function() { 67 return { 68 open: function() { 69 $(this).fadeIn(400, function() { 70 salk.reveal.updateStatus(); 71 }); 72 }, 73 close: function(option, callback) { 74 var visible = []; 75 76 // close and return 77 if ( $(this).is(":visible") ) { 78 $(this).fadeOut(400, function() { 79 salk.reveal.updateStatus(); 80 }); 81 return; 82 } 83 84 // self 85 option === "self" && callback(); 86 87 // accordion 88 if ( option === "accordion" ) { 89 $.each($('[data-reveal]').next(), function(index, val) { 90 var el = $(val); 91 if (el.is(":visible")) visible.push(el); 92 }); 93 94 visible.length || callback(); 95 if ( visible.length ) { 96 visible[0].fadeOut(400, function() { 97 callback(); 98 salk.reveal.updateStatus(); 99 }); 100 } 101 } 102 }, 103 updateStatus: function() { 104 $.each($('[data-reveal]').next(), function(index, val) { 105 var btn = $(val).prev(), 106 toggle = btn.data('toggle'); 107 108 if ( toggle !== undefined ) { 109 $(val).is(":visible") ? btn.text(toggle.split(",")[1]) : btn.text(toggle.split(",")[0]); 110 } else { 111 $(val).is(":visible") ? btn.text("Close") : btn.text("Read More"); // fallback 112 } 113 114 }); 115 } 116 } 117 }(); 118 119 $(function() { 120 121 /* reveal event listener 122 --------------------------------------------- */ 123 $('[data-reveal]').on('click', function(event) { 124 event.preventDefault(); 125 var element = $(this).next(), // element to toggle 126 option = $(this).data('reveal'), // accordion or self 127 hideme = $(this).data('hideme'); // yes or empty 128 if(hideme == 'hide'){ 129 $(this).hide(); 130 } 131 132 salk.reveal.close.call(element, option, function() { 133 salk.reveal.open.call(element); 134 135 }); 136 }); 137 138 /* gallery 139 --------------------------------------------- */ 140 (function() { 141 var gallery = $('.gallery'), 142 stage = gallery.find('.stage'), 143 items = gallery.find('.entry img'), 144 fn = { 145 active: function(items) { 146 items.removeClass('on'); 147 $(this).addClass("on"); 148 }, 149 ready: function() { 150 $(this).addClass("fade-in"); 151 }, 152 addCaption: function(caption) { 153 $(this).find('figcaption').remove(); // reset 154 if ( caption.length ) { 155 $('<figcaption>'+ caption +'</figcaption>').appendTo($(this).find('figure')); 156 } 157 } 158 } 159 160 items.on('click', function(event) { 161 event.preventDefault(); 162 stage.removeClass("fade-in"); 163 fn.active.call(this, items); 164 stage.find('img').attr('src', $(this).data('lg')).imagesLoaded(function() { 165 fn.ready.call(stage); 166 fn.addCaption.call(stage, $(this).data('caption')); 167 }.bind(this)); 168 }); 169 $(items[0]).trigger('click'); 170 }()); 171 172 /* navigation 173 --------------------------------------------- */ 174 $('header').on('click', '.dashes', function(event) { 175 event.preventDefault(); 176 $(event.delegateTarget).toggleClass('on').find('nav').fadeToggle(); 177 }); 178 179 (function() { 180 var navigation = $('header .navigation'), 181 mobile = navigator.userAgent.match(/Mobi/); 182 183 function open() { 184 var ul = $(this).siblings('ul'), 185 li = ul.find('> li'), height = 0; 186 187 $.each(li, function(index, val) { 188 height += $(val).outerHeight(); 189 }); 190 191 var a = $(this).parent('li').outerWidth() / 2, 192 left = ul.outerWidth() / 2 - a; 193 194 ul.css({ left: -left }).addClass('on').animate({ height: height, opacity: .2 }, 1, function() { 195 $(this).animate({ opacity: 1 }, 1); 196 }); 197 } 198 199 function close(event, callback) { 200 var on = $(event.delegateTarget).find('.on'),
201 self = $(this).siblings().hasClass('on'); 202 203 if ( on.length ) { 204 on.stop().animate({ height: 0, opacity: 0 }, 1, function() { 205 $(this).removeClass('on'); 206 if ( !self ) { 207 callback && callback(); 208 } 209 }); 210 return; 211 } 212 callback && callback(); 213 } 214 215 if ( !mobile ) { 216 navigation.on('mouseover', '> li > a', function(event) { 217 close.call(this, event, function() { 218 open.call(this); 219 }.bind(this)); 220 }) 221 .on('mouseleave', '> li > ul', function(event) { 222 close.call(this, event); 223 }); 224 } 225 226 else { 227 navigation.on('click', '> li.menu-item-has-children > a', function(event) { 228 event.preventDefault(); 229 close.call(this, event, function() { 230 open.call(this); 231 }.bind(this)); 232 }); 233 } 234 235 }()); 236 237 /* s navigation - set .on class 238 --------------------------------------------- */ 239 (function() { 240 var page = location.pathname.split('/'), 241 nav = $('.s-navigation'); 242 243 page.splice(-1, 1); 244 nav.find('a[href$="/'+ page[page.length-1] +'/"]').parent('li').addClass('on'); 245 nav.on('click', 'a[href="#"]', function(event) { 246 event.preventDefault(); 247 nav.toggleClass('on'); 248 $(this).toggletext("Menu", "x"); 249 }); 250 }()); 251 252 /* leadership administration 253 --------------------------------------------- */ 254 salk.page("/leadership/administration/", function() { 255 $('.directory').on('click', 'a', function(event) { 256 event.preventDefault(); 257 salk.scrollto($(this).attr('href')); 258 }); 259 }); 260 261 /* science events 262 --------------------------------------------- */ 263 salk.page("/science-events/", function() { 264 $('.event-types').on('click', '> ul a', function(event) { 265 event.preventDefault(); 266 var stage = $(event.delegateTarget), 267 type = $(this).text(); 268 269 stage.find('> ul a').removeClass('on'); 270 $(this).addClass('on'); 271 stage.find('.entries').hide(); 272 stage.find('[data-type="'+ type +'"]').fadeIn(800); 273 }); 274 }); 275 276 /* FAQ 277 --------------------------------------------- */ 278 salk.page("technology-development/otd-faq|core-facilities/next-generation-sequencing/next-gen-resources|/careers/immigration-services/visa-and-travel-information", function() { 279 $('.faq').on('click', 'a', function(event) { 280 event.preventDefault(); 281 salk.scrollto($(this).attr('href')); 282 }); 283 }); 284 285 /* careers 286 --------------------------------------------- */ 287 salk.page("/careers/", function() { 288 $('.fellows-program, .immigration-visa-terminology').on('click', '.-readmore', function(event) { 289 event.preventDefault(); 290 $(this).next().fadeIn("slow").end().remove(); 291 }); 292 }); 293 294 /* research overview 295 --------------------------------------------- */ 296 salk.page("/research/", function() { 297 $('.research-overview .entry').on('click', '.-expand', function(event) { 298 event.preventDefault(); 299 var entry = $(event.delegateTarget), 300 tab = $(this).text().toLowerCase(); 301 302 entry.find('.-tab').hide().end().find('.' + tab).fadeIn("slow", function() { 303 // adjust permalink caret postion 304 $(window).trigger('load'); 305 }); 306 }); 307 }); 308 309 /* search 310 --------------------------------------------- */ 311 $('header .search').on('click', 'a', function(event) { 312 // alert('search clicked'); 313 event.preventDefault(); 314 var s = $('.gtranslate_wrapper'); 315 //console.log(s); 316 s.hide(); 317 var a = $(this); 318 a.hide().next().fadeToggle(800, function() { 319 var form = $(this), input = $(this).find('input'); 320 321 input.focus(); 322 input.on('blur', function() { 323 a.show() && form.hide(); 324 s.show(); 325 }); 326 }); 327 }); 328 329 /* faculty 330 --------------------------------------------- */ 331 $('.faculty .entries a').on('mouseenter', '> div', function() { 332 $(this).stop().animate({ opacity: 1}, 400, 'easeOutCubic'); 333 }) 334 .on('mouseleave', '> div', function() { 335 $(this).stop().animate({ opacity: 0}, 1200, 'easeOutCubic'); 336 }); 337 338 /* permalink 339 --------------------------------------------- */ 340 $(window).on('resize load', _.debounce(function() { 341 var permalinks = $('.permalink'); 342 permalinks.css({ height: 0, opacity: 0 }); 343 $.each($('.permalink'), function(index, val) { 344 $(val).css({ height: $(val).closest('.entry').height(), opacity: 1 }); 345 }); 346 }, 200)); 347 348 /* constant contact 349 --------------------------------------------- */ 350 $('.-panels').on('submit', '[data-role="stay-informed"]', function(event) { 351 event.preventDefault(); 352 var form = $(this), 353 email = $('[name="email"]').val(), 354 listid = $('[name="listid"]').val(), 355 response = $(this).find(".response"); 356 357 if ( email.trim().length === 0 ) { 358 return; 359 } 360 361 $.post(salk.templatepath + '/constant-contact.php', { email: email, listid: listid }, function(data, textStatus, xhr) { 362 if ( 'validation' in data ) { 363 // response.html(data.validation[0]).wrapInner("<p>"); 364 response.html("Please enter a valid email address.").wrapInner("<p>"); 365 }; 366 367 if ( 'confirmation' in data ) { 368 response.html(data.confirmation).wrapInner("<p>"); 369 form[0].reset(); 370 form.find('[type="submit"]').remove(); 371 }; 372 }); 373 }); 374 375 /* legacy 376 --------------------------------------------- */ 377 salk.page("/news-release/", function() { 378 var content = $('section.content'), 379 iframe = content.find("iframe[src^='//www.youtube.com'], iframe[src^='//player.vimeo.com']"); 380 381 iframe.removeAttr('height').removeAttr('width'); 382 iframe.unwrap().wrap('<div class="embed-responsive embed-responsive-16by9 legacy-embed" />'); 383 }); 384 385 386 387 /* contact 388 --------------------------------------------- */ 389 salk.page("/contact/", function() { 390 $('form[data-role="contact"]').on('submit', function(event) { 391 event.preventDefault(); 392 $(this).handleform(); 393 }); 394 }); 395 396 /* hero -caret 397 --------------------------------------------- */ 398 /* salk.page("^/$", function() { 399 var caret = $('.hero .-caret'), 400 panels = $('.-panels'); 401 caret.on('click', '.fa', function(event) { 402 event.preventDefault(); 403 salk.scrollto($('.-panels'), { offset: 30 }); 404 $(this).parent().remove(); 405 }); 406 caret.addClass("fade-in -slow"); 407 408 $(window).on('resize load', _.debounce(function() { 409 var height = $(this).outerHeight(); 410 window.innerHeight < panels.offset().top + 64 ? // 4em padding 411 caret.css({ top: height-140, display: "block" }) : 412 caret.css({ display: "none" }); 413 }, 100)); 414 }); */ 415 }); 416 417}( window.salk = window.salk || {}, jQuery )); 418 419 420 jQuery('.closeall').click(function(){ 421 jQuery('.accordion-body.in') 422 .collapse('hide'); 423 jQuery(this).hide(); 424 jQuery('.openall').show(); 425 }); 426 jQuery('.openall').click(function(){ 427 jQuery('.accordion-body:not(".in")') 428 .collapse('show'); 429 jQuery(this).hide(); 430 jQuery('.closeall').show(); 431 432 }); 433 434 435 436 437 438 439 440jQuery( document ).ready(function() { 441 442// Javascript to enable link to tab 443 var url = document.location.toString(); 444 if (url.match('#')) { 445 jQuery('.nav-tabs a[href="#' + url.split('#')[1] + '"]').tab('show'); 446 } 447 448 // Change hash for page-reload 449 jQuery('.nav-tabs a').on('shown.bs.tab', function (e) { 450 window.location.hash = e.target.hash; 451 }); 452 453/* 454 455jQuery('#give-lively-widget-inner').load(function(){ 456 console.log('give lively widget ready'); 457 var myHead = jQuery("#give-lively-widget-inner").contents().find("head"); 458 var myCSS = '<style>.text-muted {color: #fff !important;}</style>'; 459 jQuery(myHead).append(myCSS); 460 }); */ 461}); 462 463 464 465
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.