windhamdavid 2 years ago
parent
commit
f5d90739f4
8 changed files with 827 additions and 0 deletions
  1. 16 0
      js/climatecontrol.js
  2. 38 0
      js/customizer.js
  3. 9 0
      js/featured-content-admin.js
  4. 128 0
      js/functions.js
  5. 7 0
      js/html5.js
  6. 10 0
      js/jquery.nivo.slider.pack.js
  7. 21 0
      js/keyboard-image-navigation.js
  8. 598 0
      js/slider.js

+ 16 - 0
js/climatecontrol.js

@@ -0,0 +1,16 @@
+$(document).ready( function() {
+	$('nav#primary-navigation .nav-menu > li').hover( function() {
+		if ( $(this).has('.sub-menu').length ) {
+			$('.sub-nav-back').addClass('show');
+		}
+	},
+	function() {
+		$('.sub-nav-back').removeClass('show');
+	});
+});
+$(window).load( function() {
+	$('#slider').nivoSlider({
+		directionNav: false,
+		controlNav: false,
+	});
+});

+ 38 - 0
js/customizer.js

@@ -0,0 +1,38 @@
+/**
+ * Twenty Fourteen Theme Customizer enhancements for a better user experience.
+ *
+ * Contains handlers to make Theme Customizer preview reload changes asynchronously.
+ */
+( function( $ ) {
+	// Site title and description.
+	wp.customize( 'blogname', function( value ) {
+		value.bind( function( to ) {
+			$( '.site-title a' ).text( to );
+		} );
+	} );
+	wp.customize( 'blogdescription', function( value ) {
+		value.bind( function( to ) {
+			$( '.site-description' ).text( to );
+		} );
+	} );
+	// Header text color.
+	wp.customize( 'header_textcolor', function( value ) {
+		value.bind( function( to ) {
+			if ( 'blank' === to ) {
+				$( '.site-title, .site-description' ).css( {
+					'clip': 'rect(1px, 1px, 1px, 1px)',
+					'position': 'absolute'
+				} );
+			} else {
+				$( '.site-title,  .site-description' ).css( {
+					'clip': 'auto',
+					'position': 'static'
+				} );
+
+				$( '.site-title a' ).css( {
+					'color': to
+				} );
+			}
+		} );
+	} );
+} )( jQuery );

+ 9 - 0
js/featured-content-admin.js

@@ -0,0 +1,9 @@
+/**
+ * Twenty Fourteen Featured Content admin behavior: add a tag suggestion
+ * when changing the tag.
+ */
+/* global ajaxurl:true */
+
+jQuery( document ).ready( function( $ ) {
+	$( '#customize-control-featured-content-tag-name input' ).suggest( ajaxurl + '?action=ajax-tag-search&tax=post_tag', { delay: 500, minchars: 2 } );
+});

+ 128 - 0
js/functions.js

@@ -0,0 +1,128 @@
+/**
+ * Theme functions file
+ *
+ * Contains handlers for navigation, accessibility, header sizing
+ * footer widgets and Featured Content slider
+ *
+ */
+( function( $ ) {
+	var body    = $( 'body' ),
+		_window = $( window );
+
+	// Enable menu toggle for small screens.
+	( function() {
+		var nav = $( '#primary-navigation' ), button, menu;
+		if ( ! nav ) {
+			return;
+		}
+
+		button = nav.find( '.menu-toggle' );
+		if ( ! button ) {
+			return;
+		}
+
+		// Hide button if menu is missing or empty.
+		menu = nav.find( '.nav-menu' );
+		if ( ! menu || ! menu.children().length ) {
+			button.hide();
+			return;
+		}
+
+		$( '.menu-toggle' ).on( 'click.twentyfourteen', function() {
+			nav.toggleClass( 'toggled-on' );
+		} );
+	} )();
+
+	/*
+	 * Makes "skip to content" link work correctly in IE9 and Chrome for better
+	 * accessibility.
+	 *
+	 * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
+	 */
+	_window.on( 'hashchange.twentyfourteen', function() {
+		var element = document.getElementById( location.hash.substring( 1 ) );
+
+		if ( element ) {
+			if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
+				element.tabIndex = -1;
+			}
+
+			element.focus();
+
+			// Repositions the window on jump-to-anchor to account for header height.
+			window.scrollBy( 0, -80 );
+		}
+	} );
+
+	$( function() {
+		// Search toggle.
+		$( '.search-toggle' ).on( 'click.twentyfourteen', function( event ) {
+			var that    = $( this ),
+				wrapper = $( '.search-box-wrapper' );
+
+			that.toggleClass( 'active' );
+			wrapper.toggleClass( 'hide' );
+
+			if ( that.is( '.active' ) || $( '.search-toggle .screen-reader-text' )[0] === event.target ) {
+				wrapper.find( '.search-field' ).focus();
+			}
+		} );
+
+		/*
+		 * Fixed header for large screen.
+		 * If the header becomes more than 48px tall, unfix the header.
+		 *
+		 * The callback on the scroll event is only added if there is a header
+		 * image and we are not on mobile.
+		 */
+		if ( _window.width() > 781 ) {
+			var mastheadHeight = $( '#masthead' ).height(),
+				toolbarOffset, mastheadOffset;
+
+			if ( mastheadHeight > 48 ) {
+				body.removeClass( 'masthead-fixed' );
+			}
+
+			if ( body.is( '.header-image' ) ) {
+				toolbarOffset  = body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
+				mastheadOffset = $( '#masthead' ).offset().top - toolbarOffset;
+
+				_window.on( 'scroll.twentyfourteen', function() {
+					if ( ( window.scrollY > mastheadOffset ) && ( mastheadHeight < 49 ) ) {
+						body.addClass( 'masthead-fixed' );
+					} else {
+						body.removeClass( 'masthead-fixed' );
+					}
+				} );
+			}
+		}
+
+		// Focus styles for menus.
+		$( '.primary-navigation, .secondary-navigation' ).find( 'a' ).on( 'focus.twentyfourteen blur.twentyfourteen', function() {
+			$( this ).parents().toggleClass( 'focus' );
+		} );
+	} );
+
+	// Arrange footer widgets vertically.
+	if ( $.isFunction( $.fn.masonry ) ) {
+		$( '#footer-sidebar' ).masonry( {
+			itemSelector: '.widget',
+			columnWidth: function( containerWidth ) {
+				return containerWidth / 4;
+			},
+			gutterWidth: 0,
+			isResizable: true,
+			isRTL: $( 'body' ).is( '.rtl' )
+		} );
+	}
+
+	// Initialize Featured Content slider.
+	_window.load( function() {
+		if ( body.is( '.slider' ) ) {
+			$( '.featured-content' ).featuredslider( {
+				selector: '.featured-content-inner > article',
+				controlsContainer: '.featured-content'
+			} );
+		}
+	} );
+} )( jQuery );

File diff suppressed because it is too large
+ 7 - 0
js/html5.js


File diff suppressed because it is too large
+ 10 - 0
js/jquery.nivo.slider.pack.js


+ 21 - 0
js/keyboard-image-navigation.js

@@ -0,0 +1,21 @@
+/**
+ * Twenty Fourteen keyboard support for image navigation.
+ */
+( function( $ ) {
+	$( document ).on( 'keydown.twentyfourteen', function( e ) {
+		var url = false;
+
+		// Left arrow key code.
+		if ( e.which === 37 ) {
+			url = $( '.previous-image a' ).attr( 'href' );
+
+		// Right arrow key code.
+		} else if ( e.which === 39 ) {
+			url = $( '.entry-attachment a' ).attr( 'href' );
+		}
+
+		if ( url && ( !$( 'textarea, input' ).is( ':focus' ) ) ) {
+			window.location = url;
+		}
+	} );
+} )( jQuery );

+ 598 - 0
js/slider.js

@@ -0,0 +1,598 @@
+/*
+ * Twenty Fourteen Featured Content Slider
+ *
+ * Adapted from FlexSlider v2.2.0, copyright 2012 WooThemes
+ * @link http://www.woothemes.com/flexslider/
+ */
+/* global DocumentTouch:true,setImmediate:true,featuredSliderDefaults:true,MSGesture:true */
+( function( $ ) {
+	// FeaturedSlider: object instance.
+	$.featuredslider = function( el, options ) {
+		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 = {},
+			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 );
+
+		// Private slider methods.
+		methods = {
+			init: function() {
+				slider.animating = false;
+				slider.currentSlide = 0;
+				slider.animatingTo = slider.currentSlide;
+				slider.atEnd = ( slider.currentSlide === 0 || slider.currentSlide === slider.last );
+				slider.containerSelector = slider.vars.selector.substr( 0, slider.vars.selector.search( ' ' ) );
+				slider.slides = $( slider.vars.selector, slider );
+				slider.container = $( slider.containerSelector, slider );
+				slider.count = slider.slides.length;
+				slider.prop = 'marginLeft';
+				slider.isRtl = $( 'body' ).hasClass( 'rtl' );
+				slider.args = {};
+				// TOUCH
+				slider.transitions = ( function() {
+					var obj = document.createElement( 'div' ),
+						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';
+							return true;
+						}
+					}
+					return false;
+				}() );
+				// CONTROLSCONTAINER
+				if ( slider.vars.controlsContainer !== '' ) {
+					slider.controlsContainer = $( slider.vars.controlsContainer ).length > 0 && $( slider.vars.controlsContainer );
+				}
+
+				slider.doMath();
+
+				// INIT
+				slider.setup( 'init' );
+
+				// CONTROLNAV
+				methods.controlNav.setup();
+
+				// DIRECTIONNAV
+				methods.directionNav.setup();
+
+				// KEYBOARD
+				if ( $( slider.containerSelector ).length === 1 ) {
+					$( document ).bind( 'keyup', function( event ) {
+						var keycode = event.keyCode,
+							target = false;
+						if ( ! slider.animating && ( keycode === 39 || keycode === 37 ) ) {
+							if ( keycode === 39 ) {
+								target = slider.getTarget( 'next' );
+							} else if ( keycode === 37 ) {
+								target = slider.getTarget( 'prev' );
+							}
+
+							slider.featureAnimate( target );
+						}
+					} );
+				}
+
+				// TOUCH
+				if ( touch ) {
+					methods.touch();
+				}
+
+				$( window ).bind( 'resize orientationchange focus', methods.resize );
+
+				slider.find( 'img' ).attr( 'draggable', 'false' );
+			},
+
+			controlNav: {
+				setup: function() {
+					methods.controlNav.setupPaging();
+				},
+				setupPaging: function() {
+					var type = 'control-paging',
+						j = 1,
+						item,
+						slide,
+						i;
+
+					slider.controlNavScaffold = $( '<ol class="' + namespace + 'control-nav ' + namespace + type + '"></ol>' );
+
+					if ( slider.pagingCount > 1 ) {
+						for ( i = 0; i < slider.pagingCount; i++ ) {
+							slide = slider.slides.eq( i );
+							item = '<a>' + j + '</a>';
+							slider.controlNavScaffold.append( '<li>' + item + '</li>' );
+							j++;
+						}
+					}
+
+					// CONTROLSCONTAINER
+					( slider.controlsContainer ) ? $( slider.controlsContainer ).append( slider.controlNavScaffold ) : slider.append( slider.controlNavScaffold );
+					methods.controlNav.set();
+
+					methods.controlNav.active();
+
+					slider.controlNavScaffold.delegate( 'a, img', eventType, function( event ) {
+						event.preventDefault();
+
+						if ( watchedEvent === '' || watchedEvent === event.type ) {
+							var $this = $( this ),
+								target = slider.controlNav.index( $this );
+
+							if ( ! $this.hasClass( namespace + 'active' ) ) {
+								slider.direction = ( target > slider.currentSlide ) ? 'next' : 'prev';
+								slider.featureAnimate( target );
+							}
+						}
+
+						// Set up flags to prevent event duplication.
+						if ( watchedEvent === '' ) {
+							watchedEvent = event.type;
+						}
+
+						methods.setToClearWatchedEvent();
+					} );
+				},
+				set: function() {
+					var selector = 'a';
+					slider.controlNav = $( '.' + namespace + 'control-nav li ' + selector, ( slider.controlsContainer ) ? slider.controlsContainer : slider );
+				},
+				active: function() {
+					slider.controlNav.removeClass( namespace + 'active' ).eq( slider.animatingTo ).addClass( namespace + 'active' );
+				},
+				update: function( action, pos ) {
+					if ( slider.pagingCount > 1 && action === 'add' ) {
+						slider.controlNavScaffold.append( $( '<li><a>' + slider.count + '</a></li>' ) );
+					} else if ( slider.pagingCount === 1 ) {
+						slider.controlNavScaffold.find( 'li' ).remove();
+					} else {
+						slider.controlNav.eq( pos ).closest( 'li' ).remove();
+					}
+					methods.controlNav.set();
+					( slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length ) ? slider.update( pos, action ) : methods.controlNav.active();
+				}
+			},
+
+			directionNav: {
+				setup: function() {
+					var directionNavScaffold = $( '<ul class="' + namespace + 'direction-nav"><li><a class="' + namespace + 'prev" href="#">' + slider.vars.prevText + '</a></li><li><a class="' + namespace + 'next" href="#">' + slider.vars.nextText + '</a></li></ul>' );
+
+					// CONTROLSCONTAINER
+					if ( slider.controlsContainer ) {
+						$( slider.controlsContainer ).append( directionNavScaffold );
+						slider.directionNav = $( '.' + namespace + 'direction-nav li a', slider.controlsContainer );
+					} else {
+						slider.append( directionNavScaffold );
+						slider.directionNav = $( '.' + namespace + 'direction-nav li a', slider );
+					}
+
+					methods.directionNav.update();
+
+					slider.directionNav.bind( eventType, function( event ) {
+						event.preventDefault();
+						var target;
+
+						if ( watchedEvent === '' || watchedEvent === event.type ) {
+							target = ( $( this ).hasClass( namespace + 'next' ) ) ? slider.getTarget( 'next' ) : slider.getTarget( 'prev' );
+							slider.featureAnimate( target );
+						}
+
+						// Set up flags to prevent event duplication.
+						if ( watchedEvent === '' ) {
+							watchedEvent = event.type;
+						}
+
+						methods.setToClearWatchedEvent();
+					} );
+				},
+				update: function() {
+					var disabledClass = namespace + 'disabled';
+					if ( slider.pagingCount === 1 ) {
+						slider.directionNav.addClass( disabledClass ).attr( 'tabindex', '-1' );
+					} else {
+						slider.directionNav.removeClass( disabledClass ).removeAttr( 'tabindex' );
+					}
+				}
+			},
+
+			touch: function() {
+				var startX,
+					startY,
+					offset,
+					cwidth,
+					dx,
+					startT,
+					scrolling = false,
+					localX = 0,
+					localY = 0,
+					accDx = 0;
+
+				if ( ! msGesture ) {
+					el.addEventListener( 'touchstart', onTouchStart, false );
+				} else {
+					el.style.msTouchAction = 'none';
+					el._gesture = new MSGesture(); // MSFT specific.
+					el._gesture.target = el;
+					el.addEventListener( 'MSPointerDown', onMSPointerDown, false );
+					el._slider = slider;
+					el.addEventListener( 'MSGestureChange', onMSGestureChange, false );
+					el.addEventListener( 'MSGestureEnd', onMSGestureEnd, false );
+				}
+
+				function onTouchStart( e ) {
+					if ( slider.animating ) {
+						e.preventDefault();
+					} else if ( ( window.navigator.msPointerEnabled ) || e.touches.length === 1 ) {
+						cwidth = slider.w;
+						startT = Number( new Date() );
+
+						// Local vars for X and Y points.
+						localX = e.touches[0].pageX;
+						localY = e.touches[0].pageY;
+
+						offset = ( slider.currentSlide + slider.cloneOffset ) * cwidth;
+						if ( slider.animatingTo === slider.last && slider.direction !== 'next' ) {
+							offset = 0;
+						}
+
+						startX = localX;
+						startY = localY;
+
+						el.addEventListener( 'touchmove', onTouchMove, false );
+						el.addEventListener( 'touchend', onTouchEnd, false );
+					}
+				}
+
+				function onTouchMove( e ) {
+					// Local vars for X and Y points.
+					localX = e.touches[0].pageX;
+					localY = e.touches[0].pageY;
+
+					dx = startX - localX;
+					scrolling = Math.abs( dx ) < Math.abs( localY - startY );
+
+					if ( ! scrolling ) {
+						e.preventDefault();
+						if ( slider.transitions ) {
+							slider.setProps( offset + dx, 'setTouch' );
+						}
+					}
+				}
+
+				function onTouchEnd() {
+					// Finish the touch by undoing the touch session.
+					el.removeEventListener( 'touchmove', onTouchMove, false );
+
+					if ( slider.animatingTo === slider.currentSlide && ! scrolling && dx !== null ) {
+						var updateDx = dx,
+							target = ( updateDx > 0 ) ? slider.getTarget( 'next' ) : slider.getTarget( 'prev' );
+
+						slider.featureAnimate( target );
+					}
+					el.removeEventListener( 'touchend', onTouchEnd, false );
+
+					startX = null;
+					startY = null;
+					dx = null;
+					offset = null;
+				}
+
+				function onMSPointerDown( e ) {
+					e.stopPropagation();
+					if ( slider.animating ) {
+						e.preventDefault();
+					} else {
+						el._gesture.addPointer( e.pointerId );
+						accDx = 0;
+						cwidth = slider.w;
+						startT = Number( new Date() );
+						offset = ( slider.currentSlide + slider.cloneOffset ) * cwidth;
+						if ( slider.animatingTo === slider.last && slider.direction !== 'next' ) {
+							offset = 0;
+						}
+					}
+				}
+
+				function onMSGestureChange( e ) {
+					e.stopPropagation();
+					var slider = e.target._slider,
+						transX,
+						transY;
+					if ( ! slider ) {
+						return;
+					}
+
+					transX = -e.translationX,
+					transY = -e.translationY;
+
+					// Accumulate translations.
+					accDx = accDx + transX;
+					dx = accDx;
+					scrolling = Math.abs( accDx ) < Math.abs( -transY );
+
+					if ( e.detail === e.MSGESTURE_FLAG_INERTIA ) {
+						setImmediate( function () { // MSFT specific.
+							el._gesture.stop();
+						} );
+
+						return;
+					}
+
+					if ( ! scrolling || Number( new Date() ) - startT > 500 ) {
+						e.preventDefault();
+						if ( slider.transitions ) {
+							slider.setProps( offset + dx, 'setTouch' );
+						}
+					}
+				}
+
+				function onMSGestureEnd( e ) {
+					e.stopPropagation();
+					var slider = e.target._slider,
+						updateDx,
+						target;
+					if ( ! slider ) {
+						return;
+					}
+
+					if ( slider.animatingTo === slider.currentSlide && ! scrolling && dx !== null ) {
+						updateDx = dx,
+						target = ( updateDx > 0 ) ? slider.getTarget( 'next' ) : slider.getTarget( 'prev' );
+
+						slider.featureAnimate( target );
+					}
+
+					startX = null;
+					startY = null;
+					dx = null;
+					offset = null;
+					accDx = 0;
+				}
+			},
+
+			resize: function() {
+				if ( ! slider.animating && slider.is( ':visible' ) ) {
+					slider.doMath();
+
+					// SMOOTH HEIGHT
+					methods.smoothHeight();
+					slider.newSlides.width( slider.computedW );
+					slider.setProps( slider.computedW, 'setTotal' );
+				}
+			},
+
+			smoothHeight: function( dur ) {
+				var $obj = slider.viewport;
+				( dur ) ? $obj.animate( { 'height': slider.slides.eq( slider.animatingTo ).height() }, dur ) : $obj.height( slider.slides.eq( slider.animatingTo ).height() );
+			},
+
+			setToClearWatchedEvent: function() {
+				clearTimeout( watchedEventClearTimer );
+				watchedEventClearTimer = setTimeout( function() {
+					watchedEvent = '';
+				}, 3000 );
+			}
+		};
+
+		// Public methods.
+		slider.featureAnimate = function( target ) {
+			if ( target !== slider.currentSlide ) {
+				slider.direction = ( target > slider.currentSlide ) ? 'next' : 'prev';
+			}
+
+			if ( ! slider.animating && slider.is( ':visible' ) ) {
+				slider.animating = true;
+				slider.animatingTo = target;
+
+				// CONTROLNAV
+				methods.controlNav.active();
+
+				slider.slides.removeClass( namespace + 'active-slide' ).eq( target ).addClass( namespace + 'active-slide' );
+
+				slider.atEnd = target === 0 || target === slider.last;
+
+				// DIRECTIONNAV
+				methods.directionNav.update();
+
+				var dimension = slider.computedW,
+					slideString;
+
+				if ( slider.currentSlide === 0 && target === slider.count - 1 && slider.direction !== 'next' ) {
+					slideString = 0;
+				} else if ( slider.currentSlide === slider.last && target === 0 && slider.direction !== 'prev' ) {
+					slideString = ( slider.count + 1 ) * dimension;
+				} else {
+					slideString = ( target + slider.cloneOffset ) * dimension;
+				}
+				slider.setProps( slideString, '', slider.vars.animationSpeed );
+				if ( slider.transitions ) {
+					if ( ! slider.atEnd ) {
+						slider.animating = false;
+						slider.currentSlide = slider.animatingTo;
+					}
+					slider.container.unbind( 'webkitTransitionEnd transitionend' );
+					slider.container.bind( 'webkitTransitionEnd transitionend', function() {
+						slider.wrapup( dimension );
+					} );
+				} else {
+					slider.container.animate( slider.args, slider.vars.animationSpeed, 'swing', function() {
+						slider.wrapup( dimension );
+					} );
+				}
+
+				// SMOOTH HEIGHT
+				methods.smoothHeight( slider.vars.animationSpeed );
+			}
+		};
+
+		slider.wrapup = function( dimension ) {
+			if ( slider.currentSlide === 0 && slider.animatingTo === slider.last ) {
+				slider.setProps( dimension, 'jumpEnd' );
+			} else if ( slider.currentSlide === slider.last && slider.animatingTo === 0 ) {
+				slider.setProps( dimension, 'jumpStart' );
+			}
+			slider.animating = false;
+			slider.currentSlide = slider.animatingTo;
+		};
+
+		slider.getTarget = function( dir ) {
+			slider.direction = dir;
+
+			// Swap for RTL.
+			if ( slider.isRtl ) {
+				dir = 'next' === dir ? 'prev' : 'next';
+			}
+
+			if ( dir === 'next' ) {
+				return ( slider.currentSlide === slider.last ) ? 0 : slider.currentSlide + 1;
+			} else {
+				return ( slider.currentSlide === 0 ) ? slider.last : slider.currentSlide - 1;
+			}
+		};
+
+		slider.setProps = function( pos, special, dur ) {
+			var target = ( function() {
+				var posCalc = ( function() {
+						switch ( special ) {
+							case 'setTotal': return ( slider.currentSlide + slider.cloneOffset ) * pos;
+							case 'setTouch': return pos;
+							case 'jumpEnd': return slider.count * pos;
+							case 'jumpStart': return pos;
+							default: return pos;
+						}
+					}() );
+
+					return ( posCalc * -1 ) + 'px';
+				}() );
+
+			if ( slider.transitions ) {
+				target = 'translate3d(' + target + ',0,0 )';
+				dur = ( dur !== undefined ) ? ( dur / 1000 ) + 's' : '0s';
+				slider.container.css( '-' + slider.pfx + '-transition-duration', dur );
+			}
+
+			slider.args[slider.prop] = target;
+			if ( slider.transitions || dur === undefined ) {
+				slider.container.css( slider.args );
+			}
+		};
+
+		slider.setup = function( type ) {
+			var sliderOffset;
+
+			if ( type === 'init' ) {
+				slider.viewport = $( '<div class="' + namespace + 'viewport"></div>' ).css( { 'overflow': 'hidden', 'position': 'relative' } ).appendTo( slider ).append( slider.container );
+				slider.cloneCount = 0;
+				slider.cloneOffset = 0;
+			}
+			slider.cloneCount = 2;
+			slider.cloneOffset = 1;
+			// Clear out old clones.
+			if ( type !== 'init' ) {
+				slider.container.find( '.clone' ).remove();
+			}
+
+			slider.container.append( slider.slides.first().clone().addClass( 'clone' ).attr( 'aria-hidden', 'true' ) ).prepend( slider.slides.last().clone().addClass( 'clone' ).attr( 'aria-hidden', 'true' ) );
+			slider.newSlides = $( slider.vars.selector, slider );
+
+			sliderOffset = slider.currentSlide + slider.cloneOffset;
+			slider.container.width( ( slider.count + slider.cloneCount ) * 200 + '%' );
+			slider.setProps( sliderOffset * slider.computedW, 'init' );
+			setTimeout( function() {
+				slider.doMath();
+				slider.newSlides.css( { 'width': slider.computedW, 'float': 'left', 'display': 'block' } );
+				// SMOOTH HEIGHT
+				methods.smoothHeight();
+			}, ( type === 'init' ) ? 100 : 0 );
+
+			slider.slides.removeClass( namespace + 'active-slide' ).eq( slider.currentSlide ).addClass( namespace + 'active-slide' );
+		};
+
+		slider.doMath = function() {
+			var slide = slider.slides.first();
+
+			slider.w = ( slider.viewport===undefined ) ? slider.width() : slider.viewport.width();
+			slider.h = slide.height();
+			slider.boxPadding = slide.outerWidth() - slide.width();
+
+			slider.itemW = slider.w;
+			slider.pagingCount = slider.count;
+			slider.last = slider.count - 1;
+			slider.computedW = slider.itemW - slider.boxPadding;
+		};
+
+		slider.update = function( pos, action ) {
+			slider.doMath();
+
+			// Update currentSlide and slider.animatingTo if necessary.
+			if ( pos < slider.currentSlide ) {
+				slider.currentSlide += 1;
+			} else if ( pos <= slider.currentSlide && pos !== 0 ) {
+				slider.currentSlide -= 1;
+			}
+			slider.animatingTo = slider.currentSlide;
+
+			// Update controlNav.
+			if ( action === 'add' || slider.pagingCount > slider.controlNav.length ) {
+				methods.controlNav.update( 'add' );
+			} else if ( action === 'remove' || slider.pagingCount < slider.controlNav.length ) {
+				if ( slider.currentSlide > slider.last ) {
+					slider.currentSlide -= 1;
+					slider.animatingTo -= 1;
+				}
+				methods.controlNav.update( 'remove', slider.last );
+			}
+			// Update directionNav.
+			methods.directionNav.update();
+		};
+
+		// FeaturedSlider: initialize.
+		methods.init();
+	};
+
+	// Default settings.
+	$.featuredslider.defaults = {
+		namespace: 'slider-',     // String: prefix string attached to the class of every element generated by the plugin.
+		selector: '.slides > li', // String: selector, must match a simple pattern.
+		animationSpeed: 600,      // Integer: Set the speed of animations, in milliseconds.
+		controlsContainer: '',    // jQuery Object/Selector: container navigation to append elements.
+
+		// Text labels.
+		prevText: featuredSliderDefaults.prevText, // String: Set the text for the "previous" directionNav item.
+		nextText: featuredSliderDefaults.nextText  // String: Set the text for the "next" directionNav item.
+	};
+
+	// FeaturedSlider: plugin function.
+	$.fn.featuredslider = function( options ) {
+		if ( options === undefined ) {
+			options = {};
+		}
+
+		if ( typeof options === 'object' ) {
+			return this.each( function() {
+				var $this = $( this ),
+					selector = ( options.selector ) ? options.selector : '.slides > li',
+					$slides = $this.find( selector );
+
+			if ( $slides.length === 1 || $slides.length === 0 ) {
+					$slides.fadeIn( 400 );
+				} else if ( $this.data( 'featuredslider' ) === undefined ) {
+					new $.featuredslider( this, options );
+				}
+			} );
+		}
+	};
+} )( jQuery );