| 1 |
const WSRSpinner = window.WSRSpinner || ( |
| 2 |
function ( document, window, $ ) { |
| 3 |
const app = { |
| 4 |
init() { |
| 5 |
window.WSRSpinner = app; |
| 6 |
app.spinner = $( '#wsrw-admin-spinner' ); |
| 7 |
}, |
| 8 |
show_button_spinner( $button, position = 'right' ) { |
| 9 |
$button.prop( 'disabled', true ); |
| 10 |
const offset = $button.offset(); |
| 11 |
const menu_width = $( '#adminmenuwrap' ).width(); |
| 12 |
const admin_bar = $( '#wpadminbar' ).height(); |
| 13 |
let css = {}; |
| 14 |
app.spinner.show(); |
| 15 |
if ( 'right' === position ) { |
| 16 |
css = { |
| 17 |
left: offset.left - menu_width + $button.outerWidth(), |
| 18 |
top: offset.top - admin_bar + $button.outerHeight() / 2 - app.spinner.height() / 2, |
| 19 |
}; |
| 20 |
} else { |
| 21 |
css = { |
| 22 |
left: offset.left - menu_width - app.spinner.outerWidth() - 20, |
| 23 |
top: offset.top - admin_bar + $button.outerHeight() / 2 - app.spinner.height() / 2, |
| 24 |
}; |
| 25 |
} |
| 26 |
|
| 27 |
app.spinner.css( css ); |
| 28 |
}, |
| 29 |
hide_button_spinner( $button ) { |
| 30 |
$button.prop( 'disabled', false ); |
| 31 |
app.spinner.hide(); |
| 32 |
}, |
| 33 |
}; |
| 34 |
return app; |
| 35 |
}( document, window, jQuery ) |
| 36 |
); |
| 37 |
|
| 38 |
WSRSpinner.init(); |
| 39 |
|