-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.wixel.content_slider.min.js
10 lines (10 loc) · 2.19 KB
/
jquery.wixel.content_slider.min.js
1
2
3
4
5
6
7
8
9
10
/**
* Wixel Content Slider
* http://wixelhq.com
*
* Copyright 2012, WixelHQ
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Author: Sean Nieuwoudt (http://twitter.com/SeanNieuwoudt)
*/
(function(b){var a={init:function(c){var d=b.extend({debug:false,speed:500},c);if(d.debug){jQuery.data(document.body,"wx_scroll_debug",true)}if(d.speed){jQuery.data(document.body,"wx_scroll_speed",d.speed)}return this.each(function(){var f=1;var h=b(this);h.data("debug",d.debug);h.data("duration",d.duration);h.data("auto_scroll",d.auto_scroll);a.log(d);a.log("Creating the .wx-slide-rail container");h.wrapInner('<div class="wx-slide-rail">');b(this).find(".wx-slide-rail").css({position:"absolute",top:"0",left:"0"});h.find(".slide-item").first().addClass("active-slide");h.find(".slide-item").each(function(i){b(this).attr("position",f);a.log("Setting slide position attribute: "+f);f++});var g=h.width();var j=h.find(".slide-item").length;var e=g*j;h.data("slide_width",g);h.find(".wx-slide-rail").css({width:e})})},next:function(){return this.each(function(){var f=b(this);var e=f.find(".slide-item.active-slide").next();if(e.length==0){e=f.find(".slide-item").first()}f.find(".slide-item").removeClass("active-slide");e.addClass("active-slide");a.log("Sliding to: "+e.attr("position"));var c=e.attr("position")-1;var d=b(this).data("slide_width");f.find(".wx-slide-rail").animate({left:-(c*d)},jQuery.data(document.body,"wx_scroll_speed"))})},previous:function(){return this.each(function(){var f=b(this);var e=f.find(".slide-item.active-slide").prev();if(e.length==0){e=f.find(".slide-item").last()}f.find(".slide-item").removeClass("active-slide");e.addClass("active-slide");a.log("Sliding to: "+e.attr("position"));var c=e.attr("position")-1;var d=b(this).data("slide_width");f.find(".wx-slide-rail").animate({left:-(c*d)},jQuery.data(document.body,"wx_scroll_speed"))})},log:function(c){if(jQuery.data(document.body,"wx_scroll_debug")&&console){console.log(c)}}};b.fn.wxContentSlider=function(c){if(a[c]){return a[c].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof c==="object"||!c){return a.init.apply(this,arguments)}else{b.error("Method "+c+" does not exist on jQuery.wxContentSlider")}}}})(jQuery);