initial
This commit is contained in:
commit
9883323161
17470 files changed
+4470592
No files matched your search
@@ -0,0 +1,40 @@
|
||||
.plugin-card-jetpack-plugin-search .plugin-action-buttons {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.plugin-card-jetpack-plugin-search .plugin-card-bottom {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jetpack-plugin-search__bottom {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-content: space-between;
|
||||
clear: both;
|
||||
padding: 12px 20px;
|
||||
background-color: #f6f7f7;
|
||||
border-top: 1px solid #dcdcde;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.jetpack-plugin-search__text {
|
||||
flex: 1;
|
||||
margin: 0 24px 0 16px;
|
||||
}
|
||||
|
||||
/* Hides the link to dismiss cards when it's in action links
|
||||
* are before being moved to bottom row */
|
||||
.action-links .jetpack-plugin-search__dismiss {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jetpack-plugin-search__bottom .jetpack-plugin-search__dismiss {
|
||||
color: #484848;
|
||||
font-style: italic;
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jetpack-plugin-search__dismiss:hover {
|
||||
color: #646970;
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
/**
|
||||
* Handles the activation of a Jetpack feature, dismissing the card, and replacing the bottom row
|
||||
* of the card with customized content.
|
||||
*/
|
||||
|
||||
/* global jetpackPluginSearch, jpTracksAJAX */
|
||||
|
||||
var JetpackPSH = {};
|
||||
|
||||
( function ( $, jpsh ) {
|
||||
JetpackPSH = {
|
||||
$pluginFilter: $( '#plugin-filter' ),
|
||||
|
||||
/**
|
||||
* Get parent search hint element.
|
||||
* @return {Element | null}
|
||||
*/
|
||||
getCard: function () {
|
||||
return document.querySelector( '.plugin-card-jetpack-plugin-search' );
|
||||
},
|
||||
|
||||
/**
|
||||
* Track user event such as a click on a button or a link.
|
||||
*
|
||||
* @param {string} eventName Event identifier.
|
||||
* @param {object} feature Identifier of feature involved in the event.
|
||||
* @param {object} target Object where action was performed.
|
||||
*/
|
||||
trackEvent: function ( eventName, feature, target ) {
|
||||
jpTracksAJAX
|
||||
.record_ajax_event( eventName, 'click', { feature: feature } )
|
||||
.always( function () {
|
||||
if ( 'undefined' !== typeof target && !! target.getAttribute( 'href' ) ) {
|
||||
// If it has an href, follow it.
|
||||
window.location = target.getAttribute( 'href' );
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Replace bottom row of the card to insert logo, text and link to dismiss the card.
|
||||
*/
|
||||
replaceCardBottom: function () {
|
||||
var hint = JetpackPSH.getCard();
|
||||
if ( 'object' === typeof hint && null !== hint ) {
|
||||
hint.querySelector( '.plugin-card-bottom' ).outerHTML =
|
||||
'<div class="jetpack-plugin-search__bottom"><img src="' +
|
||||
jetpackPluginSearch.logo +
|
||||
'" width="32" />' +
|
||||
'<p class="jetpack-plugin-search__text">' +
|
||||
jetpackPluginSearch.legend +
|
||||
' <a class="jetpack-plugin-search__support_link" href="' +
|
||||
jetpackPluginSearch.supportLink +
|
||||
'" target="_blank" rel="noopener noreferrer" data-track="support_link" >' +
|
||||
jetpackPluginSearch.supportText +
|
||||
'</a>' +
|
||||
'</p>' +
|
||||
'</div>';
|
||||
|
||||
// Remove link and parent li from action links and move it to bottom row
|
||||
var dismissLink = document.querySelector( '.jetpack-plugin-search__dismiss' );
|
||||
dismissLink.parentNode.parentNode.removeChild( dismissLink.parentNode );
|
||||
document.querySelector( '.jetpack-plugin-search__bottom' ).appendChild( dismissLink );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Check if plugin card list nodes changed. If there's a Jetpack PSH card, replace the bottom row.
|
||||
* @param {array} mutationsList
|
||||
*/
|
||||
replaceOnNewResults: function ( mutationsList ) {
|
||||
mutationsList.forEach( function ( mutation ) {
|
||||
if (
|
||||
'childList' === mutation.type &&
|
||||
1 === document.querySelectorAll( '.plugin-card-jetpack-plugin-search' ).length
|
||||
) {
|
||||
JetpackPSH.replaceCardBottom();
|
||||
}
|
||||
} );
|
||||
},
|
||||
|
||||
dismiss: function ( moduleName ) {
|
||||
document.getElementById( 'the-list' ).removeChild( JetpackPSH.getCard() );
|
||||
$.ajax( {
|
||||
url: jpsh.base_rest_url + '/hints',
|
||||
method: 'post',
|
||||
beforeSend: function ( xhr ) {
|
||||
xhr.setRequestHeader( 'X-WP-Nonce', jpsh.nonce );
|
||||
},
|
||||
data: JSON.stringify( {
|
||||
hint: moduleName,
|
||||
} ),
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
} ).done( function () {
|
||||
JetpackPSH.trackEvent( 'wpa_plugin_search_dismiss', moduleName );
|
||||
} );
|
||||
},
|
||||
|
||||
ajaxActivateModule: function ( moduleName ) {
|
||||
var $moduleBtn = JetpackPSH.$pluginFilter.find( '#plugin-select-activate' );
|
||||
$moduleBtn.toggleClass( 'install-now updating-message' );
|
||||
$moduleBtn.prop( 'disabled', true );
|
||||
$moduleBtn.text( jpsh.activating );
|
||||
var data = {};
|
||||
data[ moduleName ] = true;
|
||||
$.ajax( {
|
||||
url: jpsh.base_rest_url + '/settings',
|
||||
method: 'post',
|
||||
beforeSend: function ( xhr ) {
|
||||
xhr.setRequestHeader( 'X-WP-Nonce', jpsh.nonce );
|
||||
},
|
||||
data: JSON.stringify( data ),
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
} )
|
||||
.done( function () {
|
||||
JetpackPSH.updateButton( moduleName );
|
||||
JetpackPSH.trackEvent( 'wpa_plugin_search_activate', moduleName );
|
||||
} )
|
||||
.error( function () {
|
||||
$moduleBtn.toggleClass( 'install-now updating-message' );
|
||||
} );
|
||||
},
|
||||
|
||||
// Remove onclick handler, disable loading spinner, update button to redirect to module settings.
|
||||
updateButton: function ( moduleName ) {
|
||||
$.ajax( {
|
||||
url: jpsh.base_rest_url + '/module/' + moduleName,
|
||||
method: 'get',
|
||||
beforeSend: function ( xhr ) {
|
||||
xhr.setRequestHeader( 'X-WP-Nonce', jpsh.nonce );
|
||||
},
|
||||
dataType: 'json',
|
||||
} ).done( function ( response ) {
|
||||
var $moduleBtn = JetpackPSH.$pluginFilter.find( '#plugin-select-activate' );
|
||||
$moduleBtn.prop( 'onclick', null ).off( 'click' );
|
||||
$moduleBtn.toggleClass( 'install-now updating-message' );
|
||||
$moduleBtn.text( jpsh.activated );
|
||||
setTimeout( function () {
|
||||
var url = 'https://jetpack.com/redirect/?source=plugin-hint-learn-' + moduleName,
|
||||
label = jpsh.getStarted,
|
||||
classes = 'jetpack-plugin-search__primary button',
|
||||
track = 'configure';
|
||||
|
||||
// If the feature has options in Jetpack admin UI, link to them.
|
||||
if ( response.options && 0 < Object.keys( response.options ).length ) {
|
||||
url = $moduleBtn.data( 'configure-url' );
|
||||
label = jpsh.manageSettings;
|
||||
classes += ' jetpack-plugin-search__configure';
|
||||
} else {
|
||||
// If it has no options, the Get started button will be displayed so remove the Learn more link if it's there.
|
||||
var learnMore = document.querySelector( '.jetpack-plugin-search__learn-more' );
|
||||
learnMore.parentNode.removeChild( learnMore );
|
||||
classes += ' jetpack-plugin-search__get-started';
|
||||
track = 'get_started';
|
||||
}
|
||||
$moduleBtn.replaceWith(
|
||||
'<a id="plugin-select-settings" class="' +
|
||||
classes +
|
||||
'" href="' +
|
||||
url +
|
||||
'" data-module="' +
|
||||
moduleName +
|
||||
'" data-track="' +
|
||||
track +
|
||||
'">' +
|
||||
label +
|
||||
'</a>'
|
||||
);
|
||||
}, 1000 );
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Start suggesting.
|
||||
*/
|
||||
init: function () {
|
||||
if ( JetpackPSH.$pluginFilter.length < 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Replace PSH bottom row on page load
|
||||
JetpackPSH.replaceCardBottom();
|
||||
|
||||
// Listen for changes in plugin search results
|
||||
var resultsObserver = new MutationObserver( JetpackPSH.replaceOnNewResults );
|
||||
resultsObserver.observe( document.getElementById( 'plugin-filter' ), { childList: true } );
|
||||
|
||||
JetpackPSH.$pluginFilter
|
||||
.on( 'click', '.jetpack-plugin-search__dismiss', function ( event ) {
|
||||
event.preventDefault();
|
||||
JetpackPSH.dismiss( $( this ).data( 'module' ) );
|
||||
} )
|
||||
.on( 'click', 'button#plugin-select-activate', function ( event ) {
|
||||
event.preventDefault();
|
||||
JetpackPSH.ajaxActivateModule( $( this ).data( 'module' ) );
|
||||
} )
|
||||
.on( 'click', '.jetpack-plugin-search__primary', function ( event ) {
|
||||
var $this = $( this );
|
||||
var opensInNewTab = '_blank' === $this.attr( 'target' );
|
||||
if ( ! opensInNewTab ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if ( $this.data( 'track' ) ) {
|
||||
// This catches Purchase, Configure, and Get started. Feature activation is tracked when it ends successfully, in its callback.
|
||||
JetpackPSH.trackEvent(
|
||||
'wpa_plugin_search_' + $this.data( 'track' ),
|
||||
$this.data( 'module' ),
|
||||
// only redirect if not opening in a new tab
|
||||
opensInNewTab ? undefined : $this.get( 0 )
|
||||
);
|
||||
}
|
||||
} )
|
||||
.on( 'click', '.jetpack-plugin-search__learn-more', function ( event ) {
|
||||
var $this = $( this );
|
||||
var opensInNewTab = '_blank' === $this.attr( 'target' );
|
||||
if ( ! opensInNewTab ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
JetpackPSH.trackEvent(
|
||||
'wpa_plugin_search_learn_more',
|
||||
$this.data( 'module' ),
|
||||
opensInNewTab ? undefined : $this.get( 0 )
|
||||
);
|
||||
} )
|
||||
.on( 'click', '.jetpack-plugin-search__support_link', function ( event ) {
|
||||
var $this = $( this );
|
||||
var opensInNewTab = '_blank' === $this.attr( 'target' );
|
||||
if ( ! opensInNewTab ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
JetpackPSH.trackEvent(
|
||||
'wpa_plugin_search_support_link',
|
||||
$this.data( 'module' ),
|
||||
opensInNewTab ? undefined : $this.get( 0 )
|
||||
);
|
||||
} );
|
||||
},
|
||||
};
|
||||
|
||||
JetpackPSH.init();
|
||||
} )( jQuery, jetpackPluginSearch );
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 183 104" xmlns="http://www.w3.org/2000/svg"><path d="m.3 99.6c11-.6 22.1-.7 33.1-.8l16.6-.1h16.6l33.1.2c11 .1 22.1.2 33.1.6.2 0 .4.2.4.4s-.2.4-.4.4c-11 .4-22.1.5-33.1.6l-33.1.2h-16.6l-16.6-.1c-11-.1-22.1-.3-33.1-.8-.1 0-.2-.1-.2-.2 0-.3.1-.4.2-.4zm152.5 0c2.5-.5 5-.7 7.5-.8l3.7-.1h3.7c2.5 0 5 .1 7.5.2s5 .2 7.5.6c.2 0 .4.2.4.5 0 .2-.2.3-.4.4-2.5.4-5 .5-7.5.6s-5 .1-7.5.2h-3.7l-3.7-.1c-2.5-.1-5-.3-7.5-.8-.1 0-.2-.1-.2-.2 0-.4.1-.5.2-.5z" fill="#e3eaf0"/><path d="m46.1 82.8v-57.8h70.1v57.8h-66.3" fill="#d8dee4"/><path d="m46.1 24.7v-13.6h98.2v13.5h-92.8" fill="#BBC9D5"/><path d="m144.3 25.2.9 57.3-28.9.1v-57.4z" fill="#ccced0"/><path d="m102.5 82.7h-48.2v-32.1h53.1v32.1m0-35.7h-53.1v-13.2h53.1z" fill="#fff"/><path d="m96.1 41.6c-.7.2-1.4.5-2.1.8-.6.4-1.3.7-1.9 1.1-.4.3-.9.6-1.4.9.4-.5.9-1.1 1.3-1.6.5-.6 1-1.3 1.4-2 .5-.7.9-1.4 1.2-2.2 0-.1 0-.1-.1-.1h-.1c-.7.5-1.3 1.1-1.8 1.7s-1 1.3-1.5 1.9c-.4.6-.9 1.2-1.3 1.9.2-.7.5-1.4.7-2.2l.6-2.4c.2-.8.3-1.6.3-2.5v-.1h-.1c-.4.7-.8 1.5-1 2.2-.3.8-.5 1.6-.7 2.3-.2.6-.3 1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2-4c3.8-3.2 6.7-7.4 8.6-12 2-4.6 2.8-9.5 3.1-14.4s0-9.8-.7-14.6z" fill="#069e08"/><path d="m145.3 78.3 7.4 5.9 15.1-17.2" fill="#069e08"/><path d="m168.1 66.9c-.1-.1-.3-.2-.5-.1-1.5 1.2-2.9 2.6-4.2 3.9l-3.9 4.2c-2.3 2.6-4.6 5.1-6.9 7.7-1-.8-1.9-1.5-2.9-2.3l-1.9-1.5c-.7-.5-1.2-1.1-2.1-1.2h-.4c-.4.2-.6.6-.4 1 .3.9 1 1.2 1.6 1.8l1.8 1.5c1.2 1 2.4 2 3.7 3 .5.4 1.1.3 1.5-.1 2.5-2.9 5-5.7 7.5-8.6 1.2-1.5 2.5-2.9 3.7-4.4s2.3-3 3.3-4.7c.2.1.1-.1.1-.2z" fill="#fff"/><path d="m137.2 99.7c-5-.2-10-.4-15-.5s-10-.2-15-.2c-10-.1-19.9-.1-29.9-.1l-29.9-.1h-18.7c-.7 0-1.1 0-1.6-.1s-.9-.3-1.3-.6c-.8-.6-1.3-1.4-1.5-2.4 0-.2-.1-.5-.1-.7v-1.6l52.9-.1h4.8v2.4c0 .3.2.5.5.5h24.5c.3 0 .5-.2.5-.5v-2.7c3.5 0 6.9-.1 10.4-.2 4.5-.1 9-.2 13.5-.4.1 0 .2-.1.2-.3 0-.1-.1-.2-.2-.2-4.5-.2-9-.3-13.5-.4s-9-.2-13.5-.2c-9-.1-18-.1-27-.1l-54.2-.2c-.6 0-1.Line truncated
|
||||
|
After Width: | Height: | Size: 5.4 KiB |
Reference in new issue
Block a user