| 1 |
/* global pagenow, ajaxurl, CalypsoifyOpts */ |
| 2 |
( function( $ ) { |
| 3 |
$( window ).load( function() { |
| 4 |
// On Plugins.php |
| 5 |
if ( 'plugins' === pagenow ) { |
| 6 |
// pagenow === $current_screen->id |
| 7 |
// Remove | and () from the plugins filter bar |
| 8 |
$.each( $( 'ul.subsubsub li' ), function( i, el ) { |
| 9 |
var li = $( el ); |
| 10 |
li.html( |
| 11 |
li |
| 12 |
.html() |
| 13 |
.replace( '|', '' ) |
| 14 |
.replace( '(', '' ) |
| 15 |
.replace( ')', '' ) |
| 16 |
); |
| 17 |
} ); |
| 18 |
|
| 19 |
// Add in the AJAX-y goodness for toggling autoupdates. |
| 20 |
$( 'input.autoupdate-toggle' ).change( function( event ) { |
| 21 |
var el = event.target; |
| 22 |
|
| 23 |
el.disabled = true; |
| 24 |
el.classList.add( 'is-toggling' ); |
| 25 |
|
| 26 |
jQuery.post( |
| 27 |
ajaxurl, |
| 28 |
{ |
| 29 |
action: 'jetpack_toggle_autoupdate', |
| 30 |
type: 'plugins', |
| 31 |
slug: el.dataset.slug, |
| 32 |
active: el.checked, |
| 33 |
_wpnonce: CalypsoifyOpts.nonces.autoupdate_plugins, |
| 34 |
}, |
| 35 |
function() { |
| 36 |
// Add something to test and confirm that `el.dataset.slug` is missing from `response.data` ? |
| 37 |
el.disabled = false; |
| 38 |
el.classList.remove( 'is-toggling' ); |
| 39 |
} |
| 40 |
); |
| 41 |
} ); |
| 42 |
} |
| 43 |
|
| 44 |
$( '#wp-admin-bar-root-default' ).on( 'click', 'li', function( event ) { |
| 45 |
location.href = $( event.target ) |
| 46 |
.closest( 'a' ) |
| 47 |
.attr( 'href' ); |
| 48 |
} ); |
| 49 |
|
| 50 |
$( '#wp-admin-bar-top-secondary' ).on( 'click', 'li#wp-admin-bar-my-account', function( |
| 51 |
event |
| 52 |
) { |
| 53 |
location.href = $( event.target ) |
| 54 |
.closest( 'a' ) |
| 55 |
.attr( 'href' ); |
| 56 |
} ); |
| 57 |
|
| 58 |
if ( document && document.location && document.location.search ) { |
| 59 |
var params_array = document.location.search.substr( 1 ).split( '&' ), |
| 60 |
params_object = {}, |
| 61 |
body = $( document.body ), |
| 62 |
i, |
| 63 |
key_value, |
| 64 |
pluginEl; |
| 65 |
|
| 66 |
if ( params_array && params_array.length ) { |
| 67 |
for ( i = 0; i < params_array.length; i++ ) { |
| 68 |
key_value = params_array[ i ].split( '=' ); |
| 69 |
params_object[ key_value[ 0 ] ] = key_value[ 1 ]; |
| 70 |
} |
| 71 |
|
| 72 |
if ( params_object.s && params_object[ 'modal-mode' ] && params_object.plugin ) { |
| 73 |
pluginEl = $( |
| 74 |
'.plugin-card-' + params_object.plugin + ' .thickbox.open-plugin-details-modal' |
| 75 |
); |
| 76 |
if ( pluginEl && pluginEl.length ) { |
| 77 |
pluginEl.click(); |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
body.on( 'thickbox:iframe:loaded', function() { |
| 83 |
$( '#TB_window' ).on( 'click', 'button#TB_closeWindowButton', function() { |
| 84 |
$( '#TB_closeWindowButton' ).click(); |
| 85 |
} ); |
| 86 |
} ); |
| 87 |
} |
| 88 |
} ); |
| 89 |
} )( jQuery ); |
| 90 |
|