PageSourceSearch

https://ccmc.gov.in/jquery/super-treadmill.js

js ccmc.gov.in collected 2026-10-02 12:56:47 UTC 4,332 bytes, 118 lines download raw bytes

1
2
3(function ( $ ) {
4 
5    var running = false;
6
7    // moves treadmill in the downward direction
8    treadmillDown = function(obj, speed) {
9                    setTimeout( function() {
10                        if(running) {
11                            var elm = obj.find('.treadmill-unit').last();
12                            var elm2 = elm.clone();
13                            var height = elm.height();
14                            elm2.css('top', -height + 'px');
15                            elm2.css('height', '0px');
16                            elm2.prependTo(obj);
17                            elm2.animate({
18                                'top': '0px',
19                                'height': height
20                            }, 1000, function() { 
21                                elm.remove();
22                            });
23
24                            treadmillDown(obj, speed);
25                        }
26                    }, speed);
27    },
28
29    //moves treadmill in the upward direction
30    treadmillUp = function(obj, speed) {
31                    setTimeout( function() {
32                        if(running) {
33                            var elm = obj.find('.treadmill-unit').first();
34                            var elm2 = elm.clone();
35                            var height = elm.height();
36                            elm.animate({
37                                'height': '0px',
38                                'top': -height
39                            }, 1000, function() {
40                                elm.remove();
41                            });
42                            elm2.appendTo(obj);
43
44                            treadmillUp(obj, speed);
45                        }                   
46                    }, speed);
47    },
48
49    // decides which type of treadmill to use
50    selectTreadmill = function(direction, obj, speed) {
51        if(direction == "down")
52            treadmillDown(obj, speed);
53        else
54            treadmillUp(obj, speed);
55    },
56    
57    // starts the treadmill
58    $.fn.startTreadmill = function( options ) {
59
60        var treadmillHeight = 0;
61
62        var settings = $.extend({
63            // These are the defaults.
64            runAfterPageLoad: true,
65            direction: "down",
66            speed: "medium",
67            viewable: 3,
68            pause: false
69        }, options );
70
71        // Sets the height of Super Treadmill to viewable times height of the first unit else it is set to user-defined css value
72        if(settings.viewable <= $(this).children().length && settings.viewable != 0)
73            treadmillHeight = settings.viewable * $(this).find('.treadmill-unit').first().height();
74        else
75            treadmillHeight = $(this).height();
76
77        $(this).css('height', treadmillHeight);
78
79        
80        // Super-Treadmill starts immediately after the page load
81        if(settings.runAfterPageLoad)
82            running = true;
83
84        
85        // Setting the tread speed of the Super-Treadmill
86        var treadSpeed = 3000;
87
88        if(settings.speed == "slow" || settings.speed == "medium" || settings.speed == "fast" || $.isNumeric(settings.speed)) {
89            if(settings.speed == "slow")
90                treadSpeed = 5000; // 5 seconds
91            else if(settings.speed == "fast")
92                treadSpeed = 1200; // 1.2 seconds
93            else if(settings.speed == "medium")
94                treadSpeed = 3000; // 3 seconds
95            else
96                treadSpeed = settings.speed; // user-defined value
97        }
98        else
99            $.error("Super-Treadmill can only use one of its predefined speeds: 'slow', 'medium', 'fast' or a number that you specify, which it later converts into milliseconds");
100
101        
102        // Binding events to pause the Super-Treadmill during mouse enter and leave.
103        if(settings.pause) {
104            $(this).mouseenter( function() {
105                running = !running;
106            });
107
108            $(this).mouseleave( function() {
109                running = !running;
110                selectTreadmill(settings.direction, $(this), treadSpeed);
111            });
112        }
113
114        selectTreadmill(settings.direction, $(this), treadSpeed);
115        
116    };
117 
118}( 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.