Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** PLUGIN DIRECTORY
- What you can find in this file [listed in order they appear]
- 1.) FlexSlider Responsive Slider 2.1 - http://flexslider.woothemes.com/
- 2.) bxSlider v4.0 - http://bxslider.com
- 3.) jQuery imagesLoaded plugin 2.1.0 - http://github.com/desandro/imagesloaded
- 4.) fancyBox 2.0.5 - http://fancyapps.com/fancybox/
- 5.) jquery-placeholder 2.0.3 - https://github.com/mathiasbynens/jquery-placeholder
- 6.) Isotope Leak Free - https://github.com/khiltd/isotope-leak-free
- 7.) jquery.pjax.js - https://github.com/defunkt/jquery-pjax
- 8.) RefineSlide
- X.) Init scripts
- */
- /*
- * 1.) jQuery FlexSlider v2.1
- * @author: Muffin Man
- * Contributing author: Tyler Smith (@mbmufffin)
- */
- ;(function ($) {
- //FlexSlider: Object Instance
- $.flexslider = function(el, options) {
- var slider = $(el),
- vars = $.extend({}, $.flexslider.defaults, options),
- namespace = vars.namespace,
- touch = ("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch,
- eventType = (touch) ? "touchend" : "click",
- vertical = vars.direction === "vertical",
- reverse = vars.reverse,
- carousel = (vars.itemWidth > 0),
- fade = vars.animation === "fade",
- asNav = vars.asNavFor !== "",
- methods = {};
- // Store a reference to the slider object
- $.data(el, "flexslider", slider);
- // Privat slider methods
- methods = {
- init: function() {
- slider.animating = false;
- slider.currentSlide = vars.startAt;
- slider.animatingTo = slider.currentSlide;
- slider.atEnd = (slider.currentSlide === 0 || slider.currentSlide === slider.last);
- slider.containerSelector = vars.selector.substr(0,vars.selector.search(' '));
- slider.slides = $(vars.selector, slider);
- slider.container = $(slider.containerSelector, slider);
- slider.count = slider.slides.length;
- // SYNC:
- slider.syncExists = $(vars.sync).length > 0;
- // SLIDE:
- if (vars.animation === "slide") vars.animation = "swing";
- slider.prop = (vertical) ? "top" : "marginLeft";
- slider.args = {};
- // SLIDESHOW:
- slider.manualPause = false;
- // TOUCH/USECSS:
- slider.transitions = !vars.video && !fade && vars.useCSS && (function() {
- var obj = document.createElement('div'),
- props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
- for (var 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 (vars.controlsContainer !== "") slider.controlsContainer = $(vars.controlsContainer).length > 0 && $(vars.controlsContainer);
- // MANUAL:
- if (vars.manualControls !== "") slider.manualControls = $(vars.manualControls).length > 0 && $(vars.manualControls);
- // RANDOMIZE:
- if (vars.randomize) {
- slider.slides.sort(function() { return (Math.round(Math.random())-0.5); });
- slider.container.empty().append(slider.slides);
- }
- slider.doMath();
- // ASNAV:
- if (asNav) methods.asNav.setup();
- // INIT
- slider.setup("init");
- // CONTROLNAV:
- if (vars.controlNav) methods.controlNav.setup();
- // DIRECTIONNAV:
- if (vars.directionNav) methods.directionNav.setup();
- // KEYBOARD:
- if (vars.keyboard && ($(slider.containerSelector).length === 1 || vars.multipleKeyboard)) {
- $(document).bind('keyup', function(event) {
- var keycode = event.keyCode;
- if (!slider.animating && (keycode === 39 || keycode === 37)) {
- var target = (keycode === 39) ? slider.getTarget('next') :
- (keycode === 37) ? slider.getTarget('prev') : false;
- slider.flexAnimate(target, vars.pauseOnAction);
- }
- });
- }
- // MOUSEWHEEL:
- if (vars.mousewheel) {
- slider.bind('mousewheel', function(event, delta, deltaX, deltaY) {
- event.preventDefault();
- var target = (delta < 0) ? slider.getTarget('next') : slider.getTarget('prev');
- slider.flexAnimate(target, vars.pauseOnAction);
- });
- }
- // PAUSEPLAY
- if (vars.pausePlay) methods.pausePlay.setup();
- // SLIDSESHOW
- if (vars.slideshow) {
- if (vars.pauseOnHover) {
- slider.hover(function() {
- if (!slider.manualPlay && !slider.manualPause) slider.pause();
- }, function() {
- if (!slider.manualPause && !slider.manualPlay) slider.play();
- });
- }
- // initialize animation
- (vars.initDelay > 0) ? setTimeout(slider.play, vars.initDelay) : slider.play();
- }
- // TOUCH
- if (touch && vars.touch) methods.touch();
- // FADE&&SMOOTHHEIGHT || SLIDE:
- if (!fade || (fade && vars.smoothHeight)) $(window).bind("resize focus", methods.resize);
- // API: start() Callback
- setTimeout(function(){
- vars.start(slider);
- }, 200);
- },
- asNav: {
- setup: function() {
- slider.asNav = true;
- slider.animatingTo = Math.floor(slider.currentSlide/slider.move);
- slider.currentItem = slider.currentSlide;
- slider.slides.removeClass(namespace + "active-slide").eq(slider.currentItem).addClass(namespace + "active-slide");
- slider.slides.click(function(e){
- e.preventDefault();
- var $slide = $(this),
- target = $slide.index();
- if (!$(vars.asNavFor).data('flexslider').animating && !$slide.hasClass('active')) {
- slider.direction = (slider.currentItem < target) ? "next" : "prev";
- slider.flexAnimate(target, vars.pauseOnAction, false, true, true);
- }
- });
- }
- },
- controlNav: {
- setup: function() {
- if (!slider.manualControls) {
- methods.controlNav.setupPaging();
- } else { // MANUALCONTROLS:
- methods.controlNav.setupManual();
- }
- },
- setupPaging: function() {
- var type = (vars.controlNav === "thumbnails") ? 'control-thumbs' : 'control-paging',
- j = 1,
- item;
- slider.controlNavScaffold = $('<ol class="'+ namespace + 'control-nav ' + namespace + type + '"></ol>');
- if (slider.pagingCount > 1) {
- for (var i = 0; i < slider.pagingCount; i++) {
- item = (vars.controlNav === "thumbnails") ? '<img src="' + slider.slides.eq(i).attr("data-thumb") + '"/>' : '<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();
- var $this = $(this),
- target = slider.controlNav.index($this);
- if (!$this.hasClass(namespace + 'active')) {
- slider.direction = (target > slider.currentSlide) ? "next" : "prev";
- slider.flexAnimate(target, vars.pauseOnAction);
- }
- });
- // Prevent iOS click event bug
- if (touch) {
- slider.controlNavScaffold.delegate('a', "click touchstart", function(event) {
- event.preventDefault();
- });
- }
- },
- setupManual: function() {
- slider.controlNav = slider.manualControls;
- methods.controlNav.active();
- slider.controlNav.live(eventType, function(event) {
- event.preventDefault();
- var $this = $(this),
- target = slider.controlNav.index($this);
- if (!$this.hasClass(namespace + 'active')) {
- (target > slider.currentSlide) ? slider.direction = "next" : slider.direction = "prev";
- slider.flexAnimate(target, vars.pauseOnAction);
- }
- });
- // Prevent iOS click event bug
- if (touch) {
- slider.controlNav.live("click touchstart", function(event) {
- event.preventDefault();
- });
- }
- },
- set: function() {
- var selector = (vars.controlNav === "thumbnails") ? 'img' : '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="#">' + vars.prevText + '</a></li><li><a class="' + namespace + 'next" href="#">' + 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 = ($(this).hasClass(namespace + 'next')) ? slider.getTarget('next') : slider.getTarget('prev');
- slider.flexAnimate(target, vars.pauseOnAction);
- });
- // Prevent iOS click event bug
- if (touch) {
- slider.directionNav.bind("click touchstart", function(event) {
- event.preventDefault();
- });
- }
- },
- update: function() {
- var disabledClass = namespace + 'disabled';
- if (slider.pagingCount === 1) {
- slider.directionNav.addClass(disabledClass);
- } else if (!vars.animationLoop) {
- if (slider.animatingTo === 0) {
- slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "prev").addClass(disabledClass);
- } else if (slider.animatingTo === slider.last) {
- slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "next").addClass(disabledClass);
- } else {
- slider.directionNav.removeClass(disabledClass);
- }
- } else {
- slider.directionNav.removeClass(disabledClass);
- }
- }
- },
- pausePlay: {
- setup: function() {
- var pausePlayScaffold = $('<div class="' + namespace + 'pauseplay"><a></a></div>');
- // CONTROLSCONTAINER:
- if (slider.controlsContainer) {
- slider.controlsContainer.append(pausePlayScaffold);
- slider.pausePlay = $('.' + namespace + 'pauseplay a', slider.controlsContainer);
- } else {
- slider.append(pausePlayScaffold);
- slider.pausePlay = $('.' + namespace + 'pauseplay a', slider);
- }
- methods.pausePlay.update((vars.slideshow) ? namespace + 'pause' : namespace + 'play');
- slider.pausePlay.bind(eventType, function(event) {
- event.preventDefault();
- if ($(this).hasClass(namespace + 'pause')) {
- slider.manualPause = true;
- slider.manualPlay = false;
- slider.pause();
- } else {
- slider.manualPause = false;
- slider.manualPlay = true;
- slider.play();
- }
- });
- // Prevent iOS click event bug
- if (touch) {
- slider.pausePlay.bind("click touchstart", function(event) {
- event.preventDefault();
- });
- }
- },
- update: function(state) {
- (state === "play") ? slider.pausePlay.removeClass(namespace + 'pause').addClass(namespace + 'play').text(vars.playText) : slider.pausePlay.removeClass(namespace + 'play').addClass(namespace + 'pause').text(vars.pauseText);
- }
- },
- touch: function() {
- var startX,
- startY,
- offset,
- cwidth,
- dx,
- startT,
- scrolling = false;
- el.addEventListener('touchstart', onTouchStart, false);
- function onTouchStart(e) {
- if (slider.animating) {
- e.preventDefault();
- } else if (e.touches.length === 1) {
- slider.pause();
- // CAROUSEL:
- cwidth = (vertical) ? slider.h : slider. w;
- startT = Number(new Date());
- // CAROUSEL:
- offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
- (carousel && reverse) ? slider.limit - (((slider.itemW + vars.itemMargin) * slider.move) * slider.animatingTo) :
- (carousel && slider.currentSlide === slider.last) ? slider.limit :
- (carousel) ? ((slider.itemW + vars.itemMargin) * slider.move) * slider.currentSlide :
- (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
- startX = (vertical) ? e.touches[0].pageY : e.touches[0].pageX;
- startY = (vertical) ? e.touches[0].pageX : e.touches[0].pageY;
- el.addEventListener('touchmove', onTouchMove, false);
- el.addEventListener('touchend', onTouchEnd, false);
- }
- }
- function onTouchMove(e) {
- dx = (vertical) ? startX - e.touches[0].pageY : startX - e.touches[0].pageX;
- scrolling = (vertical) ? (Math.abs(dx) < Math.abs(e.touches[0].pageX - startY)) : (Math.abs(dx) < Math.abs(e.touches[0].pageY - startY));
- if (!scrolling || Number(new Date()) - startT > 500) {
- e.preventDefault();
- if (!fade && slider.transitions) {
- if (!vars.animationLoop) {
- dx = dx/((slider.currentSlide === 0 && dx < 0 || slider.currentSlide === slider.last && dx > 0) ? (Math.abs(dx)/cwidth+2) : 1);
- }
- slider.setProps(offset + dx, "setTouch");
- }
- }
- }
- function onTouchEnd(e) {
- if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
- var updateDx = (reverse) ? -dx : dx,
- target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');
- if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth/2)) {
- slider.flexAnimate(target, vars.pauseOnAction);
- } else {
- slider.flexAnimate(slider.currentSlide, vars.pauseOnAction, true);
- }
- }
- // finish the touch by undoing the touch session
- el.removeEventListener('touchmove', onTouchMove, false);
- el.removeEventListener('touchend', onTouchEnd, false);
- startX = null;
- startY = null;
- dx = null;
- offset = null;
- }
- },
- resize: function() {
- if (!slider.animating && slider.is(':visible')) {
- if (!carousel) slider.doMath();
- if (fade) {
- // SMOOTH HEIGHT:
- methods.smoothHeight();
- } else if (carousel) { //CAROUSEL:
- slider.slides.width(slider.computedW);
- slider.update(slider.pagingCount);
- slider.setProps();
- }
- else if (vertical) { //VERTICAL:
- slider.viewport.height(slider.h);
- slider.setProps(slider.h, "setTotal");
- } else {
- // SMOOTH HEIGHT:
- if (vars.smoothHeight) methods.smoothHeight();
- slider.newSlides.width(slider.computedW);
- slider.setProps(slider.computedW, "setTotal");
- }
- }
- },
- smoothHeight: function(dur) {
- if (!vertical || fade) {
- var $obj = (fade) ? slider : slider.viewport;
- (dur) ? $obj.animate({"height": slider.slides.eq(slider.animatingTo).height()}, dur) : $obj.height(slider.slides.eq(slider.animatingTo).height());
- }
- },
- sync: function(action) {
- var $obj = $(vars.sync).data("flexslider"),
- target = slider.animatingTo;
- switch (action) {
- case "animate": $obj.flexAnimate(target, vars.pauseOnAction, false, true); break;
- case "play": if (!$obj.playing && !$obj.asNav) { $obj.play(); } break;
- case "pause": $obj.pause(); break;
- }
- }
- };
- // public methods
- slider.flexAnimate = function(target, pause, override, withSync, fromNav) {
- if (asNav && slider.pagingCount === 1) slider.direction = (slider.currentItem < target) ? "next" : "prev";
- if (!slider.animating && (slider.canAdvance(target, fromNav) || override) && slider.is(":visible")) {
- if (asNav && withSync) {
- var master = $(vars.asNavFor).data('flexslider');
- slider.atEnd = target === 0 || target === slider.count - 1;
- master.flexAnimate(target, true, false, true, fromNav);
- slider.direction = (slider.currentItem < target) ? "next" : "prev";
- master.direction = slider.direction;
- if (Math.ceil((target + 1)/slider.visible) - 1 !== slider.currentSlide && target !== 0) {
- slider.currentItem = target;
- slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
- target = Math.floor(target/slider.visible);
- } else {
- slider.currentItem = target;
- slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
- return false;
- }
- }
- slider.animating = true;
- slider.animatingTo = target;
- // API: before() animation Callback
- vars.before(slider);
- // SLIDESHOW:
- if (pause) slider.pause();
- // SYNC:
- if (slider.syncExists && !fromNav) methods.sync("animate");
- // CONTROLNAV
- if (vars.controlNav) methods.controlNav.active();
- // !CAROUSEL:
- // CANDIDATE: slide active class (for add/remove slide)
- if (!carousel) slider.slides.removeClass(namespace + 'active-slide').eq(target).addClass(namespace + 'active-slide');
- // INFINITE LOOP:
- // CANDIDATE: atEnd
- slider.atEnd = target === 0 || target === slider.last;
- // DIRECTIONNAV:
- if (vars.directionNav) methods.directionNav.update();
- if (target === slider.last) {
- // API: end() of cycle Callback
- vars.end(slider);
- // SLIDESHOW && !INFINITE LOOP:
- if (!vars.animationLoop) slider.pause();
- }
- // SLIDE:
- if (!fade) {
- var dimension = (vertical) ? slider.slides.filter(':first').height() : slider.computedW,
- margin, slideString, calcNext;
- // INFINITE LOOP / REVERSE:
- if (carousel) {
- margin = (vars.itemWidth > slider.w) ? vars.itemMargin * 2 : vars.itemMargin;
- calcNext = ((slider.itemW + margin) * slider.move) * slider.animatingTo;
- slideString = (calcNext > slider.limit && slider.visible !== 1) ? slider.limit : calcNext;
- } else if (slider.currentSlide === 0 && target === slider.count - 1 && vars.animationLoop && slider.direction !== "next") {
- slideString = (reverse) ? (slider.count + slider.cloneOffset) * dimension : 0;
- } else if (slider.currentSlide === slider.last && target === 0 && vars.animationLoop && slider.direction !== "prev") {
- slideString = (reverse) ? 0 : (slider.count + 1) * dimension;
- } else {
- slideString = (reverse) ? ((slider.count - 1) - target + slider.cloneOffset) * dimension : (target + slider.cloneOffset) * dimension;
- }
- slider.setProps(slideString, "", vars.animationSpeed);
- if (slider.transitions) {
- if (!vars.animationLoop || !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, vars.animationSpeed, vars.easing, function(){
- slider.wrapup(dimension);
- });
- }
- } else { // FADE:
- slider.slides.eq(slider.currentSlide).fadeOut(vars.animationSpeed, vars.easing);
- slider.slides.eq(target).fadeIn(vars.animationSpeed, vars.easing, slider.wrapup);
- }
- // SMOOTH HEIGHT:
- if (vars.smoothHeight) methods.smoothHeight(vars.animationSpeed);
- }
- };
- slider.wrapup = function(dimension) {
- // SLIDE:
- if (!fade && !carousel) {
- if (slider.currentSlide === 0 && slider.animatingTo === slider.last && vars.animationLoop) {
- slider.setProps(dimension, "jumpEnd");
- } else if (slider.currentSlide === slider.last && slider.animatingTo === 0 && vars.animationLoop) {
- slider.setProps(dimension, "jumpStart");
- }
- }
- slider.animating = false;
- slider.currentSlide = slider.animatingTo;
- // API: after() animation Callback
- vars.after(slider);
- };
- // SLIDESHOW:
- slider.animateSlides = function() {
- if (!slider.animating) slider.flexAnimate(slider.getTarget("next"));
- };
- // SLIDESHOW:
- slider.pause = function() {
- clearInterval(slider.animatedSlides);
- slider.playing = false;
- // PAUSEPLAY:
- if (vars.pausePlay) methods.pausePlay.update("play");
- // SYNC:
- if (slider.syncExists) methods.sync("pause");
- };
- // SLIDESHOW:
- slider.play = function() {
- slider.animatedSlides = setInterval(slider.animateSlides, vars.slideshowSpeed);
- slider.playing = true;
- // PAUSEPLAY:
- if (vars.pausePlay) methods.pausePlay.update("pause");
- // SYNC:
- if (slider.syncExists) methods.sync("play");
- };
- slider.canAdvance = function(target, fromNav) {
- // ASNAV:
- var last = (asNav) ? slider.pagingCount - 1 : slider.last;
- return (fromNav) ? true :
- (asNav && slider.currentItem === slider.count - 1 && target === 0 && slider.direction === "prev") ? true :
- (asNav && slider.currentItem === 0 && target === slider.pagingCount - 1 && slider.direction !== "next") ? false :
- (target === slider.currentSlide && !asNav) ? false :
- (vars.animationLoop) ? true :
- (slider.atEnd && slider.currentSlide === 0 && target === last && slider.direction !== "next") ? false :
- (slider.atEnd && slider.currentSlide === last && target === 0 && slider.direction === "next") ? false :
- true;
- };
- slider.getTarget = function(dir) {
- slider.direction = dir;
- if (dir === "next") {
- return (slider.currentSlide === slider.last) ? 0 : slider.currentSlide + 1;
- } else {
- return (slider.currentSlide === 0) ? slider.last : slider.currentSlide - 1;
- }
- };
- // SLIDE:
- slider.setProps = function(pos, special, dur) {
- var target = (function() {
- var posCheck = (pos) ? pos : ((slider.itemW + vars.itemMargin) * slider.move) * slider.animatingTo,
- posCalc = (function() {
- if (carousel) {
- return (special === "setTouch") ? pos :
- (reverse && slider.animatingTo === slider.last) ? 0 :
- (reverse) ? slider.limit - (((slider.itemW + vars.itemMargin) * slider.move) * slider.animatingTo) :
- (slider.animatingTo === slider.last) ? slider.limit : posCheck;
- } else {
- switch (special) {
- case "setTotal": return (reverse) ? ((slider.count - 1) - slider.currentSlide + slider.cloneOffset) * pos : (slider.currentSlide + slider.cloneOffset) * pos;
- case "setTouch": return (reverse) ? pos : pos;
- case "jumpEnd": return (reverse) ? pos : slider.count * pos;
- case "jumpStart": return (reverse) ? slider.count * pos : pos;
- default: return pos;
- }
- }
- }());
- return (posCalc * -1) + "px";
- }());
- if (slider.transitions) {
- target = (vertical) ? "translate3d(0," + target + ",0)" : "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) {
- // SLIDE:
- if (!fade) {
- var sliderOffset, arr;
- if (type === "init") {
- slider.viewport = $('<div class="' + namespace + 'viewport"></div>').css({"overflow": "hidden", "position": "relative"}).appendTo(slider).append(slider.container);
- // INFINITE LOOP:
- slider.cloneCount = 0;
- slider.cloneOffset = 0;
- // REVERSE:
- if (reverse) {
- arr = $.makeArray(slider.slides).reverse();
- slider.slides = $(arr);
- slider.container.empty().append(slider.slides);
- }
- }
- // INFINITE LOOP && !CAROUSEL:
- if (vars.animationLoop && !carousel) {
- 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')).prepend(slider.slides.last().clone().addClass('clone'));
- }
- slider.newSlides = $(vars.selector, slider);
- sliderOffset = (reverse) ? slider.count - 1 - slider.currentSlide + slider.cloneOffset : slider.currentSlide + slider.cloneOffset;
- // VERTICAL:
- if (vertical && !carousel) {
- slider.container.height((slider.count + slider.cloneCount) * 200 + "%").css("position", "absolute").width("100%");
- setTimeout(function(){
- slider.newSlides.css({"display": "block"});
- slider.doMath();
- slider.viewport.height(slider.h);
- slider.setProps(sliderOffset * slider.h, "init");
- }, (type === "init") ? 100 : 0);
- } else {
- 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:
- if (vars.smoothHeight) methods.smoothHeight();
- }, (type === "init") ? 100 : 0);
- }
- } else { // FADE:
- slider.slides.css({"width": "100%", "float": "left", "marginRight": "-100%", "position": "relative"});
- if (type === "init") slider.slides.eq(slider.currentSlide).fadeIn(vars.animationSpeed, vars.easing);
- // SMOOTH HEIGHT:
- if (vars.smoothHeight) methods.smoothHeight();
- }
- // !CAROUSEL:
- // CANDIDATE: active slide
- if (!carousel) slider.slides.removeClass(namespace + "active-slide").eq(slider.currentSlide).addClass(namespace + "active-slide");
- };
- slider.doMath = function() {
- var slide = slider.slides.first(),
- slideMargin = vars.itemMargin,
- minItems = vars.minItems,
- maxItems = vars.maxItems;
- slider.w = slider.width();
- slider.h = slide.height();
- slider.boxPadding = slide.outerWidth() - slide.width();
- // CAROUSEL:
- if (carousel) {
- slider.itemT = vars.itemWidth + slideMargin;
- slider.minW = (minItems) ? minItems * slider.itemT : slider.w;
- slider.maxW = (maxItems) ? maxItems * slider.itemT : slider.w;
- slider.itemW = (slider.minW > slider.w) ? (slider.w - (slideMargin * minItems))/minItems :
- (slider.maxW < slider.w) ? (slider.w - (slideMargin * maxItems))/maxItems :
- (vars.itemWidth > slider.w) ? slider.w : vars.itemWidth;
- slider.visible = Math.floor(slider.w/(slider.itemW + slideMargin));
- slider.move = (vars.move > 0 && vars.move < slider.visible ) ? vars.move : slider.visible;
- slider.pagingCount = Math.ceil(((slider.count - slider.visible)/slider.move) + 1);
- slider.last = slider.pagingCount - 1;
- slider.limit = (slider.pagingCount === 1) ? 0 :
- (vars.itemWidth > slider.w) ? ((slider.itemW + (slideMargin * 2)) * slider.count) - slider.w - slideMargin : ((slider.itemW + slideMargin) * slider.count) - slider.w - slideMargin;
- } else {
- 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 (!carousel) {
- if (pos < slider.currentSlide) {
- slider.currentSlide += 1;
- } else if (pos <= slider.currentSlide && pos !== 0) {
- slider.currentSlide -= 1;
- }
- slider.animatingTo = slider.currentSlide;
- }
- // update controlNav
- if (vars.controlNav && !slider.manualControls) {
- if ((action === "add" && !carousel) || slider.pagingCount > slider.controlNav.length) {
- methods.controlNav.update("add");
- } else if ((action === "remove" && !carousel) || slider.pagingCount < slider.controlNav.length) {
- if (carousel && slider.currentSlide > slider.last) {
- slider.currentSlide -= 1;
- slider.animatingTo -= 1;
- }
- methods.controlNav.update("remove", slider.last);
- }
- }
- // update directionNav
- if (vars.directionNav) methods.directionNav.update();
- };
- slider.addSlide = function(obj, pos) {
- var $obj = $(obj);
- slider.count += 1;
- slider.last = slider.count - 1;
- // append new slide
- if (vertical && reverse) {
- (pos !== undefined) ? slider.slides.eq(slider.count - pos).after($obj) : slider.container.prepend($obj);
- } else {
- (pos !== undefined) ? slider.slides.eq(pos).before($obj) : slider.container.append($obj);
- }
- // update currentSlide, animatingTo, controlNav, and directionNav
- slider.update(pos, "add");
- // update slider.slides
- slider.slides = $(vars.selector + ':not(.clone)', slider);
- // re-setup the slider to accomdate new slide
- slider.setup();
- //FlexSlider: added() Callback
- vars.added(slider);
- };
- slider.removeSlide = function(obj) {
- var pos = (isNaN(obj)) ? slider.slides.index($(obj)) : obj;
- // update count
- slider.count -= 1;
- slider.last = slider.count - 1;
- // remove slide
- if (isNaN(obj)) {
- $(obj, slider.slides).remove();
- } else {
- (vertical && reverse) ? slider.slides.eq(slider.last).remove() : slider.slides.eq(obj).remove();
- }
- // update currentSlide, animatingTo, controlNav, and directionNav
- slider.doMath();
- slider.update(pos, "remove");
- // update slider.slides
- slider.slides = $(vars.selector + ':not(.clone)', slider);
- // re-setup the slider to accomdate new slide
- slider.setup();
- // FlexSlider: removed() Callback
- vars.removed(slider);
- };
- //FlexSlider: Initialize
- methods.init();
- };
- //FlexSlider: Default Settings
- $.flexslider.defaults = {
- namespace: "flex-", //{NEW} String: Prefix string attached to the class of every element generated by the plugin
- selector: ".slides > li", //{NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril
- animation: "fade", //String: Select your animation type, "fade" or "slide"
- easing: "swing", //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
- direction: "horizontal", //String: Select the sliding direction, "horizontal" or "vertical"
- reverse: false, //{NEW} Boolean: Reverse the animation direction
- animationLoop: true, //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
- smoothHeight: false, //{NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode
- startAt: 0, //Integer: The slide that the slider should start on. Array notation (0 = first slide)
- slideshow: true, //Boolean: Animate slider automatically
- slideshowSpeed: 7000, //Integer: Set the speed of the slideshow cycling, in milliseconds
- animationSpeed: 600, //Integer: Set the speed of animations, in milliseconds
- initDelay: 0, //{NEW} Integer: Set an initialization delay, in milliseconds
- randomize: false, //Boolean: Randomize slide order
- // Usability features
- pauseOnAction: true, //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
- pauseOnHover: false, //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
- useCSS: true, //{NEW} Boolean: Slider will use CSS3 transitions if available
- touch: true, //{NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices
- video: false, //{NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches
- // Primary Controls
- controlNav: true, //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
- directionNav: true, //Boolean: Create navigation for previous/next navigation? (true/false)
- prevText: "Previous", //String: Set the text for the "previous" directionNav item
- nextText: "Next", //String: Set the text for the "next" directionNav item
- // Secondary Navigation
- keyboard: true, //Boolean: Allow slider navigating via keyboard left/right keys
- multipleKeyboard: true, //{NEW} Boolean: Allow keyboard navigation to affect multiple sliders. Default behavior cuts out keyboard navigation with more than one slider present.
- mousewheel: false, //{UPDATED} Boolean: Requires jquery.mousewheel.js (https://github.com/brandonaaron/jquery-mousewheel) - Allows slider navigating via mousewheel
- pausePlay: false, //Boolean: Create pause/play dynamic element
- pauseText: "Pause", //String: Set the text for the "pause" pausePlay item
- playText: "Play", //String: Set the text for the "play" pausePlay item
- // Special properties
- controlsContainer: "", //{UPDATED} jQuery Object/Selector: Declare which container the navigation elements should be appended too. Default container is the FlexSlider element. Example use would be $(".flexslider-container"). Property is ignored if given element is not found.
- manualControls: "", //{UPDATED} jQuery Object/Selector: Declare custom control navigation. Examples would be $(".flex-control-nav li") or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
- sync: "", //{NEW} Selector: Mirror the actions performed on this slider with another slider. Use with care.
- asNavFor: "", //{NEW} Selector: Internal property exposed for turning the slider into a thumbnail navigation for another slider
- // Carousel Options
- itemWidth: 0, //{NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding.
- itemMargin: 0, //{NEW} Integer: Margin between carousel items.
- minItems: 0, //{NEW} Integer: Minimum number of carousel items that should be visible. Items will resize fluidly when below this.
- maxItems: 0, //{NEW} Integer: Maxmimum number of carousel items that should be visible. Items will resize fluidly when above this limit.
- move: 0, //{NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
- // Callback API
- start: function(){}, //Callback: function(slider) - Fires when the slider loads the first slide
- before: function(){}, //Callback: function(slider) - Fires asynchronously with each slider animation
- after: function(){}, //Callback: function(slider) - Fires after each slider animation completes
- end: function(){}, //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
- added: function(){}, //{NEW} Callback: function(slider) - Fires after a slide is added
- removed: function(){} //{NEW} Callback: function(slider) - Fires after a slide is removed
- };
- //FlexSlider: Plugin Function
- $.fn.flexslider = 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.fadeIn(400);
- if (options.start) options.start($this);
- } else if ($this.data('flexslider') === undefined) {
- new $.flexslider(this, options);
- }
- });
- } else {
- // Helper strings to quickly perform functions on the slider
- var $slider = $(this).data('flexslider');
- switch (options) {
- case "play": $slider.play(); break;
- case "pause": $slider.pause(); break;
- case "next": $slider.flexAnimate($slider.getTarget("next"), true); break;
- case "prev":
- case "previous": $slider.flexAnimate($slider.getTarget("prev"), true); break;
- default: if (typeof options === "number") $slider.flexAnimate(options, true);
- }
- }
- };
- })(jQuery);
- /**
- * 2.) bxSlider v.4.0 - http://bxslider.com
- */
- /**
- * BxSlider v4.0 - Fully loaded, responsive content slider
- * http://bxslider.com
- *
- * Copyright 2012, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com
- * Written while drinking Belgian ales and listening to jazz
- *
- * Released under the WTFPL license - http://sam.zoy.org/wtfpl/
- */
- ;(function($){
- var plugin = {};
- var defaults = {
- // GENERAL
- mode: 'horizontal',
- slideSelector: '',
- infiniteLoop: true,
- hideControlOnEnd: false,
- speed: 500,
- easing: null,
- slideMargin: 0,
- startSlide: 0,
- randomStart: false,
- captions: false,
- ticker: false,
- tickerHover: false,
- adaptiveHeight: false,
- adaptiveHeightSpeed: 500,
- touchEnabled: true,
- swipeThreshold: 50,
- video: false,
- useCSS: true,
- // PAGER
- pager: true,
- pagerType: 'full',
- pagerShortSeparator: ' / ',
- pagerSelector: null,
- buildPager: null,
- pagerCustom: null,
- // CONTROLS
- controls: true,
- nextText: '',
- prevText: '',
- nextSelector: null,
- prevSelector: null,
- autoControls: false,
- startText: 'Start',
- stopText: 'Stop',
- autoControlsCombine: false,
- autoControlsSelector: null,
- // AUTO
- auto: false,
- pause: 4000,
- autoStart: true,
- autoDirection: 'next',
- autoHover: false,
- autoDelay: 0,
- // CAROUSEL
- minSlides: 1,
- maxSlides: 1,
- moveSlides: 0,
- slideWidth: 0,
- // CALLBACKS
- onSliderLoad: function() {},
- onSlideBefore: function() {},
- onSlideAfter: function() {},
- onSlideNext: function() {},
- onSlidePrev: function() {}
- }
- $.fn.bxSlider = function(options){
- if(this.length == 0) return;
- // support mutltiple elements
- if(this.length > 1){
- this.each(function(){$(this).bxSlider(options)});
- return this;
- }
- // create a namespace to be used throughout the plugin
- var slider = {};
- // set a reference to our slider element
- var el = this;
- plugin.el = this;
- /**
- * ===================================================================================
- * = PRIVATE FUNCTIONS
- * ===================================================================================
- */
- /**
- * Initializes namespace settings to be used throughout plugin
- */
- var init = function(){
- // merge user-supplied options with the defaults
- slider.settings = $.extend({}, defaults, options);
- // store the original children
- slider.children = el.children(slider.settings.slideSelector);
- // if random start, set the startSlide setting to random number
- if(slider.settings.randomStart) slider.settings.startSlide = Math.floor(Math.random() * slider.children.length);
- // store active slide information
- slider.active = { index: slider.settings.startSlide }
- // store if the slider is in carousel mode (displaying / moving multiple slides)
- slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1;
- // calculate the min / max width thresholds based on min / max number of slides
- // used to setup and update carousel slides dimensions
- slider.minThreshold = (slider.settings.minSlides * slider.settings.slideWidth) + ((slider.settings.minSlides - 1) * slider.settings.slideMargin);
- slider.maxThreshold = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
- // store the current state of the slider (if currently animating, working is true)
- slider.working = false;
- // initialize the controls object
- slider.controls = {};
- // determine which property to use for transitions
- slider.animProp = slider.settings.mode == 'vertical' ? 'top' : 'left';
- // determine if hardware acceleration can be used
- slider.usingCSS = slider.settings.useCSS && slider.settings.mode != 'fade' && (function(){
- // create our test div element
- var div = document.createElement('div');
- // css transition properties
- var props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
- // test for each property
- for(var i in props){
- if(div.style[props[i]] !== undefined){
- slider.cssPrefix = props[i].replace('Perspective', '').toLowerCase();
- slider.animProp = '-' + slider.cssPrefix + '-transform';
- return true;
- }
- }
- return false;
- }());
- // if vertical mode always make maxSlides and minSlides equal
- if(slider.settings.mode == 'vertical') slider.settings.maxSlides = slider.settings.minSlides;
- // perform all DOM / CSS modifications
- setup();
- }
- /**
- * Performs all DOM and CSS modifications
- */
- var setup = function(){
- // wrap el in a wrapper
- el.wrap('<div class="bx-wrapper"><div class="bx-viewport"></div></div>');
- // store a namspace reference to .bx-viewport
- slider.viewport = el.parent();
- // add a loading div to display while images are loading
- slider.loader = $('<div class="bx-loading" />');
- slider.viewport.prepend(slider.loader);
- // set el to a massive width, to hold any needed slides
- // also strip any margin and padding from el
- el.css({
- width: slider.settings.mode == 'horizontal' ? slider.children.length * 215 + '%' : 'auto',
- position: 'relative',
- });
- // if using CSS, add the easing property
- if(slider.usingCSS && slider.settings.easing){
- el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing);
- // if not using CSS and no easing value was supplied, use the default JS animation easing (swing)
- }else if(!slider.settings.easing){
- slider.settings.easing = 'swing';
- }
- // make modifications to the viewport (.bx-viewport)
- slider.viewport.css({
- width: '100%',
- overflow: 'hidden',
- position: 'relative'
- });
- // apply css to all slider children
- slider.children.css({
- float: slider.settings.mode == 'horizontal' ? 'left' : 'none',
- listStyle: 'none',
- });
- // apply the calculated width after the float is applied to prevent scrollbar interference
- slider.children.width(getSlideWidth());
- // if slideMargin is supplied, add the css
- if(slider.settings.mode == 'horizontal' && slider.settings.slideMargin > 0) slider.children.css('marginRight', slider.settings.slideMargin);
- if(slider.settings.mode == 'vertical' && slider.settings.slideMargin > 0) slider.children.css('marginBottom', slider.settings.slideMargin);
- // if "fade" mode, add positioning and z-index CSS
- if(slider.settings.mode == 'fade'){
- slider.children.css({
- position: 'absolute',
- zIndex: 0,
- display: 'none'
- });
- // prepare the z-index on the showing element
- slider.children.eq(slider.settings.startSlide).css({zIndex: 50, display: 'block'});
- }
- // create an element to contain all slider controls (pager, start / stop, etc)
- slider.controls.el = $('<div class="bx-controls" />');
- // if captions are requested, add them
- if(slider.settings.captions) appendCaptions();
- // if infinite loop, prepare additional slides
- if(slider.settings.infiniteLoop && slider.settings.mode != 'fade' && !slider.settings.ticker){
- var slice = slider.settings.mode == 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides;
- var sliceAppend = slider.children.slice(0, slice).clone().addClass('bx-clone');
- var slicePrepend = slider.children.slice(-slice).clone().addClass('bx-clone');
- el.append(sliceAppend).prepend(slicePrepend);
- }
- // check if startSlide is last slide
- slider.active.last = slider.settings.startSlide == getPagerQty() - 1;
- // if video is true, set up the fitVids plugin
- if(slider.settings.video) el.fitVids();
- // only check for control addition if not in "ticker" mode
- if(!slider.settings.ticker){
- // if pager is requested, add it
- if(slider.settings.pager) appendPager();
- // if controls are requested, add them
- if(slider.settings.controls) appendControls();
- // if auto is true, and auto controls are requested, add them
- if(slider.settings.auto && slider.settings.autoControls) appendControlsAuto();
- // if any control option is requested, add the controls wrapper
- if(slider.settings.controls || slider.settings.autoControls || slider.settings.pager) slider.viewport.after(slider.controls.el);
- }
- // preload all images, then perform final DOM / CSS modifications that depend on images being loaded
- el.children().imagesLoaded(function(){
- // remove the loading DOM element
- slider.loader.remove();
- // set the left / top position of "el"
- setSlidePosition();
- // if "vertical" mode, always use adaptiveHeight to prevent odd behavior
- if (slider.settings.mode == 'vertical') slider.settings.adaptiveHeight = true;
- // set the viewport height
- slider.viewport.height(getViewportHeight());
- // onSliderLoad callback
- slider.settings.onSliderLoad(slider.active.index);
- // if auto is true, start the show
- if (slider.settings.auto && slider.settings.autoStart) initAuto();
- // if ticker is true, start the ticker
- if (slider.settings.ticker) initTicker();
- // if pager is requested, make the appropriate pager link active
- if (slider.settings.pager) updatePagerActive(slider.settings.startSlide);
- // check for any updates to the controls (like hideControlOnEnd updates)
- if (slider.settings.controls) updateDirectionControls();
- // if touchEnabled is true, setup the touch events
- if (slider.settings.touchEnabled && !slider.settings.ticker) initTouch();
- });
- }
- /**
- * Returns the calculated height of the viewport, used to determine either adaptiveHeight or the maxHeight value
- */
- var getViewportHeight = function(){
- var height = 0;
- // first determine which children (slides) should be used in our height calculation
- var children = $();
- // if mode is not "vertical", adaptiveHeight is always false, so return all children
- if(slider.settings.mode != 'vertical' && !slider.settings.adaptiveHeight){
- children = slider.children;
- }else{
- // if not carousel, return the single active child
- if(!slider.carousel){
- children = slider.children.eq(slider.active.index);
- // if carousel, return a slice of children
- }else{
- // get the individual slide index
- var currentIndex = slider.settings.moveSlides == 1 ? slider.active.index : slider.active.index * getMoveBy();
- // add the current slide to the children
- children = slider.children.eq(currentIndex);
- // cycle through the remaining "showing" slides
- for (i = 1; i <= slider.settings.maxSlides - 1; i++){
- // if looped back to the start
- if(currentIndex + i >= slider.children.length){
- children = children.add(slider.children.eq(i - 1));
- }else{
- children = children.add(slider.children.eq(currentIndex + i));
- }
- }
- }
- }
- // if "vertical" mode, calculate the sum of the heights of the children
- if(slider.settings.mode == 'vertical'){
- children.each(function(index) {
- height += $(this).outerHeight();
- });
- // add user-supplied margins
- if(slider.settings.slideMargin > 0){
- height += slider.settings.slideMargin * (slider.settings.minSlides - 1);
- }
- // if not "vertical" mode, calculate the max height of the children
- }else{
- height = Math.max.apply(Math, children.map(function(){
- return $(this).outerHeight(false);
- }).get());
- }
- return height;
- }
- /**
- * Returns the calculated width to be applied to each slide
- */
- var getSlideWidth = function(){
- // start with any user-supplied slide width
- var newElWidth = slider.settings.slideWidth;
- // get the current viewport width
- var wrapWidth = slider.viewport.width();
- // if slide width was not supplied, use the viewport width (means not carousel)
- if(slider.settings.slideWidth == 0){
- newElWidth = wrapWidth;
- // if carousel, use the thresholds to determine the width
- }else{
- if(wrapWidth > slider.maxThreshold){
- newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.maxSlides - 1))) / slider.settings.maxSlides;
- }else if(wrapWidth < slider.minThreshold){
- newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides;
- }
- }
- return newElWidth;
- }
- /**
- * Returns the number of slides currently visible in the viewport (includes partially visible slides)
- */
- var getNumberSlidesShowing = function(){
- var slidesShowing = 1;
- if(slider.settings.mode == 'horizontal'){
- // if viewport is smaller than minThreshold, return minSlides
- if(slider.viewport.width() < slider.minThreshold){
- slidesShowing = slider.settings.minSlides;
- // if viewport is larger than minThreshold, return maxSlides
- }else if(slider.viewport.width() > slider.maxThreshold){
- slidesShowing = slider.settings.maxSlides;
- // if viewport is between min / max thresholds, divide viewport width by first child width
- }else{
- var childWidth = slider.children.first().width();
- slidesShowing = Math.floor(slider.viewport.width() / childWidth);
- }
- // if "vertical" mode, slides showing will always be minSlides
- }else if(slider.settings.mode == 'vertical'){
- slidesShowing = slider.settings.minSlides;
- }
- return slidesShowing;
- }
- /**
- * Returns the number of pages (one full viewport of slides is one "page")
- */
- var getPagerQty = function(){
- var pagerQty = 0;
- // if moveSlides is specified by the user
- if(slider.settings.moveSlides > 0){
- if(slider.settings.infiniteLoop){
- pagerQty = slider.children.length / getMoveBy();
- }else{
- // use a while loop to determine pages
- var breakPoint = 0;
- var counter = 0
- // when breakpoint goes above children length, counter is the number of pages
- while (breakPoint < slider.children.length){
- ++pagerQty;
- breakPoint = counter + getNumberSlidesShowing();
- counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing();
- }
- }
- // if moveSlides is 0 (auto) divide children length by sides showing, then round up
- }else{
- pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing());
- }
- return pagerQty;
- }
- /**
- * Returns the number of indivual slides by which to shift the slider
- */
- var getMoveBy = function(){
- // if moveSlides was set by the user and moveSlides is less than number of slides showing
- if(slider.settings.moveSlides > 0 && slider.settings.moveSlides <= getNumberSlidesShowing()){
- return slider.settings.moveSlides;
- }
- // if moveSlides is 0 (auto)
- return getNumberSlidesShowing();
- }
- /**
- * Sets the slider's (el) left or top position
- */
- var setSlidePosition = function(){
- // if last slide
- if(slider.active.last){
- if (slider.settings.mode == 'horizontal'){
- // get the last child's position
- var lastChild = slider.children.last();
- var position = lastChild.position();
- // set the left position
- setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.width())), 'reset', 0);
- }else if(slider.settings.mode == 'vertical'){
- // get the last showing index's position
- var lastShowingIndex = slider.children.length - slider.settings.minSlides;
- var position = slider.children.eq(lastShowingIndex).position();
- // set the top position
- setPositionProperty(-position.top, 'reset', 0);
- }
- // if not last slide
- }else{
- // get the position of the first showing slide
- var position = slider.children.eq(slider.active.index * getMoveBy()).position();
- // check for last slide
- if (slider.active.index == getPagerQty() - 1) slider.active.last = true;
- // set the repective position
- if (position != undefined){
- if (slider.settings.mode == 'horizontal') setPositionProperty(-position.left, 'reset', 0);
- else if (slider.settings.mode == 'vertical') setPositionProperty(-position.top, 'reset', 0);
- }
- }
- }
- /**
- * Sets the el's animating property position (which in turn will sometimes animate el).
- * If using CSS, sets the transform property. If not using CSS, sets the top / left property.
- *
- * @param value (int)
- * - the animating property's value
- *
- * @param type (string) 'slider', 'reset', 'ticker'
- * - the type of instance for which the function is being
- *
- * @param duration (int)
- * - the amount of time (in ms) the transition should occupy
- *
- * @param params (array) optional
- * - an optional parameter containing any variables that need to be passed in
- */
- var setPositionProperty = function(value, type, duration, params){
- // use CSS transform
- if(slider.usingCSS){
- // determine the translate3d value
- var propValue = slider.settings.mode == 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)';
- // add the CSS transition-duration
- el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's');
- if(type == 'slide'){
- // set the property value
- el.css(slider.animProp, propValue);
- // bind a callback method - executes when CSS transition completes
- el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
- // unbind the callback
- el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
- updateAfterSlideTransition();
- });
- }else if(type == 'reset'){
- el.css(slider.animProp, propValue);
- }else if(type == 'ticker'){
- // make the transition use 'linear'
- el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear');
- el.css(slider.animProp, propValue);
- // bind a callback method - executes when CSS transition completes
- el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
- // unbind the callback
- el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
- // reset the position
- setPositionProperty(params['resetValue'], 'reset', 0);
- // start the loop again
- tickerLoop();
- });
- }
- // use JS animate
- }else{
- var animateObj = {};
- animateObj[slider.animProp] = value;
- if(type == 'slide'){
- el.animate(animateObj, duration, slider.settings.easing, function(){
- updateAfterSlideTransition();
- });
- }else if(type == 'reset'){
- el.css(slider.animProp, value)
- }else if(type == 'ticker'){
- el.animate(animateObj, speed, 'linear', function(){
- setPositionProperty(params['resetValue'], 'reset', 0);
- // run the recursive loop after animation
- tickerLoop();
- });
- }
- }
- }
- /**
- * Populates the pager with proper amount of pages
- */
- var populatePager = function(){
- var pagerHtml = '';
- pagerQty = getPagerQty();
- // loop through each pager item
- for(var i=0; i < pagerQty; i++){
- var linkContent = '';
- // if a buildPager function is supplied, use it to get pager link value, else use index + 1
- if(slider.settings.buildPager && $.isFunction(slider.settings.buildPager)){
- linkContent = slider.settings.buildPager(i);
- slider.pagerEl.addClass('bx-custom-pager');
- }else{
- linkContent = i + 1;
- slider.pagerEl.addClass('bx-default-pager');
- }
- // var linkContent = slider.settings.buildPager && $.isFunction(slider.settings.buildPager) ? slider.settings.buildPager(i) : i + 1;
- // add the markup to the string
- pagerHtml += '<div class="bx-pager-item"><a href="" data-slide-index="' + i + '" class="bx-pager-link">' + linkContent + '</a></div>';
- };
- // populate the pager element with pager links
- slider.pagerEl.html(pagerHtml);
- }
- /**
- * Appends the pager to the controls element
- */
- var appendPager = function(){
- if(!slider.settings.pagerCustom){
- // create the pager DOM element
- slider.pagerEl = $('<div class="bx-pager" />');
- // if a pager selector was supplied, populate it with the pager
- if(slider.settings.pagerSelector){
- $(slider.settings.pagerSelector).html(slider.pagerEl);
- // if no pager selector was supplied, add it after the wrapper
- }else{
- slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl);
- }
- // populate the pager
- populatePager();
- }else{
- slider.pagerEl = $(slider.settings.pagerCustom);
- }
- // assign the pager click binding
- slider.pagerEl.delegate('a', 'click', clickPagerBind);
- }
- /**
- * Appends prev / next controls to the controls element
- */
- var appendControls = function(){
- slider.controls.next = $('<span class="bx-next link">' + slider.settings.nextText + '</span>');
- slider.controls.prev = $('<span class="bx-prev link disabled">' + slider.settings.prevText + '</span>');
- // bind click actions to the controls
- slider.controls.next.bind('click', clickNextBind);
- slider.controls.prev.bind('click', clickPrevBind);
- // if nextSlector was supplied, populate it
- if(slider.settings.nextSelector){
- $(slider.settings.nextSelector).append(slider.controls.next);
- }
- // if prevSlector was supplied, populate it
- if(slider.settings.prevSelector){
- $(slider.settings.prevSelector).append(slider.controls.prev);
- }
- // if no custom selectors were supplied
- if(!slider.settings.nextSelector && !slider.settings.prevSelector){
- // add the controls to the DOM
- slider.controls.directionEl = $('<div class="bx-controls-direction" />');
- // add the control elements to the directionEl
- slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next);
- // slider.viewport.append(slider.controls.directionEl);
- slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl);
- }
- }
- /**
- * Appends start / stop auto controls to the controls element
- */
- var appendControlsAuto = function(){
- slider.controls.start = $('<div class="bx-controls-auto-item"><a class="bx-start" href="">' + slider.settings.startText + '</a></div>');
- slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>');
- // add the controls to the DOM
- slider.controls.autoEl = $('<div class="bx-controls-auto" />');
- // bind click actions to the controls
- slider.controls.autoEl.delegate('.bx-start', 'click', clickStartBind);
- slider.controls.autoEl.delegate('.bx-stop', 'click', clickStopBind);
- // if autoControlsCombine, insert only the "start" control
- if(slider.settings.autoControlsCombine){
- slider.controls.autoEl.append(slider.controls.start);
- // if autoControlsCombine is false, insert both controls
- }else{
- slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop);
- }
- // if auto controls selector was supplied, populate it with the controls
- if(slider.settings.autoControlsSelector){
- $(slider.settings.autoControlsSelector).html(slider.controls.autoEl);
- // if auto controls selector was not supplied, add it after the wrapper
- }else{
- slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl);
- }
- // update the auto controls
- updateAutoControls(slider.settings.autoStart ? 'stop' : 'start');
- }
- /**
- * Appends image captions to the DOM
- */
- var appendCaptions = function(){
- // cycle through each child
- slider.children.each(function(index){
- // get the image title attribute
- var title = $(this).find('img:first').attr('title');
- // append the caption
- if (title != undefined) $(this).append('<div class="bx-caption"><span>' + title + '</span></div>');
- });
- }
- /**
- * Click next binding
- *
- * @param e (event)
- * - DOM event object
- */
- var clickNextBind = function(e){
- // if auto show is running, stop it
- if (slider.settings.auto) el.stopAuto();
- el.goToNextSlide();
- e.preventDefault();
- }
- /**
- * Click prev binding
- *
- * @param e (event)
- * - DOM event object
- */
- var clickPrevBind = function(e){
- // if auto show is running, stop it
- if (slider.settings.auto) el.stopAuto();
- el.goToPrevSlide();
- e.preventDefault();
- }
- /**
- * Click start binding
- *
- * @param e (event)
- * - DOM event object
- */
- var clickStartBind = function(e){
- el.startAuto();
- e.preventDefault();
- }
- /**
- * Click stop binding
- *
- * @param e (event)
- * - DOM event object
- */
- var clickStopBind = function(e){
- el.stopAuto();
- e.preventDefault();
- }
- /**
- * Click pager binding
- *
- * @param e (event)
- * - DOM event object
- */
- var clickPagerBind = function(e){
- // if auto show is running, stop it
- if (slider.settings.auto) el.stopAuto();
- var pagerLink = $(e.currentTarget);
- var pagerIndex = parseInt(pagerLink.attr('data-slide-index'));
- // if clicked pager link is not active, continue with the goToSlide call
- if(pagerIndex != slider.active.index) el.goToSlide(pagerIndex);
- e.preventDefault();
- }
- /**
- * Updates the pager links with an active class
- *
- * @param slideIndex (int)
- * - index of slide to make active
- */
- var updatePagerActive = function(slideIndex){
- // if "short" pager type
- if(slider.settings.pagerType == 'short'){
- slider.pagerEl.html((slideIndex + 1) + slider.settings.pagerShortSeparator + slider.children.length);
- return;
- }
- // remove all pager active classes
- slider.pagerEl.find('a').removeClass('active');
- // apply the active class
- slider.pagerEl.find('a').eq(slideIndex).addClass('active');
- }
- /**
- * Performs needed actions after a slide transition
- */
- var updateAfterSlideTransition = function(){
- // if infinte loop is true
- if(slider.settings.infiniteLoop){
- var position = '';
- // first slide
- if(slider.active.index == 0){
- // set the new position
- position = slider.children.eq(0).position();
- // carousel, last slide
- }else if(slider.active.index == getPagerQty() - 1 && slider.carousel){
- position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position();
- // last slide
- }else if(slider.active.index == slider.children.length - 1){
- position = slider.children.eq(slider.children.length - 1).position();
- }
- if (slider.settings.mode == 'horizontal') { setPositionProperty(-position.left, 'reset', 0);; }
- else if (slider.settings.mode == 'vertical') { setPositionProperty(-position.top, 'reset', 0);; }
- }
- // declare that the transition is complete
- slider.working = false;
- // onSlideAfter callback
- slider.settings.onSlideAfter(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
- }
- /**
- * Updates the auto controls state (either active, or combined switch)
- *
- * @param state (string) "start", "stop"
- * - the new state of the auto show
- */
- var updateAutoControls = function(state){
- // if autoControlsCombine is true, replace the current control with the new state
- if(slider.settings.autoControlsCombine){
- slider.controls.autoEl.html(slider.controls[state]);
- // if autoControlsCombine is false, apply the "active" class to the appropriate control
- }else{
- slider.controls.autoEl.find('a').removeClass('active');
- slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active');
- }
- }
- /**
- * Updates the direction controls (checks if either should be hidden)
- */
- var updateDirectionControls = function(){
- // if infiniteLoop is false and hideControlOnEnd is true
- if(!slider.settings.infiniteLoop && slider.settings.hideControlOnEnd){
- // if first slide
- if (slider.active.index == 0){
- slider.controls.prev.addClass('disabled');
- slider.controls.next.removeClass('disabled');
- // if last slide
- }else if(slider.active.index == getPagerQty() - 1){
- slider.controls.next.addClass('disabled');
- slider.controls.prev.removeClass('disabled');
- // if any slide in the middle
- }else{
- slider.controls.prev.removeClass('disabled');
- slider.controls.next.removeClass('disabled');
- }
- }
- }
- /**
- * Initialzes the auto process
- */
- var initAuto = function(){
- // if autoDelay was supplied, launch the auto show using a setTimeout() call
- if(slider.settings.autoDelay > 0){
- var timeout = setTimeout(el.startAuto, slider.settings.autoDelay);
- // if autoDelay was not supplied, start the auto show normally
- }else{
- el.startAuto();
- }
- // if autoHover is requested
- if(slider.settings.autoHover){
- // on el hover
- el.hover(function(){
- // if the auto show is currently playing (has an active interval)
- if(slider.interval){
- // stop the auto show and pass true agument which will prevent control update
- el.stopAuto(true);
- // create a new autoPaused value which will be used by the relative "mouseout" event
- slider.autoPaused = true;
- }
- }, function(){
- // if the autoPaused value was created be the prior "mouseover" event
- if(slider.autoPaused){
- // start the auto show and pass true agument which will prevent control update
- el.startAuto(true);
- // reset the autoPaused value
- slider.autoPaused = null;
- }
- });
- }
- }
- /**
- * Initialzes the ticker process
- */
- var initTicker = function(){
- var startPosition = 0;
- // if autoDirection is "next", append a clone of the entire slider
- if(slider.settings.autoDirection == 'next'){
- el.append(slider.children.clone().addClass('bx-clone'));
- // if autoDirection is "prev", prepend a clone of the entire slider, and set the left position
- }else{
- el.prepend(slider.children.clone().addClass('bx-clone'));
- var position = slider.children.first().position();
- startPosition = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
- }
- setPositionProperty(startPosition, 'reset', 0);
- // do not allow controls in ticker mode
- slider.settings.pager = false;
- slider.settings.controls = false;
- slider.settings.autoControls = false;
- // if autoHover is requested
- if(slider.settings.tickerHover && !slider.usingCSS){
- // on el hover
- slider.viewport.hover(function(){
- el.stop();
- }, function(){
- // calculate the total width of children (used to calculate the speed ratio)
- var totalDimens = 0;
- slider.children.each(function(index){
- totalDimens += slider.settings.mode == 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
- });
- // calculate the speed ratio (used to determine the new speed to finish the paused animation)
- var ratio = slider.settings.speed / totalDimens;
- // determine which property to use
- var property = slider.settings.mode == 'horizontal' ? 'left' : 'top';
- // calculate the new speed
- var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property)))));
- tickerLoop(newSpeed);
- });
- }
- // start the ticker loop
- tickerLoop();
- }
- /**
- * Runs a continuous loop, news ticker-style
- */
- var tickerLoop = function(resumeSpeed){
- speed = resumeSpeed ? resumeSpeed : slider.settings.speed;
- var position = {left: 0, top: 0};
- var reset = {left: 0, top: 0};
- // if "next" animate left position to last child, then reset left to 0
- if(slider.settings.autoDirection == 'next'){
- position = el.find('.bx-clone').first().position();
- // if "prev" animate left position to 0, then reset left to first non-clone child
- }else{
- reset = slider.children.first().position();
- }
- var animateProperty = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
- var resetValue = slider.settings.mode == 'horizontal' ? -reset.left : -reset.top;
- var params = {resetValue: resetValue};
- setPositionProperty(animateProperty, 'ticker', speed, params);
- }
- /**
- * Initializes touch events
- */
- var initTouch = function(){
- // initialize object to contain all touch values
- slider.touch = {
- start: {x: 0, y: 0},
- end: {x: 0, y: 0}
- }
- slider.viewport.bind('touchstart', onTouchStart);
- }
- /**
- * Event handler for "touchstart"
- *
- * @param e (event)
- * - DOM event object
- */
- var onTouchStart = function(e){
- if(slider.working){
- e.preventDefault();
- }else{
- // record the original position when touch starts
- slider.touch.originalPos = el.position();
- var orig = e.originalEvent;
- // record the starting touch x, y coordinates
- slider.touch.start.x = orig.changedTouches[0].pageX;
- slider.touch.start.y = orig.changedTouches[0].pageY;
- // bind a "touchmove" event to the viewport
- slider.viewport.bind('touchmove', onTouchMove);
- // bind a "touchend" event to the viewport
- slider.viewport.bind('touchend', onTouchEnd);
- }
- }
- /**
- * Event handler for "touchmove"
- *
- * @param e (event)
- * - DOM event object
- */
- var onTouchMove = function(e){
- e.preventDefault();
- if(slider.settings.mode != 'fade'){
- var orig = e.originalEvent;
- var value = 0;
- // if horizontal, drag along x axis
- if(slider.settings.mode == 'horizontal'){
- var change = orig.changedTouches[0].pageX - slider.touch.start.x;
- value = slider.touch.originalPos.left + change;
- // if vertical, drag along y axis
- }else{
- var change = orig.changedTouches[0].pageY - slider.touch.start.y;
- value = slider.touch.originalPos.top + change;
- }
- setPositionProperty(value, 'reset', 0);
- }
- }
- /**
- * Event handler for "touchend"
- *
- * @param e (event)
- * - DOM event object
- */
- var onTouchEnd = function(e){
- slider.viewport.unbind('touchmove', onTouchMove);
- var orig = e.originalEvent;
- var value = 0;
- // record end x, y positions
- slider.touch.end.x = orig.changedTouches[0].pageX;
- slider.touch.end.y = orig.changedTouches[0].pageY;
- // if fade mode, check if absolute x distance clears the threshold
- if(slider.settings.mode == 'fade'){
- var distance = Math.abs(slider.touch.start.x - slider.touch.end.x);
- if(distance >= slider.settings.swipeThreshold){
- slider.touch.start.x > slider.touch.end.x ? el.goToNextSlide() : el.goToPrevSlide();
- el.stopAuto();
- }
- // not fade mode
- }else{
- var distance = 0;
- // calculate distance and el's animate property
- if(slider.settings.mode == 'horizontal'){
- distance = slider.touch.end.x - slider.touch.start.x;
- value = slider.touch.originalPos.left;
- }else{
- distance = slider.touch.end.y - slider.touch.start.y;
- value = slider.touch.originalPos.top;
- }
- // if not infinite loop and first / last slide, do not attempt a slide transition
- if(!slider.settings.infiniteLoop && ((slider.active.index == 0 && distance > 0) || (slider.active.last && distance < 0))){
- setPositionProperty(value, 'reset', 200);
- }else{
- // check if distance clears threshold
- if(Math.abs(distance) >= slider.settings.swipeThreshold){
- distance < 0 ? el.goToNextSlide() : el.goToPrevSlide();
- el.stopAuto();
- }else{
- // el.animate(property, 200);
- setPositionProperty(value, 'reset', 200);
- }
- }
- }
- slider.viewport.unbind('touchend', onTouchEnd);
- }
- /**
- * ===================================================================================
- * = PUBLIC FUNCTIONS
- * ===================================================================================
- */
- /**
- * Performs slide transition to the specified slide
- *
- * @param slideIndex (int)
- * - the destination slide's index (zero-based)
- *
- * @param direction (string)
- * - INTERNAL USE ONLY - the direction of travel ("prev" / "next")
- */
- el.goToSlide = function(slideIndex, direction){
- // if plugin is currently in motion, ignore request
- if(slider.working || slider.active.index == slideIndex) return;
- // declare that plugin is in motion
- slider.working = true;
- // store the old index
- slider.oldIndex = slider.active.index;
- // if slideIndex is less than zero, set active index to last child (this happens during infinite loop)
- if(slideIndex < 0){
- slider.active.index = getPagerQty() - 1;
- // if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop)
- }else if(slideIndex >= getPagerQty()){
- slider.active.index = 0;
- // set active index to requested slide
- }else{
- slider.active.index = slideIndex;
- }
- // onSlideBefore, onSlideNext, onSlidePrev callbacks
- slider.settings.onSlideBefore(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
- if(direction == 'next'){
- slider.settings.onSlideNext(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
- }else if(direction == 'prev'){
- slider.settings.onSlidePrev(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
- }
- // check if last slide
- slider.active.last = slider.active.index >= getPagerQty() - 1;
- // update the pager with active class
- if(slider.settings.pager) updatePagerActive(slider.active.index);
- // // check for direction control update
- if(slider.settings.controls) updateDirectionControls();
- // if slider is set to mode: "fade"
- if(slider.settings.mode == 'fade'){
- // if adaptiveHeight is true and next height is different from current height, animate to the new height
- if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){
- slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
- }
- // fade out the visible child and reset its z-index value
- slider.children.filter(':visible').fadeOut(slider.settings.speed).css({zIndex: 0});
- // fade in the newly requested slide
- slider.children.eq(slider.active.index).css('zIndex', 51).fadeIn(slider.settings.speed, function(){
- $(this).css('zIndex', 50);
- updateAfterSlideTransition();
- });
- // slider mode is not "fade"
- }else{
- // if adaptiveHeight is true and next height is different from current height, animate to the new height
- if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){
- slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
- }
- var moveBy = 0;
- var position = {left: 0, top: 0};
- // if carousel and not infinite loop
- if(!slider.settings.infiniteLoop && slider.carousel && slider.active.last){
- if(slider.settings.mode == 'horizontal'){
- // get the last child position
- var lastChild = slider.children.eq(slider.children.length - 1);
- position = lastChild.position();
- // calculate the position of the last slide
- moveBy = slider.viewport.width() - lastChild.width();
- }else{
- // get last showing index position
- var lastShowingIndex = slider.children.length - slider.settings.minSlides;
- position = slider.children.eq(lastShowingIndex).position();
- }
- // horizontal carousel, going previous while on first slide (infiniteLoop mode)
- }else if(slider.carousel && slider.active.last && direction == 'prev'){
- // get the last child position
- var eq = slider.settings.moveSlides == 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides);
- var lastChild = el.children('.bx-clone').eq(eq);
- position = lastChild.position();
- // if infinite loop and "Next" is clicked on the last slide
- }else if(direction == 'next' && slider.active.index == 0){
- // get the last clone position
- position = el.find('.bx-clone').eq(slider.settings.maxSlides).position();
- slider.active.last = false;
- // normal non-zero requests
- }else if(slideIndex >= 0){
- var requestEl = slideIndex * getMoveBy();
- position = slider.children.eq(requestEl).position();
- }
- // plugin values to be animated
- var value = slider.settings.mode == 'horizontal' ? -(position.left - moveBy) : -position.top;
- setPositionProperty(value, 'slide', slider.settings.speed);
- }
- }
- /**
- * Transitions to the next slide in the show
- */
- el.goToNextSlide = function(){
- // if infiniteLoop is false and last page is showing, disregard call
- if (!slider.settings.infiniteLoop && slider.active.last) return;
- var pagerIndex = slider.active.index + 1;
- el.goToSlide(pagerIndex, 'next');
- }
- /**
- * Transitions to the prev slide in the show
- */
- el.goToPrevSlide = function(){
- // if infiniteLoop is false and last page is showing, disregard call
- if (!slider.settings.infiniteLoop && slider.active.index == 0) return;
- var pagerIndex = slider.active.index - 1;
- el.goToSlide(pagerIndex, 'prev');
- }
- /**
- * Starts the auto show
- *
- * @param preventControlUpdate (boolean)
- * - if true, auto controls state will not be updated
- */
- el.startAuto = function(preventControlUpdate){
- // if an interval already exists, disregard call
- if(slider.interval) return;
- // create an interval
- slider.interval = setInterval(function(){
- slider.settings.autoDirection == 'next' ? el.goToNextSlide() : el.goToPrevSlide();
- }, slider.settings.pause);
- // if auto controls are displayed and preventControlUpdate is not true
- if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('stop');
- }
- /**
- * Stops the auto show
- *
- * @param preventControlUpdate (boolean)
- * - if true, auto controls state will not be updated
- */
- el.stopAuto = function(preventControlUpdate){
- // if no interval exists, disregard call
- if(!slider.interval) return;
- // clear the interval
- clearInterval(slider.interval);
- slider.interval = null;
- // if auto controls are displayed and preventControlUpdate is not true
- if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('start');
- }
- /**
- * Returns current slide index (zero-based)
- */
- el.getCurrentSlide = function(){
- return slider.active.index;
- }
- /**
- * Returns number of slides in show
- */
- el.getSlideCount = function(){
- return slider.children.length;
- }
- /**
- * Makes slideshow responsive
- */
- // first get the original window dimens (thanks alot IE)
- var windowWidth = $(window).width();
- var windowHeight = $(window).height();
- $(window).resize(function(){
- // get the new window dimens (again, thank you IE)
- var windowWidthNew = $(window).width();
- var windowHeightNew = $(window).height();
- // make sure that it is a true window resize
- // *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
- // are resized. Can you just die already?*
- if(windowWidth != windowWidthNew || windowHeight != windowHeightNew){
- // set the new window dimens
- windowWidth = windowWidthNew;
- windowHeight = windowHeightNew;
- // resize all children in ratio to new screen size
- slider.children.add(el.find('.bx-clone')).width(getSlideWidth());
- // adjust the height
- slider.viewport.css('height', getViewportHeight());
- // if active.last was true before the screen resize, we want
- // to keep it last no matter what screen size we end on
- if (slider.active.last) slider.active.index = getPagerQty() - 1;
- // if the active index (page) no longer exists due to the resize, simply set the index as last
- if (slider.active.index >= getPagerQty()) slider.active.last = true;
- // if a pager is being displayed and a custom pager is not being used, update it
- if(slider.settings.pager && !slider.settings.pagerCustom){
- populatePager();
- updatePagerActive(slider.active.index);
- }
- // update the slide position
- if(!slider.settings.ticker) setSlidePosition();
- }
- });
- init();
- // returns the current jQuery object
- return this;
- }
- })(jQuery);
- /**
- * 3.) jQuery imagesLoaded plugin 2.1.0 - http://github.com/desandro/imagesloaded
- */
- /*!
- * jQuery imagesLoaded plugin v2.1.0
- * http://github.com/desandro/imagesloaded
- *
- * MIT License. by Paul Irish et al.
- */
- /*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */
- /*global jQuery: false */
- (function(c,n){var l="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";c.fn.imagesLoaded=function(f){function m(){var b=c(i),a=c(h);d&&(h.length?d.reject(e,b,a):d.resolve(e));c.isFunction(f)&&f.call(g,e,b,a)}function j(b,a){b.src===l||-1!==c.inArray(b,k)||(k.push(b),a?h.push(b):i.push(b),c.data(b,"imagesLoaded",{isBroken:a,src:b.src}),o&&d.notifyWith(c(b),[a,e,c(i),c(h)]),e.length===k.length&&(setTimeout(m),e.unbind(".imagesLoaded")))}var g=this,d=c.isFunction(c.Deferred)?c.Deferred():
- 0,o=c.isFunction(d.notify),e=g.find("img").add(g.filter("img")),k=[],i=[],h=[];c.isPlainObject(f)&&c.each(f,function(b,a){if("callback"===b)f=a;else if(d)d[b](a)});e.length?e.bind("load.imagesLoaded error.imagesLoaded",function(b){j(b.target,"error"===b.type)}).each(function(b,a){var d=a.src,e=c.data(a,"imagesLoaded");if(e&&e.src===d)j(a,e.isBroken);else if(a.complete&&a.naturalWidth!==n)j(a,0===a.naturalWidth||0===a.naturalHeight);else if(a.readyState||a.complete)a.src=l,a.src=d}):m();return d?d.promise(g):
- g}})(jQuery);
- /**
- * 4.) fancyBox 2.0.5 - http://fancyapps.com/fancybox/
- */
- /*!
- * fancyBox - jQuery Plugin
- * version: 2.0.5 (02/03/2012)
- * @requires jQuery v1.6 or later
- *
- * Examples at http://fancyapps.com/fancybox/
- * License: www.fancyapps.com/fancybox/#license
- *
- * Copyright 2012 Janis Skarnelis - [email protected]
- *
- */
- (function (window, document, undefined) {
- "use strict";
- var $ = window.jQuery,
- W = $(window),
- D = $(document),
- F = $.fancybox = function () {
- F.open.apply( this, arguments );
- },
- didResize = false,
- resizeTimer = null,
- isMobile = document.createTouch !== undefined,
- isString = function(str) {
- return $.type(str) === "string";
- };
- $.extend(F, {
- // The current version of fancyBox
- version: '2.0.5',
- defaults: {
- padding: 15,
- margin: 20,
- width: 800,
- height: 600,
- minWidth: 100,
- minHeight: 100,
- maxWidth: 9999,
- maxHeight: 9999,
- autoSize: true,
- autoResize: !isMobile,
- autoCenter : !isMobile,
- fitToView: true,
- aspectRatio: false,
- topRatio: 0.5,
- fixed: !($.browser.msie && $.browser.version <= 6) && !isMobile,
- scrolling: 'auto', // 'auto', 'yes' or 'no'
- wrapCSS: 'fancybox-default',
- arrows: true,
- closeBtn: true,
- closeClick: false,
- nextClick : false,
- mouseWheel: true,
- autoPlay: false,
- playSpeed: 3000,
- preload : 3,
- modal: false,
- loop: true,
- ajax: { dataType: 'html', headers: { 'X-fancyBox': true } },
- keys: {
- next: [13, 32, 34, 39, 40], // enter, space, page down, right arrow, down arrow
- prev: [8, 33, 37, 38], // backspace, page up, left arrow, up arrow
- close: [27] // escape key
- },
- // Override some properties
- index: 0,
- type: null,
- href: null,
- content: null,
- title: null,
- // HTML templates
- tpl: {
- wrap: '<div class="fancybox-wrap"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div>',
- image: '<img class="fancybox-image" src="{href}" alt="" />',
- iframe: '<iframe class="fancybox-iframe" name="fancybox-frame{rnd}" frameborder="0" hspace="0"' + ($.browser.msie ? ' allowtransparency="true"' : '') + '></iframe>',
- swf: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{href}" /><embed src="{href}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="100%" height="100%" wmode="transparent"></embed></object>',
- error: '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
- closeBtn: '<div title="Close" class="fancybox-item fancybox-close"></div>',
- next: '<a title="Next" class="fancybox-nav fancybox-next"><span></span></a>',
- prev: '<a title="Previous" class="fancybox-nav fancybox-prev"><span></span></a>'
- },
- // Properties for each animation type
- // Opening fancyBox
- openEffect: 'fade', // 'elastic', 'fade' or 'none'
- openSpeed: 250,
- openEasing: 'swing',
- openOpacity: true,
- openMethod: 'zoomIn',
- // Closing fancyBox
- closeEffect: 'fade', // 'elastic', 'fade' or 'none'
- closeSpeed: 250,
- closeEasing: 'swing',
- closeOpacity: true,
- closeMethod: 'zoomOut',
- // Changing next gallery item
- nextEffect: 'elastic', // 'elastic', 'fade' or 'none'
- nextSpeed: 300,
- nextEasing: 'swing',
- nextMethod: 'changeIn',
- // Changing previous gallery item
- prevEffect: 'elastic', // 'elastic', 'fade' or 'none'
- prevSpeed: 300,
- prevEasing: 'swing',
- prevMethod: 'changeOut',
- // Enabled helpers
- helpers: {
- overlay: {
- speedIn: 0,
- speedOut: 300,
- opacity: 0.8,
- css: {
- cursor: 'pointer'
- },
- closeClick: true
- },
- title: {
- type: 'float' // 'float', 'inside', 'outside' or 'over'
- }
- },
- // Callbacks
- onCancel: $.noop, // If canceling
- beforeLoad: $.noop, // Before loading
- afterLoad: $.noop, // After loading
- beforeShow: $.noop, // Before changing in current item
- afterShow: $.noop, // After opening
- beforeClose: $.noop, // Before closing
- afterClose: $.noop // After closing
- },
- //Current state
- group: {}, // Selected group
- opts: {}, // Group options
- coming: null, // Element being loaded
- current: null, // Currently loaded element
- isOpen: false, // Is currently open
- isOpened: false, // Have been fully opened at least once
- wrap: null,
- outer: null,
- inner: null,
- player: {
- timer: null,
- isActive: false
- },
- // Loaders
- ajaxLoad: null,
- imgPreload: null,
- // Some collections
- transitions: {},
- helpers: {},
- /*
- * Static methods
- */
- open: function (group, opts) {
- //Kill existing instances
- F.close(true);
- //Normalize group
- if (group && !$.isArray(group)) {
- group = group instanceof $ ? $(group).get() : [group];
- }
- F.isActive = true;
- //Extend the defaults
- F.opts = $.extend(true, {}, F.defaults, opts);
- //All options are merged recursive except keys
- if ($.isPlainObject(opts) && opts.keys !== undefined) {
- F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
- }
- F.group = group;
- F._start(F.opts.index || 0);
- },
- cancel: function () {
- if (F.coming && false === F.trigger('onCancel')) {
- return;
- }
- F.coming = null;
- F.hideLoading();
- if (F.ajaxLoad) {
- F.ajaxLoad.abort();
- }
- F.ajaxLoad = null;
- if (F.imgPreload) {
- F.imgPreload.onload = F.imgPreload.onabort = F.imgPreload.onerror = null;
- }
- },
- close: function (a) {
- F.cancel();
- if (!F.current || false === F.trigger('beforeClose')) {
- return;
- }
- F.unbindEvents();
- //If forced or is still opening then remove immediately
- if (!F.isOpen || (a && a[0] === true)) {
- $(".fancybox-wrap").stop().trigger('onReset').remove();
- F._afterZoomOut();
- } else {
- F.isOpen = F.isOpened = false;
- $(".fancybox-item, .fancybox-nav").remove();
- F.wrap.stop(true).removeClass('fancybox-opened');
- F.inner.css('overflow', 'hidden');
- F.transitions[F.current.closeMethod]();
- }
- },
- // Start/stop slideshow
- play: function (a) {
- var clear = function () {
- clearTimeout(F.player.timer);
- },
- set = function () {
- clear();
- if (F.current && F.player.isActive) {
- F.player.timer = setTimeout(F.next, F.current.playSpeed);
- }
- },
- stop = function () {
- clear();
- $('body').unbind('.player');
- F.player.isActive = false;
- F.trigger('onPlayEnd');
- },
- start = function () {
- if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
- F.player.isActive = true;
- $('body').bind({
- 'afterShow.player onUpdate.player': set,
- 'onCancel.player beforeClose.player': stop,
- 'beforeLoad.player': clear
- });
- set();
- F.trigger('onPlayStart');
- }
- };
- if (F.player.isActive || (a && a[0] === false)) {
- stop();
- } else {
- start();
- }
- },
- next: function () {
- if (F.current) {
- F.jumpto(F.current.index + 1);
- }
- },
- prev: function () {
- if (F.current) {
- F.jumpto(F.current.index - 1);
- }
- },
- jumpto: function (index) {
- if (!F.current) {
- return;
- }
- index = parseInt(index, 10);
- if (F.group.length > 1 && F.current.loop) {
- if (index >= F.group.length) {
- index = 0;
- } else if (index < 0) {
- index = F.group.length - 1;
- }
- }
- if (F.group[index] !== undefined) {
- F.cancel();
- F._start(index);
- }
- },
- reposition: function (a, b) {
- if (F.isOpen) {
- if (b && b.type === 'scroll') {
- F.wrap.stop().animate(F._getPosition(a), 200);
- } else {
- F.wrap.css(F._getPosition(a));
- }
- }
- },
- update: function (e) {
- if (F.isOpen) {
- // It's a very bad idea to attach handlers to the window scroll event, run this code after a delay
- if (!didResize) {
- resizeTimer = setTimeout(function () {
- var current = F.current;
- if (didResize) {
- didResize = false;
- if (current) {
- if (!e || (e && (e.type === 'orientationchange' || (current.autoResize && e.type === 'resize')))) {
- if (current.autoSize) {
- F.inner.height('auto');
- current.height = F.inner.height();
- }
- F._setDimension();
- if (current.canGrow) {
- F.inner.height('auto');
- }
- }
- if (current.autoCenter) {
- F.reposition(null, e);
- }
- F.trigger('onUpdate');
- }
- }
- }, 100);
- }
- didResize = true;
- }
- },
- toggle: function () {
- if (F.isOpen) {
- F.current.fitToView = !F.current.fitToView;
- F.update();
- }
- },
- hideLoading: function () {
- D.unbind('keypress.fb');
- $("#fancybox-loading").remove();
- },
- showLoading: function () {
- F.hideLoading();
- //If user will press the escape-button, the request will be canceled
- D.bind('keypress.fb', function(e) {
- if (e.keyCode == 27) {
- e.preventDefault();
- F.cancel();
- }
- });
- $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
- },
- getViewport: function () {
- return {
- x: W.scrollLeft(),
- y: W.scrollTop(),
- w: W.width(),
- h: W.height()
- };
- },
- // Unbind the keyboard / clicking actions
- unbindEvents: function () {
- if (F.wrap) {
- F.wrap.unbind('.fb');
- }
- D.unbind('.fb');
- W.unbind('.fb');
- },
- bindEvents: function () {
- var current = F.current,
- keys = current.keys;
- if (!current) {
- return;
- }
- W.bind('resize.fb, orientationchange.fb', F.update);
- if (!current.fixed && current.autoCenter) {
- W.bind("scroll.fb", F.update);
- }
- if (keys) {
- D.bind('keydown.fb', function (e) {
- var code;
- // Ignore key combinations and key events within form elements
- if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && $.inArray(e.target.tagName.toLowerCase(), ['input', 'textarea', 'select', 'button']) < 0) {
- code = e.keyCode;
- if ($.inArray(code, keys.close) > -1) {
- F.close();
- e.preventDefault();
- } else if ($.inArray(code, keys.next) > -1) {
- F.next();
- e.preventDefault();
- } else if ($.inArray(code, keys.prev) > -1) {
- F.prev();
- e.preventDefault();
- }
- }
- });
- }
- if ($.fn.mousewheel && current.mouseWheel && F.group.length > 1) {
- F.wrap.bind('mousewheel.fb', function (e, delta) {
- var target = e.target || null;
- if (delta !== 0 && (!target || target.clientHeight === 0 || (target.scrollHeight === target.clientHeight && target.scrollWidth === target.clientWidth))) {
- e.preventDefault();
- F[delta > 0 ? 'prev' : 'next']();
- }
- });
- }
- },
- trigger: function (event) {
- var ret, obj = F[ $.inArray(event, ['onCancel', 'beforeLoad', 'afterLoad']) > -1 ? 'coming' : 'current' ];
- if (!obj) {
- return;
- }
- if ($.isFunction( obj[event] )) {
- ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
- }
- if (ret === false) {
- return false;
- }
- if (obj.helpers) {
- $.each(obj.helpers, function (helper, opts) {
- if (opts && $.isPlainObject(F.helpers[helper]) && $.isFunction(F.helpers[helper][event])) {
- F.helpers[helper][event](opts, obj);
- }
- });
- }
- $.event.trigger(event + '.fb');
- },
- isImage: function (str) {
- return str && str.toString().match(/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i);
- },
- isSWF: function (str) {
- return str && str.toString().match(/\.(swf)(.*)?$/i);
- },
- _start: function (index) {
- var coming = {},
- element = F.group[index] || null,
- isDom,
- href,
- type,
- rez,
- hrefParts;
- if (element && (element.nodeType || element instanceof $)) {
- isDom = true;
- if ($.metadata) {
- coming = $(element).metadata();
- }
- }
- coming = $.extend(true, {}, F.opts, {index : index, element : element}, ($.isPlainObject(element) ? element : coming));
- // Re-check overridable options
- $.each(['href', 'title', 'content', 'type'], function(i,v) {
- coming[v] = F.opts[ v ] || (isDom && $(element).attr( v )) || coming[ v ] || null;
- });
- // Convert margin property to array - top, right, bottom, left
- if (typeof coming.margin === 'number') {
- coming.margin = [coming.margin, coming.margin, coming.margin, coming.margin];
- }
- // 'modal' propery is just a shortcut
- if (coming.modal) {
- $.extend(true, coming, {
- closeBtn : false,
- closeClick: false,
- nextClick : false,
- arrows : false,
- mouseWheel : false,
- keys : null,
- helpers: {
- overlay : {
- css: {
- cursor : 'auto'
- },
- closeClick : false
- }
- }
- });
- }
- //Give a chance for callback or helpers to update coming item (type, title, etc)
- F.coming = coming;
- if (false === F.trigger('beforeLoad')) {
- F.coming = null;
- return;
- }
- type = coming.type;
- href = coming.href || element;
- ///Check if content type is set, if not, try to get
- if (!type) {
- if (isDom) {
- rez = $(element).data('fancybox-type');
- if (!rez && element.className) {
- rez = element.className.match(/fancybox\.(\w+)/);
- type = rez ? rez[1] : null;
- }
- }
- if (!type && isString(href)) {
- if (F.isImage(href)) {
- type = 'image';
- } else if (F.isSWF(href)) {
- type = 'swf';
- } else if (href.match(/^#/)) {
- type = 'inline';
- }
- }
- // ...if not - display element itself
- if (!type) {
- type = isDom ? 'inline' : 'html';
- }
- coming.type = type;
- }
- // Check before try to load; 'inline' and 'html' types need content, others - href
- if (type === 'inline' || type === 'html') {
- if (!coming.content) {
- if (type === 'inline') {
- coming.content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
- } else {
- coming.content = element;
- }
- }
- if (!coming.content || !coming.content.length) {
- type = null;
- }
- } else if (!href) {
- type = null;
- }
- /*
- Add reference to the group, so it`s possible to access from callbacks, example:
- afterLoad : function() {
- this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
- }
- */
- hrefParts = href.split(/\s+/, 2);
- coming.group = F.group;
- coming.isDom = isDom;
- coming.href = hrefParts.shift();
- coming.selector = hrefParts.shift();
- if (type === 'image') {
- F._loadImage();
- } else if (type === 'ajax') {
- F._loadAjax();
- } else if (type) {
- F._afterLoad();
- } else {
- F._error( 'type' );
- }
- },
- _error: function ( type ) {
- F.hideLoading();
- $.extend(F.coming, {
- type : 'html',
- autoSize : true,
- minHeight : 0,
- hasError : type,
- content : F.coming.tpl.error
- });
- F._afterLoad();
- },
- _loadImage: function () {
- // Reset preload image so it is later possible to check "complete" property
- F.imgPreload = new Image();
- F.imgPreload.onload = function () {
- this.onload = this.onerror = null;
- F.coming.width = this.width;
- F.coming.height = this.height;
- F._afterLoad();
- };
- F.imgPreload.onerror = function () {
- this.onload = this.onerror = null;
- F._error( 'image' );
- };
- F.imgPreload.src = F.coming.href;
- if (!F.imgPreload.width) {
- F.showLoading();
- }
- },
- _loadAjax: function () {
- F.showLoading();
- F.ajaxLoad = $.ajax($.extend({}, F.coming.ajax, {
- url: F.coming.href,
- error: function (jqXHR, textStatus) {
- if (F.coming && textStatus !== 'abort') {
- F._error( 'ajax', jqXHR );
- } else {
- F.hideLoading();
- }
- },
- success: function (data, textStatus) {
- if (textStatus === 'success') {
- F.coming.content = data;
- F._afterLoad();
- }
- }
- }));
- },
- _preloadImages: function() {
- var group = F.group,
- current = F.current,
- len = group.length,
- item,
- href,
- i,
- cnt = Math.min(current.preload, len - 1);
- if (!current.preload || group.length < 2) {
- return;
- }
- for (i = 1; i <= cnt; i += 1) {
- item = group[ (current.index + i ) % len ];
- href = $( item ).attr('href') || item;
- if (item.type === 'image' || F.isImage(href)) {
- new Image().src = href;
- }
- }
- },
- _afterLoad: function () {
- F.hideLoading();
- if (!F.coming || false === F.trigger('afterLoad', F.current)) {
- F.coming = false;
- return;
- }
- if (F.isOpened) {
- $(".fancybox-item").remove();
- F.wrap.stop(true).removeClass('fancybox-opened');
- F.inner.css('overflow', 'hidden');
- F.transitions[F.current.prevMethod]();
- } else {
- $(".fancybox-wrap").stop().trigger('onReset').remove();
- F.trigger('afterClose');
- }
- F.unbindEvents();
- F.isOpen = false;
- F.current = F.coming;
- //Build the neccessary markup
- F.wrap = $(F.current.tpl.wrap).addClass('fancybox-' + (isMobile ? 'mobile' : 'desktop') + ' fancybox-tmp ' + F.current.wrapCSS).appendTo('body');
- F.outer = $('.fancybox-outer', F.wrap).css('padding', F.current.padding + 'px');
- F.inner = $('.fancybox-inner', F.wrap);
- F._setContent();
- },
- _setContent: function () {
- var current = F.current, content = current.content, type = current.type, loadingBay;
- switch (type) {
- case 'inline':
- case 'ajax':
- case 'html':
- if (current.selector) {
- content = $("<div>").html(content).find(current.selector);
- } else if (content instanceof $) {
- content = content.show().detach();
- if (content.parent().hasClass('fancybox-inner')) {
- content.parents('.fancybox-wrap').trigger('onReset').remove();
- }
- $(F.wrap).bind('onReset', function () {
- content.appendTo('body').hide();
- });
- }
- if (current.autoSize) {
- loadingBay = $('<div class="fancybox-tmp ' + F.current.wrapCSS + '"></div>').appendTo('body').append(content);
- current.width = loadingBay.width();
- current.height = loadingBay.height();
- // Re-check to fix 1px bug in some browsers
- loadingBay.width( F.current.width );
- if (loadingBay.height() > current.height) {
- loadingBay.width(current.width + 1);
- current.width = loadingBay.width();
- current.height = loadingBay.height();
- }
- content = loadingBay.contents().detach();
- loadingBay.remove();
- }
- break;
- case 'image':
- content = current.tpl.image.replace('{href}', current.href);
- current.aspectRatio = true;
- break;
- case 'swf':
- content = current.tpl.swf.replace(/\{width\}/g, current.width).replace(/\{height\}/g, current.height).replace(/\{href\}/g, current.href);
- break;
- }
- if (type === 'iframe') {
- content = $(current.tpl.iframe.replace('{rnd}', new Date().getTime()) ).attr('scrolling', current.scrolling);
- current.scrolling = 'auto';
- // Set auto height for iframes
- if (current.autoSize) {
- content.width( current.width );
- F.showLoading();
- content.data('ready', false).appendTo(F.inner).bind({
- onCancel : function() {
- $(this).unbind();
- F._afterZoomOut();
- },
- load : function() {
- var iframe = $(this), height;
- try {
- if (this.contentWindow.document.location) {
- height = iframe.contents().find('body').height() + 12;
- iframe.height( height );
- }
- } catch (e) {
- current.autoSize = false;
- }
- if (iframe.data('ready') === false) {
- F.hideLoading();
- if (height) {
- F.current.height = height;
- }
- F._beforeShow();
- iframe.data('ready', true);
- } else if (height) {
- F.update();
- }
- }
- }).attr('src', current.href);
- return;
- }
- content.attr('src', current.href);
- } else if (type === 'image' || type === 'swf') {
- current.autoSize = false;
- current.scrolling = 'visible';
- }
- F.inner.append(content);
- F._beforeShow();
- },
- _beforeShow : function() {
- F.coming = null;
- //Give a chance for helpers or callbacks to update elements
- F.trigger('beforeShow');
- //Set initial dimensions and hide
- F._setDimension();
- F.wrap.hide().removeClass('fancybox-tmp');
- F.bindEvents();
- F._preloadImages();
- F.transitions[ F.isOpened ? F.current.nextMethod : F.current.openMethod ]();
- },
- _setDimension: function () {
- var wrap = F.wrap,
- outer = F.outer,
- inner = F.inner,
- current = F.current,
- viewport = F.getViewport(),
- margin = current.margin,
- padding2 = current.padding * 2,
- width = current.width,
- height = current.height,
- maxWidth = current.maxWidth,
- maxHeight = current.maxHeight,
- minWidth = current.minWidth,
- minHeight = current.minHeight,
- ratio,
- height_,
- space;
- viewport.w -= (margin[1] + margin[3]);
- viewport.h -= (margin[0] + margin[2]);
- if (width.toString().indexOf('%') > -1) {
- width = (((viewport.w - padding2) * parseFloat(width)) / 100);
- }
- if (height.toString().indexOf('%') > -1) {
- height = (((viewport.h - padding2) * parseFloat(height)) / 100);
- }
- ratio = width / height;
- width += padding2;
- height += padding2;
- if (current.fitToView) {
- maxWidth = Math.min(viewport.w, maxWidth);
- maxHeight = Math.min(viewport.h, maxHeight);
- }
- if (current.aspectRatio) {
- if (width > maxWidth) {
- width = maxWidth;
- height = ((width - padding2) / ratio) + padding2;
- }
- if (height > maxHeight) {
- height = maxHeight;
- width = ((height - padding2) * ratio) + padding2;
- }
- if (width < minWidth) {
- width = minWidth;
- height = ((width - padding2) / ratio) + padding2;
- }
- if (height < minHeight) {
- height = minHeight;
- width = ((height - padding2) * ratio) + padding2;
- }
- } else {
- width = Math.max(minWidth, Math.min(width, maxWidth));
- height = Math.max(minHeight, Math.min(height, maxHeight));
- }
- width = Math.round(width);
- height = Math.round(height);
- //Reset dimensions
- $(wrap.add(outer).add(inner)).width('auto').height('auto');
- inner.width(width - padding2).height(height - padding2);
- wrap.width(width);
- height_ = wrap.height(); // Real wrap height
- //Fit wrapper inside
- if (width > maxWidth || height_ > maxHeight) {
- while ((width > maxWidth || height_ > maxHeight) && width > minWidth && height_ > minHeight) {
- height = height - 10;
- if (current.aspectRatio) {
- width = Math.round(((height - padding2) * ratio) + padding2);
- if (width < minWidth) {
- width = minWidth;
- height = ((width - padding2) / ratio) + padding2;
- }
- } else {
- width = width - 10;
- }
- inner.width(width - padding2).height(height - padding2);
- wrap.width(width);
- height_ = wrap.height();
- }
- }
- current.dim = {
- width: width,
- height: height_
- };
- current.canGrow = current.autoSize && height > minHeight && height < maxHeight;
- current.canShrink = false;
- current.canExpand = false;
- if ((width - padding2) < current.width || (height - padding2) < current.height) {
- current.canExpand = true;
- } else if ((width > viewport.w || height_ > viewport.h) && width > minWidth && height > minHeight) {
- current.canShrink = true;
- }
- space = height_ - padding2;
- F.innerSpace = space - inner.height();
- F.outerSpace = space - outer.height();
- },
- _getPosition: function (a) {
- var current = F.current,
- viewport = F.getViewport(),
- margin = current.margin,
- width = F.wrap.width() + margin[1] + margin[3],
- height = F.wrap.height() + margin[0] + margin[2],
- rez = {
- position: 'absolute',
- top: margin[0] + viewport.y,
- left: margin[3] + viewport.x
- };
- if (current.autoCenter && current.fixed && (!a || a[0] === false) && height <= viewport.h && width <= viewport.w) {
- rez = {
- position: 'fixed',
- top: margin[0],
- left: margin[3]
- };
- }
- rez.top = Math.ceil(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio))) + 'px';
- rez.left = Math.ceil(Math.max(rez.left, rez.left + ((viewport.w - width) * 0.5))) + 'px';
- return rez;
- },
- _afterZoomIn: function () {
- var current = F.current, scrolling = current ? current.scrolling : 'no';
- if (!current) {
- return;
- }
- F.isOpen = F.isOpened = true;
- F.wrap.addClass('fancybox-opened').css('overflow', 'visible');
- F.update();
- F.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
- //Assign a click event
- if (current.closeClick || current.nextClick) {
- //This is not the perfect solution but arrows have to be next to content so their height will match
- // and I do not want another wrapper around content
- F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
- if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
- F[ current.closeClick ? 'close' : 'next' ]();
- }
- });
- }
- //Create a close button
- if (current.closeBtn) {
- $(current.tpl.closeBtn).appendTo(F.outer).bind('click.fb', F.close);
- }
- //Create navigation arrows
- if (current.arrows && F.group.length > 1) {
- if (current.loop || current.index > 0) {
- $(current.tpl.prev).appendTo(F.inner).bind('click.fb', F.prev);
- }
- if (current.loop || current.index < F.group.length - 1) {
- $(current.tpl.next).appendTo(F.inner).bind('click.fb', F.next);
- }
- }
- F.trigger('afterShow');
- if (F.opts.autoPlay && !F.player.isActive) {
- F.opts.autoPlay = false;
- F.play();
- }
- },
- _afterZoomOut: function () {
- F.trigger('afterClose');
- F.wrap.trigger('onReset').remove();
- $.extend(F, {
- group: {},
- opts: {},
- current: null,
- isActive: false,
- isOpened: false,
- isOpen: false,
- wrap: null,
- outer: null,
- inner: null
- });
- }
- });
- /*
- * Default transitions
- */
- F.transitions = {
- getOrigPosition: function () {
- var current = F.current,
- element = current.element,
- padding = current.padding,
- orig = $(current.orig),
- pos = {},
- width = 50,
- height = 50,
- viewport;
- if (!orig.length && current.isDom && $(element).is(':visible')) {
- orig = $(element).find('img:first');
- if (!orig.length) {
- orig = $(element);
- }
- }
- if (orig.length) {
- pos = orig.offset();
- if (orig.is('img')) {
- width = orig.outerWidth();
- height = orig.outerHeight();
- }
- } else {
- viewport = F.getViewport();
- pos.top = viewport.y + (viewport.h - height) * 0.5;
- pos.left = viewport.x + (viewport.w - width) * 0.5;
- }
- pos = {
- top: Math.ceil(pos.top - padding) + 'px',
- left: Math.ceil(pos.left - padding) + 'px',
- width: Math.ceil(width + padding * 2) + 'px',
- height: Math.ceil(height + padding * 2) + 'px'
- };
- return pos;
- },
- step: function (now, fx) {
- var ratio, innerValue, outerValue;
- if (fx.prop === 'width' || fx.prop === 'height') {
- innerValue = outerValue = Math.ceil(now - (F.current.padding * 2));
- if (fx.prop === 'height') {
- ratio = (now - fx.start) / (fx.end - fx.start);
- if (fx.start > fx.end) {
- ratio = 1 - ratio;
- }
- innerValue -= F.innerSpace * ratio;
- outerValue -= F.outerSpace * ratio;
- }
- F.inner[fx.prop](innerValue);
- F.outer[fx.prop](outerValue);
- }
- },
- zoomIn: function () {
- var wrap = F.wrap,
- current = F.current,
- startPos,
- endPos,
- dim = current.dim;
- if (current.openEffect === 'elastic') {
- endPos = $.extend({}, dim, F._getPosition(true));
- //Remove "position" property
- delete endPos.position;
- startPos = this.getOrigPosition();
- if (current.openOpacity) {
- startPos.opacity = 0;
- endPos.opacity = 1;
- }
- F.outer.add(F.inner).width('auto').height('auto');
- wrap.css(startPos).show();
- wrap.animate(endPos, {
- duration: current.openSpeed,
- easing: current.openEasing,
- step: this.step,
- complete: F._afterZoomIn
- });
- } else {
- wrap.css($.extend({}, dim, F._getPosition()));
- if (current.openEffect === 'fade') {
- wrap.fadeIn(current.openSpeed, F._afterZoomIn);
- } else {
- wrap.show();
- F._afterZoomIn();
- }
- }
- },
- zoomOut: function () {
- var wrap = F.wrap,
- current = F.current,
- endPos;
- if (current.closeEffect === 'elastic') {
- if (wrap.css('position') === 'fixed') {
- wrap.css(F._getPosition(true));
- }
- endPos = this.getOrigPosition();
- if (current.closeOpacity) {
- endPos.opacity = 0;
- }
- wrap.animate(endPos, {
- duration: current.closeSpeed,
- easing: current.closeEasing,
- step: this.step,
- complete: F._afterZoomOut
- });
- } else {
- wrap.fadeOut(current.closeEffect === 'fade' ? current.closeSpeed : 0, F._afterZoomOut);
- }
- },
- changeIn: function () {
- var wrap = F.wrap,
- current = F.current,
- startPos;
- if (current.nextEffect === 'elastic') {
- startPos = F._getPosition(true);
- startPos.opacity = 0;
- startPos.top = (parseInt(startPos.top, 10) - 200) + 'px';
- wrap.css(startPos).show().animate({
- opacity: 1,
- top: '+=200px'
- }, {
- duration: current.nextSpeed,
- easing: current.nextEasing,
- complete: F._afterZoomIn
- });
- } else {
- wrap.css(F._getPosition());
- if (current.nextEffect === 'fade') {
- wrap.hide().fadeIn(current.nextSpeed, F._afterZoomIn);
- } else {
- wrap.show();
- F._afterZoomIn();
- }
- }
- },
- changeOut: function () {
- var wrap = F.wrap,
- current = F.current,
- cleanUp = function () {
- $(this).trigger('onReset').remove();
- };
- wrap.removeClass('fancybox-opened');
- if (current.prevEffect === 'elastic') {
- wrap.animate({
- 'opacity': 0,
- top: '+=200px'
- }, {
- duration: current.prevSpeed,
- easing: current.prevEasing,
- complete: cleanUp
- });
- } else {
- wrap.fadeOut(current.prevEffect === 'fade' ? current.prevSpeed : 0, cleanUp);
- }
- }
- };
- /*
- * Overlay helper
- */
- F.helpers.overlay = {
- overlay: null,
- update: function () {
- var width, scrollWidth, offsetWidth;
- //Reset width/height so it will not mess
- this.overlay.width(0).height(0);
- if ($.browser.msie) {
- scrollWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
- offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
- width = scrollWidth < offsetWidth ? W.width() : scrollWidth;
- } else {
- width = D.width();
- }
- this.overlay.width(width).height(D.height());
- },
- beforeShow: function (opts) {
- if (this.overlay) {
- return;
- }
- opts = $.extend(true, {
- speedIn : 'fast',
- closeClick : true,
- opacity : 1,
- css : {
- background: 'black'
- }
- }, opts);
- this.overlay = $('<div id="fancybox-overlay"></div>').css(opts.css).appendTo('body');
- this.update();
- if (opts.closeClick) {
- this.overlay.bind('click.fb', F.close);
- }
- W.bind("resize.fb", $.proxy(this.update, this));
- this.overlay.fadeTo(opts.speedIn, opts.opacity);
- },
- onUpdate: function () {
- //Update as content may change document dimensions
- this.update();
- },
- afterClose: function (opts) {
- if (this.overlay) {
- this.overlay.fadeOut(opts.speedOut || 0, function () {
- $(this).remove();
- });
- }
- this.overlay = null;
- }
- };
- /*
- * Title helper
- */
- F.helpers.title = {
- beforeShow: function (opts) {
- var title, text = F.current.title;
- if (text) {
- title = $('<div class="fancybox-title fancybox-title-' + opts.type + '-wrap">' + text + '</div>').appendTo('body');
- if (opts.type === 'float') {
- //This helps for some browsers
- title.width(title.width());
- title.wrapInner('<span class="child"></span>');
- //Increase bottom margin so this title will also fit into viewport
- F.current.margin[2] += Math.abs(parseInt(title.css('margin-bottom'), 10));
- }
- title.appendTo(opts.type === 'over' ? F.inner : (opts.type === 'outside' ? F.wrap : F.outer));
- }
- }
- };
- // jQuery plugin initialization
- $.fn.fancybox = function (options) {
- var that = $(this),
- selector = this.selector || '',
- index,
- run = function(e) {
- var what = this, idx = index, relType, relVal;
- if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
- e.preventDefault();
- relType = options.groupAttr || 'data-fancybox-group';
- relVal = $(what).attr(relType);
- if (!relVal) {
- relType = 'rel';
- relVal = what[ relType ];
- }
- if (relVal && relVal !== '' && relVal !== 'nofollow') {
- what = selector.length ? $(selector) : that;
- what = what.filter('[' + relType + '="' + relVal + '"]');
- idx = what.index(this);
- }
- options.index = idx;
- F.open(what, options);
- }
- };
- options = options || {};
- index = options.index || 0;
- if (selector) {
- D.undelegate(selector, 'click.fb-start').delegate(selector, 'click.fb-start', run);
- } else {
- that.unbind('click.fb-start').bind('click.fb-start', run);
- }
- return this;
- };
- }(window, document));
- /**
- * 5.) jquery placeholder 2.0.3 - https://github.com/mathiasbynens/jquery-placeholder
- * @author Mathias Bynens
- */
- (function (window, document, $) {
- var isInputSupported = 'placeholder' in document.createElement('input'),
- isTextareaSupported = 'placeholder' in document.createElement('textarea'),
- prototype = $.fn,
- valHooks = $.valHooks,
- hooks,
- placeholder;
- if (isInputSupported && isTextareaSupported) {
- placeholder = prototype.placeholder = function() {
- return this;
- };
- placeholder.input = placeholder.textarea = true;
- } else {
- placeholder = prototype.placeholder = function() {
- return this
- .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
- .not('.placeholder')
- .bind({
- 'focus.placeholder': clearPlaceholder,
- 'blur.placeholder': setPlaceholder
- })
- .data('placeholder-enabled', true)
- .trigger('blur.placeholder').end();
- };
- placeholder.input = isInputSupported;
- placeholder.textarea = isTextareaSupported;
- hooks = {
- 'get': function(element) {
- var $element = $(element);
- return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
- },
- 'set': function(element, value) {
- var $element = $(element);
- if (!$element.data('placeholder-enabled')) {
- return element.value = value;
- }
- if (value == '') {
- element.value = value;
- // We can’t use `triggerHandler` here because of dummy text/password inputs :(
- setPlaceholder.call(element);
- } else if ($element.hasClass('placeholder')) {
- clearPlaceholder.call(element, true, value) || (element.value = value);
- } else {
- element.value = value;
- }
- // `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
- return $element;
- }
- };
- isInputSupported || (valHooks.input = hooks);
- isTextareaSupported || (valHooks.textarea = hooks);
- $(function() {
- // Look for forms
- $(document).delegate('form', 'submit.placeholder', function() {
- // Clear the placeholder values so they don’t get submitted
- var $inputs = $('.placeholder', this).each(clearPlaceholder);
- setTimeout(function() {
- $inputs.each(setPlaceholder);
- }, 10);
- });
- });
- // Clear placeholder values upon page reload
- $(window).bind('beforeunload.placeholder', function() {
- $('.placeholder').each(function() {
- this.value = '';
- });
- });
- }
- function args(elem) {
- // Return an object of element attributes
- var newAttrs = {},
- rinlinejQuery = /^jQuery\d+$/;
- $.each(elem.attributes, function(i, attr) {
- if (attr.specified && !rinlinejQuery.test(attr.name)) {
- newAttrs[attr.name] = attr.value;
- }
- });
- return newAttrs;
- }
- function clearPlaceholder(event, value) {
- var input = this,
- $input = $(input);
- if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
- if ($input.data('placeholder-password')) {
- $input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
- // If `clearPlaceholder` was called from `$.valHooks.input.set`
- if (event === true) {
- return $input[0].value = value;
- }
- $input.focus();
- } else {
- input.value = '';
- $input.removeClass('placeholder');
- }
- }
- }
- function setPlaceholder() {
- var $replacement,
- input = this,
- $input = $(input),
- $origInput = $input,
- id = this.id;
- if (input.value === '') {
- if (input.type == 'password') {
- if (!$input.data('placeholder-textinput')) {
- try {
- $replacement = $input.clone().attr({ 'type': 'text' });
- } catch(e) {
- $replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
- }
- $replacement
- .removeAttr('name')
- .data({
- 'placeholder-password': true,
- 'placeholder-id': id
- })
- .bind('focus.placeholder', clearPlaceholder);
- $input
- .data({
- 'placeholder-textinput': $replacement,
- 'placeholder-id': id
- })
- .before($replacement);
- }
- $input = $input.removeAttr('id').hide().prev().attr('id', id).show();
- // Note: `$input[0] != input` now!
- }
- $input.addClass('placeholder');
- $input[0].value = $input.attr('placeholder');
- } else {
- $input.removeClass('placeholder');
- }
- }
- }(this, document, jQuery));
- /**
- * 6.) Isotope Leak Free - https://github.com/khiltd/isotope-leak-free
- */
- /**
- * Isotope Leak Free
- *
- * https://github.com/khiltd/isotope-leak-free
- *
- * Forked from Isotope v1.5.21 to stop crashing browsers.
- *
- * Original, crashy version by:
- *
- * http://isotope.metafizzy.co
- *
- * Commercial use requires one-time license fee
- * http://metafizzy.co/#licenses
- *
- * Copyright 2012 David DeSandro / Metafizzy
- */
- (function(a,b,c){"use strict";var d=a.document,e=a.Modernizr,f=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},g="Moz Webkit O Ms".split(" "),h=function(a){var b=d.documentElement.style,c;if(typeof b[a]=="string")return a;a=f(a);for(var e=0,h=g.length;e<h;e++){c=g[e]+a;if(typeof b[c]=="string")return c}},i=h("transform"),j=h("transitionProperty"),k={csstransforms:function(){return!!i},csstransforms3d:function(){var a=!!h("perspective");if(a){var c=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),d="@media ("+c.join("transform-3d),(")+"modernizr)",e=b("<style>"+d+"{#modernizr{height:3px}}"+"</style>").appendTo("head"),f=b('<div id="modernizr" />').appendTo("html");a=f.height()===3,f.remove(),e.remove()}return a},csstransitions:function(){return!!j}},l;if(e)for(l in k)e.hasOwnProperty(l)||e.addTest(l,k[l]);else{e=a.Modernizr={_version:"1.6ish: miniModernizr for Isotope"};var m=" ",n;for(l in k)n=k[l](),e[l]=n,m+=" "+(n?"":"no-")+l;b("html").addClass(m)}if(e.csstransforms){var o=e.csstransforms3d?{translate:function(a){return"translate3d("+a[0]+"px, "+a[1]+"px, 0) "},scale:function(a){return"scale3d("+a+", "+a+", 1) "}}:{translate:function(a){return"translate("+a[0]+"px, "+a[1]+"px) "},scale:function(a){return"scale("+a+") "}},p=function(a,c,d){var e=b.data(a,"isoTransform")||{},f={},g,h={},j;f[c]=d,b.extend(e,f);for(g in e)j=e[g],h[g]=o[g](j);var k=h.translate||"",l=h.scale||"",m=k+l;b.data(a,"isoTransform",e),a.style[i]=m};b.cssNumber.scale=!0,b.cssHooks.scale={set:function(a,b){p(a,"scale",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.scale?d.scale:1}},b.fx.step.scale=function(a){b.cssHooks.scale.set(a.elem,a.now+a.unit)},b.cssNumber.translate=!0,b.cssHooks.translate={set:function(a,b){p(a,"translate",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.translate?d.translate:[0,0]}}}var q,r;e.csstransitions&&(q={WebkitTransitionProperty:"webkitTransitionEnd",MozTransitionProperty:"transitionend",OTransitionProperty:"oTransitionEnd otransitionend",transitionProperty:"transitionend"}[j],r=h("transitionDuration"));var s=b.event,t;s.special.smartresize={setup:function(){b(this).bind("resize",s.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",s.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",t&&clearTimeout(t),t=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Isotope=function(a,c,d){this.element=b(c),this._create(a),this._init(d)};var u=["width","height"],v=b(a);b.Isotope.settings={resizable:!0,layoutMode:"masonry",containerClass:"isotope",itemClass:"isotope-item",hiddenClass:"isotope-hidden",hiddenStyle:{opacity:0,scale:.001},visibleStyle:{opacity:1,scale:1},containerStyle:{position:"relative",overflow:"hidden"},animationEngine:"best-available",animationOptions:{queue:!1,duration:800},sortBy:"original-order",sortAscending:!0,resizesContainer:!0,transformsEnabled:!0,itemPositionDataEnabled:!1},b.Isotope.prototype={_create:function(a){this.options=b.extend({},b.Isotope.settings,a),this.styleQueue=[],this.elemCount=0;var c=this.element[0].style;this.originalStyle={};var d=u.slice(0);for(var e in this.options.containerStyle)d.push(e);for(var f=0,g=d.length;f<g;f++)e=d[f],this.originalStyle[e]=c[e]||"";this.element.css(this.options.containerStyle),this._updateAnimationEngine(),this._updateUsingTransforms();var h={"original-order":function(a,b){return b.elemCount++,b.elemCount},random:function(){return Math.random()}};this.options.getSortData=b.extend(this.options.getSortData,h),this.reloadItems(),this.offset={left:parseInt(this.element.css("padding-left")||0,10),top:parseInt(this.element.css("padding-top")||0,10)};var i=this;setTimeout(function(){i.element.addClass(i.options.containerClass)},0),this.options.resizable&&v.bind("smartresize.isotope",function(){i.resize()}),this.element.delegate("."+this.options.hiddenClass,"click",function(){return!1})},_expandoSafe:function(a){return delete a.prevObject,a},_getAtoms:function(a){var b=this.options.itemSelector,c=b?a.filter(b).add(a.find(b)):a,d={position:"absolute"};return this.usingTransforms&&(d.left=0,d.top=0),c.css(d).addClass(this.options.itemClass),this.updateSortData(c,!0),c},_init:function(a){this.$filteredAtoms=this._expandoSafe(this._filter(this.$allAtoms)),this._sort(),this.reLayout(a)},option:function(a){if(b.isPlainObject(a)){this.options=b.extend(!0,this.options,a);var c;for(var d in a)c="_update"+f(d),this[c]&&this[c]()}},_updateAnimationEngine:function(){var a=this.options.animationEngine.toLowerCase().replace(/[ _\-]/g,""),b;switch(a){case"css":case"none":b=!1;break;case"jquery":b=!0;break;default:b=!e.csstransitions}this.isUsingJQueryAnimation=b,this._updateUsingTransforms()},_updateTransformsEnabled:function(){this._updateUsingTransforms()},_updateUsingTransforms:function(){var a=this.usingTransforms=this.options.transformsEnabled&&e.csstransforms&&e.csstransitions&&!this.isUsingJQueryAnimation;a||(delete this.options.hiddenStyle.scale,delete this.options.visibleStyle.scale),this.getPositionStyles=a?this._translate:this._positionAbs},_filter:function(a){var b=this.options.filter===""?"*":this.options.filter;if(!b)return a;var c=this.options.hiddenClass,d="."+c,e=a.filter(d),f=e;if(b!=="*"){f=e.filter(b);var g=a.not(d).not(b).addClass(c);this.styleQueue.push({$el:g,style:this.options.hiddenStyle})}return this.styleQueue.push({$el:f,style:this.options.visibleStyle}),f.removeClass(c),a.filter(b)},updateSortData:function(a,c){var d=this,e=this.options.getSortData,f,g;a.each(function(){f=b(this),g={};for(var a in e)!c&&a==="original-order"?g[a]=b.data(this,"isotope-sort-data")[a]:g[a]=e[a](f,d);b.data(this,"isotope-sort-data",g)})},_sort:function(){var a=this.options.sortBy,b=this._getSorter,c=this.options.sortAscending?1:-1,d=function(d,e){var f=b(d,a),g=b(e,a);return f===g&&a!=="original-order"&&(f=b(d,"original-order"),g=b(e,"original-order")),(f>g?1:f<g?-1:0)*c};this.$filteredAtoms.sort(d)},_getSorter:function(a,c){return b.data(a,"isotope-sort-data")[c]},_translate:function(a,b){return{translate:[a,b]}},_positionAbs:function(a,b){return{left:a,top:b}},_pushPosition:function(a,b,c){b=Math.round(b+this.offset.left),c=Math.round(c+this.offset.top);var d=this.getPositionStyles(b,c);this.styleQueue.push({$el:a,style:d}),this.options.itemPositionDataEnabled&&a.data("isotope-item-position",{x:b,y:c})},layout:function(a,b){var c=this.options.layoutMode;this["_"+c+"Layout"](a);if(this.options.resizesContainer){var d=this["_"+c+"GetContainerSize"]();this.styleQueue.push({$el:this.element,style:d})}this._processStyleQueue(a,b),this.isLaidOut=!0},_processStyleQueue:function(a,c){var d=this.isLaidOut?this.isUsingJQueryAnimation?"animate":"css":"css",f=this.options.animationOptions,g=this.options.onLayout,h,i,j,k;i=function(a,b){b.$el[d](b.style,f)};if(this._isInserting&&this.isUsingJQueryAnimation)i=function(a,b){h=b.$el.hasClass("no-transition")?"css":d,b.$el[h](b.style,f)};else if(c||g||f.complete){var l=!1,m=[c,g,f.complete],n=this;j=!0,k=function(){if(l)return;var b;for(var c=0,d=m.length;c<d;c++)b=m[c],typeof b=="function"&&b.call(n.element,a,n);l=!0};if(this.isUsingJQueryAnimation&&d==="animate")f.complete=k,j=!1;else if(e.csstransitions){var o=0,p=this.styleQueue[0],s=p&&p.$el,t;while(!s||!s.length){t=this.styleQueue[o++];if(!t)return;s=t.$el}var u=parseFloat(getComputedStyle(s[0])[r]);u>0&&(i=function(a,b){b.$el[d](b.style,f).one(q,k)},j=!1)}}b.each(this.styleQueue,i),j&&k(),this.styleQueue=[]},resize:function(){this["_"+this.options.layoutMode+"ResizeChanged"]()&&this.reLayout()},reLayout:function(a){this["_"+this.options.layoutMode+"Reset"](),this.layout(this.$filteredAtoms,a)},addItems:function(a,b){var c=this._getAtoms(a);this.$allAtoms=this._expandoSafe(this.$allAtoms.add(c)),b&&b(c)},insert:function(a,b){this.element.append(a);var c=this;this.addItems(a,function(a){var d=c._filter(a);c._addHideAppended(d),c._sort(),c.reLayout(),c._revealAppended(d,b)})},appended:function(a,b){var c=this;this.addItems(a,function(a){c._addHideAppended(a),c.layout(a),c._revealAppended(a,b)})},_addHideAppended:function(a){this.$filteredAtoms=this._expandoSafe(this.$filteredAtoms.add(a)),a.addClass("no-transition"),this._isInserting=!0,this.styleQueue.push({$el:a,style:this.options.hiddenStyle})},_revealAppended:function(a,b){var c=this;setTimeout(function(){a.removeClass("no-transition"),c.styleQueue.push({$el:a,style:c.options.visibleStyle}),c._isInserting=!1,c._processStyleQueue(a,b)},10)},reloadItems:function(){this.$allAtoms=this._expandoSafe(this._getAtoms(this.element.children()))},remove:function(a,b){this.$allAtoms=this._expandoSafe(this.$allAtoms.not(a)),this.$filteredAtoms=this._expandoSafe(this.$filteredAtoms.not(a));var c=this,d=function(){a.remove(),b&&b.call(c.element)};a.filter(":not(."+this.options.hiddenClass+")").length?(this.styleQueue.push({$el:a,style:this.options.hiddenStyle}),this._sort(),this.reLayout(d)):d()},shuffle:function(a){this.updateSortData(this.$allAtoms),this.options.sortBy="random",this._sort(),this.reLayout(a)},destroy:function(){var a=this.usingTransforms,b=this.options;this.$allAtoms.removeClass(b.hiddenClass+" "+b.itemClass).each(function(){var b=this.style;b.position="",b.top="",b.left="",b.opacity="",a&&(b[i]="")});var c=this.element[0].style;for(var d in this.originalStyle)c[d]=this.originalStyle[d];this.element.unbind(".isotope").undelegate("."+b.hiddenClass,"click").removeClass(b.containerClass).removeData("isotope"),v.unbind(".isotope")},_getSegments:function(a){var b=this.options.layoutMode,c=a?"rowHeight":"columnWidth",d=a?"height":"width",e=a?"rows":"cols",g=this.element[d](),h,i=this.options[b]&&this.options[b][c]||this.$filteredAtoms["outer"+f(d)](!0)||g;h=Math.floor(g/i),h=Math.max(h,1),this[b][e]=h,this[b][c]=i},_checkIfSegmentsChanged:function(a){var b=this.options.layoutMode,c=a?"rows":"cols",d=this[b][c];return this._getSegments(a),this[b][c]!==d},_masonryReset:function(){this.masonry={},this._getSegments();var a=this.masonry.cols;this.masonry.colYs=[];while(a--)this.masonry.colYs.push(0)},_masonryLayout:function(a){var c=this,d=c.masonry;a.each(function(){var a=b(this),e=Math.ceil(a.outerWidth(!0)/d.columnWidth);e=Math.min(e,d.cols);if(e===1)c._masonryPlaceBrick(a,d.colYs);else{var f=d.cols+1-e,g=[],h,i;for(i=0;i<f;i++)h=d.colYs.slice(i,i+e),g[i]=Math.max.apply(Math,h);c._masonryPlaceBrick(a,g)}})},_masonryPlaceBrick:function(a,b){var c=Math.min.apply(Math,b),d=0;for(var e=0,f=b.length;e<f;e++)if(b[e]===c){d=e;break}var g=this.masonry.columnWidth*d,h=c;this._pushPosition(a,g,h);var i=c+a.outerHeight(!0),j=this.masonry.cols+1-f;for(e=0;e<j;e++)this.masonry.colYs[d+e]=i},_masonryGetContainerSize:function(){var a=Math.max.apply(Math,this.masonry.colYs);return{height:a}},_masonryResizeChanged:function(){return this._checkIfSegmentsChanged()},_fitRowsReset:function(){this.fitRows={x:0,y:0,height:0}},_fitRowsLayout:function(a){var c=this,d=this.element.width(),e=this.fitRows;a.each(function(){var a=b(this),f=a.outerWidth(!0),g=a.outerHeight(!0);e.x!==0&&f+e.x>d&&(e.x=0,e.y=e.height),c._pushPosition(a,e.x,e.y),e.height=Math.max(e.y+g,e.height),e.x+=f})},_fitRowsGetContainerSize:function(){return{height:this.fitRows.height}},_fitRowsResizeChanged:function(){return!0},_cellsByRowReset:function(){this.cellsByRow={index:0},this._getSegments(),this._getSegments(!0)},_cellsByRowLayout:function(a){var c=this,d=this.cellsByRow;a.each(function(){var a=b(this),e=d.index%d.cols,f=Math.floor(d.index/d.cols),g=(e+.5)*d.columnWidth-a.outerWidth(!0)/2,h=(f+.5)*d.rowHeight-a.outerHeight(!0)/2;c._pushPosition(a,g,h),d.index++})},_cellsByRowGetContainerSize:function(){return{height:Math.ceil(this.$filteredAtoms.length/this.cellsByRow.cols)*this.cellsByRow.rowHeight+this.offset.top}},_cellsByRowResizeChanged:function(){return this._checkIfSegmentsChanged()},_straightDownReset:function(){this.straightDown={y:0}},_straightDownLayout:function(a){var c=this;a.each(function(a){var d=b(this);c._pushPosition(d,0,c.straightDown.y),c.straightDown.y+=d.outerHeight(!0)})},_straightDownGetContainerSize:function(){return{height:this.straightDown.y}},_straightDownResizeChanged:function(){return!0},_masonryHorizontalReset:function(){this.masonryHorizontal={},this._getSegments(!0);var a=this.masonryHorizontal.rows;this.masonryHorizontal.rowXs=[];while(a--)this.masonryHorizontal.rowXs.push(0)},_masonryHorizontalLayout:function(a){var c=this,d=c.masonryHorizontal;a.each(function(){var a=b(this),e=Math.ceil(a.outerHeight(!0)/d.rowHeight);e=Math.min(e,d.rows);if(e===1)c._masonryHorizontalPlaceBrick(a,d.rowXs);else{var f=d.rows+1-e,g=[],h,i;for(i=0;i<f;i++)h=d.rowXs.slice(i,i+e),g[i]=Math.max.apply(Math,h);c._masonryHorizontalPlaceBrick(a,g)}})},_masonryHorizontalPlaceBrick:function(a,b){var c=Math.min.apply(Math,b),d=0;for(var e=0,f=b.length;e<f;e++)if(b[e]===c){d=e;break}var g=c,h=this.masonryHorizontal.rowHeight*d;this._pushPosition(a,g,h);var i=c+a.outerWidth(!0),j=this.masonryHorizontal.rows+1-f;for(e=0;e<j;e++)this.masonryHorizontal.rowXs[d+e]=i},_masonryHorizontalGetContainerSize:function(){var a=Math.max.apply(Math,this.masonryHorizontal.rowXs);return{width:a}},_masonryHorizontalResizeChanged:function(){return this._checkIfSegmentsChanged(!0)},_fitColumnsReset:function(){this.fitColumns={x:0,y:0,width:0}},_fitColumnsLayout:function(a){var c=this,d=this.element.height(),e=this.fitColumns;a.each(function(){var a=b(this),f=a.outerWidth(!0),g=a.outerHeight(!0);e.y!==0&&g+e.y>d&&(e.x=e.width,e.y=0),c._pushPosition(a,e.x,e.y),e.width=Math.max(e.x+f,e.width),e.y+=g})},_fitColumnsGetContainerSize:function(){return{width:this.fitColumns.width}},_fitColumnsResizeChanged:function(){return!0},_cellsByColumnReset:function(){this.cellsByColumn={index:0},this._getSegments(),this._getSegments(!0)},_cellsByColumnLayout:function(a){var c=this,d=this.cellsByColumn;a.each(function(){var a=b(this),e=Math.floor(d.index/d.rows),f=d.index%d.rows,g=(e+.5)*d.columnWidth-a.outerWidth(!0)/2,h=(f+.5)*d.rowHeight-a.outerHeight(!0)/2;c._pushPosition(a,g,h),d.index++})},_cellsByColumnGetContainerSize:function(){return{width:Math.ceil(this.$filteredAtoms.length/this.cellsByColumn.rows)*this.cellsByColumn.columnWidth}},_cellsByColumnResizeChanged:function(){return this._checkIfSegmentsChanged(!0)},_straightAcrossReset:function(){this.straightAcross={x:0}},_straightAcrossLayout:function(a){var c=this;a.each(function(a){var d=b(this);c._pushPosition(d,c.straightAcross.x,0),c.straightAcross.x+=d.outerWidth(!0)})},_straightAcrossGetContainerSize:function(){return{width:this.straightAcross.x}},_straightAcrossResizeChanged:function(){return!0}},b.fn.imagesLoaded=function(a){function h(){a.call(c,d)}function i(a){var c=a.target;c.src!==f&&b.inArray(c,g)===-1&&(g.push(c),--e<=0&&(setTimeout(h),d.unbind(".imagesLoaded",i)))}var c=this,d=c.find("img").add(c.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",g=[];return e||h(),d.bind("load.imagesLoaded error.imagesLoaded",i).each(function(){var a=this.src;this.src=f,this.src=a}),c};var w=function(b){a.console&&a.console.error(b)};b.fn.isotope=function(a,c){if(typeof a=="string"){var d=Array.prototype.slice.call(arguments,1);this.each(function(){var c=b.data(this,"isotope");if(!c){w("cannot call methods on isotope prior to initialization; attempted to call method '"+a+"'");return}if(!b.isFunction(c[a])||a.charAt(0)==="_"){w("no such method '"+a+"' for isotope instance");return}c[a].apply(c,d)})}else this.each(function(){var d=b.data(this,"isotope");d?(d.option(a),d._init(c)):b.data(this,"isotope",new b.Isotope(a,this,c))});return this}})(window,jQuery);
- // Isotope init
- // ------------------
- $(document).on('ready pjax:success', function() {
- $(function () {
- var $isotopeContainer = $('#isotope-team');
- $isotopeContainer.isotope({
- // options
- //filter: '.metal',
- itemSelector : '.item'
- });
- var $optionSets = $('#filters'),
- $optionLinks = $optionSets.find('a');
- // filter Meet the Team items when filter link is clicked
- $optionLinks.click(function(){
- var $this = $(this);
- // don't proceed if already selected
- if ( $this.hasClass('selected') ) {
- return false;
- }
- $optionSets.find('.selected').removeClass('selected');
- $this.addClass('selected');
- var selector = $this.attr('data-filter');
- $isotopeContainer.isotope({ filter: selector });
- return false;
- });
- });
- });
- /**
- * 7.) jquery.pjax.js - https://github.com/defunkt/jquery-pjax
- */
- // jquery.pjax.js
- // copyright chris wanstrath
- // https://github.com/defunkt/jquery-pjax
- (function($){
- // When called on a container with a selector, fetches the href with
- // ajax into the container or with the data-pjax attribute on the link
- // itself.
- //
- // Tries to make sure the back button and ctrl+click work the way
- // you'd expect.
- //
- // Exported as $.fn.pjax
- //
- // Accepts a jQuery ajax options object that may include these
- // pjax specific options:
- //
- //
- // container - Where to stick the response body. Usually a String selector.
- // $(container).html(xhr.responseBody)
- // (default: current jquery context)
- // push - Whether to pushState the URL. Defaults to true (of course).
- // replace - Want to use replaceState instead? That's cool.
- //
- // For convenience the second parameter can be either the container or
- // the options object.
- //
- // Returns the jQuery object
- function fnPjax(selector, container, options) {
- var context = this
- return this.on('click.pjax', selector, function(event) {
- var opts = $.extend({}, optionsFor(container, options))
- if (!opts.container)
- opts.container = $(this).attr('data-pjax') || context
- handleClick(event, opts)
- })
- }
- // Public: pjax on click handler
- //
- // Exported as $.pjax.click.
- //
- // event - "click" jQuery.Event
- // options - pjax options
- //
- // Examples
- //
- // $(document).on('click', 'a', $.pjax.click)
- // // is the same as
- // $(document).pjax('a')
- //
- // $(document).on('click', 'a', function(event) {
- // var container = $(this).closest('[data-pjax-container]')
- // $.pjax.click(event, container)
- // })
- //
- // Returns nothing.
- function handleClick(event, container, options) {
- options = optionsFor(container, options)
- var link = event.currentTarget
- if (link.tagName.toUpperCase() !== 'A')
- throw "$.fn.pjax or $.pjax.click requires an anchor element"
- // Middle click, cmd click, and ctrl click should open
- // links in a new tab as normal.
- if ( event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey )
- return
- // Ignore cross origin links
- if ( location.protocol !== link.protocol || location.host !== link.host )
- return
- // Ignore anchors on the same page
- if (link.hash && link.href.replace(link.hash, '') ===
- location.href.replace(location.hash, ''))
- return
- // Ignore empty anchor "foo.html#"
- if (link.href === location.href + '#')
- return
- var defaults = {
- url: link.href,
- container: $(link).attr('data-pjax'),
- target: link,
- fragment: null
- }
- pjax($.extend({}, defaults, options))
- event.preventDefault()
- }
- // Public: pjax on form submit handler
- //
- // Exported as $.pjax.submit
- //
- // event - "click" jQuery.Event
- // options - pjax options
- //
- // Examples
- //
- // $(document).on('submit', 'form', function(event) {
- // var container = $(this).closest('[data-pjax-container]')
- // $.pjax.submit(event, container)
- // })
- //
- // Returns nothing.
- function handleSubmit(event, container, options) {
- options = optionsFor(container, options)
- var form = event.currentTarget
- if (form.tagName.toUpperCase() !== 'FORM')
- throw "$.pjax.submit requires a form element"
- var defaults = {
- type: form.method,
- url: form.action,
- data: $(form).serializeArray(),
- container: $(form).attr('data-pjax'),
- target: form,
- fragment: null
- }
- pjax($.extend({}, defaults, options))
- event.preventDefault()
- }
- // Loads a URL with ajax, puts the response body inside a container,
- // then pushState()'s the loaded URL.
- //
- // Works just like $.ajax in that it accepts a jQuery ajax
- // settings object (with keys like url, type, data, etc).
- //
- // Accepts these extra keys:
- //
- // container - Where to stick the response body.
- // $(container).html(xhr.responseBody)
- // push - Whether to pushState the URL. Defaults to true (of course).
- // replace - Want to use replaceState instead? That's cool.
- //
- // Use it just like $.ajax:
- //
- // var xhr = $.pjax({ url: this.href, container: '#main' })
- // console.log( xhr.readyState )
- //
- // Returns whatever $.ajax returns.
- function pjax(options) {
- options = $.extend(true, {}, $.ajaxSettings, pjax.defaults, options)
- if ($.isFunction(options.url)) {
- options.url = options.url()
- }
- var target = options.target
- var hash = parseURL(options.url).hash
- var context = options.context = findContainerFor(options.container)
- // We want the browser to maintain two separate internal caches: one
- // for pjax'd partial page loads and one for normal page loads.
- // Without adding this secret parameter, some browsers will often
- // confuse the two.
- if (!options.data) options.data = {}
- options.data._pjax = context.selector
- function fire(type, args) {
- var event = $.Event(type, { relatedTarget: target })
- context.trigger(event, args)
- return !event.isDefaultPrevented()
- }
- var timeoutTimer
- options.beforeSend = function(xhr, settings) {
- // No timeout for non-GET requests
- // Its not safe to request the resource again with a fallback method.
- if (settings.type !== 'GET') {
- settings.timeout = 0
- }
- xhr.setRequestHeader('X-PJAX', 'true')
- xhr.setRequestHeader('X-PJAX-Container', context.selector)
- var result
- if (!fire('pjax:beforeSend', [xhr, settings]))
- return false
- if (settings.timeout > 0) {
- timeoutTimer = setTimeout(function() {
- if (fire('pjax:timeout', [xhr, options]))
- xhr.abort('timeout')
- }, settings.timeout)
- // Clear timeout setting so jquerys internal timeout isn't invoked
- settings.timeout = 0
- }
- options.requestUrl = parseURL(settings.url).href
- }
- options.complete = function(xhr, textStatus) {
- if (timeoutTimer)
- clearTimeout(timeoutTimer)
- fire('pjax:complete', [xhr, textStatus, options])
- fire('pjax:end', [xhr, options])
- }
- options.error = function(xhr, textStatus, errorThrown) {
- var container = extractContainer("", xhr, options)
- var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options])
- if (options.type == 'GET' && textStatus !== 'abort' && allowed) {
- locationReplace(container.url)
- }
- }
- options.success = function(data, status, xhr) {
- var container = extractContainer(data, xhr, options)
- if (!container.contents) {
- locationReplace(container.url)
- return
- }
- pjax.state = {
- id: options.id || uniqueId(),
- url: container.url,
- title: container.title,
- container: context.selector,
- fragment: options.fragment,
- timeout: options.timeout
- }
- if (options.push || options.replace) {
- window.history.replaceState(pjax.state, container.title, container.url)
- }
- if (container.title) document.title = container.title
- context.html(container.contents)
- // Scroll to top by default
- if (typeof options.scrollTo === 'number')
- $(window).scrollTop(options.scrollTo)
- // Google Analytics support
- if ( (options.replace || options.push) && window._gaq )
- _gaq.push(['_trackPageview'])
- // If the URL has a hash in it, make sure the browser
- // knows to navigate to the hash.
- if ( hash !== '' ) {
- // Avoid using simple hash set here. Will add another history
- // entry. Replace the url with replaceState and scroll to target
- // by hand.
- //
- // window.location.hash = hash
- var url = parseURL(container.url)
- url.hash = hash
- pjax.state.url = url.href
- window.history.replaceState(pjax.state, container.title, url.href)
- var target = $(url.hash)
- if (target.length) $(window).scrollTop(target.offset().top)
- }
- fire('pjax:success', [data, status, xhr, options])
- }
- // Initialize pjax.state for the initial page load. Assume we're
- // using the container and options of the link we're loading for the
- // back button to the initial page. This ensures good back button
- // behavior.
- if (!pjax.state) {
- pjax.state = {
- id: uniqueId(),
- url: window.location.href,
- title: document.title,
- container: context.selector,
- fragment: options.fragment,
- timeout: options.timeout
- }
- window.history.replaceState(pjax.state, document.title)
- }
- // Cancel the current request if we're already pjaxing
- var xhr = pjax.xhr
- if ( xhr && xhr.readyState < 4) {
- xhr.onreadystatechange = $.noop
- xhr.abort()
- }
- pjax.options = options
- var xhr = pjax.xhr = $.ajax(options)
- if (xhr.readyState > 0) {
- if (options.push && !options.replace) {
- // Cache current container element before replacing it
- cachePush(pjax.state.id, context.clone().contents())
- window.history.pushState(null, "", stripPjaxParam(options.requestUrl))
- }
- fire('pjax:start', [xhr, options])
- fire('pjax:send', [xhr, options])
- }
- return pjax.xhr
- }
- // Public: Reload current page with pjax.
- //
- // Returns whatever $.pjax returns.
- function pjaxReload(container, options) {
- var defaults = {
- url: window.location.href,
- push: false,
- replace: true,
- scrollTo: false
- }
- return pjax($.extend(defaults, optionsFor(container, options)))
- }
- // Internal: Hard replace current state with url.
- //
- // Work for around WebKit
- // https://bugs.webkit.org/show_bug.cgi?id=93506
- //
- // Returns nothing.
- function locationReplace(url) {
- window.history.replaceState(null, "", "#")
- window.location.replace(url)
- }
- // popstate handler takes care of the back and forward buttons
- //
- // You probably shouldn't use pjax on pages with other pushState
- // stuff yet.
- function onPjaxPopstate(event) {
- var state = event.state
- if (state && state.container) {
- var container = $(state.container)
- if (container.length) {
- var contents = cacheMapping[state.id]
- if (pjax.state) {
- // Since state ids always increase, we can deduce the history
- // direction from the previous state.
- var direction = pjax.state.id < state.id ? 'forward' : 'back'
- // Cache current container before replacement and inform the
- // cache which direction the history shifted.
- cachePop(direction, pjax.state.id, container.clone().contents())
- } else {
- // Page was reloaded but we have an existing history entry.
- // Set it to our initial state.
- pjax.state = state;
- return;
- }
- var popstateEvent = $.Event('pjax:popstate', {
- state: state,
- direction: direction
- })
- container.trigger(popstateEvent)
- var options = {
- id: state.id,
- url: state.url,
- container: container,
- push: false,
- fragment: state.fragment,
- timeout: state.timeout,
- scrollTo: false
- }
- if (contents) {
- container.trigger('pjax:start', [null, options])
- if (state.title) document.title = state.title
- container.html(contents)
- pjax.state = state
- container.trigger('pjax:end', [null, options])
- } else {
- pjax(options)
- }
- // Force reflow/relayout before the browser tries to restore the
- // scroll position.
- container[0].offsetHeight
- } else {
- locationReplace(location.href)
- }
- }
- }
- // Fallback version of main pjax function for browsers that don't
- // support pushState.
- //
- // Returns nothing since it retriggers a hard form submission.
- function fallbackPjax(options) {
- var url = $.isFunction(options.url) ? options.url() : options.url,
- method = options.type ? options.type.toUpperCase() : 'GET'
- var form = $('<form>', {
- method: method === 'GET' ? 'GET' : 'POST',
- action: url,
- style: 'display:none'
- })
- if (method !== 'GET' && method !== 'POST') {
- form.append($('<input>', {
- type: 'hidden',
- name: '_method',
- value: method.toLowerCase()
- }))
- }
- var data = options.data
- if (typeof data === 'string') {
- $.each(data.split('&'), function(index, value) {
- var pair = value.split('=')
- form.append($('<input>', {type: 'hidden', name: pair[0], value: pair[1]}))
- })
- } else if (typeof data === 'object') {
- for (key in data)
- form.append($('<input>', {type: 'hidden', name: key, value: data[key]}))
- }
- $(document.body).append(form)
- form.submit()
- }
- // Internal: Generate unique id for state object.
- //
- // Use a timestamp instead of a counter since ids should still be
- // unique across page loads.
- //
- // Returns Number.
- function uniqueId() {
- return (new Date).getTime()
- }
- // Internal: Strips _pjax param from url
- //
- // url - String
- //
- // Returns String.
- function stripPjaxParam(url) {
- return url
- .replace(/\?_pjax=[^&]+&?/, '?')
- .replace(/_pjax=[^&]+&?/, '')
- .replace(/[\?&]$/, '')
- }
- // Internal: Parse URL components and returns a Locationish object.
- //
- // url - String URL
- //
- // Returns HTMLAnchorElement that acts like Location.
- function parseURL(url) {
- var a = document.createElement('a')
- a.href = url
- return a
- }
- // Internal: Build options Object for arguments.
- //
- // For convenience the first parameter can be either the container or
- // the options object.
- //
- // Examples
- //
- // optionsFor('#container')
- // // => {container: '#container'}
- //
- // optionsFor('#container', {push: true})
- // // => {container: '#container', push: true}
- //
- // optionsFor({container: '#container', push: true})
- // // => {container: '#container', push: true}
- //
- // Returns options Object.
- function optionsFor(container, options) {
- // Both container and options
- if ( container && options )
- options.container = container
- // First argument is options Object
- else if ( $.isPlainObject(container) )
- options = container
- // Only container
- else
- options = {container: container}
- // Find and validate container
- if (options.container)
- options.container = findContainerFor(options.container)
- return options
- }
- // Internal: Find container element for a variety of inputs.
- //
- // Because we can't persist elements using the history API, we must be
- // able to find a String selector that will consistently find the Element.
- //
- // container - A selector String, jQuery object, or DOM Element.
- //
- // Returns a jQuery object whose context is `document` and has a selector.
- function findContainerFor(container) {
- container = $(container)
- if ( !container.length ) {
- throw "no pjax container for " + container.selector
- } else if ( container.selector !== '' && container.context === document ) {
- return container
- } else if ( container.attr('id') ) {
- return $('#' + container.attr('id'))
- } else {
- throw "cant get selector for pjax container!"
- }
- }
- // Internal: Filter and find all elements matching the selector.
- //
- // Where $.fn.find only matches descendants, findAll will test all the
- // top level elements in the jQuery object as well.
- //
- // elems - jQuery object of Elements
- // selector - String selector to match
- //
- // Returns a jQuery object.
- function findAll(elems, selector) {
- return elems.filter(selector).add(elems.find(selector));
- }
- // Internal: Extracts container and metadata from response.
- //
- // 1. Extracts X-PJAX-URL header if set
- // 2. Extracts inline <title> tags
- // 3. Builds response Element and extracts fragment if set
- //
- // data - String response data
- // xhr - XHR response
- // options - pjax options Object
- //
- // Returns an Object with url, title, and contents keys.
- function extractContainer(data, xhr, options) {
- var obj = {}
- // Prefer X-PJAX-URL header if it was set, otherwise fallback to
- // using the original requested url.
- obj.url = stripPjaxParam(xhr.getResponseHeader('X-PJAX-URL') || options.requestUrl)
- // Attempt to parse response html into elements
- if (/<html/i.test(data)) {
- var $head = $(data.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0])
- var $body = $(data.match(/<body[^>]*>([\s\S.]*)<\/body>/i)[0])
- } else {
- var $head = $body = $(data)
- }
- // If response data is empty, return fast
- if ($body.length === 0)
- return obj
- // If there's a <title> tag in the header, use it as
- // the page's title.
- obj.title = findAll($head, 'title').last().text()
- if (options.fragment) {
- // If they specified a fragment, look for it in the response
- // and pull it out.
- if (options.fragment === 'body') {
- var $fragment = $body
- } else {
- var $fragment = findAll($body, options.fragment).first()
- }
- if ($fragment.length) {
- obj.contents = $fragment.contents()
- // If there's no title, look for data-title and title attributes
- // on the fragment
- if (!obj.title)
- obj.title = $fragment.attr('title') || $fragment.data('title')
- }
- } else if (!/<html/i.test(data)) {
- obj.contents = $body
- }
- // Clean up any <title> tags
- if (obj.contents) {
- // Remove any parent title elements
- obj.contents = obj.contents.not('title')
- // Then scrub any titles from their descendents
- obj.contents.find('title').remove()
- }
- // Trim any whitespace off the title
- if (obj.title) obj.title = $.trim(obj.title)
- return obj
- }
- // Internal: History DOM caching class.
- var cacheMapping = {}
- var cacheForwardStack = []
- var cacheBackStack = []
- // Push previous state id and container contents into the history
- // cache. Should be called in conjunction with `pushState` to save the
- // previous container contents.
- //
- // id - State ID Number
- // value - DOM Element to cache
- //
- // Returns nothing.
- function cachePush(id, value) {
- cacheMapping[id] = value
- cacheBackStack.push(id)
- // Remove all entires in forward history stack after pushing
- // a new page.
- while (cacheForwardStack.length)
- delete cacheMapping[cacheForwardStack.shift()]
- // Trim back history stack to max cache length.
- while (cacheBackStack.length > pjax.defaults.maxCacheLength)
- delete cacheMapping[cacheBackStack.shift()]
- }
- // Shifts cache from directional history cache. Should be
- // called on `popstate` with the previous state id and container
- // contents.
- //
- // direction - "forward" or "back" String
- // id - State ID Number
- // value - DOM Element to cache
- //
- // Returns nothing.
- function cachePop(direction, id, value) {
- var pushStack, popStack
- cacheMapping[id] = value
- if (direction === 'forward') {
- pushStack = cacheBackStack
- popStack = cacheForwardStack
- } else {
- pushStack = cacheForwardStack
- popStack = cacheBackStack
- }
- pushStack.push(id)
- if (id = popStack.pop())
- delete cacheMapping[id]
- }
- // Install pjax functions on $.pjax to enable pushState behavior.
- //
- // Does nothing if already enabled.
- //
- // Examples
- //
- // $.pjax.enable()
- //
- // Returns nothing.
- function enable() {
- $.fn.pjax = fnPjax
- $.pjax = pjax
- $.pjax.enable = $.noop
- $.pjax.disable = disable
- $.pjax.click = handleClick
- $.pjax.submit = handleSubmit
- $.pjax.reload = pjaxReload
- $.pjax.defaults = {
- timeout: 2000,
- push: true,
- replace: false,
- type: 'GET',
- dataType: 'html',
- scrollTo: 0,
- maxCacheLength: 20
- }
- $(window).bind('popstate.pjax', onPjaxPopstate)
- }
- // Disable pushState behavior.
- //
- // This is the case when a browser doesn't support pushState. It is
- // sometimes useful to disable pushState for debugging on a modern
- // browser.
- //
- // Examples
- //
- // $.pjax.disable()
- //
- // Returns nothing.
- function disable() {
- $.fn.pjax = function() { return this }
- $.pjax = fallbackPjax
- $.pjax.enable = enable
- $.pjax.disable = $.noop
- $.pjax.click = $.noop
- $.pjax.submit = $.noop
- $.pjax.reload = function() { window.location.reload() }
- $(window).unbind('popstate.pjax', onPjaxPopstate)
- }
- // Add the state property to jQuery's event object so we can use it in
- // $(window).bind('popstate')
- if ( $.inArray('state', $.event.props) < 0 )
- $.event.props.push('state')
- // Is pjax supported by this browser?
- $.support.pjax =
- window.history && window.history.pushState && window.history.replaceState &&
- // pushState isn't reliable on iOS until 5.
- !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/)
- $.support.pjax ? enable() : disable()
- })(jQuery);
- // LOAD DISQUS FUNCTION
- function loadDisqus() {
- var disqus_shortname = 'redstormentertainment';
- $.ajax({
- url: 'http://redstormentertainment.disqus.com/embed.js',
- dataType: 'script',
- cache: true // otherwise will get fresh copy every page load
- });
- }
- // LOAD SOCIALITE FUNCTION
- function loadSocialite() {
- $.ajax({
- url: '//www.redstorm.com/js/libs/socialite.custom.min.js?v=1.0.1',
- dataType: 'script',
- async: true,
- cache: true, // otherwise will get fresh copy every page load
- success: function() {
- // script loaded, do stuff!
- /* * * LOAD SOCIAL MEDIA SHARING BUTTONS * * */
- Socialite.load('#socialite');
- /* * * INITIATE FACEBOOK RECENT ACTIVITY WIDGET * * */
- if (typeof(FB) != 'undefined'
- && FB != null ) {
- FB.XFBML.parse(document.getElementById('news'));
- }
- }
- });
- }
- // LOAD ONLY FACEBOOK SDK
- function loadFacebookSDK() {
- $.ajax({
- url: 'http://connect.facebook.net/en_US/all.js',
- dataType: 'script',
- cache: true, // otherwise will get fresh copy every page load
- success: function () {
- /* * * INITIATE FACEBOOK RECENT ACTIVITY WIDGET * * */
- if (typeof(FB) != 'undefined'
- && FB != null ) {
- FB.XFBML.parse(document.getElementById('fb-activity'));
- }
- }
- });
- }
- /**
- * X.) Plugin Initialization Code
- * Author: John Bacon, Red Storm Entertainment
- */
- /*============================================================*/
- /* PJAX
- /*============================================================*/
- var pjaxSelection = ':not([data-skip-pjax])a';
- $(document).pjax(pjaxSelection, { container: '#pjax-container', fragment: '#pjax-container', timeout: 2000, maxCacheLength: 2});
- $(document).on('pjax:send', function() {
- $('#loading').show()
- })
- $(document).on('pjax:complete', function() {
- $('#loading').hide()
- })
- $(document).on('pjax:timeout', function(event) {
- // Prevent default timeout redirection behavior
- event.preventDefault()
- })
- // Temporary fix (duplicate code) until we figure out what is causing issues in IE8
- $(document).ready(function() {
- // FlexSlider
- // ----------
- $('#slider-main').flexslider({
- directionNav: false,
- animation: 'fade',
- animationDuration: 600,
- manualControls: '.flex-control-nav li',
- // Removes spin.gif from background
- start: function () {
- $('.slides').css('background', 'none');
- }
- });
- $('#slider').flexslider({
- animation: "slide",
- controlNav: true,
- animationLoop: false,
- slideshow: false,
- sync: "#carousel",
- start: function () {
- $('#slider .flex-viewport').css('opacity', '100');
- $('#slider').css('background-image', 'none');
- }
- });
- // The slider being synced must be initialized first
- $('#carousel').flexslider({
- animation: "slide",
- controlNav: false,
- animationLoop: false,
- slideshow: false,
- itemWidth: 210,
- itemMargin: 5,
- asNavFor: '#slider',
- start: function () {
- $('#carousel .flex-viewport').css('opacity', '100');
- $('#carousel').css('background-image', 'none');
- }
- });
- // bxSlider
- // --------
- $('#gallery').removeClass('is-hidden').bxSlider({
- mode: 'horizontal',
- minSlides: 2,
- maxSlides: 2,
- slideWidth: 305,
- slideMargin: 0,
- infiniteLoop: false,
- hideControlOnEnd: true,
- nextText: '',
- prevText: '',
- pager: false,
- displaySlideQty: 2,
- moveSlideQty: 1,
- speed: 250
- });
- $('#four-gallery').removeClass('is-hidden').bxSlider({
- mode: 'horizontal',
- minSlides: 4,
- maxSlides: 4,
- slideWidth: 180,
- slideMargin: 0,
- infiniteLoop: false,
- hideControlOnEnd: true,
- nextText: '',
- prevText: '',
- pager: false,
- displaySlideQty: 4,
- moveSlideQty: 2,
- speed: 250
- });
- $('#archive-list').removeClass('is-hidden').bxSlider({
- mode: 'horizontal',
- infiniteLoop: false,
- hideControlOnEnd: true,
- nextText: '',
- prevText: '',
- pager: false,
- speed: 500
- });
- // Accordion script
- // ----------------
- var $accordion = $('.accordion-heading');
- $accordion.click(function () {
- if( $(this).next().is(':hidden') ) {
- $accordion.removeClass('active').next().slideUp();
- $(this).addClass('active').next().slideDown();
- }
- return false;
- });
- // FancyBox
- // --------
- var $thumb = $('.thumb');
- $thumb.fancybox({
- loop: true,
- helpers : {
- title : { type : 'over' }
- }
- });
- // jQuery Placeholder
- // ------------------
- $('input, textarea').placeholder();
- // Asteroids link-up
- // -----------------
- $('#logo-link').click(function() {
- $.getScript('/js/mylibs/asteroids.min.js?v=1.0.1');
- return false;
- });
- // // Facebook
- // if ( $('#twitter-news').length > 0 ) {
- // // run the app
- // FB.XFBML.parse();
- // };
- $(function loadAJAX() {
- var disqus_shortname = 'redstormentertainment'; // required: replace example with your forum shortname
- if ( $("#news").length > 0 ) {
- if ( $("#socialite").length > 0 ) {
- var initSocialite = loadSocialite();
- var initDisqus = loadDisqus();
- } else {
- var initFacebookSDK = loadFacebookSDK();
- }
- }
- });
- });
- // will fire on initial page load (document.ready), and subsequent PJAX page loads
- $(document).on('pjax:success', function() {
- // FlexSlider
- // ----------
- $('#slider-main').flexslider({
- directionNav: false,
- animation: 'fade',
- animationDuration: 600,
- manualControls: '.flex-control-nav li',
- // Removes spin.gif from background
- start: function () {
- $('.slides').css('background', 'none');
- }
- });
- $('#slider').flexslider({
- animation: "slide",
- controlNav: true,
- animationLoop: false,
- slideshow: false,
- sync: "#carousel",
- start: function () {
- $('#slider .flex-viewport').css('opacity', '100');
- $('#slider').css('background-image', 'none');
- }
- });
- // The slider being synced must be initialized first
- $('#carousel').flexslider({
- animation: "slide",
- controlNav: false,
- animationLoop: false,
- slideshow: false,
- itemWidth: 210,
- itemMargin: 5,
- asNavFor: '#slider',
- start: function () {
- $('#carousel .flex-viewport').css('opacity', '100');
- $('#carousel').css('background-image', 'none');
- }
- });
- // bxSlider
- // --------
- $('#gallery').removeClass('is-hidden').bxSlider({
- mode: 'horizontal',
- minSlides: 2,
- maxSlides: 2,
- slideWidth: 305,
- slideMargin: 0,
- infiniteLoop: false,
- hideControlOnEnd: true,
- nextText: '',
- prevText: '',
- pager: false,
- displaySlideQty: 2,
- moveSlideQty: 1,
- speed: 250
- });
- $('#four-gallery').removeClass('is-hidden').bxSlider({
- mode: 'horizontal',
- minSlides: 4,
- maxSlides: 4,
- slideWidth: 180,
- slideMargin: 0,
- infiniteLoop: false,
- hideControlOnEnd: true,
- nextText: '',
- prevText: '',
- pager: false,
- displaySlideQty: 4,
- moveSlideQty: 2,
- speed: 250
- });
- $('#archive-list').removeClass('is-hidden').bxSlider({
- mode: 'horizontal',
- infiniteLoop: false,
- hideControlOnEnd: true,
- nextText: '',
- prevText: '',
- pager: false,
- speed: 500
- });
- // Accordion script
- // ----------------
- var $accordion = $('.accordion-heading');
- $accordion.click(function () {
- if( $(this).next().is(':hidden') ) {
- $accordion.removeClass('active').next().slideUp();
- $(this).addClass('active').next().slideDown();
- }
- return false;
- });
- // FancyBox
- // --------
- var $thumb = $('.thumb');
- $thumb.fancybox({
- loop: true,
- helpers : {
- title : { type : 'over' }
- }
- });
- // jQuery Placeholder
- // ------------------
- $('input, textarea').placeholder();
- // Asteroids link-up
- // -----------------
- $('#logo-link').click(function() {
- $.getScript('/js/mylibs/asteroids.min.js?v=1.0.1');
- return false;
- });
- // // Facebook
- // if ( $('#twitter-news').length > 0 ) {
- // // run the app
- // FB.XFBML.parse();
- // };
- $(function loadAJAX() {
- var disqus_shortname = 'redstormentertainment'; // required: replace example with your forum shortname
- if ( $("#news").length > 0 ) {
- if ( $("#socialite").length > 0 ) {
- var initSocialite = loadSocialite();
- var initDisqus = loadDisqus();
- } else {
- var initFacebookSDK = loadFacebookSDK();
- }
- }
- });
- });
Add Comment
Please, Sign In to add comment