- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
ScriptResource.axd
资源名称:a.rar [点击查看]
上传用户:aa118c
上传日期:2021-05-13
资源大小:4785k
文件大小:254k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
HTML/CSS
- //-----------------------------------------------------------------------
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------
- // MicrosoftAjax.js
- // Microsoft AJAX Framework.
- Function.__typeName = 'Function';
- Function.__class = true;
- Function.createCallback = function Function$createCallback(method, context) {
- /// <param name="method" type="Function"></param>
- /// <param name="context" mayBeNull="true"></param>
- /// <returns type="Function"></returns>
- var e = Function._validateParams(arguments, [
- {name: "method", type: Function},
- {name: "context", mayBeNull: true}
- ]);
- if (e) throw e;
- return function() {
- var l = arguments.length;
- if (l > 0) {
- var args = [];
- for (var i = 0; i < l; i++) {
- args[i] = arguments[i];
- }
- args[l] = context;
- return method.apply(this, args);
- }
- return method.call(this, context);
- }
- }
- Function.createDelegate = function Function$createDelegate(instance, method) {
- /// <param name="instance" mayBeNull="true"></param>
- /// <param name="method" type="Function"></param>
- /// <returns type="Function"></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance", mayBeNull: true},
- {name: "method", type: Function}
- ]);
- if (e) throw e;
- return function() {
- return method.apply(instance, arguments);
- }
- }
- Function.emptyFunction = Function.emptyMethod = function Function$emptyMethod() {
- if (arguments.length !== 0) throw Error.parameterCount();
- }
- Function._validateParams = function Function$_validateParams(params, expectedParams) {
- var e;
- e = Function._validateParameterCount(params, expectedParams);
- if (e) {
- e.popStackFrame();
- return e;
- }
- for (var i=0; i < params.length; i++) {
- var expectedParam = expectedParams[Math.min(i, expectedParams.length - 1)];
- var paramName = expectedParam.name;
- if (expectedParam.parameterArray) {
- paramName += "[" + (i - expectedParams.length + 1) + "]";
- }
- e = Function._validateParameter(params[i], expectedParam, paramName);
- if (e) {
- e.popStackFrame();
- return e;
- }
- }
- return null;
- }
- Function._validateParameterCount = function Function$_validateParameterCount(params, expectedParams) {
- var maxParams = expectedParams.length;
- var minParams = 0;
- for (var i=0; i < expectedParams.length; i++) {
- if (expectedParams[i].parameterArray) {
- maxParams = Number.MAX_VALUE;
- }
- else if (!expectedParams[i].optional) {
- minParams++;
- }
- }
- if (params.length < minParams || params.length > maxParams) {
- var e = Error.parameterCount();
- e.popStackFrame();
- return e;
- }
- return null;
- }
- Function._validateParameter = function Function$_validateParameter(param, expectedParam, paramName) {
- var e;
- var expectedType = expectedParam.type;
- var expectedInteger = !!expectedParam.integer;
- var expectedDomElement = !!expectedParam.domElement;
- var mayBeNull = !!expectedParam.mayBeNull;
- e = Function._validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName);
- if (e) {
- e.popStackFrame();
- return e;
- }
- var expectedElementType = expectedParam.elementType;
- var elementMayBeNull = !!expectedParam.elementMayBeNull;
- if (expectedType === Array && typeof(param) !== "undefined" && param !== null &&
- (expectedElementType || !elementMayBeNull)) {
- var expectedElementInteger = !!expectedParam.elementInteger;
- var expectedElementDomElement = !!expectedParam.elementDomElement;
- for (var i=0; i < param.length; i++) {
- var elem = param[i];
- e = Function._validateParameterType(elem, expectedElementType,
- expectedElementInteger, expectedElementDomElement, elementMayBeNull,
- paramName + "[" + i + "]");
- if (e) {
- e.popStackFrame();
- return e;
- }
- }
- }
- return null;
- }
- Function._validateParameterType = function Function$_validateParameterType(param, expectedType, expectedInteger, expectedDomElement, mayBeNull, paramName) {
- var e;
- if (typeof(param) === "undefined") {
- if (mayBeNull) {
- return null;
- }
- else {
- e = Error.argumentUndefined(paramName);
- e.popStackFrame();
- return e;
- }
- }
- if (param === null) {
- if (mayBeNull) {
- return null;
- }
- else {
- e = Error.argumentNull(paramName);
- e.popStackFrame();
- return e;
- }
- }
- if (expectedType && expectedType.__enum) {
- if (typeof(param) !== 'number') {
- e = Error.argumentType(paramName, Object.getType(param), expectedType);
- e.popStackFrame();
- return e;
- }
- if ((param % 1) === 0) {
- var values = expectedType.prototype;
- if (!expectedType.__flags || (param === 0)) {
- for (var i in values) {
- if (values[i] === param) return null;
- }
- }
- else {
- var v = param;
- for (var i in values) {
- var vali = values[i];
- if (vali === 0) continue;
- if ((vali & param) === vali) {
- v -= vali;
- }
- if (v === 0) return null;
- }
- }
- }
- e = Error.argumentOutOfRange(paramName, param, String.format(Sys.Res.enumInvalidValue, param, expectedType.getName()));
- e.popStackFrame();
- return e;
- }
- if (expectedDomElement && (param !== window) && (param !== document) &&
- !(window.HTMLElement && (param instanceof HTMLElement)) &&
- (typeof(param.nodeName) !== 'string')) {
- e = Error.argument(paramName, Sys.Res.argumentDomElement);
- e.popStackFrame();
- return e;
- }
- if (expectedType && !expectedType.isInstanceOfType(param)) {
- e = Error.argumentType(paramName, Object.getType(param), expectedType);
- e.popStackFrame();
- return e;
- }
- if (expectedType === Number && expectedInteger) {
- if ((param % 1) !== 0) {
- e = Error.argumentOutOfRange(paramName, param, Sys.Res.argumentInteger);
- e.popStackFrame();
- return e;
- }
- }
- return null;
- }
- Error.__typeName = 'Error';
- Error.__class = true;
- Error.create = function Error$create(message, errorInfo) {
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <param name="errorInfo" optional="true" mayBeNull="true"></param>
- /// <returns type="Error"></returns>
- var e = Function._validateParams(arguments, [
- {name: "message", type: String, mayBeNull: true, optional: true},
- {name: "errorInfo", mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var e = new Error(message);
- e.message = message;
- if (errorInfo) {
- for (var v in errorInfo) {
- e[v] = errorInfo[v];
- }
- }
- e.popStackFrame();
- return e;
- }
- Error.argument = function Error$argument(paramName, message) {
- /// <param name="paramName" type="String" optional="true" mayBeNull="true"></param>
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "paramName", type: String, mayBeNull: true, optional: true},
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.ArgumentException: " + (message ? message : Sys.Res.argument);
- if (paramName) {
- displayMessage += "n" + String.format(Sys.Res.paramName, paramName);
- }
- var e = Error.create(displayMessage, { name: "Sys.ArgumentException", paramName: paramName });
- e.popStackFrame();
- return e;
- }
- Error.argumentNull = function Error$argumentNull(paramName, message) {
- /// <param name="paramName" type="String" optional="true" mayBeNull="true"></param>
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "paramName", type: String, mayBeNull: true, optional: true},
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.ArgumentNullException: " + (message ? message : Sys.Res.argumentNull);
- if (paramName) {
- displayMessage += "n" + String.format(Sys.Res.paramName, paramName);
- }
- var e = Error.create(displayMessage, { name: "Sys.ArgumentNullException", paramName: paramName });
- e.popStackFrame();
- return e;
- }
- Error.argumentOutOfRange = function Error$argumentOutOfRange(paramName, actualValue, message) {
- /// <param name="paramName" type="String" optional="true" mayBeNull="true"></param>
- /// <param name="actualValue" optional="true" mayBeNull="true"></param>
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "paramName", type: String, mayBeNull: true, optional: true},
- {name: "actualValue", mayBeNull: true, optional: true},
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.ArgumentOutOfRangeException: " + (message ? message : Sys.Res.argumentOutOfRange);
- if (paramName) {
- displayMessage += "n" + String.format(Sys.Res.paramName, paramName);
- }
- if (typeof(actualValue) !== "undefined" && actualValue !== null) {
- displayMessage += "n" + String.format(Sys.Res.actualValue, actualValue);
- }
- var e = Error.create(displayMessage, {
- name: "Sys.ArgumentOutOfRangeException",
- paramName: paramName,
- actualValue: actualValue
- });
- e.popStackFrame();
- return e;
- }
- Error.argumentType = function Error$argumentType(paramName, actualType, expectedType, message) {
- /// <param name="paramName" type="String" optional="true" mayBeNull="true"></param>
- /// <param name="actualType" type="Type" optional="true" mayBeNull="true"></param>
- /// <param name="expectedType" type="Type" optional="true" mayBeNull="true"></param>
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "paramName", type: String, mayBeNull: true, optional: true},
- {name: "actualType", type: Type, mayBeNull: true, optional: true},
- {name: "expectedType", type: Type, mayBeNull: true, optional: true},
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.ArgumentTypeException: ";
- if (message) {
- displayMessage += message;
- }
- else if (actualType && expectedType) {
- displayMessage +=
- String.format(Sys.Res.argumentTypeWithTypes, actualType.getName(), expectedType.getName());
- }
- else {
- displayMessage += Sys.Res.argumentType;
- }
- if (paramName) {
- displayMessage += "n" + String.format(Sys.Res.paramName, paramName);
- }
- var e = Error.create(displayMessage, {
- name: "Sys.ArgumentTypeException",
- paramName: paramName,
- actualType: actualType,
- expectedType: expectedType
- });
- e.popStackFrame();
- return e;
- }
- Error.argumentUndefined = function Error$argumentUndefined(paramName, message) {
- /// <param name="paramName" type="String" optional="true" mayBeNull="true"></param>
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "paramName", type: String, mayBeNull: true, optional: true},
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.ArgumentUndefinedException: " + (message ? message : Sys.Res.argumentUndefined);
- if (paramName) {
- displayMessage += "n" + String.format(Sys.Res.paramName, paramName);
- }
- var e = Error.create(displayMessage, { name: "Sys.ArgumentUndefinedException", paramName: paramName });
- e.popStackFrame();
- return e;
- }
- Error.format = function Error$format(message) {
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.FormatException: " + (message ? message : Sys.Res.format);
- var e = Error.create(displayMessage, {name: 'Sys.FormatException'});
- e.popStackFrame();
- return e;
- }
- Error.invalidOperation = function Error$invalidOperation(message) {
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.InvalidOperationException: " + (message ? message : Sys.Res.invalidOperation);
- var e = Error.create(displayMessage, {name: 'Sys.InvalidOperationException'});
- e.popStackFrame();
- return e;
- }
- Error.notImplemented = function Error$notImplemented(message) {
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.NotImplementedException: " + (message ? message : Sys.Res.notImplemented);
- var e = Error.create(displayMessage, {name: 'Sys.NotImplementedException'});
- e.popStackFrame();
- return e;
- }
- Error.parameterCount = function Error$parameterCount(message) {
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "message", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var displayMessage = "Sys.ParameterCountException: " + (message ? message : Sys.Res.parameterCount);
- var e = Error.create(displayMessage, {name: 'Sys.ParameterCountException'});
- e.popStackFrame();
- return e;
- }
- Error.prototype.popStackFrame = function Error$popStackFrame() {
- if (arguments.length !== 0) throw Error.parameterCount();
- if (typeof(this.stack) === "undefined" || this.stack === null ||
- typeof(this.fileName) === "undefined" || this.fileName === null ||
- typeof(this.lineNumber) === "undefined" || this.lineNumber === null) {
- return;
- }
- var stackFrames = this.stack.split("n");
- var currentFrame = stackFrames[0];
- var pattern = this.fileName + ":" + this.lineNumber;
- while(typeof(currentFrame) !== "undefined" &&
- currentFrame !== null &&
- currentFrame.indexOf(pattern) === -1) {
- stackFrames.shift();
- currentFrame = stackFrames[0];
- }
- var nextFrame = stackFrames[1];
- if (typeof(nextFrame) === "undefined" || nextFrame === null) {
- return;
- }
- var nextFrameParts = nextFrame.match(/@(.*):(d+)$/);
- if (typeof(nextFrameParts) === "undefined" || nextFrameParts === null) {
- return;
- }
- this.fileName = nextFrameParts[1];
- this.lineNumber = parseInt(nextFrameParts[2]);
- stackFrames.shift();
- this.stack = stackFrames.join("n");
- }
- if (!window) this.window = this;
- window.Type = Function;
- window.__rootNamespaces = [];
- window.__registeredTypes = {};
- Type.__fullyQualifiedIdentifierRegExp = new RegExp("^[^.0-9 \s|,;:&*=+\-()\[\]{}^%#@!~\n\r\t\f\\]([^ \s|,;:&*=+\-()\[\]{}^%#@!~\n\r\t\f\\]*[^. \s|,;:&*=+\-()\[\]{}^%#@!~\n\r\t\f\\])?$", "i");
- Type.__identifierRegExp = new RegExp("^[^.0-9 \s|,;:&*=+\-()\[\]{}^%#@!~\n\r\t\f\\][^. \s|,;:&*=+\-()\[\]{}^%#@!~\n\r\t\f\\]*$", "i");
- Type.prototype.callBaseMethod = function Type$callBaseMethod(instance, name, baseArguments) {
- /// <param name="instance"></param>
- /// <param name="name" type="String"></param>
- /// <param name="baseArguments" type="Array" optional="true" mayBeNull="true" elementMayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance"},
- {name: "name", type: String},
- {name: "baseArguments", type: Array, mayBeNull: true, optional: true, elementMayBeNull: true}
- ]);
- if (e) throw e;
- var baseMethod = this.getBaseMethod(instance, name);
- if (!baseMethod) throw Error.invalidOperation(String.format(Sys.Res.methodNotFound, name));
- if (!baseArguments) {
- return baseMethod.apply(instance);
- }
- else {
- return baseMethod.apply(instance, baseArguments);
- }
- }
- Type.prototype.getBaseMethod = function Type$getBaseMethod(instance, name) {
- /// <param name="instance"></param>
- /// <param name="name" type="String"></param>
- /// <returns type="Function" mayBeNull="true"></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance"},
- {name: "name", type: String}
- ]);
- if (e) throw e;
- if (!this.isInstanceOfType(instance)) throw Error.argumentType('instance', Object.getType(instance), this);
- var baseType = this.getBaseType();
- if (baseType) {
- var baseMethod = baseType.prototype[name];
- return (baseMethod instanceof Function) ? baseMethod : null;
- }
- return null;
- }
- Type.prototype.getBaseType = function Type$getBaseType() {
- /// <returns type="Type" mayBeNull="true"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- return (typeof(this.__baseType) === "undefined") ? null : this.__baseType;
- }
- Type.prototype.getInterfaces = function Type$getInterfaces() {
- /// <returns type="Array" elementType="Type" mayBeNull="false" elementMayBeNull="false"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- var result = [];
- var type = this;
- while(type) {
- var interfaces = type.__interfaces;
- if (interfaces) {
- for (var i = 0, l = interfaces.length; i < l; i++) {
- var interfaceType = interfaces[i];
- if (!Array.contains(result, interfaceType)) {
- result[result.length] = interfaceType;
- }
- }
- }
- type = type.__baseType;
- }
- return result;
- }
- Type.prototype.getName = function Type$getName() {
- /// <returns type="String"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- return (typeof(this.__typeName) === "undefined") ? "" : this.__typeName;
- }
- Type.prototype.implementsInterface = function Type$implementsInterface(interfaceType) {
- /// <param name="interfaceType" type="Type"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "interfaceType", type: Type}
- ]);
- if (e) throw e;
- this.resolveInheritance();
- var interfaceName = interfaceType.getName();
- var cache = this.__interfaceCache;
- if (cache) {
- var cacheEntry = cache[interfaceName];
- if (typeof(cacheEntry) !== 'undefined') return cacheEntry;
- }
- else {
- cache = this.__interfaceCache = {};
- }
- var baseType = this;
- while (baseType) {
- var interfaces = baseType.__interfaces;
- if (interfaces) {
- if (Array.indexOf(interfaces, interfaceType) !== -1) {
- return cache[interfaceName] = true;
- }
- }
- baseType = baseType.__baseType;
- }
- return cache[interfaceName] = false;
- }
- Type.prototype.inheritsFrom = function Type$inheritsFrom(parentType) {
- /// <param name="parentType" type="Type"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "parentType", type: Type}
- ]);
- if (e) throw e;
- this.resolveInheritance();
- var baseType = this.__baseType;
- while (baseType) {
- if (baseType === parentType) {
- return true;
- }
- baseType = baseType.__baseType;
- }
- return false;
- }
- Type.prototype.initializeBase = function Type$initializeBase(instance, baseArguments) {
- /// <param name="instance"></param>
- /// <param name="baseArguments" type="Array" optional="true" mayBeNull="true" elementMayBeNull="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance"},
- {name: "baseArguments", type: Array, mayBeNull: true, optional: true, elementMayBeNull: true}
- ]);
- if (e) throw e;
- if (!this.isInstanceOfType(instance)) throw Error.argumentType('instance', Object.getType(instance), this);
- this.resolveInheritance();
- if (this.__baseType) {
- if (!baseArguments) {
- this.__baseType.apply(instance);
- }
- else {
- this.__baseType.apply(instance, baseArguments);
- }
- }
- return instance;
- }
- Type.prototype.isImplementedBy = function Type$isImplementedBy(instance) {
- /// <param name="instance" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance", mayBeNull: true}
- ]);
- if (e) throw e;
- if (typeof(instance) === "undefined" || instance === null) return false;
- var instanceType = Object.getType(instance);
- return !!(instanceType.implementsInterface && instanceType.implementsInterface(this));
- }
- Type.prototype.isInstanceOfType = function Type$isInstanceOfType(instance) {
- /// <param name="instance" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance", mayBeNull: true}
- ]);
- if (e) throw e;
- if (typeof(instance) === "undefined" || instance === null) return false;
- if (instance instanceof this) return true;
- var instanceType = Object.getType(instance);
- return !!(instanceType === this) ||
- (instanceType.inheritsFrom && instanceType.inheritsFrom(this)) ||
- (instanceType.implementsInterface && instanceType.implementsInterface(this));
- }
- Type.prototype.registerClass = function Type$registerClass(typeName, baseType, interfaceTypes) {
- /// <param name="typeName" type="String"></param>
- /// <param name="baseType" type="Type" optional="true" mayBeNull="true"></param>
- /// <param name="interfaceTypes" parameterArray="true" type="Type"></param>
- /// <returns type="Type"></returns>
- var e = Function._validateParams(arguments, [
- {name: "typeName", type: String},
- {name: "baseType", type: Type, mayBeNull: true, optional: true},
- {name: "interfaceTypes", type: Type, parameterArray: true}
- ]);
- if (e) throw e;
- if (!Type.__fullyQualifiedIdentifierRegExp.test(typeName)) throw Error.argument('typeName', Sys.Res.notATypeName);
- var parsedName;
- try {
- parsedName = eval(typeName);
- }
- catch(e) {
- throw Error.argument('typeName', Sys.Res.argumentTypeName);
- }
- if (parsedName !== this) throw Error.argument('typeName', Sys.Res.badTypeName);
- if (window.__registeredTypes[typeName]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, typeName));
- if ((arguments.length > 1) && (typeof(baseType) === 'undefined')) throw Error.argumentUndefined('baseType');
- if (baseType && !baseType.__class) throw Error.argument('baseType', Sys.Res.baseNotAClass);
- this.prototype.constructor = this;
- this.__typeName = typeName;
- this.__class = true;
- if (baseType) {
- this.__baseType = baseType;
- this.__basePrototypePending = true;
- }
- if (!window.__classes) window.__classes = {};
- window.__classes[typeName.toUpperCase()] = this;
- if (interfaceTypes) {
- this.__interfaces = [];
- for (var i = 2; i < arguments.length; i++) {
- var interfaceType = arguments[i];
- if (!interfaceType.__interface) throw Error.argument('interfaceTypes[' + (i - 2) + ']', Sys.Res.notAnInterface);
- this.resolveInheritance();
- for (var methodName in interfaceType.prototype) {
- var method = interfaceType.prototype[methodName];
- if (!this.prototype[methodName]) {
- this.prototype[methodName] = method;
- }
- }
- this.__interfaces.push(interfaceType);
- }
- }
- window.__registeredTypes[typeName] = true;
- return this;
- }
- Type.prototype.registerInterface = function Type$registerInterface(typeName) {
- /// <param name="typeName" type="String"></param>
- /// <returns type="Type"></returns>
- var e = Function._validateParams(arguments, [
- {name: "typeName", type: String}
- ]);
- if (e) throw e;
- if (!Type.__fullyQualifiedIdentifierRegExp.test(typeName)) throw Error.argument('typeName', Sys.Res.notATypeName);
- var parsedName;
- try {
- parsedName = eval(typeName);
- }
- catch(e) {
- throw Error.argument('typeName', Sys.Res.argumentTypeName);
- }
- if (parsedName !== this) throw Error.argument('typeName', Sys.Res.badTypeName);
- if (window.__registeredTypes[typeName]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, typeName));
- this.prototype.constructor = this;
- this.__typeName = typeName;
- this.__interface = true;
- window.__registeredTypes[typeName] = true;
- return this;
- }
- Type.prototype.resolveInheritance = function Type$resolveInheritance() {
- if (arguments.length !== 0) throw Error.parameterCount();
- if (this.__basePrototypePending) {
- var baseType = this.__baseType;
- baseType.resolveInheritance();
- for (var memberName in baseType.prototype) {
- var memberValue = baseType.prototype[memberName];
- if (!this.prototype[memberName]) {
- this.prototype[memberName] = memberValue;
- }
- }
- delete this.__basePrototypePending;
- }
- }
- Type.getRootNamespaces = function Type$getRootNamespaces() {
- /// <returns type="Array"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- return Array.clone(window.__rootNamespaces);
- }
- Type.isClass = function Type$isClass(type) {
- /// <param name="type" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "type", mayBeNull: true}
- ]);
- if (e) throw e;
- if ((typeof(type) === 'undefined') || (type === null)) return false;
- return !!type.__class;
- }
- Type.isInterface = function Type$isInterface(type) {
- /// <param name="type" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "type", mayBeNull: true}
- ]);
- if (e) throw e;
- if ((typeof(type) === 'undefined') || (type === null)) return false;
- return !!type.__interface;
- }
- Type.isNamespace = function Type$isNamespace(object) {
- /// <param name="object" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "object", mayBeNull: true}
- ]);
- if (e) throw e;
- if ((typeof(object) === 'undefined') || (object === null)) return false;
- return !!object.__namespace;
- }
- Type.parse = function Type$parse(typeName, ns) {
- /// <param name="typeName" type="String" mayBeNull="true"></param>
- /// <param name="ns" optional="true" mayBeNull="true"></param>
- /// <returns type="Type" mayBeNull="true"></returns>
- var e = Function._validateParams(arguments, [
- {name: "typeName", type: String, mayBeNull: true},
- {name: "ns", mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var fn;
- if (ns) {
- if (!window.__classes) return null;
- fn = window.__classes[ns.getName().toUpperCase() + '.' + typeName.toUpperCase()];
- return fn || null;
- }
- if (!typeName) return null;
- if (!Type.__htClasses) {
- Type.__htClasses = {};
- }
- fn = Type.__htClasses[typeName];
- if (!fn) {
- fn = eval(typeName);
- if (typeof(fn) !== 'function') throw Error.argument('typeName', Sys.Res.notATypeName);
- Type.__htClasses[typeName] = fn;
- }
- return fn;
- }
- Type.registerNamespace = function Type$registerNamespace(namespacePath) {
- /// <param name="namespacePath" type="String"></param>
- var e = Function._validateParams(arguments, [
- {name: "namespacePath", type: String}
- ]);
- if (e) throw e;
- if (!Type.__fullyQualifiedIdentifierRegExp.test(namespacePath)) throw Error.argument('namespacePath', Sys.Res.invalidNameSpace);
- var rootObject = window;
- var namespaceParts = namespacePath.split('.');
- for (var i = 0; i < namespaceParts.length; i++) {
- var currentPart = namespaceParts[i];
- var ns = rootObject[currentPart];
- if (ns && !ns.__namespace) {
- throw Error.invalidOperation(String.format(Sys.Res.namespaceContainsObject, namespaceParts.splice(0, i + 1).join('.')));
- }
- if (!ns) {
- ns = rootObject[currentPart] = {};
- if (i === 0) {
- window.__rootNamespaces[window.__rootNamespaces.length] = ns;
- }
- ns.__namespace = true;
- ns.__typeName = namespaceParts.slice(0, i + 1).join('.');
- var parsedName;
- try {
- parsedName = eval(ns.__typeName);
- }
- catch(e) {
- parsedName = null;
- }
- if (parsedName !== ns) {
- delete rootObject[currentPart];
- throw Error.argument('namespacePath', Sys.Res.invalidNameSpace);
- }
- ns.getName = function ns$getName() {return this.__typeName;}
- }
- rootObject = ns;
- }
- }
- Object.__typeName = 'Object';
- Object.__class = true;
- Object.getType = function Object$getType(instance) {
- /// <param name="instance"></param>
- /// <returns type="Type"></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance"}
- ]);
- if (e) throw e;
- var ctor = instance.constructor;
- if (!ctor || (typeof(ctor) !== "function") || !ctor.__typeName || (ctor.__typeName === 'Object')) {
- return Object;
- }
- return ctor;
- }
- Object.getTypeName = function Object$getTypeName(instance) {
- /// <param name="instance"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "instance"}
- ]);
- if (e) throw e;
- return Object.getType(instance).getName();
- }
- Boolean.__typeName = 'Boolean';
- Boolean.__class = true;
- Boolean.parse = function Boolean$parse(value) {
- /// <param name="value" type="String"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", type: String}
- ]);
- if (e) throw e;
- var v = value.trim().toLowerCase();
- if (v === 'false') return false;
- if (v === 'true') return true;
- throw Error.argumentOutOfRange('value', value, Sys.Res.boolTrueOrFalse);
- }
- Date.__typeName = 'Date';
- Date.__class = true;
- Date._appendPreOrPostMatch = function Date$_appendPreOrPostMatch(preMatch, strBuilder) {
- var quoteCount = 0;
- var escaped = false;
- for (var i = 0, il = preMatch.length; i < il; i++) {
- var c = preMatch.charAt(i);
- switch (c) {
- case ''':
- if (escaped) strBuilder.append("'");
- else quoteCount++;
- escaped = false;
- break;
- case '\':
- if (escaped) strBuilder.append("\");
- escaped = !escaped;
- break;
- default:
- strBuilder.append(c);
- escaped = false;
- break;
- }
- }
- return quoteCount;
- }
- Date._expandFormat = function Date$_expandFormat(dtf, format) {
- if (!format) {
- format = "F";
- }
- if (format.length === 1) {
- switch (format) {
- case "d":
- return dtf.ShortDatePattern;
- case "D":
- return dtf.LongDatePattern;
- case "t":
- return dtf.ShortTimePattern;
- case "T":
- return dtf.LongTimePattern;
- case "F":
- return dtf.FullDateTimePattern;
- case "M": case "m":
- return dtf.MonthDayPattern;
- case "s":
- return dtf.SortableDateTimePattern;
- case "Y": case "y":
- return dtf.YearMonthPattern;
- default:
- throw Error.format(Sys.Res.formatInvalidString);
- }
- }
- return format;
- }
- Date._expandYear = function Date$_expandYear(dtf, year) {
- if (year < 100) {
- var curr = new Date().getFullYear();
- year += curr - (curr % 100);
- if (year > dtf.Calendar.TwoDigitYearMax) {
- return year - 100;
- }
- }
- return year;
- }
- Date._getParseRegExp = function Date$_getParseRegExp(dtf, format) {
- if (!dtf._parseRegExp) {
- dtf._parseRegExp = {};
- }
- else if (dtf._parseRegExp[format]) {
- return dtf._parseRegExp[format];
- }
- var expFormat = Date._expandFormat(dtf, format);
- expFormat = expFormat.replace(/([^$.*+?|[](){}])/g, "\\$1");
- var regexp = new Sys.StringBuilder("^");
- var groups = [];
- var index = 0;
- var quoteCount = 0;
- var tokenRegExp = Date._getTokenRegExp();
- var match;
- while ((match = tokenRegExp.exec(expFormat)) !== null) {
- var preMatch = expFormat.slice(index, match.index);
- index = tokenRegExp.lastIndex;
- quoteCount += Date._appendPreOrPostMatch(preMatch, regexp);
- if ((quoteCount%2) === 1) {
- regexp.append(match[0]);
- continue;
- }
- switch (match[0]) {
- case 'dddd': case 'ddd':
- case 'MMMM': case 'MMM':
- regexp.append("(\D+)");
- break;
- case 'tt': case 't':
- regexp.append("(\D*)");
- break;
- case 'yyyy':
- regexp.append("(\d{4})");
- break;
- case 'fff':
- regexp.append("(\d{3})");
- break;
- case 'ff':
- regexp.append("(\d{2})");
- break;
- case 'f':
- regexp.append("(\d)");
- break;
- case 'dd': case 'd':
- case 'MM': case 'M':
- case 'yy': case 'y':
- case 'HH': case 'H':
- case 'hh': case 'h':
- case 'mm': case 'm':
- case 'ss': case 's':
- regexp.append("(\d\d?)");
- break;
- case 'zzz':
- regexp.append("([+-]?\d\d?:\d{2})");
- break;
- case 'zz': case 'z':
- regexp.append("([+-]?\d\d?)");
- break;
- }
- Array.add(groups, match[0]);
- }
- Date._appendPreOrPostMatch(expFormat.slice(index), regexp);
- regexp.append("$");
- var regexpStr = regexp.toString().replace(/s+/g, "\s+");
- var parseRegExp = {'regExp': regexpStr, 'groups': groups};
- dtf._parseRegExp[format] = parseRegExp;
- return parseRegExp;
- }
- Date._getTokenRegExp = function Date$_getTokenRegExp() {
- return /dddd|ddd|dd|d|MMMM|MMM|MM|M|yyyy|yy|y|hh|h|HH|H|mm|m|ss|s|tt|t|fff|ff|f|zzz|zz|z/g;
- }
- Date.parseLocale = function Date$parseLocale(value, formats) {
- /// <param name="value" type="String"></param>
- /// <param name="formats" parameterArray="true" optional="true" mayBeNull="true"></param>
- /// <returns type="Date"></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", type: String},
- {name: "formats", mayBeNull: true, optional: true, parameterArray: true}
- ]);
- if (e) throw e;
- return Date._parse(value, Sys.CultureInfo.CurrentCulture, arguments);
- }
- Date.parseInvariant = function Date$parseInvariant(value, formats) {
- /// <param name="value" type="String"></param>
- /// <param name="formats" parameterArray="true" optional="true" mayBeNull="true"></param>
- /// <returns type="Date"></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", type: String},
- {name: "formats", mayBeNull: true, optional: true, parameterArray: true}
- ]);
- if (e) throw e;
- return Date._parse(value, Sys.CultureInfo.InvariantCulture, arguments);
- }
- Date._parse = function Date$_parse(value, cultureInfo, args) {
- var custom = false;
- for (var i = 1, il = args.length; i < il; i++) {
- var format = args[i];
- if (format) {
- custom = true;
- var date = Date._parseExact(value, format, cultureInfo);
- if (date) return date;
- }
- }
- if (! custom) {
- var formats = cultureInfo._getDateTimeFormats();
- for (var i = 0, il = formats.length; i < il; i++) {
- var date = Date._parseExact(value, formats[i], cultureInfo);
- if (date) return date;
- }
- }
- return null;
- }
- Date._parseExact = function Date$_parseExact(value, format, cultureInfo) {
- value = value.trim();
- var dtf = cultureInfo.dateTimeFormat;
- var parseInfo = Date._getParseRegExp(dtf, format);
- var match = new RegExp(parseInfo.regExp).exec(value);
- if (match !== null) {
- var groups = parseInfo.groups;
- var year = null, month = null, date = null, weekDay = null;
- var hour = 0, min = 0, sec = 0, msec = 0, tzMinOffset = null;
- var pmHour = false;
- for (var j = 0, jl = groups.length; j < jl; j++) {
- var matchGroup = match[j+1];
- if (matchGroup) {
- switch (groups[j]) {
- case 'dd': case 'd':
- date = Date._parseInt(matchGroup);
- if ((date < 1) || (date > 31)) return null;
- break;
- case 'MMMM':
- month = cultureInfo._getMonthIndex(matchGroup);
- if ((month < 0) || (month > 11)) return null;
- break;
- case 'MMM':
- month = cultureInfo._getAbbrMonthIndex(matchGroup);
- if ((month < 0) || (month > 11)) return null;
- break;
- case 'M': case 'MM':
- var month = Date._parseInt(matchGroup) - 1;
- if ((month < 0) || (month > 11)) return null;
- break;
- case 'y': case 'yy':
- year = Date._expandYear(dtf,Date._parseInt(matchGroup));
- if ((year < 0) || (year > 9999)) return null;
- break;
- case 'yyyy':
- year = Date._parseInt(matchGroup);
- if ((year < 0) || (year > 9999)) return null;
- break;
- case 'h': case 'hh':
- hour = Date._parseInt(matchGroup);
- if (hour === 12) hour = 0;
- if ((hour < 0) || (hour > 11)) return null;
- break;
- case 'H': case 'HH':
- hour = Date._parseInt(matchGroup);
- if ((hour < 0) || (hour > 23)) return null;
- break;
- case 'm': case 'mm':
- min = Date._parseInt(matchGroup);
- if ((min < 0) || (min > 59)) return null;
- break;
- case 's': case 'ss':
- sec = Date._parseInt(matchGroup);
- if ((sec < 0) || (sec > 59)) return null;
- break;
- case 'tt': case 't':
- var upperToken = matchGroup.toUpperCase();
- pmHour = (upperToken === dtf.PMDesignator.toUpperCase());
- if (!pmHour && (upperToken !== dtf.AMDesignator.toUpperCase())) return null;
- break;
- case 'f':
- msec = Date._parseInt(matchGroup) * 100;
- if ((msec < 0) || (msec > 999)) return null;
- break;
- case 'ff':
- msec = Date._parseInt(matchGroup) * 10;
- if ((msec < 0) || (msec > 999)) return null;
- break;
- case 'fff':
- msec = Date._parseInt(matchGroup);
- if ((msec < 0) || (msec > 999)) return null;
- break;
- case 'dddd':
- weekDay = cultureInfo._getDayIndex(matchGroup);
- if ((weekDay < 0) || (weekDay > 6)) return null;
- break;
- case 'ddd':
- weekDay = cultureInfo._getAbbrDayIndex(matchGroup);
- if ((weekDay < 0) || (weekDay > 6)) return null;
- break;
- case 'zzz':
- var offsets = matchGroup.split(/:/);
- if (offsets.length !== 2) return null;
- var hourOffset = Date._parseInt(offsets[0]);
- if ((hourOffset < -12) || (hourOffset > 13)) return null;
- var minOffset = Date._parseInt(offsets[1]);
- if ((minOffset < 0) || (minOffset > 59)) return null;
- tzMinOffset = (hourOffset * 60) + (matchGroup.startsWith('-')? -minOffset : minOffset);
- break;
- case 'z': case 'zz':
- var hourOffset = Date._parseInt(matchGroup);
- if ((hourOffset < -12) || (hourOffset > 13)) return null;
- tzMinOffset = hourOffset * 60;
- break;
- }
- }
- }
- var result = new Date();
- if (year === null) {
- year = result.getFullYear();
- }
- if (month === null) {
- month = result.getMonth();
- }
- if (date === null) {
- date = result.getDate();
- }
- result.setFullYear(year, month, date);
- if (result.getDate() !== date) return null;
- if ((weekDay !== null) && (result.getDay() !== weekDay)) {
- return null;
- }
- if (pmHour && (hour < 12)) {
- hour += 12;
- }
- result.setHours(hour, min, sec, msec);
- if (tzMinOffset !== null) {
- var adjustedMin = result.getMinutes() - (tzMinOffset + result.getTimezoneOffset());
- result.setHours(result.getHours() + parseInt(adjustedMin/60), adjustedMin%60);
- }
- return result;
- }
- }
- Date._parseInt = function Date$_parseInt(value) {
- return parseInt(value.replace(/^[s0]+(d+)$/,"$1"));
- }
- Date.prototype.format = function Date$format(format) {
- /// <param name="format" type="String"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "format", type: String}
- ]);
- if (e) throw e;
- return this._toFormattedString(format, Sys.CultureInfo.InvariantCulture);
- }
- Date.prototype.localeFormat = function Date$localeFormat(format) {
- /// <param name="format" type="String"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "format", type: String}
- ]);
- if (e) throw e;
- return this._toFormattedString(format, Sys.CultureInfo.CurrentCulture);
- }
- Date.prototype._toFormattedString = function Date$_toFormattedString(format, cultureInfo) {
- if (!format || (format.length === 0) || (format === 'i')) {
- if (cultureInfo && (cultureInfo.name.length > 0)) {
- return this.toLocaleString();
- }
- else {
- return this.toString();
- }
- }
- var dtf = cultureInfo.dateTimeFormat;
- format = Date._expandFormat(dtf, format);
- var ret = new Sys.StringBuilder();
- var hour;
- function addLeadingZero(num) {
- if (num < 10) {
- return '0' + num;
- }
- return num.toString();
- }
- function addLeadingZeros(num) {
- if (num < 10) {
- return '00' + num;
- }
- if (num < 100) {
- return '0' + num;
- }
- return num.toString();
- }
- var quoteCount = 0;
- var tokenRegExp = Date._getTokenRegExp();
- for (;;) {
- var index = tokenRegExp.lastIndex;
- var ar = tokenRegExp.exec(format);
- var preMatch = format.slice(index, ar ? ar.index : format.length);
- quoteCount += Date._appendPreOrPostMatch(preMatch, ret);
- if (!ar) break;
- if ((quoteCount%2) === 1) {
- ret.append(ar[0]);
- continue;
- }
- switch (ar[0]) {
- case "dddd":
- ret.append(dtf.DayNames[this.getDay()]);
- break;
- case "ddd":
- ret.append(dtf.AbbreviatedDayNames[this.getDay()]);
- break;
- case "dd":
- ret.append(addLeadingZero(this.getDate()));
- break;
- case "d":
- ret.append(this.getDate());
- break;
- case "MMMM":
- ret.append(dtf.MonthNames[this.getMonth()]);
- break;
- case "MMM":
- ret.append(dtf.AbbreviatedMonthNames[this.getMonth()]);
- break;
- case "MM":
- ret.append(addLeadingZero(this.getMonth() + 1));
- break;
- case "M":
- ret.append(this.getMonth() + 1);
- break;
- case "yyyy":
- ret.append(this.getFullYear());
- break;
- case "yy":
- ret.append(addLeadingZero(this.getFullYear() % 100));
- break;
- case "y":
- ret.append(this.getFullYear() % 100);
- break;
- case "hh":
- hour = this.getHours() % 12;
- if (hour === 0) hour = 12;
- ret.append(addLeadingZero(hour));
- break;
- case "h":
- hour = this.getHours() % 12;
- if (hour === 0) hour = 12;
- ret.append(hour);
- break;
- case "HH":
- ret.append(addLeadingZero(this.getHours()));
- break;
- case "H":
- ret.append(this.getHours());
- break;
- case "mm":
- ret.append(addLeadingZero(this.getMinutes()));
- break;
- case "m":
- ret.append(this.getMinutes());
- break;
- case "ss":
- ret.append(addLeadingZero(this.getSeconds()));
- break;
- case "s":
- ret.append(this.getSeconds());
- break;
- case "tt":
- ret.append((this.getHours() < 12) ? dtf.AMDesignator : dtf.PMDesignator);
- break;
- case "t":
- ret.append(((this.getHours() < 12) ? dtf.AMDesignator : dtf.PMDesignator).charAt(0));
- break;
- case "f":
- ret.append(addLeadingZeros(this.getMilliseconds()).charAt(0));
- break;
- case "ff":
- ret.append(addLeadingZeros(this.getMilliseconds()).substr(0, 2));
- break;
- case "fff":
- ret.append(addLeadingZeros(this.getMilliseconds()));
- break;
- case "z":
- hour = this.getTimezoneOffset() / 60;
- ret.append(((hour >= 0) ? '+' : '-') + Math.floor(Math.abs(hour)));
- break;
- case "zz":
- hour = this.getTimezoneOffset() / 60;
- ret.append(((hour >= 0) ? '+' : '-') + addLeadingZero(Math.floor(Math.abs(hour))));
- break;
- case "zzz":
- hour = this.getTimezoneOffset() / 60;
- ret.append(((hour >= 0) ? '+' : '-') + addLeadingZero(Math.floor(Math.abs(hour))) +
- dtf.TimeSeparator + addLeadingZero(Math.abs(this.getTimezoneOffset() % 60)));
- break;
- }
- }
- return ret.toString();
- }
- Number.__typeName = 'Number';
- Number.__class = true;
- Number.parseLocale = function Number$parseLocale(value) {
- /// <param name="value" type="String"></param>
- /// <returns type="Number"></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", type: String}
- ]);
- if (e) throw e;
- return Number._parse(value, Sys.CultureInfo.CurrentCulture);
- }
- Number.parseInvariant = function Number$parseInvariant(value) {
- /// <param name="value" type="String"></param>
- /// <returns type="Number"></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", type: String}
- ]);
- if (e) throw e;
- return Number._parse(value, Sys.CultureInfo.InvariantCulture);
- }
- Number._parse = function Number$_parse(value, cultureInfo) {
- var valueStr = value.trim();
- if (valueStr.match(/infinity/i) !== null) {
- return parseFloat(valueStr);
- }
- if (valueStr.match(/^0x[a-f0-9]+$/i) !== null) {
- return parseInt(valueStr);
- }
- var numFormat = cultureInfo.numberFormat;
- var decSeparator = numFormat.NumberDecimalSeparator;
- var grpSeparator = numFormat.NumberGroupSeparator;
- var numberFormatRegex = new RegExp("^[+-]?[\d\" + grpSeparator + "]*\" + decSeparator + "?\d*([eE][+-]?\d+)?$");
- if (!valueStr.match(numberFormatRegex)) {
- return Number.NaN;
- }
- valueStr = valueStr.split(grpSeparator).join("");
- valueStr = valueStr.replace(decSeparator, ".");
- return parseFloat(valueStr);
- }
- Number.prototype.format = function Number$format(format) {
- /// <param name="format" type="String"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "format", type: String}
- ]);
- if (e) throw e;
- return this._toFormattedString(format, Sys.CultureInfo.InvariantCulture);
- }
- Number.prototype.localeFormat = function Number$localeFormat(format) {
- /// <param name="format" type="String"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "format", type: String}
- ]);
- if (e) throw e;
- return this._toFormattedString(format, Sys.CultureInfo.CurrentCulture);
- }
- Number.prototype._toFormattedString = function Number$_toFormattedString(format, cultureInfo) {
- if (!format || (format.length === 0) || (format === 'i')) {
- if (cultureInfo && (cultureInfo.name.length > 0)) {
- return this.toLocaleString();
- }
- else {
- return this.toString();
- }
- }
- var _percentPositivePattern = ["n %", "n%", "%n" ];
- var _percentNegativePattern = ["-n %", "-n%", "-%n"];
- var _numberNegativePattern = ["(n)","-n","- n","n-","n -"];
- var _currencyPositivePattern = ["$n","n$","$ n","n $"];
- var _currencyNegativePattern = ["($n)","-$n","$-n","$n-","(n$)","-n$","n-$","n$-","-n $","-$ n","n $-","$ n-","$ -n","n- $","($ n)","(n $)"];
- function expandNumber(number, precision, groupSizes, sep, decimalChar) {
- var curSize = groupSizes[0];
- var curGroupIndex = 1;
- var numberString = number.toString();
- var right = "";
- var exponent = "";
- var decimalSplit = numberString.split('.');
- if (decimalSplit.length > 1) {
- numberString = decimalSplit[0];
- right = decimalSplit[1];
- var exponentSplit = right.split(/e/i);
- if (exponentSplit.length > 1) {
- right = exponentSplit[0];
- exponent = "e" + exponentSplit[1];
- }
- }
- if (precision > 0) {
- var rightDifference = right.length - precision;
- if (rightDifference > 0) {
- right = right.slice(0, precision);
- } else if (rightDifference < 0) {
- for (var i=0; i<Math.abs(rightDifference); i++) {
- right += '0';
- }
- }
- right = decimalChar + right;
- }
- else { right = "";
- }
- right += exponent;
- var stringIndex = numberString.length-1;
- var ret = "";
- while (stringIndex >= 0) {
- if (curSize === 0 || curSize > stringIndex) {
- if (ret.length > 0)
- return numberString.slice(0, stringIndex + 1) + sep + ret + right;
- else
- return numberString.slice(0, stringIndex + 1) + right;
- }
- if (ret.length > 0)
- ret = numberString.slice(stringIndex - curSize + 1, stringIndex+1) + sep + ret;
- else
- ret = numberString.slice(stringIndex - curSize + 1, stringIndex+1);
- stringIndex -= curSize;
- if (curGroupIndex < groupSizes.length) {
- curSize = groupSizes[curGroupIndex];
- curGroupIndex++;
- }
- }
- return numberString.slice(0, stringIndex + 1) + sep + ret + right;
- }
- var nf = cultureInfo.numberFormat;
- var number = Math.abs(this);
- if (!format)
- format = "D";
- var precision = -1;
- if (format.length > 1) precision = parseInt(format.slice(1));
- var pattern;
- switch (format.charAt(0)) {
- case "d":
- case "D":
- pattern = 'n';
- if (precision !== -1) {
- var numberStr = ""+number;
- var zerosToAdd = precision - numberStr.length;
- if (zerosToAdd > 0) {
- for (var i=0; i<zerosToAdd; i++) {
- numberStr = '0'+numberStr;
- }
- }
- number = numberStr;
- }
- if (this < 0) number = -number;
- break;
- case "c":
- case "C":
- if (this < 0) pattern = _currencyNegativePattern[nf.CurrencyNegativePattern];
- else pattern = _currencyPositivePattern[nf.CurrencyPositivePattern];
- if (precision === -1) precision = nf.CurrencyDecimalDigits;
- number = expandNumber(Math.abs(this), precision, nf.CurrencyGroupSizes, nf.CurrencyGroupSeparator, nf.CurrencyDecimalSeparator);
- break;
- case "n":
- case "N":
- if (this < 0) pattern = _numberNegativePattern[nf.NumberNegativePattern];
- else pattern = 'n';
- if (precision === -1) precision = nf.NumberDecimalDigits;
- number = expandNumber(Math.abs(this), precision, nf.NumberGroupSizes, nf.NumberGroupSeparator, nf.NumberDecimalSeparator);
- break;
- case "p":
- case "P":
- if (this < 0) pattern = _percentNegativePattern[nf.PercentNegativePattern];
- else pattern = _percentPositivePattern[nf.PercentPositivePattern];
- if (precision === -1) precision = nf.PercentDecimalDigits;
- number = expandNumber(Math.abs(this), precision, nf.PercentGroupSizes, nf.PercentGroupSeparator, nf.PercentDecimalSeparator);
- break;
- default:
- throw Error.format(Sys.Res.formatBadFormatSpecifier);
- }
- var regex = /n|$|-|%/g;
- var ret = "";
- for (;;) {
- var index = regex.lastIndex;
- var ar = regex.exec(pattern);
- ret += pattern.slice(index, ar ? ar.index : pattern.length);
- if (!ar)
- break;
- switch (ar[0]) {
- case "n":
- ret += number;
- break;
- case "$":
- ret += nf.CurrencySymbol;
- break;
- case "-":
- ret += nf.NegativeSign;
- break;
- case "%":
- ret += nf.PercentSymbol;
- break;
- }
- }
- return ret;
- }
- RegExp.__typeName = 'RegExp';
- RegExp.__class = true;
- Array.__typeName = 'Array';
- Array.__class = true;
- Array.add = Array.enqueue = function Array$enqueue(array, item) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="item" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "item", mayBeNull: true}
- ]);
- if (e) throw e;
- array[array.length] = item;
- }
- Array.addRange = function Array$addRange(array, items) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="items" type="Array" elementMayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "items", type: Array, elementMayBeNull: true}
- ]);
- if (e) throw e;
- array.push.apply(array, items);
- }
- Array.clear = function Array$clear(array) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true}
- ]);
- if (e) throw e;
- array.length = 0;
- }
- Array.clone = function Array$clone(array) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <returns type="Array" elementMayBeNull="true"></returns>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true}
- ]);
- if (e) throw e;
- if (array.length === 1) {
- return [array[0]];
- }
- else {
- return Array.apply(null, array);
- }
- }
- Array.contains = function Array$contains(array, item) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="item" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "item", mayBeNull: true}
- ]);
- if (e) throw e;
- return (Array.indexOf(array, item) >= 0);
- }
- Array.dequeue = function Array$dequeue(array) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <returns mayBeNull="true"></returns>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true}
- ]);
- if (e) throw e;
- return array.shift();
- }
- Array.forEach = function Array$forEach(array, method, instance) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="method" type="Function"></param>
- /// <param name="instance" optional="true" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "method", type: Function},
- {name: "instance", mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- for (var i = 0, l = array.length; i < l; i++) {
- var elt = array[i];
- if (typeof(elt) !== 'undefined') method.call(instance, elt, i, array);
- }
- }
- Array.indexOf = function Array$indexOf(array, item, start) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="item" optional="true" mayBeNull="true"></param>
- /// <param name="start" optional="true" mayBeNull="true"></param>
- /// <returns type="Number"></returns>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "item", mayBeNull: true, optional: true},
- {name: "start", mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- if (typeof(item) === "undefined") return -1;
- var length = array.length;
- if (length !== 0) {
- start = start - 0;
- if (isNaN(start)) {
- start = 0;
- }
- else {
- if (isFinite(start)) {
- start = start - (start % 1);
- }
- if (start < 0) {
- start = Math.max(0, length + start);
- }
- }
- for (var i = start; i < length; i++) {
- if ((typeof(array[i]) !== "undefined") && (array[i] === item)) {
- return i;
- }
- }
- }
- return -1;
- }
- Array.insert = function Array$insert(array, index, item) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="index" mayBeNull="true"></param>
- /// <param name="item" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "index", mayBeNull: true},
- {name: "item", mayBeNull: true}
- ]);
- if (e) throw e;
- array.splice(index, 0, item);
- }
- Array.parse = function Array$parse(value) {
- /// <param name="value" type="String" mayBeNull="true"></param>
- /// <returns type="Array" elementMayBeNull="true"></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", type: String, mayBeNull: true}
- ]);
- if (e) throw e;
- if (!value) return [];
- var v = eval(value);
- if (!Array.isInstanceOfType(v)) throw Error.argument('value', Sys.Res.arrayParseBadFormat);
- return v;
- }
- Array.remove = function Array$remove(array, item) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="item" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "item", mayBeNull: true}
- ]);
- if (e) throw e;
- var index = Array.indexOf(array, item);
- if (index >= 0) {
- array.splice(index, 1);
- }
- return (index >= 0);
- }
- Array.removeAt = function Array$removeAt(array, index) {
- /// <param name="array" type="Array" elementMayBeNull="true"></param>
- /// <param name="index" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "array", type: Array, elementMayBeNull: true},
- {name: "index", mayBeNull: true}
- ]);
- if (e) throw e;
- array.splice(index, 1);
- }
- String.__typeName = 'String';
- String.__class = true;
- String.prototype.endsWith = function String$endsWith(suffix) {
- /// <param name="suffix" type="String"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "suffix", type: String}
- ]);
- if (e) throw e;
- return (this.substr(this.length - suffix.length) === suffix);
- }
- String.prototype.startsWith = function String$startsWith(prefix) {
- /// <param name="prefix" type="String"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "prefix", type: String}
- ]);
- if (e) throw e;
- return (this.substr(0, prefix.length) === prefix);
- }
- String.prototype.trim = function String$trim() {
- /// <returns type="String"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this.replace(/^s+|s+$/g, '');
- }
- String.prototype.trimEnd = function String$trimEnd() {
- /// <returns type="String"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this.replace(/s+$/, '');
- }
- String.prototype.trimStart = function String$trimStart() {
- /// <returns type="String"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this.replace(/^s+/, '');
- }
- String.format = function String$format(format, args) {
- /// <param name="format" type="String"></param>
- /// <param name="args" parameterArray="true" mayBeNull="true"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "format", type: String},
- {name: "args", mayBeNull: true, parameterArray: true}
- ]);
- if (e) throw e;
- return String._toFormattedString(false, arguments);
- }
- String.localeFormat = function String$localeFormat(format, args) {
- /// <param name="format" type="String"></param>
- /// <param name="args" parameterArray="true" mayBeNull="true"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "format", type: String},
- {name: "args", mayBeNull: true, parameterArray: true}
- ]);
- if (e) throw e;
- return String._toFormattedString(true, arguments);
- }
- String._toFormattedString = function String$_toFormattedString(useLocale, args) {
- var result = '';
- var format = args[0];
- for (var i=0;;) {
- var open = format.indexOf('{', i);
- var close = format.indexOf('}', i);
- if ((open < 0) && (close < 0)) {
- result += format.slice(i);
- break;
- }
- if ((close > 0) && ((close < open) || (open < 0))) {
- if (format.charAt(close + 1) !== '}') {
- throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
- }
- result += format.slice(i, close + 1);
- i = close + 2;
- continue;
- }
- result += format.slice(i, open);
- i = open + 1;
- if (format.charAt(i) === '{') {
- result += '{';
- i++;
- continue;
- }
- if (close < 0) throw Error.argument('format', Sys.Res.stringFormatBraceMismatch);
- var brace = format.substring(i, close);
- var colonIndex = brace.indexOf(':');
- var argNumber = parseInt((colonIndex < 0)? brace : brace.substring(0, colonIndex)) + 1;
- if (isNaN(argNumber)) throw Error.argument('format', Sys.Res.stringFormatInvalid);
- var argFormat = (colonIndex < 0)? '' : brace.substring(colonIndex + 1);
- var arg = args[argNumber];
- if (typeof(arg) === "undefined" || arg === null) {
- arg = '';
- }
- if (arg.toFormattedString) {
- result += arg.toFormattedString(argFormat);
- }
- else if (useLocale && arg.localeFormat) {
- result += arg.localeFormat(argFormat);
- }
- else if (arg.format) {
- result += arg.format(argFormat);
- }
- else
- result += arg.toString();
- i = close + 1;
- }
- return result;
- }
- Type.registerNamespace('Sys');
- Sys.IDisposable = function Sys$IDisposable() {
- throw Error.notImplemented();
- }
- function Sys$IDisposable$dispose() {
- throw Error.notImplemented();
- }
- Sys.IDisposable.prototype = {
- dispose: Sys$IDisposable$dispose
- }
- Sys.IDisposable.registerInterface('Sys.IDisposable');
- Sys.StringBuilder = function Sys$StringBuilder(initialText) {
- /// <param name="initialText" optional="true" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "initialText", mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- this._parts = (typeof(initialText) !== 'undefined' && initialText !== null && initialText !== '') ?
- [initialText.toString()] : [];
- this._value = {};
- this._len = 0;
- }
- function Sys$StringBuilder$append(text) {
- /// <param name="text" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "text", mayBeNull: true}
- ]);
- if (e) throw e;
- this._parts[this._parts.length] = text;
- }
- function Sys$StringBuilder$appendLine(text) {
- /// <param name="text" optional="true" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "text", mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- this._parts[this._parts.length] =
- ((typeof(text) === 'undefined') || (text === null) || (text === '')) ?
- 'rn' : text + 'rn';
- }
- function Sys$StringBuilder$clear() {
- if (arguments.length !== 0) throw Error.parameterCount();
- this._parts = [];
- this._value = {};
- this._len = 0;
- }
- function Sys$StringBuilder$isEmpty() {
- /// <returns type="Boolean"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- if (this._parts.length === 0) return true;
- return this.toString() === '';
- }
- function Sys$StringBuilder$toString(separator) {
- /// <param name="separator" type="String" optional="true" mayBeNull="true"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "separator", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- separator = separator || '';
- var parts = this._parts;
- if (this._len !== parts.length) {
- this._value = {};
- this._len = parts.length;
- }
- var val = this._value;
- if (typeof(val[separator]) === 'undefined') {
- if (separator !== '') {
- for (var i = 0; i < parts.length;) {
- if ((typeof(parts[i]) === 'undefined') || (parts[i] === '') || (parts[i] === null)) {
- parts.splice(i, 1);
- }
- else {
- i++;
- }
- }
- }
- val[separator] = this._parts.join(separator);
- }
- return val[separator];
- }
- Sys.StringBuilder.prototype = {
- append: Sys$StringBuilder$append,
- appendLine: Sys$StringBuilder$appendLine,
- clear: Sys$StringBuilder$clear,
- isEmpty: Sys$StringBuilder$isEmpty,
- toString: Sys$StringBuilder$toString
- }
- Sys.StringBuilder.registerClass('Sys.StringBuilder');
- if (!window.XMLHttpRequest) {
- window.XMLHttpRequest = function window$XMLHttpRequest() {
- var progIDs = [ 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP' ];
- for (var i = 0; i < progIDs.length; i++) {
- try {
- var xmlHttp = new ActiveXObject(progIDs[i]);
- return xmlHttp;
- }
- catch (ex) {
- }
- }
- return null;
- }
- }
- Sys.Browser = {};
- Sys.Browser.InternetExplorer = {};
- Sys.Browser.Firefox = {};
- Sys.Browser.Safari = {};
- Sys.Browser.Opera = {};
- Sys.Browser.agent = null;
- Sys.Browser.hasDebuggerStatement = false;
- Sys.Browser.name = navigator.appName;
- Sys.Browser.version = parseFloat(navigator.appVersion);
- if (navigator.userAgent.indexOf(' MSIE ') > -1) {
- Sys.Browser.agent = Sys.Browser.InternetExplorer;
- Sys.Browser.version = parseFloat(navigator.userAgent.match(/MSIE (d+.d+)/)[1]);
- Sys.Browser.hasDebuggerStatement = true;
- }
- else if (navigator.userAgent.indexOf(' Firefox/') > -1) {
- Sys.Browser.agent = Sys.Browser.Firefox;
- Sys.Browser.version = parseFloat(navigator.userAgent.match(/ Firefox/(d+.d+)/)[1]);
- Sys.Browser.name = 'Firefox';
- Sys.Browser.hasDebuggerStatement = true;
- }
- else if (navigator.userAgent.indexOf(' Safari/') > -1) {
- Sys.Browser.agent = Sys.Browser.Safari;
- Sys.Browser.version = parseFloat(navigator.userAgent.match(/ Safari/(d+.d+)/)[1]);
- Sys.Browser.name = 'Safari';
- }
- else if (navigator.userAgent.indexOf('Opera/') > -1) {
- Sys.Browser.agent = Sys.Browser.Opera;
- }
- Type.registerNamespace('Sys.UI');
- Sys._Debug = function Sys$_Debug() {
- if (arguments.length !== 0) throw Error.parameterCount();
- }
- function Sys$_Debug$_appendConsole(text) {
- if ((typeof(Debug) !== 'undefined') && Debug.writeln) {
- Debug.writeln(text);
- }
- if (window.console && window.console.log) {
- window.console.log(text);
- }
- if (window.opera) {
- window.opera.postError(text);
- }
- if (window.debugService) {
- window.debugService.trace(text);
- }
- }
- function Sys$_Debug$_appendTrace(text) {
- var traceElement = document.getElementById('TraceConsole');
- if (traceElement && (traceElement.tagName.toUpperCase() === 'TEXTAREA')) {
- traceElement.value += text + 'n';
- }
- }
- function Sys$_Debug$assert(condition, message, displayCaller) {
- /// <param name="condition" type="Boolean"></param>
- /// <param name="message" type="String" optional="true" mayBeNull="true"></param>
- /// <param name="displayCaller" type="Boolean" optional="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "condition", type: Boolean},
- {name: "message", type: String, mayBeNull: true, optional: true},
- {name: "displayCaller", type: Boolean, optional: true}
- ]);
- if (e) throw e;
- if (!condition) {
- message = (displayCaller && this.assert.caller) ?
- String.format(Sys.Res.assertFailedCaller, message, this.assert.caller) :
- String.format(Sys.Res.assertFailed, message);
- if (confirm(String.format(Sys.Res.breakIntoDebugger, message))) {
- this.fail(message);
- }
- }
- }
- function Sys$_Debug$clearTrace() {
- var traceElement = document.getElementById('TraceConsole');
- if (traceElement && (traceElement.tagName.toUpperCase() === 'TEXTAREA')) {
- traceElement.value = '';
- }
- }
- function Sys$_Debug$fail(message) {
- /// <param name="message" type="String" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "message", type: String, mayBeNull: true}
- ]);
- if (e) throw e;
- this._appendConsole(message);
- if (Sys.Browser.hasDebuggerStatement) {
- eval('debugger');
- }
- }
- function Sys$_Debug$trace(text) {
- /// <param name="text"></param>
- var e = Function._validateParams(arguments, [
- {name: "text"}
- ]);
- if (e) throw e;
- this._appendConsole(text);
- this._appendTrace(text);
- }
- function Sys$_Debug$traceDump(object, name) {
- /// <param name="object" mayBeNull="true"></param>
- /// <param name="name" type="String" mayBeNull="true" optional="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "object", mayBeNull: true},
- {name: "name", type: String, mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- var text = this._traceDump(object, name, true);
- }
- function Sys$_Debug$_traceDump(object, name, recursive, indentationPadding, loopArray) {
- name = name? name : 'traceDump';
- indentationPadding = indentationPadding? indentationPadding : '';
- if (object === null) {
- this.trace(indentationPadding + name + ': null');
- return;
- }
- switch(typeof(object)) {
- case 'undefined':
- this.trace(indentationPadding + name + ': Undefined');
- break;
- case 'number': case 'string': case 'boolean':
- this.trace(indentationPadding + name + ': ' + object);
- break;
- default:
- if (Date.isInstanceOfType(object) || RegExp.isInstanceOfType(object)) {
- this.trace(indentationPadding + name + ': ' + object.toString());
- break;
- }
- if (!loopArray) {
- loopArray = [];
- }
- else if (Array.contains(loopArray, object)) {
- this.trace(indentationPadding + name + ': ...');
- return;
- }
- Array.add(loopArray, object);
- if ((object == window) || (object === document) ||
- (window.HTMLElement && (object instanceof HTMLElement)) ||
- (typeof(object.nodeName) === 'string')) {
- var tag = object.tagName? object.tagName : 'DomElement';
- if (object.id) {
- tag += ' - ' + object.id;
- }
- this.trace(indentationPadding + name + ' {' + tag + '}');
- }
- else {
- var typeName = Object.getTypeName(object);
- this.trace(indentationPadding + name + (typeof(typeName) === 'string' ? ' {' + typeName + '}' : ''));
- if ((indentationPadding === '') || recursive) {
- indentationPadding += " ";
- var i, length, properties, p, v;
- if (Array.isInstanceOfType(object)) {
- length = object.length;
- for (i = 0; i < length; i++) {
- this._traceDump(object[i], '[' + i + ']', recursive, indentationPadding, loopArray);
- }
- }
- else {
- for (p in object) {
- v = object[p];
- if (!Function.isInstanceOfType(v)) {
- this._traceDump(v, p, recursive, indentationPadding, loopArray);
- }
- }
- }
- }
- }
- Array.remove(loopArray, object);
- }
- }
- Sys._Debug.prototype = {
- _appendConsole: Sys$_Debug$_appendConsole,
- _appendTrace: Sys$_Debug$_appendTrace,
- assert: Sys$_Debug$assert,
- clearTrace: Sys$_Debug$clearTrace,
- fail: Sys$_Debug$fail,
- trace: Sys$_Debug$trace,
- traceDump: Sys$_Debug$traceDump,
- _traceDump: Sys$_Debug$_traceDump
- }
- Sys._Debug.registerClass('Sys._Debug');
- Sys.Debug = new Sys._Debug();
- Sys.Debug.isDebug = true;
- function Sys$Enum$parse(value, ignoreCase) {
- /// <param name="value" type="String"></param>
- /// <param name="ignoreCase" type="Boolean" optional="true"></param>
- /// <returns></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", type: String},
- {name: "ignoreCase", type: Boolean, optional: true}
- ]);
- if (e) throw e;
- var values, parsed, val;
- if (ignoreCase) {
- values = this.__lowerCaseValues;
- if (!values) {
- this.__lowerCaseValues = values = {};
- var prototype = this.prototype;
- for (var name in prototype) {
- values[name.toLowerCase()] = prototype[name];
- }
- }
- }
- else {
- values = this.prototype;
- }
- if (!this.__flags) {
- val = (ignoreCase ? value.toLowerCase() : value);
- parsed = values[val.trim()];
- if (typeof(parsed) !== 'number') throw Error.argument('value', String.format(Sys.Res.enumInvalidValue, value, this.__typeName));
- return parsed;
- }
- else {
- var parts = (ignoreCase ? value.toLowerCase() : value).split(',');
- var v = 0;
- for (var i = parts.length - 1; i >= 0; i--) {
- var part = parts[i].trim();
- parsed = values[part];
- if (typeof(parsed) !== 'number') throw Error.argument('value', String.format(Sys.Res.enumInvalidValue, value.split(',')[i].trim(), this.__typeName));
- v |= parsed;
- }
- return v;
- }
- }
- function Sys$Enum$toString(value) {
- /// <param name="value" optional="true" mayBeNull="true"></param>
- /// <returns type="String"></returns>
- var e = Function._validateParams(arguments, [
- {name: "value", mayBeNull: true, optional: true}
- ]);
- if (e) throw e;
- if ((typeof(value) === 'undefined') || (value === null)) return this.__string;
- if ((typeof(value) != 'number') || ((value % 1) !== 0)) throw Error.argumentType('value', Object.getType(value), this);
- var values = this.prototype;
- var i;
- if (!this.__flags || (value === 0)) {
- for (i in values) {
- if (values[i] === value) {
- return i;
- }
- }
- }
- else {
- var sorted = this.__sortedValues;
- if (!sorted) {
- sorted = [];
- for (i in values) {
- sorted[sorted.length] = {key: i, value: values[i]};
- }
- sorted.sort(function(a, b) {
- return a.value - b.value;
- });
- this.__sortedValues = sorted;
- }
- var parts = [];
- var v = value;
- for (i = sorted.length - 1; i >= 0; i--) {
- var kvp = sorted[i];
- var vali = kvp.value;
- if (vali === 0) continue;
- if ((vali & value) === vali) {
- parts[parts.length] = kvp.key;
- v -= vali;
- if (v === 0) break;
- }
- }
- if (parts.length && v === 0) return parts.reverse().join(', ');
- }
- throw Error.argumentOutOfRange('value', value, String.format(Sys.Res.enumInvalidValue, value, this.__typeName));
- }
- Type.prototype.registerEnum = function Type$registerEnum(name, flags) {
- /// <param name="name" type="String"></param>
- /// <param name="flags" type="Boolean" optional="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "name", type: String},
- {name: "flags", type: Boolean, optional: true}
- ]);
- if (e) throw e;
- if (!Type.__fullyQualifiedIdentifierRegExp.test(name)) throw Error.argument('name', Sys.Res.notATypeName);
- var parsedName;
- try {
- parsedName = eval(name);
- }
- catch(e) {
- throw Error.argument('name', Sys.Res.argumentTypeName);
- }
- if (parsedName !== this) throw Error.argument('name', Sys.Res.badTypeName);
- if (window.__registeredTypes[name]) throw Error.invalidOperation(String.format(Sys.Res.typeRegisteredTwice, name));
- for (var i in this.prototype) {
- var val = this.prototype[i];
- if (!Type.__identifierRegExp.test(i)) throw Error.invalidOperation(String.format(Sys.Res.enumInvalidValueName, i));
- if (typeof(val) !== 'number' || (val % 1) !== 0) throw Error.invalidOperation(Sys.Res.enumValueNotInteger);
- if (typeof(this[i]) !== 'undefined') throw Error.invalidOperation(String.format(Sys.Res.enumReservedName, i));
- }
- for (var i in this.prototype) {
- this[i] = this.prototype[i];
- }
- this.__typeName = name;
- this.parse = Sys$Enum$parse;
- this.__string = this.toString();
- this.toString = Sys$Enum$toString;
- this.__flags = flags;
- this.__enum = true;
- window.__registeredTypes[name] = true;
- }
- Type.isEnum = function Type$isEnum(type) {
- /// <param name="type" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "type", mayBeNull: true}
- ]);
- if (e) throw e;
- if ((typeof(type) === 'undefined') || (type === null)) return false;
- return !!type.__enum;
- }
- Type.isFlags = function Type$isFlags(type) {
- /// <param name="type" mayBeNull="true"></param>
- /// <returns type="Boolean"></returns>
- var e = Function._validateParams(arguments, [
- {name: "type", mayBeNull: true}
- ]);
- if (e) throw e;
- if ((typeof(type) === 'undefined') || (type === null)) return false;
- return !!type.__flags;
- }
- Sys.EventHandlerList = function Sys$EventHandlerList() {
- if (arguments.length !== 0) throw Error.parameterCount();
- this._list = {};
- }
- function Sys$EventHandlerList$addHandler(id, handler) {
- /// <param name="id" type="String"></param>
- /// <param name="handler" type="Function"></param>
- var e = Function._validateParams(arguments, [
- {name: "id", type: String},
- {name: "handler", type: Function}
- ]);
- if (e) throw e;
- Array.add(this._getEvent(id, true), handler);
- }
- function Sys$EventHandlerList$removeHandler(id, handler) {
- /// <param name="id" type="String"></param>
- /// <param name="handler" type="Function"></param>
- var e = Function._validateParams(arguments, [
- {name: "id", type: String},
- {name: "handler", type: Function}
- ]);
- if (e) throw e;
- var evt = this._getEvent(id);
- if (!evt) return;
- Array.remove(evt, handler);
- }
- function Sys$EventHandlerList$getHandler(id) {
- /// <param name="id" type="String"></param>
- /// <returns type="Function"></returns>
- var e = Function._validateParams(arguments, [
- {name: "id", type: String}
- ]);
- if (e) throw e;
- var evt = this._getEvent(id);
- if (!evt || (evt.length === 0)) return null;
- evt = Array.clone(evt);
- if (!evt._handler) {
- evt._handler = function(source, args) {
- for (var i = 0, l = evt.length; i < l; i++) {
- evt[i](source, args);
- }
- };
- }
- return evt._handler;
- }
- function Sys$EventHandlerList$_getEvent(id, create) {
- if (!this._list[id]) {
- if (!create) return null;
- this._list[id] = [];
- }
- return this._list[id];
- }
- Sys.EventHandlerList.prototype = {
- addHandler: Sys$EventHandlerList$addHandler,
- removeHandler: Sys$EventHandlerList$removeHandler,
- getHandler: Sys$EventHandlerList$getHandler,
- _getEvent: Sys$EventHandlerList$_getEvent
- }
- Sys.EventHandlerList.registerClass('Sys.EventHandlerList');
- Sys.EventArgs = function Sys$EventArgs() {
- if (arguments.length !== 0) throw Error.parameterCount();
- }
- Sys.EventArgs.registerClass('Sys.EventArgs');
- Sys.EventArgs.Empty = new Sys.EventArgs();
- Sys.CancelEventArgs = function Sys$CancelEventArgs() {
- if (arguments.length !== 0) throw Error.parameterCount();
- Sys.CancelEventArgs.initializeBase(this);
- this._cancel = false;
- }
- function Sys$CancelEventArgs$get_cancel() {
- /// <value type="Boolean"></value>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this._cancel;
- }
- function Sys$CancelEventArgs$set_cancel(value) {
- var e = Function._validateParams(arguments, [{name: "value", type: Boolean}]);
- if (e) throw e;
- this._cancel = value;
- }
- Sys.CancelEventArgs.prototype = {
- get_cancel: Sys$CancelEventArgs$get_cancel,
- set_cancel: Sys$CancelEventArgs$set_cancel
- }
- Sys.CancelEventArgs.registerClass('Sys.CancelEventArgs', Sys.EventArgs);
- Sys.INotifyPropertyChange = function Sys$INotifyPropertyChange() {
- if (arguments.length !== 0) throw Error.parameterCount();
- throw Error.notImplemented();
- }
- function Sys$INotifyPropertyChange$add_propertyChanged(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- throw Error.notImplemented();
- }
- function Sys$INotifyPropertyChange$remove_propertyChanged(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- throw Error.notImplemented();
- }
- Sys.INotifyPropertyChange.prototype = {
- add_propertyChanged: Sys$INotifyPropertyChange$add_propertyChanged,
- remove_propertyChanged: Sys$INotifyPropertyChange$remove_propertyChanged
- }
- Sys.INotifyPropertyChange.registerInterface('Sys.INotifyPropertyChange');
- Sys.PropertyChangedEventArgs = function Sys$PropertyChangedEventArgs(propertyName) {
- /// <param name="propertyName" type="String"></param>
- var e = Function._validateParams(arguments, [
- {name: "propertyName", type: String}
- ]);
- if (e) throw e;
- Sys.PropertyChangedEventArgs.initializeBase(this);
- this._propertyName = propertyName;
- }
- function Sys$PropertyChangedEventArgs$get_propertyName() {
- /// <value type="String"></value>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this._propertyName;
- }
- Sys.PropertyChangedEventArgs.prototype = {
- get_propertyName: Sys$PropertyChangedEventArgs$get_propertyName
- }
- Sys.PropertyChangedEventArgs.registerClass('Sys.PropertyChangedEventArgs', Sys.EventArgs);
- Sys.INotifyDisposing = function Sys$INotifyDisposing() {
- if (arguments.length !== 0) throw Error.parameterCount();
- throw Error.notImplemented();
- }
- function Sys$INotifyDisposing$add_disposing(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- throw Error.notImplemented();
- }
- function Sys$INotifyDisposing$remove_disposing(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- throw Error.notImplemented();
- }
- Sys.INotifyDisposing.prototype = {
- add_disposing: Sys$INotifyDisposing$add_disposing,
- remove_disposing: Sys$INotifyDisposing$remove_disposing
- }
- Sys.INotifyDisposing.registerInterface("Sys.INotifyDisposing");
- Sys.Component = function Sys$Component() {
- if (arguments.length !== 0) throw Error.parameterCount();
- if (Sys.Application) Sys.Application.registerDisposableObject(this);
- }
- function Sys$Component$get_events() {
- /// <value type="Sys.EventHandlerList"></value>
- if (arguments.length !== 0) throw Error.parameterCount();
- if (!this._events) {
- this._events = new Sys.EventHandlerList();
- }
- return this._events;
- }
- function Sys$Component$get_id() {
- /// <value type="String"></value>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this._id;
- }
- function Sys$Component$set_id(value) {
- var e = Function._validateParams(arguments, [{name: "value", type: String}]);
- if (e) throw e;
- if (this._idSet) throw Error.invalidOperation(Sys.Res.componentCantSetIdTwice);
- this._idSet = true;
- var oldId = this.get_id();
- if (oldId && Sys.Application.findComponent(oldId)) throw Error.invalidOperation(Sys.Res.componentCantSetIdAfterAddedToApp);
- this._id = value;
- }
- function Sys$Component$get_isInitialized() {
- /// <value type="Boolean"></value>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this._initialized;
- }
- function Sys$Component$get_isUpdating() {
- /// <value type="Boolean"></value>
- if (arguments.length !== 0) throw Error.parameterCount();
- return this._updating;
- }
- function Sys$Component$add_disposing(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- this.get_events().addHandler("disposing", handler);
- }
- function Sys$Component$remove_disposing(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- this.get_events().removeHandler("disposing", handler);
- }
- function Sys$Component$add_propertyChanged(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- this.get_events().addHandler("propertyChanged", handler);
- }
- function Sys$Component$remove_propertyChanged(handler) {
- var e = Function._validateParams(arguments, [{name: "handler", type: Function}]);
- if (e) throw e;
- this.get_events().removeHandler("propertyChanged", handler);
- }
- function Sys$Component$beginUpdate() {
- this._updating = true;
- }
- function Sys$Component$dispose() {
- if (this._events) {
- var handler = this._events.getHandler("disposing");
- if (handler) {
- handler(this, Sys.EventArgs.Empty);
- }
- }
- delete this._events;
- Sys.Application.unregisterDisposableObject(this);
- Sys.Application.removeComponent(this);
- }
- function Sys$Component$endUpdate() {
- this._updating = false;
- if (!this._initialized) this.initialize();
- this.updated();
- }
- function Sys$Component$initialize() {
- this._initialized = true;
- }
- function Sys$Component$raisePropertyChanged(propertyName) {
- /// <param name="propertyName" type="String"></param>
- var e = Function._validateParams(arguments, [
- {name: "propertyName", type: String}
- ]);
- if (e) throw e;
- if (!this._events) return;
- var handler = this._events.getHandler("propertyChanged");
- if (handler) {
- handler(this, new Sys.PropertyChangedEventArgs(propertyName));
- }
- }
- function Sys$Component$updated() {
- }
- Sys.Component.prototype = {
- _id: null,
- _idSet: false,
- _initialized: false,
- _updating: false,
- get_events: Sys$Component$get_events,
- get_id: Sys$Component$get_id,
- set_id: Sys$Component$set_id,
- get_isInitialized: Sys$Component$get_isInitialized,
- get_isUpdating: Sys$Component$get_isUpdating,
- add_disposing: Sys$Component$add_disposing,
- remove_disposing: Sys$Component$remove_disposing,
- add_propertyChanged: Sys$Component$add_propertyChanged,
- remove_propertyChanged: Sys$Component$remove_propertyChanged,
- beginUpdate: Sys$Component$beginUpdate,
- dispose: Sys$Component$dispose,
- endUpdate: Sys$Component$endUpdate,
- initialize: Sys$Component$initialize,
- raisePropertyChanged: Sys$Component$raisePropertyChanged,
- updated: Sys$Component$updated
- }
- Sys.Component.registerClass('Sys.Component', null, Sys.IDisposable, Sys.INotifyPropertyChange, Sys.INotifyDisposing);
- function Sys$Component$_setProperties(target, properties) {
- /// <param name="target"></param>
- /// <param name="properties"></param>
- var e = Function._validateParams(arguments, [
- {name: "target"},
- {name: "properties"}
- ]);
- if (e) throw e;
- var current;
- var targetType = Object.getType(target);
- var isObject = (targetType === Object) || (targetType === Sys.UI.DomElement);
- var isComponent = Sys.Component.isInstanceOfType(target) && !target.get_isUpdating();
- if (isComponent) target.beginUpdate();
- for (var name in properties) {
- var val = properties[name];
- var getter = isObject ? null : target["get_" + name];
- if (isObject || typeof(getter) !== 'function') {
- var targetVal = target[name];
- if (!isObject && typeof(targetVal) === 'undefined') throw Error.invalidOperation(String.format(Sys.Res.propertyUndefined, name));
- if (!val || (typeof(val) !== 'object') || (isObject && !targetVal)) {
- target[name] = val;
- }
- else {
- Sys$Component$_setProperties(targetVal, val);
- }
- }
- else {
- var setter = target["set_" + name];
- if (typeof(setter) === 'function') {
- setter.apply(target, [val]);
- }
- else if (val instanceof Array) {
- current = getter.apply(target);
- if (!(current instanceof Array)) throw new Error.invalidOperation(String.format(Sys.Res.propertyNotAnArray, name));
- for (var i = 0, j = current.length, l= val.length; i < l; i++, j++) {
- current[j] = val[i];
- }
- }
- else if ((typeof(val) === 'object') && (Object.getType(val) === Object)) {
- current = getter.apply(target);
- if ((typeof(current) === 'undefined') || (current === null)) throw new Error.invalidOperation(String.format(Sys.Res.propertyNullOrUndefined, name));
- Sys$Component$_setProperties(current, val);
- }
- else {
- throw new Error.invalidOperation(String.format(Sys.Res.propertyNotWritable, name));
- }
- }
- }
- if (isComponent) target.endUpdate();
- }
- function Sys$Component$_setReferences(component, references) {
- for (var name in references) {
- var setter = component["set_" + name];
- var reference = $find(references[name]);
- if (typeof(setter) !== 'function') throw new Error.invalidOperation(String.format(Sys.Res.propertyNotWritable, name));
- if (!reference) throw Error.invalidOperation(String.format(Sys.Res.referenceNotFound, references[name]));
- setter.apply(component, [reference]);
- }
- }
- var $create = Sys.Component.create = function Sys$Component$create(type, properties, events, references, element) {
- /// <param name="type" type="Type"></param>
- /// <param name="properties" optional="true" mayBeNull="true"></param>
- /// <param name="events" optional="true" mayBeNull="true"></param>
- /// <param name="references" optional="true" mayBeNull="true"></param>
- /// <param name="element" domElement="true" optional="true" mayBeNull="true"></param>
- /// <returns type="Sys.UI.Component"></returns>
- var e = Function._validateParams(arguments, [
- {name: "type", type: Type},
- {name: "properties", mayBeNull: true, optional: true},
- {name: "events", mayBeNull: true, optional: true},
- {name: "references", mayBeNull: true, optional: true},
- {name: "element", mayBeNull: true, domElement: true, optional: true}
- ]);
- if (e) throw e;
- if (!type.inheritsFrom(Sys.Component)) {
- throw Error.argument('type', String.format(Sys.Res.createNotComponent, type.getName()));
- }
- if (type.inheritsFrom(Sys.UI.Behavior) || type.inheritsFrom(Sys.UI.Control)) {
- if (!element) throw Error.argument('element', Sys.Res.createNoDom);
- }
- else if (element) throw Error.argument('element', Sys.Res.createComponentOnDom);
- var component = (element ? new type(element): new type());
- var app = Sys.Application;
- var creatingComponents = app.get_isCreatingComponents();
- component.beginUpdate();
- if (properties) {
- Sys$Component$_setProperties(component, properties);
- }
- if (events) {
- for (var name in events) {
- if (!(component["add_" + name] instanceof Function)) throw new Error.invalidOperation(String.format(Sys.Res.undefinedEvent, name));
- if (!(events[name] instanceof Function)) throw new Error.invalidOperation(Sys.Res.eventHandlerNotFunction);
- component["add_" + name](events[name]);
- }
- }
- app._createdComponents[app._createdComponents.length] = component;
- if (component.get_id()) {
- app.addComponent(component);
- }
- if (creatingComponents) {
- if (references) {
- app._addComponentToSecondPass(component, references);
- }
- else {
- component.endUpdate();
- }
- }
- else {
- if (references) {
- Sys$Component$_setReferences(component, references);
- }
- component.endUpdate();
- }
- return component;
- }
- Sys.UI.MouseButton = function Sys$UI$MouseButton() {
- /// <field name="leftButton" type="Number" integer="true" static="true"></field>
- /// <field name="middleButton" type="Number" integer="true" static="true"></field>
- /// <field name="rightButton" type="Number" integer="true" static="true"></field>
- if (arguments.length !== 0) throw Error.parameterCount();
- throw Error.notImplemented();
- }
- Sys.UI.MouseButton.prototype = {
- leftButton: 0,
- middleButton: 1,
- rightButton: 2
- }
- Sys.UI.MouseButton.registerEnum("Sys.UI.MouseButton");
- Sys.UI.Key = function Sys$UI$Key() {
- /// <field name="backspace" type="Number" integer="true" static="true"></field>
- /// <field name="tab" type="Number" integer="true" static="true"></field>
- /// <field name="enter" type="Number" integer="true" static="true"></field>
- /// <field name="esc" type="Number" integer="true" static="true"></field>
- /// <field name="space" type="Number" integer="true" static="true"></field>
- /// <field name="pageUp" type="Number" integer="true" static="true"></field>
- /// <field name="pageDown" type="Number" integer="true" static="true"></field>
- /// <field name="end" type="Number" integer="true" static="true"></field>
- /// <field name="home" type="Number" integer="true" static="true"></field>
- /// <field name="left" type="Number" integer="true" static="true"></field>
- /// <field name="up" type="Number" integer="true" static="true"></field>
- /// <field name="right" type="Number" integer="true" static="true"></field>
- /// <field name="down" type="Number" integer="true" static="true"></field>
- /// <field name="del" type="Number" integer="true" static="true"></field>
- if (arguments.length !== 0) throw Error.parameterCount();
- throw Error.notImplemented();
- }
- Sys.UI.Key.prototype = {
- backspace: 8,
- tab: 9,
- enter: 13,
- esc: 27,
- space: 32,
- pageUp: 33,
- pageDown: 34,
- end: 35,
- home: 36,
- left: 37,
- up: 38,
- right: 39,
- down: 40,
- del: 127
- }
- Sys.UI.Key.registerEnum("Sys.UI.Key");
- Sys.UI.DomEvent = function Sys$UI$DomEvent(eventObject) {
- /// <param name="eventObject"></param>
- /// <field name="altKey" type="Boolean"></field>
- /// <field name="button" type="Sys.UI.MouseButton"></field>
- /// <field name="charCode" type="Number" integer="true"></field>
- /// <field name="clientX" type="Number" integer="true"></field>
- /// <field name="clientY" type="Number" integer="true"></field>
- /// <field name="ctrlKey" type="Boolean"></field>
- /// <field name="keyCode" type="Number" integer="true"></field>
- /// <field name="offsetX" type="Number" integer="true"></field>
- /// <field name="offsetY" type="Number" integer="true"></field>
- /// <field name="screenX" type="Number" integer="true"></field>
- /// <field name="screenY" type="Number" integer="true"></field>
- /// <field name="shiftKey" type="Boolean"></field>
- /// <field name="target" domElement="true"></field>
- /// <field name="type" type="String"></field>
- var e = Function._validateParams(arguments, [
- {name: "eventObject"}
- ]);
- if (e) throw e;
- var e = eventObject;
- this.rawEvent = e;
- this.altKey = e.altKey;
- if (typeof(e.button) !== 'undefined') {
- this.button = (typeof(e.which) !== 'undefined') ? e.button :
- (e.button === 4) ? Sys.UI.MouseButton.middleButton :
- (e.button === 2) ? Sys.UI.MouseButton.rightButton :
- Sys.UI.MouseButton.leftButton;
- }
- if (e.type === 'keypress') {
- this.charCode = e.charCode || e.keyCode;
- }
- else if (e.keyCode && (e.keyCode === 46)) {
- this.keyCode = 127;
- }
- else {
- this.keyCode = e.keyCode;
- }
- this.clientX = e.clientX;
- this.clientY = e.clientY;
- this.ctrlKey = e.ctrlKey;
- this.target = e.target ? e.target : e.srcElement;
- if (this.target) {
- var loc = Sys.UI.DomElement.getLocation(this.target);
- this.offsetX = (typeof(e.offsetX) !== 'undefined') ? e.offsetX : window.pageXOffset + (e.clientX || 0) - loc.x;
- this.offsetY = (typeof(e.offsetY) !== 'undefined') ? e.offsetY : window.pageYOffset + (e.clientY || 0) - loc.y;
- }
- this.screenX = e.screenX;
- this.screenY = e.screenY;
- this.shiftKey = e.shiftKey;
- this.type = e.type;
- }
- function Sys$UI$DomEvent$preventDefault() {
- if (arguments.length !== 0) throw Error.parameterCount();
- if (this.rawEvent.preventDefault) {
- this.rawEvent.preventDefault();
- }
- else if (window.event) {
- window.event.returnValue = false;
- }
- }
- function Sys$UI$DomEvent$stopPropagation() {
- if (arguments.length !== 0) throw Error.parameterCount();
- if (this.rawEvent.stopPropagation) {
- this.rawEvent.stopPropagation();
- }
- else if (window.event) {
- window.event.cancelBubble = true;
- }
- }
- Sys.UI.DomEvent.prototype = {
- preventDefault: Sys$UI$DomEvent$preventDefault,
- stopPropagation: Sys$UI$DomEvent$stopPropagation
- }
- Sys.UI.DomEvent.registerClass('Sys.UI.DomEvent');
- var $addHandler = Sys.UI.DomEvent.addHandler = function Sys$UI$DomEvent$addHandler(element, eventName, handler) {
- /// <param name="element" domElement="true"></param>
- /// <param name="eventName" type="String"></param>
- /// <param name="handler" type="Function"></param>
- var e = Function._validateParams(arguments, [
- {name: "element", domElement: true},
- {name: "eventName", type: String},
- {name: "handler", type: Function}
- ]);
- if (e) throw e;
- if (!element._events) {
- element._events = {};
- }
- var eventCache = element._events[eventName];
- if (!eventCache) {
- element._events[eventName] = eventCache = [];
- }
- var browserHandler;
- if (element.addEventListener) {
- browserHandler = function(e) {
- return handler.call(element, new Sys.UI.DomEvent(e));
- }
- element.addEventListener(eventName, browserHandler, false);
- }
- else if (element.attachEvent) {
- browserHandler = function() {
- return handler.call(element, new Sys.UI.DomEvent(window.event));
- }
- element.attachEvent('on' + eventName, browserHandler);
- }
- eventCache[eventCache.length] = {handler: handler, browserHandler: browserHandler};
- }
- var $addHandlers = Sys.UI.DomEvent.addHandlers = function Sys$UI$DomEvent$addHandlers(element, events, handlerOwner) {
- /// <param name="element" domElement="true"></param>
- /// <param name="events" type="Object"></param>
- /// <param name="handlerOwner" optional="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "element", domElement: true},
- {name: "events", type: Object},
- {name: "handlerOwner", optional: true}
- ]);
- if (e) throw e;
- for (var name in events) {
- var handler = events[name];
- if (typeof(handler) !== 'function') throw Error.invalidOperation(Sys.Res.cantAddNonFunctionhandler);
- if (handlerOwner) {
- handler = Function.createDelegate(handlerOwner, handler);
- }
- $addHandler(element, name, handler);
- }
- }
- var $clearHandlers = Sys.UI.DomEvent.clearHandlers = function Sys$UI$DomEvent$clearHandlers(element) {
- /// <param name="element" domElement="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "element", domElement: true}
- ]);
- if (e) throw e;
- if (element._events) {
- var cache = element._events;
- for (var name in cache) {
- var handlers = cache[name];
- for (var i = handlers.length - 1; i >= 0; i--) {
- $removeHandler(element, name, handlers[i].handler);
- }
- }
- element._events = null;
- }
- }
- var $removeHandler = Sys.UI.DomEvent.removeHandler = function Sys$UI$DomEvent$removeHandler(element, eventName, handler) {
- /// <param name="element" domElement="true"></param>
- /// <param name="eventName" type="String"></param>
- /// <param name="handler" type="Function"></param>
- var e = Function._validateParams(arguments, [
- {name: "element", domElement: true},
- {name: "eventName", type: String},
- {name: "handler", type: Function}
- ]);
- if (e) throw e;
- var browserHandler = null;
- if ((typeof(element._events) !== 'object') || (element._events == null)) throw Error.invalidOperation(Sys.Res.eventHandlerInvalid);
- var cache = element._events[eventName];
- if (!(cache instanceof Array)) throw Error.invalidOperation(Sys.Res.eventHandlerInvalid);
- var browserHandler = null;
- for (var i = 0, l = cache.length; i < l; i++) {
- if (cache[i].handler === handler) {
- browserHandler = cache[i].browserHandler;
- break;
- }
- }
- if (typeof(browserHandler) !== 'function') throw Error.invalidOperation(Sys.Res.eventHandlerInvalid);
- if (element.removeEventListener) {
- element.removeEventListener(eventName, browserHandler, false);
- }
- else if (element.detachEvent) {
- element.detachEvent('on' + eventName, browserHandler);
- }
- cache.splice(i, 1);
- }
- Sys.IContainer = function Sys$IContainer() {
- throw Error.notImplemented();
- }
- function Sys$IContainer$addComponent(component) {
- /// <param name="component" type="Sys.Component"></param>
- var e = Function._validateParams(arguments, [
- {name: "component", type: Sys.Component}
- ]);
- if (e) throw e;
- throw Error.notImplemented();
- }
- function Sys$IContainer$removeComponent(component) {
- /// <param name="component" type="Sys.Component"></param>
- var e = Function._validateParams(arguments, [
- {name: "component", type: Sys.Component}
- ]);
- if (e) throw e;
- throw Error.notImplemented();
- }
- function Sys$IContainer$findComponent(id) {
- /// <param name="id" type="String"></param>
- /// <returns type="Sys.Component"></returns>
- var e = Function._validateParams(arguments, [
- {name: "id", type: String}
- ]);
- if (e) throw e;
- throw Error.notImplemented();
- }
- function Sys$IContainer$getComponents() {
- /// <returns type="Array" elementType="Sys.Component"></returns>
- if (arguments.length !== 0) throw Error.parameterCount();
- throw Error.notImplemented();
- }
- Sys.IContainer.prototype = {
- addComponent: Sys$IContainer$addComponent,
- removeComponent: Sys$IContainer$removeComponent,
- findComponent: Sys$IContainer$findComponent,
- getComponents: Sys$IContainer$getComponents
- }
- Sys.IContainer.registerInterface("Sys.IContainer");
- Sys._ScriptLoader = function Sys$_ScriptLoader() {
- this._scriptsToLoad = null;
- this._scriptLoadedDelegate = Function.createDelegate(this, this._scriptLoadedHandler);
- }
- function Sys$_ScriptLoader$dispose() {
- this._stopLoading();
- if(this._events) {
- delete this._events;
- }
- this._scriptLoadedDelegate = null;
- }
- function Sys$_ScriptLoader$loadScripts(scriptTimeout, allScriptsLoadedCallback, scriptLoadFailedCallback, scriptLoadTimeoutCallback) {
- /// <param name="scriptTimeout" type="Number" integer="true"></param>
- /// <param name="allScriptsLoadedCallback" type="Function" mayBeNull="true"></param>
- /// <param name="scriptLoadFailedCallback" type="Function" mayBeNull="true"></param>
- /// <param name="scriptLoadTimeoutCallback" type="Function" mayBeNull="true"></param>
- var e = Function._validateParams(arguments, [
- {name: "scriptTimeout", type: Number, integer: true},
- {name: "allScriptsLoadedCallback", type: Function, mayBeNull: true},
- {name: "scriptLoadFailedCallback", type: Function, mayBeNull: true},
- {name: "scriptLoadTimeoutCallback", type: Function, mayBeNull: true}
- ]);
- if (e) throw e;
- if(this._loading) {
- throw Error.invalidOperation(Sys.Res.scriptLoaderAlreadyLoading);
- }
- this._loading = true;
- this._allScriptsLoadedCallback = allScriptsLoadedCallback;
- this._scriptLoadFailedCallback = scriptLoadFailedCallback;
- this._scriptLoadTimeoutCallback = scriptLoadTimeoutCallback;
- this._loadScriptsInternal();
- }
- function Sys$_ScriptLoader$notifyScriptLoaded() {
- if (arguments.length !== 0) throw Error.parameterCount();
- if(!this._loading) {
- return;
- }
- this._currentTask._notified++;
- if(Sys.Browser.agent === Sys.Browser.Safari) {
- if(this._currentTask._notified === 1) {
- window.setTimeout(Function.createDelegate(this, function() {
- this._scriptLoadedHandler(this._currentTask.get_scriptElement(), true);
- }), 0);
- }
- }
- }
- function Sys$_ScriptLoader$queueCustomScriptTag(scriptAttributes) {
- /// <param name="scriptAttributes" mayBeNull="false"></param>
- var e = Function._validateParams(arguments, [
- {name: "scriptAttributes"}
- ]);
- if (e) throw e;
- if(!this._scriptsToLoad) {
- this._scriptsToLoad = [];
- }
- Array.add(this._scriptsToLoad, scriptAttributes);
- }
- function Sys$_ScriptLoader$queueScriptBlock(scriptContent) {
- /// <param name="scriptContent" type="String" mayBeNull="false"></param>
- var e = Function._validateParams(arguments, [
- {name: "scriptContent", type: String}
- ]);
- if (e) throw e;
- if(!this._scriptsToLoad) {
- this._scriptsToLoad = [];
- }
- Array.add(this._scriptsToLoad, {text: scriptContent});
- }
- function Sys$_ScriptLoader$queueScriptReference(scriptUrl) {
- /// <param name="scriptUrl" type="String" mayBeNull="false"></param>
- var e = Function._validateParams(arguments, [
- {name: "scriptUrl", type: String}
- ]);
- if (e) throw e;
- if(!this._scriptsToLoad) {
- this._scriptsToLoad = [];
- }
- Array.add(this._scriptsToLoad, {src: scriptUrl});
- }
- function Sys$_ScriptLoader$_createScriptElement(queuedScript) {
- var scriptElement = document.createElement('SCRIPT');
- scriptElement.type = 'text/javascript';
- for (var attr in queuedScript) {
- scriptElement[attr] = queuedScript[attr];
- }
- return scriptElement;
- }
- function Sys$_ScriptLoader$_loadScriptsInternal() {
- if (this._scriptsToLoad && this._scriptsToLoad.length > 0) {
- var nextScript = Array.dequeue(this._scriptsToLoad);
- var scriptElement = this._createScriptElement(nextScript);
- if (scriptElement.text && Sys.Browser.agent === Sys.Browser.Safari) {
- scriptElement.innerHTML = scriptElement.text;
- delete scriptElement.text;
- }
- if (typeof(nextScript.src) === "string") {
- this._currentTask = new Sys._ScriptLoaderTask(scriptElement, this._scriptLoadedDelegate);
- this._currentTask.execute();
- }
- else {
- document.getElementsByTagName('HEAD')[0].appendChild(scriptElement);
- Sys._ScriptLoader._clearScript(scriptElement);
- this._loadScriptsInternal();
- }
- }
- else {
- var callback = this._allScriptsLoadedCallback;
- this._stopLoading();
- if(callback) {
- callback(this);
- }
- }
- }
- function Sys$_ScriptLoader$_raiseError(multipleCallbacks) {
- var callback = this._scriptLoadFailedCallback;
- var scriptElement = this._currentTask.get_scriptElement();
- this._stopLoading();
- if(callback) {
- callback(this, scriptElement, multipleCallbacks);
- }
- else {
- throw Sys._ScriptLoader._errorScriptLoadFailed(scriptElement.src, multipleCallbacks);
- }
- }
- function Sys$_ScriptLoader$_scriptLoadedHandler(scriptElement, loaded) {
- if(loaded && this._currentTask._notified) {
- if(this._currentTask._notified > 1) {