function fwslider() { var glob = { cs: 0, pause: 6000, duration: 750 }; this.init = function(params) { if (params.duration) { glob.duration = parseInt(params.duration, 10); } if (params.pause) { glob.pause = parseInt(params.pause, 10); } /* Init */ content.init(); display.bindControls(); controls.bindControls(); }; var display = { /* Resize function */ resize: function() { $("#fwslider").css({height: $("#fwslider .slide").height()}); controls.position(); }, /* Bind resize listener */ bindControls: function() { $(window).resize(function() { display.resize(); }); } }; var controls = { /* Adjust buttons position */ position: function() { $("#fwslider .slidePrev, #fwslider .slideNext").css({ top: $("#fwslider").height() / 2 - $("#fwslider .slideNext").height() / 2 }); $("#fwslider .slidePrev").css({left: 0}); $("#fwslider .slideNext").css({right: 0}); }, /* Bind button controls */ bindControls: function() { /* Hover effect */ $("#fwslider .slidePrev, #fwslider .slideNext").on("mouseover", function() { $(this).animate({ opacity: 1 }, { queue: false, duration: 1000, easing: "easeOutCubic" }); }); /* Hover effect - mouseout */ $("#fwslider .slidePrev, #fwslider .slideNext").on("mouseout", function() { $(this).animate({ opacity: 0.5 }, { queue: false, duration: 1000, easing: "easeOutCubic" }); }); /* Next Button */ $("#fwslider .slideNext").on("click", function() { if ($("#fwslider .slide").is(":animated")) return; if ($("#fwslider .slide:eq(" + (glob.cs + 1) + ")").length <= 0) { glob.cs = 0; $("#fwslider .timers .timer .progress").stop(); $("#fwslider .timers .timer:last .progress").animate({ width: "100%" }, { queue: false, duration: glob.duration, easing: "easeOutCubic", complete: function() { $("#fwslider .timers .timer .progress").css({ width: "0%" }); } }); } else { glob.cs++; $("#fwslider .timers .timer .progress").stop(); $("#fwslider .timers .timer:lt(" + glob.cs + ") .progress").animate({ width: "100%" }, { queue: false, duration: glob.duration, easing: "easeOutCubic" }); } content.show(); }); /* Previous Button */ $("#fwslider .slidePrev").on("click", function() { if ($("#fwslider .slide").is(":animated")) return; if (glob.cs <= 0) { glob.cs = $("#fwslider .slide:last").index(); $("#fwslider .timers .timer .progress").stop(); $("#fwslider .timers .timer .progress").css({ width: "100%" }); $("#fwslider .timers .timer:last .progress").animate({ width: "0%" }, { queue: false, duration: glob.duration, easing: "easeOutCubic" }); } else { glob.cs--; $("#fwslider .timers .timer .progress").stop(); $("#fwslider .timers .timer:gt(" + glob.cs + ") .progress").css({ width: "0%" }); $("#fwslider .timers .timer:eq(" + glob.cs + ") .progress").animate({ width: "0%" }, { queue: false, duration: glob.duration, easing: "easeOutCubic" }); } content.show(); }); } }; var content = { init: function() { /* First run content adjustment */ for (var i = 0; i < $("#fwslider .slide").length; i++) { $('