PageSourceSearch

https://refluxsummit.com/wp-content/plugins/vivo-online-marketing/…/asset/shortcode-counter/js/vivo-counter.js

js refluxsummit.com collected 2026-09-26 06:51:19 UTC 9,161 bytes, 314 lines download raw bytes

1(function ($) {
2
3    /** ----------------------------------------------------------------------------------------------------------------
4     *  Counter box
5     */
6
7    // Animate counter boxes
8    $.fn.vivo_box_counting = function () {
9		var $type	= $(this).data('type'),
10			$count_value = $(this).data('value'),
11            $count_direction = $(this).data('direction'),
12            $delimiter = $(this).data('delimiter'),
13            $from_value = $(this).data('start-value'),
14            $to_value = $count_value,
15			increment = $(this).data('increment'),
16			$animation = $(this).data('animation'),
17			dynamic_value = $count_value,
18			self = this;
19
20        if (!$delimiter) {
21            $delimiter = '';
22        }
23
24        if ($count_direction == 'down') {
25            $from_value = $count_value;
26            $to_value = 0;
27        }
28		if( $animation ){
29			$(this).countTo({
30				from: $from_value,
31				to: $to_value,
32				refreshInterval: 10,
33				speed: 1000,
34				formatter: function (value, options) {
35					value = value.toFixed(options.decimals);
36					value = value.replace(/\B(?=(\d{3})+(?!\d))/g, $delimiter);
37
38					if (value == '-0') {
39						value = 0;
40					}
41
42					return value;
43				},
44				onComplete: function(value){
45					$(this).attr('data-counting-updated', 1);
46				}
47			});
48		}else{
49			var without_animation_value = $to_value.toFixed(0);
50			without_animation_value = without_animation_value.replace(/\B(?=(\d{3})+(?!\d))/g, $delimiter);
51			$(self).text(without_animation_value)
52		}
53		if( $type == "cc" ){	
54			setInterval( function(){	
55				if( $(self).attr('data-counting-updated') ){
56					dynamic_value = dynamic_value + increment;
57					
58					var check_dynamic_value 		= Math.round(dynamic_value);
59					var check_dynamic_value_to_show	= check_dynamic_value.toFixed(0);
60					$(self).text(check_dynamic_value_to_show.replace(/\B(?=(\d{3})+(?!\d))/g, $delimiter));
61					$(self).attr( 'data-value', check_dynamic_value );
62				}
63			}, 1000 );
64		}
65    };
66
67
68    $.fn.countTo = function (options) {
69        options = options || {};
70
71        return $(this).each(function () {
72            // set options for current element
73            var settings = $.extend({}, $.fn.countTo.defaults, {
74                from: $(this).data('from'),
75                to: $(this).data('to'),
76                speed: $(this).data('speed'),
77                refreshInterval: $(this).data('refresh-interval'),
78                decimals: $(this).data('decimals')
79            }, options);
80
81            // how many times to update the value, and how much to increment the value on each update
82            var loops = Math.ceil(settings.speed / settings.refreshInterval),
83                increment = (settings.to - settings.from) / loops;
84
85            // references & variables that will change with each update
86            var self = this,
87                $self = $(this),
88                loopCount = 0,
89                value = settings.from,
90                data = $self.data('countTo') || {};
91
92            $self.data('countTo', data);
93
94            // if an existing interval can be found, clear it first
95            if (data.interval) {
96                clearInterval(data.interval);
97            }
98            data.interval = setInterval(updateTimer, settings.refreshInterval);
99
100            // initialize the element with the starting value
101            render(value);
102
103            function updateTimer() {
104                value += increment;
105                loopCount++;
106
107                render(value);
108
109                if (typeof(settings.onUpdate) == 'function') {
110                    settings.onUpdate.call(self, value);
111                }
112
113                if (loopCount >= loops) {
114                    // remove the interval
115                    $self.removeData('countTo');
116                    clearInterval(data.interval);
117                    value = settings.to;
118
119                    if (typeof(settings.onComplete) == 'function') {
120                        settings.onComplete.call(self, value);
121                    }
122                }
123            }
124
125            function render(value) {
126                var formattedValue = settings.formatter.call(self, value, settings);
127                $self.text(formattedValue);
128            }
129        });
130    };
131
132    $.fn.countTo.defaults = {
133        from: 0,               // the number the element should start at
134        to: 0,                 // the number the element should end at
135        speed: 1000,           // how long it should take to count between the target numbers
136        refreshInterval: 100,  // how often the element should be updated
137        decimals: 0,           // the number of decimal places to show
138        formatter: formatter,  // handler for formatting the value before rendering
139        onUpdate: null,        // callback method for every time the element is updated
140        onComplete: null       // callback method for when the element finishes updating
141    };
142
143    function formatter(value, settings) {
144        return value.toFixed(settings.decimals);
145    }
146 
147//    $('.vivo-display-counter').each(function() {
148//        $(this).vivo_box_counting();
149//    });
150 
151 
152/*
153 * jQuery.appear
154 * https://github.com/bas2k/jquery.appear/
155 * http://code.google.com/p/jquery-appear/
156 * http://bas2k.ru/
157 *
158 * Copyright (c) 2009 Michael Hixson
159 * Copyright (c) 2012-2014 Alexander Brovikov
160 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
161 */
162
163$.fn.appear = function(fn, options) {
164
165    var settings = $.extend({
166
167        //arbitrary data to pass to fn
168        data: undefined,
169
170        //call fn only on the first appear?
171        one: true,
172
173        // X & Y accuracy
174        accX: 0,
175        accY: 0
176
177    }, options);
178
179    return this.each(function() {
180
181        var t = $(this);
182
183        //whether the element is currently visible
184        t.appeared = false;
185
186        if (!fn) {
187
188            //trigger the custom event
189            t.trigger('appear', settings.data);
190            return;
191        }
192
193        var w = $(window);
194
195        //fires the appear event when appropriate
196        var check = function() {
197
198            //is the element hidden?
199            if (!t.is(':visible')) {
200
201                //it became hidden
202                t.appeared = false;
203                return;
204            }
205
206            //is the element inside the visible window?
207            var a = w.scrollLeft();
208            var b = w.scrollTop();
209            var o = t.offset();
210            var x = o.left;
211            var y = o.top;
212
213            var ax = settings.accX;
214            var ay = settings.accY;
215            var th = t.height();
216            var wh = w.height();
217            var tw = t.width();
218            var ww = w.width();
219
220            if (y + th + ay >= b &&
221                y <= b + wh + ay &&
222                x + tw + ax >= a &&
223                x <= a + ww + ax) {
224
225                //trigger the custom event
226                if (!t.appeared) t.trigger('appear', settings.data);
227
228            } else {
229
230                //it scrolled out of view
231                t.appeared = false;
232            }
233        };
234
235        //create a modified fn with some additional logic
236        var modifiedFn = function() {
237
238            //mark the element as visible
239            t.appeared = true;
240
241            //is this supposed to happen only once?
242            if (settings.one) {
243
244                //remove the check
245                w.unbind('scroll', check);
246                var i = $.inArray(check, $.fn.appear.checks);
247                if (i >= 0) $.fn.appear.checks.splice(i, 1);
248            }
249
250            //trigger the original fn
251            fn.apply(this, arguments);
252        };
253
254        //bind the modified fn to the element
255        if (settings.one) t.one('appear', settings.data, modifiedFn);
256        else t.bind('appear', settings.data, modifiedFn);
257
258        //check whenever the window scrolls
259        w.scroll(check);
260
261        //check whenever the dom changes
262        $.fn.appear.checks.push(check);
263
264        //check now
265        (check)();
266    });
267};
268
269//keep a queue of appearance checks
270$.extend($.fn.appear, {
271
272    checks: [],
273    timeout: null,
274
275    //process the queue
276    checkAll: function() {
277        var length = $.fn.appear.checks.length;
278        if (length >
278 0) while (length--) ($.fn.appear.checks[length])();
279    },
280
281    //check the queue asynchronously
282    run: function() {
283        if ($.fn.appear.timeout) clearTimeout($.fn.appear.timeout);
284        $.fn.appear.timeout = setTimeout($.fn.appear.checkAll, 20);
285    }
286});
287
288//run checks when these methods are called
289$.each(['append', 'prepend', 'after', 'before', 'attr',
290    'removeAttr', 'addClass', 'removeClass', 'toggleClass',
291    'remove', 'css', 'show', 'hide'], function(i, n) {
292    var old = $.fn[n];
293    if (old) {
294        $.fn[n] = function() {
295            var r = old.apply(this, arguments);
296            $.fn.appear.run();
297            return r;
298        }
299    }
300});
301
302
303	// Counters Box
304	$(document).ready(function(){
305		$('.vivo_counter-box').each(function() {
306			$(this).appear(function() {
307				$(this).find('.vivo_display-counter').each(function() {
308					$(this).vivo_box_counting();
309				});
310			});
311		});
312	});
313
314})(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.