diff --git a/themes/butterfly/source/js/flipcountdown.js b/themes/butterfly/source/js/flipcountdown.js index e69de29..92f403c 100644 --- a/themes/butterfly/source/js/flipcountdown.js +++ b/themes/butterfly/source/js/flipcountdown.js @@ -0,0 +1,190 @@ +/** + * @preserve jQuery flipcountdown plugin v3.0.4 + * @homepage http://xdsoft.net/jqplugins/flipcountdown/ + * (c) 2013, Chupurnov Valeriy. + */ + (function($){ + jQuery.fn.flipCountDown = jQuery.fn.flipcountdown = function( _options ){ + var default_options = { + showHour :true, + showMinute :true, + showSecond :true, + am :false, + tzoneOffset :0, + speedFlip :60, + period :1000, + tick :function(){ + return new Date(); + }, + autoUpdate :true, + size :'md' + }, + + sizes = { + lg:77, + md:52, + sm:35, + xs:24 + }, + + createFlipCountDown = function( $box ){ + let $flipcountdown = $('
'), + $clearex = $(''), + + options = $.extend({},default_options), + + timer = 0, + + _animateRange = function( box,a,b ){ + _animateOne( box,a,(a>b&&!(a==9&&b==0))?-1:1,!(a==9&&b==0)?Math.abs(a-b):1 ); + }, + + _animateOne = function( box,a,arrow,range ){ + if( range<1 ) + return; + + _setMargin(box,-(a*6*sizes[options.size]+1),1,arrow,function(){ + _animateOne(box,a+arrow,arrow,range-1); + },range); + }, + + _setMargin = function( box, marginTop, rec, arrow,callback,range){ + if( marginTop<=-sizes[options.size]*60 ) + marginTop = -1; + box.css('background-position','0px '+marginTop+'px' ); + if( rec<=6 ){ + setTimeout(function(){ + _setMargin(box, marginTop-arrow*sizes[options.size], ++rec, arrow, callback,range); + },parseInt(options.speedFlip/range)); + }else + callback(); + }, + + blocks = [], + + _typeCompare = function ( a,b ){ + return a&&b&&( + (a==b)|| + (/^[0-9]+$/.test(a+''+b))|| + (/^[:.\s]+$/.test(a+''+b)) + ); + }, + + _generate = function( chars ){ + if( !(chars instanceof Array) || !chars.length ) + return false; + for( var i = 0, n = chars.length;i