Fix JSHint errors in theme-install.js.

props kovshenin.
fixes #26045.


git-svn-id: https://develop.svn.wordpress.org/trunk@26210 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2013-11-15 14:15:39 +00:00
parent 92f9cc1d5f
commit 6597d9d43e
1 changed files with 41 additions and 29 deletions

View File

@ -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() {
@ -131,10 +140,10 @@ var ThemeViewer;
};
return api;
}
};
})(jQuery);
jQuery( document ).ready( function($) {
jQuery( document ).ready( function() {
theme_viewer = new ThemeViewer();
theme_viewer.init();
});
@ -171,6 +180,7 @@ var ThemeScroller;
if ( typeof ajaxurl === 'undefined' ||
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() {
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();
});