/* global wpcom_reblog */ var jetpackLikesWidgetBatch = []; var jetpackLikesMasterReady = false; // Due to performance problems on pages with a large number of widget iframes that need to be loaded, // we are limiting the processing at any instant to unloaded widgets that are currently in viewport, // plus this constant that will allow processing of widgets above and bellow the current fold. // This aim of it is to improve the UX and hide the transition from unloaded to loaded state from users. var jetpackLikesLookAhead = 2000; // pixels // Keeps track of loaded comment likes widget so we can unload them when they are scrolled out of view. var jetpackCommentLikesLoadedWidgets = []; var jetpackLikesDocReadyPromise = new Promise( resolve => { if ( document.readyState !== 'loading' ) { resolve(); } else { window.addEventListener( 'DOMContentLoaded', () => resolve() ); } } ); function JetpackLikesPostMessage( message, target ) { if ( typeof message === 'string' ) { try { message = JSON.parse( message ); } catch ( e ) { return; } } if ( target && typeof target.postMessage === 'function' ) { try { target.postMessage( JSON.stringify( { type: 'likesMessage', data: message, } ), '*' ); } catch ( e ) { return; } } } function JetpackLikesBatchHandler() { const requests = []; document.querySelectorAll( 'div.jetpack-likes-widget-unloaded' ).forEach( widget => { if ( jetpackLikesWidgetBatch.indexOf( widget.id ) > -1 ) { return; } if ( ! jetpackIsScrolledIntoView( widget ) ) { return; } jetpackLikesWidgetBatch.push( widget.id ); var regex = /like-(post|comment)-wrapper-(\d+)-(\d+)-(\w+)/, match = regex.exec( widget.id ), info; if ( ! match || match.length !== 5 ) { return; } info = { blog_id: match[ 2 ], width: widget.width, }; if ( 'post' === match[ 1 ] ) { info.post_id = match[ 3 ]; } else if ( 'comment' === match[ 1 ] ) { info.comment_id = match[ 3 ]; } info.obj_id = match[ 4 ]; requests.push( info ); } ); if ( requests.length > 0 ) { JetpackLikesPostMessage( { event: 'initialBatch', requests: requests }, window.frames[ 'likes-master' ] ); } } function JetpackLikesMessageListener( event ) { let message = event && event.data; if ( typeof message === 'string' ) { try { message = JSON.parse( message ); } catch ( err ) { return; } } const type = message && message.type; const data = message && message.data; if ( type !== 'likesMessage' || typeof data.event === 'undefined' ) { return; } // We only allow messages from one origin const allowedOrigin = 'https://widgets.wp.com'; if ( allowedOrigin !== event.origin ) { return; } switch ( data.event ) { case 'masterReady': jetpackLikesDocReadyPromise.then( () => { jetpackLikesMasterReady = true; const stylesData = { event: 'injectStyles', }; const sdTextColor = document.querySelector( '.sd-text-color' ); const sdLinkColor = document.querySelector( '.sd-link-color' ); const sdTextColorStyles = ( sdTextColor && getComputedStyle( sdTextColor ) ) || {}; const sdLinkColorStyles = ( sdLinkColor && getComputedStyle( sdLinkColor ) ) || {}; // enable reblogs if they are enabled for the page if ( document.body.classList.contains( 'jetpack-reblog-enabled' ) ) { JetpackLikesPostMessage( { event: 'reblogsEnabled' }, window.frames[ 'likes-master' ] ); } stylesData.textStyles = { color: sdTextColorStyles[ 'color' ], fontFamily: sdTextColorStyles[ 'font-family' ], fontSize: sdTextColorStyles[ 'font-size' ], direction: sdTextColorStyles[ 'direction' ], fontWeight: sdTextColorStyles[ 'font-weight' ], fontStyle: sdTextColorStyles[ 'font-style' ], textDecoration: sdTextColorStyles[ 'text-decoration' ], }; stylesData.linkStyles = { color: sdLinkColorStyles[ 'color' ], fontFamily: sdLinkColorStyles[ 'font-family' ], fontSize: sdLinkColorStyles[ 'font-size' ], textDecoration: sdLinkColorStyles[ 'text-decoration' ], fontWeight: sdLinkColorStyles[ 'font-weight' ], fontStyle: sdLinkColorStyles[ 'font-style' ], }; JetpackLikesPostMessage( stylesData, window.frames[ 'likes-master' ] ); JetpackLikesBatchHandler(); } ); break; case 'showLikeWidget': { const placeholder = document.querySelector( `#${ data.id } .likes-widget-placeholder` ); if ( placeholder ) { placeholder.style.display = 'none'; } break; } case 'showCommentLikeWidget': { const placeholder = document.querySelector( `#${ data.id } .likes-widget-placeholder` ); if ( placeholder ) { placeholder.style.display = 'none'; } break; } case 'killCommentLikes': // If kill switch for comment likes is enabled remove all widgets wrappers and `Loading...` placeholders. document .querySelectorAll( '.jetpack-comment-likes-widget-wrapper' ) .forEach( wrapper => wrapper.remove() ); break; case 'clickReblogFlair': if ( wpcom_reblog && typeof wpcom_reblog.toggle_reblog_box_flair === 'function' ) { wpcom_reblog.toggle_reblog_box_flair( data.obj_id, data.post_id ); } break; case 'hideOtherGravatars': { hideLikersPopover(); break; } case 'showOtherGravatars': { const container = document.querySelector( '#likes-other-gravatars' ); if ( ! container ) { break; } const list = container.querySelector( 'ul' ); container.style.display = 'none'; list.innerHTML = ''; container .querySelectorAll( '.likes-text span' ) .forEach( item => ( item.textContent = data.totalLikesLabel ) ); ( data.likers || [] ).forEach( async ( liker, index ) => { if ( liker.profile_URL.substr( 0, 4 ) !== 'http' ) { // We only display gravatars with http or https schema return; } const element = document.createElement( 'li' ); list.append( element ); element.innerHTML = ` `; // Add some extra attributes through native methods, to ensure strings are sanitized. element.classList.add( liker.css_class ); element.querySelector( 'img' ).alt = data.avatarAltTitle.replace( '%s', liker.name ); element.querySelector( 'span' ).innerText = liker.name; if ( index === data.likers.length - 1 ) { element.addEventListener( 'keydown', ( e ) => { if ( e.key === 'Tab' && ! e.shiftKey ) { e.preventDefault(); hideLikersPopover(); JetpackLikesPostMessage( { event: 'focusLikesCount', parent: data.parent }, window.frames[ 'likes-master' ] ); } } ); } } ); const positionPopup = function() { const containerStyle = getComputedStyle(container); const isRtl = containerStyle.direction === 'rtl'; const el = document.querySelector( `*[name='${ data.parent }']` ); const rect = el.getBoundingClientRect(); const win = el.ownerDocument.defaultView; const offset = { top: rect.top + win.pageYOffset, left: rect.left + win.pageXOffset, }; // don't display yet or we get skewed window.innerWidth later container.style.display = 'none'; let containerLeft = 0; container.style.top = offset.top + data.position.top - 1 + 'px'; if ( isRtl ) { const visibleAvatarsCount = data && data.likers ? Math.min( data.likers.length, 5 ) : 0; // 24px is the width of the avatar + 4px is the padding between avatars containerLeft = offset.left + data.position.left + 24 * visibleAvatarsCount + 4; container.style.transform = 'translateX(-100%)'; } else { containerLeft = offset.left + data.position.left; } container.style.left = containerLeft + 'px'; // Container width - padding const initContainerWidth = data.width - 20; const rowLength = Math.floor( initContainerWidth / 37 ); // # of rows + (avatar + avatar padding) + text above + container padding let height = Math.ceil( data.likers.length / rowLength ) * 37 + 17 + 22; if ( height > 204 ) { height = 204; } // If the popup is overflows viewport width, we should show it on the next line // Push it offscreen to calculated rendered width const windowWidth = win.innerWidth; container.style.left = '-9999px'; container.style.display = 'block'; // If the popup exceeds the viewport width, // flip the position of the popup. const containerWidth = container.offsetWidth; const containerRight = containerLeft + containerWidth; if ( containerRight > windowWidth && ! isRtl) { containerLeft = rect.left + rect.width - containerWidth; } else if ( containerLeft - containerWidth < 0 && isRtl ) { container.style.transform = 'none'; containerLeft = rect.left; } // Set the container left container.style.left = containerLeft + 'px'; container.setAttribute( 'aria-hidden', 'false' ); } positionPopup(); container.focus(); const debounce = function( func, wait ) { var timeout; return function() { var context = this; var args = arguments; clearTimeout( timeout ); timeout = setTimeout( function() { func.apply( context, args ); }, wait ); }; }; const debouncedPositionPopup = debounce( positionPopup, 100 ); // Keep a reference of this function in the element itself // so that we can destroy it later container.__resizeHandler = debouncedPositionPopup; // When window is resized, resize the popup. window.addEventListener( "resize", debouncedPositionPopup ); } } } window.addEventListener( 'message', JetpackLikesMessageListener ); function hideLikersPopover() { const container = document.querySelector( '#likes-other-gravatars' ); if ( container ) { container.style.display = 'none'; container.setAttribute( 'aria-hidden', 'true' ); // Remove the resize event listener and cleanup. const resizeHandler = container.__resizeHandler; if ( resizeHandler ) { window.removeEventListener( "resize", resizeHandler ); delete container.__resizeHandler; } } } document.addEventListener( 'click', hideLikersPopover ); function JetpackLikesWidgetQueueHandler() { var wrapperID; if ( ! jetpackLikesMasterReady ) { setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } // Restore widgets to initial unloaded state when they are scrolled out of view. jetpackUnloadScrolledOutWidgets(); var unloadedWidgetsInView = jetpackGetUnloadedWidgetsInView(); if ( unloadedWidgetsInView.length > 0 ) { // Grab any unloaded widgets for a batch request JetpackLikesBatchHandler(); } for ( var i = 0, length = unloadedWidgetsInView.length; i <= length - 1; i++ ) { wrapperID = unloadedWidgetsInView[ i ].id; if ( ! wrapperID ) { continue; } jetpackLoadLikeWidgetIframe( wrapperID ); } } function jetpackLoadLikeWidgetIframe( wrapperID ) { if ( typeof wrapperID === 'undefined' ) { return; } const wrapper = document.querySelector( '#' + wrapperID ); wrapper.querySelectorAll( 'iframe' ).forEach( iFrame => iFrame.remove() ); const placeholder = wrapper.querySelector( '.likes-widget-placeholder' ); // Post like iframe if ( placeholder && placeholder.classList.contains( 'post-likes-widget-placeholder' ) ) { const postLikesFrame = document.createElement( 'iframe' ); postLikesFrame.classList.add( 'post-likes-widget', 'jetpack-likes-widget' ); postLikesFrame.name = wrapper.dataset.name; postLikesFrame.src = wrapper.dataset.src; postLikesFrame.height = '55px'; postLikesFrame.width = '100%'; postLikesFrame.frameBorder = '0'; postLikesFrame.scrolling = 'no'; postLikesFrame.title = wrapper.dataset.title; placeholder.after( postLikesFrame ); } // Comment like iframe if ( placeholder.classList.contains( 'comment-likes-widget-placeholder' ) ) { const commentLikesFrame = document.createElement( 'iframe' ); commentLikesFrame.class = 'comment-likes-widget-frame jetpack-likes-widget-frame'; commentLikesFrame.name = wrapper.dataset.name; commentLikesFrame.src = wrapper.dataset.src; commentLikesFrame.height = '18px'; commentLikesFrame.width = '100%'; commentLikesFrame.frameBorder = '0'; commentLikesFrame.scrolling = 'no'; wrapper.querySelector( '.comment-like-feedback' ).after( commentLikesFrame ); jetpackCommentLikesLoadedWidgets.push( commentLikesFrame ); } wrapper.classList.remove( 'jetpack-likes-widget-unloaded' ); wrapper.classList.add( 'jetpack-likes-widget-loading' ); wrapper.querySelector( 'iframe' ).addEventListener( 'load', e => { JetpackLikesPostMessage( { event: 'loadLikeWidget', name: e.target.name, width: e.target.width }, window.frames[ 'likes-master' ] ); wrapper.classList.remove( 'jetpack-likes-widget-loading' ); wrapper.classList.add( 'jetpack-likes-widget-loaded' ); } ); } function jetpackGetUnloadedWidgetsInView() { const unloadedWidgets = document.querySelectorAll( 'div.jetpack-likes-widget-unloaded' ); return [ ...unloadedWidgets ].filter( item => jetpackIsScrolledIntoView( item ) ); } function jetpackIsScrolledIntoView( element ) { const top = element.getBoundingClientRect().top; const bottom = element.getBoundingClientRect().bottom; // Allow some slack above and bellow the fold with jetpackLikesLookAhead, // with the aim of hiding the transition from unloaded to loaded widget from users. return top + jetpackLikesLookAhead >= 0 && bottom <= window.innerHeight + jetpackLikesLookAhead; } function jetpackUnloadScrolledOutWidgets() { for ( let i = jetpackCommentLikesLoadedWidgets.length - 1; i >= 0; i-- ) { const currentWidgetIframe = jetpackCommentLikesLoadedWidgets[ i ]; if ( ! jetpackIsScrolledIntoView( currentWidgetIframe ) ) { const widgetWrapper = currentWidgetIframe && currentWidgetIframe.parentElement && currentWidgetIframe.parentElement.parentElement; // Restore parent class to 'unloaded' so this widget can be picked up by queue manager again if needed. widgetWrapper.classList.remove( 'jetpack-likes-widget-loaded' ); widgetWrapper.classList.remove( 'jetpack-likes-widget-loading' ); widgetWrapper.classList.add( 'jetpack-likes-widget-unloaded' ); // Bring back the loading placeholder into view. widgetWrapper .querySelectorAll( '.comment-likes-widget-placeholder' ) .forEach( item => ( item.style.display = 'block' ) ); // Remove it from the list of loaded widgets. jetpackCommentLikesLoadedWidgets.splice( i, 1 ); // Remove comment like widget iFrame. currentWidgetIframe.remove(); } } } var jetpackWidgetsDelayedExec = function ( after, fn ) { var timer; return function () { clearTimeout( timer ); timer = setTimeout( fn, after ); }; }; var jetpackOnScrollStopped = jetpackWidgetsDelayedExec( 250, JetpackLikesWidgetQueueHandler ); // Load initial batch of widgets, prior to any scrolling events. JetpackLikesWidgetQueueHandler(); // Add event listener to execute queue handler after scroll. window.addEventListener( 'scroll', jetpackOnScrollStopped, true ); ; /* global screenReaderText */ /** * Theme functions file. * * Contains handlers for navigation and widget area. * * @version 1.0.1 */ ( function($) { var $body, $window, $sidebar, adminbarOffset, top = false, bottom = false, windowWidth, windowHeight, lastWindowPos = 0, topOffset = 0, bodyHeight, sidebarHeight, resizeTimer, secondary, button; var direction; (document.dir !=undefined)? direction =document.dir : direction =document.getElementsByTagName("html")[0].getAttribute("dir"); // Add overlay-wrap Div container to be able to close overlay $('#masthead').after('
'); // Overlay (main menu + widget area) open/close $('.overlay-open').on( 'click', function () { $('html').addClass('overlay-show'); $('body').addClass('overlay-show'); }); $('#overlay-close').on( 'click', function () { $('html').removeClass('overlay-show'); $('body').removeClass('overlay-show'); }); // Hide Desktop Off Canvas Menu on Click into main website area $('#overlay-wrap').on( 'click', function () { $('html').removeClass('overlay-show'); $('body').removeClass('overlay-show'); }); // Desktio Search open/close $('.search-open').on( 'click', function () { $( ".desktop-search" ).slideToggle( "fast", function() { }); }); // Featured Posts Slider $(document).ready(function() { if (direction=="rtl") { $('.featured-slider').slick({ dots: false, slidesToShow: 1, autoplay: false, cssEase: 'ease', draggable: true, pauseOnHover: false, infinite: true, rtl: true }); } else { $('.featured-slider').slick({ dots: false, slidesToShow: 1, autoplay: false, cssEase: 'ease', draggable: true, pauseOnHover: false, infinite: true }); } }); // Fade in Featured Images $(document).ready(function() { if ( window.innerWidth >= 1060 ) { $('body').toggleClass('imgfade-on'); $('.fadein').viewportChecker({ classToAdd: 'inview', // Class to add to the elements when they are visible offset: 50, removeClassAfterAnimation: true }); } }); $( document.body ).on( 'post-load', function () { if ( window.innerWidth >= 1060 ) { $('body').toggleClass('imgfade-on'); $('.fadein').viewportChecker({ classToAdd: 'inview', // Class to add to the elements when they are visible offset: 50, removeClassAfterAnimation: true }); } } ); // Sticky Desktop Header Bar $(function() { var stickyheader = $('.sticky-header'); $(window).scroll(function() { var scroll = $(window).scrollTop(); if (scroll >= 158) { $('body').addClass('header-stick'); stickyheader.removeClass('hidden'); stickyheader.attr("aria-hidden","false"); } else { $('body').removeClass('header-stick'); stickyheader.addClass('hidden'); stickyheader.attr("aria-hidden","true"); } }); }); // Sticky Last Sidebar Element $(document).ready(function() { if ( window.innerWidth >= 1060 ) { $(".blog #secondary .widget:last-child").stick_in_parent({ parent: "#blog-wrap", offset_top: 80 }); } }); // Sticky Last Sidebar Element - Single Post $(document).ready(function() { if ( window.innerWidth >= 1060 ) { $(".single-post #secondary .widget:last-child").stick_in_parent({ parent: "#singlepost-wrap", offset_top: 80 }); } }); // Add dropdown toggle that display child menu items. $( '.menu-item-has-children > a' ).after( '' ); $( '.page_item_has_children > a' ).after( '' ); // Toggle buttons and submenu items with active children menu items. $( '.current-menu-ancestor > button' ).addClass( 'toggle-on' ); $( '.current-menu-ancestor > .sub-menu' ).addClass( 'toggled-on' ); $( '.current-menu-ancestor > .children' ).addClass( 'toggled-on' ); $( '.dropdown-toggle' ).click( function( e ) { var _this = $( this ); e.preventDefault(); _this.toggleClass( 'toggle-on' ); _this.next( '.children, .sub-menu' ).toggleClass( 'toggled-on' ); _this.attr( 'aria-expanded', _this.attr( 'aria-expanded' ) === 'false' ? 'true' : 'false' ); _this.html( _this.html() === screenReaderText.expand ? screenReaderText.collapse : screenReaderText.expand ); } ); secondary = $( '#secondary' ); button = $( '.site-branding' ).find( '.secondary-toggle' ); // Enable menu toggle for small screens. ( function() { var menu, widgets, social; if ( ! secondary || ! button ) { return; } // Hide button if there are no widgets and the menus are missing or empty. menu = secondary.find( '.nav-menu' ); widgets = secondary.find( '#widget-area' ); social = secondary.find( '#social-navigation' ); if ( ! widgets.length && ! social.length && ( ! menu || ! menu.children().length ) ) { button.hide(); return; } button.on( 'click.nikau', function() { secondary.toggleClass( 'toggled-on' ); secondary.trigger( 'resize' ); $( this ).toggleClass( 'toggled-on' ); if ( $( this, secondary ).hasClass( 'toggled-on' ) ) { $( this ).attr( 'aria-expanded', 'true' ); secondary.attr( 'aria-expanded', 'true' ); } else { $( this ).attr( 'aria-expanded', 'false' ); secondary.attr( 'aria-expanded', 'false' ); } } ); } )(); } )( jQuery ); ; !function(r){"use strict";var t,e,n;e={},(n=function(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}).m=t=[function(r,t,e){e(1),e(70),e(77),e(80),e(81),e(83),e(95),e(96),e(98),e(101),e(103),e(104),e(113),e(114),e(117),e(123),e(138),e(140),e(141),r.exports=e(142)},function(r,t,e){var n=e(2),o=e(38),a=e(62),c=e(67),i=e(69);n({target:"Array",proto:!0,arity:1,forced:e(6)((function(){return 4294967297!==[].push.call({length:4294967296},1)}))||!function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(r){return r instanceof TypeError}}()},{push:function(r){var t=o(this),e=a(t),n=arguments.length;i(e+n);for(var u=0;uf;)o(n,e=t[f++])&&(~c(s,e)||u(s,e));return s}},function(r,t,e){var n=e(11),o=e(59),a=e(62);e=function(r){return function(t,e,c){var i,u=n(t),f=a(u),s=o(c,f);if(r&&e!=e){for(;s"+r+""}var c,i=n(45),u=n(74),f=n(64),s=n(53),p=n(76),l=n(41),y=(n=n(52),"prototype"),h="script",v=n("IE_PROTO"),g=function(){try{c=new ActiveXObject("htmlfile")}catch(r){}var r;g="undefined"==typeof document||document.domain&&c?function(r){r.write(a("")),r.close();var t=r.parentWindow.Object;return r=null,t}(c):((r=l("iframe")).style.display="none",p.appendChild(r),r.src=String("javascript:"),(r=r.contentWindow.document).open(),r.write(a("document.F=Object")),r.close(),r.F);for(var t=f.length;t--;)delete g[y][f[t]];return g()};s[v]=!0,t.exports=Object.create||function(t,e){var n;return null!==t?(o[y]=i(t),n=new o,o[y]=null,n[v]=t):n=g(),e===r?n:u.f(n,e)}},function(r,t,e){var n=e(5),o=e(44),a=e(43),c=e(45),i=e(11),u=e(75);t.f=n&&!o?Object.defineProperties:function(r,t){c(r);for(var e,n=i(t),o=u(t),f=o.length,s=0;s=t||56320!=(64512&i(r,e))))return!1}return!0}})},function(r,t,e){var n=e(91),o=String;r.exports=function(r){if("Symbol"===n(r))throw new TypeError("Cannot convert a Symbol value to a string");return o(r)}},function(r,t,e){var n=e(2),o=e(7),a=e(13),c=e(15),i=e(102),u=(e=e(6),Array),f=a("".charAt),s=a("".charCodeAt),p=a([].join),l="".toWellFormed,y=l&&e((function(){return"1"!==o(l,1)}));n({target:"String",proto:!0,forced:y},{toWellFormed:function(){var r=i(c(this));if(y)return o(l,r);for(var t=r.length,e=u(t),n=0;n