// jQuery File for Parenting Together // Version 1.0 /*! https://mths.be/startswith v0.2.0 by @mathias */ if (!String.prototype.startsWith) { (function () { 'use strict'; // needed to support `apply`/`call` with `undefined`/`null` var defineProperty = (function () { // IE 8 only supports `Object.defineProperty` on DOM elements try { var object = {}; var $defineProperty = Object.defineProperty; var result = $defineProperty(object, object, object) && $defineProperty; } catch (error) {} return result; }()); var toString = {}.toString; var startsWith = function (search) { if (this == null) { throw TypeError(); } var string = String(this); if (search && toString.call(search) == '[object RegExp]') { throw TypeError(); } var stringLength = string.length; var searchString = String(search); var searchLength = searchString.length; var position = arguments.length > 1 ? arguments[1] : undefined; // `ToInteger` var pos = position ? Number(position) : 0; if (pos != pos) { // better `isNaN` pos = 0; } var start = Math.min(Math.max(pos, 0), stringLength); // Avoid the `indexOf` call if no match is possible if (searchLength + start > stringLength) { return false; } var index = -1; while (++index < searchLength) { if (string.charCodeAt(start + index) != searchString.charCodeAt(index)) { return false; } } return true; }; if (defineProperty) { defineProperty(String.prototype, 'startsWith', { 'value': startsWith, 'configurable': true, 'writable': true }); } else { String.prototype.startsWith = startsWith; } }()); } /*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, curly:true, browser:true, indent:2, maxerr:50 */ (function (document) { "use strict"; if (document.getElementsByClassName) { document.getElementsByClassName = function (match) { var result = [], elements = document.getElementsByTagName('*'), i, elem; match = " " + match + " "; for (i = 0; i < elements.length; i++) { elem = elements[i]; if ((" " + (elem.className || elem.getAttribute("class")) + " ").indexOf(match) > -1) { result.push(elem); } } return result; }; } }(document)); function showonlyone(thechosenone) { jQuery('.item').each(function (index) { if (jQuery(this).attr("id") == thechosenone) { jQuery(this).slideToggle("slow"); } else { jQuery(this).hide("show"); } }); } jQuery(document).ready(function () { //Mobile Menu jQuery(".menuToggle").click(function () { jQuery(".menuToggle").parent(".main-navigation").toggleClass("toggled"); }); //Sharebar - Footer jQuery(".main-sharebar .block-share h4").click(function () { if (jQuery(".main-sharebar .block-share ul.block-share-list").hasClass("reveal-social-icons")) { jQuery(".main-sharebar .block-share ul.block-share-list").css("margin-left", "-600px"); jQuery(".main-sharebar .block-share ul.block-share-list").css("opacity", "0"); jQuery(".main-sharebar .block-share ul.block-share-list").removeClass("reveal-social-icons"); } else { jQuery(".main-sharebar .block-share ul.block-share-list").css("margin-left", "0"); jQuery(".main-sharebar .block-share ul.block-share-list").css("opacity", "1"); jQuery(".main-sharebar .block-share ul.block-share-list").addClass("reveal-social-icons"); } }); jQuery(".main-sharebar .block-share p").click(function () { if (jQuery(".main-sharebar .block-share ul.block-share-list").hasClass("reveal-social-icons")) { jQuery(".main-sharebar .block-share ul.block-share-list").css("margin-left", "-600px"); jQuery(".main-sharebar .block-share ul.block-share-list").css("opacity", "0"); jQuery(".main-sharebar .block-share ul.block-share-list").removeClass("reveal-social-icons"); } else { jQuery(".main-sharebar .block-share ul.block-share-list").css("margin-left", "0"); jQuery(".main-sharebar .block-share ul.block-share-list").css("opacity", "1"); jQuery(".main-sharebar .block-share ul.block-share-list").addClass("reveal-social-icons"); } }); //Get Wordpress PageID function get_current_page_id() { var page_body = jQuery('body.page'); var id = 0; if (page_body) { var classList = page_body.attr('class').split(/\s+/); jQuery.each(classList, function (index, item) { if (item.indexOf('page-id') >= 0) { var item_arr = item.split('-'); id = item_arr[item_arr.length - 1]; return false; } }); } return id; } //////////////////////// jQuery Cookies //////////////////////// // Create cookie if it doesn't exist if (typeof jQuery.cookie('pages-read') == 'undefined') { jQuery.cookie('pages-read', JSON.stringify([]), { path: '/' }); } var pages_read = JSON.parse(jQuery.cookie('pages-read')); var current_page_id = get_current_page_id(); // if page is not in cookie, add it /*if (pages_read.indexOf(current_page_id) === -1) { pages_read.push(current_page_id); jQuery.cookie('pages-read', JSON.stringify(pages_read), { path: '/' }); }*/ jQuery(".page-checkbox input[type=checkbox]").on('click', function () { if (jQuery(this).is(':checked')) { if (pages_read.indexOf(current_page_id) === -1) { pages_read.push(current_page_id); jQuery.cookie('pages-read', JSON.stringify(pages_read), { path: '/' }); jQuery('.page-' + current_page_id).attr('checked', 'on'); progressAutoUpdate(); } } }); // set checkboxes for (var i = 0; i < pages_read.length; i++) { jQuery('.page-' + pages_read[i]).attr('checked', 'on'); jQuery('.single-page-' + pages_read[i]).attr('checked', 'on').prop('disabled', true); } function progressAutoUpdate() { var total_checked = 0; var total_count = 0; jQuery('li.top-level').each(function () { var checked = 0; var count = 0; jQuery(this).find('li.second-level .checkbox-element input').each(function () { if (jQuery(this).is(':checked')) { checked++; total_checked++; } count++; total_count++; }); if (count > 0) { jQuery(this).find('.top-element input').prop('checked', (count == checked)); } else { total_count++; if (jQuery(this).find('.top-element input').is(':checked')) { total_checked++; } } }); if (total_checked == total_count) { jQuery('.progress-reveal').show(); //jQuery('.completed-section').show(); } var progress = (total_checked * 100 / total_count).toFixed(0); jQuery('.progress-bar').attr('aria-valuenow', progress).css('width', progress + '%'); //Append the progress percentage to the element below jQuery(".progress-wrapper .overall .right").html(progress + '%'); } progressAutoUpdate(); //Testimonals Carousel jQuery('.testimonials').slick({ adaptiveHeight: true, infinite: true, autoplay: false, autoplaySpeed: 5000, slidesToShow: 1, slidesToScroll: 1, arrows: false, dots: true }); //Equal Height Column - Useful Links if (jQuery(window).width() > 600) { jQuery(".all-useful-links .column-2 .section-links").height(jQuery(".all-useful-links .column-1").height() - 24); } // Select all links with hashes jQuery('a[href*="#"]') // Remove links that don't actually link to anything .not('[href="#"]') .not('[href="#0"]') .click(function (event) { // On-page links if ( location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname ) { // Figure out element to scroll to var target = jQuery(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); // Does a scroll target exist? if (target.length) { // Only prevent default if animation is actually gonna happen event.preventDefault(); jQuery('html, body').animate({ scrollTop: target.offset().top }, 1000, function () { // Callback after animation // Must change focus! var $target = jQuery(target); $target.focus(); if ($target.is(":focus")) { // Checking if the target was focused return false; } else { $target.attr('tabindex', '-1'); // Adding tabindex for elements not focusable $target.focus(); // Set focus again }; }); } } }); //Side navigation Accordion jQuery(".side-navigation ul li.top-level .checkbox-element label").click(function (e) { jQuery(this).parent().parent().parent().find("ul.second-level").slideToggle("slow", function () { //Nothing here }); }); jQuery(".side-navigation ul .top-element > a.current-post").parent().parent().find("ul.second-level").show(); jQuery(".side-navigation ul.second-level li > a.current-post").parent().parent().parent().find("ul.second-level").show(); //Useful Links sidebar jQuery(".useful-links .item-links ul li a").attr('rel', 'noopener noreferrer'); //Related Links - Detecting if they are external or internal links jQuery(".useful-links .item-links a").each(function () { if (jQuery(this).attr('href').startsWith('/')) { jQuery(this).addClass("internal-link").removeClass("external-link").attr('target', '_self'); } else { jQuery(this).addClass("external-link").removeClass("internal-link").attr('target', '_blank'); } }); //Spinning Wheel var spinTrigger = jQuery(".spinner-button"); var theWheel = { element: jQuery(".spinning-wheel"), currSpin: 1, maxSpin: 5, currDeg: 0, degCalc: 0 }; spinTrigger.click(function () { jQuery(".item").hide(); theWheel.degCalc = (360 / theWheel.maxSpin) + ((360 / theWheel.maxSpin) * (theWheel.maxSpin - 2)); //theWheel.degCalc = (360 / theWheel.maxSpin) + 360; theWheel.currDeg = theWheel.degCalc * theWheel.currSpin; theWheel.element.attr('style', 'transform: rotate(' + theWheel.currDeg + 'deg); -webkit-transform: rotate(' + theWheel.currDeg + 'deg); -moz-transform: rotate(' + theWheel.currDeg + 'deg);'); theWheel.currSpin = theWheel.currSpin + 1; jQuery(".item.spin-" + theWheel.currSpin).show(); if (theWheel.currSpin >= theWheel.maxSpin) { theWheel.currSpin = 0; } }); //Progress Page jQuery(".progress-items input[type=checkbox]:checked").parent().parent().addClass("highlighted"); //Side Navigation var sidebarUL = ".side-navigation ul.list-pages"; jQuery(".side-navigation .mobile-view").click(function () { jQuery(this).toggleClass("toggled"); jQuery(sidebarUL).slideToggle("slow"); jQuery(sidebarUL).toggleClass("opened"); }); //Read More content jQuery(".btn-read-more").click(function () { jQuery(".more-content").toggleClass("revealed"); jQuery(".more-content").slideToggle("slow"); if (jQuery(".more-content").hasClass("revealed")) { jQuery(".btn-read-more").text("Read less"); } else { jQuery(".btn-read-more").text("Read more"); } }); //******************************************Separation Journey*******************************************************************************// if (typeof jQuery.cookie('journey-clicked') == 'undefined') { jQuery.cookie('journey-clicked', JSON.stringify([]), { path: '/' }); } var journey_clicked = JSON.parse(jQuery.cookie('journey-clicked')); // if page is not in cookie, add it jQuery('.separation-journey .separation-item, .separation-journey .bullet-text').click(function () { var element_id = jQuery(this).find('input').attr('id'); if (!jQuery(this).find('input').is(":checked")) { if (journey_clicked.indexOf(element_id) !== -1) { journey_clicked.splice(journey_clicked.indexOf(element_id), 1);; jQuery.cookie('journey-clicked', JSON.stringify(journey_clicked), { path: '/' }); } } else { if (journey_clicked.indexOf(element_id) === -1) { journey_clicked.push(element_id); jQuery.cookie('journey-clicked', JSON.stringify(journey_clicked), { path: '/' }); } } //call the function updateTotalJourney(); }); // set checkboxes for (var i = 0; i < journey_clicked.length; i++) { jQuery('#' + journey_clicked[i]).attr('checked', 'on'); } jQuery(".journey-counter .rounded-button").hide(); jQuery(".separation-journey .hidden-information").hide(); function updateTotalJourney() { var total_checked = 0; var total_count = 0; jQuery('.separation-journey ul li.separation-item, .separation-journey .bullet-text').each(function () { var checked = 0; var count = 0; jQuery(this).find('input').each(function () { if (jQuery(this).is(':checked')) { checked++; total_checked++; jQuery(".journey-counter .rounded-button").show(); } count++; total_count++; }); if (count > 0) { jQuery(this).find('> input').prop('checked', (count == checked)); } else { total_count++; if (jQuery(this).find('> input').is(':checked')) { total_checked++; } } }); jQuery(".separation-journey .rounded-button").click(function () { jQuery(".hidden-information").show(); }); var journeyProgress = (total_checked); jQuery('.separation-journey .journey-counter .items-clicked .number').text(journeyProgress); if (total_checked == 0) { jQuery(".journey-counter .rounded-button").hide(); jQuery(".separation-journey .hidden-information").hide(); } } updateTotalJourney(); //Image Map - Loss Cycle // window.showonlyone = function (thechosenone) { // jQuery('.item').each(function (index) { // if (jQuery(this).attr("id") == thechosenone) { // jQuery(this).slideToggle("slow"); // } else { // jQuery(this).hide("show"); // } // }); // } showonlyone(); }); /* window.onload = function () { var image = 'loss-cycle-map-img'; var ImageMap = function (map) { var n, areas = document.getElementsByClassName('areaElement'), len = areas.length, coords = [], previousWidth = 1000; for (n = 0; n < len; n++) { coords[n] = areas[n].coords.split(','); } this.resize = function () { var n, m, clen, x = document.getElementById('loss-cycle-map-img').clientWidth / previousWidth; for (n = 0; n < len; n++) { clen = coords[n].length; for (m = 0; m < clen; m++) { coords[n][m] *= x; } areas[n].coords = coords[n].join(','); } previousWidth = document.getElementById('loss-cycle-map-img').clientWidth return true; }; window.onresize = this.resize; }, imageMap = new ImageMap(document.getElementById('loss-cycle-map')); imageMap.resize(); } */ jQuery(window).load(function () { /** * Detect OS & browsers */ /* Add class for mac */ if (navigator.appVersion.indexOf("Win") != -1) { jQuery('body').addClass('window-os'); } if (navigator.platform.toUpperCase().indexOf('MAC') >= 0) { jQuery('body').addClass('mac-os'); } if (navigator.appVersion.indexOf("Linux") != -1) { jQuery('body').addClass('linux-os'); } /* Add class for all ie version */ var trident = !!navigator.userAgent.match(/Trident\/7.0/); var net = !!navigator.userAgent.match(/.NET4.0E/); var IE11 = trident && net; var IEold = (navigator.userAgent.match(/MSIE/i) ? true : false); if (IE11 || IEold) { jQuery('body').addClass('internet-explorer'); } var ua = navigator.userAgent.toLowerCase(); if (ua.indexOf('safari') != -1) { if (ua.indexOf('chrome') > -1) { jQuery('body').addClass('chrome'); } else { jQuery('body').addClass('safari'); } } var FF = !(window.mozInnerScreenX == null); if (FF) { jQuery('body').addClass('fire-fox'); } else { //jQuery('body').addClass('not-fire-fox'); } /* End */ });