(function($) { UABBProgressBar = function( settings ) { this.settings = settings; this.animation_delay = settings.animation_delay; this.viewport_position = 90; this.animation_speed = settings.animation_speed; this.nodeClass = '.fl-node-' + settings.id; this._init(); }; UABBProgressBar.addCommas = function( n ){ var rgx = /(\d+)(\d{3})/; n += ''; x = n.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; }; UABBProgressBar.prototype = { settings : {}, nodeClass : '', animation : '', animation_speed : '1000', animation_delay : 0, viewport_position : 90, _init: function() { if( typeof jQuery.fn.waypoint !== 'undefined' ) { $(this.nodeClass).waypoint({ offset: this.viewport_position + '%', handler: $.proxy( this._initProgressBar, this ) }); } }, /** * Initiate animation. * * @since 0.0.7 * @access private * @method _initProgressBar */ _initProgressBar: function() { var delay = '1000'; if( !isNaN( delay ) && delay > 0 ) { setTimeout( function(){ this._countProgressNumber(); }.bind( this ), delay ); } else { this._countProgressNumber(); } }, _countProgressNumber: function() { var ani_speed = parseInt('1000'); jQuery( '.fl-node-' ).find( '.uabb-layout-' ).each( function( index ) { var form = jQuery( '.fl-node-' ).find( '.uabb-layout-.uabb-progress-bar-' + index ); var completeClass = form.hasClass('uabb-progress-complete-number'); if( !completeClass ) { text_field.animate({ Counter: number }, { duration: (ani_speed), easing: 'linear', step: function ( now ) { text_field.text( UABBProgressBar.addCommas( Math.ceil( now ) ) + '%' ); } }); form.addClass( 'uabb-progress-complete-number' ); } }); }, _executeProgressBarHorizontal: function() { var ani_speed = parseInt('1000'); jQuery( '.fl-node-' ).find( '.uabb-layout-horizontal' ).each( function( index ) { var form = jQuery( '.fl-node-' ).find( '.uabb-layout-horizontal.uabb-progress-bar-' + index ); var completeClass = form.hasClass('uabb-progress-complete'); if( !completeClass ) { var number = Math.ceil( form.data( 'number' ) ); form.find('.uabb-progress-bar').animate({ width: number + '%' }, { duration: ani_speed, easing: 'linear', queue: false }); form.addClass( 'uabb-progress-complete' ); } }); }, _executeProgressBarVertical: function() { var ani_speed = parseInt('1000'); jQuery( '.fl-node-' ).find( '.uabb-layout-vertical' ).each( function( index ) { var form = jQuery( '.fl-node-' ).find( '.uabb-layout-vertical.uabb-progress-bar-' + index ); var completeClass = form.hasClass('uabb-progress-complete'); if( !completeClass ) { var number = Math.ceil( form.data( 'number' ) ); var progressBarWidth = number + '%'; form.find('.uabb-progress-bar').animate({ height: number + '%' }, { duration: ani_speed, easing: 'linear' }); form.addClass( 'uabb-progress-complete' ); } }); }, _executeProgressBarCircular: function( e ) { var ani_speed = parseInt('1000'); jQuery( '.fl-node-' ).find( '.uabb-layout-circular' ).each( function( index ) { var form = jQuery( '.fl-node-' ).find( '.uabb-layout-circular.uabb-progress-bar-' + index ); var completeClass = form.hasClass('uabb-progress-complete'); if( !completeClass ) { var circle = form.find('.uabb-bar'), circular_number = Math.ceil( form.find('.uabb-svg-wrap').data( 'number' ) ); var r = 140, circlePi = Math.PI*(r*2); var pct = ( ( 100 - circular_number ) /100) * circlePi; circle.animate({ strokeDashoffset: pct }, { duration: ani_speed, easing: 'linear' }); form.addClass( 'uabb-progress-complete' ); } }); }, _executeProgressBarSemiCircular: function( e ) { var ani_speed = parseInt('1000'); jQuery( '.fl-node-' ).find( '.uabb-layout-semi-circular' ).each( function( index ) { var form = jQuery( '.fl-node-' ).find( '.uabb-layout-semi-circular.uabb-progress-bar-' + index ); var completeClass = form.hasClass('uabb-progress-complete'); if( !completeClass ) { var circle = form.find('.uabb-bar'), circular_number = Math.ceil( form.find('.uabb-svg-wrap').data( 'number' ) ) / 2; var r = 145, circlePi = Math.PI*(r*2); var pct = ( ( 100 - circular_number ) /100) * circlePi; circle.animate({ strokeDashoffset: pct }, { duration: ani_speed, easing: 'linear' }); form.addClass( 'uabb-progress-complete' ); } }); }, }; new UABBProgressBar({ id: '', animation_delay: '1', animation_speed: '1', viewport_position: 90 }); })(jQuery);