//Expires: Sat, 21 Oct 2017 01:31:16 // General JS jQuery(document).ready(function($) { // Suggest a topic form focus $('textarea#suggestATopic').focus(function() { $(this).val(''); }); // remove the final menu divider css border property $('#wrapper .menu ul:first li:last').css('border-right', 'none'); // replace
tags with nicer CSS versions $('#wrapper hr').after('
').remove(); // init the news ticker $('#wrapper .tickerBar .ticker').scrollable({ interval: 4000, vertical:true, size:1, loop: true, speed: 700, onBeforeSeek: function() { this.getItems().fadeTo(300, 0.2); }, onSeek: function() { this.getItems().fadeTo(300, 1); } }); // home page tabs $('ul.tabs').tabs('div.panes > div'); // remove the background from the last table cell on homepage tabs $('#wrapper .contentContainer.homepage .tabContainer div.panes div table tr td:last-child').css('background', 'none'); // remove the background from the last table cell on homepage panel $('#wrapper .contentContainer.homepage .panelContainer table tr').each(function() { $(this).children('td:last').css('background', 'none'); }); // remove the background from the last videoResult div $('#wrapper .contentContainer .content .mostPopular .videoResult:last').css('background', 'none'); $('#wrapper .contentContainer .content .col.one .videoResult:last').css('background', 'none'); $('#wrapper .contentContainer .content .col.two .videoResult:last').css('background', 'none'); // remove the border from the last report page ul li ul li $('#wrapper .contentContainer.reportPage .col.one ul li ul li:last-child').css('border', 'none'); // init Pretty Photo //if($.fn.prettyPhoto) { // $('#wrapper .contentContainer .content a[rel="prettyPhoto"]').prettyPhoto(); //} // when the site search is clicked, we want to remove the current text: $('input#siteSearchTextField').focus(function() { $(this).val(''); }); $('input#siteSearchTextField').blur(function() { if($(this).val() === '') { $(this).val('Search'); } }); // hide all Report Page accordion sub-UL's (list of files) $('.reportPage .col.one ul li ul').hide(); $('.dropInForDialogue .col.one ul li ul').hide(); // Report Page accordions $(".reportPage .col.one ul li:not('li ul li')").click(enableAccordion); $(".dropInForDialogue .col.one ul[class!=presentations] li:not('li ul li')").click(enableAccordion); // define template for doc rating var docRatingTemplate = '
Was this document useful?YesNo
'; // Add in report rating links $('.reportPage .col.one ul li ul li a').after(docRatingTemplate); $('.documentRating .yes').click(documentRatingClickEvent); $('.documentRating .no').click(documentRatingClickEvent); // add newsletter download registration links $('.newsletterRegistration .col.one .right .latestNewsletter').parent().after(docRatingTemplate); $('.newsletterRegistration .documentRating .yes').click(newsletterRatingClickEvent); $('.newsletterRegistration .documentRating .no').click(newsletterRatingClickEvent); // check to see if the first left menu item is empty and populate if so if($('.leftMenu ul li:first a').html() == '') { $('.leftMenu ul li:first a').html($('#wrapper .contentContainer .content h1:first').html()); } // newsletter registration list style tweaks $('.newsletterRegistration .col.one ul li').each(function() { $(this).html('' + $(this).text() + ''); }); // TwoRowThreeColumn Col3 add dividers in //$('.twoRowsThreeColumns .row2 .col.three ul li').append('
'); // ViewProjectPage Row3 Col2 add dividers in // /$('.twoRowsThreeColumns.viewProjectPage .row3 .col.two ul li').append('
'); $('.twoRowsThreeColumns.strategicResearchPage .row1 .col.one ul li').append('
'); }); if(isDefined('Shadowbox')) { Shadowbox.init(); } function isDefined(variable) { return (typeof(window[variable]) == "undefined")? false: true; } var ratingUrl = '/cms/documents/rate/{filename}/{rating}'; var documentRatingDomContainer; function documentRatingClickEvent() { // get the document name from the href tag of parent element var doc = $(this).parent().parent().parent().children('a').attr('href'); // make the url ajax friendly var docFriendlyUrl = doc.replace(/\//g, '|'); // add file name & rating into the ajax url var ajaxUrl = ratingUrl.replace(/\{filename\}/, docFriendlyUrl); ajaxUrl = ajaxUrl.replace(/\{rating\}/, jQuery(this).attr('class')); // hide contents of the document voting div, show ajax indicator documentRatingDomContainer = jQuery(this).parent().parent(); jQuery(documentRatingDomContainer).children('span').fadeOut('fast'); jQuery(documentRatingDomContainer).css('background', 'url(../../img/ajax/1.gif) no-repeat center center'); // call the ajax jQuery.get(ajaxUrl, documentVotingAjaxResponseHandler); return false; } function newsletterRatingClickEvent() { // get the document name from the href tag of parent element var doc = jQuery('a#LatestNewsletterLink').attr('href'); // make the url ajax friendly var docFriendlyUrl = doc.replace(/\//g, '|'); // add file name & rating into the ajax url var ajaxUrl = ratingUrl.replace(/\{filename\}/, docFriendlyUrl); ajaxUrl = ajaxUrl.replace(/\{rating\}/, jQuery(this).attr('class')); // hide contents of the document voting div, show ajax indicator documentRatingDomContainer = jQuery(this).parent().parent(); jQuery(documentRatingDomContainer).children('span').fadeOut('fast'); jQuery(documentRatingDomContainer).css('background', 'url(../../img/ajax/1.gif) no-repeat center center'); // call the ajax jQuery.get(ajaxUrl, documentVotingAjaxResponseHandler); return false; } function documentVotingAjaxResponseHandler(reply) { // ajax response from documents controller in Silverstripe jQuery(documentRatingDomContainer).children('span').fadeIn('fast'); jQuery(documentRatingDomContainer).css('background', 'transparent'); if(reply === 'true') { alert('Thank you for your vote'); } else { alert(reply); } } function enableAccordion() { // hide other open accordion panels jQuery(this).siblings('li').removeClass('open').children('ul').slideUp(); // show our clicked accordion panel jQuery(this).addClass('open').children('ul').slideDown(); } // This javascript tags file downloads and external links in Google Analytics. // You need to be using the Google Analytics New Tracking Code (ga.js) // for this script to work. // To use, place this file on all pages just above the Google Analytics tracking code. // All outbound links and links to non-html files should now be automatically tracked. // // This script has been provided by Goodwebpractices.com // Thanks to ShoreTel, MerryMan and Colm McBarron // // www.goodwebpractices.com // VKI has made changes as indicated below. if (document.getElementsByTagName) { // Initialize external link handlers var hrefs = document.getElementsByTagName("a"); for (var l = 0; l < hrefs.length; l++) { // try {} catch{} block added by erikvold VKI try{ //protocol, host, hostname, port, pathname, search, hash if (hrefs[l].protocol == "mailto:") { startListening(hrefs[l],"click",trackMailto); } else if (hrefs[l].hostname == location.host) { var path = hrefs[l].pathname + hrefs[l].search; var isDoc = path.match(/\.(?:doc|eps|jpg|png|svg|xls|ppt|pdf|xls|zip|txt|vsd|vxd|js|css|rar|exe|wma|mov|avi|wmv|mp3)($|\&|\?)/); if (isDoc) { startListening(hrefs[l],"click",trackExternalLinks); } } else { startListening(hrefs[l],"click",trackExternalLinks); } } catch(e){ continue; } } } function startListening (obj,evnt,func) { if (obj.addEventListener) { obj.addEventListener(evnt,func,false); } else if (obj.attachEvent) { obj.attachEvent("on" + evnt,func); } } function trackMailto (evnt) { var href = (evnt.srcElement) ? evnt.srcElement.href : this.href; var mailto = "/mailto/" + href.substring(7); if (typeof(pageTracker) == "object") pageTracker._trackPageview(mailto); } function trackExternalLinks (evnt) { var e = (evnt.srcElement) ? evnt.srcElement : this; while (e.tagName != "A") { e = e.parentNode; } var lnk = (e.pathname.charAt(0) == "/") ? e.pathname : "/" + e.pathname; if (e.search && e.pathname.indexOf(e.search) == -1) lnk += e.search; if (e.hostname != location.host) lnk = "/external/" + e.hostname + lnk; if (typeof(pageTracker) == "object") pageTracker._trackPageview(lnk); }; (function () { "use strict"; /** * Store current instance */ var instance; /** * Defaults values * @type object */ var defaults = { 'messageLocales': { 'en': 'The Sciencewise programme is funded by the Department for Business, Innovation & Skills. The latest contract for management of the Sciencewise programme ended on 31st March 2016. From 1st April enquires about the Sciencewise programme should be sent to sciencewise@bis.gsi.gov.uk' }, 'buttonLocales': { 'en': 'Ok' }, 'expiresIn': 0, 'buttonBgColor': '#492F91', 'buttonTextColor': '#fff', 'noticeBgColor': '#000', 'noticeTextColor': '#fff' }; /** * Initialize cookie notice on DOMContentLoaded * if not already initialized with alt params */ if (document.addEventListener) { // For all major browsers, except IE 8 and earlier document.addEventListener('DOMContentLoaded', function () { if (!instance) { new cookieNoticeJS(); } }); } else if (document.attachEvent) { // For IE 8 and earlier versions document.attachEvent('onDOMContentLoaded', function () { if (!instance) { new cookieNoticeJS(); } }); } /** * Constructor * @constructor */ window.cookieNoticeJS = function () { // If an instance is already set stop here if (instance !== undefined) { return; } // Set current instance instance = this; // If cookies are not supported or notice cookie is already set if (!testCookie() || getNoticeCookie()) { return; } // Extend default params var params = extendDefaults(defaults, arguments[0] || {}); // Get current locale for notice text var noticeText = getStringForCurrentLocale(params.messageLocales); // Create notice var notice = createNotice(noticeText, params.noticeBgColor, params.noticeTextColor); // Get current locale for button text var buttonText = getStringForCurrentLocale(params.buttonLocales); // Create dismiss button var dismissButton = createDismissButton(buttonText, params.buttonBgColor, params.buttonTextColor); // Dismiss button click event dismissButton.addEventListener('click', function (e) { e.preventDefault(); setDismissNoticeCookie(parseInt(params.expiresIn + "", 10) * 60 * 1000 * 60 * 24); fadeElementOut(notice); }); // Append notice to the DOM document.body.appendChild(notice).appendChild(dismissButton); }; /** * Get the string for the current locale * and fallback to "en" if none provided * @param locales * @returns {*} */ function getStringForCurrentLocale(locales) { var locale = (navigator.userLanguage || navigator.language).substr(0, 2); return (locales[locale]) ? locales[locale] : locales['en']; } /** * Test if cookies are enabled * @returns {boolean} */ function testCookie() { document.cookie = 'testCookie=1'; return document.cookie.indexOf('testCookie') != -1; } /** * Test if notice cookie is there * @returns {boolean} */ function getNoticeCookie() { return document.cookie.indexOf('cookie_site_notice') != -1; } /** * Create notice * @param message * @param bgColor * @param textColor * @returns {HTMLElement} */ function createNotice(message, bgColor, textColor) { var notice = document.createElement('div'), noticeStyle = notice.style; notice.innerHTML = message; notice.setAttribute('id', 'cookieNotice'); noticeStyle.position = 'fixed'; noticeStyle.bottom = 0; noticeStyle.left = 0; noticeStyle.right = 0; noticeStyle.background = bgColor; noticeStyle.color = textColor; noticeStyle["z-index"] = '99999'; noticeStyle["opacity"] = '0.9'; noticeStyle.padding = '10px'; noticeStyle["text-align"] = 'center'; noticeStyle["font-size"] = "13px"; noticeStyle["line-height"] = "24px"; noticeStyle.fontFamily = 'Segoe UI, Helvetica neue, Helvetica, Arial, sans-serif'; return notice; } /** * Create dismiss button * @param message * @param buttonColor * @param buttonTextColor * @returns {HTMLElement} */ function createDismissButton(message, buttonColor, buttonTextColor) { var dismissButton = document.createElement('a'), dismissButtonStyle = dismissButton.style; // Dismiss button dismissButton.href = '#'; dismissButton.innerHTML = message; // Dismiss button style dismissButtonStyle.background = buttonColor; dismissButtonStyle.color = buttonTextColor; dismissButtonStyle['text-decoration'] = 'none'; dismissButtonStyle.display = 'inline-block'; dismissButtonStyle.padding = '0 15px'; dismissButtonStyle.margin = '0 0 0 10px'; return dismissButton; } /** * Set sismiss notice cookie * @param expireIn */ function setDismissNoticeCookie(expireIn) { var now = new Date(), cookieExpire = new Date(); cookieExpire.setTime(now.getTime() + expireIn); //document.cookie = "cookie_site_notice=1; expires=" + cookieExpire.toUTCString() + "; path=/;"; document.cookie = "cookie_site_notice=1; path=/;"; } /** * Fade a given element out * @param element */ function fadeElementOut(element) { element.style.opacity = 1; (function fade() { (element.style.opacity -= .1) < 0.01 ? document.body.removeChild(element) : setTimeout(fade, 40) })(); } /** * Utility method to extend defaults with user options * @param source * @param properties * @returns {*} */ function extendDefaults(source, properties) { var property; for (property in properties) { if (properties.hasOwnProperty(property)) { if (typeof source[property] === 'object') { source[property] = extendDefaults(source[property], properties[property]); } else { source[property] = properties[property]; } } } return source; } /* test-code */ cookieNoticeJS.extendDefaults = extendDefaults; cookieNoticeJS.clearInstance = function () { instance = undefined; }; /* end-test-code */ }());