1: // README
2: //
3: // There are two steps to adding a property:
4: //
5: // 1. Create a member variable to store your property
6: // 2. Add the get_ and set_ accessors for your property
7: //
8: // Remember that both are case sensitive!
9:
10:
11: /// <reference name="MicrosoftAjaxTimer.debug.js" />
12: /// <reference name="MicrosoftAjaxWebForms.debug.js" />
13: /// <reference name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" assembly="AjaxControlToolkit" />
14:
15:
16: Type.registerNamespace('AJAXControls.ProgressBar'); 17:
18: AJAXControls.ProgressBar.ProgressBarBehavior = function(element) { 19: AJAXControls.ProgressBar.ProgressBarBehavior.initializeBase(this, [element]);
20:
21: // TODO : (Step 1) Add your property variables here
22: this._MaxSizeValue = 0;
23: this._MinSizeValue = 0;
24: this._TotalDistance = 0;
25: this._TimerValue = 0.1;
26: this._Animation = null;
27: this._ScriptLocationValue = '';
28: this._ScriptNameValue = '';
29: this._Counter = 0;
30: this._TimeOutValue = 2000;
31: this._CurrentValue = 0;
32: this._PercentageControlIDValue = null;
33: this._ModeValue = 'width';
34: }
35: AJAXControls.ProgressBar.ProgressBarBehavior.prototype = { 36: initialize: function() { 37: AJAXControls.ProgressBar.ProgressBarBehavior.callBaseMethod(this, 'initialize');
38:
39: // TODO: Add your initalization code here
40: this._TotalDistance = this._MaxSizeValue - this._MinSizeValue;
41: this._Animation = new $AA.LengthAnimation(this.get_element(), this._TimerValue, 50, 'style', this._ModeValue, 0, 0, '%');
42: this._Animation.add_ended(Function.createDelegate(this, this.AnimationEnd));
43: this._Animation.initialize();
44: },
45:
46: show: function() { 47: this.get_element().style.display = '';
48: this.get_element().style.visibility = '';
49: this._Animation.play();
50: },
51:
52: hide: function() { 53: this.get_element().style.display = 'none';
54: this.get_element().style.visibility = 'hidden';
55: this._Animation.stop();
56: },
57:
58: AnimationEnd: function() { 59: if (this._CurrentValue < 100) { 60: ++this._Counter;
61: Sys.Net.WebServiceProxy.invoke(this._ScriptLocationValue, this._ScriptNameValue, false, {}, Function.createDelegate(this, this._onMethodComplete), Function.createDelegate(this, this._onMethodError), this._Counter, this._TimeOutValue); 62: }
63: },
64: _onMethodComplete: function(result, userContext, methodName) { 65: if (this._Counter == userContext) { 66: if (result > 100)
67: result = 100;
68: this._StartValue = this._CurrentValue;
69: this._EndValue = result;
70: this._CurrentValue = result;
71: if (this._PercentageControlIDValue) { 72: var PercentHolder = $get(this._PercentageControlIDValue);
73: PercentHolder.innerHTML = result + "% completed";
74: }
75: this._Animation.set_startValue(this._StartValue);
76: this._Animation.set_endValue(this._EndValue);
77: this._Animation.play();
78: }
79: },
80: _onMethodError: function(webServiceError, userContext, methodName) { 81: if (webServiceError.get_timedOut()) { 82: this.get_element().innerHTML = AjaxControlToolkit.Resources.DynamicPopulate_WebServiceTimeout;
83: }
84: else { 85: this.get_element().innerHTML = String.format(AjaxControlToolkit.Resources.DynamicPopulate_WebServiceError, webServiceError.get_statusCode());
86: this.get_element().innerHTML += this._ScriptLocationValue;
87: this.get_element().innerHTML += this._ScriptNameValue;
88: }
89: },
90:
91: dispose: function() { 92: // TODO: Add your cleanup code here
93:
94: AJAXControls.ProgressBar.ProgressBarBehavior.callBaseMethod(this, 'dispose');
95: },
96:
97: // TODO: (Step 2) Add your property accessors here
98: get_MaxSize: function() { 99: return this._MaxSizeValue;
100: },
101:
102: set_MaxSize: function(value) { 103: this._MaxSizeValue = value;
104: },
105: get_MinSize: function() { 106: return this._MinSizeValue;
107: },
108:
109: set_MinSize: function(value) { 110: this._MinSizeValue = value;
111: },
112: get_Timer: function() { 113: return this._TimerValue;
114: },
115:
116: set_Timer: function(value) { 117: this._TimerValue = value;
118: },
119: get_ScriptName: function() { 120: return this._ScriptNameValue;
121: },
122:
123: set_ScriptName: function(value) { 124: this._ScriptNameValue = value;
125: },
126: get_ScriptLocation: function() { 127: return this._ScriptLocationValue;
128: },
129:
130: set_ScriptLocation: function(value) { 131: this._ScriptLocationValue = value;
132: },
133: get_PercentageControlID: function() { 134: return this._PercentageControlIDValue;
135: },
136:
137: set_PercentageControlID: function(value) { 138: this._PercentageControlIDValue = value;
139: },
140: get_Mode: function() { 141: return this._ModeValue;
142: },
143:
144: set_Mode: function(value) { 145: this._ModeValue = value;
146: }
147: }
148: AJAXControls.ProgressBar.ProgressBarBehavior.registerClass('AJAXControls.ProgressBar.ProgressBarBehavior', AjaxControlToolkit.BehaviorBase);