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( $ ) {
$( '#customize-control-featured-content-tag-name input' ).suggest( ajaxurl + '?action=ajax-tag-search&tax=post_tag', { delay: 500, minchars: 2 } );
} );

View File

@ -66,14 +66,15 @@
* image and we are not on mobile.
*/
if ( _window.width() > 781 ) {
var mastheadHeight = $( '#masthead' ).height();
var mastheadHeight = $( '#masthead' ).height(),
toolbarOffset, mastheadOffset;
if ( mastheadHeight > 48 ) {
body.removeClass( 'masthead-fixed' );
}
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;
_window.on( 'scroll.twentyfourteen', function() {

View File

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