(function($) { var plugin = {}; var defaults = { mode: 'horizontal', slideselector: '', infiniteloop: true, hidecontrolonend: false, speed: 500, easing: null, slidemargin: 0, startslide: 0, randomstart: false, captions: false, ticker: false, tickerhover: false, adaptiveheight: false, adaptiveheightspeed: 500, video: false, usecss: true, preloadimages: 'visible', responsive: true, slidezindex: 50, wrapperclass: 'bx-wrapper', touchenabled: true, swipethreshold: 50, onetoonetouch: true, preventdefaultswipex: true, preventdefaultswipey: false, pager: true, pagertype: 'full', pagershortseparator: ' / ', pagerselector: null, buildpager: null, pagercustom: null, controls: true, nexttext: 'next', prevtext: 'prev', nextselector: null, prevselector: null, autocontrols: false, starttext: 'start', stoptext: 'stop', autocontrolscombine: false, autocontrolsselector: null, auto: false, pause: 4000, autostart: true, autodirection: 'next', autohover: false, autodelay: 0, autoslideforonepage: false, minslides: 1, maxslides: 1, moveslides: 0, slidewidth: 0, onsliderload: function() {}, onslidebefore: function() {}, onslideafter: function() {}, onslidenext: function() {}, onslideprev: function() {}, onsliderresize: function() {} } $.fn.bxslider = function(options) { if (this.length == 0) return this; if (this.length > 1) { this.each(function() { $(this).bxslider(options) }); return this; } var slider = {}; var el = this; plugin.el = this; var windowwidth = $(window).width(); var windowheight = $(window).height(); var init = function() { slider.settings = $.extend({}, defaults, options); slider.settings.slidewidth = parseint(slider.settings.slidewidth); slider.children = el.children(slider.settings.slideselector); 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 (slider.settings.randomstart) slider.settings.startslide = math.floor(math.random() * slider.children.length); slider.active = { index: slider.settings.startslide } slider.carousel = slider.settings.minslides > 1 || slider.settings.maxslides > 1; if (slider.carousel) slider.settings.preloadimages = 'all'; 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); slider.working = false; slider.controls = {}; slider.interval = null; slider.animprop = slider.settings.mode == 'vertical' ? 'top' : 'left'; slider.usingcss = slider.settings.usecss && slider.settings.mode != 'fade' && (function() { var div = document.createelement('div'); var props = ['webkitperspective', 'mozperspective', 'operspective', 'msperspective']; for (var i in props) { if (div.style[props[i]] !== undefined) { slider.cssprefix = props[i].replace('perspective', '').tolowercase(); slider.animprop = '-' + slider.cssprefix + '-transform'; return true; } } return false; }()); if (slider.settings.mode == 'vertical') slider.settings.maxslides = slider.settings.minslides; el.data("origstyle", el.attr("style")); el.children(slider.settings.slideselector).each(function() { $(this).data("origstyle", $(this).attr("style")); }); setup(); } var setup = function() { el.wrap('
'); slider.viewport = el.parent(); slider.loader = $(''); slider.viewport.prepend(slider.loader); el.css({ width: slider.settings.mode == 'horizontal' ? (slider.children.length * 100 + 215) + '%' : 'auto', position: 'relative' }); if (slider.usingcss && slider.settings.easing) { el.css('-' + slider.cssprefix + '-transition-timing-function', slider.settings.easing); } else if (!slider.settings.easing) { slider.settings.easing = 'swing'; } var slidesshowing = getnumberslidesshowing(); slider.viewport.css({ width: '100%', overflow: 'hidden', position: 'relative' }); slider.viewport.parent().css({ maxwidth: getviewportmaxwidth() }); if (!slider.settings.pager) { slider.viewport.parent().css({ margin: '0 auto 0px' }); } slider.children.css({ 'float': slider.settings.mode == 'horizontal' ? 'left' : 'none', liststyle: 'none', position: 'relative' }); slider.children.css('width', getslidewidth()); 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 (slider.settings.mode == 'fade') { slider.children.css({ position: 'absolute', zindex: 0, display: 'none' }); slider.children.eq(slider.settings.startslide).css({ zindex: slider.settings.slidezindex, display: 'block' }); } slider.controls.el = $(''); if (slider.settings.captions) appendcaptions(); slider.active.last = slider.settings.startslide == getpagerqty() - 1; if (slider.settings.video) el.fitvids(); var preloadselector = slider.children.eq(slider.settings.startslide); if (slider.settings.preloadimages == "all") preloadselector = slider.children; if (!slider.settings.ticker) { if (slider.settings.pager) appendpager(); if (slider.settings.controls) appendcontrols(); if (slider.settings.auto && slider.settings.autocontrols) appendcontrolsauto(); if (slider.settings.controls || slider.settings.autocontrols || slider.settings.pager) slider.viewport.after(slider.controls.el); } else { slider.settings.pager = false; } loadelements(preloadselector, start); } var loadelements = function(selector, callback) { var total = selector.find('img, iframe').length; if (total == 0) { callback(); return; } var count = 0; selector.find('img, iframe').each(function() { $(this).one('load', function() { if (++count == total) callback(); }).each(function() { if (this.complete) $(this).load(); }); }); } var start = function() { if (slider.settings.infiniteloop && slider.settings.mode != 'fade' && !slider.settings.ticker) { var slice = slider.settings.mode == 'vertical' ? slider.settings.minslides : slider.settings.maxslides; var sliceappend = slider.children.slice(0, slice).clone().addclass('bx-clone'); var sliceprepend = slider.children.slice(-slice).clone().addclass('bx-clone'); el.append(sliceappend).prepend(sliceprepend); } slider.loader.remove(); setslideposition(); if (slider.settings.mode == 'vertical') slider.settings.adaptiveheight = true; slider.viewport.height(getviewportheight()); el.redrawslider(); slider.settings.onsliderload(slider.active.index); slider.initialized = true; if (slider.settings.responsive) $(window).bind('resize', resizewindow); if (slider.settings.auto && slider.settings.autostart && (getpagerqty() > 1 || slider.settings.autoslideforonepage)) initauto(); if (slider.settings.ticker) initticker(); if (slider.settings.pager) updatepageractive(slider.settings.startslide); if (slider.settings.controls) updatedirectioncontrols(); if (slider.settings.touchenabled && !slider.settings.ticker) inittouch(); } var getviewportheight = function() { var height = 0; var children = $(); if (slider.settings.mode != 'vertical' && !slider.settings.adaptiveheight) { children = slider.children; } else { if (!slider.carousel) { children = slider.children.eq(slider.active.index); } else { var currentindex = slider.settings.moveslides == 1 ? slider.active.index : slider.active.index * getmoveby(); children = slider.children.eq(currentindex); for (i = 1; i <= slider.settings.maxslides - 1; i++) { if (currentindex + i >= slider.children.length) { children = children.add(slider.children.eq(i - 1)); } else { children = children.add(slider.children.eq(currentindex + i)); } } } } if (slider.settings.mode == 'vertical') { children.each(function(index) { height += $(this).outerheight(); }); if (slider.settings.slidemargin > 0) { height += slider.settings.slidemargin * (slider.settings.minslides - 1); } } 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; } 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; } var getslidewidth = function() { var newelwidth = slider.settings.slidewidth; var wrapwidth = slider.viewport.width(); if (slider.settings.slidewidth == 0 || (slider.settings.slidewidth > wrapwidth && !slider.carousel) || slider.settings.mode == 'vertical') { newelwidth = wrapwidth; } else if (slider.settings.maxslides > 1 && slider.settings.mode == 'horizontal') { if (wrapwidth > slider.maxthreshold) {} else if (wrapwidth < slider.minthreshold) { newelwidth = (wrapwidth - (slider.settings.slidemargin * (slider.settings.minslides - 1))) / slider.settings.minslides; } } return newelwidth; } var getnumberslidesshowing = function() { var slidesshowing = 1; if (slider.settings.mode == 'horizontal' && slider.settings.slidewidth > 0) { if (slider.viewport.width() < slider.minthreshold) { slidesshowing = slider.settings.minslides; } else if (slider.viewport.width() > slider.maxthreshold) { slidesshowing = slider.settings.maxslides; } else { var childwidth = slider.children.first().width() + slider.settings.slidemargin; slidesshowing = math.floor((slider.viewport.width() + slider.settings.slidemargin) / childwidth); } } else if (slider.settings.mode == 'vertical') { slidesshowing = slider.settings.minslides; } return slidesshowing; } var getpagerqty = function() { var pagerqty = 0; if (slider.settings.moveslides > 0) { if (slider.settings.infiniteloop) { pagerqty = math.ceil(slider.children.length / getmoveby()); } else { var breakpoint = 0; var counter = 0 while (breakpoint < slider.children.length) { ++pagerqty; breakpoint = counter + getnumberslidesshowing(); counter += slider.settings.moveslides <= getnumberslidesshowing() ? slider.settings.moveslides : getnumberslidesshowing(); } } } else { pagerqty = math.ceil(slider.children.length / getnumberslidesshowing()); } return pagerqty; } var getmoveby = function() { if (slider.settings.moveslides > 0 && slider.settings.moveslides <= getnumberslidesshowing()) { return slider.settings.moveslides; } return getnumberslidesshowing(); } var setslideposition = function() { if (slider.children.length > slider.settings.maxslides && slider.active.last && !slider.settings.infiniteloop) { if (slider.settings.mode == 'horizontal') { var lastchild = slider.children.last(); var position = lastchild.position(); setpositionproperty(-(position.left - (slider.viewport.width() - lastchild.outerwidth())), 'reset', 0); } else if (slider.settings.mode == 'vertical') { var lastshowingindex = slider.children.length - slider.settings.minslides; var position = slider.children.eq(lastshowingindex).position(); setpositionproperty(-position.top, 'reset', 0); } } else { var position = slider.children.eq(slider.active.index * getmoveby()).position(); if (slider.active.index == getpagerqty() - 1) slider.active.last = true; if (position != undefined) { if (slider.settings.mode == 'horizontal') setpositionproperty(-position.left, 'reset', 0); else if (slider.settings.mode == 'vertical') setpositionproperty(-position.top, 'reset', 0); } } } var setpositionproperty = function(value, type, duration, params) { if (slider.usingcss) { var propvalue = slider.settings.mode == 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)'; el.css('-' + slider.cssprefix + '-transition-duration', duration / 1000 + 's'); if (type == 'slide') { el.css(slider.animprop, propvalue); el.bind('transitionend webkittransitionend otransitionend mstransitionend', function() { el.unbind('transitionend webkittransitionend otransitionend mstransitionend'); updateafterslidetransition(); }); } else if (type == 'reset') { el.css(slider.animprop, propvalue); } else if (type == 'ticker') { el.css('-' + slider.cssprefix + '-transition-timing-function', 'linear'); el.css(slider.animprop, propvalue); el.bind('transitionend webkittransitionend otransitionend mstransitionend', function() { el.unbind('transitionend webkittransitionend otransitionend mstransitionend'); setpositionproperty(params['resetvalue'], 'reset', 0); tickerloop(); }); } } else { var animateobj = {}; animateobj[slider.animprop] = value; if (type == 'slide') { el.animate(animateobj, duration, slider.settings.easing, function() { updateafterslidetransition(); }); } else if (type == 'reset') { el.css(slider.animprop, value) } else if (type == 'ticker') { el.animate(animateobj, speed, 'linear', function() { setpositionproperty(params['resetvalue'], 'reset', 0); tickerloop(); }); } } } var populatepager = function() { var pagerhtml = ''; var pagerqty = getpagerqty(); for (var i = 0; i < pagerqty; i++) { var linkcontent = ''; if (slider.settings.buildpager && $.isfunction(slider.settings.buildpager)) { linkcontent = slider.settings.buildpager(i); slider.pagerel.addclass('bx-custom-pager'); } else { linkcontent = i + 1; slider.pagerel.addclass('bx-default-pager'); } pagerhtml += ''; } ;slider.pagerel.html(pagerhtml); } var appendpager = function() { if (!slider.settings.pagercustom) { slider.pagerel = $(''); if (slider.settings.pagerselector) { $(slider.settings.pagerselector).html(slider.pagerel); } else { slider.controls.el.addclass('bx-has-pager').append(slider.pagerel); } populatepager(); } else { slider.pagerel = $(slider.settings.pagercustom); } slider.pagerel.on('click', 'a', clickpagerbind); } var appendcontrols = function() { slider.controls.next = $('' + slider.settings.nexttext + ''); slider.controls.prev = $('' + slider.settings.prevtext + ''); slider.controls.next.bind('click', clicknextbind); slider.controls.prev.bind('click', clickprevbind); if (slider.settings.nextselector) { $(slider.settings.nextselector).append(slider.controls.next); } if (slider.settings.prevselector) { $(slider.settings.prevselector).append(slider.controls.prev); } if (!slider.settings.nextselector && !slider.settings.prevselector) { slider.controls.directionel = $(''); slider.controls.directionel.append(slider.controls.prev).append(slider.controls.next); slider.controls.el.addclass('bx-has-controls-direction').append(slider.controls.directionel); } } var appendcontrolsauto = function() { slider.controls.start = $(''); slider.controls.stop = $(''); slider.controls.autoel = $(''); slider.controls.autoel.on('click', '.bx-start', clickstartbind); slider.controls.autoel.on('click', '.bx-stop', clickstopbind); if (slider.settings.autocontrolscombine) { slider.controls.autoel.append(slider.controls.start); } else { slider.controls.autoel.append(slider.controls.start).append(slider.controls.stop); } if (slider.settings.autocontrolsselector) { $(slider.settings.autocontrolsselector).html(slider.controls.autoel); } else { slider.controls.el.addclass('bx-has-controls-auto').append(slider.controls.autoel); } updateautocontrols(slider.settings.autostart ? 'stop' : 'start'); } var appendcaptions = function() { slider.children.each(function(index) { var title = $(this).find('img:first').attr('title'); if (title != undefined && ('' + title).length) { $(this).append(' '); } }); } var clicknextbind = function(e) { if (slider.settings.auto) el.stopauto(); el.gotonextslide(); e.preventdefault(); } var clickprevbind = function(e) { if (slider.settings.auto) el.stopauto(); el.gotoprevslide(); e.preventdefault(); } var clickstartbind = function(e) { el.startauto(); e.preventdefault(); } var clickstopbind = function(e) { el.stopauto(); e.preventdefault(); } var clickpagerbind = function(e) { if (slider.settings.auto) el.stopauto(); var pagerlink = $(e.currenttarget); if (pagerlink.attr('data-slide-index') !== undefined) { var pagerindex = parseint(pagerlink.attr('data-slide-index')); if (pagerindex != slider.active.index) el.gotoslide(pagerindex); e.preventdefault(); } } var updatepageractive = function(slideindex) { var len = slider.children.length; 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; } slider.pagerel.find('a').removeclass('active'); slider.pagerel.each(function(i, el) { $(el).find('a').eq(slideindex).addclass('active'); }); } var updateafterslidetransition = function() { if (slider.settings.infiniteloop) { var position = ''; if (slider.active.index == 0) { position = slider.children.eq(0).position(); } else if (slider.active.index == getpagerqty() - 1 && slider.carousel) { position = slider.children.eq((getpagerqty() - 1) * getmoveby()).position(); } 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); } } } slider.working = false; slider.settings.onslideafter(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); } var updateautocontrols = function(state) { if (slider.settings.autocontrolscombine) { slider.controls.autoel.html(slider.controls[state]); } else { slider.controls.autoel.find('a').removeclass('active'); slider.controls.autoel.find('a:not(.bx-' + state + ')').addclass('active'); } } 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 (slider.active.index == 0) { slider.controls.prev.addclass('disabled'); slider.controls.next.removeclass('disabled'); } else if (slider.active.index == getpagerqty() - 1) { slider.controls.next.addclass('disabled'); slider.controls.prev.removeclass('disabled'); } else { slider.controls.prev.removeclass('disabled'); slider.controls.next.removeclass('disabled'); } } } var initauto = function() { if (slider.settings.autodelay > 0) { var timeout = settimeout(el.startauto, slider.settings.autodelay); } else { el.startauto(); } if (slider.settings.autohover) { el.hover(function() { if (slider.interval) { el.stopauto(true); slider.autopaused = true; } }, function() { if (slider.autopaused) { el.startauto(true); slider.autopaused = null; } }); } } var initticker = function() { var startposition = 0; if (slider.settings.autodirection == 'next') { el.append(slider.children.clone().addclass('bx-clone')); } else { el.prepend(slider.children.clone().addclass('bx-clone')); var position = slider.children.first().position(); startposition = slider.settings.mode == 'horizontal' ? -position.left : -position.top; } setpositionproperty(startposition, 'reset', 0); slider.settings.pager = false; slider.settings.controls = false; slider.settings.autocontrols = false; if (slider.settings.tickerhover && !slider.usingcss) { slider.viewport.hover(function() { el.stop(); }, function() { var totaldimens = 0; slider.children.each(function(index) { totaldimens += slider.settings.mode == 'horizontal' ? $(this).outerwidth(true) : $(this).outerheight(true); }); var ratio = slider.settings.speed / totaldimens; var property = slider.settings.mode == 'horizontal' ? 'left' : 'top'; var newspeed = ratio * (totaldimens - (math.abs(parseint(el.css(property))))); tickerloop(newspeed); }); } tickerloop(); } var tickerloop = function(resumespeed) { speed = resumespeed ? resumespeed : slider.settings.speed; var position = { left: 0, top: 0 }; var reset = { left: 0, top: 0 }; if (slider.settings.autodirection == 'next') { position = el.find('.bx-clone').first().position(); } else { reset = slider.children.first().position(); } var animateproperty = slider.settings.mode == 'horizontal' ? -position.left : -position.top; var resetvalue = slider.settings.mode == 'horizontal' ? -reset.left : -reset.top; var params = { resetvalue: resetvalue }; setpositionproperty(animateproperty, 'ticker', speed, params); } var inittouch = function() { slider.touch = { start: { x: 0, y: 0 }, end: { x: 0, y: 0 } } slider.viewport.bind('touchstart', ontouchstart); } var ontouchstart = function(e) { if (slider.working) { e.preventdefault(); } else { slider.touch.originalpos = el.position(); var orig = e.originalevent; slider.touch.start.x = orig.changedtouches[0].pagex; slider.touch.start.y = orig.changedtouches[0].pagey; slider.viewport.bind('touchmove', ontouchmove); slider.viewport.bind('touchend', ontouchend); } } var ontouchmove = function(e) { var orig = e.originalevent; var xmovement = math.abs(orig.changedtouches[0].pagex - slider.touch.start.x); var ymovement = math.abs(orig.changedtouches[0].pagey - slider.touch.start.y); if ((xmovement * 3) > ymovement && slider.settings.preventdefaultswipex) { e.preventdefault(); } else if ((ymovement * 3) > xmovement && slider.settings.preventdefaultswipey) { e.preventdefault(); } if (slider.settings.mode != 'fade' && slider.settings.onetoonetouch) { var value = 0; if (slider.settings.mode == 'horizontal') { var change = orig.changedtouches[0].pagex - slider.touch.start.x; value = slider.touch.originalpos.left + change; } else { var change = orig.changedtouches[0].pagey - slider.touch.start.y; value = slider.touch.originalpos.top + change; } setpositionproperty(value, 'reset', 0); } } var ontouchend = function(e) { slider.viewport.unbind('touchmove', ontouchmove); var orig = e.originalevent; var value = 0; slider.touch.end.x = orig.changedtouches[0].pagex; slider.touch.end.y = orig.changedtouches[0].pagey; if (slider.settings.mode == 'fade') { var distance = math.abs(slider.touch.start.x - slider.touch.end.x); if (distance >= slider.settings.swipethreshold) { slider.touch.start.x > slider.touch.end.x ? el.gotonextslide() : el.gotoprevslide(); el.stopauto(); } } else { var distance = 0; 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 (!slider.settings.infiniteloop && ((slider.active.index == 0 && distance > 0) || (slider.active.last && distance < 0))) { setpositionproperty(value, 'reset', 200); } else { if (math.abs(distance) >= slider.settings.swipethreshold) { distance < 0 ? el.gotonextslide() : el.gotoprevslide(); el.stopauto(); } else { setpositionproperty(value, 'reset', 200); } } } slider.viewport.unbind('touchend', ontouchend); } var resizewindow = function(e) { if (!slider.initialized) return; var windowwidthnew = $(window).width(); var windowheightnew = $(window).height(); if (windowwidth != windowwidthnew || windowheight != windowheightnew) { windowwidth = windowwidthnew; windowheight = windowheightnew; el.redrawslider(); slider.settings.onsliderresize.call(el, slider.active.index); } } el.gotoslide = function(slideindex, direction) { if (slider.working || slider.active.index == slideindex) return; slider.working = true; slider.oldindex = slider.active.index; if (slideindex < 0) { slider.active.index = getpagerqty() - 1; } else if (slideindex >= getpagerqty()) { slider.active.index = 0; } else { slider.active.index = slideindex; } slider.settings.onslidebefore(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); if (direction == 'next') { slider.settings.onslidenext(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); } else if (direction == 'prev') { slider.settings.onslideprev(slider.children.eq(slider.active.index), slider.oldindex, slider.active.index); } slider.active.last = slider.active.index >= getpagerqty() - 1; if (slider.settings.pager) updatepageractive(slider.active.index); if (slider.settings.controls) updatedirectioncontrols(); if (slider.settings.mode == 'fade') { if (slider.settings.adaptiveheight && slider.viewport.height() != getviewportheight()) { slider.viewport.animate({ height: getviewportheight() }, slider.settings.adaptiveheightspeed); } slider.children.filter(':visible').fadeout(slider.settings.speed).css({ zindex: 0 }); slider.children.eq(slider.active.index).css('zindex', slider.settings.slidezindex + 1).fadein(slider.settings.speed, function() { $(this).css('zindex', slider.settings.slidezindex); updateafterslidetransition(); }); } else { if (slider.settings.adaptiveheight && slider.viewport.height() != getviewportheight()) { slider.viewport.animate({ height: getviewportheight() }, slider.settings.adaptiveheightspeed); } var moveby = 0; var position = { left: 0, top: 0 }; if (!slider.settings.infiniteloop && slider.carousel && slider.active.last) { if (slider.settings.mode == 'horizontal') { var lastchild = slider.children.eq(slider.children.length - 1); position = lastchild.position(); moveby = slider.viewport.width() - lastchild.outerwidth(); } else { var lastshowingindex = slider.children.length - slider.settings.minslides; position = slider.children.eq(lastshowingindex).position(); } } else if (slider.carousel && slider.active.last && direction == 'prev') { var eq = slider.settings.moveslides == 1 ? slider.settings.maxslides - getmoveby() : ((getpagerqty() - 1) * getmoveby()) - (slider.children.length - slider.settings.maxslides); var lastchild = el.children('.bx-clone').eq(eq); position = lastchild.position(); } else if (direction == 'next' && slider.active.index == 0) { position = el.find('> .bx-clone').eq(slider.settings.maxslides).position(); slider.active.last = false; } else if (slideindex >= 0) { var requestel = slideindex * getmoveby(); position = slider.children.eq(requestel).position(); } if ("undefined" !== typeof (position)) { var value = slider.settings.mode == 'horizontal' ? -(position.left - moveby) : -position.top; setpositionproperty(value, 'slide', slider.settings.speed); } } } el.gotonextslide = function() { if (!slider.settings.infiniteloop && slider.active.last) return; var pagerindex = parseint(slider.active.index) + 1; el.gotoslide(pagerindex, 'next'); } el.gotoprevslide = function() { if (!slider.settings.infiniteloop && slider.active.index == 0) return; var pagerindex = parseint(slider.active.index) - 1; el.gotoslide(pagerindex, 'prev'); } el.startauto = function(preventcontrolupdate) { if (slider.interval) return; slider.interval = setinterval(function() { slider.settings.autodirection == 'next' ? el.gotonextslide() : el.gotoprevslide(); }, slider.settings.pause); if (slider.settings.autocontrols && preventcontrolupdate != true) updateautocontrols('stop'); } el.stopauto = function(preventcontrolupdate) { if (!slider.interval) return; clearinterval(slider.interval); slider.interval = null; if (slider.settings.autocontrols && preventcontrolupdate != true) updateautocontrols('start'); } el.getcurrentslide = function() { return slider.active.index; } el.getcurrentslideelement = function() { return slider.children.eq(slider.active.index); } el.getslidecount = function() { return slider.children.length; } el.redrawslider = function() { slider.children.add(el.find('.bx-clone')).width(getslidewidth()); slider.viewport.css('height', getviewportheight()); if (!slider.settings.ticker) setslideposition(); if (slider.active.last) slider.active.index = getpagerqty() - 1; if (slider.active.index >= getpagerqty()) slider.active.last = true; if (slider.settings.pager && !slider.settings.pagercustom) { populatepager(); updatepageractive(slider.active.index); } } el.destroyslider = function() { if (!slider.initialized) return; slider.initialized = false; $('.bx-clone', this).remove(); slider.children.each(function() { $(this).data("origstyle") != undefined ? $(this).attr("style", $(this).data("origstyle")) : $(this).removeattr('style'); }); $(this).data("origstyle") != undefined ? this.attr("style", $(this).data("origstyle")) : $(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.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); } el.reloadslider = function(settings) { if (settings != undefined) options = settings; el.destroyslider(); init(); } init(); return this; } } )(jquery);