PageSourceSearch

https://stroy-dokument.kz/modules/mod_sp_smart_slider/tmpl/minima/js/minima.slider.js

js stroy-dokument.kz collected 2026-10-06 05:17:26 UTC 5,732 bytes, 186 lines download raw bytes

1/**
2 * @author    JoomShaper http://www.joomshaper.com
3 * @copyright Copyright (C) 2010 - 2013 JoomShaper
4 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2
5 */;
6(function ($) {
7    var methods = {
8        currentIndex: 0,
9        totalItems: 0,
10        settings: {},
11        canvasWidth: 0,
12        canvasHeight: 0,
13        elements: '',
14        prevIndex: function () {
15            var c = this.currentIndex;
16            c--;
17            if (c < 0)
18                c = this.totalItems - 1;
19            return c;
20        },
21        nextIndex: function () {
22            var c = this.currentIndex;
23            c++;
24            if (c >= (this.totalItems))
25                c = 0;
26            return c;
27        },
28
29        currentIndex: function () {
30            return this.currentIndex;
31        },
32
33        prev: function () {
34            clearTimeout(this.autoplay);
35            this.currentIndex--;
36            if (this.currentIndex < 0) this.currentIndex = this.totalItems - 1;
37            var $this = this;
38            methods['run'].call(this);
39        },
40
41        next: function () {
42            clearTimeout(this.autoplay);
43            this.currentIndex++;
44            if (this.currentIndex >= (this.totalItems)) this.currentIndex = 0;
45            methods['run'].call(this);
46        },
47
48        play: function () {
49            var $this = this;
50            this.autoplay = setTimeout(function () {
51                methods['next'].call($this);
52            }, 1000);
53        },
54
55
56        preloader: function () {
57            var loadedImage = new Image();
58            var preloadImages = this.settings.preloadImages; // should array
59            var $this = this;
60
61            this.items.removeClass(this.settings.animateInClass).addClass(this.settings.animateOutClass);
62
63            if (this.settings.showPreloader != true || preloadImages.length < 1) {
64                $(this.settings.preloader).remove();
65                methods['run'].call(this);
66                this.elements.trigger('onSlide');
67            } else {
68                for (i = 0; i < preloadImages.length; i++) loadedImage.src = preloadImages[i];
69                $(loadedImage).load(function () {
70                    $($this.settings.preloader).fadeOut('fast', function () {
71                        $(this).remove()
72                    });
73                    methods['run'].call($this);
74                    $this.elements.trigger('onSlide');
75                });
76            }
77        },
78
79        autoplay: function () {
80
81            var $this = this;
82            if (this.settings.autoplay == true) {
83                this.autoplay = setTimeout(function () {
84                    methods['next'].call($this);
85                }, this.settings.duration);
86            }
87        },
88
89        pause: function () {
90            clearTimeout(this.autoplay);
91        },
92
93        goTo: function (index) {
94            clearTimeout(this.autoplay);
95            this.currentIndex = index;
96            methods['run'].call(this);
97        },
98
99        run: function () {
100            clearTimeout(this.delay);
101            var $this = this;
102            var $item = this.items.removeClass(this.settings.animateInClass).addClass(this.settings.animateOutClass);
103
104            this.delay = setTimeout(function () {
105                $item.eq($this.currentIndex)
106                    .removeClass($this.settings.animateOutClass)
107                    .addClass($this.settings.animateInClass);
108                $this.elements.trigger('onSlide');
109            }, this.settings.delay);
110
111            methods['autoplay'].call(this);
112        },
113
114        resize: function (fn) {
115
116            if (this.settings.fullWidth == true) {
117                this.elements.height($(window).width() * this.ratioHeight);
118            }
119        },
120
121        onSlide: function (fn) {
122            var $this = this;
123            this.elements.bind('onSlide', function (event) {
124                fn($this.currentIndex, $this.items, event);
125            });
126        },
127
128        init: function (elements, settings) {
129            this.currentIndex = 0;
130            this.elements = elements;
131            this.items = $(elements).find('>*');
132
133
134            this.totalItems = this.items.length;
135            this.settings = settings;
136
137
138            this.canvasWidth = this.settings.canvasWidth;
139            this.canvasHeight = this.settings.canvasHeight;
140
141            this.ratioHeight = this.settings.rHeight / this.settings.rWidth;
142            this.ratioWidth = this.settings.rWidth / this.settings.rHeight;
143
144
145            this.elements.width(this.canvasWidth);
146            this.elements.height(this.canvasHeight);
147
148
149            var $this = this;
150            this.items.each(function (i) {
151                $(this).addClass($this.settings.itemClassPrefix + (i + 1));
152            });
153        },
154
155    };
156
157    $.fn.minimaSlider = function (options, param) {
158
159        var settings = $.extend({
160            preloadImages: [],
161            autoplay: true,
162            preloader: '.sp-preloader',
163            showPreloader: true,
164            duration: 5000,
165            delay: 400,
166            itemClassPrefix: 'item-',
167            rWidth: 0,
168            rHeight: 0,
169            fullWidth: false,
170            animateInClass: 'animate-in',
171            animateOutClass: 'animate-out',
172        }, options);
173
174        return this.each(function (index, element) {
175
176            if (typeof (options) === 'string') {
177                methods[options].call(this, param);
178            } else {
179                methods['init'].call(this, $(this), settings);
180                methods['preloader'].call(this);
181                methods['autoplay'].call(this);
182                methods['resize'].call(this);
183            }
184        });
185    }
186})(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.