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 = $( '