diff --git a/wp-content/themes/twentyfourteen/js/featured-content-admin.js b/wp-content/themes/twentyfourteen/js/featured-content-admin.js index 7283296389..4385fb5fc7 100644 --- a/wp-content/themes/twentyfourteen/js/featured-content-admin.js +++ b/wp-content/themes/twentyfourteen/js/featured-content-admin.js @@ -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 } ); } ); diff --git a/wp-content/themes/twentyfourteen/js/functions.js b/wp-content/themes/twentyfourteen/js/functions.js index 1527d02107..67c858e0eb 100644 --- a/wp-content/themes/twentyfourteen/js/functions.js +++ b/wp-content/themes/twentyfourteen/js/functions.js @@ -66,15 +66,16 @@ * 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, - mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset; + toolbarOffset = body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0; + mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset; _window.on( 'scroll.twentyfourteen', function() { if ( ( window.scrollY > mastheadOffset ) && ( mastheadHeight < 49 ) ) { diff --git a/wp-content/themes/twentyfourteen/js/slider.js b/wp-content/themes/twentyfourteen/js/slider.js index 8133223795..e2740869c2 100644 --- a/wp-content/themes/twentyfourteen/js/slider.js +++ b/wp-content/themes/twentyfourteen/js/slider.js @@ -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 = $( '
    ' ); 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 = '' + j + ''; slider.controlNavScaffold.append( '
  1. ' + item + '
  2. ' ); @@ -293,13 +304,15 @@ function onMSGestureChange( e ) { e.stopPropagation(); - var slider = e.target._slider; + var slider = e.target._slider, + transX, + transY; if ( ! slider ) { return; } - var transX = -e.translationX, - transY = -e.translationY; + transX = -e.translationX, + transY = -e.translationY; // Accumulate translations. accDx = accDx + transX; @@ -324,14 +337,16 @@ 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, - target = ( updateDx > 0 ) ? slider.getTarget( 'next' ) : slider.getTarget( 'prev' ); + 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;