PageSourceSearch

https://www.socialmotus.com/scripts/jquery.jomino.js

js socialmotus.com collected 2026-10-04 21:15:04 UTC 3,558 bytes, 123 lines download raw bytes

1/**
2 * jQuery.jomino - domino your html elements !
3 * @author Amin Rockninja - amin.mdlahir(at)gmail(dot)com
4 * Version : 1.0.0 - Tue 11 Aug 2009
5 */
6(function($j){
7
8    // Definition
9    jQuery.fn.jomino = function(options){
10    
11        //default options
12        var defaults = {
13			//basics
14            interval: "200",
15            duration: "400",
16            easing: 'swing',
17            reverse: false,
18            random: false,
19			autostart: true,
20			
21			//callbacks
22			onAnimate: null,
23			onComplete: null
24        };
25        
26        //setup options
27        var opts = jQuery.extend({}, defaults, options);
28        
29        //private variables
30        var elems = jQuery.makeArray(this);
31		var elemsCollection = new Array;
32		var reverse = opts.reverse;
33		var intervalTimer = null;
34        
35        //adjust sequence in array based on options
36        elems = opts.reverse ? elems.reverse() : elems; // for backwards direction
37        elems = opts.random ? elems.sort(function(){ return 0.5 - Math.random() }) : elems; //elements in array scrambled for randomness
38        
39        //global methods
40		jQuery.jomino = {
41            forward: function(){
42				reverse = false;
43				if (!intervalTimer) {
44					intervalTimer = fireElement();
45				}
46            },
47			rewind: function() {
48                if (!reverse) {
49                    jQuery.jomino.stop();
50                    reverse = true;
51                    intervalTimer = fireElement();
52                }
53			},
54			stop: function() {
55				clearTimeout(intervalTimer);
56				intervalTimer = null;
57				reverse = false;
58			}
59        };
60		
61		//recursive function which executes the animation on the elements in array, one element at a time
62        function fireElement(){
63			var elemsSize = reverse ? elemsCollection.length : elems.length;
64			var nextElem = null;
65            if (elemsSize > 0) {
66				if(!reverse) {
67					nextElem = elems.shift();
68                	elemsCollection.push(nextElem);
69				} else {
70					nextElem = elemsCollection.pop();
71					elems.unshift(nextElem);
72				}
73                jQuery.fn.jomino.animateElement(nextElem, reverse, opts.duration, opts.easing);
74                setTimeout(function(){
75                    fireCallback(opts, "onAnimate", nextElem);
76                }, opts.duration);
77				intervalTimer = setTimeout(function(){
78                    fireElement();
79                }, opts.interval);
80                
81            } else if (elemsSize == 0) {
82                    setTimeout(function(){
83                        fireCallback(opts, "onComplete", nextElem);
84                    }, opts.duration);
85					reverse = false;
86					intervalTimer = null;
87                }
88            }
89		
90		if(opts.autostart)
91			jQuery.jomino.forward();
92 
93    };
94	
95	//exposed functions
96  	//animation on current element
97    jQuery.fn.jomino.animateElement = function(elem, reverse, duration, easemethod){
98		reverse ? jQuery(elem).fadeOut(duration, easemethod) : jQuery(elem).fadeIn(duration, easemethod);  
99    };
100	
101	//private functions
102    //callback
103    function fireCallback(opts, name, obj){
104        var fn = opts[name];
105        if ($j.isFunction(fn)) {
106            try {
107                return fn.call(obj);
108            } 
109            catch (error) {
110                log("jomino." + name + ": ", error);
111                return false;
112            }
113        }
114        return true;
115    }
116     
117	 // For debugging using firebug
118     function log($jtxt, $jobj){
119         if (window.console && window.console.log) 
120             window.console.log($jtxt, $jobj);
121     };
122    
123    })(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.