/* IWS Dynamic Components
------------------------------------------- */
/* initialize components */
function iws_init() {
// Headline Autoscale Variables
var base_size;
var base_width;
var max_size = 72;
var min_window_size = 0;
var theID = '';
// Window Size Tracking
function resizeChecks() {
// Restore Standard Main Navigation
if (jQuery(window).width() >= 980) {
jQuery('.procurement #campaign-header form.mobile, .page-procurement #campaign-header form.mobile').hide();
jQuery('.procurement #campaign-header #mobile-side-menu, .page-procurement #campaign-header #mobile-side-menu').hide();
}
if (jQuery(window).width() >= 860) {
jQuery('#navigation h3 em').removeClass('open');
}
if (jQuery(window).width() >= 880) {
jQuery('.bursar #campaign-header form.mobile').hide();
}
if (jQuery(window).width() >= 880) {
$('#side-nav .tools-library').attr('tabindex', '-1');
}
else {
$('#side-nav .tools-library').removeAttr('tabindex');
}
// Get/set width of TOC
if ( $('.node-type-dfa-policies #main-body').length && (jQuery(window).width() >= 1200) ) {
var bodyOffset = $('.node-type-dfa-policies #main-body').offset().left;
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').width(bodyOffset - 66);
//$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8 h2').width(bodyOffset - 66);
}
if ( $('.node-type-dfa-policies #main-body').length && (jQuery(window).width() <= 1200) && (jQuery(window).width() >= 768) ) {
var bodyOffset = $('.node-type-dfa-policies #main-body').offset().left;
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').width(bodyOffset + 0);
//$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8 h2').width(bodyOffset - 66);
}
if ( $('.node-type-dfa-policies #main-body').length && (jQuery(window).width() <= 768) ) {
var bodyOffset = $('.node-type-dfa-policies #main-body').offset().left;
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').width(200);
//$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8 h2').width(bodyOffset - 66);
}
if (jQuery(window).width() >= 350) {
$('.has-slider.fis #wrap .quicktabs-wrapper .item-list ul li:nth-child(3)').each(function(){
var ampersand = $(this).html().replace('and','&');
$(this).html(ampersand);
});
}
if (jQuery(window).width() <= 350) {
$('.has-slider.fis #wrap .quicktabs-wrapper .item-list ul li:nth-child(3)').each(function(){
var space = $(this).html().replace(' and ',' ');
$(this).html(space);
});
}
if (jQuery(window).width() <= 479) {
$('#toc-toggle').each(function(){
var toc = $(this).html().replace('Table of Contents','TOC');
$(this).html(toc);
});
}
if (jQuery(window).width() >= 479) {
$('#toc-toggle').each(function(){
var toc = $(this).html().replace('TOC','Table of Contents');
$(this).html(toc);
});
}
// move all sidebar content below main content on smaller screens
if (jQuery(window).width() <= 768) {
$('#secondary-nav').insertAfter('#main-body');
}
else {
$('#secondary-nav').insertBefore('#main-body');
}
}
$.fn.exists = function () {
return this.length !== 0;
}
jQuery(window).load(function() {
// Fix duplicate ids in content area
$('h3[id="Ithaca-Based_Locations_and_Cornell_Tech-anchor"]').not(':eq(0)').each(function(i){ //selects all divs with the id but not the first one
var $that = $(this),
newID = $that.attr('id') + (i + 1) // adds a incising number to the ID's
$that.attr('id', newID) // sets the new id
})
$('h3[id="Weill_Cornell_Campus_Units-anchor"]').not(':eq(0)').each(function(i){ //selects all divs with the id but not the first one
var $that = $(this),
newID = $that.attr('id') + (i + 1) // adds a incising number to the ID's
$that.attr('id', newID) // sets the new id
})
// Fix duplicate hrefs in TOC
$('#secondary-nav a[href="#Ithaca-Based_Locations_and_Cornell_Tech-anchor"]').not(':eq(0)').each(function(i){ //selects all divs with the id but not the first one
var $that = $(this),
newHref = $that.attr('href') + (i + 1) // adds a incising number to the ID's
$that.attr('href', newHref) // sets the new id
})
$('#secondary-nav a[href="#Weill_Cornell_Campus_Units-anchor"]').not(':eq(0)').each(function(i){ //selects all divs with the id but not the first one
var $that = $(this),
newHref = $that.attr('href') + (i + 1) // adds a incising number to the ID's
$that.attr('href', newHref) // sets the new id
})
// Reinitialize Headline Autoscale (after remote webfonts load)
jQuery('.autosize-header .home #identity-content h1').removeAttr('style');
base_width = jQuery('.home #identity-content h1 span').width();
resizeChecks();
// Single-line News Headlines (move date to line two)
jQuery('.home #news h3').each(function( index ) {
if (jQuery(this).next('h4.date').position().top - jQuery(this).position().top < 8) {
jQuery(this).find('a').append(' ');
}
});
jQuery('.node-type-dfa-policies .filter-button.full-policy').addClass('section-open');
//$('#top_btn').css('display', 'none');
//$('#toc-toggle').css('display', 'none');
});
jQuery(document).ready(function() {
expander();
// Remove toc items
$('.pdf-section.no-toc h3').addClass('no-toc');
$('.pdf-section.no-toc h2').addClass('no-toc');
$('.policy-definition-title').addClass('no-toc');
$('body.fis').addClass('has-slider');
if (jQuery(window).width() >= 350) {
$('.has-slider.fis #wrap .quicktabs-wrapper .item-list ul li:nth-child(3)').each(function(){
var ampersand = $(this).html().replace('and','&');
$(this).html(ampersand);
});
resizeChecks();
}
if (jQuery(window).width() <= 350) {
$('.has-slider.fis #wrap .quicktabs-wrapper .item-list ul li:nth-child(3)').each(function(){
var space = $(this).html().replace(' and ',' ');
$(this).html(space);
});
resizeChecks();
}
if (jQuery(window).width() <= 479) {
$('#toc-toggle').each(function(){
var toc = $(this).html().replace('Table of Contents','TOC');
$(this).html(toc);
});
resizeChecks();
}
// Top button
$('#top_btn').click(function() {
$('html:not(:animated), body:not(:animated)').animate({
scrollTop: $('#main-body').offset().top
}, 200);
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').animate({
scrollTop: 0
}, 200);
$('#policy-filters .section-open').focus();
//$(this).blur();
});
$('#top_btn').prepend('');
// Toggle TOC
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').addClass('closed');
$('#toc-toggle').click(function() {
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').show('fast');
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').toggleClass('open closed');
$('#toc-title > button').focus();
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').animate({
scrollTop: 0
}, 200);
});
// Close TOC
$('#toc-title').append('');
// Close TOC
$('#toc-title .fa-times-circle').click(function() {
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').hide('fast');
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').removeClass('open');
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').addClass('closed');
$('#toc-toggle').css('display','block');
$('#toc-toggle').focus();
});
// Get/set width of TOC
if ( $('.node-type-dfa-policies #main-body').length && (jQuery(window).width() >= 1200) ) {
var bodyOffset = $('.node-type-dfa-policies #main-body').offset().left;
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').width(bodyOffset - 66);
//$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8 h2').width(bodyOffset - 66);
}
if ( $('.node-type-dfa-policies #main-body').length && (jQuery(window).width() <= 1200) && (jQuery(window).width() >= 768) ) {
var bodyOffset = $('.node-type-dfa-policies #main-body').offset().left;
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').width(bodyOffset + 0);
//$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8 h2').width(bodyOffset - 66);
}
if ( $('.node-type-dfa-policies #main-body').length && (jQuery(window).width() <= 768) ) {
var bodyOffset = $('.node-type-dfa-policies #main-body').offset().left;
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').width(200);
//$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8 h2').width(bodyOffset - 66);
}
/*add top menu to main nav (mobile)*/
jQuery('
').appendTo('#cu-brand .mean-bar .mean-nav > ul');
jQuery('#top-nav .content .menu').appendTo('#cu-brand .mean-bar .mean-nav > ul li.more-list-item');
jQuery('#cu-brand .mean-bar .mean-nav > ul li a.audience-more-link').css('pointer-events','none');
jQuery('+').appendTo('#cu-brand .mean-bar .mean-nav > ul li.more-list-item');
jQuery('#top-nav .block-menu h2').prependTo('#top-nav .content .menu');
jQuery('.my-mean-expand').on("click",function(e){
e.preventDefault();
if (jQuery(this).hasClass("mean-clicked")) {
jQuery(this).text('+');
jQuery('#cu-brand li.more-list-item ul').slideUp(300, function(){});
jQuery('#cu-brand li.more-list-item ul').css('pointer-events','none');
} else {
jQuery(this).text('-');
jQuery('#cu-brand li.more-list-item ul').slideDown(300, function(){});
jQuery('#cu-brand li.more-list-item ul').css('pointer-events','all');
}
jQuery(this).toggleClass("mean-clicked");
});
// Homepage Headline Autoscale
base_size = parseInt(jQuery('.home #identity-content h1').css('font-size'));
base_width = jQuery('.home #identity-content h1 span').width();
jQuery(window).resize(resizeChecks);
resizeChecks();
//calculate number of elements and add to parent columns class
if (!window.console) window.console = {};
if (!window.console.log) window.console.log = function () { }; //make this function work on IE9
jQuery('.region-wrap').addClass('columns');
jQuery('#main .region').addClass('columns');
jQuery('#main-body .region').addClass('columns');
jQuery('#news-and-events .region').addClass('columns');
jQuery('#popular-links .region').addClass('columns');
jQuery('#footer .region').addClass('columns');
jQuery('.page-procurement-supplierlistview .content table').addClass('wide');
jQuery('.fis #main-body .content table').addClass('wide');
jQuery('.procurement #main-body .content table').addClass('wide');
jQuery('.payroll #main-body .content table').addClass('wide');
jQuery('.accounting #main-body .content table').addClass('wide');
jQuery('.procurement #main-body .content table').addClass('wide');
jQuery('.tax #main-body .content table').addClass('wide');
jQuery('.travel #main-body .content table').addClass('wide');
jQuery('.capitalassets #main-body .content table').addClass('wide');
jQuery('.controller #main-body .content table').addClass('wide');
jQuery('.accounting.yearend #main-body .content table').addClass('wide');
jQuery('.region-popular-links').find('.popular-links-lists').addClass('col-item');
jQuery('.page-procurement-supplierlistview #main').removeClass('twocolumn sidebar-left');
jQuery('.page-events #main').removeClass('twocolumn sidebar-left');
jQuery('.page-news-events #main').removeClass('twocolumn sidebar-left');
jQuery('.html.tools-library.forms #main').removeClass('twocolumn sidebar-left');
jQuery('#block-system-main .content .node-department-page').removeClass('clearfix');
jQuery('#responsibilities > .field-collection-container').removeClass('clearfix');
jQuery('.columns').each(function(){
var col_count = jQuery(this).children('.col-item').length;
if (col_count > 5) {
col_count = 5;}
//console.log('col_count');
jQuery(this).addClass(' columns-'+col_count);
});
//match column heights
jQuery(function() {
if (jQuery(window).width() > 980) {
jQuery('body:not(.business-tools) .columns .col-item:not(.section-links)').matchHeight();
//console.log('matchHeight');
}
});
jQuery('#main-navigation').find('ul.nice-menu-down > li').addClass('top');
jQuery('#quicktabs-bursar .item-list').insertAfter('#quicktabs-bursar .quicktabs_main');
// Section Navigation (sidebar)
$('#secondary-nav .menu .expanded').attr('aria-haspopup', 'true');
$('').insertAfter( $('#secondary-nav .menu .expanded > a') );
$('.submenu-toggle').each(function(){
if ( $(this).parent().hasClass('active') ) {
$(this).attr('aria-expanded', 'true');
$(this).parent().addClass('open');
}
else {
$(this).attr('aria-expanded', 'false');
$(this).parent().removeClass('open');
}
});
$('.submenu-toggle').click(function() {
$(this).toggleClass('open');
$(this).parent().toggleClass('open');
$(this).parent().children('ul.menu').slideToggle(200);
if ( $(this).parent().hasClass('open') ) {
$(this).attr('aria-expanded', 'true');
}
else {
$(this).attr('aria-expanded', 'false');
}
});
// Justified Navigation
var nav_count = jQuery('.nav-centered #navigation ul.menu').first().find('li').length;
if (nav_count > 0) {
var nav_width = 100 / nav_count;
jQuery('.nav-centered #navigation ul.menu').first().find('li').css( 'width',nav_width+'%');
}
// Diagnostics
jQuery('#diagnostics').hide();
jQuery('#toggle-diagnostics').click(function(e) {
e.preventDefault();
jQuery(this).toggleClass('open');
jQuery('#diagnostics').slideToggle(300);
});
// Nav Temp
jQuery('#navigation a').click(function(e) {
e.preventDefault();
jQuery('#navigation li').removeClass('active');
jQuery(this).parent('li').addClass('active');
});
// Mobile bursar search
jQuery('.bursar #campaign-header form.mobile').hide();
jQuery('.bursar #campaign-header #side-nav .fa-search').click(function(e) {
e.preventDefault();
jQuery('.bursar #campaign-header form.mobile').slideToggle(200);
resizeChecks();
});
// Mobile procurement search
jQuery('.procurement #campaign-header #mobile-form, .page-procurement #campaign-header #mobile-form').hide();
jQuery('.procurement #campaign-header #side-nav .fa-search, .page-procurement #campaign-header #side-nav .fa-search').click(function(e) {
e.preventDefault();
jQuery('.procurement #campaign-header #mobile-form, .page-procurement #campaign-header #mobile-form').slideToggle(200);
if ( jQuery('.procurement #campaign-header #mobile-side-menu, .page-procurement #campaign-header #mobile-side-menu').css('visibility','visible') ) {
jQuery('.procurement #campaign-header #mobile-side-menu, .page-procurement #campaign-header #mobile-side-menu').hide();
}
resizeChecks();
});
// Mobile side nav menu
jQuery('.procurement #campaign-header #mobile-side-menu, .page-procurement #campaign-header #mobile-side-menu').hide();
jQuery('.procurement #campaign-header .fa-reorder, .page-procurement #campaign-header .fa-reorder').click(function(e) {
e.preventDefault();
jQuery('.procurement #campaign-header #mobile-side-menu, .page-procurement #campaign-header #mobile-side-menu').slideToggle(200);
if ( jQuery('.procurement #campaign-header #mobile-form, .page-procurement #campaign-header #mobile-form').css('visibility','visible') ) {
jQuery('.procurement #campaign-header #mobile-form, .page-procurement #campaign-header #mobile-form').hide();
}
resizeChecks();
});
// Form UI
jQuery('#cuweblogin input').focus(function() {
jQuery(this).parent('fieldset').addClass('active');
}).blur(function() {
jQuery(this).parent('fieldset').removeClass('active');
});
// Search
var mousedown = false;
$('#search-button').click(function(e) {
e.preventDefault();
mousedown = true;
$('#search-box').toggleClass('open');
$(this).toggleClass('open');
if ( $(this).hasClass('open') ) {
$('#searchbox').focus();
}
else {
$(this).focus();
mousedown = false;
}
});
$('#cu-search input').focus(function() {
if (!mousedown) {
$('#search-box, #search-button').addClass('open');
mousedown = false;
}
});
// Add ol counter class
jQuery('ol').addClass('custom-counter');
//business tools icon
jQuery('.ftbsc #main-navigation .region-main-navigation .content .nice-menu li.menu-6271').append('');
jQuery('.bsc #main-navigation .region-main-navigation .content .nice-menu li.menu-6271').append('');
// Mobile Table Helper
jQuery('#main-body table.wide').wrap('');
//jQuery('.tools-library #main table').wrap('');
jQuery('.table-scroller').append('').bind('scroll touchmove', function() {
jQuery(this).find('.table-fader').remove(); // hide fader DIV on user interaction
});
// Focus states for grid images
jQuery('#spotlight .node .field-content a').each(function(){
$(this).focus(function () {
$(this).parent().parent().find('img').css('opacity', '.82');
});
$(this).blur(function () {
$(this).parent().parent().find('img').css('opacity', '1');
});
});
jQuery('#spotlight .node .event-short-description a').each(function(){
$(this).focus(function () {
$(this).parent().parent().find('img').css('opacity', '.82');
});
$(this).blur(function () {
$(this).parent().parent().find('img').css('opacity', '1');
});
});
// Add null alt for grid images
jQuery('#spotlight > .node > img').each(function(){
$(this).attr('alt','');
});
// Make accordions accessible
$('dt').each(function( index ){
$(this).contents().wrap('');
$(this).attr('role', 'heading');
// $(this).parent().attr('role', 'button');
$(this).attr('aria-level', '2');
$(this).find('button').attr('id', 'dd'+index+'Title');
// $(this).next('dd').attr('aria-labelledby','dd'+index+'Title');
$(this).next('dd').attr('role','region');
$(this).next('dd').attr('id','dd'+index);
$(this).find('button').attr('aria-controls','dd'+index);
});
// ...with up/down arrows
$('button.dl-button').keydown(function(e) {
if (e.keyCode === 40) {
$(this).parent().parent().next('div').find('button').focus();
}
if (e.keyCode === 38) {
$(this).parent().parent().prev('div').find('button').focus();
}
});
// Remove empty paragraph tags
$('p').each(function() {
var $this = $(this);
if($this.html().replace(/\s| /g, '').length === 0) {
$this.remove();
}
});
// Make tabbed content accessible
$('ul.quicktabs-tabs').each(function(){
$(this).attr('role', 'tablist');
});
$('ul.quicktabs-tabs li').each(function( index ){
$(this).attr('id', 'tab'+index);
$(this).attr('aria-controls','panel'+index);
$(this).attr('role', 'tab');
});
$('#quicktabs-container-tabbed_content > div').each(function( index ){
$(this).attr('role', 'tabpanel');
$(this).attr('id', 'panel'+index);
$(this).attr('aria-labeledby', 'tab'+index);
});
$('.front.home #quicktabs-container-tabbed_content .node h2').attr('tab-index', '0');
// Focus on logo when clicking back to top
$('#back-to-top').click(function() {
window.location='#cu-identity';
$(this).blur();
//$('#cu-seal a').focus();
});
// Radio button focus state
$('.radio-button input[type="checkbox"]').each(function(){
$(this).focus(function () {
$(this).parent().css('outline', '#6898e0 solid 2px');
});
$(this).blur(function () {
$(this).parent().css('outline', '0');
});
});
// Don't read mobile tools button on desktop
if (jQuery(window).width() >= 880) {
$('#side-nav .tools-library').attr('tabindex', '-1');
}
else {
$('#side-nav .tools-library').removeAttr('tabindex');
}
/* Hide Quicktabs from screen readers and from tab order
$('#block-quicktabs-tabbed-content *').attr('aria-hidden','true');
$('#block-quicktabs-tabbed-content *').attr('aria-live','off');
$('#block-quicktabs-tabbed-content *').attr('tabindex','-1');
$('#block-quicktabs-bursar *').attr('aria-hidden','true');
$('#block-quicktabs-bursar *').attr('aria-live','off');
$('#block-quicktabs-bursar *').attr('tabindex','-1');
*/
//Assign aria-role to Quicktabs
$('#quicktabs-tab-bursar-0').attr('role','button');
$('#quicktabs-tab-bursar-1').attr('role','button');
$('#quicktabs-tab-bursar-2').attr('role','button');
$('#quicktabs-tab-bursar-0').attr('aria-label','Read about Paying Your Bill');
$('#quicktabs-tab-bursar-1').attr('aria-label','Read about Installment Plans');
$('#quicktabs-tab-bursar-2').attr('aria-label','Read about Direct Deposit');
$('#tab0').removeAttr('aria-controls');
$('#tab1').removeAttr('aria-controls');
$('#tab2').removeAttr('aria-controls');
//Quicktabs - Move keyboard focus on click
$('#quicktabs-tab-bursar-0').on('keypress click', function(e) {
console.log("I WORK.");
if (e.which === 13) {
$('#node-751 h2 a').focus();
}
});
$('#quicktabs-tab-bursar-1').on('keypress click', function(e) {
if (e.which === 13) {
$('#node-2081 h2 a').focus();
}
});
$('#quicktabs-tab-bursar-2').on('keypress click', function(e) {
if (e.which === 13) {
$('#node-1271 h2 a').focus();
}
});
// move all sidebar content below main content on smaller screens
if (jQuery(window).width() <= 768) {
$('#secondary-nav').insertAfter('#main-body');
}
else {
$('#secondary-nav').insertBefore('#main-body');
}
//================================= TABLE OF CONTENTS ==============================================//
//Move TOC to bottom
if (jQuery(window).width() <= 768) {
$('#block-block-716').appendTo('#content-wrap');
}
// Add print buttons
$('').appendTo('.node-type-dfa-policies #main-body > .field-name-field-policy-number:first-child');
$('').prependTo('.node-type-dfa-policies .pdf-section:not(#full-policy)');
// Add checkmark icon
$('').prependTo('.field.field-name-field-entities-affected-text- .field-items .field-item ul li');
$('').prependTo('.field.field-name-field-entities-affected-choice .field-items .field-item ul li');
$('').prependTo('.field-name-field-who-should-read-this-polic .field-items .field-item ul li');
$('').prependTo('.field-name-field-web-address-for-this-polic .field-items .field-item ul li');
$('').prependTo('.field-name-field_most_current_version_of_th .field-items .field-item ul li');
// Add user icon
$('').prependTo('.entity.field-collection-item-field-who-should-read-this-polic .content .field .field-items .field-item');
// Unlink (for now)
$('.entity.field-collection-item-field-who-should-read-this-polic .content .field .field-items .field-item a').contents().unwrap();
// Remove hyperlink from glossify links
$('.glossify-link').on({"click": function(e) { e.preventDefault(); }});
// Remove glossify from some terms with deglossify class
$('.node-type-dfa-policies .deglossify .glossify-link').each(function(){
$(this).parent().find('img').remove();
$(this).contents().unwrap();
});
// Remove glossify from header tags
$('.node-type-dfa-policies h2 .glossify-link').each(function(){
$(this).parent().find('img').remove();
$(this).contents().unwrap();
});
$('.node-type-dfa-policies h3 .glossify-link').each(function(){
$(this).parent().find('img').remove();
$(this).contents().unwrap();
});
$('.node-type-dfa-policies h4 .glossify-link').each(function(){
$(this).parent().find('img').remove();
$(this).contents().unwrap();
});
$('.node-type-dfa-policies h5 .glossify-link').each(function(){
$(this).parent().find('img').remove();
$(this).contents().unwrap();
});
$('.node-type-dfa-policies h6 .glossify-link').each(function(){
$(this).parent().find('img').remove();
$(this).contents().unwrap();
});
$('.node-type-dfa-policies #secondary-nav .glossify-link').each(function(){
$(this).children('img').remove();
$(this).contents().unwrap();
});
$('.node-type-dfa-policies #secondary .glossify-link').each(function(){
$(this).children('img').remove();
$(this).contents().unwrap();
});
//$('body.node-type-policies #definitions h3 a').contents().unwrap();
//$('body.node-type-dfa-policies #definitions h3 a').contents().unwrap();
// for now
//$('.policy-teaser-content-wrapper .field-name-field-policy-number .field-item').each(function(){
//var theTitle = $(this).closest('.policy-teaser-content-wrapper').find('.field-name-title h2 a');
//$(this).prependTo(theTitle);
//});
// Add policy filter buttons
//$('#policy-filters').append('');
$('body.node-type-policies .pdf-section').each(function(){
var filterButton = $(this).attr('id');
$('.node-type-dfa-policies #policy-filters').append('');
});
$('body.node-type-dfa-policies .pdf-section').each(function(){
var filterButton = $(this).attr('id');
$('.node-type-dfa-policies #policy-filters').append('');
});
// Remove hyphens from filter button text
$('.node-type-dfa-policies #policy-filters .filter-button').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
// Show/Hide policy sections
$('.node-type-dfa-policies #policy-filters .filter-button').click(function() {
$(this).siblings().removeClass('section-open');
$(this).addClass('section-open');
$('.field-name-field-recent-changes').addClass('visually-hiding').removeClass('visible');
var filterButtonId = this.value;
//console.log(filterButtonId);
// Remove any existing next/previous buttons
$('button.next-section').remove();
$('.next-section-label').remove();
$('button.previous-section').remove();
$('.previous-section-label').remove();
// Show clicked section, hide the rest
$('#'+filterButtonId).removeClass('visually-hiding').addClass('visible').siblings('.pdf-section').addClass('visually-hiding').removeClass('visible');
//Jump to section on phones
if ( jQuery(window).width() < 479 ) {
window.location = '#'+filterButtonId;
}
// Get the next section id, if there is one
var nextSection = $('#'+filterButtonId).next('.pdf-section').attr('id');
// Get the previous section id, if there is one
var previousSection = $('#'+filterButtonId).prev('.pdf-section').attr('id');
// If there is a next section...
if ( $('#'+filterButtonId).next('.pdf-section').exists() && filterButtonId !== 'full-policy' ) {
// Add the relevant next button
$('').insertAfter('#'+filterButtonId);
}
//else if ( $('#'+filterButtonId).next('.pdf-section').exists() && filterButtonId === 'full-policy' ) {
//Add back the next button to the bottom of the policy in the case of the Full Policy button
//$('').appendTo('.node-type-dfa-policies .policies.content');
//}
else {
// We're either at the end of the policy, or showing the full policy
$('.next-section.undefined').hide();
}
// If there is a previous section...
if ( $('#'+filterButtonId).prev('.pdf-section').exists() ) {
// Add the relevant previous button
$('').insertAfter('#'+filterButtonId);
}
else {
// We're either at the end of the policy, or showing the full policy
$('.previous-section.undefined').hide();
}
// Remove hyphens from next button text
$('.next-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
// Remove hyphens from previous button text
$('.previous-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
});
// Show full policy, all sections
$('.node-type-dfa-policies #policy-filters .filter-button.full-policy').click(function() {
$('.pdf-section').removeClass('visually-hiding').addClass('visible');
$('.field-name-field-recent-changes').removeClass('visually-hiding').addClass('visible');
});
$('a[href="#Full_Policy-anchor"]').click(function() {
$(this).attr('href','#filters-full-policy');
$('#filters-full-policy').siblings().removeClass('section-open');
//$('#filters-full-policy').addClass('section-open');
$('.pdf-section').removeClass('visually-hiding').addClass('visible');
$('.field-name-field-recent-changes').removeClass('visually-hiding').addClass('visible');
//Hide next/prev links
$('.next-section').hide();
$('.next-section-label').hide();
$('.previous-section').hide();
$('.previous-section-label').hide();
});
// Click button to show next section
$('body').on('click', '.next-section', function (e) {
e.preventDefault();
var nextSection = $(this).attr('title');
var filterButtonId = nextSection;
// Hide existing buttons
$('.next-section').hide();
$('.next-section-label').hide();
$('.previous-section').hide();
$('.previous-section-label').hide();
// Jump to top
window.location = '#main-body';
// Show next section, hide the rest
$('#'+nextSection).removeClass('visually-hiding').siblings('.pdf-section').removeClass('visible').addClass('visually-hiding');
// Highlight the new filter button
$('.node-type-dfa-policies #policy-filters #filters-'+nextSection).addClass('section-open');
$('.node-type-dfa-policies #policy-filters #filters-'+nextSection).siblings().removeClass('section-open');
// Get the next section id, if there is one
var nextSection = $('#'+filterButtonId+' ~ .pdf-section').attr('id');
// If there is a next section...
if (nextSection !== undefined) {
// Add the relevant next button
$('').insertAfter('#'+filterButtonId);
// Remove hyphens from next button text
$('.next-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
}
else {
// We're either at the end of the policy, or showing the full policy
$('.next-section').hide();
}
// Get the previous section id, if there is one
var previousSection = $('#'+filterButtonId).prevAll('.pdf-section:first').attr('id');
// If there is a previous section...
if (previousSection !== undefined) {
// Add the relevant previous button
$('').insertAfter('#'+filterButtonId);
// Remove hyphens from previous button text
$('.previous-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
}
else {
// We're at the beginning of the policy
$('.previous-section').hide();
}
});
// Click button to show previous section
$('body').on('click', '.previous-section', function (e) {
e.preventDefault();
var previousSection = $(this).attr('title');
var filterButtonId = previousSection;
// Hide existing
$('.next-section').hide();
$('.next-section-label').hide();
$('.previous-section').hide();
$('.previous-section-label').hide();
// Jump to top
window.location = '#main-body';
if ( filterButtonId !== 'full-policy' ) {
// Show previous section, hide the rest
$('#'+previousSection).removeClass('visually-hiding').siblings('.pdf-section').addClass('visually-hiding');
}
else {
// Show all sections
$('.pdf-section').removeClass('visually-hiding').addClass('visible');
$('.field-name-field-recent-changes').removeClass('visually-hiding').addClass('visible');
}
// Highlight the new filter button
$('.node-type-dfa-policies #policy-filters #filters-'+previousSection).addClass('section-open');
$('.node-type-dfa-policies #policy-filters #filters-'+previousSection).siblings().removeClass('section-open');
// Get the previous section id, if there is one
var previousSection = $('#'+filterButtonId).prevAll('.pdf-section:first').attr('id');
// If there is a previous section...
if (typeof previousSection !== 'undefined' ) {
// Add the relevant previous button
$('').insertAfter('#'+filterButtonId);
//console.log(previousSection);
// Remove hyphens from previous button text
$('.previous-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
}
else if (filterButtonId !== 'full-policy') {
// We're at the beginning of the policy
$('').insertAfter('#'+filterButtonId);
}
// Get the next section id, if there is one
var nextSection = $('#'+filterButtonId+' ~ .pdf-section').attr('id');
// If there is a next section...
if (nextSection !== 'undefined' && (filterButtonId !== 'full-policy')) {
// Add the relevant next button
$('').insertAfter('#'+filterButtonId);
// Remove hyphens from next button text
$('.next-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
}
else {
// We're either at the end of the policy, or showing the full policy
$('.next-section').hide();
}
});
$('body.node-type-dfa-policies').prepend('');
// Remove trailing colon from toc
$('.node-type-dfa-policies ul[data-toc=".policies.content"] li a').each(function(){
var myString = $(this).text();
var newString = myString.substr(0, myString.length-1);
var lastChar = myString[myString.length -1];
if (lastChar === ':') {
$(this).text(newString);
}
});
$('.node-type-dfa-policies ol[data-toc=".policies.content"] li a').each(function(){
var myString = $(this).text();
var newString = myString.substr(0, myString.length-1);
var lastChar = myString[myString.length -1];
if (lastChar === ':') {
$(this).text(newString);
}
});
// Reorder first two TOC items
if( $('#Recent_Changes_to_this_Policy-anchor').exists() ) {
$('.node-type-dfa-policies ul[data-toc=".policies.content"] > li:first-child').insertAfter('.node-type-dfa-policies ul[data-toc=".policies.content"] > li:nth-child(2)');
}
// Add seal for printing
$('#print-full-document').click(function() {
$('.pdf-section').addClass('visible-for-print');
$('.field-name-field-recent-changes').addClass('visible-for-print');
$('#dfa-policy-seal').remove(); // Remove previously shown before adding this one
$('#content-wrap').prepend('');
$('#print-header').insertAfter('#dfa-policy-seal');
});
// Add seal for printing
$('.print-section').click(function() {
//$('.pdf-section').show();
$('#dfa-policy-seal').remove(); // Remove previously shown before adding this one
$(this).parent().prepend('');
$('#print-header').insertAfter('#dfa-policy-seal');
});
// Need to show all sections for the anchor to work
jQuery('.node-type-dfa-policies ul[data-toc=".policies.content"] li a').click(function(e) {
//preventDefault can be removed dont go to href external link
//e.preventDefault();
$('.node-type-dfa-policies ul[data-toc=".policies.content"] li a').each(function() {
$(this).removeClass('active');
});
$(this).addClass('active');
var $target = $(this).attr('href');
var targetArr = $target.split('#');
if (targetArr.length >1){
var target = targetArr[1];
target = document.getElementById( target );
//or search by selector id
//target = $("h3[id='"+target+"']");
$.each($(target), function(){
// console.log(this);
});
// console.log($(target).length);
if ( $(target).length == 1 ){
var target_parent_div = $(target).closest('.pdf-section');
if (target_parent_div.length == 1){
$('.pdf-section').addClass('visually-hiding').removeClass('visible visible-for-toc');
$(target_parent_div).removeClass('visually-hiding').addClass('visible-for-toc');
$('html, body').animate({
scrollTop: $($(target)).offset().top
}, 500);
$('.next-section').addClass('visually-hiding').removeClass('visible');
$('.next-section-label').addClass('visually-hiding').removeClass('visible');
$('.previous-section').addClass('visually-hiding').removeClass('visible');
$('.previous-section-label').addClass('visually-hiding').removeClass('visible');
var filterButtonId = $(target_parent_div).attr('id');
filterButtonId = 'filters-'+filterButtonId;
// console.log(filterButtonId);
$('#'+filterButtonId).siblings().removeClass('section-open');
$('#'+filterButtonId).addClass('section-open');
$('.field-name-field-recent-changes').addClass('visually-hiding').removeClass('visible');
// Remove any existing next/previous buttons
$('button.next-section').remove();
$('.next-section-label').remove();
$('button.previous-section').remove();
$('.previous-section-label').remove();
// Get the next section id, if there is one
var nextSection = $(target_parent_div).next('.pdf-section').attr('id');
// Get the previous section id, if there is one
var previousSection = $(target_parent_div).prev('.pdf-section').attr('id');
// If there is a next section...
if ( $(target_parent_div).next('.pdf-section').exists() && target_parent_div !== '#full-policy' ) {
// Add the relevant next button
$('').insertAfter(target_parent_div);
}
else {
// We're either at the end of the policy, or showing the full policy
$('.next-section.undefined').hide();
}
// If there is a previous section...
if ( $(target_parent_div).prev('.pdf-section').exists() ) {
// Add the relevant previous button
$('').insertAfter(target_parent_div);
}
else {
// We're either at the end of the policy, or showing the full policy
$('.previous-section.undefined').hide();
}
// Remove hyphens from next button text
$('.next-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
// Remove hyphens from previous button text
$('.previous-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
}else{
// console.warn("Warning: cannot locate parent pdf-section element");
}
}else{
// console.warn("Warning: target not found");
}
}else{
// console.warn("Warning: no # in href");
}
//return false;
});
jQuery('.policies.content .pdf-section a').click(function(e) {
if (this.getAttribute('href').charAt(0) === "#") {
var $target = $(this).attr('href');
var targetArr = $target.split('#');
if (targetArr.length >1){
var target = targetArr[1];
target = document.getElementById( target );
//or search by selector id
//target = $("h3[id='"+target+"']");
$.each($(target), function(){
// console.log(this);
});
//console.log($(target).length);
if ( $(target).length == 1 ){
var target_parent_div = $(target).closest('.pdf-section');
if (target_parent_div.length == 1){
$('.pdf-section').addClass('visually-hiding').removeClass('visible visible-for-toc');
$(target_parent_div).removeClass('visually-hiding').addClass('visible-for-toc');
$('html, body').animate({
scrollTop: $($(target)).offset().top
}, 500);
$('.next-section').addClass('visually-hiding').removeClass('visible');
$('.next-section-label').addClass('visually-hiding').removeClass('visible');
$('.previous-section').addClass('visually-hiding').removeClass('visible');
$('.previous-section-label').addClass('visually-hiding').removeClass('visible');
var parentId = $(target_parent_div).attr('id');
filterButtonId = document.getElementById( 'filters-'+parentId );
// console.log(filterButtonId);
$(filterButtonId).addClass('section-open');
$(filterButtonId).siblings().removeClass('section-open');
$('.field-name-field-recent-changes').addClass('visually-hiding').removeClass('visible');
// Remove any existing next/previous buttons
$('button.next-section').remove();
$('.next-section-label').remove();
$('button.previous-section').remove();
$('.previous-section-label').remove();
// Get the next section id, if there is one
var nextSection = $(target_parent_div).next('.pdf-section').attr('id');
// Get the previous section id, if there is one
var previousSection = $(target_parent_div).prev('.pdf-section').attr('id');
// If there is a next section...
if ( $(target_parent_div).next('.pdf-section').exists() && target_parent_div !== '#full-policy' ) {
// Add the relevant next button
$('').insertAfter(target_parent_div);
}
else {
// We're either at the end of the policy, or showing the full policy
$('.next-section.undefined').hide();
}
// If there is a previous section...
if ( $(target_parent_div).prev('.pdf-section').exists() ) {
// Add the relevant previous button
$('').insertAfter(target_parent_div);
}
else {
// We're either at the end of the policy, or showing the full policy
$('.previous-section.undefined').hide();
}
// Remove hyphens from next button text
$('.next-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
// Remove hyphens from previous button text
$('.previous-section-label').each(function(){
var buttonText = $(this).html().replace('-',' ');
$(this).html(buttonText);
});
}else{
// console.warn("Warning: cannot locate parent pdf-section element");
}
}else{
// console.warn("Warning: target not found");
}
}else{
// console.warn("Warning: no # in href");
}
//return false;
}
});
// Hide toc when clicked on smaller screens
if (jQuery(window).width() <= 1215) {
$('.node-type-dfa-policies ul[data-toc=".policies.content"] li a').click(function() {
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').hide('fast');
});
}
// Need to show all sections for the anchor to work (this is in case we want to number it -- ol instead of ul)
$('.node-type-dfa-policies ol[data-toc=".policies.content"] li a').click(function() {
$('.node-type-dfa-policies ol[data-toc=".policies.content"] li a').each(function(){
$(this).removeClass('active');
});
$(this).addClass('active');
$('.next-section').addClass('visually-hiding').removeClass('visible');
$('.next-section-label').addClass('visually-hiding').removeClass('visible');
$('.previous-section').addClass('visually-hiding').removeClass('visible');
$('.previous-section-label').addClass('visually-hiding').removeClass('visible');
$('#block-views-b80aedba5cfce5d3f4e89a6ec12026b8').hide('fast');
});
// Add alt = null to definition icons
$('.glossify-link img').each(function(){
$(this).attr('alt','');
});
});
}