From 7ff0442a07d530690e991eac0508ada0f75607bc Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 6 Feb 2014 05:31:22 +0000 Subject: [PATCH] JSHint fixes for media-views and Gruntfile. props gcorne. fixes #27032, #27033. git-svn-id: https://develop.svn.wordpress.org/trunk@27105 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 2 +- src/wp-includes/js/media-views.js | 47 ++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 6354ab57ac..e8e1bc8dcb 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -305,7 +305,7 @@ module.exports = function(grunt) { files: { src: [ BUILD_DIR + '/**/*.js', - '!' + BUILD_DIR + '/wp-content/**/*.js', + '!' + BUILD_DIR + '/wp-content/**/*.js' ] } } diff --git a/src/wp-includes/js/media-views.js b/src/wp-includes/js/media-views.js index 745bf86f59..b30e7031de 100644 --- a/src/wp-includes/js/media-views.js +++ b/src/wp-includes/js/media-views.js @@ -44,8 +44,9 @@ sensitivity = sensitivity || 2000; if ( $.support.transition ) { - if ( ! (selector instanceof $) ) + if ( ! (selector instanceof $) ) { selector = $( selector ); + } // Resolve the deferred when the first element finishes animating. selector.first().one( $.support.transition.end, deferred.resolve ); @@ -216,7 +217,7 @@ * * @param {string} id * @returns {wp.media.controller.State} Returns a State model - * from the StateMachine collection + * from the StateMachine collection */ state: function( id ) { this.states = this.states || new Backbone.Collection(); @@ -269,7 +270,7 @@ * active state. * * @returns {wp.media.controller.State} Returns a State model - * from the StateMachine collection + * from the StateMachine collection */ lastState: function() { if ( this._lastState ) { @@ -535,11 +536,13 @@ }) ); } - if ( ! this.get('edge') ) + if ( ! this.get('edge') ) { this.set( 'edge', 120 ); + } - if ( ! this.get('gutter') ) + if ( ! this.get('gutter') ) { this.set( 'gutter', 8 ); + } this.resetDisplays(); }, @@ -893,8 +896,9 @@ var library = this.get('library'), edit = this.frame.state('gallery-edit').get('library'); - if ( this.editLibrary && this.editLibrary !== edit ) + if ( this.editLibrary && this.editLibrary !== edit ) { library.unobserve( this.editLibrary ); + } // Accepts attachments that exist in the original library and // that do not exist in gallery's library. @@ -1137,8 +1141,9 @@ if ( attributes.scanners.length ) { scanners = attributes.scanners = $.when.apply( $, attributes.scanners ); scanners.always( function() { - if ( embed.get('scanners') === scanners ) + if ( embed.get('scanners') === scanners ) { embed.set( 'loading', false ); + } }); } else { attributes.scanners = null; @@ -1829,10 +1834,11 @@ text: l10n.cancelGalleryTitle, priority: 20, click: function() { - if ( previous ) + if ( previous ) { frame.setState( previous ); - else + } else { frame.close(); + } } }, separateCancel: new media.View({ @@ -2495,8 +2501,9 @@ media.transition( $el ).done( function() { // Transition end events are subject to race conditions. // Make sure that the value is set as intended. - if ( '0' === $el.css('opacity') ) + if ( '0' === $el.css('opacity') ) { $el.hide(); + } }); } }); @@ -3023,8 +3030,9 @@ // value to the `model` and remove it from the `options object. _.each( this.defaults, function( def, key ) { var value = this.options[ key ]; - if ( _.isUndefined( value ) ) + if ( _.isUndefined( value ) ) { return; + } this.model.set( key, value ); delete this.options[ key ]; @@ -3491,8 +3499,9 @@ options.buttons = this.buttons; options.describe = this.controller.state().get('describe'); - if ( 'image' === options.type ) + if ( 'image' === options.type ) { options.size = this.imageSize(); + } options.can = {}; if ( options.nonces ) { @@ -3500,17 +3509,19 @@ options.can.save = !! options.nonces.update; } - if ( this.controller.state().get('allowLocalEdits') ) + if ( this.controller.state().get('allowLocalEdits') ) { options.allowLocalEdits = true; + } this.views.detach(); this.$el.html( this.template( options ) ); this.$el.toggleClass( 'uploading', options.uploading ); - if ( options.uploading ) + if ( options.uploading ) { this.$bar = this.$('.media-progress-bar div'); - else + } else { delete this.$bar; + } // Check if the model is selected. this.updateSelect(); @@ -4034,8 +4045,9 @@ }, refreshSortable: function() { - if ( ! this.options.sortable || ! $.fn.sortable ) + if ( ! this.options.sortable || ! $.fn.sortable ) { return; + } // If the `collection` has a `comparator`, disable sorting. var collection = this.collection, @@ -4387,8 +4399,9 @@ if ( ! this.collection.length ) { this.collection.more().done( function() { - if ( ! view.collection.length ) + if ( ! view.collection.length ) { view.createUploader(); + } }); } },