Skip to content

Commit

Permalink
Merge branch-1.6.8 into master.
Browse files Browse the repository at this point in the history
  • Loading branch information
Screenfeed committed Jul 26, 2017
2 parents 1d54eb7 + acd99a4 commit 7c61d71
Show file tree
Hide file tree
Showing 37 changed files with 850 additions and 302 deletions.
12 changes: 12 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,18 @@ td.imagify-cell-filename {
background: #D0021B;
color: #FFF;
}
.imagify-settings-section .imagify-error {
display: inline-block;
padding: 7px 10px;
margin: 10px 0 0 45px;
border-radius: 3px;
}
.imagify-settings-section .imagify-error code {
font-weight: normal;
}
.imagify-settings-section .imagify-error.hidden {
display: none;
}
.imagify-warning,
#wpadminbar .imagify-warning * {
background: #f5a623;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/admin.min.css

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions assets/js/bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ window.imagify = window.imagify || {

e.preventDefault();

if ( optimizationLevel === undefined ) {
if ( undefined === optimizationLevel ) {
optimizationLevel = -1;
}

Expand Down Expand Up @@ -262,20 +262,20 @@ window.imagify = window.imagify || {

// Before the attachment optimization.
Optimizer.before( function( data ) {
table.find( '.imagify-row-progress' ).after( '<tr id="attachment-' + data.id + '"><td class="imagify-cell-filename"><span class="imagiuploaded"><img src="' + data.thumbnail + '"/>"</span><span class="imagifilename">' + data.filename + '</span></td><td class="imagify-cell-status"><span class="imagistatus status-compressing"><span class="dashicons dashicons-admin-generic rotate"></span>Compressing<span></span></span></td><td class="imagify-cell-original"></td><td class="imagify-cell-optimized"></td><td class="imagify-cell-percentage"></td><td class="imagify-cell-thumbnails"></td><td class="imagify-cell-savings"></td></tr>' );
table.find( '.imagify-row-progress' ).after( '<tr id="attachment-' + data.id + '"><td class="imagify-cell-filename"><span class="imagiuploaded"><img src="' + data.thumbnail + '" alt=""/></span><span class="imagifilename">' + data.filename + '</span></td><td class="imagify-cell-status"><span class="imagistatus status-compressing"><span class="dashicons dashicons-admin-generic rotate"></span>' + imagifyBulk.labels.optimizing + '<span></span></span></td><td class="imagify-cell-original"></td><td class="imagify-cell-optimized"></td><td class="imagify-cell-percentage"></td><td class="imagify-cell-thumbnails"></td><td class="imagify-cell-savings"></td></tr>' );
} )
// After the attachment optimization.
.each( function( data ) {
var $progress = $( '#imagify-progress-bar' ),
errorClass = 'error',
errorDashicon = 'dismiss',
errorMessage = 'Error';
errorMessage = imagifyBulk.labels.error;

$progress.css( { 'width': data.progress + '%' } );
$progress.find( '.percent' ).html( data.progress + '%' );

if ( data.success ) {
$( '#attachment-' + data.image + ' .imagify-cell-status' ).html( '<span class="imagistatus status-complete"><span class="dashicons dashicons-yes"></span>Complete</span>' );
$( '#attachment-' + data.image + ' .imagify-cell-status' ).html( '<span class="imagistatus status-complete"><span class="dashicons dashicons-yes"></span>' + imagifyBulk.labels.complete + '</span>' );
$( '#attachment-' + data.image + ' .imagify-cell-original' ).html( data.original_size_human );
$( '#attachment-' + data.image + ' .imagify-cell-optimized' ).html( data.new_size_human );
$( '#attachment-' + data.image + ' .imagify-cell-percentage' ).html( '<span class="imagify-chart"><span class="imagify-chart-container"><canvas height="18" width="18" id="imagify-consumption-chart" style="width: 18px; height: 18px;"></canvas></span></span><span class="imagipercent">' + data.percent + '</span>%' );
Expand All @@ -285,7 +285,7 @@ window.imagify = window.imagify || {

// The table footer total optimized files.
files = files + data.thumbnails + 1;
$( '.imagify-cell-nb-files' ).html( files + ' file(s)' );
$( '.imagify-cell-nb-files' ).html( imagifyBulk.labels.nbrFiles.replace( '%s', files ) );

// The table footer original size.
original_overall_size = original_overall_size + data.original_overall_size;
Expand All @@ -312,10 +312,10 @@ window.imagify = window.imagify || {
if ( data.error.indexOf( 'This image is already compressed' ) >= 0 ) {
errorClass = 'warning';
errorDashicon = 'warning';
errorMessage = 'Notice';
errorMessage = imagifyBulk.labels.notice;
} else {
errors++;
$( '.imagify-cell-errors' ).html( errors + ' error(s)' );
$( '.imagify-cell-errors' ).html( imagifyBulk.labels.nbrErrors.replace( '%s', errors ) );
}

$( '#attachment-' + data.image ).after( '<tr><td colspan="7"><span class="status-' + errorClass + '">' + data.error + '</span></td></tr>' );
Expand Down Expand Up @@ -356,7 +356,7 @@ window.imagify = window.imagify || {
}
} )
.error( function( id ) {
imagify.log( 'Can\'t optimize image with id ' + id );
imagify.log( "Can't optimize image with id " + id + "." );
} )
.run();
} )
Expand Down
2 changes: 1 addition & 1 deletion assets/js/bulk.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions assets/js/imagify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* imagify-gulpjs - version 0.0.1 - 2016-04-07
* WP Media <[email protected]>
*
* Note: when updating this file, don't forget to replace `this.buffer_size = 1;` by `this.buffer_size = imagifyBulk.buffer_size;`.
* Note: when updating this file, don't forget to replace `this.buffer_size = 1;` by `this.buffer_size = imagifyBulk.buffer_size;`. Also, humanSize() has been edited to use a correct format.
*/
(function () {
'use strict';
Expand Down Expand Up @@ -94,13 +94,13 @@ window.ImagifyGulp = function () {
key: 'humanSize',
value: function humanSize( bytes ) {
if ( 0 === bytes ) {
return '0kb';
return '0\u00A0kB';
}

var sizes = [ 'b', 'kb', 'mb' ],
var sizes = [ 'B', 'kB', 'MB' ],
i = parseInt( Math.floor( Math.log( bytes ) / Math.log( 1024 ) ) );

return ( bytes / Math.pow( 1024, i ) ).toFixed( 2 ) + sizes[ i ];
return ( bytes / Math.pow( 1024, i ) ).toFixed( 2 ) + '\u00A0' + sizes[ i ];
}
}, {
key: 'run',
Expand Down
2 changes: 1 addition & 1 deletion assets/js/imagify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 89 additions & 2 deletions assets/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,26 @@ window.imagify = window.imagify || {
* Imagify Backup alert.
*/
$( '.imagify-settings-section' ).find( '#backup' ).on( 'change', function() {
var $_this = $( this );
var $_this = $( this ),
$backupMessage = $_this.siblings( '#backup-dir-is-writable' ),
params = {
'action': 'imagify_check_backup_dir_is_writable',
'_wpnonce': $backupMessage.data( 'nonce' )
};

if ( $_this.is( ':checked' ) ) {
$.getJSON( ajaxurl, params )
.done( function( r ) {
if ( $.isPlainObject( r ) && r.success ) {
if ( r.data.is_writable ) {
// Hide the error message.
$backupMessage.addClass( 'hidden' );
} else {
// Show the error message.
$backupMessage.removeClass( 'hidden' );
}
}
} );
return;
}

Expand All @@ -113,11 +130,81 @@ window.imagify = window.imagify || {
cancelButtonText: imagifyAdmin.labels.swalCancel,
reverseButtons: true
} ).then(
function() {},
function() {
// Leave it unchecked, hide the error message.
$backupMessage.addClass( 'hidden' );
},
function() {
// Re-check.
$_this.prop( 'checked', true );
}
);
} );

} )(jQuery, document, window);


// "Select all" checkboxes =========================================================================
(function( w, d, $, undefined ) {

var jqPropHookChecked = $.propHooks.checked;

// Force `.prop()` to trigger a `change` event.
$.propHooks.checked = {
set: function( elem, value, name ) {
var ret;

if ( undefined === jqPropHookChecked ) {
ret = ( elem[ name ] = value );
} else {
ret = jqPropHookChecked( elem, value, name );
}

$( elem ).trigger( 'change.imagify' );

return ret;
}
};

// Check all checkboxes.
$( '.imagify-check-group .imagify-row-check' ).on( 'click', function() {
var $group = $( this ).closest( '.imagify-check-group' ),
allChecked = 0 === $group.find( '.imagify-row-check' ).filter( ':visible:enabled' ).not( ':checked' ).length;

// Toggle "check all" checkboxes.
$group.find( '.imagify-toggle-check' ).prop( 'checked', allChecked );
} )
.first().trigger( 'change.imagify' );

$( '.imagify-check-group .imagify-toggle-check' ).on( 'click.wp-toggle-checkboxes', function( e ) {
var $this = $( this ),
$wrap = $this.closest( '.imagify-check-group' ),
controlChecked = $this.prop( 'checked' ),
toggle = e.shiftKey || $this.data( 'wp-toggle' );

$wrap.find( '.imagify-toggle-check' )
.prop( 'checked', function() {
var $this = $( this );

if ( $this.is( ':hidden,:disabled' ) ) {
return false;
}

if ( toggle ) {
return ! $this.prop( 'checked' );
}

return controlChecked ? true : false;
} );

$wrap.find( '.imagify-row-check' )
.prop( 'checked', function() {
if ( toggle ) {
return false;
}

return controlChecked ? true : false;
} );
} );

} )(window, document, jQuery);
Loading

0 comments on commit 7c61d71

Please sign in to comment.