From 431512990eee95143d9ac7ec740fbd649a77d4e2 Mon Sep 17 00:00:00 2001 From: 2012mjm <2007mjm@gmail.com> Date: Mon, 20 May 2013 02:15:08 +0430 Subject: [PATCH 1/2] Add play & stop function var sliderTabs = new $.sliderTabs($("#mySliderTabs"), { autoplay: 5000, mouseoverStop: true, //dafault:true, if mouse over on slide & tabs, then slider stops mouseleavePlay: true, //dafault:true, if mouse leave from slide & tabs, then slider runs }); // slider delay equal autoplay play slider // slider delay equal 3000 million second play slider stop slider --- jquery.sliderTabs.js | 46 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/jquery.sliderTabs.js b/jquery.sliderTabs.js index cedf1b7..f47b487 100644 --- a/jquery.sliderTabs.js +++ b/jquery.sliderTabs.js @@ -1,11 +1,12 @@ /* - * jQuery SliderTabs v1.1 + * jQuery SliderTabs v1.2 * http://lopatin.github.com/sliderTabs * * Copyright 2012, Alex Lopatin * Free to use under the MIT license. * http://www.opensource.org/licenses/mit-license.php * + * Edit By javad (www.mjm3d.com) */ @@ -15,6 +16,9 @@ */ $.sliderTabs = function(container, options){ var plugin = this; + + /* Add by javad */ + var autoplayInterval; var defaults = { autoplay: false, @@ -44,7 +48,11 @@ transition: 'slide', transitionEasing: 'easeOutCubic', transitionSpeed: 500, - width: null + width: null, + + /* Add by javad */ + mouseoverStop: true, + mouseleavePlay: true, }; // jQuery objects of important elements @@ -207,7 +215,7 @@ // Auto play if(settings.autoplay) - setInterval(plugin.next, settings.autoplay); + autoplayInterval = setInterval(plugin.next, settings.autoplay); // Panel arrows @@ -219,6 +227,22 @@ plugin.prev(); return false; }); + + /* Add by javad */ + // Stop, if mouse over + if(settings.mouseoverStop) { + $container.mouseover(function() { + plugin.stop(); + }); + } + + /* Add by javad */ + // play, if mouse leave + if(settings.mouseleavePlay) { + $container.mouseleave(function() { + plugin.play(); + }); + } } /* @@ -545,6 +569,20 @@ return height; }; + /* Add by javad */ + // Play slider + plugin.play = function(speed=null){ + if(!speed) speed = settings.autoplay; + if(speed) autoplayInterval = setInterval(plugin.next, speed); + } + + /* Add by javad */ + // Stop slider + plugin.stop = function(){ + if(autoplayInterval) + clearInterval(autoplayInterval); + } + // Initialize the plugin plugin.init(); @@ -827,4 +865,4 @@ function handler(event) { * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ -(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this); \ No newline at end of file +(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this); From 10d02892dfd57f2758a0c08a1de2cb7b2301bbd4 Mon Sep 17 00:00:00 2001 From: 2012mjm <2007mjm@gmail.com> Date: Mon, 20 May 2013 23:08:07 +0430 Subject: [PATCH 2/2] bug fix solve problem view in google chrome & IE --- jquery.sliderTabs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.sliderTabs.js b/jquery.sliderTabs.js index f47b487..5b7442c 100644 --- a/jquery.sliderTabs.js +++ b/jquery.sliderTabs.js @@ -571,7 +571,7 @@ /* Add by javad */ // Play slider - plugin.play = function(speed=null){ + plugin.play = function(speed){ if(!speed) speed = settings.autoplay; if(speed) autoplayInterval = setInterval(plugin.next, speed); }