﻿Type.registerNamespace("AjaxControlToolkit"); AjaxControlToolkit.NumericUpDownBehavior = function(a) { AjaxControlToolkit.NumericUpDownBehavior.initializeBase(this, [a]); this._currentValue = null; this._widthValue = null; this._targetButtonUpIDValue = null; this._targetButtonDownIDValue = null; this._serviceUpPathValue = null; this._serviceUpMethodValue = null; this._serviceDownPathValue = null; this._serviceDownMethodValue = null; this._refValuesValue = null; this._tagValue = null; this._elementTextBox = null; this._step = 1; this._min = -Number.MAX_VALUE; this._max = Number.MAX_VALUE; this._bUp = null; this._bDown = null; this._stepPrecision = 0; this._valuePrecision = 0; this._clickUpHandler = null; this._clickDownHandler = null; this._changeHandler = null }; AjaxControlToolkit.NumericUpDownBehavior.prototype = { initialize: function() { AjaxControlToolkit.NumericUpDownBehavior.callBaseMethod(this, "initialize"); $common.prepareHiddenElementForATDeviceUpdate(); var a = this.get_element(); this._elementTextBox = a; if (this._refValuesValue || this._serviceUpMethodValue || this._serviceDownMethodValue) this._elementTextBox.readOnly = true; else this._elementTextBox.readOnly = false; this.readValue(); this._changeHandler = Function.createDelegate(this, this._onChange); $addHandler(a, "blur", this._changeHandler); if (this._targetButtonUpIDValue == "" || this._targetButtonDownIDValue == "") { this._widthValue = Math.max(this._widthValue, 24); a.style.width = this._widthValue - 24 + "px"; a.style.textAlign = "center"; var b = document.createElement("DIV"); b.style.position = "relative"; b.style.width = this._widthValue + "px"; b.style.fontSize = a.clientHeight + "px"; b.style.height = a.clientHeight + "px"; b.style.paddingRight = "24px"; if (!(Sys.Browser.agent == Sys.Browser.Firefox || Sys.Browser.agent == Sys.Browser.Safari)) b.style.display = "inline"; else b.style.display = "inline-block"; a.parentNode.insertBefore(b, a); var c = document.createElement("TABLE"), g = document.createElement("TBODY"), h = document.createElement("TR"), i = document.createElement("TR"), d = document.createElement("TD"), f = document.createElement("TD"), e = document.createElement("TD"); d.rowSpan = "2"; d.style.verticalAlign = "middle"; f.style.verticalAlign = "middle"; e.style.verticalAlign = "middle"; h.appendChild(d); h.appendChild(f); i.appendChild(e); g.appendChild(h); g.appendChild(i); c.appendChild(g); b.appendChild(c); a.parentNode.removeChild(a); d.appendChild(a); c.style.borderCollapse = "collapse"; c.cellSpacing = "0"; c.cellPadding = "0"; c.style.display = "inline"; c.style.position = "relative"; d.style.padding = "0"; f.style.padding = "0"; e.style.padding = "0"; d.style.margin = "0"; f.style.margin = "0"; e.style.margin = "0" } if (this._targetButtonUpIDValue == "") { this._bUp = document.createElement("input"); this._bUp.type = "button"; this._bUp.id = a.id + "_bUp"; this._bUp.style.border = "outset 1px"; if (Sys.Browser.agent == Sys.Browser.InternetExplorer) { this._bUp.style.fontFamily = "Webdings"; this._bUp.style.fontSize = "9pt"; this._bUp.value = "5" } else { this._bUp.style.fontFamily = "Tahoma, Arial, sans-serif"; this._bUp.style.fontSize = "5pt"; this._bUp.value = "\u25b2"; this._bUp.style.fontWeight = "bold"; this._bUp.style.lineHeight = "3pt" } this._bUp.style.height = "12px"; this._bUp.style.width = "24px"; this._bUp.style.overflow = "hidden"; this._bUp.style.lineHeight = "1em"; f.appendChild(this._bUp) } if (this._targetButtonDownIDValue == "") { this._bDown = document.createElement("input"); this._bDown.type = "button"; this._bDown.id = a.id + "_bDown"; this._bDown.style.border = "outset 1px"; if (Sys.Browser.agent == Sys.Browser.InternetExplorer) { this._bDown.value = "6"; this._bDown.style.fontFamily = "Webdings"; this._bDown.style.fontSize = "9pt" } else { this._bDown.value = "\u25bc"; this._bDown.style.fontFamily = "Tahoma, Arial, sans-serif"; this._bDown.style.fontSize = "5pt"; this._bDown.style.fontWeight = "bold" } this._bDown.style.height = "12px"; this._bDown.style.lineHeight = "3pt"; this._bDown.style.width = "24px"; this._bDown.style.overflow = "hidden"; e.appendChild(this._bDown) } if (this._bUp == null) this._bUp = document.getElementById(this._targetButtonUpIDValue); if (this._bUp) { this._clickUpHandler = Function.createDelegate(this, this._clickUp); $addHandler(this._bUp, "click", this._clickUpHandler) } if (this._bDown == null) this._bDown = document.getElementById(this._targetButtonDownIDValue); if (this._bDown) { this._clickDownHandler = Function.createDelegate(this, this._clickDown); $addHandler(this._bDown, "click", this._clickDownHandler) } }, dispose: function() { if (this._changeHandler) { $removeHandler(this.get_element(), "blur", this._changeHandler); this._changeHandler = null } if (this._clickUpHandler) if (this._bUp) { $removeHandler(this._bUp, "click", this._clickUpHandler); this._clickUpHandler = null } if (this._clickDownHandler) if (this._bDown) { $removeHandler(this._bDown, "click", this._clickDownHandler); this._clickDownHandler = null } AjaxControlToolkit.NumericUpDownBehavior.callBaseMethod(this, "dispose") }, add_currentChanged: function(a) { this.get_events().addHandler("currentChanged", a) }, remove_currentChanged: function(a) { this.get_events().removeHandler("currentChanged", a) }, raiseCurrentChanged: function(a) { var b = this.get_events().getHandler("currentChanged"); if (b) { if (!a) a = Sys.EventArgs.Empty; b(this, a) } }, _onChange: function() { this.readValue(); if (this._refValuesValue) { this.setCurrentToTextBox(this._refValuesValue[this._currentValue]); if (this._elementTextBox) this._elementTextBox.readOnly = true } else { this.setCurrentToTextBox(this._currentValue); if (this._elementTextBox) this._elementTextBox.readOnly = this._serviceUpMethodValue || this._serviceDownMethodValue } }, readValue: function() { if (this._elementTextBox) { var b = this._elementTextBox.value; if (!this._refValuesValue) { if (!b) this._currentValue = this._min; else try { this._currentValue = parseFloat(b) } catch (d) { this._currentValue = this._min } if (isNaN(this._currentValue)) this._currentValue = this._min; this.setCurrentToTextBox(this._currentValue); this._valuePrecision = this._computePrecision(this._currentValue) } else { if (!b) this._currentValue = 0; else { var c = 0; for (var a = 0; a < this._refValuesValue.length; a++) if (b.toLowerCase() == this._refValuesValue[a].toLowerCase()) c = a; this._currentValue = c } this.setCurrentToTextBox(this._refValuesValue[this._currentValue]) } } }, setCurrentToTextBox: function(b) { if (this._elementTextBox) { this._elementTextBox.value = b; this.raiseCurrentChanged(b); if (document.createEvent) { var a = document.createEvent("HTMLEvents"); a.initEvent("change", true, false); this._elementTextBox.dispatchEvent(a) } else if (document.createEventObject) this._elementTextBox.fireEvent("onchange") } }, _incrementValue: function(a) { var b = parseFloat((this._currentValue + a).toFixed(Math.max(this._stepPrecision, this._valuePrecision))); if (a > 0) this._currentValue = Math.max(Math.min(b, this._max), this._min); else this._currentValue = Math.min(Math.max(b, this._min), this._max) }, _computePrecision: function(b) { if (b == Number.Nan) return this._min; var c = b.toString(); if (c) { var d = /\.(\d*)$/, a = c.match(d); if (a && a.length == 2 && a[1]) return a[1].length } return this._min }, get_Width: function() { return this._widthValue }, set_Width: function(a) { if (this._widthValue != a) { this._widthValue = a; this.raisePropertyChanged("Width") } }, get_Tag: function() { return this._tagValue }, set_Tag: function(a) { if (this._tagValue != a) { this._tagValue = a; this.raisePropertyChanged("Tag") } }, get_TargetButtonUpID: function() { return this._targetButtonUpIDValue }, set_TargetButtonUpID: function(a) { if (this._targetButtonUpIDValue != a) { this._targetButtonUpIDValue = a; this.raisePropertyChanged("TargetButtonUpID") } }, get_TargetButtonDownID: function() { return this._targetButtonDownIDValue }, set_TargetButtonDownID: function(a) { if (this._targetButtonDownIDValue != a) { this._targetButtonDownIDValue = a; this.raisePropertyChanged("TargetButtonDownID") } }, get_ServiceUpPath: function() { return this._serviceUpPathValue }, set_ServiceUpPath: function(a) { if (this._serviceUpPathValue != a) { this._serviceUpPathValue = a; this.raisePropertyChanged("ServiceUpPath") } }, get_ServiceUpMethod: function() { return this._serviceUpMethodValue }, set_ServiceUpMethod: function(a) { if (this._serviceUpMethodValue != a) { this._serviceUpMethodValue = a; this.raisePropertyChanged("ServiceUpMethod"); if (this._elementTextBox) this._elementTextBox.readOnly = true } }, get_ServiceDownPath: function() { return this._serviceDownPathValue }, set_ServiceDownPath: function(a) { if (this._serviceDownPathValue != a) { this._serviceDownPathValue = a; this.raisePropertyChanged("ServiceDownPath") } }, get_ServiceDownMethod: function() { return this._serviceDownMethodValue }, set_ServiceDownMethod: function(a) { if (this._serviceDownMethodValue != a) { this._serviceDownMethodValue = a; this.raisePropertyChanged("ServiceDownMethod"); if (this._elementTextBox) this._elementTextBox.readOnly = true } }, get_RefValues: function() { return this._refValuesValue ? this._refValuesValue.join(";") : "" }, set_RefValues: function(a) { if (a != "") { this._refValuesValue = a.split(";"); this._onChange(); if (this._elementTextBox) this._elementTextBox.readOnly = true } else { this._refValuesValue = null; if (this._elementTextBox) this._elementTextBox.readOnly = false } this.raisePropertyChanged("RefValues") }, get_Step: function() { return this._step }, set_Step: function(a) { if (a != this._step) { this._step = a; this._stepPrecision = this._computePrecision(a); this.raisePropertyChanged("Step") } }, get_Minimum: function() { return this._min }, set_Minimum: function(a) { if (a != this._min) { this._min = a; this.raisePropertyChanged("Minimum") } }, get_Maximum: function() { return this._max }, set_Maximum: function(a) { if (a != this._max) { this._max = a; this.raisePropertyChanged("Maximum") } }, _clickUp: function(a) { this.readValue(); if (this._serviceUpPathValue && this._serviceUpMethodValue) { Sys.Net.WebServiceProxy.invoke(this._serviceUpPathValue, this._serviceUpMethodValue, false, { current: this._currentValue, tag: this._tagValue }, Function.createDelegate(this, this._onMethodUpDownComplete)); $common.updateFormToRefreshATDeviceBuffer() } else if (this._refValuesValue) { if (this._currentValue + 1 < this._refValuesValue.length) { this._currentValue = this._currentValue + 1; this.setCurrentToTextBox(this._refValuesValue[this._currentValue]) } } else { this._incrementValue(this._step); this.setCurrentToTextBox(this._currentValue) } if (a) a.preventDefault(); return false }, _clickDown: function(a) { this.readValue(); if (this._serviceDownPathValue && this._serviceDownMethodValue) { Sys.Net.WebServiceProxy.invoke(this._serviceDownPathValue, this._serviceDownMethodValue, false, { current: this._currentValue, tag: this._tagValue }, Function.createDelegate(this, this._onMethodUpDownComplete)); $common.updateFormToRefreshATDeviceBuffer() } else if (this._refValuesValue) { if (this._currentValue - 1 >= 0) { this._currentValue = this._currentValue - 1; this.setCurrentToTextBox(this._refValuesValue[this._currentValue]) } } else { this._incrementValue(-this._step); this.setCurrentToTextBox(this._currentValue) } if (a) a.preventDefault(); return false }, _onMethodUpDownComplete: function(a) { this._currentValue = a; this.setCurrentToTextBox(this._currentValue) } }; AjaxControlToolkit.NumericUpDownBehavior.registerClass("AjaxControlToolkit.NumericUpDownBehavior", AjaxControlToolkit.BehaviorBase)
if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();