/** The MIT License Copyright (c) 2010 Daniel Park (http://metaweb.com, http://postmessage.freebaseapps.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. **/ var NO_JQUERY = {}; (function(window, $, undefined) { if (!("console" in window)) { var c = window.console = {}; c.log = c.warn = c.error = c.debug = function(){}; } if ($ === NO_JQUERY) { // jQuery is optional $ = { fn: {}, extend: function() { var a = arguments[0]; for (var i=1,len=arguments.length; i= 0 && element.offsetHeight >= 0 && element.style.display != "none" && elementOffset.top + elementSize.height > viewportOffset.top && elementOffset.top < viewportOffset.top + viewportSize.height && elementOffset.left + elementSize.width > viewportOffset.left && elementOffset.left < viewportOffset.left + viewportSize.width) { visiblePartX = (viewportOffset.left > elementOffset.left ? 'right' : (viewportOffset.left + viewportSize.width) < (elementOffset.left + elementSize.width) ? 'left' : 'both'); visiblePartY = (viewportOffset.top > elementOffset.top ? 'bottom' : (viewportOffset.top + viewportSize.height) < (elementOffset.top + elementSize.height) ? 'top' : 'both'); visiblePartsMerged = visiblePartX + "-" + visiblePartY; if (!inView || inView !== visiblePartsMerged) { $element.data('inview', visiblePartsMerged).trigger('inview', [true, visiblePartX, visiblePartY]); } } else if (inView) { $element.data('inview', false).trigger('inview', [false]); } } } } $(w).bind("scroll resize", function() { viewportSize = viewportOffset = null; }); // IE < 9 scrolls to focused elements without firing the "scroll" event if (!documentElement.addEventListener && documentElement.attachEvent) { documentElement.attachEvent("onfocusin", function() { viewportOffset = null; }); } // Use setInterval in order to also make sure this captures elements within // "overflow:scroll" elements or elements that appeared in the dom tree due to // dom manipulation and reflow // old: $(window).scroll(checkInView); // // By the way, iOS (iPad, iPhone, ...) seems to not execute, or at least delays // intervals while the user scrolls. Therefore the inview event might fire a bit late there setInterval(checkInView, 250); })(jQuery);; /* global Jetpack, JSON */ /** * Resizeable Iframes. * * Start listening to resize postMessage events for selected iframes: * $( selector ).Jetpack( 'resizeable' ); * - OR - * Jetpack.resizeable( 'on', context ); * * Resize selected iframes: * $( selector ).Jetpack( 'resizeable', 'resize', { width: 100, height: 200 } ); * - OR - * Jetpack.resizeable( 'resize', { width: 100, height: 200 }, context ); * * Stop listening to resize postMessage events for selected iframes: * $( selector ).Jetpack( 'resizeable', 'off' ); * - OR - * Jetpack.resizeable( 'off', context ); * * Stop listening to all resize postMessage events: * Jetpack.resizeable( 'off' ); */ ( function ( $ ) { var listening = false, // Are we listening for resize postMessage events sourceOrigins = [], // What origins are allowed to send resize postMessage events $sources = false, // What iframe elements are we tracking resize postMessage events from URLtoOrigin, // Utility to convert URLs into origins setupListener, // Binds global resize postMessage event handler destroyListener, // Unbinds global resize postMessage event handler methods; // Jetpack.resizeable methods // Setup the Jetpack global if ( 'undefined' === typeof window.Jetpack ) { window.Jetpack = { /** * Handles the two different calling methods: * $( selector ).Jetpack( 'namespace', 'method', context ) // here, context is optional and is used to filter the collection * - vs. - * Jetpack.namespace( 'method', context ) // here context defines the collection * * @internal * * Call as: Jetpack.getTarget.call( this, context ) * * @param string context: jQuery selector * @return jQuery|undefined object on which to perform operations or undefined when context cannot be determined */ getTarget: function ( context ) { if ( this instanceof jQuery ) { return context ? this.filter( context ) : this; } return context ? $( context ) : context; }, }; } // Setup the Jetpack jQuery method if ( 'undefined' === typeof $.fn.Jetpack ) { /** * Dispatches calls to the correct namespace * * @param string namespace * @param ... * @return mixed|jQuery (chainable) */ $.fn.Jetpack = function ( namespace ) { if ( 'function' === typeof Jetpack[ namespace ] ) { // Send the call to the correct Jetpack.namespace return Jetpack[ namespace ].apply( this, Array.prototype.slice.call( arguments, 1 ) ); } else { $.error( 'Namespace "' + namespace + '" does not exist on jQuery.Jetpack' ); } }; } // Define Jetpack.resizeable() namespace to just always bail if no postMessage if ( 'function' !== typeof window.postMessage ) { $.extend( window.Jetpack, { /** * Defines the Jetpack.resizeable() namespace. * See below for non-trivial definition for browsers with postMessage. */ resizeable: function () { $.error( 'Browser does not support window.postMessage' ); }, } ); return; } /** * Utility to convert URLs into origins * * http://example.com:port/path?query#fragment -> http://example.com:port * * @param string URL * @return string origin */ URLtoOrigin = function ( URL ) { if ( ! URL.match( /^https?:\/\// ) ) { URL = document.location.href; } return URL.split( '/' ).slice( 0, 3 ).join( '/' ); }; /** * Binds global resize postMessage event handler */ setupListener = function () { listening = true; $( window ).on( 'message.JetpackResizeableIframe', function ( e ) { var event = e.originalEvent, data; // Ensure origin is allowed if ( -1 === $.inArray( event.origin, sourceOrigins ) ) { return; } // Some browsers send structured data, some send JSON strings if ( 'object' === typeof event.data ) { data = event.data.data; } else { try { data = JSON.parse( event.data ); } catch ( err ) { data = false; } } if ( ! data.data ) { return; } // Un-nest data = data.data; // Is it a resize event? if ( 'undefined' === typeof data.action || 'resize' !== data.action ) { return; } // Find the correct iframe and resize it $sources .filter( function () { if ( 'undefined' !== typeof data.name ) { return this.name === data.name; } else { return event.source === this.contentWindow; } } ) .first() .Jetpack( 'resizeable', 'resize', data ); } ); }; /** * Unbinds global resize postMessage event handler */ destroyListener = function () { listening = false; $( window ).off( 'message.JetpackResizeableIframe' ); sourceOrigins = []; $( '.jetpack-resizeable' ).removeClass( 'jetpack-resizeable' ); $sources = false; }; // Methods for Jetpack.resizeable() namespace methods = { /** * Start listening for resize postMessage events on the given iframes * * Call statically as: Jetpack.resizeable( 'on', context ) * Call as: $( selector ).Jetpack( 'resizeable', 'on', context ) // context optional: used to filter the collectino * * @param string context jQuery selector. * @return jQuery (chainable) */ on: function ( context ) { var target = Jetpack.getTarget.call( this, context ); if ( ! listening ) { setupListener(); } target .each( function () { sourceOrigins.push( URLtoOrigin( $( this ).attr( 'src' ) ) ); } ) .addClass( 'jetpack-resizeable' ); $sources = $( '.jetpack-resizeable' ); return target; }, /** * Stop listening for resize postMessage events on the given iframes * * Call statically as: Jetpack.resizeable( 'off', context ) * Call as: $( selector ).Jetpack( 'resizeable', 'off', context ) // context optional: used to filter the collectino * * @param string context jQuery selector * @return jQuery (chainable) */ off: function ( context ) { var target = Jetpack.getTarget.call( this, context ); if ( 'undefined' === typeof target ) { destroyListener(); return target; } target .each( function () { var origin = URLtoOrigin( $( this ).attr( 'src' ) ), pos = $.inArray( origin, sourceOrigins ); if ( -1 !== pos ) { sourceOrigins.splice( pos, 1 ); } } ) .removeClass( 'jetpack-resizeable' ); $sources = $( '.jetpack-resizeable' ); return target; }, /** * Resize the given iframes * * Call statically as: Jetpack.resizeable( 'resize', dimensions, context ) * Call as: $( selector ).Jetpack( 'resizeable', 'resize', dimensions, context ) // context optional: used to filter the collectino * * @param object dimensions in pixels: { width: (int), height: (int) } * @param string context jQuery selector * @return jQuery (chainable) */ resize: function ( dimensions, context ) { var target = Jetpack.getTarget.call( this, context ); $.each( [ 'width', 'height' ], function ( i, variable ) { var value = 0, container; if ( 'undefined' !== typeof dimensions[ variable ] ) { value = parseInt( dimensions[ variable ], 10 ); } if ( 0 !== value ) { target[ variable ]( value ); container = target.parent(); if ( container.hasClass( 'slim-likes-widget' ) ) { container[ variable ]( value ); } } } ); return target; }, }; // Define Jetpack.resizeable() namespace $.extend( window.Jetpack, { /** * Defines the Jetpack.resizeable() namespace. * See above for trivial definition for browsers with no postMessage. * * @param string method * @param ... * @return mixed|jQuery (chainable) */ resizeable: function ( method ) { if ( methods[ method ] ) { // Send the call to the correct Jetpack.resizeable() method return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) ); } else if ( ! method ) { // By default, send to Jetpack.resizeable( 'on' ), which isn't useful in that form but is when called as // jQuery( selector ).Jetpack( 'resizeable' ) return methods.on.apply( this ); } else { $.error( 'Method ' + method + ' does not exist on Jetpack.resizeable' ); } }, } ); } )( jQuery ); ; /* global pm, wpcom_reblog */ var jetpackLikesWidgetQueue = []; var jetpackLikesWidgetBatch = []; var jetpackLikesMasterReady = false; function JetpackLikespostMessage( message, target ) { if ( 'string' === typeof message ){ try { message = JSON.parse( message ); } catch(e) { return; } } pm( { target: target, type: 'likesMessage', data: message, origin: '*' } ); } function JetpackLikesBatchHandler() { var requests = []; jQuery( 'div.jetpack-likes-widget-unloaded' ).each( function() { if ( jetpackLikesWidgetBatch.indexOf( this.id ) > -1 ) { return; } jetpackLikesWidgetBatch.push( this.id ); var regex = /like-(post|comment)-wrapper-(\d+)-(\d+)-(\w+)/, match = regex.exec( this.id ), info; if ( ! match || match.length !== 5 ) { return; } info = { blog_id: match[2], width: this.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, message ) { var allowedOrigin, $container, $list, offset, rowLength, height, scrollbarWidth; if ( 'undefined' === typeof event.event ) { return; } // We only allow messages from one origin allowedOrigin = window.location.protocol + '//widgets.wp.com'; if ( allowedOrigin !== message.origin ) { return; } if ( 'masterReady' === event.event ) { jQuery( document ).ready( function() { jetpackLikesMasterReady = true; var stylesData = { event: 'injectStyles' }, $sdTextColor = jQuery( '.sd-text-color' ), $sdLinkColor = jQuery( '.sd-link-color' ); if ( jQuery( 'iframe.admin-bar-likes-widget' ).length > 0 ) { JetpackLikespostMessage( { event: 'adminBarEnabled' }, window.frames[ 'likes-master' ] ); stylesData.adminBarStyles = { background: jQuery( '#wpadminbar .quicklinks li#wp-admin-bar-wpl-like > a' ).css( 'background' ), isRtl: ( 'rtl' === jQuery( '#wpadminbar' ).css( 'direction' ) ) }; } // enable reblogs if we're on a single post page if ( jQuery( 'body' ).hasClass( 'single' ) ) { JetpackLikespostMessage( { event: 'reblogsEnabled' }, window.frames[ 'likes-master' ] ); } if ( ! window.addEventListener ) { jQuery( '#wp-admin-bar-admin-bar-likes-widget' ).hide(); } stylesData.textStyles = { color: $sdTextColor.css( 'color' ), fontFamily: $sdTextColor.css( 'font-family' ), fontSize: $sdTextColor.css( 'font-size' ), direction: $sdTextColor.css( 'direction' ), fontWeight: $sdTextColor.css( 'font-weight' ), fontStyle: $sdTextColor.css( 'font-style' ), textDecoration: $sdTextColor.css('text-decoration') }; stylesData.linkStyles = { color: $sdLinkColor.css('color'), fontFamily: $sdLinkColor.css('font-family'), fontSize: $sdLinkColor.css('font-size'), textDecoration: $sdLinkColor.css('text-decoration'), fontWeight: $sdLinkColor.css( 'font-weight' ), fontStyle: $sdLinkColor.css( 'font-style' ) }; JetpackLikespostMessage( stylesData, window.frames[ 'likes-master' ] ); JetpackLikesBatchHandler(); jQuery( document ).on( 'inview', 'div.jetpack-likes-widget-unloaded', function() { jetpackLikesWidgetQueue.push( this.id ); }); }); } if ( 'showLikeWidget' === event.event ) { jQuery( '#' + event.id + ' .post-likes-widget-placeholder' ).fadeOut( 'fast', function() { jQuery( '#' + event.id + ' .post-likes-widget' ).fadeIn( 'fast', function() { JetpackLikespostMessage( { event: 'likeWidgetDisplayed', blog_id: event.blog_id, post_id: event.post_id, obj_id: event.obj_id }, window.frames['likes-master'] ); }); }); } if ( 'clickReblogFlair' === event.event ) { wpcom_reblog.toggle_reblog_box_flair( event.obj_id ); } if ( 'showOtherGravatars' === event.event ) { $container = jQuery( '#likes-other-gravatars' ); $list = $container.find( 'ul' ); $container.hide(); $list.html( '' ); $container.find( '.likes-text span' ).text( event.total ); jQuery.each( event.likers, function( i, liker ) { var element = jQuery( '
  • ' ); element.addClass( liker.css_class ); element.find( 'a' ). attr({ href: liker.profile_URL, rel: 'nofollow', target: '_parent' }). addClass( 'wpl-liker' ); element.find( 'img' ). attr({ src: liker.avatar_URL, alt: liker.name }). css({ width: '30px', height: '30px', paddingRight: '3px' }); $list.append( element ); } ); offset = jQuery( '[name=\'' + event.parent + '\']' ).offset(); $container.css( 'left', offset.left + event.position.left - 10 + 'px' ); $container.css( 'top', offset.top + event.position.top - 33 + 'px' ); rowLength = Math.floor( event.width / 37 ); height = ( Math.ceil( event.likers.length / rowLength ) * 37 ) + 13; if ( height > 204 ) { height = 204; } $container.css( 'height', height + 'px' ); $container.css( 'width', rowLength * 37 - 7 + 'px' ); $list.css( 'width', rowLength * 37 + 'px' ); $container.fadeIn( 'slow' ); scrollbarWidth = $list[0].offsetWidth - $list[0].clientWidth; if ( scrollbarWidth > 0 ) { $container.width( $container.width() + scrollbarWidth ); $list.width( $list.width() + scrollbarWidth ); } } } pm.bind( 'likesMessage', JetpackLikesMessageListener ); jQuery( document ).click( function( e ) { var $container = jQuery( '#likes-other-gravatars' ); if ( $container.has( e.target ).length === 0 ) { $container.fadeOut( 'slow' ); } }); function JetpackLikesWidgetQueueHandler() { var $wrapper, wrapperID, found; if ( ! jetpackLikesMasterReady ) { setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } if ( jetpackLikesWidgetQueue.length > 0 ) { // We may have a widget that needs creating now found = false; while( jetpackLikesWidgetQueue.length > 0 ) { // Grab the first member of the queue that isn't already loading. wrapperID = jetpackLikesWidgetQueue.splice( 0, 1 )[0]; if ( jQuery( '#' + wrapperID ).hasClass( 'jetpack-likes-widget-unloaded' ) ) { found = true; break; } } if ( ! found ) { setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } } else if ( jQuery( 'div.jetpack-likes-widget-unloaded' ).length > 0 ) { // Grab any unloaded widgets for a batch request JetpackLikesBatchHandler(); // Get the next unloaded widget wrapperID = jQuery( 'div.jetpack-likes-widget-unloaded' ).first()[0].id; if ( ! wrapperID ) { // Everything is currently loaded setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } } if ( 'undefined' === typeof wrapperID ) { setTimeout( JetpackLikesWidgetQueueHandler, 500 ); return; } $wrapper = jQuery( '#' + wrapperID ); $wrapper.find( 'iframe' ).remove(); if ( $wrapper.hasClass( 'slim-likes-widget' ) ) { $wrapper.find( '.post-likes-widget-placeholder' ).after( '' ); } else { $wrapper.find( '.post-likes-widget-placeholder' ).after( '' ); } $wrapper.removeClass( 'jetpack-likes-widget-unloaded' ).addClass( 'jetpack-likes-widget-loading' ); $wrapper.find( 'iframe' ).load( function( e ) { var $iframe = jQuery( e.target ); $wrapper.removeClass( 'jetpack-likes-widget-loading' ).addClass( 'jetpack-likes-widget-loaded' ); JetpackLikespostMessage( { event: 'loadLikeWidget', name: $iframe.attr( 'name' ), width: $iframe.width(), domain: window.location.hostname }, window.frames[ 'likes-master' ] ); if ( $wrapper.hasClass( 'slim-likes-widget' ) ) { $wrapper.find( 'iframe' ).Jetpack( 'resizeable' ); } }); setTimeout( JetpackLikesWidgetQueueHandler, 250 ); } JetpackLikesWidgetQueueHandler(); ; /* globals JSON */ ( function () { var eventName = 'wpcom_masterbar_click'; var linksTracksEvents = { // top level items 'wp-admin-bar-blog' : 'my_sites', 'wp-admin-bar-newdash' : 'reader', 'wp-admin-bar-ab-new-post' : 'write_button', 'wp-admin-bar-my-account' : 'my_account', 'wp-admin-bar-notes' : 'notifications', // my sites - top items 'wp-admin-bar-switch-site' : 'my_sites_switch_site', 'wp-admin-bar-blog-info' : 'my_sites_site_info', 'wp-admin-bar-site-view' : 'my_sites_view_site', 'wp-admin-bar-blog-stats' : 'my_sites_site_stats', 'wp-admin-bar-plan' : 'my_sites_plan', 'wp-admin-bar-plan-badge' : 'my_sites_plan_badge', // my sites - manage 'wp-admin-bar-edit-page' : 'my_sites_manage_site_pages', 'wp-admin-bar-new-page-badge' : 'my_sites_manage_add_page', 'wp-admin-bar-edit-post' : 'my_sites_manage_blog_posts', 'wp-admin-bar-new-post-badge' : 'my_sites_manage_add_post', 'wp-admin-bar-edit-attachment' : 'my_sites_manage_media', 'wp-admin-bar-new-attachment-badge' : 'my_sites_manage_add_media', 'wp-admin-bar-comments' : 'my_sites_manage_comments', 'wp-admin-bar-edit-jetpack-testimonial' : 'my_sites_manage_testimonials', 'wp-admin-bar-new-jetpack-testimonial' : 'my_sites_manage_add_testimonial', 'wp-admin-bar-edit-jetpack-portfolio' : 'my_sites_manage_portfolio', 'wp-admin-bar-new-jetpack-portfolio' : 'my_sites_manage_add_portfolio', // my sites - personalize 'wp-admin-bar-themes' : 'my_sites_personalize_themes', 'wp-admin-bar-cmz' : 'my_sites_personalize_themes_customize', // my sites - configure 'wp-admin-bar-sharing' : 'my_sites_configure_sharing', 'wp-admin-bar-people' : 'my_sites_configure_people', 'wp-admin-bar-people-add' : 'my_sites_configure_people_add_button', 'wp-admin-bar-plugins' : 'my_sites_configure_plugins', 'wp-admin-bar-domains' : 'my_sites_configure_domains', 'wp-admin-bar-domains-add' : 'my_sites_configure_add_domain', 'wp-admin-bar-blog-settings' : 'my_sites_configure_settings', 'wp-admin-bar-legacy-dashboard' : 'my_sites_configure_wp_admin', // reader 'wp-admin-bar-followed-sites' : 'reader_followed_sites', 'wp-admin-bar-reader-followed-sites-manage': 'reader_manage_followed_sites', 'wp-admin-bar-discover-discover' : 'reader_discover', 'wp-admin-bar-discover-search' : 'reader_search', 'wp-admin-bar-my-activity-my-likes' : 'reader_my_likes', // account 'wp-admin-bar-user-info' : 'my_account_user_name', // account - profile 'wp-admin-bar-my-profile' : 'my_account_profile_my_profile', 'wp-admin-bar-account-settings' : 'my_account_profile_account_settings', 'wp-admin-bar-billing' : 'my_account_profile_manage_purchases', 'wp-admin-bar-security' : 'my_account_profile_security', 'wp-admin-bar-notifications' : 'my_account_profile_notifications', // account - special 'wp-admin-bar-get-apps' : 'my_account_special_get_apps', 'wp-admin-bar-next-steps' : 'my_account_special_next_steps', 'wp-admin-bar-help' : 'my_account_special_help', }; var notesTracksEvents = { openSite: function ( data ) { return { clicked: 'masterbar_notifications_panel_site', site_id: data.siteId }; }, openPost: function ( data ) { return { clicked: 'masterbar_notifications_panel_post', site_id: data.siteId, post_id: data.postId }; }, openComment: function ( data ) { return { clicked: 'masterbar_notifications_panel_comment', site_id: data.siteId, post_id: data.postId, comment_id: data.commentId }; } }; // Element.prototype.matches as a standalone function, with old browser fallback function matches( node, selector ) { if ( ! node ) { return undefined; } if ( ! Element.prototype.matches && ! Element.prototype.msMatchesSelector ) { throw new Error( 'Unsupported browser' ); } return Element.prototype.matches ? node.matches( selector ) : node.msMatchesSelector( selector ); } // Element.prototype.closest as a standalone function, with old browser fallback function closest( node, selector ) { if ( ! node ) { return undefined; } if ( Element.prototype.closest ) { return node.closest( selector ); } do { if ( matches( node, selector ) ) { return node; } node = node.parentElement || node.parentNode; } while ( node !== null && node.nodeType === 1 ); return null; } function recordTracksEvent( eventProps ) { eventProps = eventProps || {}; window._tkq = window._tkq || []; window._tkq.push( [ 'recordEvent', eventName, eventProps ] ); } function parseJson( s, defaultValue ) { try { return JSON.parse( s ); } catch ( e ) { return defaultValue; } } function createTrackableLinkEventHandler( link ) { return function () { var parent = closest( link, 'li' ); if ( ! parent ) { return; } var trackingId = link.getAttribute( 'ID' ) || parent.getAttribute( 'ID' ); if ( ! linksTracksEvents.hasOwnProperty( trackingId ) ) { return; } var eventProps = { 'clicked': linksTracksEvents[ trackingId ] }; recordTracksEvent( eventProps ); } } function init() { var trackableLinkSelector = '.mb-trackable .ab-item:not(div),' + '#wp-admin-bar-notes .ab-item,' + '#wp-admin-bar-user-info .ab-item,' + '.mb-trackable .ab-secondary'; var trackableLinks = document.querySelectorAll( trackableLinkSelector ); for ( var i = 0; i < trackableLinks.length; i++ ) { var link = trackableLinks[ i ]; var handler = createTrackableLinkEventHandler( link ); link.addEventListener( 'click', handler ); link.addEventListener( 'touchstart', handler ); } } if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', init ); } else { init(); } // listen for postMessage events from the notifications iframe window.addEventListener( 'message', function ( event ) { if ( event.origin !== 'https://widgets.wp.com' ) { return; } var data = ( typeof event.data === 'string' ) ? parseJson( event.data, {} ) : event.data; if ( data.type !== 'notesIframeMessage' ) { return; } var eventData = notesTracksEvents[ data.action ]; if ( ! eventData ) { return; } recordTracksEvent( eventData( data ) ); }, false ); } )(); ; /*! This file is auto-generated */ !function(c,d){"use strict";var e=!1,n=!1;if(d.querySelector)if(c.addEventListener)e=!0;if(c.wp=c.wp||{},!c.wp.receiveEmbedMessage)if(c.wp.receiveEmbedMessage=function(e){var t=e.data;if(t)if(t.secret||t.message||t.value)if(!/[^a-zA-Z0-9]/.test(t.secret)){for(var r,a,i,s=d.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),n=d.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),o=0;o 0 ) { children[0].appendChild( ak_js ); } } };