/*jslint single: true, devel: true, this: true, for: true, white: true, browser: true, */ /*global window, localStorage, setTimeout, jQuery, document, confirm, google, Modernizr */ // jQuery Parallax Plugin, used for parallax background effect on home page /* Plugin: jQuery Parallax Version 1.1.3 Author: Ian Lunn Twitter: @IanLunn Author URL: http://www.ianlunn.co.uk/ Plugin URL: http://www.ianlunn.co.uk/plugins/jquery-parallax/ Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html */ (function( $ ){ var $window = $(window); var windowHeight = $window.height(); $window.resize(function () { windowHeight = $window.height(); }); $.fn.parallax = function(xpos, speedFactor, outerHeight) { var $this = $(this); var getHeight; var firstTop; var paddingTop = 0; //get the starting position of each element to have parallax applied to it function update (){ $this.each(function(){ firstTop = $this.offset().top; }); if (outerHeight) { getHeight = function(jqo) { return jqo.outerHeight(true); }; } else { getHeight = function(jqo) { return jqo.height(); }; } // setup defaults if arguments aren't specified if (arguments.length < 1 || xpos === null) xpos = "50%"; if (arguments.length < 2 || speedFactor === null) speedFactor = 0.5; if (arguments.length < 3 || outerHeight === null) outerHeight = true; // function to be called whenever the window is scrolled or resized var pos = $window.scrollTop(); $this.each(function(){ var $element = $(this); var top = $element.offset().top; var height = getHeight($element); // Check if totally above or totally below viewport if (top + height < pos || top > pos + windowHeight) { return; } $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); }); } $window.bind('scroll', update).resize(update); update(); }; })(jQuery); // Fancybox Plugin, used for lightbox popup on product page/blog images /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */ (function(r,G,f,v){var J=f("html"),n=f(r),p=f(G),b=f.fancybox=function(){b.open.apply(this,arguments)},I=navigator.userAgent.match(/msie/i),B=null,s=G.createTouch!==v,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},q=function(a){return a&&"string"===f.type(a)},E=function(a){return q(a)&&0
',image:'',iframe:'",error:'

The requested content cannot be loaded.
Please try again later.

',closeBtn:'',next:'',prev:''},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0, openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1, isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k, c.metadata())):k=c);g=d.href||k.href||(q(c)?c:null);h=d.title!==v?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));q(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":q(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(q(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&& k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==v&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current|| b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer= setTimeout(b.next,b.current.playSpeed))},c=function(){d();p.unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==v&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({},e.dim,k)))},update:function(a){var d= a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(B),B=null);b.isOpen&&!B&&(B=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),B=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate")), b.update())},hideLoading:function(){p.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('
').click(b.cancel).appendTo("body");p.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||!1,d={x:n.scrollLeft(), y:n.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&r.innerWidth?r.innerWidth:n.width(),d.h=s&&r.innerHeight?r.innerHeight:n.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");p.unbind(".fb");n.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(n.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&p.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k=e.target||e.srcElement; if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,e){if(e&&b.helpers[d]&&f.isFunction(b.helpers[d][a]))b.helpers[d][a](f.extend(!0, {},b.helpers[d].defaults,e),c)});p.trigger(a)}},isImage:function(a){return q(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(a){return q(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1, mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio= !0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,w(d.padding[a]))});b.trigger("onReady");if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href"); "image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width/b.opts.pixelRatio;b.coming.height=this.height/b.opts.pixelRatio;b._afterLoad()};a.onerror=function(){this.onload= this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href); f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload, e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin, outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("
").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('
').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",!1)}));break;case "image":e=a.tpl.image.replace("{href}", g);break;case "swf":e='',h="",f.each(a.swf,function(a,b){e+='';h+=" "+a+'="'+b+'"'}),e+='"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");a.inner.css("overflow","yes"===k?"scroll": "no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth,p=h.maxHeight,s=h.scrolling,q=h.scrollOutside? h.scrollbarWidth:0,x=h.margin,y=l(x[1]+x[3]),r=l(x[0]+x[2]),v,z,t,C,A,F,B,D,H;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");x=l(k.outerWidth(!0)-k.width());v=l(k.outerHeight(!0)-k.height());z=y+x;t=r+v;C=E(c)?(a.w-z)*l(c)/100:c;A=E(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(H=h.content,h.autoHeight&&1===H.data("ready"))try{H[0].contentWindow.document.location&&(g.width(C).height(9999),F=H.contents().find("body"),q&&F.css("overflow-x","hidden"),A=F.outerHeight(!0))}catch(G){}}else if(h.autoWidth|| h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=l(C);j=l(A);D=C/A;m=l(E(m)?l(m,"w")-z:m);n=l(E(n)?l(n,"w")-z:n);u=l(E(u)?l(u,"h")-t:u);p=l(E(p)?l(p,"h")-t:p);F=n;B=p;h.fitToView&&(n=Math.min(a.w-z,n),p=Math.min(a.h-t,p));z=a.w-y;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/D)),j>p&&(j=p,c=l(j*D)),cz||y>r)&&(c>m&&j>u)&&!(19n&&(c=n,j=l(c/D)),g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height();else c=Math.max(m,Math.min(c,c-(a-z))),j=Math.max(u,Math.min(j,j-(y-r)));q&&("auto"===s&&jz||y>r)&&c>m&&j>u;c=h.aspectRatio?cu&&j
').appendTo(b.coming?b.coming.parent:a.parent);this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(n.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){if(f(a.target).hasClass("fancybox-overlay"))return b.isActive? b.close():d.close(),!1});this.overlay.css(a.css).show()},close:function(){var a,b;n.unbind("resize.overlay");this.el.hasClass("fancybox-lock")&&(f(".fancybox-margin").removeClass("fancybox-margin"),a=n.scrollTop(),b=n.scrollLeft(),this.el.removeClass("fancybox-lock"),n.scrollTop(a).scrollLeft(b));f(".fancybox-overlay").remove().hide();f.extend(this,{overlay:null,fixed:!1})},update:function(){var a="100%",b;this.overlay.width(a).height("100%");I?(b=Math.max(G.documentElement.offsetWidth,G.body.offsetWidth), p.width()>b&&(a=p.width())):p.width()>n.width()&&(a=p.width());this.overlay.width(a).height(p.height())},onReady:function(a,b){var e=this.overlay;f(".fancybox-overlay").stop(!0,!0);e||this.create(a);a.locked&&(this.fixed&&b.fixed)&&(e||(this.margin=p.height()>n.height()?f("html").css("margin-right").replace("px",""):!1),b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){var e,c;b.locked&&(!1!==this.margin&&(f("*").filter(function(){return"fixed"=== f(this).css("position")&&!f(this).hasClass("fancybox-overlay")&&!f(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),e=n.scrollTop(),c=n.scrollLeft(),this.el.addClass("fancybox-lock"),n.scrollTop(e).scrollLeft(c));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.coming&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d= b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(q(e)&&""!==f.trim(e)){d=f('
'+e+"
");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),I&&d.width(d.width()),d.wrapInner(''),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d, e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):p.undelegate(c,"click.fb-start").delegate(c+ ":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};p.ready(function(){var a,d;f.scrollbarWidth===v&&(f.scrollbarWidth=function(){var a=f('
').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===v){a=f.support;d=f('
').appendTo("body");var e=20=== d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")});a=f(r).width();J.addClass("fancybox-lock-test");d=f(r).width();J.removeClass("fancybox-lock-test");f("").appendTo("head")})})(window,document,jQuery); // jQuery UI Stars plugin, used for review stars form input and rating display /*! * jQuery UI Stars v3.0.1 * http://plugins.jquery.com/project/Star_Rating_widget * * Copyright (c) 2010 Marek "Orkan" Zajac (orkans@gmail.com) * Dual licensed under the MIT and GPL licenses. * http://docs.jquery.com/License * * $Rev: 164 $ * $Date:: 2010-05-01 #$ * $Build: 35 (2010-05-01) * * Depends: * jquery.ui.core.js * jquery.ui.widget.js * */ (function($) { $.widget('ui.stars', { options: { inputType: 'radio', // [radio|select] split: 0, // decrease number of stars by splitting each star into pieces [2|3|4|...] disabled: false, // set to [true] to make the stars initially disabled cancelTitle: 'Cancel Rating', cancelValue: 0, // default value of Cancel btn. cancelShow: true, disableValue: false, // set to [false] to not disable the hidden input when Cancel btn is clicked, so the value will present in POST data. oneVoteOnly: false, showTitles: false, captionEl: null, // jQuery object - target for text captions callback: null, // function(ui, type, value, event) /* * CSS classes */ starWidth: 16, // width of the star image cancelClass: 'ui-stars-cancel', starClass: 'ui-stars-star', starOnClass: 'ui-stars-star-on', starHoverClass: 'ui-stars-star-hover', starDisabledClass: 'ui-stars-star-disabled', cancelHoverClass: 'ui-stars-cancel-hover', cancelDisabledClass: 'ui-stars-cancel-disabled' }, _create: function() { var self = this, o = this.options, starId = 0; this.element.data('former.stars', this.element.html()); o.isSelect = o.inputType == 'select'; this.$form = $(this.element).closest('form'); this.$selec = o.isSelect ? $('select', this.element) : null; this.$rboxs = o.isSelect ? $('option', this.$selec) : $(':radio', this.element); /* * Map all inputs from $rboxs array to Stars elements */ this.$stars = this.$rboxs.map(function(i) { var el = { value: this.value, title: (o.isSelect ? this.text : this.title) || this.value, isDefault: (o.isSelect && this.defaultSelected) || this.defaultChecked }; if(i==0) { o.split = typeof o.split != 'number' ? 0 : o.split; o.val2id = []; o.id2val = []; o.id2title = []; o.name = o.isSelect ? self.$selec.get(0).name : this.name; o.disabled = o.disabled || (o.isSelect ? $(self.$selec).attr('disabled') : $(this).attr('disabled')); } /* * Consider it as a Cancel button? */ if(el.value == o.cancelValue) { o.cancelTitle = el.title; return null; } o.val2id[el.value] = starId; o.id2val[starId] = el.value; o.id2title[starId] = el.title; if(el.isDefault) { o.checked = starId; o.value = o.defaultValue = el.value; o.title = el.title; } var $s = $('
').addClass(o.starClass); var $a = $('').attr('title', o.showTitles ? el.title : '').text(el.value); /* * Prepare division settings */ if(o.split) { var oddeven = (starId % o.split); var stwidth = Math.floor(o.starWidth / o.split); $s.width(stwidth); $a.css('margin-left', '-' + (oddeven * stwidth) + 'px'); } starId++; return $s.append($a).get(0); }); /* * How many Stars? */ o.items = starId; /* * Remove old content */ o.isSelect ? this.$selec.remove() : this.$rboxs.remove(); /* * Append Stars interface */ this.$cancel = $('
').addClass(o.cancelClass).append( $('').attr('title', o.showTitles ? o.cancelTitle : '').text(o.cancelValue) ); o.cancelShow &= !o.disabled && !o.oneVoteOnly; o.cancelShow && this.element.append(this.$cancel); this.element.append(this.$stars); /* * Initial selection */ if(o.checked === undefined) { o.checked = -1; o.value = o.defaultValue = o.cancelValue; o.title = ''; } /* * The only FORM element, that has been linked to the stars control. The value field is updated on each Star click event */ this.$value = $(""); this.element.append(this.$value); /* * Attach stars event handler */ this.$stars.bind('click.stars', function(e) { if(!o.forceSelect && o.disabled) return false; var i = self.$stars.index(this); o.checked = i; o.value = o.id2val[i]; o.title = o.id2title[i]; self.$value.attr({disabled: o.disabled ? 'disabled' : '', value: o.value}); fillTo(i, false); self._disableCancel(); !o.forceSelect && self.callback(e, 'star'); }) .bind('mouseover.stars', function() { if(o.disabled) return false; var i = self.$stars.index(this); fillTo(i, true); }) .bind('mouseout.stars', function() { if(o.disabled) return false; fillTo(self.options.checked, false); }); /* * Attach cancel event handler */ this.$cancel.bind('click.stars', function(e) { if(!o.forceSelect && (o.disabled || o.value == o.cancelValue)) return false; o.checked = -1; o.value = o.cancelValue; o.title = ''; self.$value.val(o.value); o.disableValue && self.$value.attr({disabled: 'disabled'}); fillNone(); self._disableCancel(); !o.forceSelect && self.callback(e, 'cancel'); }) .bind('mouseover.stars', function() { if(self._disableCancel()) return false; self.$cancel.addClass(o.cancelHoverClass); fillNone(); self._showCap(o.cancelTitle); }) .bind('mouseout.stars', function() { if(self._disableCancel()) return false; self.$cancel.removeClass(o.cancelHoverClass); self.$stars.triggerHandler('mouseout.stars'); }); /* * Attach onReset event handler to the parent FORM */ this.$form.bind('reset.stars', function(){ !o.disabled && self.select(o.defaultValue); }); /* * Clean up to avoid memory leaks in certain versions of IE 6 */ $(window).unload(function(){ self.$cancel.unbind('.stars'); self.$stars.unbind('.stars'); self.$form.unbind('.stars'); self.$selec = self.$rboxs = self.$stars = self.$value = self.$cancel = self.$form = null; }); /* * Star selection helpers */ function fillTo(index, hover) { if(index != -1) { var addClass = hover ? o.starHoverClass : o.starOnClass; var remClass = hover ? o.starOnClass : o.starHoverClass; self.$stars.eq(index).prevAll('.' + o.starClass).andSelf().removeClass(remClass).addClass(addClass); self.$stars.eq(index).nextAll('.' + o.starClass).removeClass(o.starHoverClass + ' ' + o.starOnClass); self._showCap(o.id2title[index]); } else fillNone(); }; function fillNone() { self.$stars.removeClass(o.starOnClass + ' ' + o.starHoverClass); self._showCap(''); }; /* * Finally, set up the Stars */ this.select(o.value); o.disabled && this.disable(); }, /* * Private functions */ _disableCancel: function() { var o = this.options, disabled = o.disabled || o.oneVoteOnly || (o.value == o.cancelValue); if(disabled) this.$cancel.removeClass(o.cancelHoverClass).addClass(o.cancelDisabledClass); else this.$cancel.removeClass(o.cancelDisabledClass); this.$cancel.css('opacity', disabled ? 0.5 : 1); return disabled; }, _disableAll: function() { var o = this.options; this._disableCancel(); if(o.disabled) this.$stars.filter('div').addClass(o.starDisabledClass); else this.$stars.filter('div').removeClass(o.starDisabledClass); }, _showCap: function(s) { var o = this.options; if(o.captionEl) o.captionEl.text(s); }, /* * Public functions */ value: function() { return this.options.value; }, select: function(val) { var o = this.options, e = (val == o.cancelValue) ? this.$cancel : this.$stars.eq(o.val2id[val]); o.forceSelect = true; e.triggerHandler('click.stars'); o.forceSelect = false; }, selectID: function(id) { var o = this.options, e = (id == -1) ? this.$cancel : this.$stars.eq(id); o.forceSelect = true; e.triggerHandler('click.stars'); o.forceSelect = false; }, enable: function() { this.options.disabled = false; this._disableAll(); }, disable: function() { this.options.disabled = true; this._disableAll(); }, destroy: function() { this.$form.unbind('.stars'); this.$cancel.unbind('.stars').remove(); this.$stars.unbind('.stars').remove(); this.$value.remove(); this.element.unbind('.stars').html(this.element.data('former.stars')).removeData('stars'); return this; }, callback: function(e, type) { var o = this.options; o.callback && o.callback(this, type, o.value, e); o.oneVoteOnly && !o.disabled && this.disable(); } }); $.extend($.ui.stars, { version: '3.0.1' }); })(jQuery); // scrollReveal, used for fading in search results !function(){"use strict";function e(n){return"undefined"==typeof this||Object.getPrototypeOf(this)!==e.prototype?new e(n):(O=this,O.version="3.3.2",O.tools=new E,O.isSupported()?(O.tools.extend(O.defaults,n||{}),O.defaults.container=t(O.defaults),O.store={elements:{},containers:[]},O.sequences={},O.history=[],O.uid=0,O.initialized=!1):"undefined"!=typeof console&&null!==console,O)}function t(e){if(e&&e.container){if("string"==typeof e.container)return window.document.documentElement.querySelector(e.container);if(O.tools.isNode(e.container))return e.container}return O.defaults.container}function n(e,t){return"string"==typeof e?Array.prototype.slice.call(t.querySelectorAll(e)):O.tools.isNode(e)?[e]:O.tools.isNodeList(e)?Array.prototype.slice.call(e):[]}function i(){return++O.uid}function o(e,t,n){t.container&&(t.container=n),e.config?e.config=O.tools.extendClone(e.config,t):e.config=O.tools.extendClone(O.defaults,t),"top"===e.config.origin||"bottom"===e.config.origin?e.config.axis="Y":e.config.axis="X"}function r(e){var t=window.getComputedStyle(e.domEl);e.styles||(e.styles={transition:{},transform:{},computed:{}},e.styles.inline=e.domEl.getAttribute("style")||"",e.styles.inline+="; visibility: visible; ",e.styles.computed.opacity=t.opacity,t.transition&&"all 0s ease 0s"!==t.transition?e.styles.computed.transition=t.transition+", ":e.styles.computed.transition=""),e.styles.transition.instant=s(e,0),e.styles.transition.delayed=s(e,e.config.delay),e.styles.transform.initial=" -webkit-transform:",e.styles.transform.target=" -webkit-transform:",a(e),e.styles.transform.initial+="transform:",e.styles.transform.target+="transform:",a(e)}function s(e,t){var n=e.config;return"-webkit-transition: "+e.styles.computed.transition+"-webkit-transform "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s, opacity "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s; transition: "+e.styles.computed.transition+"transform "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s, opacity "+n.duration/1e3+"s "+n.easing+" "+t/1e3+"s; "}function a(e){var t,n=e.config,i=e.styles.transform;t="top"===n.origin||"left"===n.origin?/^-/.test(n.distance)?n.distance.substr(1):"-"+n.distance:n.distance,parseInt(n.distance)&&(i.initial+=" translate"+n.axis+"("+t+")",i.target+=" translate"+n.axis+"(0)"),n.scale&&(i.initial+=" scale("+n.scale+")",i.target+=" scale(1)"),n.rotate.x&&(i.initial+=" rotateX("+n.rotate.x+"deg)",i.target+=" rotateX(0)"),n.rotate.y&&(i.initial+=" rotateY("+n.rotate.y+"deg)",i.target+=" rotateY(0)"),n.rotate.z&&(i.initial+=" rotateZ("+n.rotate.z+"deg)",i.target+=" rotateZ(0)"),i.initial+="; opacity: "+n.opacity+";",i.target+="; opacity: "+e.styles.computed.opacity+";"}function l(e){var t=e.config.container;t&&O.store.containers.indexOf(t)===-1&&O.store.containers.push(e.config.container),O.store.elements[e.id]=e}function c(e,t,n){var i={target:e,config:t,interval:n};O.history.push(i)}function f(){if(O.isSupported()){y();for(var e=0;em&&n>p&&y before // By default, loadCSS attempts to inject the link after the last stylesheet or script in the DOM. However, you might desire a more specific location in your document. // `media` [OPTIONAL] is the media type or query of the stylesheet. By default it will be 'all' var doc = w.document; var ss = doc.createElement( "link" ); var ref; if( before ){ ref = before; } else { var refs = ( doc.body || doc.getElementsByTagName( "head" )[ 0 ] ).childNodes; ref = refs[ refs.length - 1]; } var sheets = doc.styleSheets; ss.rel = "stylesheet"; ss.href = href; // temporarily set media to something inapplicable to ensure it'll fetch without blocking render ss.media = "only x"; // wait until body is defined before injecting link. This ensures a non-blocking load in IE11. function ready( cb ){ if( doc.body ){ return cb(); } setTimeout(function(){ ready( cb ); }); } // Inject link // Note: the ternary preserves the existing behavior of "before" argument, but we could choose to change the argument to "after" in a later release and standardize on ref.nextSibling for all refs // Note: `insertBefore` is used instead of `appendChild`, for safety re: http://www.paulirish.com/2011/surefire-dom-element-insertion/ ready( function(){ ref.parentNode.insertBefore( ss, ( before ? ref : ref.nextSibling ) ); }); // A method (exposed on return object for external use) that mimics onload by polling document.styleSheets until it includes the new sheet. var onloadcssdefined = function( cb ){ var resolvedHref = ss.href; var i = sheets.length; while( i-- ){ if( sheets[ i ].href === resolvedHref ){ return cb(); } } setTimeout(function() { onloadcssdefined( cb ); }); }; function loadCB(){ if( ss.addEventListener ){ ss.removeEventListener( "load", loadCB ); } ss.media = media || "all"; } // once loaded, set link's media back to `all` so that the stylesheet applies once it loads if( ss.addEventListener ){ ss.addEventListener( "load", loadCB); } ss.onloadcssdefined = onloadcssdefined; onloadcssdefined( loadCB ); return ss; }; // commonjs if( typeof exports !== "undefined" ){ exports.loadCSS = loadCSS; } else { w.loadCSS = loadCSS; } }( typeof global !== "undefined" ? global : this )); // bxSlider, used for Image carousel on the product page /** * bxSlider v4.2.5 * Copyright 2013-2015 Steven Wanderski * Written while drinking Belgian ales and listening to jazz * Licensed under MIT (http://opensource.org/licenses/MIT) */ ;(function($) { var defaults = { // GENERAL mode: 'horizontal', slideSelector: '', infiniteLoop: true, hideControlOnEnd: false, speed: 1200, easing: null, slideMargin: 0, startSlide: 0, randomStart: false, captions: false, ticker: false, tickerHover: false, adaptiveHeight: false, adaptiveHeightSpeed: 500, video: false, useCSS: true, preloadImages: 'visible', responsive: true, slideZIndex: 50, wrapperClass: 'bx-wrapper', // TOUCH touchEnabled: true, swipeThreshold: 50, oneToOneTouch: true, preventDefaultSwipeX: true, preventDefaultSwipeY: false, // ACCESSIBILITY ariaLive: true, ariaHidden: true, // KEYBOARD keyboardEnabled: false, // PAGER pager: true, pagerType: 'full', pagerShortSeparator: ' / ', pagerSelector: null, buildPager: null, pagerCustom: null, // CONTROLS controls: true, nextText: 'Next', prevText: 'Prev', nextSelector: null, prevSelector: null, autoControls: false, startText: 'Start', stopText: 'Stop', autoControlsCombine: false, autoControlsSelector: null, // AUTO auto: false, pause: 4000, autoStart: true, autoDirection: 'next', stopAutoOnClick: false, autoHover: false, autoDelay: 0, autoSlideForOnePage: false, // CAROUSEL minSlides: 1, maxSlides: 1, moveSlides: 0, slideWidth: 0, shrinkItems: false, // CALLBACKS onSliderLoad: function() { return true; }, onSlideBefore: function() { return true; }, onSlideAfter: function() { return true; }, onSlideNext: function() { return true; }, onSlidePrev: function() { return true; }, onSliderResize: function() { return true; } }; $.fn.bxSlider = function(options) { if (this.length === 0) { return this; } // support multiple 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 el = this, // get the original window dimens (thanks a lot IE) windowWidth = $(window).width(), windowHeight = $(window).height(); // Return if slider is already initialized if ($(el).data('bxSlider')) { return; } /** * =================================================================================== * = PRIVATE FUNCTIONS * =================================================================================== */ /** * Initializes namespace settings to be used throughout plugin */ var init = function() { // Return if slider is already initialized if ($(el).data('bxSlider')) { return; } // merge user-supplied options with the defaults slider.settings = $.extend({}, defaults, options); // parse slideWidth setting slider.settings.slideWidth = parseInt(slider.settings.slideWidth); // store the original children slider.children = el.children(slider.settings.slideSelector); // check if actual number of slides is less than minSlides / maxSlides if (slider.children.length < slider.settings.minSlides) { slider.settings.minSlides = slider.children.length; } if (slider.children.length < slider.settings.maxSlides) { slider.settings.maxSlides = slider.children.length; } // 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 ? true : false; // if carousel, force preloadImages = 'all' if (slider.carousel) { slider.settings.preloadImages = 'all'; } // 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 = {}; // initialize an auto interval slider.interval = null; // 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 props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']; // test for each property for (var i = 0; i < props.length; i++) { 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; } // save original style data el.data('origStyle', el.attr('style')); el.children(slider.settings.slideSelector).each(function() { $(this).data('origStyle', $(this).attr('style')); }); // perform all DOM / CSS modifications setup(); }; /** * Performs all DOM and CSS modifications */ var setup = function() { var preloadSelector = slider.children.eq(slider.settings.startSlide); // set the default preload selector (visible) // wrap el in a wrapper el.wrap('
'); // store a namespace reference to .bx-viewport slider.viewport = el.parent(); // add aria-live if the setting is enabled and ticker mode is disabled if (slider.settings.ariaLive && !slider.settings.ticker) { slider.viewport.attr('aria-live', 'polite'); } // add a loading div to display while images are loading slider.loader = $('
'); 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 * 1000 + 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' }); slider.viewport.parent().css({ maxWidth: getViewportMaxWidth() }); // make modification to the wrapper (.bx-wrapper) if (!slider.settings.pager && !slider.settings.controls) { slider.viewport.parent().css({ margin: '0 auto 0px' }); } // apply css to all slider children slider.children.css({ 'float': slider.settings.mode === 'horizontal' ? 'left' : 'none', listStyle: 'none', position: 'relative' }); // apply the calculated width after the float is applied to prevent scrollbar interference slider.children.css('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: slider.settings.slideZIndex, display: 'block'}); } // create an element to contain all slider controls (pager, start / stop, etc) slider.controls.el = $('
'); // if captions are requested, add them if (slider.settings.captions) { appendCaptions(); } // 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(); } if (slider.settings.preloadImages === 'all' || slider.settings.ticker) { preloadSelector = slider.children; } // only check for control addition if not in "ticker" mode if (!slider.settings.ticker) { // 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 pager is requested, add it if (slider.settings.pager) { appendPager(); } // 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); } // if ticker mode, do not allow a pager } else { slider.settings.pager = false; } loadElements(preloadSelector, start); }; var loadElements = function(selector, callback) { var total = selector.find('img:not([src=""]), iframe').length, count = 0; if (total === 0) { callback(); return; } selector.find('img:not([src=""]), iframe').each(function() { $(this).one('load error', function() { if (++count === total) { callback(); } }).each(function() { if (this.complete) { $(this).load(); } }); }); }; /** * Start the slider */ var start = function() { // 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, sliceAppend = slider.children.slice(0, slice).clone(true).addClass('bx-clone'), slicePrepend = slider.children.slice(-slice).clone(true).addClass('bx-clone'); if (slider.settings.ariaHidden) { sliceAppend.attr('aria-hidden', true); slicePrepend.attr('aria-hidden', true); } el.append(sliceAppend).prepend(slicePrepend); } // 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()); // make sure everything is positioned just right (same as a window resize) el.redrawSlider(); // onSliderLoad callback slider.settings.onSliderLoad.call(el, slider.active.index); // slider has been fully initialized slider.initialized = true; // bind the resize call to the window if (slider.settings.responsive) { $(window).bind('resize', resizeWindow); } // if auto is true and has more than 1 page, start the show if (slider.settings.auto && slider.settings.autoStart && (getPagerQty() > 1 || slider.settings.autoSlideForOnePage)) { 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(); } // if keyboardEnabled is true, setup the keyboard events if (slider.settings.keyboardEnabled && !slider.settings.ticker) { $(document).keydown(keyPress); } }; /** * 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 = $(); // AVENUE CUSTOM if (slider.settings.verticalHeight) { return slider.settings.verticalHeight(); } // if mode is not "vertical" and adaptiveHeight is false, include 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()); } if (slider.viewport.css('box-sizing') === 'border-box') { height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')) + parseFloat(slider.viewport.css('border-top-width')) + parseFloat(slider.viewport.css('border-bottom-width')); } else if (slider.viewport.css('box-sizing') === 'padding-box') { height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')); } return height; }; /** * Returns the calculated width to be used for the outer wrapper / viewport */ var getViewportMaxWidth = function() { var width = '100%'; if (slider.settings.slideWidth > 0) { if (slider.settings.mode === 'horizontal') { width = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin); } else { width = slider.settings.slideWidth; } } return width; }; /** * Returns the calculated width to be applied to each slide */ var getSlideWidth = function() { var newElWidth = slider.settings.slideWidth, // start with any user-supplied slide width wrapWidth = slider.viewport.width(); // get the current viewport width // AVENUE CUSTOM if (slider.settings.verticalWidth) { return slider.settings.verticalWidth(); } // if slide width was not supplied, or is larger than the viewport use the viewport width if (slider.settings.slideWidth === 0 || (slider.settings.slideWidth > wrapWidth && !slider.carousel) || slider.settings.mode === 'vertical') { newElWidth = wrapWidth; // if carousel, use the thresholds to determine the width } else if (slider.settings.maxSlides > 1 && slider.settings.mode === 'horizontal') { if (wrapWidth > slider.maxThreshold) { return newElWidth; } else if (wrapWidth < slider.minThreshold) { newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides; } else if (slider.settings.shrinkItems) { newElWidth = Math.floor((wrapWidth + slider.settings.slideMargin) / (Math.ceil((wrapWidth + slider.settings.slideMargin) / (newElWidth + slider.settings.slideMargin))) - slider.settings.slideMargin); } } return newElWidth; }; /** * Returns the number of slides currently visible in the viewport (includes partially visible slides) */ var getNumberSlidesShowing = function() { var slidesShowing = 1, childWidth = null; if (slider.settings.mode === 'horizontal' && slider.settings.slideWidth > 0) { // if viewport is smaller than minThreshold, return minSlides if (slider.viewport.width() < slider.minThreshold) { slidesShowing = slider.settings.minSlides; // if viewport is larger than maxThreshold, 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 { childWidth = slider.children.first().width() + slider.settings.slideMargin; slidesShowing = Math.floor((slider.viewport.width() + slider.settings.slideMargin) / 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, breakPoint = 0, counter = 0; // if moveSlides is specified by the user if (slider.settings.moveSlides > 0) { if (slider.settings.infiniteLoop) { pagerQty = Math.ceil(slider.children.length / getMoveBy()); } else { // 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 individual 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() { var position, lastChild, lastShowingIndex; // if last slide, not infinite loop, and number of children is larger than specified maxSlides if (slider.children.length > slider.settings.maxSlides && slider.active.last && !slider.settings.infiniteLoop) { if (slider.settings.mode === 'horizontal') { // get the last child's position lastChild = slider.children.last(); position = lastChild.position(); // set the left position setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.outerWidth())), 'reset', 0); } else if (slider.settings.mode === 'vertical') { // get the last showing index's position lastShowingIndex = slider.children.length - slider.settings.minSlides; 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 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 respective 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) 'slide', '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) { var animateObj, propValue; // use CSS transform if (slider.usingCSS) { // determine the translate3d value 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); if (duration !== 0) { // bind a callback method - executes when CSS transition completes el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) { //make sure it's the correct one if (!$(e.target).is(el)) { return; } // unbind the callback el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); updateAfterSlideTransition(); }); } else { //duration = 0 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); if (duration !== 0) { el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(e) { //make sure it's the correct one if (!$(e.target).is(el)) { return; } // unbind the callback el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd'); // reset the position setPositionProperty(params.resetValue, 'reset', 0); // start the loop again tickerLoop(); }); } else { //duration = 0 setPositionProperty(params.resetValue, 'reset', 0); tickerLoop(); } } // use JS animate } else { 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, duration, '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 = '', linkContent = '', pagerQty = getPagerQty(); // loop through each pager item for (var i = 0; i < pagerQty; i++) { 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) || slider.settings.pagerCustom) { 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 += ''; } // 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 = $('
'); // 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.on('click touchend', 'a', clickPagerBind); }; /** * Appends prev / next controls to the controls element */ var appendControls = function() { slider.controls.next = $('' + slider.settings.nextText + ''); slider.controls.prev = $('' + slider.settings.prevText + ''); // bind click actions to the controls slider.controls.next.bind('click touchend', clickNextBind); slider.controls.prev.bind('click touchend', clickPrevBind); // if nextSelector was supplied, populate it if (slider.settings.nextSelector) { $(slider.settings.nextSelector).append(slider.controls.next); } // if prevSelector 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 = $('
'); // 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 = $(''); slider.controls.stop = $(''); // add the controls to the DOM slider.controls.autoEl = $('
'); // bind click actions to the controls slider.controls.autoEl.on('click', '.bx-start', clickStartBind); slider.controls.autoEl.on('click', '.bx-stop', 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 && ('' + title).length) { $(this).append('
' + title + '
'); } }); }; /** * Click next binding * * @param e (event) * - DOM event object */ var clickNextBind = function(e) { e.preventDefault(); if (slider.controls.el.hasClass('disabled')) { return; } // if auto show is running, stop it if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); } el.goToNextSlide(); }; /** * Click prev binding * * @param e (event) * - DOM event object */ var clickPrevBind = function(e) { e.preventDefault(); if (slider.controls.el.hasClass('disabled')) { return; } // if auto show is running, stop it if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); } el.goToPrevSlide(); }; /** * 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) { var pagerLink, pagerIndex; e.preventDefault(); if (slider.controls.el.hasClass('disabled')) { return; } // if auto show is running, stop it if (slider.settings.auto && slider.settings.stopAutoOnClick) { el.stopAuto(); } pagerLink = $(e.currentTarget); if (pagerLink.attr('data-slide-index') !== undefined) { 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); } } }; /** * 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 var len = slider.children.length; // nb of children if (slider.settings.pagerType === 'short') { if (slider.settings.maxSlides > 1) { len = Math.ceil(slider.children.length / slider.settings.maxSlides); } slider.pagerEl.html((slideIndex + 1) + slider.settings.pagerShortSeparator + len); return; } // remove all pager active classes slider.pagerEl.find('a').removeClass('active'); // apply the active class for all pagers slider.pagerEl.each(function(i, el) { $(el).find('a').eq(slideIndex).addClass('active'); }); }; /** * Performs needed actions after a slide transition */ var updateAfterSlideTransition = function() { // if infinite 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 (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.call(el, 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 (getPagerQty() === 1) { slider.controls.prev.addClass('disabled'); slider.controls.next.addClass('disabled'); } else 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'); } } }; /** * Initializes 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(); //add focus and blur events to ensure its running if timeout gets paused $(window).focus(function() { el.startAuto(); }).blur(function() { el.stopAuto(); }); } // 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 argument 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 argument which will prevent control update el.startAuto(true); // reset the autoPaused value slider.autoPaused = null; } }); } }; /** * Initializes the ticker process */ var initTicker = function() { var startPosition = 0, position, transform, value, idx, ratio, property, newSpeed, totalDimens; // 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')); 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) { if (slider.usingCSS) { idx = slider.settings.mode === 'horizontal' ? 4 : 5; slider.viewport.hover(function() { transform = el.css('-' + slider.cssPrefix + '-transform'); value = parseFloat(transform.split(',')[idx]); setPositionProperty(value, 'reset', 0); }, function() { 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) ratio = slider.settings.speed / totalDimens; // determine which property to use property = slider.settings.mode === 'horizontal' ? 'left' : 'top'; // calculate the new speed newSpeed = ratio * (totalDimens - (Math.abs(parseInt(value)))); tickerLoop(newSpeed); }); } else { // on el hover slider.viewport.hover(function() { el.stop(); }, function() { // calculate the total width of children (used to calculate the speed ratio) 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) ratio = slider.settings.speed / totalDimens; // determine which property to use property = slider.settings.mode === 'horizontal' ? 'left' : 'top'; // calculate the new speed 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) { var speed = resumeSpeed ? resumeSpeed : slider.settings.speed, position = {left: 0, top: 0}, reset = {left: 0, top: 0}, animateProperty, resetValue, params; // 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(); } animateProperty = slider.settings.mode === 'horizontal' ? -position.left : -position.top; resetValue = slider.settings.mode === 'horizontal' ? -reset.left : -reset.top; params = {resetValue: resetValue}; setPositionProperty(animateProperty, 'ticker', speed, params); }; /** * Check if el is on screen */ var isOnScreen = function(el) { var win = $(window), viewport = { top: win.scrollTop(), left: win.scrollLeft() }, bounds = el.offset(); viewport.right = viewport.left + win.width(); viewport.bottom = viewport.top + win.height(); bounds.right = bounds.left + el.outerWidth(); bounds.bottom = bounds.top + el.outerHeight(); return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); }; /** * Initializes keyboard events */ var keyPress = function(e) { var activeElementTag = document.activeElement.tagName.toLowerCase(), tagFilters = 'input|textarea', p = new RegExp(activeElementTag,['i']), result = p.exec(tagFilters); if (result == null && isOnScreen(el)) { if (e.keyCode === 39) { clickNextBind(e); return false; } else if (e.keyCode === 37) { clickPrevBind(e); return false; } } }; /** * 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 MSPointerDown pointerdown', onTouchStart); //for browsers that have implemented pointer events and fire a click after //every pointerup regardless of whether pointerup is on same screen location as pointerdown or not slider.viewport.on('click', '.bxslider a', function(e) { if (slider.viewport.hasClass('click-disabled')) { e.preventDefault(); slider.viewport.removeClass('click-disabled'); } }); }; /** * Event handler for "touchstart" * * @param e (event) * - DOM event object */ var onTouchStart = function(e) { //disable slider controls while user is interacting with slides to avoid slider freeze that happens on touch devices when a slide swipe happens immediately after interacting with slider controls slider.controls.el.addClass('disabled'); if (slider.working) { e.preventDefault(); slider.controls.el.removeClass('disabled'); } else { // record the original position when touch starts slider.touch.originalPos = el.position(); var orig = e.originalEvent, touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig]; // record the starting touch x, y coordinates slider.touch.start.x = touchPoints[0].pageX; slider.touch.start.y = touchPoints[0].pageY; if (slider.viewport.get(0).setPointerCapture) { slider.pointerId = orig.pointerId; slider.viewport.get(0).setPointerCapture(slider.pointerId); } // bind a "touchmove" event to the viewport slider.viewport.bind('touchmove MSPointerMove pointermove', onTouchMove); // bind a "touchend" event to the viewport slider.viewport.bind('touchend MSPointerUp pointerup', onTouchEnd); slider.viewport.bind('MSPointerCancel pointercancel', onPointerCancel); } }; /** * Cancel Pointer for Windows Phone * * @param e (event) * - DOM event object */ var onPointerCancel = function(e) { /* onPointerCancel handler is needed to deal with situations when a touchend doesn't fire after a touchstart (this happens on windows phones only) */ setPositionProperty(slider.touch.originalPos.left, 'reset', 0); //remove handlers slider.controls.el.removeClass('disabled'); slider.viewport.unbind('MSPointerCancel pointercancel', onPointerCancel); slider.viewport.unbind('touchmove MSPointerMove pointermove', onTouchMove); slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd); if (slider.viewport.get(0).releasePointerCapture) { slider.viewport.get(0).releasePointerCapture(slider.pointerId); } }; /** * Event handler for "touchmove" * * @param e (event) * - DOM event object */ var onTouchMove = function(e) { var orig = e.originalEvent, touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig], // if scrolling on y axis, do not prevent default xMovement = Math.abs(touchPoints[0].pageX - slider.touch.start.x), yMovement = Math.abs(touchPoints[0].pageY - slider.touch.start.y), value = 0, change = 0; // x axis swipe if ((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX) { e.preventDefault(); // y axis swipe } else if ((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY) { e.preventDefault(); } if (slider.settings.mode !== 'fade' && slider.settings.oneToOneTouch) { // if horizontal, drag along x axis if (slider.settings.mode === 'horizontal') { change = touchPoints[0].pageX - slider.touch.start.x; value = slider.touch.originalPos.left + change; // if vertical, drag along y axis } else { change = touchPoints[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 MSPointerMove pointermove', onTouchMove); //enable slider controls as soon as user stops interacing with slides slider.controls.el.removeClass('disabled'); var orig = e.originalEvent, touchPoints = (typeof orig.changedTouches !== 'undefined') ? orig.changedTouches : [orig], value = 0, distance = 0; // record end x, y positions slider.touch.end.x = touchPoints[0].pageX; slider.touch.end.y = touchPoints[0].pageY; // if fade mode, check if absolute x distance clears the threshold if (slider.settings.mode === 'fade') { distance = Math.abs(slider.touch.start.x - slider.touch.end.x); if (distance >= slider.settings.swipeThreshold) { if (slider.touch.start.x > slider.touch.end.x) { el.goToNextSlide(); } else { el.goToPrevSlide(); } el.stopAuto(); } // not fade mode } else { // 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) { if (distance < 0) { el.goToNextSlide(); } else { el.goToPrevSlide(); } el.stopAuto(); } else { // el.animate(property, 200); setPositionProperty(value, 'reset', 200); } } } slider.viewport.unbind('touchend MSPointerUp pointerup', onTouchEnd); if (slider.viewport.get(0).releasePointerCapture) { slider.viewport.get(0).releasePointerCapture(slider.pointerId); } }; /** * Window resize event callback */ var resizeWindow = function(e) { // don't do anything if slider isn't initialized. if (!slider.initialized) { return; } // Delay if slider working. if (slider.working) { window.setTimeout(resizeWindow, 10); } else { // get the new window dimens (again, thank you IE) var windowWidthNew = $(window).width(), 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; // update all dynamic elements el.redrawSlider(); // Call user resize handler slider.settings.onSliderResize.call(el, slider.active.index); } } }; /** * Adds an aria-hidden=true attribute to each element * * @param startVisibleIndex (int) * - the first visible element's index */ var applyAriaHiddenAttributes = function(startVisibleIndex) { var numberOfSlidesShowing = getNumberSlidesShowing(); // only apply attributes if the setting is enabled and not in ticker mode if (slider.settings.ariaHidden && !slider.settings.ticker) { // add aria-hidden=true to all elements slider.children.attr('aria-hidden', 'true'); // get the visible elements and change to aria-hidden=false slider.children.slice(startVisibleIndex, startVisibleIndex + numberOfSlidesShowing).attr('aria-hidden', 'false'); } }; /** * Returns index according to present page range * * @param slideOndex (int) * - the desired slide index */ var setSlideIndex = function(slideIndex) { if (slideIndex < 0) { if (slider.settings.infiniteLoop) { return getPagerQty() - 1; }else { //we don't go to undefined slides return slider.active.index; } // if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop) } else if (slideIndex >= getPagerQty()) { if (slider.settings.infiniteLoop) { return 0; } else { //we don't move to undefined pages return slider.active.index; } // set active index to requested slide } else { return slideIndex; } }; /** * =================================================================================== * = 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) { // onSlideBefore, onSlideNext, onSlidePrev callbacks // Allow transition canceling based on returned value var performTransition = true, moveBy = 0, position = {left: 0, top: 0}, lastChild = null, lastShowingIndex, eq, value, requestEl; // store the old index slider.oldIndex = slider.active.index; //set new index slider.active.index = setSlideIndex(slideIndex); // if plugin is currently in motion, ignore request if (slider.working || slider.active.index === slider.oldIndex) { return; } // declare that plugin is in motion slider.working = true; performTransition = slider.settings.onSlideBefore.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index); // If transitions canceled, reset and return if (typeof (performTransition) !== 'undefined' && !performTransition) { slider.active.index = slider.oldIndex; // restore old index slider.working = false; // is not in motion return; } if (direction === 'next') { // Prevent canceling in future functions or lack there-of from negating previous commands to cancel if (!slider.settings.onSlideNext.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)) { performTransition = false; } } else if (direction === 'prev') { // Prevent canceling in future functions or lack there-of from negating previous commands to cancel if (!slider.settings.onSlidePrev.call(el, slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index)) { performTransition = false; } } // check if last slide slider.active.last = slider.active.index >= getPagerQty() - 1; // update the pager with active class if (slider.settings.pager || slider.settings.pagerCustom) { 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', slider.settings.slideZIndex + 1).fadeIn(slider.settings.speed, function() { $(this).css('zIndex', slider.settings.slideZIndex); 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); } // 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 lastChild = slider.children.eq(slider.children.length - 1); position = lastChild.position(); // calculate the position of the last slide moveBy = slider.viewport.width() - lastChild.outerWidth(); } else { // get last showing index position 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 eq = slider.settings.moveSlides === 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides); 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) { //parseInt is applied to allow floats for slides/page requestEl = slideIndex * parseInt(getMoveBy()); position = slider.children.eq(requestEl).position(); } /* If the position doesn't exist * (e.g. if you destroy the slider on a next click), * it doesn't throw an error. */ if (typeof (position) !== 'undefined') { value = slider.settings.mode === 'horizontal' ? -(position.left - moveBy) : -position.top; // plugin values to be animated setPositionProperty(value, 'slide', slider.settings.speed); } else { slider.working = false; } } if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); } }; /** * 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 = parseInt(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 = parseInt(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() { if (slider.settings.autoDirection === 'next') { el.goToNextSlide(); } else { 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 current slide element */ el.getCurrentSlideElement = function() { return slider.children.eq(slider.active.index); }; /** * Returns a slide element * @param index (int) * - The index (zero-based) of the element you want returned. */ el.getSlideElement = function(index) { return slider.children.eq(index); }; /** * Returns number of slides in show */ el.getSlideCount = function() { return slider.children.length; }; /** * Return slider.working variable */ el.isWorking = function() { return slider.working; }; /** * Update all dynamic slider elements */ el.redrawSlider = function() { // resize all children in ratio to new screen size slider.children.add(el.find('.bx-clone')).outerWidth(getSlideWidth()); // adjust the height slider.viewport.css('height', getViewportHeight()); // update the slide position if (!slider.settings.ticker) { setSlidePosition(); } // 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); } if (slider.settings.ariaHidden) { applyAriaHiddenAttributes(slider.active.index * getMoveBy()); } }; /** * Destroy the current instance of the slider (revert everything back to original state) */ el.destroySlider = function() { // don't do anything if slider has already been destroyed if (!slider.initialized) { return; } slider.initialized = false; $('.bx-clone', this).remove(); slider.children.each(function() { if ($(this).data('origStyle') !== undefined) { $(this).attr('style', $(this).data('origStyle')); } else { $(this).removeAttr('style'); } }); if ($(this).data('origStyle') !== undefined) { this.attr('style', $(this).data('origStyle')); } else { $(this).removeAttr('style'); } $(this).unwrap().unwrap(); if (slider.controls.el) { slider.controls.el.remove(); } if (slider.controls.next) { slider.controls.next.remove(); } if (slider.controls.prev) { slider.controls.prev.remove(); } if (slider.pagerEl && slider.settings.controls && !slider.settings.pagerCustom) { slider.pagerEl.remove(); } $('.bx-caption', this).remove(); if (slider.controls.autoEl) { slider.controls.autoEl.remove(); } clearInterval(slider.interval); if (slider.settings.responsive) { $(window).unbind('resize', resizeWindow); } if (slider.settings.keyboardEnabled) { $(document).unbind('keydown', keyPress); } //remove self reference in data $(this).removeData('bxSlider'); }; /** * Reload the slider (revert all DOM changes, and re-initialize) */ el.reloadSlider = function(settings) { if (settings !== undefined) { options = settings; } el.destroySlider(); init(); //store reference to self in order to access public functions later $(el).data('bxSlider', this); }; init(); $(el).data('bxSlider', this); // returns the current jQuery object return this; }; })(jQuery); // Avenue Javascript /* Core avenue javascript functions The following attributes are meaningful in documents: data-avenue-reload=RELOADNAME data-avenue-part=PARTNAME data-avenue-url=url Specifies that this div should be reloaded with the specified page part. Triggered be a call to Avenue.reload_parts('RELOADNAME') There are also some special reload names: 'scs' - reloaded with parts from the selected style/colour/size product with selection changes 'fast_order' - reloaded whenever any fast order entry line changes 'fast_order_X' - reloaded whenever a specific fast order line number is changed. data-toggle=av-modal data-avenue-part=PARTNAME data-avenue-url=url Specifies that a bootstrap modal dialog will be displayed when this element is clicked class=smallimg class=bigimg (want to change these to use data attributes - does thumbnail switching) data-avenue-product-autocomplete=true Triggers product code autocomplete on an input data-avenue-debtor-autocomplete=true Triggers debtor code autocomplete on an input data-avenue-confirm=Confirmation Message Prompts the user with a message before allowing a click on the element. data-avenue-autodisable=true Causes the element to become disabled whenever its enclosing form is submitted (prevents double submit). data-avenue-href=URL On a button, will redirect to URL instead of performing any form processing. data-avenue-ajax-dialog-form=URL On a form, will display the resulting page in a bootstrap-styled modal dialog data-avenue-class-set=CLASS data-avenue-class-target=JQUERY_EXPRESSION data-avenue-class-persist=true On click, will set the class of the elements matching JQUERY_EXPRESSION. If class-persist is set, stores the current setting in localStorage */ var Avenue = (function($) { "use strict"; var settings = {}; settings.init_functions = []; settings.init_once_functions = []; settings.callbacks = {}; settings.loading_gif = '/ajax.gif'; settings.reload_parts = { 'timeout' : 200, 'remove_contents' : function ($div) { $div.children('.load_animation').remove(); //Dedup loading spinner var $new_div = $('
').append($('',{'class': 'loading', 'src': settings.loading_gif})); $new_div.height($div.height()); $new_div.width($div.width()); $div.addClass('av-reload-loading').append($new_div); }, 'add_contents' : function ($div, $new_html) { $div.removeClass('av-reload-loading').html($new_html); }, 'append_contents' : function ($div, $new_html) { $div.removeClass('av-reload-loading').find('.load_animation').remove(); $div.append($new_html); } }; var avenue = { 'settings': settings, 'styles' : {} }; avenue.prepare_html = function (target) { if (!settings.init_functions) { return; } $.each(settings.init_functions, function (ignore, init_function) { init_function(target); }); }; avenue.set_style = function(style_name) { var style = avenue.styles[style_name]; if(style) { $.extend(true, settings, style); } }; // allow for different 'styles' that can be easily loaded avenue.styles.bootstrap3 = { 'validation' : { 'field_valid' : function ($field) { $field.closest('.form-group').removeClass('has-error'); $field.find('.validation_error').remove(); }, 'field_invalid' : function($field, message) { $field.closest('.form-group').addClass('has-error'); $field.append($('
').text(message)); } } }; avenue.styles.default = { 'validation' : { 'field_valid' : function ($field) { $field.removeClass('input_error'); $field.find('.validation_error').remove(); }, 'field_invalid' : function ($field, message) { $field.addClass('input_error'); $field.append($('
').text(message)); } } }; avenue.set_style('default'); avenue.reload_counts = {}; avenue.reload_parts = function (reload_name, options) { if (!options) { options = {}; } var reload_count = (avenue.reload_counts[reload_name] || 0) + 1; avenue.reload_counts[reload_name] = reload_count; options = $.extend({reload_name: reload_name, reload_count: reload_count}, options); var find_target = 'div[data-avenue-reload=' + reload_name + ']'; var divs; if(options.scope) { divs = options.scope.find(find_target); } else { divs = $(find_target); } divs.each(function (ignore, div) { var $div = $(div); avenue.load_part($div, options); }); }; avenue.load_part = function($div, options) { if (!options) { options = {}; } var remove_contents = options.remove_contents || settings.reload_parts.remove_contents; var additional_contents = options.appending ? (options.append_contents || settings.reload_parts.append_contents) : (options.add_contents || settings.reload_parts.add_contents); var data = options.data || {}; if (typeof(data) === "function") { data = data($div); } if(!options.reload_check || options.reload_check($div, data)) { // allow the div to specify an entire url var div_path = $div.data('avenue-url'); var query; if(!div_path) { var part_name = $div.data('avenue-part'); var path; if(options.path) { path = options.path; } else { path = $div.data('avenue-base-url'); if(!path) { path = $div.closest('[data-avenue-base-url]').data('avenue-base-url'); } if(!path) { // if we aren't explicitely reloading from a set location, pass the current query path = window.location.pathname; query = window.location.search; } } if (!path.match(/\/$/)) { path += '/'; } if(part_name) { div_path = path + '_part/' + part_name; } } if(!div_path) { // this is not a loadable element return false; } if (options.url_params) { query = '?' + options.url_params; } if(query) { div_path += query; } var type = options.method || 'GET'; if($div.data('avenue-method')) { type = $div.data('avenue-method'); } var done = false; var load_function; load_function = function() { $.ajax({ url: div_path, type: type, data: data, // TODO: should probably do something with the status (second arg) success: function (new_html, ignore, jqXHR) { if(jqXHR.getResponseHeader('X-Avenue-Calculation-Required')) { // try again in a second setTimeout(load_function, 2000); } else { done = true; // reload count prevents a previous reload from overwriting the most recent reload. if (!options.reload_count || avenue.reload_counts[options.reload_name] === options.reload_count) { var $new_html; $new_html = $($.parseHTML($.trim(new_html))); var $newly_added = additional_contents($div, $new_html); avenue.prepare_html($newly_added || $div); // allow a callback for after modified if(options.when_modified) { options.when_modified($div, data); } // allow a callback for after reload if(options.when_reloaded){ options.when_reloaded($div, data); } // Append any inlined script tags which need to run $('
'+new_html+'
').find('[data-avenue-ensure-appended]').each(function(i, el) { $('body').append(el); }); $div.trigger('avenue.reload.complete'); } } } }); }; load_function(); var timeout_function = function () { if (!done && (!options.reload_count || avenue.reload_counts[options.reload_name] === options.reload_count)) { remove_contents($div); // allow a callback for after modified if(options.when_modified) { options.when_modified($div); } } }; setTimeout(timeout_function, options.timeout || settings.reload_parts.timeout); } }; avenue.init = function (new_settings) { if (new_settings) { $.extend(settings, new_settings); } $.each(settings.init_once_functions, function (ignore, init_function) { init_function(); }); avenue.prepare_html($('html')); }; return avenue; }(jQuery)); (function($) { "use strict"; var settings = Avenue.settings; // Generic modal overlay - used by the product quick view var $ajaxModalOverlay; var $ajaxModalOverlayContent; Avenue.display_modal = function(modal_type, content, params) { if(!$ajaxModalOverlay) { // TODO: there should be a way to customize this $ajaxModalOverlayContent = $("
"); $ajaxModalOverlay = $('
', {'class': 'modal fade', 'tabindex': '-1', 'role': 'dialog'}); $ajaxModalOverlay.append( $('
', {'class': 'modal-dialog', 'role': 'document'}).append( $('
', {'class': 'modal-content'}).append( $("
", {'class': "modal-close", 'style': "display:" + params['hidden_closed_button']}).append( $("