Ubuntu
/**
* Mini chart.
*
* @param {element} canvas The canvas element.
*/
window.imagify.drawMeAChart = function( canvas ) {
canvas.each( function() {
var value = parseInt( jQuery( this ).closest( '.imagify-chart' ).next( '.imagify-chart-value' ).text(), 10 );
new window.imagify.Chart( this, { // eslint-disable-line no-new
type: 'doughnut',
data: {
datasets: [ {
data: [ value, 100 - value ],
backgroundColor: [ '#00B3D3', '#D8D8D8' ],
borderColor: '#fff',
borderWidth: 1
} ]
},
options: {
legend: {
display: false
},
events: [],
animation: {
easing: 'easeOutBounce'
},
tooltips: {
enabled: false
},
responsive: false
}
} );
} );
};
(function($, d, w, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names
w.imagify.filesList = {
working: [],
/*
* Init.
*/
init: function () {
var $document = $( d ),
$processing;
// Update the chart in the media modal when a media is selected, and the ones already printed.
$( w ).on( 'canvasprinted.imagify', this.updateChart ).trigger( 'canvasprinted.imagify' );
// Handle bulk actions.
this.insertBulkActionTags();
$( '#doaction, #doaction2' ).on( 'click.imagify', this.processBulkAction );
// Optimize, restore, etc.
$document.on( 'click.imagify', '.button-imagify-optimize, .button-imagify-manual-reoptimize, .button-imagify-generate-webp, .button-imagify-delete-webp, .button-imagify-restore, .button-imagify-refresh-status', this.processOptimization );
$document.on( 'imagifybeat-send', this.addToImagifybeat );
$document.on( 'imagifybeat-tick', this.processImagifybeat );
// Some items may be processed in background on page load.
$processing = $( '.wp-list-table.imagify-files .button-imagify-processing' );
if ( $processing.length ) {
// Some media are already being processed.
// Lock the items, so we can check their status with Imagifybeat.
$processing.closest( 'tr' ).find( '.check-column [name="bulk_select[]"]' ).each( function() {
var id = w.imagify.filesList.sanitizeId( this.value );
w.imagify.filesList.lockItem( w.imagifyFiles.context, id );
} );
// Fasten Imagifybeat.
w.imagify.beat.interval( 15 );
}
},
// Charts ==================================================================================
/**
* Update the chart in the media modal when a media is selected, and the ones already printed.
*
* @param {object} e Event.
* @param {string} selector A CSS selector.
*/
updateChart: function( e, selector ) {
var $canvas;
selector = selector || '.imagify-consumption-chart';
$canvas = $( selector );
w.imagify.drawMeAChart( $canvas );
$canvas.closest( '.imagify-datas-list' ).siblings( '.imagify-datas-details' ).hide();
},
// Bulk optimization =======================================================================
/**
* Insert the bulk actions in the