Skip to content

Instantly share code, notes, and snippets.

@tamert
Created November 27, 2012 17:52
Show Gist options
  • Save tamert/4155858 to your computer and use it in GitHub Desktop.
Save tamert/4155858 to your computer and use it in GitHub Desktop.
/**
* jQuery Stepbystep plugin
* http://www.tinysay.com/
*
* Copyright 2012, Tamer Agaoglu
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Date: Tuesday 27 Nov 2012
*/
;(function ($) {
$.fn.stepbystep = function(options,callback){
/* OPTIONS DEFAULTS */
var defaults = {
speed : 600, // effect speed
start : true, // item open or close ?
number : 0, // first item number
effect : "fade", // fade , slide
random : false, // random number all items ?
wait : 100, // delay all
};
var options = $.extend({}, defaults, options);
if(typeof callback != 'function') {
callback = function(){ };
}
if($(this)==undefined){
return false;
} else if($(this)==null){
return false;
} else if($(this).length<1){
return false;
}
var $this = $(this);
var total = $this.length;
var item = $this.eq(options.number);
var next = parseInt(options.number+1);
/* END STEP : START */
if(item==undefined){
callback();
return false;
} else if(item==null){
callback();
return false;
} else if(item.length<1){
callback();
return false;
}
/* END STEP : END */
if(options.start==true){
if(options.effect=="fade"){
item.delay(options.wait).slideDown(options.speed, function () {
$this.stepbystep({
speed : options.speed,
start : options.start,
number : options.number+1,
effect : options.effect,
random : options.random,
wait : options.wait
}, callback);
});
}
} else {
if(options.effect=="fade"){
item.delay(options.wait).slideUp(options.speed, function () {
$this.stepbystep({
speed : options.speed,
start : options.start,
number : options.number+1,
effect : options.effect,
random : options.random,
wait : options.wait
}, callback);
});
}
}
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment