Ticker.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. if (typeof window.RadControlsNamespace == "undefined")
  2. {
  3. window.RadControlsNamespace = {};
  4. }
  5. RadControlsNamespace.Ticker = function (listener)
  6. {
  7. this.Listener = listener;
  8. this.IntervalPointer = null;
  9. }
  10. RadControlsNamespace.Ticker.prototype =
  11. {
  12. Configure : function (config)
  13. {
  14. this.Duration = config.Duration;
  15. this.Interval = 16;
  16. },
  17. Start : function ()
  18. {
  19. clearInterval(this.IntervalPointer);
  20. this.TimeElapsed = 0;
  21. var instance = this;
  22. var closure = function ()
  23. {
  24. instance.Tick();
  25. }
  26. this.Tick();
  27. this.IntervalPointer = setInterval(closure, this.Interval);
  28. },
  29. Tick : function ()
  30. {
  31. this.TimeElapsed += this.Interval;
  32. this.Listener.OnTick(this.TimeElapsed);
  33. if (this.TimeElapsed >= this.Duration)
  34. {
  35. this.Stop();
  36. }
  37. },
  38. Stop : function ()
  39. {
  40. if (this.IntervalPointer)
  41. {
  42. this.Listener.OnTickEnd();
  43. clearInterval(this.IntervalPointer);
  44. this.IntervalPointer = null;
  45. }
  46. }
  47. }
  48. //BEGIN_ATLAS_NOTIFY
  49. if (typeof(Sys) != "undefined")
  50. {
  51. if (Sys.Application != null && Sys.Application.notifyScriptLoaded != null)
  52. {
  53. Sys.Application.notifyScriptLoaded();
  54. }
  55. }
  56. //END_ATLAS_NOTIFY