File: D:/HostingSpaces/yoda-ict/yoda-ict.nl/wwwroot/public/js/home_clients_slider.js
(function($) {
/**
* Delays elements on scroll.
* Used for creating a parallax effect.
*
* @param element
* @param options
*/
$.clientSlider = function(element, options) {
var defaults = {
};
// Reference to this
var t = this;
// Create settings object
t.settings = {};
// Elements
var $ul = $('ul',element);
// Properties
var cIndex = 0;
var num;
// Constructor
t.init = function ()
{
// Extend the defaults with options, save in settings
t.settings = $.extend({}, defaults, options);
num = $ul.children('li').size();
};
t.next = function()
{
// Goto
if(cIndex != (num-3)) // 3 visible)
{
goto(cIndex+1);
}
};
t.prev = function()
{
// Goto
if(cIndex != 0) // 3 visible)
{
goto(cIndex-1);
}
};
var checkButtons = function()
{
console.log(cIndex);
// Disable next button
if(cIndex == (num-3))
{
$('#next').addClass('disabled');
}
else
{
$('#next').removeClass('disabled');
}
// Disable next button
if(cIndex == 0)
{
$('#prev').addClass('disabled');
}
else
{
$('#prev').removeClass('disabled');
}
};
var goto = function(tIndex)
{
var $li = $ul.children('li');
var top = -tIndex * ($li.height() + 20); // 20px marge
$ul.stop().animate({ top: top+'px' },600);
cIndex = tIndex;
checkButtons();
};
t.init();
};
// Extend Jquery with function
$.fn.clientSlider = function(options)
{
return this.each(function()
{
// if plugin has not already been attached to the element
if ($(this).data('cs') == undefined)
{
// create a new instance of the plugin
var clientSlider = new $.clientSlider(this, options);
$(this).data('cs', clientSlider);
}
});
}
})(jQuery);