epiclock.retro.min.js 1.1 KB

123456789101112131415161718
  1. /*!
  2. * Retro renderer for epiclock
  3. *
  4. * Copyright (c) Eric Garside
  5. * Dual licensed under:
  6. * MIT: http://www.opensource.org/licenses/mit-license.php
  7. * GPLv3: http://www.opensource.org/licenses/gpl-3.0.html
  8. */
  9. "use strict";(function($){var innerTemplate='<span class="epiclock-img"><span class="epiclock-animation"></span></span>';function animate()
  10. {var clock=this;setTimeout(function()
  11. {$('.a1',clock.container).removeClass('a1').addClass('a2');setTimeout(function()
  12. {$('.a2',clock.container).removeClass('a2').addClass('s');},150);},150);}
  13. $.epiclock.addRenderer('retro',function(element,value)
  14. {var digits=value.substring(1)==='m'?[value]:value.split('').reverse(),last=element.data('epiclock-last'),compare=last?last.split('').reverse():[],image=$.makeArray($('.epiclock-img',element)).reverse();$.each(digits,function(index,digit)
  15. {if(digit===compare[index])
  16. {return;}
  17. $('.epiclock-animation',$(image[index]||$(innerTemplate).prependTo(element)).removeClass('d'+compare[index]).addClass('d'+digit)).removeClass('s').addClass('a1');});},function()
  18. {this.bind('rendered',animate);});}(jQuery));