PageSourceSearch

http://kuvshinovoadm.ru/js/jquery.tinycarousel.js

js kuvshinovoadm.ru collected 2026-10-03 00:38:36 UTC 5,958 bytes, 208 lines download raw bytes

1;(function (factory)
2{
3    if (typeof define === 'function' && define.amd)
4    {
5        define(['jquery'], factory);
6    }
7    else if (typeof exports === 'object')
8    {
9        factory(require('jquery'));
10    }
11    else
12    {
13        factory(jQuery);
14    }
15}
16(function ($)
17{
18    var pluginName = "tinycarousel"
19    ,   defaults   =
20        {
21            start:          0      // The starting slide
22        ,   axis:           "x"    // vertical or horizontal scroller? ( x || y ).
23        ,   buttons:        true   // show left and right navigation buttons.
24        ,   bullets:        false  // is there a page number navigation present?
25        ,   interval:       false  // move to another block on intervals.
26        ,   intervalTime:   3000   // interval time in milliseconds.
27        ,   animation:      true   // false is instant, true is animate.
28        ,   animationTime:  1000   // how fast must the animation move in ms?
29        ,   infinite:       true   // infinite carousel.
30        }
31    ;
32
33    function Plugin($container, options)
34    {
35        this.options   = $.extend({}, defaults, options);
36        this._defaults = defaults;
37        this._name     = pluginName;
38
39        var self      = this
40        ,   $viewport = $container.find(".viewport:first")
41        ,   $overview = $container.find(".overview:first")
42        ,   $slides   = 0
43        ,   $next     = $container.find(".next:first")
44        ,   $prev     = $container.find(".prev:first")
45        ,   $bullets  = $container.find(".bullet")
46
47        ,   viewportSize    = 0
48        ,   contentStyle    = {}
49        ,   slidesVisible   = 0
50        ,   slideSize       = 0
51        ,   slideIndex      = 0
52
53        ,   isHorizontal  = this.options.axis === 'x'
54        ,   sizeLabel     = isHorizontal ? "Width" : "Height"
55        ,   posiLabel     = isHorizontal ? "left" : "top"
56        ,   intervalTimer = null
57        ;
58
59        this.slideCurrent = 0;
60        this.slidesTotal  = 0;
61
62        function initialize()
63        {
64            self.update();
65            self.move(self.slideCurrent);
66
67            setEvents();
68
69            return self;
70        }
71
72        this.update = function()
73        {
74            $overview.find(".mirrored").remove();
75
76            $slides           = $overview.children();
77            viewportSize      = $viewport[0]["offset" + sizeLabel];
78            slideSize         = $slides.first()["outer" + sizeLabel](true);
79            self.slidesTotal  = $slides.length;
80            self.slideCurrent = self.options.start || 0;
81            slidesVisible     = Math.ceil(viewportSize / slideSize);
82
83            $overview.append($slides.slice(0, slidesVisible).clone().addClass("mirrored"));
84            $overview.css(sizeLabel.toLowerCase(), slideSize * (self.slidesTotal + slidesVisible));
85
86            return self;
87        };
88
89        function setEvents()
90        {
91            if(self.options.buttons)
92            {
93                $prev.click(function()
94                {
95                    self.move(--slideIndex);
96
97                    return false;
98                });
99
100                $next.click(function()
101                {
102                    self.move(++slideIndex);
103
104                    return false;
105                });
106            }
107
108            $(window).resize(self.update);
109
110            if(self.options.bullets)
111            {
112                $container.on("click", ".bullet", function()
113                {
114                    self.move(slideIndex = +$(this).attr("data-slide"));
115
116                    return false;
117                });
118            }
119        }
120
121        this.start = function()
122        {
123            if(self.options.interval)
124            {
125                clearTimeout(intervalTimer);
126
127                intervalTimer = setTimeout(function()
128                {
129                    self.move(++slideIndex);
130
131                }, self.options.intervalTime);
132            }
133
134            return self;
135        };
136
137        this.stop = function()
138        {
139            clearTimeout(intervalTimer);
140
141            return self;
142        };
143
144        this.move = function(index)
145        {
146            slideIndex        = index;
147            self.slideCurrent = slideIndex % self.slidesTotal;
148
149            if(slideIndex < 0)
150            {
151                self.slideCurrent = slideIndex = self.slidesTotal - 1;
152                $overview.css(posiLabel, -(self.slidesTotal) * slideSize);
153            }
154
155            if(slideIndex > self.slidesTotal)
156            {
157                self.slideCurrent = slideIndex = 1;
158                $overview.css(posiLabel, 0);
159            }
160
161            contentStyle[posiLabel] = -slideIndex * slideSize;
162
163            $overview.animate(
164                contentStyle
165            ,   {
166                    queue    : false
167                ,   duration : self.options.animation ? self.options.animationTime : 0
168                ,   always : function()
169                    {
170                        $container.trigger("move", [$slides[self.slideCurrent], self.slideCurrent]);
171                    }
172            });
173
174            setButtons();
175            self.start();
176
177            return self;
178        };
179
180        function setButtons()
181        {
182            if(self.options.buttons && !self.options.infinite)
183            {
184                $prev.toggleClass("disable", self.slideCurrent <= 0);
185                $next.toggleClass("disable", self.slideCurrent >= self.slidesTotal - slidesVisible);
186            }
187
188            if(self.options.bullets)
189            {
190                $bullets.removeClass("active");
191                $($bullets[self.slideCurrent]).addClass("active");
192            }
193        }
194
195        return initialize();
196    }
197
198    $.fn[pluginName] = function(options)
199    {
200        return this.each(function()
201        {
202            if(!$.data(this, "plugin_" + pluginName))
203            {
204                $.data(this, "plugin_" + pluginName, new Plugin($(this), options));
205            }
206        });
207    };
208}));

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.