/* ========================================================== * autocomplete.js * Deal with the Typeahead.js/Bloodhound library to build the search field autocomplete * * Author: Yann, yann@antistatique.net * Date: 2014-05-01 14:23:18 * * Copyright 2014 Federal Chancellery of Switzerland * Licensed under MIT ========================================================== */ (function($, data) { 'use strict'; var $searchFields = $('.form-search .search-field'); if (data) { // Init the Bloodhound suggestion engine var bloodhound = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), queryTokenizer: Bloodhound.tokenizers.whitespace, local: $.map(data, function(state) { return { value: state }; }) }); bloodhound.initialize(); // Init Typeahead on search-fields $searchFields.typeahead({ hint: false, highlight: true, minLength: 1 }, { name: 'search', displayKey: 'value', source: bloodhound.ttAdapter() }); } }) (jQuery, (typeof searchData === 'undefined' ? false : searchData)); /* ========================================================== * carousel.js * Carousel helper * * Author: Yann, yann@antistatique.net * Date: 2014-05-15 13:55:53 * * Copyright 2014 Federal Chancellery of Switzerland * Licensed under MIT ========================================================== */ (function($) { 'use strict'; $(window).load(function () { carouselInit(jQuery); }); $(window).resize(function () { carouselInit(jQuery); }); // slideshow counter var slideshow_total = $('.carousel-slideshow .item').length; $('#carousel-total').text(slideshow_total); $('.carousel-slideshow').on('slid.bs.carousel', function () { var carouselData = $(this).data('bs.carousel'); var currentIndex = carouselData.getItemIndex(carouselData.$element.find('.item.active')); var total = carouselData.$items.length; var text = (currentIndex + 1); $('#carousel-index').text(text); $('#carousel-total').text(total); }); }) (jQuery); function carouselInit($) { 'use strict'; var $carousel = $('.carousel:not(.carousel-slideshow)'); $('.carousel .item:first-child').addClass('first'); $('.carousel .item:last-child').addClass('last'); $('.carousel').each(function() { disableControl($(this)); }); $('.carousel').on('slid.bs.carousel', function () { disableControl($(this)); }); if($carousel) { $carousel.each(function () { var biggestHeight = 0, titleHeight = $(this).find('.item.active h3:first-child').height(), imgHeight = $(this).find('.item.active .carousel-img').height(); $(this).find('.carousel-indicators, .carousel-control').css('top', titleHeight + imgHeight + 50); $(this).find('.item').each(function () { if ($(this).height() >= biggestHeight) { biggestHeight = $(this).height(); } }); $(this).find('.item').height(biggestHeight); }); } } function disableControl(element) { 'use strict'; if (element.find('.first').hasClass('active')) { element.find('.left').addClass('disabled').attr('aria-disabled', 'true'); } else { element.find('.left').removeClass('disabled').attr('aria-disabled', 'false'); } if (element.find('.last').hasClass('active')) { element.find('.right').addClass('disabled').attr('aria-disabled', 'true'); } else { element.find('.right').removeClass('disabled').attr('aria-disabled', 'false'); } } /* ========================================================== * collapse.js * Add class when nav collapse is open * * Author: Yann, yann@antistatique.net * Date: 2014-05-06 * * Copyright 2014 Federal Chancellery of Switzerland * Licensed under MIT ========================================================== */ (function($) { 'use strict'; // Normal Collapse $('.collapse:not(tbody)').on('show.bs.collapse', function () { $(this) .prev() .addClass('active icon--root') .removeClass('icon--greater') .attr({ 'aria-selected': 'true', 'aria-expanded': 'true' }); }); $('.collapse:not(tbody)').on('hide.bs.collapse', function () { $(this) .prev() .removeClass('active icon--root') .addClass('icon--greater') .attr( { 'aria-selected': 'false', 'aria-expanded': 'false' }); }); // Table Collapse $('tbody.collapse').on('show.bs.collapse', function () { $(this) .prev().find('[data-toggle=collapse]') .addClass('active') .attr({ 'aria-selected': 'true', 'aria-expanded': 'true' }); }); $('tbody.collapse').on('hide.bs.collapse', function () { $(this) .prev().find('[data-toggle=collapse]') .removeClass('active') .attr({ 'aria-selected': 'false', 'aria-expanded': 'false' }); }); // Ensure every first collapse toggle for accordions is accessible // (cf. https://github.com/paypal/bootstrap-accessibility-plugin/issues/98): $('[aria-multiselectable="true"]').each(function() { $(this).find('[data-toggle="collapse"][data-parent]').first().attr({tabindex: 0}); }); }) (jQuery); /* ========================================================== * drilldown.js * Drilldown plugin scripts. For page-list-nav element * * Author: Toni Fisler, toni@antistatique.net * Date: 2014-05-30 09:02:09 * * Copyright 2014 Federal Chancellery of Switzerland * Licensed under MIT ========================================================== */ (function($) { 'use strict'; var options = { event: 'click', // * View note below selector: 'a', // * View note below speed: 100, cssClass: { container: 'drilldown-container', root: 'nav-page-list', sub: 'drilldown-sub', back: 'drilldown-back' } }; $('.drilldown').drilldown(options); }) (jQuery); /* ========================================================== * global-nav.js * Global Navigation syripts * * Author: Toni Fisler, toni@antistatique.net * Date: 2014-05-27 16:36:15 * * Copyright 2014 Federal Chancellery of Switzerland * Licensed under MIT ========================================================== */ (function($) { 'use strict'; // Handle scroll to position nav as fixed var top = 36; $(window).scroll(function () { var y = $(this).scrollTop(); if (y >= top) { if (!$('.nav-mobile').hasClass('fixed')) { $('.nav-mobile').addClass('fixed') .after('
'); } } else { if ($('.nav-mobile').hasClass('fixed')) { $('.nav-mobile').removeClass('fixed'); $('#spacer').remove(); } } }); }) (jQuery); // OUTLINE.JS // https://github.com/lindsayevans/outline.js // // Based on http://www.paciellogroup.com/blog/2012/04/how-to-remove-css-outlines-in-an-accessible-manner/ // // Hide outline on mouse interactions // Show it on keyboard interactions (function(doc){ 'use strict'; var styleElement = doc.createElement('STYLE'), domEvents = 'addEventListener' in doc, addListener = function(type, callback){ // Basic cross-browser event handling if (domEvents) { doc.addEventListener(type, callback); } else { doc.attachEvent('on' + type, callback); } }, setCSS = function(cssText){ !!styleElement.styleSheet ? styleElement.styleSheet.cssText = cssText : styleElement.innerHTML = cssText; }; doc.getElementsByTagName('HEAD')[0].appendChild(styleElement); // Using mousedown instead of mouseover, so that previously focused elements don't lose focus ring on mouse move addListener('mousedown', function(){ setCSS(':focus{outline:0!important}::-moz-focus-inner{border:0!important}'); }); addListener('keydown', function(){ setCSS(''); }); })(document); /* ========================================================== * print.js * Add print preview windows * * Author: Yann, yann@antistatique.net * Date: 2015-02-02 * * Copyright 2014 Federal Chancellery of Switzerland * Licensed under MIT ========================================================== */ (function($) { 'use strict'; // Initialization $.fn.printPreview = function() { return this; }; $.printPreview = { printPreview: function(element) { var $body = $('body'), $container = $('.container-main'), footnoteLinks = "", linksIndex = 0; $body.find('.nav-mobile, .drilldown, .nav-main, .header-separator, .nav-service, .nav-lang, .form-search, .yamm--select, footer, .alert, .icon--print, .social-sharing, form, .nav-process, .carousel-indicators, .carousel-control, .breadcrumb, .pagination-container').remove(); // if an element is passed, we want it to be the only thing to print out if (element) { element = $('[data-print=' + element + ']').clone(); // clone to fix issue with IE render var header = $('header').clone(), // clone to fix issue with IE render title = element.attr('data-title') ? '