From 4f17571b3f43ccc75e0b4510107e32816c725e73 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 15 Nov 2013 14:16:08 +0000 Subject: [PATCH] Fix JSHint errors in theme-install.js. props kovshenin. fixes #26045. Built from https://develop.svn.wordpress.org/trunk@26210 git-svn-id: http://core.svn.wordpress.org/trunk@26118 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/theme-install.js | 70 +++++++++++++++++++------------- wp-admin/js/theme-install.min.js | 2 +- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/wp-admin/js/theme-install.js b/wp-admin/js/theme-install.js index 0899ab72f0..ed7d775c1c 100644 --- a/wp-admin/js/theme-install.js +++ b/wp-admin/js/theme-install.js @@ -1,3 +1,7 @@ +/* global ajaxurl, list_args, theme_list_args */ + +var theme_viewer; + /** * Theme Browsing * @@ -28,16 +32,18 @@ jQuery(document).ready( function($) { tb_position = function() { var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 1040 < width ) ? 1040 : width, adminbar_height = 0; - if ( $('body.admin-bar').length ) + if ( $('body.admin-bar').length ) { adminbar_height = 28; + } if ( tbWindow.size() ) { tbWindow.width( W - 50 ).height( H - 45 - adminbar_height ); $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height ); tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'}); - if ( typeof document.body.style.maxWidth != 'undefined' ) + if ( typeof document.body.style.maxWidth !== 'undefined' ) { tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'}); - }; + } + } }; $(window).resize(function(){ tb_position(); }); @@ -49,8 +55,9 @@ jQuery(document).ready( function($) { * Displays theme previews on theme install pages. */ jQuery( function($) { - if( ! window.postMessage ) + if ( ! window.postMessage ) { return; + } var preview = $('#theme-installer'), info = preview.find('.install-theme-info'), @@ -86,7 +93,7 @@ jQuery( function($) { var ThemeViewer; (function($){ - ThemeViewer = function( args ) { + ThemeViewer = function() { function init() { $( '#filter-click, #mini-filter-click' ).unbind( 'click' ).click( function() { @@ -100,13 +107,15 @@ var ThemeViewer; var count = $( '#filter-box :checked' ).length, text = $( '#filter-click' ).text(); - if ( text.indexOf( '(' ) != -1 ) + if ( text.indexOf( '(' ) !== -1 ) { text = text.substr( 0, text.indexOf( '(' ) ); + } - if ( count == 0 ) + if ( count === 0 ) { $( '#filter-click' ).text( text ); - else + } else { $( '#filter-click' ).text( text + ' (' + count + ')' ); + } }); /* $('#filter-box :submit').unbind( 'click' ).click(function() { @@ -130,11 +139,11 @@ var ThemeViewer; init: init }; - return api; - } + return api; + }; })(jQuery); -jQuery( document ).ready( function($) { +jQuery( document ).ready( function() { theme_viewer = new ThemeViewer(); theme_viewer.init(); }); @@ -169,9 +178,10 @@ var ThemeScroller; // Get out early if we don't have the required arguments. if ( typeof ajaxurl === 'undefined' || - typeof list_args === 'undefined' || - typeof theme_list_args === 'undefined' ) { - $('.pagination-links').show(); + typeof list_args === 'undefined' || + typeof theme_list_args === 'undefined' ) { + + $('.pagination-links').show(); return; } @@ -189,11 +199,11 @@ var ThemeScroller; * If there are more pages to query, then start polling to track * when user hits the bottom of the current page */ - if ( theme_list_args.total_pages >= this.nextPage ) - this.pollInterval = - setInterval( function() { - return self.poll(); - }, this.scrollPollingDelay ); + if ( theme_list_args.total_pages >= this.nextPage ) { + this.pollInterval = setInterval( function() { + return self.poll(); + }, this.scrollPollingDelay ); + } }, /** @@ -207,8 +217,9 @@ var ThemeScroller; var bottom = this.$document.scrollTop() + this.$window.innerHeight(); if ( this.querying || - ( bottom < this.$outList.height() - this.outListBottomThreshold ) ) + ( bottom < this.$outList.height() - this.outListBottomThreshold ) ) { return; + } this.ajax(); }, @@ -227,11 +238,13 @@ var ThemeScroller; return; } - if ( this.nextPage > theme_list_args.total_pages ) + if ( this.nextPage > theme_list_args.total_pages ) { clearInterval( this.pollInterval ); + } - if ( this.nextPage <= ( theme_list_args.total_pages + 1 ) ) + if ( this.nextPage <= ( theme_list_args.total_pages + 1 ) ) { this.$outList.append( results.rows ); + } }, /** @@ -241,11 +254,8 @@ var ThemeScroller; * @access private */ ajax: function() { - var self = this; - - this.querying = true; - - var query = { + var self = this, + query = { action: 'fetch-list', paged: this.nextPage, s: theme_list_args.search, @@ -256,6 +266,8 @@ var ThemeScroller; 'list_args': list_args }; + this.querying = true; + this.$spinner.show(); $.getJSON( ajaxurl, query ) .done( function( response ) { @@ -270,9 +282,9 @@ var ThemeScroller; setTimeout( function() { self.ajax(); }, self.failedRetryDelay ); }); } - } + }; - $(document).ready( function($) { + $(document).ready( function() { ThemeScroller.init(); }); diff --git a/wp-admin/js/theme-install.min.js b/wp-admin/js/theme-install.min.js index fca2ab6a79..e65c1a863c 100644 --- a/wp-admin/js/theme-install.min.js +++ b/wp-admin/js/theme-install.min.js @@ -1 +1 @@ -jQuery(function(a){a("#availablethemes").on("click",".theme-detail",function(b){var c=a(this).closest(".available-theme"),d=c.find(".themedetaildiv");d.length||(d=c.find(".install-theme-info .theme-details"),d=d.clone().addClass("themedetaildiv").appendTo(c).hide()),d.toggle(),b.preventDefault()})});var tb_position;jQuery(document).ready(function(a){tb_position=function(){var b=a("#TB_window"),c=a(window).width(),d=a(window).height(),e=c>1040?1040:c,f=0;a("body.admin-bar").length&&(f=28),b.size()&&(b.width(e-50).height(d-45-f),a("#TB_iframeContent").width(e-50).height(d-75-f),b.css({"margin-left":"-"+parseInt((e-50)/2,10)+"px"}),"undefined"!=typeof document.body.style.maxWidth&&b.css({top:20+f+"px","margin-top":"0"}))},a(window).resize(function(){tb_position()})}),jQuery(function(a){if(window.postMessage){var b=a("#theme-installer"),c=b.find(".install-theme-info"),d=b.find(".wp-full-overlay-main"),e=a(document.body);b.on("click",".close-full-overlay",function(a){b.fadeOut(200,function(){d.empty(),e.removeClass("theme-installer-active full-overlay-active")}),a.preventDefault()}),b.on("click",".collapse-sidebar",function(a){b.toggleClass("collapsed").toggleClass("expanded"),a.preventDefault()}),a("#availablethemes").on("click",".install-theme-preview",function(f){var g;c.html(a(this).closest(".installable-theme").find(".install-theme-info").html()),g=c.find(".theme-preview-url").val(),d.html('