From 3d0c903bfdc40461ae80b072699987d1fa3a2992 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 15 Nov 2013 23:18:18 +0000 Subject: [PATCH] Fix JSHint errors in three files. props tommcfarlin. fixes #25942, #25943, #25944. git-svn-id: https://develop.svn.wordpress.org/trunk@26232 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/dashboard.js | 38 ++++++++++++++++++++------------ src/wp-admin/js/media-gallery.js | 1 + src/wp-admin/js/theme-preview.js | 17 ++++++++------ 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/wp-admin/js/dashboard.js b/src/wp-admin/js/dashboard.js index 93473dbb5f..a8d119d1c2 100644 --- a/src/wp-admin/js/dashboard.js +++ b/src/wp-admin/js/dashboard.js @@ -1,11 +1,11 @@ -/* global pagenow */ +/* global pagenow, ajaxurl, postboxes, wpActiveEditor:true */ var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad; jQuery(document).ready( function($) { /* Dashboard Welcome Panel */ var welcomePanel = $('#welcome-panel'), welcomePanelHide = $('#wp_welcome_panel-hide'), - updateWelcomePanel = function( visible ) { + updateWelcomePanel = function( visible ) { $.post( ajaxurl, { action: 'update-welcome-panel', visible: visible, @@ -13,8 +13,9 @@ jQuery(document).ready( function($) { }); }; - if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) + if ( welcomePanel.hasClass('hidden') && welcomePanelHide.prop('checked') ) { welcomePanel.removeClass('hidden'); + } $('.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) { e.preventDefault(); @@ -48,8 +49,9 @@ jQuery(document).ready( function($) { if ( el ) { el = el.toString(); - if ( $.inArray(el, ajaxWidgets) != -1 ) + if ( $.inArray(el, ajaxWidgets) !== -1 ) { show(0, el); + } } else { $.each( ajaxWidgets, show ); } @@ -90,8 +92,9 @@ jQuery(document).ready( function($) { $('#title, #tags-input, #content').each( function() { var input = $(this), prompt = $('#' + this.id + '-prompt-text'); - if ( '' === this.value ) + if ( '' === this.value ) { prompt.removeClass('screen-reader-text'); + } prompt.click( function() { $(this).addClass('screen-reader-text'); @@ -99,8 +102,9 @@ jQuery(document).ready( function($) { }); input.blur( function() { - if ( '' === this.value ) + if ( '' === this.value ) { prompt.removeClass('screen-reader-text'); + } }); input.focus( function() { @@ -109,8 +113,8 @@ jQuery(document).ready( function($) { }); $('#quick-press').on( 'click focusin', function() { - $(this).addClass("quickpress-open"); - $("#description-wrap, p.submit").slideDown(200); + $(this).addClass('quickpress-open'); + $('#description-wrap, p.submit').slideDown(200); wpActiveEditor = 'content'; }); }; @@ -120,10 +124,10 @@ jQuery(document).ready( function($) { $( '.show-more a' ).on( 'click', function(e) { $( this ).fadeOut().closest('.activity-block').find( 'li.hidden' ).fadeIn().removeClass( 'hidden' ); e.preventDefault(); - }) + }); // Dashboard columns - jQuery(document).ready(function ($) { + jQuery(document).ready(function () { // Update main column count on load updateColumnCount(); }); @@ -134,13 +138,19 @@ jQuery(document).ready( function($) { function updateColumnCount() { var cols = 1, - windowWidth = parseInt(jQuery(window).width()); - if (799 < windowWidth && 1299 > windowWidth) + windowWidth = parseInt(jQuery(window).width(), 10); + + if (799 < windowWidth && 1299 > windowWidth) { cols = 2; - if (1300 < windowWidth && 1799 > windowWidth) + } + + if (1300 < windowWidth && 1799 > windowWidth) { cols = 3; - if (1800 < windowWidth) + } + + if (1800 < windowWidth) { cols = 4; + } jQuery('.metabox-holder').attr('class', jQuery('.metabox-holder').attr('class').replace(/columns-\d+/, 'columns-' + cols)); } diff --git a/src/wp-admin/js/media-gallery.js b/src/wp-admin/js/media-gallery.js index 38e4f7b481..52da393dcc 100644 --- a/src/wp-admin/js/media-gallery.js +++ b/src/wp-admin/js/media-gallery.js @@ -1,3 +1,4 @@ +/* global ajaxurl */ jQuery(function($){ $( 'body' ).bind( 'click.wp-gallery', function(e){ var target = $( e.target ), id, img_size; diff --git a/src/wp-admin/js/theme-preview.js b/src/wp-admin/js/theme-preview.js index b7959c501f..28d93cfc70 100644 --- a/src/wp-admin/js/theme-preview.js +++ b/src/wp-admin/js/theme-preview.js @@ -1,4 +1,4 @@ - +/* global tb_click */ var thickDims, tbWidth, tbHeight; jQuery(document).ready(function($) { @@ -12,28 +12,31 @@ jQuery(document).ready(function($) { tbWindow.width(w).height(h); $('#TB_iframeContent').width(w).height(h - 27); tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'}); - if ( typeof document.body.style.maxWidth != 'undefined' ) + if ( typeof document.body.style.maxWidth !== 'undefined' ) { tbWindow.css({'top':'30px','margin-top':'0'}); + } } }; thickDims(); - $(window).resize( function() { thickDims() } ); + $(window).resize( function() { thickDims(); } ); $('a.thickbox-preview').click( function() { tb_click.call(this); var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text; - if ( tbWidth = href.match(/&tbWidth=[0-9]+/) ) + if ( tbWidth = href.match(/&tbWidth=[0-9]+/) ) { tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10); - else + } else { tbWidth = $(window).width() - 90; + } - if ( tbHeight = href.match(/&tbHeight=[0-9]+/) ) + if ( tbHeight = href.match(/&tbHeight=[0-9]+/) ) { tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10); - else + } else { tbHeight = $(window).height() - 60; + } if ( alink.length ) { url = alink.attr('href') || '';