1jQuery(function($) { 2 var Device = { 3 touch: false, 4 shortDuration: 400, 5 mediumDuration: 800, 6 longDuration: 1200, 7 initialLoadDone: false, 8 fullsite: false, 9 desktop: true, 10 init: function() { 11 Device.pixelRes = window.devicePixelRatio; 12 Device.touch = $('#js').hasClass('touch'); 13 Device.screenWidth = $('#screen-size').width(); 14 Device.screenHeight = $('#screen-size').height(); 15 Device.topPage = $('#top-page-wrapper').hasClass('active'); 16 Device.fullsite = $('#full-site-indicator').is(':visible'); 17 Device.desktop = $('#desktop-indicator').is(':visible'); 18 19 if (Device.pixelRes > 1.5) { 20 Device.pixelRes = 1.5; 21 } 22 /* 23 if (navigator.appName === 'Microsoft Internet Explorer' || !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv 11/)) || $.browser.msie === 1) { 24 $('#js').addClass('ie'); 25 } 26 */ 27 Accordion.fullsite = Device.fullsite; 28 }, 29 refresh: function() { 30 Device.screenWidth = $('#screen-size').width(); 31 Device.screenHeight = $('#screen-size').height(); 32 Device.fullsite = $('#full-site-indicator').is(':visible'); 33 Device.desktop = $('#desktop-indicator').is(':visible'); 34 Accordion.fullsite = Device.fullsite; 35 } 36 }; 37 38 var Filters = { 39 hash: '', 40 type: '', 41 venue: '', 42 dates: '', 43 access: '', 44 init: function() { 45 if ($('#event-archive').size() !== 0) { 46 Filters.detectHashChange(); 47 Filters.doFilters(); 48 Filters.bindClick(); 49 } 50 }, 51 detectHashChange: function() { 52 $(window).bind('hashchange', function() { 53 Filters.hash = window.location.hash + ''; 54 Filters.doFilters(); 55 }); 56 }, 57 getParameterByName: function(name, url) { 58 if (!url) { 59 url = window.location.href; 60 } 61 name = name.replace(/[\[\]]/g, "\\$&"); 62 var regex = new RegExp("[?&#]" + name + "(=([^&#]*)|&|#|$)"), 63 results = regex.exec(url); 64 if (!results) { 65 return null; 66 } else { 67 return decodeURIComponent(results[2].replace(/\+/g, " ")); 68 } 69 }, 70 changeHash: function() { 71 var _hash = ''; 72 if (Filters.type !== '') { 73 if (_hash !== '') { 74 _hash = _hash + '&'; 75 } 76 _hash = _hash + 'type=' + Filters.type; 77 } 78 if (Filters.access !== '') { 79 if (_hash !== '') { 80 _hash = _hash + '&'; 81 } 82 _hash = _hash + 'access=' + Filters.access; 83 } 84 if (Filters.venue !== '') { 85 if (_hash !== '') { 86 _hash = _hash + '&'; 87 } 88 _hash = _hash + 'venue=' + Filters.venue; 89 } 90 if (Filters.dates !== '') { 91 if (_hash !== '') { 92 _hash = _hash + '&'; 93 } 94 _hash = _hash + 'date=' + Filters.dates; 95 } 96 window.location.hash = _hash; 97 }, 98 bindClick: function() { 99 $('.type-filter').bind('click', function() { 100 if ($(this).hasClass('selected')) { 101 Filters.type = ''; 102 } else { 103 Filters.type = $(this).data('filter').replace('type-', ''); 104 } 105 Filters.changeHash(); 106 return false; 107 }); 108 $('.access-filter').bind('click', function() { 109 if ($(this).hasClass('selected')) { 110 Filters.access = ''; 111 } else { 112 Filters.access = $(this).data('filter').replace('access-', ''); 113 } 114 Filters.changeHash(); 115 return false;
116 }); 117 $('.venue-filter').bind('click', function() { 118 if ($(this).hasClass('selected')) { 119 Filters.venue = ''; 120 } else { 121 Filters.venue = $(this).data('filter').replace('venue-', ''); 122 } 123 Filters.changeHash(); 124 return false; 125 }); 126 $('.date-filter').bind('click', function() { 127 if ($(this).hasClass('selected')) { 128 Filters.dates = ''; 129 } else { 130 Filters.dates = $(this).data('filter'); 131 } 132 Filters.changeHash(); 133 return false; 134 }); 135 $('#clear-type-filters').bind('click', function() { 136 Filters.type = ''; 137 Filters.changeHash(); 138 return false; 139 }); 140 $('#clear-access-filters').bind('click', function() { 141 Filters.access = ''; 142 Filters.changeHash(); 143 return false; 144 }); 145 $('#clear-venue-filters').bind('click', function() { 146 Filters.venue = ''; 147 Filters.changeHash(); 148 return false; 149 }); 150 151 }, 152 doFilters: function() { 153 $('#featured-events').show(); 154 $('.event-listing').show().removeClass('date-match'); 155 156 var _type = Filters.getParameterByName('type', window.location.hash + ''); 157 if (_type !== null) { 158 $('.event-listing:not(.type-' + _type + ')').hide(); 159 $('#type-filter-menu').find('a').removeClass('selected'); 160 $('[data-filter=type-' + _type + ']').addClass('selected'); 161 $('#type-filter-menu').find('a').first().html($('[data-filter=type-' + _type + ']').html() + '<span class="collapse-icon"></span>'); 162 Filters.type = $('[data-filter=type-' + _type + ']').data('filter').replace('type-', ''); 163 } else { 164 $('#type-filter-menu').find('a').first().html('All Event Types<span class="collapse-icon"></span>'); 165 $('#type-filter-menu').find('a').removeClass('selected'); 166 $('#clear-type-filters').addClass('selected'); 167 Filters.type = ''; 168 } 169 170 var _access = Filters.getParameterByName('access', window.location.hash + ''); 171 if (_access !== null) { 172 $('.event-listing:not(.access-' + _access + ')').hide(); 173 $('#access-filter-menu').find('a').removeClass('selected'); 174 $('[data-filter=access-' + _access + ']').addClass('selected'); 175 $('#access-filter-menu').find('a').first().html($('[data-filter=access-' + _access + ']').html() + '<span class="collapse-icon"></span>'); 176 Filters.access = $('[data-filter=access-' + _access + ']').data('filter').replace('access-', ''); 177 } else { 178 $('#access-filter-menu').find('a').first().html('Accessibility<span class="collapse-icon"></span>'); 179 $('#access-filter-menu').find('a').removeClass('selected'); 180 $('#clear-access-filters').addClass('selected'); 181 Filters.access = ''; 182 } 183 184 var _venue = Filters.getParameterByName('venue', window.location.hash + ''); 185 if (_venue !== null) { 186 $('.event-listing:not(.venue-' + _venue + ')').hide(); 187 $('#venue-filter-menu').find('a').removeClass('selected'); 188 $('[data-filter=venue-' + _venue + ']').addClass('selected'); 189 $('#venue-filter-menu').find('a').first().html($('[data-filter=venue-' + _venue + ']').html() + '<span class="collapse-icon"></span>'); 190 Filters.venue = $('[data-filter=venue-' + _venue + ']').data('filter').replace('venue-', ''); 191 } else { 192 $('#venue-filter-menu').find('a').first().html('All Event Venues<span class="collapse-icon"></span>'); 193 $('#venue-filter-menu').find('a').removeClass('selected'); 194 $('#clear-venue-filters').addClass('selected'); 195 Filters.venue = ''; 196 } 197 var _dates = Filters.getParameterByName('date', window.location.hash + ''); 198 $('#date-filters').find('a').removeClass('selected'); 199 200 Filters.dates = ''; 201 202 if (_dates !== null) { 203 var _dateArr = _dates.split(","); 204 205 for (var _i = 0; _i < _dateArr.length; _i++) { 206 $('.event-listing.date-' + _dateArr[_i]).addClass('date-match'); 207 $('[data-filter=' + _dateArr[_i] + ']').addClass('selected'); 208 Filters.dates = Filters.dates + $('[data-filter=' + _dateArr[_i] + ']').data('filter'); 209 if (_i !== (_dateArr.length - 1)) { 210 Filters.dates = Filters.dates + ','; 211 } 212 } 213 $('.event-listing:not(.date-match)').hide(); 214 } 215 216 if ($('.event-listing:visible').size() === 0) { 217 $('#no-results').show(); 218 } else { 219 $('#no-results').hide(); 220 } 221 222 if (Filters.getParameterByName('auslan', window.location.hash + '') === 'true') { 223 $('#auslan-toggle').addClass('selected'); 224 $('.event-listing:not(.auslan-interpreted').hide();
225 Filters.auslan = true; 226 } else { 227 $('#auslan-toggle').removeClass('selected'); 228 Filters.auslan = false; 229 } 230 231 if ($('.event-listing:visible').size() === 0) { 232 $('#no-results').show(); 233 $('#event-count').hide(); 234 } else { 235 $('#no-results').hide(); 236 $('#event-count').show(); 237 $('#event-counter').html($('.event-listing:visible').size()); 238 } 239 240 if ($('#featured-events').find('.event-listing:visible').size() === 0) { 241 $('#featured-events').hide(); 242 } else { 243 $('#standard-events').find('.type-highlight').hide(); 244 } 245 246 247 setTimeout(function() { 248 $(window).trigger('resize'); 249 ObjectFit.fit(); 250 }, 0); 251 } 252 }; 253 254 var Accordion = { 255 fullsite: null, 256 init: function() { 257 Accordion.resize(); 258 Accordion.bindClick(); 259 }, 260 resize: function() { 261 if (Accordion.fullsite !== Device.fullsite) { 262 263 Accordion.fullsite = Device.fullsite; 264 265 $('.mobile-accordion-header-toggle.configured').removeClass('open'); 266 $('.mobile-accordion-wrapper.configured').removeClass('open'); 267 268 $('.desktop-accordion-header-toggle.configured').removeClass('open'); 269 $('.desktop-accordion-wrapper.configured').removeClass('open'); 270 271 if (Accordion.fullsite === false) { 272 $('.desktop-accordion-body.configured').attr('style', ''); 273 $('.mobile-accordion-body.configured').hide(); 274 } else { 275 $('.mobile-accordion-body.configured').attr('style', ''); 276 $('.desktop-accordion-body.configured').hide(); 277 } 278 } 279 if (Accordion.fullsite === false) { 280 $('.mobile-accordion-body:not(.configured)').hide(); 281 } else { 282 $('.desktop-accordion-body:not(.configured)').hide(); 283 } 284 285 286 $('.mobile-accordion-body:not(.configured)').addClass('configured'); 287 $('.mobile-accordion-header-toggle:not(.configured)').addClass('configured'); 288 $('.mobile-accordion-wrapper:not(.configured)').addClass('configured'); 289 290 $('.desktop-accordion-body:not(.configured)').addClass('configured'); 291 $('.desktop-accordion-header-toggle:not(.configured)').addClass('configured'); 292 $('.desktop-accordion-wrapper:not(.configured)').addClass('configured'); 293 }, 294 toggleWrapper: function(_el, _wrapper, _body) { 295 296 _body.stop(true, false); 297 _wrapper.stop(true, false); 298 299 var _height = 0; 300 301 if (_wrapper.hasClass('open')) { 302 303 _wrapper.css({ 304 'height': _wrapper.height() 305 }); 306 307 _wrapper.removeClass('open'); 308 _el.removeClass('open'); 309 310 _height = _el.outerHeight(true); 311 312 _body.fadeOut(function() { 313 if (_el.hasClass('accordion-toggle-other-target')) { 314 var _target = $('' + _el.data('other-target') + ''); 315 _target.animate({ 316 'height': 0 317 }); 318 } 319 _wrapper.animate({ 320 'height': _height 321 }, function() { 322 _wrapper.css({ 323 'height': 'auto' 324 }); 325 $(window).trigger('resize'); 326 }); 327 }); 328 329 } else { 330 331 _wrapper.addClass('open'); 332 _el.addClass('open'); 333 _body.show(); 334 _height = _wrapper.height(); 335 _body.hide(); 336 if (_el.hasClass('accordion-toggle-other-target')) { 337 var _target = $('' + _el.data('other-target') + ''); 338 _target.animate({ 339 'height': _height 340 }); 341 } 342 _wrapper.animate({ 343 'height': _height 344 }, function() { 345 _body.fadeIn(); 346 _wrapper.css({ 347 'height': 'auto' 348 }); 349 $(window).trigger('resize'); 350 }); 351 } 352 }, 353 bindClick: function() { 354 $('body').on('click', '.mobile-accordion-header-toggle', function() { 355 if (Accordion.fullsite === false) { 356 var _el = $(this); 357 var _wrapper = $(this).closest('.mobile-accordion-wrapper'); 358 var _body = _wrapper.find('.mobile-accordion-body').first(); 359 360 Accordion.toggleWrapper(_el, _wrapper, _body); 361 362 } 363 return false;
364 }); 365 366 $('body').on('click', '.desktop-accordion-header-toggle', function() { 367 368 if (Accordion.fullsite) { 369 370 var _el = $(this); 371 var _wrapper = $(this).closest('.desktop-accordion-wrapper'); 372 var _body = _wrapper.find('.desktop-accordion-body').first(); 373 374 Accordion.toggleWrapper(_el, _wrapper, _body); 375 376 } 377 return false; 378 }); 379 380 } 381 }; 382 383 var FauxCheckboxGroup = { 384 selectAllBound: false, 385 init: function() { 386 $('.checkbox-group').each(function() { 387 /* check this hasn't already been setup */ 388 if ($(this).find('a.faux-checkbox').size() === 0) { 389 FauxCheckboxGroup.setup($(this)); 390 FauxCheckboxGroup.bindClick($(this)); 391 } 392 }); 393 394 if (FauxCheckboxGroup.selectAllBound === false) { 395 FauxCheckboxGroup.selectAllBound = true; 396 FauxCheckboxGroup.bindSelectAll(); 397 } 398 399 FauxCheckboxGroup.doActiveCheck(); 400 FauxCheckboxGroup.doSelectAllCheck(); 401 }, 402 setup: function(_element) { 403 404 /* loop through all nested radio buttons and build HTML */ 405 _element.find('input[type="checkbox"]').each(function() { 406 var _html = ''; 407 var _text = $(this).attr('value'); 408 var _attr = $(this).attr('data-text'); 409 if (typeof _attr !== typeof undefined && _attr !== false) { 410 _text = _attr; 411 } 412 _attr = $(this).attr('data-secondary-text'); 413 if (typeof _attr !== typeof undefined && _attr !== false) { 414 _html = _html + '<a href="#" class="faux-checkbox">' + _text + '<span>' + _attr + '</span><span class="icon"><span></span><span></span></span></a>'; 415 } else { 416 _html = _html + '<a href="#" class="faux-checkbox">' + _text + '<span class="icon"><span></span><span></span></span></a>'; 417 } 418 419 $(this).bind('change', function() { 420 FauxCheckboxGroup.doActiveCheck(); 421 $('form').removeClass('last-focused'); 422 $(this).closest('form').addClass('last-focused'); 423 if ($(this).closest('.programme-filters').size() !== 0) { 424 SiteHash.doFormCheck(); 425 } 426 }); 427 428 $(_html).insertAfter($(this)); 429 430 }); 431 }, 432 433 /* loop through all radio buttons and check state - match back to faux element */ 434 doActiveCheck: function() { 435 $('.checkbox-group input[type="checkbox"]').each(function(_index) { 436 if ($(this)[0].checked === true) { 437 $('.faux-checkbox:eq(' + _index + ')').addClass('selected'); 438 } else { 439 $('.faux-checkbox:eq(' + _index + ')').removeClass('selected'); 440 } 441 }); 442 FauxCheckboxGroup.doSelectAllCheck(); 443 }, 444 bindSelectAll: function() { 445 $('body').on('click', '.checkbox-toggle-all', function() { 446 var _target = $(this).data('target'); 447 if ($(this).hasClass('clear-all')) { 448 $('input[name="' + _target + '"]').each(function() { 449 $(this).prop('checked', false); 450 $(this).trigger('change'); 451 }); 452 } else { 453 $('input[name="' + _target + '"]').each(function() { 454 $(this).prop('checked', true); 455 $(this).trigger('change'); 456 }); 457 } 458 return false; 459 }); 460 }, 461 doSelectAllCheck: function() { 462 $('.checkbox-toggle-all').each(function() { 463 464 var _target = $(this).data('target'); 465 var _found = false; 466 var _foundCount = 0; 467 $('input[name="' + _target + '"]').each(function() { 468 if ($(this)[0].checked === true) { 469 _found = true; 470 _foundCount = _foundCount + 1; 471 } 472 }); 473 $(this).removeClass('select-all'); 474 $(this).removeClass('clear-all'); 475 $(this).removeClass('some-selected'); 476 if (Device.fullsite) { 477 if (_foundCount === 0) { 478 $(this).addClass('select-all'); 479 $(this).text('Select All'); 480 } else if ($('input[name="' + _target + '"]').size() === _foundCount) { 481 $(this).addClass('clear-all'); 482 $(this).text('Clear All'); 483 } else { 484 $(this).addClass('clear-all'); 485 $(this).addClass('some-selected'); 486 } 487 } else { 488 if (_found === true) { 489 $(this).addClass('clear-all'); 490 $(this).text('Clear All'); 491 } else { 492 $(this).addClass('select-all'); 493 $(this).text('Select All'); 494 } 495 } 496 }); 497 }, 498 499 /* bind click on faux elements */ 500 bindClick: function(_element) { 501 _element.find('.faux-checkbox').bind('click', function() { 502 503 var _menuWrapper = $(this).closest('.checkbox-group'); 504 var _index = _menuWrapper.find('.faux-checkbox').index($(this)); 505 var _checkbox = _menuWrapper.find('input[type="checkbox"]:eq(' + _index + ')'); 506 507 if (_checkbox[0].checked === true) { 508 _checkbox.prop('checked', false); 509 } else { 510 _checkbox.prop('checked', true); 511 } 512 513 _checkbox.trigger('change'); 514 return false;
515 }); 516 } 517 }; 518 519 520 var LoadMedia = { 521 522 totalBrackets: 9, 523 init: function() { 524 $('.load-media').each(function() { 525 LoadMedia.doLoad($(this)); 526 }); 527 }, 528 doLoad: function(_element) { 529 if (_element.hasClass('load-called') === false) { 530 _element.addClass('load-called'); 531 var _src = LoadMedia.findSrc(_element); 532 $('<img src="' + _src + '">').load(function() { 533 if (_element.hasClass('load-background')) { 534 _element.css({ 535 'background-image': 'url(' + _src + ')' 536 }); 537 } else { 538 $(this).appendTo(_element); 539 } 540 setTimeout(function() { 541 ObjectFit.fit(); 542 _element.addClass('media-loaded'); 543 _element.closest('.media-wrapper').addClass('media-ready'); 544 }, 100); 545 }); 546 } 547 }, 548 findSrc: function(_element) { 549 550 var _width = _element.width() * Device.pixelRes; 551 var _height = _element.height() * Device.pixelRes; 552 553 if (_element.is(':hidden') || _width === 0) { 554 _width = Device.screenWidth * Device.pixelRes; 555 _height = Device.screenHeight * Device.pixelRes; 556 } 557 558 var _bracket = -1; 559 var _bracketCount = 0; 560 561 for (var _i = 0; _i < LoadMedia.totalBrackets; _i++) { 562 var _bracketWidth = _element.attr('data-img-width-' + _i + ''); 563 var _bracketHeight = _element.attr('data-img-height-' + _i + ''); 564 565 if (typeof _bracketWidth === 'undefined') { 566 break; 567 } else { 568 if (_width > _bracketWidth) { 569 //_bracket = _i; 570 } else { 571 //_bracket = _i; 572 if (_width < _bracketWidth) { 573 if (typeof _bracketHeight === 'undefined') { 574 var _src = _element.data('img-url-' + (_i + 1) + ''); 575 if (typeof _src === 'undefined') { 576 _bracket = _i; 577 } else { 578 _bracket = _i; 579 } 580 break; 581 } else { 582 if (_height < _bracketHeight) { 583 var _src = _element.data('img-url-' + (_i + 1) + ''); 584 if (typeof _src === 'undefined') { 585 _bracket = _i; 586 } else { 587 _bracket = _i; 588 } 589 break; 590 } 591 } 592 } 593 } 594 } 595 _bracketCount = _bracketCount + 1; 596 } 597 598 if (_bracket === -1) { 599 _bracket = _bracketCount; 600 } 601 602 var _src = _element.data('img-url-' + _bracket + ''); 603 if (typeof _src === 'undefined') { 604 _bracket = _bracket - 1; 605 _src = _element.data('img-url-' + _bracket + ''); 606 } 607 608 return _src; 609 } 610 }; 611 612 var ObjectFit = { 613 fit: function() { 614 $('.object-fit').each(function() { 615 if ($(this).find('video, img, iframe').size() !== 0) { 616 617 var _media = $(this).find('video, img, iframe').first(); 618 619 _media.attr('style', ''); 620 621 622 var _width = _media.width(); 623 var _height = _media.height(); 624 var _ratio = _width / _height; 625 var _parentWidth = _media.parent().outerWidth(); 626 var _parentHeight = _media.parent().outerHeight(); 627 var _marginLeft = 0; 628 var _marginTop = 0; 629 var _parentRatio = _parentWidth / _parentHeight; 630 631 if ($(this).hasClass('object-contain')) { 632 if (_parentRatio > _ratio) { 633 _height = _parentHeight + 1; 634 _width = Math.ceil(_parentHeight * _ratio); 635 } else { 636 _width = _parentWidth + 1; 637 _height = Math.floor(_parentWidth / _ratio); 638 } 639 } else { 640 if (_parentRatio < _ratio) { 641 _height = _parentHeight; 642 _width = Math.ceil(_parentHeight * _ratio); 643 } else { 644 _width = _parentWidth; 645 _height = Math.floor(_parentWidth / _ratio); 646 } 647 } 648 649 _marginTop = Math.floor((_parentHeight - _height) / 2); 650 _marginLeft = Math.floor((_parentWidth - _width) / 2); 651 652 _media.css({ 653 'width': _width, 654 'height': _height, 655 'margin-top': _marginTop, 656 'margin-left': _marginLeft 657 }); 658 } 659 }); 660 } 661 }; 662 663 var NumListFix = { 664 init: function() { 665 $('ol').each(function() { 666 $(this).find('li').each(function(_index) { 667 $(this).find('.bullet').text((_index + 1) + '.'); 668 }); 669 }); 670 } 671 }; 672 673 var ScrollTop = { 674 bound: false, 675 init: function() { 676 if (ScrollTop.bound === false) { 677 $('body').on('click', '.scroll-top-button', function() { 678 $('body, html').animate({ 679 scrollTop: "0px" 680 }); 681 return false;
682 }); 683 ScrollTop.bound = true; 684 } 685 } 686 }; 687 688 var FormFix = { 689 init: function() { 690 $('form, input').attr('autocomplete', 'off'); 691 } 692 }; 693 694 var Carousel = { 695 carouselEl: [], 696 interval: [], 697 init: function() { 698 Carousel.bindControls(); 699 }, 700 bindControls: function() { 701 if (Device.initialLoadDone === false) { 702 $('body').on('click', '.carousel-control', function() { 703 704 var _el = $(this); 705 var _parent = _el.closest('ul'); 706 var _index = _parent.find('.carousel-control').index(_el); 707 var _carousel = _el.closest('.carousel'); 708 709 for (var _i = 0; _i < 10; _i++) { 710 _carousel.removeClass('active-index-' + _i); 711 } 712 713 _carousel.addClass('active-index-' + _index); 714 715 /* reset video on all slides */ 716 _carousel.find('.carousel-slide').each(function(_slideIndex) { 717 if (_slideIndex !== _index && $(this).hasClass('video-wrapper')) { 718 $(this).html($(this).html()); 719 } 720 }); 721 722 return false; 723 }); 724 725 $('body').on('click', '.carousel-prev, .carousel-next', function() { 726 var _el = $(this); 727 var _carousel = _el.closest('.carousel'); 728 var _maxNumber = _carousel.find('.carousel-control').size() - 1; 729 var _current = 0; 730 for (var _i = 0; _i < 10; _i++) { 731 if (_carousel.hasClass('active-index-' + _i)) { 732 _current = _i; 733 } 734 } 735 if ($(this).hasClass('carousel-prev')) { 736 _current = _current - 1; 737 if (_current < 0) { 738 _current = _maxNumber; 739 } 740 } 741 if ($(this).hasClass('carousel-next')) { 742 _current = _current + 1; 743 if (_current > _maxNumber) { 744 _current = 0; 745 } 746 } 747 _carousel.find('.carousel-control:eq(' + _current + ')').trigger('click'); 748 return false; 749 }); 750 } 751 }, 752 resize: function() { 753 $('.caption-wrapper').each(function() { 754 var _highest = 0; 755 $(this).find('.carousel-caption').each(function() { 756 var _height = $(this).height(); 757 if (_highest < _height) { 758 _highest = _height; 759 } 760 }); 761 $(this).height(_highest); 762 }); 763 } 764 }; 765 766 var ScrollBehaviour = { 767 loadOffsets: null, 768 loadElements: null, 769 scrollDown: true, 770 scrollPos: 0, 771 lastPos: 0, 772 navHeight: 0, 773 moveUpPos: false, 774 menuPos: 0, 775 init: function() { 776 ScrollBehaviour.getLoadOffsets(); 777 ScrollBehaviour.bindScroll(); 778 $(window).scrollTop(0); 779 $(window).trigger('scroll'); 780 }, 781 getLoadOffsets: function() { 782 ScrollBehaviour.loadOffsets = []; 783 ScrollBehaviour.loadElements = []; 784 $('.load-media-on-scroll').each(function(_index) { 785 ScrollBehaviour.loadElements[_index] = $(this); 786 ScrollBehaviour.loadOffsets[_index] = $(this).offset().top - (Device.screenHeight * 2); 787 }); 788 }, 789 bindScroll: function() { 790 if (Device.initialLoadDone === false) { 791 $(window).bind('scroll', function() { 792 ScrollBehaviour.lastPos = ScrollBehaviour.scrollPos; 793 ScrollBehaviour.scrollPos = $(window).scrollTop(); 794 if (ScrollBehaviour.lastPos > ScrollBehaviour.scrollPos) { 795 ScrollBehaviour.scrollDown = false;
796 } else { 797 ScrollBehaviour.scrollDown = true; 798 } 799 ScrollBehaviour.doLoadCheck(); 800 ScrollBehaviour.doNavPos(); 801 }); 802 } 803 }, 804 doNavPos: function() { 805 if ($('body').hasClass('.show-mobile-navigation') && ScrollBehaviour.moveUpPos === false) { 806 $('#site-header').stop(false, false).animate({ 807 'margin-top': 0 808 }); 809 ScrollBehaviour.moveUpPos = true; 810 } else if (ScrollBehaviour.moveUpPos === false && ScrollBehaviour.scrollDown === false) { 811 $('#site-header').stop(false, false).animate({ 812 'margin-top': 0 813 }); 814 ScrollBehaviour.moveUpPos = true; 815 } else if (ScrollBehaviour.scrollDown === true && $('body').hasClass('.show-mobile-navigation') === false) { 816 if (ScrollBehaviour.scrollPos > ScrollBehaviour.navHeight && ScrollBehaviour.moveUpPos === true) { 817 $('#site-header').stop(false, false).animate({ 818 'margin-top': (0 - ScrollBehaviour.navHeight) 819 }); 820 ScrollBehaviour.moveUpPos = false; 821 } else if (ScrollBehaviour.scrollPos <= ScrollBehaviour.navHeight) { 822 $('#site-header').stop(false, false).css({ 823 'margin-top': (0 - ScrollBehaviour.scrollPos) 824 }); 825 ScrollBehaviour.moveUpPos = false; 826 } else if ($('#site-header').is(':animated') === false && ScrollBehaviour.moveUpPos === false) { 827 $('#site-header').stop(false, false).css({ 828 'margin-top': (0 - ScrollBehaviour.navHeight) 829 }); 830 } 831 } 832 }, 833 doLoadCheck: function() { 834 var _found = false; 835 for (var _i = 0; _i < ScrollBehaviour.loadOffsets.length; _i++) { 836 if (ScrollBehaviour.loadOffsets[_i] < ScrollBehaviour.scrollPos && ScrollBehaviour.loadElements[_i].hasClass('load-media') === false) { 837 if (ScrollBehaviour.loadElements[_i].is(':visible')) { 838 ScrollBehaviour.loadElements[_i].addClass('load-media'); 839 _found = true; 840 } 841 } 842 } 843 if (_found === true) { 844 LoadMedia.init(); 845 } 846 }, 847 resize: function() { 848 ScrollBehaviour.scrollPos = $(window).scrollTop(); 849 $(window).scrollTop(0); 850 851 ScrollBehaviour.getLoadOffsets(); 852 ScrollBehaviour.scrollDown = false; 853 ScrollBehaviour.navHeight = $('#header-bg').height() + 2; 854 855 $(window).scrollTop(ScrollBehaviour.scrollPos); 856 $(window).trigger('scroll'); 857 858 }, 859 }; 860 861 var WidowFix = { 862 init: function() { 863 $('h1, h2, h3, h4, h5, h6, .large-text p').each(function() { 864 $(this).html($(this).html().replace(/ /g, ' ')); 865 $(this).html($(this).html().replace(' ', ' ')); 866 }); 867 $('h1').widowFix(); 868 $('h2').widowFix(); 869 $('h3').widowFix(); 870 $('h4').widowFix(); 871 $('h5').widowFix(); 872 $('h6').widowFix(); 873 $('.large-text p').widowFix(); 874 } 875 }; 876 877 var MissingPaginationFix = { 878 init: function() { 879 $('.pagination').each(function() { 880 if ($(this).find('.next').size() === 0) { 881 $(this).append('<span class="next page-numbers">Next</span>'); 882 } 883 if ($(this).find('.prev').size() === 0) { 884 $(this).append('<span class="prev page-numbers">Previous</span>'); 885 } 886 if ($(this).find('a').size() === 0) { 887 $(this).find('span').hide(); 888 } 889 }); 890 } 891 }; 892 893 var MainNav = { 894 init: function() { 895 $('.menu-item-has-children > a').bind('click', function() { 896 var _parent = $(this).parent(); 897 if (Device.desktop === true) { 898 899 if (_parent.hasClass('show-sub-nav')) { 900 if ($(this).attr('href') === '#') { 901 _parent.removeClass('show-sub-nav'); 902 _parent.removeClass('do-sub-nav-animate'); 903 return false;
904 } 905 } else { 906 _parent.addClass('show-sub-nav'); 907 setTimeout(function() { 908 _parent.addClass('do-sub-nav-animate'); 909 }, 10); 910 return false; 911 } 912 } else { 913 if (_parent.hasClass('menu-item-has-children') && $(this).attr('href') === '#') { 914 _parent.find('ul,li').stop(true, false).show(); 915 var _height = 0; 916 _parent.find('li').each(function() { 917 _height = _height + $(this).height(); 918 }); 919 if ($(this).hasClass('open')) { 920 $(this).removeClass('open'); 921 _parent.find('li').fadeOut(function() { 922 _parent.find('ul').animate({ 923 'height': 0 924 }); 925 }); 926 } else { 927 $(this).addClass('open'); 928 _parent.find('li').hide(); 929 _parent.find('ul').animate({ 930 'height': _height 931 }, function() { 932 $(this).find('li').fadeIn(); 933 }); 934 } 935 return false; 936 } 937 } 938 }); 939 if ($('html').hasClass('touch') === false) { 940 $('.menu-item-has-children > a').bind('mouseover', function() { 941 var _parent = $(this).parent(); 942 _parent.addClass('show-sub-nav'); 943 setTimeout(function() { 944 _parent.addClass('do-sub-nav-animate'); 945 }, 10); 946 }); 947 $('.menu-item-has-children').bind('mouseleave', function() { 948 $(this).removeClass('show-sub-nav'); 949 $(this).removeClass('do-sub-nav-animate'); 950 }); 951 } 952 $('#menu-button').bind('click', function() { 953 if ($('body').hasClass('show-mobile-navigation')) { 954 $('body').removeClass('show-mobile-navigation'); 955 $('#menu-button').removeClass('close-state'); 956 } else { 957 $('body').addClass('show-mobile-navigation'); 958 $('#menu-button').addClass('close-state'); 959 MainNav.doResize(); 960 } 961 return false; 962 }); 963 964 }, 965 doResize: function() { 966 if (Device.desktop === true) { 967 $('#main-navigation-inner-wrapper').attr('style', ''); 968 } else { 969 var _topOffset = $('#menu-header-menu').offset().top; 970 var _bottomOffset = $('#secondary-menu-header-menu').outerHeight() - $('#main-navigation-inner-wrapper').offset().left; 971 972 973 974 $('#menu-header-menu').children('li').each(function() { 975 _topOffset = $(this).children('a').outerHeight() + _topOffset; 976 }); 977 978 var _padding = (Device.screenHeight - _topOffset - _bottomOffset) / 2; 979 980 $('#main-navigation-inner-wrapper').css({ 981 'padding-bottom': _padding + $('#secondary-menu-header-menu').outerHeight() 982 }); 983 984 $('.secondary-menu-header-menu-container').css({ 985 'bottom': _padding 986 }); 987 } 988 } 989 }; 990 991 var MoveSearchForm = { 992 init: function() { 993 $('#secondary-menu-header-menu').append('<li id="search-form-wrapper"></li>'); 994 $('#search-form').appendTo($('#secondary-menu-header-menu').children('li').last()); 995 $('#s').attr('placeholder', 'Search'); 996 } 997 }; 998 999 var FixDoubleColumn = { 1000 resize: function() { 1001 if ($('#page').hasClass('double-column-layout')) { 1002 if ($('#menu-button').is(':visible')) { 1003 $('#page').find('.column-wrapper').first().css({ 1004 'min-height': 0 1005 }); 1006 } else { 1007 $('#page').find('.column-wrapper').first().css({ 1008 'min-height': ($('.page-section.page-sidebar').height() + 48) 1009 }); 1010 } 1011 } 1012 } 1013 }; 1014 1015 var InstagramHome = { 1016 init: function() { 1017 if ($('#links-instragram-feed').size() !== 0) { 1018 $('#links-instragram-feed').instagram({ 1019 1020 userId: '559671433',
1021 clientId: 'ab4fd7d30d474985a529eecaa464d3e8', 1022 show: 1, 1023 onComplete: function() { 1024 $('.instagram_like_container').first().prepend('<a href="https://www.instagram.com/emergingwriters/" target="_blank">emergingwriters</a>'); 1025 } 1026 }); 1027 } 1028 } 1029 }; 1030 1031 var FixFooterNav = { 1032 init: function() { 1033 var _wrapper = $('#menu-footer-menu').parent(); 1034 var _size = $('#menu-footer-menu').find('li').size(); 1035 var _halfway = Math.ceil(_size / 2) - 1; 1036 _wrapper.prepend('<ul></ul><ul></ul>'); 1037 $('#menu-footer-menu').find('li').each(function(_index) { 1038 if (_index > _halfway) { 1039 _wrapper.find('ul:eq(1)').append($(this)); 1040 } else { 1041 _wrapper.find('ul:eq(0)').append($(this)); 1042 } 1043 }); 1044 $('#menu-footer-menu').remove(); 1045 1046 } 1047 }; 1048 1049 var Masonry = { 1050 init: function() { 1051 $('.masonry-layout').isotope({ 1052 itemSelector: '.featured-content-module', 1053 percentPosition: true, 1054 transitionDuration: 0, 1055 masonry: { 1056 columnWidth: '.grid-sizer' 1057 } 1058 }); 1059 } 1060 } 1061 1062 var ResizeGalleryText = { 1063 minTextWidth: 320, 1064 doResize: function() { 1065 if ($('#carousel').size() !== 0) { 1066 $('#carousel').find('.headline').attr('style', ''); 1067 $('#carousel').find('.text').attr('style', ''); 1068 if ($('#carousel-indicator').is(':visible')) { 1069 1070 $('#carousel').find('.slide').each(function() { 1071 var _maxHeadlineWidth = $(this).find('.info-panel').width() - $(this).find('.button').width() - 96; 1072 var _usableWidth = $(this).find('.info-panel').width() - $(this).find('.headline').outerWidth() - $(this).find('.button').width() - 96; 1073 if (_usableWidth < ResizeGalleryText.minTextWidth) { 1074 $(this).find('.text').hide(); 1075 $(this).find('.headline').css({ 1076 'max-width': _maxHeadlineWidth 1077 }).addClass('no-text'); 1078 } else { 1079 $(this).find('.text').width(_usableWidth); 1080 $(this).find('.headline').removeClass('no-text'); 1081 } 1082 var _width = $('#carousel').find('h3').width(); 1083 1084 }); 1085 } else { 1086 1087 } 1088 } 1089 } 1090 } 1091 1092 var Resize = { 1093 timeout: null, 1094 init: function() { 1095 if (Device.initialLoadDone === false) { 1096 $(window).bind('resize', function() { 1097 Resize.doResize(); 1098 if (Resize.timeout != null) { 1099 clearTimeout(Resize.timeout); 1100 Resize.timeout = setTimeout(function() { 1101 Resize.doResize(); 1102 }, 250); 1103 } 1104 }); 1105 $(window).trigger('resize'); 1106 } 1107 Resize.doResize(); 1108 }, 1109 doResize: function() { 1110 Device.refresh(); 1111 MainNav.doResize(); 1112 Carousel.resize(); 1113 Masonry.init(); 1114 Accordion.resize(); 1115 FixDoubleColumn.resize(); 1116 ScrollBehaviour.resize(); 1117 ObjectFit.fit(); 1118 ResizeGalleryText.doResize(); 1119 IEDatePanelFix.resize(); 1120 } 1121 }; 1122 1123 var Maps = { 1124 doMaps: false, 1125 infoWindow: null, 1126 markers: [], 1127 mapOptions: null, 1128 map: null, 1129 infoBubble: null, 1130 init: function() { 1131 if ($('#gmap-wrapper').size() !== 0) { 1132 Maps.doMaps = true; 1133 1134 Maps.popMarkers(); 1135 1136 Maps.initMap(); 1137 Maps.showMarkers(); 1138 } 1139 }, 1140 showMarkers: function() { 1141 if (Maps.doMaps === true) { 1142 google.maps.event.trigger(Maps.map, "resize"); 1143 var latlngbounds = new google.maps.LatLngBounds(); 1144 Maps.markers[0].setMap(Maps.map); 1145 latlngbounds.extend(Maps.markers[0].position); 1146 Maps.map.setCenter(latlngbounds.getCenter()); 1147 Maps.map.fitBounds(latlngbounds); 1148 } 1149 }, 1150 initMap: function() { 1151 if (Maps.doMaps === true) { 1152 Maps.mapOptions = { 1153 scrollwheel: false, 1154 center: new google.maps.LatLng(Maps.markers[0].getPosition().lat(), Maps.markers[0].getPosition().lng()), 1155 mapTypeId: google.maps.MapTypeId.ROADMAP, 1156 maxZoom: 14, 1157 disableDefaultUI: true, 1158 zoomControl: false, 1159 zoomControlOptions: { 1160 position: google.maps.ControlPosition.LEFT_CENTER 1161 }, 1162 }; 1163 Maps.map = new google.maps.Map(document.getElementById("gmap-wrapper-inner"), Maps.mapOptions); 1164 } 1165 }, 1166 popMarkers: function() { 1167 if (Maps.doMaps === true) { 1168 Maps.activeMarkers = null; 1169 Maps.activeMarkers = []; 1170 var _pos = new google.maps.LatLng($('#gmap-wrapper').data('lat'), $('#gmap-wrapper').data('long')); 1171 var marker = new google.maps.Marker({ 1172 position: _pos, 1173 }); 1174 Maps.markers.push(marker); 1175 } 1176 } 1177 }; 1178
1179 var ShowFilterMenu = { 1180 rejectClick: false, 1181 timeout: null, 1182 init: function() { 1183 if (Device.touch === true) { 1184 /* 1185 $('li.filter-menu').children('a').bind('click',function(){ 1186 if ( $(this).parent().hasClass('show-sub-nav')) { 1187 $(this).parent().removeClass('show-sub-nav'); 1188 } else { 1189 $('li.filter-menu').removeClass('show-sub-nav'); 1190 $(this).parent().addClass('show-sub-nav'); 1191 } 1192 return false; 1193 });*/ 1194 } else { 1195 $('li.filter-menu').bind('mouseover', function() { 1196 $(this).addClass('show-sub-nav'); 1197 }); 1198 $('li.filter-menu').bind('mouseout', function() { 1199 $(this).removeClass('show-sub-nav'); 1200 }); 1201 } 1202 } 1203 }; 1204 1205 var IEDatePanelFix = { 1206 resize: function() { 1207 if ($('#date-filters').size() !== 0) { 1208 $('#date-filters').attr('style', ''); 1209 if (Device.fullsite === true) { 1210 var _width = $('#date-filters').children('li').first().width() * ($('#date-filters').children('li').size() - 1); 1211 $('#date-filters').css({ 1212 'width': _width, 1213 'margin-left': 'auto', 1214 'margin-right': 'auto' 1215 }); 1216 } 1217 } 1218 } 1219 }; 1220 1221 var RemoveHoverStates = { 1222 init: function() { 1223 if (Device.touch === true) { 1224 for (var sheetI = document.styleSheets.length - 1; sheetI >= 0; sheetI--) { 1225 var sheet = document.styleSheets[sheetI]; 1226 if (sheet.cssRules) { 1227 for (var ruleI = sheet.cssRules.length - 1; ruleI >= 0; ruleI--) { 1228 var rule = sheet.cssRules[ruleI]; 1229 if (rule.selectorText) { 1230 rule.selectorText = rule.selectorText.replace(":hover", ":active"); 1231 } 1232 } 1233 } 1234 } 1235 } 1236 } 1237 }; 1238 1239 var Slick = { 1240 init: function() { 1241 var _swipe = false; 1242 if (Device.touch === true) { 1243 _swipe = true 1244 } 1245 1246 $('.slick-wrapper').slick({ 1247 slidesToShow: 1, 1248 slidesToScroll: 1, 1249 arrows: false, 1250 fade: true, 1251 dots: false, 1252 infinite: true, 1253 swipe: _swipe, 1254 autoplaySpeed: 4500, 1255 autoplay: true, 1256 draggable: false 1257 }); 1258 $('.slick-slide').append('<a href="#" class="arrow-control left-control"></a><a href="#" class="arrow-control right-control"></a>'); 1259 $('.left-control').bind('click', function() { 1260 $(this).closest('.slick-wrapper').slick('slickPrev'); 1261 return false; 1262 }); 1263 $('.right-control').bind('click', function() { 1264 $(this).closest('.slick-wrapper').slick('slickNext'); 1265 return false; 1266 }); 1267 }, 1268 pad: function(_num, _size) { 1269 var _s = _num + ""; 1270 while (_s.length < _size) _s = "0" + _s; 1271 return _s; 1272 } 1273 } 1274 1275 1276 1277 var DoFerveLinks = { 1278 init: function() { 1279 $('.cart-menu-item a').bind('click', function(_event) { 1280 javascript: ferve.cart.show(1); 1281 _event.preventDefault(); 1282 }); 1283 $('.account-menu-item a').bind('click', function(_event) { 1284 javascript: ferve.utility.openLink('account', 0); 1285 _event.preventDefault(); 1286 }); 1287 $('.wishlist-menu-item a').bind('click', function(_event) { 1288 javascript: ferve.utility.openLink('wishlist', 0); 1289 _event.preventDefault(); 1290 }); 1291 } 1292 } 1293 1294 1295 var loadSite = { 1296 init: function() { 1297 Boot.bootPage(); 1298 Device.initialLoadDone = true; 1299 setTimeout(function() { 1300 $('#site-cover').fadeOut(400); 1301 }, 100); 1302 } 1303 }; 1304 1305 1306 1307 var Boot = { 1308 bootPage: function() {
1309 MoveSearchForm.init(); 1310 // Access.init(); 1311 FixFooterNav.init(); 1312 MainNav.init(); 1313 Accordion.init(); 1314 Carousel.init(); 1315 Slick.init(); 1316 FauxCheckboxGroup.init(); 1317 NumListFix.init(); 1318 ScrollTop.init(); 1319 Resize.init(); 1320 FormFix.init(); 1321 LoadMedia.init(); 1322 WidowFix.init(); 1323 MissingPaginationFix.init(); 1324 ScrollBehaviour.init(); 1325 Device.initialLoadDone = true; 1326 InstagramHome.init(); 1327 DoFerveLinks.init(); 1328 Filters.init(); 1329 Maps.init(); 1330 ShowFilterMenu.init(); 1331 $(window).trigger('resize'); 1332 } 1333 }; 1334 1335 1336 1337 $(window).load(function() { 1338 Device.init(); 1339 //RemoveHoverStates.init(); 1340 loadSite.init(); 1341 }); 1342 1343 1344 $(document).ready(function() { 1345 if (localStorage.getItem('popState') != 'shown') { 1346 $('#acknowledge-popup').css("display", "flex").hide().fadeIn(); 1347 localStorage.setItem('popState', 'shown') 1348 } 1349 1350 $('#popup-close, #acknowledge-popup').click(function() // You are clicking the close button 1351 { 1352 $('#acknowledge-popup').fadeOut(); // Now the pop up is hidden. 1353 }); 1354 1355 try { 1356 $('#main').responsiveTabs({ 1357 startCollapsed: 'accordion', 1358 animation: 'slide', 1359 scrollToAccordion: false, 1360 }); 1361 } catch (error) { 1362 /* silence */ 1363 } 1364 }); 1365 1366});
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.