| 1 |
// Admin bar ======================================================================================= |
| 2 |
(function($, d, w, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names |
| 3 |
|
| 4 |
var busy = false; |
| 5 |
|
| 6 |
$( d ).on( 'mouseenter', '#wp-admin-bar-imagify', function() { |
| 7 |
var $adminBarProfile, url, $adminBarPricing; |
| 8 |
|
| 9 |
if ( true === busy ) { |
| 10 |
return; |
| 11 |
} |
| 12 |
|
| 13 |
busy = true; |
| 14 |
|
| 15 |
$adminBarProfile = $( '#wp-admin-bar-imagify-profile-content' ); |
| 16 |
$adminBarPricing = $( '#wp-admin-bar-imagify-pricing-content' ); |
| 17 |
|
| 18 |
if ( ! $adminBarProfile.is( ':empty' ) ) { |
| 19 |
return; |
| 20 |
} |
| 21 |
|
| 22 |
if ( w.ajaxurl ) { |
| 23 |
url = w.ajaxurl; |
| 24 |
} else { |
| 25 |
url = w.imagifyAdminBar.ajaxurl; |
| 26 |
} |
| 27 |
|
| 28 |
url += url.indexOf( '?' ) > 0 ? '&' : '?'; |
| 29 |
|
| 30 |
$.get( url + 'action=imagify_get_admin_bar_profile&imagifygetadminbarprofilenonce=' + $( '#imagifygetadminbarprofilenonce' ).val() ) |
| 31 |
.done( function( response ) { |
| 32 |
var $templates = response.data; |
| 33 |
$( '#wp-admin-bar-imagify-profile-loading' ).remove(); |
| 34 |
if ( $templates.admin_bar_pricing ) { |
| 35 |
$adminBarPricing.html( $templates.admin_bar_pricing ); |
| 36 |
} else { |
| 37 |
$adminBarPricing.remove(); |
| 38 |
} |
| 39 |
|
| 40 |
if ( $templates.admin_bar_status ) { |
| 41 |
$adminBarProfile.html( $templates.admin_bar_status ); |
| 42 |
} |
| 43 |
|
| 44 |
busy = false; |
| 45 |
} ); |
| 46 |
} ); |
| 47 |
|
| 48 |
} )(jQuery, document, window); |
| 49 |
|