PageSourceSearch

https://www.soyvillaclara.gob.cu/modules/mod_news_pro_gk5/tmpl/portal_modes/new_news_slider/script.mootools.js

js soyvillaclara.gob.cu collected 2026-10-03 18:01:07 UTC 5,443 bytes, 185 lines download raw bytes

1jQuery(document).ready(function() {
2	jQuery(document).find('.gkNspPM-NewNewsSlider').each(function(i, module) {
3		module = jQuery(module);
4
5		if(!module.hasClass('active')) {
6			module.addClass('active');
7			new InfiniteSlider(module);
8		}
9	});
10});
11
12var InfiniteSlider = function (wrapper) {
13    // Set object fields
14    this.wrapper = wrapper;
15    this.next = this.wrapper.find('.gkNext');
16    this.prev = this.wrapper.find('.gkPrev');
17    this.items = false;
18    this.itemsAmount = this.wrapper.find('.gkItem').length;
19    this.newWidth = 0;
20    this.itemWidth = 0;
21    this.list = this.wrapper.find('.gkList');
22    this.currentItem = 0;
23    this.blank = false;
24    this.hoverStop = false;
25    this.autoAnimation = this.list.attr('data-interval');
26    // Initialize the UI
27    this.initUI();
28};
29
30InfiniteSlider.prototype.initUI = function () {
31    var self = this;
32    var content = this.list.html();
33    // Duplicate items in the list
34    this.list.html(content + content);
35    this.items = this.wrapper.find('.gkItem');
36    // Get dimensions
37    this.itemWidth = this.items.first().outerWidth();
38    this.newWidth = this.items.length * this.itemWidth;
39    // Set list dimension
40    this.list.css('width', this.newWidth + "px");
41    // Add clone classes to items
42    this.items.each(function (i, item) {
43        if (i >= self.items.length / 2) {
44            item = jQuery(item);
45            item.addClass('gkClone');
46        }
47    });
48
49    this.next.on('click', function (e) {
50        e.preventDefault();
51        self.animate('next');
52    });
53
54    this.prev.on('click', function (e) {
55        e.preventDefault();
56        self.animate('prev');
57    });
58
59    this.wrapper.on('mouseenter', function () {
60        self.hoverStop = true;
61    });
62
63    this.wrapper.on('mouseleave', function () {
64        self.hoverStop = false;
65    });
66
67    jQuery(window).on('resize', function () {
68        self.resize();
69    });
70
71    if (this.autoAnimation > 0) {
72        setTimeout(function () {
73            self.autoAnimate(self.autoAnimation);
74        }, this.autoAnimation);
75    }
76    
77    this.resize();
78};
79
80InfiniteSlider.prototype.elementToMove = function (direction) {
81    if (direction === 'prev') {
82        return ((this.itemsAmount * 2) + this.currentItem) % (this.itemsAmount * 2);
83    }
84
85    return ((this.itemsAmount * 2) + this.currentItem - 1) % (this.itemsAmount * 2);
86};
87
88InfiniteSlider.prototype.elementForMove = function (direction) {
89    if (direction === 'prev') {
90        return ((this.itemsAmount * 2) + this.currentItem + 1) % (this.itemsAmount * 2);
91    }
92
93    return ((this.itemsAmount * 2) + this.currentItem - 2) % (this.itemsAmount * 2);
94};
95
96InfiniteSlider.prototype.animate = function (direction) {
97    var self = this;
98    var forMove, toMove;
99
100    if (this.blank || !this.list.hasClass('gkScrollable')) {
101        return false;
102    }
103
104    if (direction === 'next') {
105        this.currentItem = ++this.currentItem;
106    } else {
107        this.currentItem = --this.currentItem;
108    }
109
110    this.currentItem = this.currentItem % (this.itemsAmount * 2);
111    forMove = this.elementForMove(direction);
112    toMove = this.elementToMove(direction);
113    this.blank = true;
114
115    if (direction === 'next') {
116        this.list.addClass('gkAnimate');
117
118        setTimeout(function () {
119            self.list.css('margin-left', -self.itemWidth + "px");
120
121            setTimeout(function () {
122                self.list.removeClass('gkAnimate');
123
124                setTimeout(function () {
125                    self.list.css('margin-left', "0px");
126                    jQuery(self.items.get(forMove)).after(jQuery(self.items.get(toMove)));
127                    self.blank = false;
128                }, 20);
129            }, 320);
130        }, 20);
131    } else {
132        this.list.css('margin-left', -1 * this.itemWidth + "px");
133        jQuery(this.items.get(forMove)).before(jQuery(this.items.get(toMove)));
134
135        setTimeout(function () {
136            self.list.addClass('gkAnimate');
137
138            setTimeout(function () {
139                self.list.css('margin-left', "0px");
140
141                setTimeout(function () {
142                    self.list.removeClass('gkAnimate');
143                    self.blank = false;
144                }, 320);
145            }, 20);
146        }, 20);
147    }
148};
149
150InfiniteSlider.prototype.autoAnimate = function (interval) {
151    var self = this;
152
153    if (this.blank) {
154        this.blank = false;
155    } else if (!this.hoverStop) {
156        this.animate('next');
157    }
158
159    setTimeout(function () {
160        self.autoAnimate(interval);
161    }, interval);
162};
163
164InfiniteSlider.prototype.resize = function () {
165    var divider = this.list.hasClass('scrollable') ? 2 : 1;
166    // Get item new iwdth
167    this.itemWidth = this.items.first().outerWidth();
168
169    // Compare the size of the list area
170    if ((this.list.outerWidth() / divider) >= this.wrapper.outerWidth()) {
171        this.newWidth = this.items.length * this.itemWidth;
172        this.list.removeClass('gkNonScrollable');
173        this.list.addClass('gkScrollable');
174        this.prev.css('display', 'block');
175        this.next.css('display', 'block');
176    } else {
177        this.newWidth = (this.items.length / 2) * this.itemWidth;
178        this.list.removeClass('gkScrollable');
179        this.list.addClass('gkNonScrollable');
180        this.prev.css('display', 'none');
181        this.next.css('display', 'none');
182    }
183    // Set list dimension
184    this.list.css('width', this.newWidth + "px");
185};

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.