PageSourceSearch

https://www.meteorwanda.gov.rw/_assets/a3ba85d8e2287cfa4fc9afa0fcf…/jquery.matchHeight.js?1788961564

js meteorwanda.gov.rw collected 2026-09-24 19:32:19 UTC 9,774 bytes, 273 lines download raw bytes

1
2 
3
4/*
5  Vertical News Ticker 1.21
6  Original by: Tadas Juozapaitis ( kasp3rito [eta] gmail (dot) com )
7               https://github.com/kasp3r/vTicker
8  Forked/Modified by: Richard Hollis @richhollis - richhollis.co.uk
9 */
10  (function ($) {
11    var defaults, internal, methods;
12    defaults = {
13        speed: 700,
14        pause: 4000,
15        showItems: 1,
16        mousePause: true,
17        height: 0,
18        animate: true,
19        margin: 0,
20        padding: 0,
21        startPaused: false,
22        autoAppend: true
23    };
24    internal = {
25        moveUp: function (state, attribs) {
26            return internal.showNextItem(state, attribs, 'up');
27        },
28        moveDown: function (state, attribs) {
29            return internal.showNextItem(state, attribs, 'down');
30        },
31        nextItemState: function (state, dir) {
32            var height, obj;
33            obj = state.element.children('ul');
34            height = state.itemHeight;
35            if (state.options.height > 0) {
36                height = obj.children('li:first').height();
37            }
38            height += state.options.margin + state.options.padding * 2;
39            return {
40                height: height,
41                options: state.options,
42                el: state.element,
43                obj: obj,
44                selector: dir === 'up' ? 'li:first' : 'li:last',
45                dir: dir
46            };
47        },
48        showNextItem: function (state, attribs, dir) {
49            var clone, nis;
50            nis = internal.nextItemState(state, dir);
51            nis.el.trigger('vticker.beforeTick');
52            clone = nis.obj.children(nis.selector).clone(true);
53            if (nis.dir === 'down') {
54                nis.obj.css('top', '-' + nis.height + 'px').prepend(clone);
55            }
56            if (attribs && attribs.animate) {
57                if (!state.animating) {
58                    internal.animateNextItem(nis, state);
59                }
60            } else {
61                internal.nonAnimatedNextItem(nis);
62            }
63            if (nis.dir === 'up' && state.options.autoAppend) {
64                clone.appendTo(nis.obj);
65            }
66            return nis.el.trigger('vticker.afterTick');
67        },
68        animateNextItem: function (nis, state) {
69            var opts;
70            state.animating = true;
71            opts = nis.dir === 'up' ? {
72                top: '-=' + nis.height + 'px'
73            } : {
74                top: 0
75            };
76            return nis.obj.animate(opts, state.options.speed, function () {
77                $(nis.obj).children(nis.selector).remove();
78                $(nis.obj).css('top', '0px');
79                return state.animating = false;
80            });
81        },
82        nonAnimatedNextItem: function (nis) {
83            nis.obj.children(nis.selector).remove();
84            return nis.obj.css('top', '0px');
85        },
86        nextUsePause: function () {
87            var options, state;
88            state = $(this).data('state');
89            options = state.options;
90            if (state.isPaused || internal.hasSingleItem(state)) {
91                return;
92            }
93            return methods.next.call(this, {
94                animate: options.animate
95            });
96        },
97        startInterval: function () {
98            var options, state;
99            state = $(this).data('state');
100            options = state.options;
101            return state.intervalId = setInterval((function (_this) {
102                return function () {
103                    return internal.nextUsePause.call(_this);
104                };
105            })(this), options.pause);
106        },
107        stopInterval: function () {
108            var state;
109            if (!(state = $(this).data('state'))) {
110                return;
111            }
112            if (state.intervalId) {
113                clearInterval(state.intervalId);
114            }
115            return state.intervalId = void 0;
116        },
117        restartInterval: function () {
118            internal.stopInterval.call(this);
119            return internal.startInterval.call(this);
120        },
121        getState: function (from, elem) {
122            var state;
123            if (!(state = $(elem).data('state'))) {
124                throw new Error("vTicker: No state available from " + from);
125            }
126            return state;
127        },
128        isAnimatingOrSingleItem: function (state) {
129            return state.animating || this.hasSingleItem(state);
130        },
131        hasMultipleItems: function (state) {
132            return state.itemCount > 1;
133        },
134        hasSingleItem: function (state) {
135            return !internal.hasMultipleItems(state);
136        },
137        bindMousePausing: (function (_this) {
138            return function (el, state) {
139                return el.bind('mouseenter', function () {
140                    if (state.isPaused) {
141                        return;
142                    }
143                    state.pausedByCode = true;
144                    internal.stopInterval.call(this);
145                    return methods.pause.call(this, true);
146                }).bind('mouseleave', function () {
147                    if (state.isPaused && !state.pausedByCode) {
148                        return;
149                    }
150                    state.pausedByCode = false;
151                    methods.pause.call(this, false);
152                    return internal.startInterval.call(this);
153                });
154            };
155        })(this),
156        setItemLayout: function (el, state, options) {
157            var box;
158            el.css({
159                overflow: 'hidden'
160            }).children('ul').css({
161                position: 'relative',
162                margin: 0,
163                padding: 0
164            }).children('li').css({
165                margin: options.margin,
166                padding: options.padding
167            });
168            if (isNaN(options.height) || options.height === 0) {
169                el.children('ul').children('li').each(function () {
170                    if ($(this).height() > state.itemHeight) {
171                        return state.itemHeight = $(this).height();
172                    }
173                });
174                el.children('ul').children('li').each(function () {
175                    return $(this).height(state.itemHeight);
176                });
177                box = options.margin + options.padding * 2;
178                return el.height((state.itemHeight + box) * options.showItems + options.margin);
179            } else {
180                return el.height(options.height);
181            }
182        },
183        defaultStateAttribs: function (el, options) {
184            return {
185                itemCount: el.children('ul').children('li').length,
186                itemHeight: 0,
187                itemMargin: 0,
188                element: el,
189                animating: false,
190                options: options,
191                isPaused: options.startPaused,
192                pausedByCode: false
193            };
194        }
195    };
196    methods = {
197        init: function (options) {
198            var clonedDefaults, el, state;
199            if (state = $(this).data('state')) {
200                methods.stop.call(this);
201            }
202            state = null;
203            clonedDefaults = jQuery.extend({}, defaults);
204            options = $.extend(clonedDefaults, options);
205            el = $(this);
206            state = internal.defaultStateAttribs(el, options);
207            $(this).data('state', state);
208            internal.setItemLayout(el, state, options);
209            if (!options.startPaused) {
210                internal.startInterval.call(this);
211            }
212            if (options.mousePause) {
213                return internal.bindMousePausing(el, state);
214            }
215        },
216        pause: function (pauseState) {
217            var el, state;
218            state = internal.getState('pause', this);
219            if (!internal.hasMultipleItems(state)) {
220                return false;
221            }
222            state.isPaused = pauseState;
223            el = state.element;
224            if (pauseState) {
225                $(this).addClass('paused');
226                return el.trigger('vticker.pause');
227            } else {
228                $(this).removeClass('paused');
229                return el.trigger('vticker.resume');
230            }
231        },
232        next: function (attribs) {
233            var state;
234            state = internal.getState('next', this);
235            if (internal.isAnimatingOrSingleItem(state)) {
236                return false;
237            }
238            internal.restartInterval.call(this);
239            return internal.moveUp(state, attribs);
240        },
241        prev: function (attribs) {
242            var state;
243            state = internal.getState('prev', this);
244            if (internal.isAnimatingOrSingleItem(state)) {
245                return false;
246            }
247            internal.restartInterval.call(this);
248            return internal.moveDown(state, attribs);
249        },
250        stop: function () {
251            var state;
252            state = internal.getState('stop', this);
253            return internal.stopInterval.call(this);
254        },
255        remove: function () {
256            var el, state;
257            state = internal.getState('remove', this);
258            internal.stopInterval.call(this);
259            el = state.element;
260            el.unbind();
261            return el.remove();
262        }
263    };
264    return $.fn.vTicker = function (method) {
265        if (methods[method]) {
266            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
267        }
268        if (typeof method === 'object' || !method) {
269            return methods.init.apply(this, arguments);
270        }
271        return $.error('Method ' + method + ' does not exist on jQuery.vTicker');
272    };
273})(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.