Twenty Fourteen: changes to JavaScript files to pass `jshint`, props jorbin. Fixes #25908 #25909 #25910.

* Add global variable flags to top of JS files.
 * Group variable declarations correctly.
Built from https://develop.svn.wordpress.org/trunk@26084


git-svn-id: http://core.svn.wordpress.org/trunk@26004 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2013-11-11 17:27:11 +00:00
parent 4517d7b729
commit a1036ac9f0
3 changed files with 40 additions and 24 deletions

View File

@ -1,3 +1,4 @@
/* global ajaxurl:true */
jQuery( function( $ ) { jQuery( function( $ ) {
$( '#customize-control-featured-content-tag-name input' ).suggest( ajaxurl + '?action=ajax-tag-search&tax=post_tag', { delay: 500, minchars: 2 } ); $( '#customize-control-featured-content-tag-name input' ).suggest( ajaxurl + '?action=ajax-tag-search&tax=post_tag', { delay: 500, minchars: 2 } );
} ); } );

View File

@ -66,15 +66,16 @@
* image and we are not on mobile. * image and we are not on mobile.
*/ */
if ( _window.width() > 781 ) { if ( _window.width() > 781 ) {
var mastheadHeight = $( '#masthead' ).height(); var mastheadHeight = $( '#masthead' ).height(),
toolbarOffset, mastheadOffset;
if ( mastheadHeight > 48 ) { if ( mastheadHeight > 48 ) {
body.removeClass( 'masthead-fixed' ); body.removeClass( 'masthead-fixed' );
} }
if ( body.is( '.header-image' ) ) { if ( body.is( '.header-image' ) ) {
var toolbarOffset = body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0, toolbarOffset = body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset; mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset;
_window.on( 'scroll.twentyfourteen', function() { _window.on( 'scroll.twentyfourteen', function() {
if ( ( window.scrollY > mastheadOffset ) && ( mastheadHeight < 49 ) ) { if ( ( window.scrollY > mastheadOffset ) && ( mastheadHeight < 49 ) ) {

View File

@ -1,3 +1,4 @@
/* global DocumentTouch:true,setImmediate:true,featuredSliderDefaults:true,MSGesture:true */
/* /*
* Twenty Fourteen Featured Content Slider * Twenty Fourteen Featured Content Slider
* *
@ -8,18 +9,19 @@
( function( $ ) { ( function( $ ) {
// FeaturedSlider: object instance. // FeaturedSlider: object instance.
$.featuredslider = function( el, options ) { $.featuredslider = function( el, options ) {
var slider = $( el ); var slider = $( el ),
// Make variables public.
slider.vars = $.extend( {}, $.featuredslider.defaults, options );
var namespace = slider.vars.namespace,
msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture, msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture,
touch = ( ( 'ontouchstart' in window ) || msGesture || window.DocumentTouch && document instanceof DocumentTouch ), // MSFT specific. touch = ( ( 'ontouchstart' in window ) || msGesture || window.DocumentTouch && document instanceof DocumentTouch ), // MSFT specific.
eventType = 'click touchend MSPointerUp', eventType = 'click touchend MSPointerUp',
watchedEvent = '', watchedEvent = '',
watchedEventClearTimer, watchedEventClearTimer,
methods = {}; methods = {},
namespace;
// Make variables public.
slider.vars = $.extend( {}, $.featuredslider.defaults, options );
namespace = slider.vars.namespace,
// Store a reference to the slider object. // Store a reference to the slider object.
$.data( el, 'featuredslider', slider ); $.data( el, 'featuredslider', slider );
@ -40,8 +42,10 @@
// TOUCH // TOUCH
slider.transitions = ( function() { slider.transitions = ( function() {
var obj = document.createElement( 'div' ), var obj = document.createElement( 'div' ),
props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']; props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'],
for ( var i in props ) { i;
for ( i in props ) {
if ( obj.style[ props[i] ] !== undefined ) { if ( obj.style[ props[i] ] !== undefined ) {
slider.pfx = props[i].replace( 'Perspective', '' ).toLowerCase(); slider.pfx = props[i].replace( 'Perspective', '' ).toLowerCase();
slider.prop = '-' + slider.pfx + '-transform'; slider.prop = '-' + slider.pfx + '-transform';
@ -69,9 +73,15 @@
// KEYBOARD // KEYBOARD
if ( $( slider.containerSelector ).length === 1 ) { if ( $( slider.containerSelector ).length === 1 ) {
$( document ).bind( 'keyup', function( event ) { $( document ).bind( 'keyup', function( event ) {
var keycode = event.keyCode; var keycode = event.keyCode,
target = false;
if ( ! slider.animating && ( keycode === 39 || keycode === 37 ) ) { if ( ! slider.animating && ( keycode === 39 || keycode === 37 ) ) {
var target = ( keycode === 39 ) ? slider.getTarget( 'next' ) : ( keycode === 37 ) ? slider.getTarget( 'prev' ) : false; if (keycode === 39){
target = slider.getTarget( 'next' );
} else if (keycode === 37) {
target = slider.getTarget( 'prev' );
}
slider.featureAnimate( target ); slider.featureAnimate( target );
} }
} ); } );
@ -95,12 +105,13 @@
var type = 'control-paging', var type = 'control-paging',
j = 1, j = 1,
item, item,
slide; slide,
i;
slider.controlNavScaffold = $( '<ol class="' + namespace + 'control-nav ' + namespace + type + '"></ol>' ); slider.controlNavScaffold = $( '<ol class="' + namespace + 'control-nav ' + namespace + type + '"></ol>' );
if ( slider.pagingCount > 1 ) { if ( slider.pagingCount > 1 ) {
for ( var i = 0; i < slider.pagingCount; i++ ) { for ( i = 0; i < slider.pagingCount; i++ ) {
slide = slider.slides.eq( i ); slide = slider.slides.eq( i );
item = '<a>' + j + '</a>'; item = '<a>' + j + '</a>';
slider.controlNavScaffold.append( '<li>' + item + '</li>' ); slider.controlNavScaffold.append( '<li>' + item + '</li>' );
@ -293,13 +304,15 @@
function onMSGestureChange( e ) { function onMSGestureChange( e ) {
e.stopPropagation(); e.stopPropagation();
var slider = e.target._slider; var slider = e.target._slider,
transX,
transY;
if ( ! slider ) { if ( ! slider ) {
return; return;
} }
var transX = -e.translationX, transX = -e.translationX,
transY = -e.translationY; transY = -e.translationY;
// Accumulate translations. // Accumulate translations.
accDx = accDx + transX; accDx = accDx + transX;
@ -324,14 +337,16 @@
function onMSGestureEnd( e ) { function onMSGestureEnd( e ) {
e.stopPropagation(); e.stopPropagation();
var slider = e.target._slider; var slider = e.target._slider,
updateDx,
target;
if ( ! slider ) { if ( ! slider ) {
return; return;
} }
if ( slider.animatingTo === slider.currentSlide && ! scrolling && dx !== null ) { if ( slider.animatingTo === slider.currentSlide && ! scrolling && dx !== null ) {
var updateDx = dx, updateDx = dx,
target = ( updateDx > 0 ) ? slider.getTarget( 'next' ) : slider.getTarget( 'prev' ); target = ( updateDx > 0 ) ? slider.getTarget( 'next' ) : slider.getTarget( 'prev' );
slider.featureAnimate( target ); slider.featureAnimate( target );
} }
@ -440,8 +455,7 @@
slider.setProps = function( pos, special, dur ) { slider.setProps = function( pos, special, dur ) {
var target = ( function() { var target = ( function() {
var posCheck = ( pos ) ? pos : slider.itemW * slider.animatingTo, var posCalc = ( function() {
posCalc = ( function() {
switch ( special ) { switch ( special ) {
case 'setTotal': return ( slider.currentSlide + slider.cloneOffset ) * pos; case 'setTotal': return ( slider.currentSlide + slider.cloneOffset ) * pos;
case 'setTouch': return pos; case 'setTouch': return pos;