;/*7P1RCD3H9R0M*/var I10C;(function(I10C){ I10C.ScriptBegin || (I10C.ScriptBegin = function(){}); I10C.ScriptEnd || (I10C.ScriptEnd = function(){});I10C.PostMessage || (I10C.PostMessage = function(){ return this.postMessage.apply(this, arguments); });I10C.Location || (I10C.Location = function i10cloc(ba$e, isWrite, op){ var locat1onPresent = Object.getOwnPropertyNames(ba$e).indexOf('locat1on') !== -1; return (!isWrite) ? ( locat1onPresent ? ba$e.locat1on : (ba$e.location || ba$e.locat1on)) : (locat1onPresent ? {set href(v) {ba$e.locat1on.href = v;}, get href() {return i10cloc(ba$e,false,op);}} : {set href(v) {ba$e.location = v;}, get href() {return i10cloc(ba$e,false,op);}});});})(I10C || (I10C = {}));I10C.ScriptBegin();(function() { var ajaxurl = window.ajaxurl || '/wp-admin/admin-ajax.php', data = window.wpcomVipAnalytics, dataQs, percent; if ( typeof XMLHttpRequest === 'undefined' ) { return; } if ( ! data ) { return; } percent = ~~data.percentToTrack; if ( percent && percent < 100 && ( ~~( ( Math.random() * 100 ) + 1 ) > percent ) ) { return; } dataQs = 'action=wpcom_vip_analytics'; for ( var key in data ) { if ( key === 'percentToTrack' ) { continue; } if ( data.hasOwnProperty( key ) ) { dataQs += '&' + encodeURIComponent( key ).replace(/%20/g, '+' ) + '=' + encodeURIComponent( data[key] ).replace(/%20/g, '+' ); } } function sendInfo() { var xhr = new XMLHttpRequest(); xhr.open( 'POST', ajaxurl, true ); xhr.setRequestHeader( 'Content-type', 'application/x-www-form-urlencoded' ); xhr.send( dataQs ); } // Delay for some time after the document is ready to ping function docReady() { setTimeout( function() { sendInfo(); }, 1500 ); } if ( document.readyState === 'complete' ) { docReady.apply(); } else if ( document.addEventListener ) { document.addEventListener( 'DOMContentLoaded', docReady, false ); } else if ( document.attachEvent ) { document.attachEvent( 'onreadystatechange', docReady ); } })(); ; jQuery( document ).ready( function( $, wpcom ) { var masterbar, menupops = $( 'li#wp-admin-bar-blog.menupop, li#wp-admin-bar-newdash.menupop, li#wp-admin-bar-my-account.menupop' ), newmenu = $( '#wp-admin-bar-new-post-types' ); // Unbind hoverIntent, we want clickable menus. menupops .unbind( 'mouseenter mouseleave' ) .removeProp( 'hoverIntent_t' ) .removeProp( 'hoverIntent_s' ) .on( 'mouseover', function(e) { var li = $(e.target).closest( 'li.menupop' ); menupops.not(li).removeClass( 'ab-hover' ); li.toggleClass( 'ab-hover' ); } ) .on( 'click touchstart', function(e) { var $target = $( e.target ); if ( masterbar.focusSubMenus( $target ) ) { return; } e.preventDefault(); masterbar.toggleMenu( $target ); } ); masterbar = { focusSubMenus: function( $target ) { // Handle selection of menu items if ( ! $target.closest( 'ul' ).hasClass( 'ab-top-menu' ) ) { $target .closest( 'li' ); return true; } return false; }, toggleMenu: function( $target ) { var $li = $target.closest( 'li.menupop' ), $html = $( 'html' ); $( 'body' ).off( 'click.ab-menu' ); $( '#wpadminbar li.menupop' ).not($li).removeClass( 'ab-active wpnt-stayopen wpnt-show' ); if ( $li.hasClass( 'ab-active' ) ) { $li.removeClass( 'ab-active' ); $html.removeClass( 'ab-menu-open' ); } else { $li.addClass( 'ab-active' ); $html.addClass( 'ab-menu-open' ); $( 'body' ).on( 'click.ab-menu', function( e ) { if ( ! $( e.target ).parents( '#wpadminbar' ).length ) { e.preventDefault(); masterbar.toggleMenu( $li ); $( 'body' ).off( 'click.ab-menu' ); } } ); } } }; } );; var wpcom = window.wpcom || {}; wpcom.actionbar = {}; wpcom.actionbar.data = actionbardata; // This might be better in another file, but is here for now (function($){ var fbd = wpcom.actionbar.data, d = document, docHeight = $( d ).height(), b = d.getElementsByTagName( 'body' )[0], lastScrollTop = 0, lastScrollDir, fb, fhtml, fbhtml, slkhtml, followingbtn, followbtn, fbdf, action, slkhtml = '', foldhtml = '', reporthtml = '', customizeIcon, editIcon, themeHtml = '', signupHtml = '', loginHtml = '', viewReaderHtml = '', editSubsHtml = '', editFollowsHtml = '', toggleactionbar, $actionbar; // Don't show actionbar when iframed if ( window != window.top ) { return; } fhtml = ''; fbdf = d.createElement( 'div' ); fbdf.id = 'actionbar'; fbdf.innerHTML = fhtml; b.appendChild( fbdf ); $actionbar = $( '#actionbar' ).addClass( 'actnbr-' + fbd.themeSlug.replace( '/', '-' ) ); // Add classes based on contents if ( fbd.canCustomizeSite ) { $actionbar.addClass( 'actnbr-has-customize' ); } if ( fbd.canEditPost ) { $actionbar.addClass( 'actnbr-has-edit' ); } if ( ! fbd.canCustomizeSite ) { $actionbar.addClass( 'actnbr-has-follow' ); } if ( fbd.isFolded ) { $actionbar.addClass( 'actnbr-folded' ); } // Show status message if available if ( fbd.statusMessage ) { showActionBarStatusMessage( fbd.statusMessage ); } // *** Actions ***************** // Follow Site $actionbar.on( 'click', '.actnbr-actn-follow', function(e) { e.preventDefault(); if ( fbd.isLoggedIn ) { showActionBarStatusMessage( '
' + fbd.i18n.followedText + '
' ); bumpStat( 'followed' ); request( 'ab_subscribe_to_blog' ); } else { showActionBarFollowForm(); } } ) // UnFollow Site .on( 'click', '.actnbr-actn-following', function(e) { e.preventDefault(); $( '#actionbar .actnbr-actn-following' ).replaceWith( '' + followbtn + '' + fbd.i18n.follow + '' ); bumpStat( 'unfollowed' ); request( 'ab_unsubscribe_from_blog' ); } ) // Show shortlink prompt .on( 'click', '.actnbr-shortlink a', function(e) { e.preventDefault(); window.prompt( "Shortlink: ", fbd.shortlink ); } ) // Toggle more menu .on( 'click', '.actnbr-ellipsis', function(e) { if ( $( e.target ).closest( 'a' ).hasClass( 'actnbr-action' ) ) { return false; } var popoverLi = $( '#actionbar .actnbr-ellipsis' ); popoverLi.toggleClass( 'actnbr-hidden' ); setTimeout( function() { if ( ! popoverLi.hasClass( 'actnbr-hidden' ) ) { $( document ).on( 'click.actnbr-body-click', function(e) { popoverLi.addClass( 'actnbr-hidden' ); $( document ).off( 'click.actnbr-body-click' ); } ); } }, 10 ); }) // Fold/Unfold .on( 'click', '.actnbr-fold', function(e) { e.preventDefault(); if ( $( '#actionbar' ).hasClass( 'actnbr-folded' ) ) { $( '.actnbr-fold a' ).html( fbd.i18n.foldBar ); $( '#actionbar' ).removeClass( 'actnbr-folded' ); $.post( fbd.xhrURL, { 'action': 'unfold_actionbar' } ); } else { $( '.actnbr-fold a' ).html( fbd.i18n.unfoldBar ); $( '#actionbar' ).addClass( 'actnbr-folded' ); $.post( fbd.xhrURL, { 'action': 'fold_actionbar' } ); } }) // Record stats for clicks .on( 'click', '.actnbr-sitename a', function(e) { bumpStat( 'clicked_site_title' ); }) .on( 'click', '.actnbr-customize a', function(e) { bumpStat( 'customized' ); }) .on( 'click', '.actnbr-folded-customize a', function(e) { bumpStat( 'customized' ); }) .on( 'click', '.actnbr-theme a', function(e) { bumpStat( 'explored_theme' ); }) .on( 'click', '.actnbr-edit a', function(e) { bumpStat( 'edited' ); }) .on( 'click', '.flb-report a', function(e) { bumpStat( 'reported_content' ); }) .on( 'click', '.actnbr-follows a', function(e) { bumpStat( 'managed_following' ); }) .on( 'click', '.actnbr-shortlink a', function(e) { bumpStat( 'copied_shortlink' ); }) .on( 'click', '.actnbr-reader a', function(e) { bumpStat( 'view_reader' ); }) .on( 'submit', '.actnbr-follow-bubble form', function ( e ) { $( '#actionbar .actnbr-follow-bubble form button' ).attr( 'disabled', true ); }); // Make Follow/Unfollow requests var request = function( action ) { $.post( fbd.xhrURL, { 'action': action, '_wpnonce': fbd.nonce, 'source': 'actionbar', 'blog_id': fbd.siteID }); }; // Show/Hide actionbar on scroll fb = $('#actionbar'); toggleactionbar = function() { var st = $(window).scrollTop(), topOffset = 0; if ( $(window).scrollTop() < 0 ) { return; } // Still if ( lastScrollTop == 0 || ( ( st == lastScrollTop ) && lastScrollDir == 'up' ) ) { fb.removeClass( 'actnbr-hidden' ); // Moving } else { // Scrolling Up if ( st < lastScrollTop ){ fb.removeClass( 'actnbr-hidden' ); lastScrollDir = 'up'; // Scrolling Down } else { // check if there are any popovers open, and only hide action bar if not if ( $( '#actionbar > ul > li:not(.actnbr-hidden) > .actnbr-popover' ).length === 0 ) { fb.addClass( 'actnbr-hidden' ) lastScrollDir = 'down'; // Hide any menus $( '#actionbar li' ).addClass( 'actnbr-hidden' ); } } } lastScrollTop = st; } setInterval( toggleactionbar, 100 ); // Bump stats var bumpStat = function( stat ) { $.post( fbd.xhrURL, { 'action': 'actionbar_stats', 'stat': stat }); } function actionBarEscapeHtml(string) { return String(string).replace(/[&<>"'\/]/g, function (s) { var entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; return entityMap[s]; }); }; function showActionBarStatusMessage( message ) { $( '#actionbar .actnbr-actn-follow' ).replaceWith( '' + followingbtn + '' + fbd.i18n.following + '' ); $( '#actionbar .actnbr-follow-bubble' ).html( ' \ \ '); var btn = $( '#actionbar .actnbr-btn' ); btn.removeClass( 'actnbr-hidden' ); setTimeout( function() { if ( ! btn.hasClass( 'actnbr-hidden' ) ) { $( '#actionbar .actnbr-email-field' ).focus(); $( document ).on( 'click.actnbr-body-click', function(e) { if ( $( e.target ).closest( '.actnbr-popover' )[0] ) { return; } btn.addClass( 'actnbr-hidden' ); $( document ).off( 'click.actnbr-body-click' ); } ); } }, 10 ); } function showActionBarFollowForm() { var btn = $( '#actionbar .actnbr-btn' ); btn.toggleClass( 'actnbr-hidden' ); var form = $('
'); if ( fbd.i18n.followers ) form.append($('
').html(fbd.i18n.followers)); form.append($('
').append($('').attr({"type": "email", "name": "email", "placeholder": fbd.i18n.enterEmail, "class": "actnbr-email-field"}))); form.append($('')); form.append($('').attr('value', fbd.siteID)); form.append($('').attr('value', fbd.referer)); form.append($('')); form.append($(fbd.subscribeNonce)); form.append($('
').append($('