PageSourceSearch

https://almerecity.nl/wp-content/themes/Impreza/common/js/elements/progbar.js?ver=8.46.1

js almerecity.nl collected 2026-10-02 11:43:44 UTC 4,502 bytes, 162 lines download raw bytes

1/**
2 * UpSolution Element: Progbar
3 */
4;( function( $, undefined ) {
5	"use strict";
6
7	 $us.WProgbar = function( container, options ) {
8		// Elements
9		this.$container = $( container );
10		this.$bar = $( '.w-progbar-bar-h', this.$container );
11		this.$count = $( '.w-progbar-title-count, .w-progbar-bar-count', this.$container );
12		this.$title = $( '.w-progbar-title', this.$container );
13
14		// Default options
15		this.options = {
16			delay: 100,
17			duration: 800,
18			finalValue: 100,
19			offset: '10%',
20			startValue: 0,
21			value: 50
22		};
23
24		// Get options
25		if ( this.$container.is( '[onclick]' ) ) {
26			$.extend( this.options, this.$container[0].onclick() || {} );
27			// Delete data everywhere except for the preview of the USBuilder, the data may be needed again to restore the elements.
28			if ( ! $us.usbPreview() ) this.$container.removeAttr( 'onclick' );
29		}
30
31		// Priority in transferred options through JS will be higher.
32		$.extend( this.options, options || {} );
33
34		if ( /bot|googlebot|crawler|spider|robot|crawling/i.test( navigator.userAgent ) ) {
35			this.$container.removeClass( 'initial' );
36		}
37
38		// Set start value
39		this.$count.text( '' );
40
41		// When an item falls into scope, a run callback function.
42		$us.waypoints.add( this.$container, this.options.offset, this.init.bind( this ) );
43	};
44
45	// Export API
46	$.extend( $us.WProgbar.prototype, {
47		/**
48		 * Init the object.
49		 */
50		init: function() {
51			if ( this.running ) {
52				return;
53			}
54			this.running = true;
55
56			if ( this.$container.hasClass( 'initial' ) ) {
57				this.$container.removeClass( 'initial' )
58			}
59
60			// Get all the necessary parameters for the meter and run it.
61			var
62				loops = Math.ceil( this.options.duration / this.options.delay ),
63				increment = parseFloat( this.options.value ) / loops,
64				loopCount = 0,
65				handle = null,
66				startValue = 0;
67
68			/**
69			 * Anonymous function for creating an interval.
70			 */
71			var funLoop = function() {
72				startValue += increment;
73				loopCount++;
74				if ( handle ) {
75					$ush.clearTimeout( handle );
76				}
77				if ( loopCount >= loops ) {
78					var result = this.options.template;
79					if ( this.options.hasOwnProperty( 'showFinalValue' ) ) {
80						result += ' ' + this.options.showFinalValue;
81					}
82					this.$count.text( result );
83					return;
84				}
85				this.render.call( this, startValue );
86				handle = $ush.timeout( funLoop.bind( this ), this.options.delay );
87			};
88
89			// Run loop
90			funLoop.call( this );
91
92			var finalValue = parseFloat( this.options.finalValue ),
93				width = ( ( parseFloat( parseFloat( this.options.value ) ) / parseFloat( finalValue ) ) * 100 )
94				.toFixed( 0 );
95
96			// Run the CSS animations to render a progress bar.
97			this.$bar
98				.on( 'transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', this._events.transitionEnd.bind( this ) )
99				.css( {
100					width: width + '%',
101					transitionDuration: parseInt( this.options.duration ) + 'ms'
102				} );
103		},
104		// Event handlers
105		_events: {
106			/**
107			 * Called after css animation finishes.
108			 */
109			transitionEnd: function() {
110				var result = this.options.template;
111				if ( this.options.hasOwnProperty( 'showFinalValue' ) ) {
112					result += ' ' + this.options.showFinalValue;
113				}
114				this.$count.text( result );
115				this.running = false;
116			}
117		},
118		/**
119		 * Render of the counter.
120		 *
121		 * @param {numeric} value
122		 */
123		render: function( value ) {
124			var index = 0,
125				// Result formatting
126				result = ( '' + this.options.template )
127					.replace( /([\-\d\.])/g, function( match ) {
128						value += '';
129						if ( index === 0 && match === '0' ) {
130							// Skip point if float value.
131							if ( value.charAt( index + 1 ) === '.' || match === '.' ) {
132								index++;
133							}
134							return match;
135						}
136						return value.charAt( index++ ) || '';
137					}.bind( this ) );
138
139			if ( result.charAt( index -1 ) === '.' ) {
140				result = result.substr( 0, index -1 ) + result.substr( index );
141			}
142
143			if ( this.options.hasOwnProperty( 'showFinalValue' ) ) {
144				result += ' ' + this.options.showFinalValue;
145			}
146
147			// Show result
148			this.$count.text( result );
149		}
150	} );
151
152	// The jQuery version
153	$.fn.wProgbar = function( options ) {
154		this.each( function() {
155			$( this ).data( 'wProgbar', new $us.WProgbar( this, options ) );
156		} );
157	};
158
159	$( function() {
160		jQuery( '.w-progbar' ).wProgbar();
161	} );
162} )( 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.