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
This commit is contained in:
Andrew Nacin 2013-11-15 14:16:08 +00:00
parent a66b92af4c
commit 4f17571b3f
2 changed files with 42 additions and 30 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() {
@ -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();
});

View File

@ -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('<iframe src="'+g+'" />'),b.fadeIn(200,function(){e.addClass("theme-installer-active full-overlay-active")}),f.preventDefault()})}});var ThemeViewer;!function(a){ThemeViewer=function(){function b(){a("#filter-click, #mini-filter-click").unbind("click").click(function(){return a("#filter-click").toggleClass("current"),a("#filter-box").slideToggle(),a("#current-theme").slideToggle(300),!1}),a("#filter-box :checkbox").unbind("click").click(function(){var b=a("#filter-box :checked").length,c=a("#filter-click").text();-1!=c.indexOf("(")&&(c=c.substr(0,c.indexOf("("))),0==b?a("#filter-click").text(c):a("#filter-click").text(c+" ("+b+")")})}var c={init:b};return c}}(jQuery),jQuery(document).ready(function(){theme_viewer=new ThemeViewer,theme_viewer.init()});var ThemeScroller;!function(a){ThemeScroller={querying:!1,scrollPollingDelay:500,failedRetryDelay:4e3,outListBottomThreshold:300,init:function(){var b=this;return"undefined"==typeof ajaxurl||"undefined"==typeof list_args||"undefined"==typeof theme_list_args?(a(".pagination-links").show(),void 0):(this.nonce=a("#_ajax_fetch_list_nonce").val(),this.nextPage=theme_list_args.paged+1,this.$outList=a("#availablethemes"),this.$spinner=a("div.tablenav.bottom").children(".spinner"),this.$window=a(window),this.$document=a(document),theme_list_args.total_pages>=this.nextPage&&(this.pollInterval=setInterval(function(){return b.poll()},this.scrollPollingDelay)),void 0)},poll:function(){var a=this.$document.scrollTop()+this.$window.innerHeight();this.querying||a<this.$outList.height()-this.outListBottomThreshold||this.ajax()},process:function(a){return void 0===a?(clearInterval(this.pollInterval),void 0):(this.nextPage>theme_list_args.total_pages&&clearInterval(this.pollInterval),this.nextPage<=theme_list_args.total_pages+1&&this.$outList.append(a.rows),void 0)},ajax:function(){var b=this;this.querying=!0;var c={action:"fetch-list",paged:this.nextPage,s:theme_list_args.search,tab:theme_list_args.tab,type:theme_list_args.type,_ajax_fetch_list_nonce:this.nonce,"features[]":theme_list_args.features,list_args:list_args};this.$spinner.show(),a.getJSON(ajaxurl,c).done(function(a){b.nextPage++,b.process(a),b.$spinner.hide(),b.querying=!1}).fail(function(){b.$spinner.hide(),b.querying=!1,setTimeout(function(){b.ajax()},b.failedRetryDelay)})}},a(document).ready(function(){ThemeScroller.init()})}(jQuery);
var theme_viewer;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('<iframe src="'+g+'" />'),b.fadeIn(200,function(){e.addClass("theme-installer-active full-overlay-active")}),f.preventDefault()})}});var ThemeViewer;!function(a){ThemeViewer=function(){function b(){a("#filter-click, #mini-filter-click").unbind("click").click(function(){return a("#filter-click").toggleClass("current"),a("#filter-box").slideToggle(),a("#current-theme").slideToggle(300),!1}),a("#filter-box :checkbox").unbind("click").click(function(){var b=a("#filter-box :checked").length,c=a("#filter-click").text();-1!==c.indexOf("(")&&(c=c.substr(0,c.indexOf("("))),0===b?a("#filter-click").text(c):a("#filter-click").text(c+" ("+b+")")})}var c={init:b};return c}}(jQuery),jQuery(document).ready(function(){theme_viewer=new ThemeViewer,theme_viewer.init()});var ThemeScroller;!function(a){ThemeScroller={querying:!1,scrollPollingDelay:500,failedRetryDelay:4e3,outListBottomThreshold:300,init:function(){var b=this;return"undefined"==typeof ajaxurl||"undefined"==typeof list_args||"undefined"==typeof theme_list_args?(a(".pagination-links").show(),void 0):(this.nonce=a("#_ajax_fetch_list_nonce").val(),this.nextPage=theme_list_args.paged+1,this.$outList=a("#availablethemes"),this.$spinner=a("div.tablenav.bottom").children(".spinner"),this.$window=a(window),this.$document=a(document),theme_list_args.total_pages>=this.nextPage&&(this.pollInterval=setInterval(function(){return b.poll()},this.scrollPollingDelay)),void 0)},poll:function(){var a=this.$document.scrollTop()+this.$window.innerHeight();this.querying||a<this.$outList.height()-this.outListBottomThreshold||this.ajax()},process:function(a){return void 0===a?(clearInterval(this.pollInterval),void 0):(this.nextPage>theme_list_args.total_pages&&clearInterval(this.pollInterval),this.nextPage<=theme_list_args.total_pages+1&&this.$outList.append(a.rows),void 0)},ajax:function(){var b=this,c={action:"fetch-list",paged:this.nextPage,s:theme_list_args.search,tab:theme_list_args.tab,type:theme_list_args.type,_ajax_fetch_list_nonce:this.nonce,"features[]":theme_list_args.features,list_args:list_args};this.querying=!0,this.$spinner.show(),a.getJSON(ajaxurl,c).done(function(a){b.nextPage++,b.process(a),b.$spinner.hide(),b.querying=!1}).fail(function(){b.$spinner.hide(),b.querying=!1,setTimeout(function(){b.ajax()},b.failedRetryDelay)})}},a(document).ready(function(){ThemeScroller.init()})}(jQuery);