1// (c) Copyright Microsoft Corporation. 2// This source is subject to the Microsoft Public License. 3// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL. 4// All other rights reserved. 5 6 7/// <reference name="MicrosoftAjax.debug.js" /> 8/// <reference name="MicrosoftAjaxTimer.debug.js" /> 9/// <reference name="MicrosoftAjaxWebForms.debug.js" /> 10 11 12/////////////////////////////////////////////////////////////////////////////// 13// Sys.Timer 14 15Sys.Timer = function() { 16 Sys.Timer.initializeBase(this); 17 18 this._interval = 1000; 19 this._enabled = false; 20 this._timer = null; 21} 22 23Sys.Timer.prototype = { 24 get_interval: function() { 25 26 return this._interval; 27 }, 28 set_interval: function(value) { 29 30 if (this._interval !== value) { 31 this._interval = value; 32 this.raisePropertyChanged('interval'); 33 34 if (!this.get_isUpdating() && (this._timer !== null)) { 35 this._stopTimer(); 36 this._startTimer(); 37 } 38 } 39 }, 40 41 get_enabled: function() { 42 43 return this._enabled; 44 }, 45 set_enabled: function(value) { 46 47 if (value !== this.get_enabled()) { 48 this._enabled = value; 49 this.raisePropertyChanged('enabled'); 50 if (!this.get_isUpdating()) { 51 if (value) { 52 this._startTimer(); 53 } 54 else { 55 this._stopTimer(); 56 } 57 } 58 } 59 }, 60 61 62 add_tick: function(handler) { 63 64 65 this.get_events().addHandler("tick", handler); 66 }, 67 68 remove_tick: function(handler) { 69 70 71 this.get_events().removeHandler("tick", handler); 72 }, 73 74 dispose: function() { 75 this.set_enabled(false); 76 this._stopTimer(); 77 78 Sys.Timer.callBaseMethod(this, 'dispose'); 79 }, 80 81 updated: function() { 82 Sys.Timer.callBaseMethod(this, 'updated'); 83 84 if (this._enabled) { 85 this._stopTimer(); 86 this._startTimer(); 87 } 88 }, 89 90 _timerCallback: function() { 91 var handler = this.get_events().getHandler("tick"); 92 if (handler) { 93 handler(this, Sys.EventArgs.Empty); 94 } 95 }, 96 97 _startTimer: function() { 98 this._timer = window.setInterval(Function.createDelegate(this, this._timerCallback), this._interval); 99 }, 100 101 _stopTimer: function() { 102 window.clearInterval(this._timer); 103 this._timer = null; 104 } 105} 106 107Sys.Timer.descriptor = { 108 properties: [ {name: 'interval', type: Number}, 109 {name: 'enabled', type: Boolean} ], 110 events: [ {name: 'tick'} ] 111} 112 113Sys.Timer.registerClass('Sys.Timer', Sys.Component);
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.