From d798efd2bae06f89124849e56b293c28e1e3f312 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 9 Mar 2014 22:09:53 +0000 Subject: [PATCH 01/24] Beginning of microsoft ajax definitions This is preliminary and is the foundation. Still need to add to the namespaces that have been declared and port over documentation including testing and re-view all static methods and event handler function arguments. No testing has been completed. --- README.md | 1 + microsoft-ajax/microsoft.ajax.d.ts | 894 +++++++++++++++++++++++++++++ 2 files changed, 895 insertions(+) create mode 100644 microsoft-ajax/microsoft.ajax.d.ts diff --git a/README.md b/README.md index 020897cf8..db1696e55 100755 --- a/README.md +++ b/README.md @@ -193,6 +193,7 @@ List of Definitions * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) * [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) +* [Microsoft Ajax] (http://msdn.microsoft.com/en-us/library/bb397536(v=vs.100).aspx) (by [Patrick Magee] (https://github.com/pjmagee)) * [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts new file mode 100644 index 000000000..76bc8da1f --- /dev/null +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -0,0 +1,894 @@ +// Type definitions for microsoft asp.net ajax client side library +// Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx +// Definitions by: Patrick Magee +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +//#region Global Namespace + +/** +* Global Namespace +* This section includes members or types that extend the ECMAScript (JavaScript) Global object and other core objects. +* @see {@link http://msdn.microsoft.com/en-us/library/bb310818(v=vs.100).aspx} +*/ + +//#region JavaScript Base Type Extensions + +/** +* Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. +* Array Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} +*/ +interface Array { + /** + * Adds an element to the end of an Array object. + */ + add(element: T): void; + /** + * Copies all the elements of the specified array to the end of an Array object. + */ + addRange(array: T, items: T): void; + /** + * Removes all elements from an Array object. + */ + clear(): void; + /** + * Creates a shallow copy of an Array object. + */ + clone(): Array; + /** + * Determines whether an element is in an Array object. + */ + contains(element: T): boolean; + /** + * Removes the first element from an Array object. + */ + dequeue(): T; + /** + * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. + */ + enqueue(element: T): void; + /** + * Performs a specified action on each element of an Array object. + */ + forEach(array: T[], method: Function, instance: T[]): void; + /** + * Searches for the specified element of an Array object and returns its index. + */ + indexOf(array: T[], item: T, startIndex?: number): number; + /** + * Inserts a value at the specified location in an Array object. + */ + insert(array: T[], index: number, item: T); + /** + * Creates an Array object from a string representation. + */ + parse(value: string): any[]; + /** + * Removes the first occurrence of an element in an Array object. + */ + remove(array: T[], item: T): boolean; + /** + * Removes an element at the specified location in an Array object. + */ + removeAt(array: T[], index: number): void; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Boolean object. +* Boolean Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} +*/ +interface Boolean { + /** + * Converts a string representation of a logical value to its Boolean object equivalent. + */ + parse(value: string): boolean; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Date object. +* Date Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} +*/ +interface Date { + /** + * Formats a date by using the invariant (culture-independent) culture. + */ + format(value: string): string; + /** + * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. + */ + localeFormat(value: string): string; + /** + * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. + * @exception (Debug) formats contains an invalid format. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseLocale(value: string): string; + parseLocale(value: string, formats?: string[]): string; + parseLocale(value: string, ...formats: string[]): string; + /** + * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. + * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseInvariant(value: string): string; + parseInvariant(value: string, formats?: string[]): string; + parseInvariant(value: string, ...formats: string[]): string; +} + +/** +* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). +* Error Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} +*/ +interface Error { + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; +} + +/** +* Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. +* Number Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} +*/ +interface Number { + /** + * Formats a number by using the invariant culture. + */ + format(format: string): string; + /** + * Formats a number by using the current culture. + */ + localeFormat(format: string): string; + /** + * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. + */ + parseInvariant(format: string): number; + /** + * Creates a numeric value from a locale-specific string. + */ + parseLocale(format: string): number; +} + +/** +* Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. +* Object Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} +*/ +interface Object { + /** + * Formats a number by using the invariant culture. + */ + getType(instance: any): Type; + /** + * Returns a string that identifies the run-time type name of an object. + */ + getTypeName(instance: any): string; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. +* String Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} +*/ +interface String { + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; +} + +//#endregion + +//#region ASP.NET Types + +/** +* Provides a typing and type-reflection system for ECMAScript (JavaScript) object-oriented programming functionality. +* Type Class +* @see {@link http://msdn.microsoft.com/en-us/library/bb397568(v=vs.100).aspx} +*/ +declare class Type { + /** + * Invokes a base method with specified arguments. + * @returns A value of the class that the base method returns. If the base method does not return a value, no value is returned. + */ + callBaseMethod(instance: any, name: string, baseArguments?: any[]): any; +} + +//#endregion + +//#region Shortcuts to commonly used APIs + +/** +* Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. +* @param type +* The type of the component to create. +* @param properties +* (Optional) A JSON object that describes the properties and their values. +* @param events +* (Optional) A JSON object that describes the events and their handlers. +* @param references +* (Optional) A JSON object that describes the properties that are references to other components. +* @param element +* (Optional) The DOM element that the component should be attached to. +* +* @returns A new instance of a component that uses the specified parameters. +*/ +declare function $create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; + +/** +* Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. +* @return A Component object that contains the component requested by ID, if found; otherwise, null. +*/ +declare function $find(id: string, parent?: Sys.Component): Sys.Component; + +//#endregion + +//#endregion + +//#region Sys Namespace + +/** +* Represents the root namespace for the Microsoft Ajax Library, which contains all fundamental classes and base classes. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397702(v=vs.100).aspx} +*/ +declare module Sys { + /** + * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} + */ + class Application { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Events + + /** + * Raised after all scripts have been loaded but before objects are created. + */ + add_init(handler: Function): void; + remove_init(handler: Function): void; + /** + * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. + */ + add_load(handler: Function): void; + remove_load(handler: Function): void; + /** + * Occurs when the user clicks the browser's Back or Forward button. + */ + add_navigate(handler: Function): void; + remove_navigate(handler: Function): void; + + //#endregion + + //#region Methods + + /** + * Registers a component with the application and initializes it if the component is not already initialized. + */ + addComponent(component: any): void; + /** + * Instructs the application to start creating components. + */ + beginCreateComponents(): void; + /** + * Creates a history point and adds it to the browser's history stack. + */ + addHistoryPoint(state: Object, title?: string): void; + /** + * Called by the Sys.Application.beginUpdate Method to indicate that the process of setting component properties of the application has begun. + */ + beginUpdate(): void; + /** + * Releases resources and dependencies held by the client application. + */ + dispose(): void; + /** + * Releases resources and dependencies associated with an element and its child nodes. + * @param element + * The element to dispose. + * @param childNodesOnly + * A boolean value used to determine whether to dispose of the element and its child nodes or to dispose only its child nodes. + */ + disposeElement(element: Element, childNodesOnly: boolean): void; + /** + * Instructs the application to finalize component creation. + */ + endCreateComponents(): void; + /** + * Called by the Sys.Application.endCreateComponents Method to indicate that the process of updating the application has completed. + */ + endUpdate(): void; + /** + * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. + * @return A Component object that contains the component requested by ID, if found; otherwise, null. + */ + findComponent(id: string, parent?: Component): Component; + /** + * Returns an array of all components that have been registered with the application by using the addComponent method. This member is static and can be invoked without creating an instance of the class. + */ + getComponents(): Component[]; + /** + * This function supports the client-script infrastructure and is not intended to be used directly from your code. + */ + initialize(): void; + /** + * Called by a referenced script to indicate that it has been loaded. This API is obsolete. You no longer need to call this method in order to notify the Microsoft Ajax Library that the JavaScript file has been loaded. + */ + notifyScriptLoaded(): void; + /** + * Raises the load event. This member is static and can be invoked without creating an instance of the class. + */ + raiseLoad(): void; + /** + * Raises the Sys.INotifyPropertyChange.propertyChanged event. + */ + raisePropertyChanged(propertyName: string): void; + /** + * Registers with the application an object that will require disposing. This member is static and can be invoked without creating an instance of the class. + */ + registerDisposableObject(object: any): void; + /** + * Removes the object from the application and disposes the object if it is disposable. This member is static and can be invoked without creating an instance of the class. + */ + removeComponent(component: Component): void; + /** + * Unregisters a disposable object from the application. This member is static and can be invoked without creating an instance of the class. + */ + unregisterDisposableObject(object: any): void; + /** + * Called by the Sys.Application.endUpdate method as a placeholder for additional logic. + */ + updated(): void; + + //#endregion + + //#region Properties + + /** + * Gets or sets a value that indicates whether the Web application supports history point management. + */ + get_enableHistory(): boolean; + /** + * Gets or sets a value that indicates whether the Web application supports history point management. + * @param value + * true to allow the Web application to support history points, or false to not allow history points. + */ + set_enableHistory(value: boolean): void; + /** + * Gets a value that indicates whether the application is in the process of creating components. This member is static and can be invoked without creating an instance of the class. + */ + get_isCreatingComponents(): boolean; + /** + * Gets a value that indicates whether the application is in the process of disposing its resources. This member is static and can be invoked without creating an instance of the class. + */ + get_isDisposing(): boolean; + + //#endregion + } + + /** + * Provides information about the current Web browser. + * @see {@link http://msdn.microsoft.com/en-us/library/cc679064(v=vs.100).aspx} + */ + class Browser { + + //#region Fields + + /** + * Gets an object that represents the user agent of the browser. + */ + agent: any; + /** + * Gets a value that indicates the document compatibility mode of the browser. + */ + documentMode: number; + /* + * Gets a value that indicates whether the browser supports debug statements. + */ + hasDebuggerStatement: boolean; + /** + * Gets the name of the browser. + */ + name: string; + /* + * Gets the version number of the browser. + */ + version: number; + + //#endregion + } + + class Component { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Events + + /** + * Raised when the dispose method is called for a component. + */ + add_disposing(handler: Function): void; + + remove_disposing(handler: Function): void; + + /** + * Raised when the raisePropertyChanged method of the current Component object is called. + */ + add_propertyChanged(handler: Function): void; + + remove_propertyChanged(handler: Function): void; + + //#endregion + + //#region Methods + + /** + * Called by the create method to indicate that the process of setting properties of a component instance has begun. + */ + beginUpdate(): void; + + /** + * Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. + * @param type + * The type of the component to create. + * @param properties + * (Optional) A JSON object that describes the properties and their values. + * @param events + * (Optional) A JSON object that describes the events and their handlers. + * @param references + * (Optional) A JSON object that describes the properties that are references to other components. + * @param element + * (Optional) The DOM element that the component should be attached to. + * + * @returns A new instance of a component that uses the specified parameters. + */ + create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Component; + + //#endregion + + //#region Properties + + //#endregion + } + + /** + * Provides debugging and tracing functionality for client ECMAScript (JavaScript) code. This class is static and can be invoked directly without creating an instance of the class. + */ + class Debug { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Methods + + assert(condition: boolean, message?: string, displayCaller?: boolean): void; + + /** + * Clears all trace messages from the trace console. + */ + clearTrace(): void; + + /** + * Displays a message in the debugger's output window and breaks into the debugger. + * @param message + * The message to display. + */ + fail(message: string): void; + + /** + * Appends a text line to the debugger console and to the trace console, if available. + * @param text + * The text to display. + */ + trace(text: string): void; + + /** + * Dumps an object to the debugger console and to the trace console, if available. + * @param object + * The object to dump. + * @param name + * (Optional) The name of the object. + */ + traceDump(object: any, name?: string): void; + + //#endregion + } + + //#region Event Args + + /** + * Provides a base class for classes that are used by event sources to pass event argument information. + */ + class EventArgs { + + //#region Constructors + + constructor(); + + //#endregion + + //#region Fields + + /** + * A static object of type EventArgs that is used as a convenient way to specify an empty EventArgs instance. + */ + Empty: EventArgs; + + //#endregion + + } + + /** + * Provides a class for command events. + */ + class CommandEventArgs extends EventArgs { + + //#region Constructors + + constructor(commandName: string, commandArgument: any, commandSource: any); + + //#endregion + + //#region Properties + + /** + * Gets a string that specifies the command name. + */ + get_commandName(): string; + + /** + * Gets a value that represents the command argument. + */ + get_commandArgument(): any; + + /** + * Gets a value that represents the command source. + */ + get_commandSource(): any; + + //#endregion + } + + /** + * Provides the base class for events that can be canceled. + */ + class CancelEventArgs extends EventArgs { + + //#region Properties + + /** + * true to request that the event be canceled; otherwise, false. The default is false. + */ + set_cancel(value: boolean): void; + + /* + * true to request that the event be canceled; otherwise, false. The default is false. + */ + get_cancel(): boolean; + + //#endregion + + } + + //#endregion + + //#region Exception Types + + /** + * Raised when a function or method is invoked and at least one of the passed arguments does not meet the parameter specification of the called function or method. + */ + class ArgumentException { + + } + /** + * Raised when an argument has an invalid value of null. + */ + class ArgumentNullException { + + } + /** + * Raised when an argument value is outside an acceptable range. + */ + class ArgumentOutOfRangeException { + + } + /** + * Raised when a parameter is not an allowed type. + */ + class ArgumentTypeException { + + } + /** + * Raised when an argument for a required method parameter is undefined. + */ + class ArgumentUndefinedException { + + } + /** + * + */ + class FormatException { + + } + /** + * Raised when a call to a method has failed, but the reason was not invalid arguments. + */ + class InvalidOperationException { + + } + /** + * Raised when a requested method is not supported by an object. + */ + class NotImplementedException { + + } + /** + * Raised when an invalid number of arguments have been passed to a function. + */ + class ParameterCountException { + + } + /** + * Raised by the Microsoft Ajax Library framework when a script does not load successfully. This exception should not be thrown by the developer. + */ + class ScriptLoadFailedException { + + } + + //#endregion + + //#region Sys.Net Namespace + + /** + * The Sys.Net namespace contains classes that manage communication between AJAX-enabled ASP.NET client applications and Web services on the server. For more information, see Using Web Services in ASP.NET AJAX. The Sys.Net namespace is part of the Microsoft Ajax Library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310860(v=vs.100).aspx} + */ + module Net { + + /** + * Provides the script API to make a Web request. + */ + class WebRequest { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.Net.WebRequest class. + */ + constructor(); + + //#endregion + + //#region Members + + /** + * Registers a handler for the completed request event of the Web request. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310841(v=vs.100).aspx} + */ + add_completed(handler: (reference: any, eventArgs: Sys.EventArgs) => void): void; + + /** + * Removes the event handler added by the add_completed method. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397454(v=vs.100).aspx} + */ + remove_completed(handler: (reference: any, eventArgs: Sys.EventArgs) => void): void; + + /** + * Gets the resolved URL of the Sys.Net.WebRequest instance. + * @returns The resolved URL that the Web request is directed to. + */ + getResolvedUrl(): string; + + /** + * Executes a Web request. + */ + invoke(): void; + + /** + * Raises the completed event for the associated Sys.Net.WebRequest instance. + * @param eventArgs + * The value to pass to the Web request completed event handler. + */ + completed(eventArgs: Sys.EventArgs): void; + + //#endregion + + } + } + + //#endregion + + //#region Sys.Serialization Namespace + + /** + * Contains classes related to data serialization for AJAX client functionality in ASP.NET. For more information, see Using Web Services in ASP.NET AJAX. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310840(v=vs.100).aspx} + */ + module Serialization { + + /** + * Serializes JavaScript types into JSON-formatted data and deserializes JSON-formatted data into JavaScript types + * The JavaScriptSerializer class contains only static methods. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310857(v=vs.100).aspx} + */ + class JavaScriptSerializer { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.Serialization.JavaScriptSerializer class. + */ + constructor(); + + //#endregion + + //#region Methods + + /** + * Converts an ECMAScript (JavaScript) object graph into a JSON string. This member is static and can be invoked without creating an instance of the class. + * @static + * @param value + * The JavaScript object graph to serialize. + * @exception Sys.ArgumentException + * value contains a value that cannot be serialized. + */ + static serialize(value: any): string; + + /** + * Converts a JSON string into an ECMAScript (JavaScript) object graph. This member is static and can be invoked without creating an instance of the class. + * @static + * @param value + * The JSON string to deserialize. + */ + static deserialize(value: string): any; + + //#endregion + } + } + + //#endregion + + //#region Sys.Services Namespace + + /** + * Contains types that provide script access in AJAX-enabled ASP.NET client applications to the ASP.NET authentication service, profile service, and other application services. + * The Sys.Services namespace is part of the Microsoft Ajax Library. + * For more information @{see Using Web Services in ASP.NET AJAX {@link http://msdn.microsoft.com/en-us/library/bb515101(v=vs.100).aspx}} + * @see {@link http://msdn.microsoft.com/en-us/library/bb311017(v=vs.100).aspx} + */ + module Services { + + /** + * Provides the client proxy class for the authentication service. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310861(v=vs.100).aspx} + */ + class AuthenticationService { + + } + + /** + * Defines a profile group. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} + */ + class ProfileGroup { + + } + + /** + * Provides the client proxy class for the role service. + * @see {@link http://msdn.microsoft.com/en-us/library/bb513880(v=vs.100).aspx} + */ + class RoleService { + + } + + /** + * Provides the client proxy class for the profile service. + * + */ + class ProfileService { + + } + + } + + //#endregion + + + //#region Sys.UI Namespace + + module UI { + + } + + //#endregion + +} + +//#endregion \ No newline at end of file From fc49b70da47c64d056f43f058aed95b21647e45c Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 9 Mar 2014 23:57:57 +0000 Subject: [PATCH 02/24] Added WebForms namespace. Added some preliminary classes from documentation. --- microsoft-ajax/microsoft.ajax.d.ts | 178 +++++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 76bc8da1f..1f991830d 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -889,6 +889,184 @@ declare module Sys { //#endregion + //#region Sys.WebForms Namespace + + module WebForms { + + /** + * Used by the beginRequest event of the PageRequestManager class to pass argument information to event handlers. + */ + class BeginRequestEventArgs extends EventArgs { + + } + + /** + * Used by the endRequest event of the PageRequestManager class to pass argument information to event handlers. + */ + class EndRequestEventArgs extends EventArgs { + + } + + /** + * Used by the initializeRequest event of the PageRequestManager class to pass argument information to event handlers. + */ + class InitializeRequestEventArgs extends EventArgs { + + } + + /** + * Used by the pageLoaded event of the PageRequestManager class to send event data that represents the UpdatePanel controls that were updated and created in the most recent postback. + */ + class PageLoadedEventArgs extends EventArgs { + + + } + + /** + * Used by the pageLoading event of the PageRequestManager class to send event data that represents the UpdatePanel controls that are being updated and deleted as a result of the most recent postback. + */ + class PageLoadingEventArgs extends EventArgs { + + } + + /** + * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. + */ + class PageRequestManager extends EventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.WebForms.PageRequestManager Class. + */ + constructor(); + + //#endregion + + //#region Events + + /** + * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. + * @param beginRequestHandler + * The name of the handler method that will be called. + */ + add_beginRequest(beginRequestHandler: (sender, args) => void): void; + + /** + * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. + * @param beginRequestHandler + * The handler method that will be removed. + */ + remove_beginRequest(beginRequestHandler: Function): void; + + + /** + * Raised after an asynchronous postback is finished and control has been returned to the browser. + * @param endRequestHandler + * The name of the handler method that will be called. + */ + add_endRequest(endRequestHandler: (sender, args) => void): void; + + /** + * Raised after an asynchronous postback is finished and control has been returned to the browser. + * @param endRequestHandler + * The name of the handler method that will be removed. + */ + remove_endRequest(endRequestHandler: (sender, args) => void): void; + + /** + * Raised during the initialization of the asynchronous postback. + * @param initializeRequestHandler + * The name of the handler method that will be called. + */ + add_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + + /** + * Raised during the initialization of the asynchronous postback. + * @param initializeRequestHandler + * The name of the handler method that will be called. + */ + remove_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + + /** + * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + add_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + + /** + * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + remove_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + + /** + * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + add_pageLoading(pageLoadingHandler: (sender, args) => void): void; + + /** + * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. + * @param pageLoadedHandler + * The name of the handler method that will be called. + */ + remove_pageLoading(pageLoadingHandler: (sender, args) => void): void; + + //#endregion + + //#region Methods + + /** + * Returns the instance of the PageRequestManager class for the page. + * @return The current instance of the PageRequestManager class. You do not create a new instance of the PageRequestManager class directly. Instead, an instance is available when partial-page rendering is enabled. + */ + getInstance(): PageRequestManager; + + /** + * Stops all updates that would occur as a result of an asynchronous postback. + * The abortPostBack method stops the currently executing postback. To cancel a new postback, provide an event handler for the initializeRequest event and use the cancel event of the Sys.CancelEventArgs class. + */ + abortPostBack(): void; + + /** + * Begins an asynchronous postback. + * @param updatePanelsToUpdate (Optional) An array of UniqueID values or ClientID values for UpdatePanel controls that must be re-rendered. + * @param eventTarget (Optional) A string that contains the target of the event. + * @param eventArgument (Optional) A string that contains an argument for the event. + * @param causesValidation (Optional) true to cause validation. + * @param validationGroup (Optional) A string that contains the name of the validation group. + */ + beginAsyncPostBack(updatePanelsToUpdate?: string[], eventTarget?: string, eventArgument?: string, causesValidation?: boolean, validationGroup?: string): void; + + /** + * Releases ECMAScript (JavaScript) resources and detaches events. + * the dispose method to free client resources. The PageRequestManager instance calls the dispose method during the window.unload event of the browser. + * If you call the dispose method and then reference members of the PageRequestManager class, an error occurs. In typical page developer scenarios, you do not have to call the dispose method. + */ + dispose(): void; + + //#endregion + + //#region Properties + + //#endregion + } + + //#region Exceptions + + + + //#endregion + + + } + + //#endregion + } //#endregion \ No newline at end of file From c27ec006092428e016e21e703238719e121e6194 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 10 Mar 2014 00:00:00 +0000 Subject: [PATCH 03/24] Formatting changes. --- microsoft-ajax/microsoft.ajax.d.ts | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 1f991830d..6847bb253 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -951,64 +951,54 @@ declare module Sys { * The name of the handler method that will be called. */ add_beginRequest(beginRequestHandler: (sender, args) => void): void; - /** * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. * @param beginRequestHandler * The handler method that will be removed. */ remove_beginRequest(beginRequestHandler: Function): void; - - /** * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be called. */ add_endRequest(endRequestHandler: (sender, args) => void): void; - /** * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be removed. */ remove_endRequest(endRequestHandler: (sender, args) => void): void; - /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ add_initializeRequest(initializeRequestHandler: (sender, args) => void): void; - /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ remove_initializeRequest(initializeRequestHandler: (sender, args) => void): void; - /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ add_pageLoaded(pageLoadedHandler: (sender, args) => void): void; - /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ remove_pageLoaded(pageLoadedHandler: (sender, args) => void): void; - /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ add_pageLoading(pageLoadingHandler: (sender, args) => void): void; - /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler @@ -1034,11 +1024,16 @@ declare module Sys { /** * Begins an asynchronous postback. - * @param updatePanelsToUpdate (Optional) An array of UniqueID values or ClientID values for UpdatePanel controls that must be re-rendered. - * @param eventTarget (Optional) A string that contains the target of the event. - * @param eventArgument (Optional) A string that contains an argument for the event. - * @param causesValidation (Optional) true to cause validation. - * @param validationGroup (Optional) A string that contains the name of the validation group. + * @param updatePanelsToUpdate + * (Optional) An array of UniqueID values or ClientID values for UpdatePanel controls that must be re-rendered. + * @param eventTarget + * (Optional) A string that contains the target of the event. + * @param eventArgument + * (Optional) A string that contains an argument for the event. + * @param causesValidation + * (Optional) true to cause validation. + * @param validationGroup + * (Optional) A string that contains the name of the validation group. */ beginAsyncPostBack(updatePanelsToUpdate?: string[], eventTarget?: string, eventArgument?: string, causesValidation?: boolean, validationGroup?: string): void; From fd32c98a5b13424bf5a5c5880ab639785884467f Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 10 Mar 2014 09:21:22 +0000 Subject: [PATCH 04/24] Added UI classes to the definitions Still need to add methods, properties, fields, events --- microsoft-ajax/microsoft.ajax.d.ts | 169 ++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 3 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 6847bb253..7a1fbaf96 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -297,6 +297,8 @@ declare function $create(type: Type, properties?: any, events?: any, references? */ declare function $find(id: string, parent?: Sys.Component): Sys.Component; + + //#endregion //#endregion @@ -381,11 +383,11 @@ declare module Sys { * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. * @return A Component object that contains the component requested by ID, if found; otherwise, null. */ - findComponent(id: string, parent?: Component): Component; + findComponent(id: string, parent?: Sys.Component): Sys.Component; /** * Returns an array of all components that have been registered with the application by using the addComponent method. This member is static and can be invoked without creating an instance of the class. */ - getComponents(): Component[]; + getComponents(): Sys.Component[]; /** * This function supports the client-script infrastructure and is not intended to be used directly from your code. */ @@ -525,7 +527,7 @@ declare module Sys { * * @returns A new instance of a component that uses the specified parameters. */ - create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Component; + create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; //#endregion @@ -883,8 +885,169 @@ declare module Sys { //#region Sys.UI Namespace + /** + * Contains types related to the user interface (UI), such as controls, events, and UI properties in the Microsoft Ajax Library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397431(v=vs.100).aspx} + */ module UI { + /** + * Provides a base class for all ASP.NET AJAX clientbehaviors. + */ + class Behavior extends Sys.Component { + + //#region Methods + + /** + * Gets a Sys.UI.Behavior instance with the specified name property from the specified HTML Document Object Model (DOM) element. This member a static member and can be invoked without creating an instance of the class. + * @return The specified Behavior object, if found; otherwise, null. + */ + static getBehaviorByName(element: Sys.UI.DomElement, name: string): Behavior; + /** + * Gets an array of Sys.UI.Behavior objects that are of the specified type from the specified HTML Document Object Model (DOM) element. This method is static and can be invoked without creating an instance of the class. + * @return An array of all Behavior objects of the specified type that are associated with the specified DOM element, if found; otherwise, an empty array. + */ + static getBehaviorsByType(element: Sys.UI.DomElement, type: Sys.UI.Behavior): Behavior[]; + /** + * Gets the Sys.UI.Behavior objects that are associated with the specified HTML Document Object Model (DOM) element. This member is static and can be invoked without creating an instance of the class. + * @param element + * The Sys.UI.DomElement object to search. + * @return An array of references to Behavior objects, or null if no references exist. + */ + static getBehaviors(element: DomElement): Behavior[]; + + /** + * Removes the current Behavior object from the application. + * The dispose method releases all resources from the Sys.UI.Behavior object, unbinds it from its associated HTML Document Object Model (DOM) element, and unregisters it from the application. + */ + dispose(): void; + + //#endregion + + //#region Properties + + /** + * Gets the HTML Document Object Model (DOM) element that the current Sys.UI.Behavior object is associated with. + * @return The DOM element that the current Behavior object is associated with. + */ + get_element(): Sys.UI.DomElement; + + /** + * Gets or sets the identifier for the Sys.UI.Behavior object. + * A generated identifier that consists of the ID of the associated Sys.UI.DomElement, the "$" character, and the name value of the Behavior object. + */ + get_id(): string; + + /** + * Gets or sets the identifier for the Sys.UI.Behavior object. + * @param value + * The string value to use as the identifier. + */ + set_id(value: string): void; + + /* + * Gets or sets the name of the Sys.UI.Behavior object. + * If you do not explicitly set the name property, getting the property value sets it to its default value, which is equal to the type of the Behavior object. The name property remains null until it is accessed. + * @param value + * A string value to use as the name. + */ + set_name(value: string): void; + + /** + * Gets or sets the name of the Sys.UI.Behavior object. + */ + get_name(): string; + + //#endregion + + } + /** + * Creates an object that contains a set of integer coordinates representing position, width, and height. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397698(v=vs.100).aspx} + */ + class Bounds { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.UI.Bounds class. + */ + constructor(); + + //#endregion + + //#region Fields + + /** + * Gets the height of an object in pixels. This property is read-only. + * @return A number that represents the height of an object in pixels. + */ + height: number; + + /** + * Gets the width of an object in pixels. This property is read-only. + * @return A number that represents the width of an object in pixels. + */ + width: number; + + /** + * Gets the x-coordinate of an object in pixels. + * @return A number that represents the x-coordinate of an object in pixels. + */ + x: number; + + /** + * Gets the y-coordinate of anobject in pixels. + * @return A number that represents the y-coordinate of an object in pixels. + */ + y: number; + + //#endregion + + } + /** + * Provides the base class for all all ASP.NET AJAX client controls. + */ + class Control extends Sys.Component { + + } + /** + * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. + */ + class DomElement { + + } + /** + * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. + */ + class DomEvent { + + } + /** + * Describes key codes. + */ + enum Key { + + } + /** + * Describes mouse button locations. + */ + enum MouseButton { + + } + /** + * Creates an object that contains a set of integer coordinates that represent a position. + */ + class Point { + + } + /** + * Describes the layout of a DOM element in the page when the element's visible property is set to false. + */ + enum VisibilityMode { + + } + } //#endregion From 950b2ece20a19063e0bbe8ffdaaf5f0710fdab6a Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Tue, 11 Mar 2014 09:26:35 +0000 Subject: [PATCH 05/24] Added Type definitions --- microsoft-ajax/microsoft.ajax.d.ts | 176 ++++++++++++++++++++++++++++- 1 file changed, 175 insertions(+), 1 deletion(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 7a1fbaf96..06da80605 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -268,6 +268,180 @@ declare class Type { * @returns A value of the class that the base method returns. If the base method does not return a value, no value is returned. */ callBaseMethod(instance: any, name: string, baseArguments?: any[]): any; + /** + * Creates a callback method, given the function to callback and the parameter to pass to it. + * @return + * The callback function. + * + * @param method + * The function for which the callback method will be created. + * @param context + * The parameter to pass to the function. This parameter can be null, but it cannot be omitted. + */ + static createCallback(method: Function, context: Object): Function; + /** + * Creates a delegate function that keeps the context from its creation. The context defines the object instance to which the this keyword points. + * @param instance + * The object instance that will be the context for the function. This parameter can be null. + * @param method + * The function from which the delegate is created. + * @return The delegate function. + */ + static createDelegate(instance: Object, method: Function): Function; + /** + * Returns the base implementation of a method from the base class of the specified instance. + * @param instance + * The instance for which the base method is requested. + * @param name + * The name of the method to retrieve as a reference. + */ + getBaseMethod(instance: Object, name: string): any; + /** + * Returns the base class of the instance. + * Use the getBaseType method to retrieve the base class of the instance. + */ + getBaseType(): Type; + /** + * Returns an Array object that contains the list of interfaces that the type implements. + * Use the getInterfaces function to return a list of objects that define the interfaces on a type object. + * This enables you to enumerate the array to determine the object's interfaces. + * + * @return An Array object that contains the list of interfaces that the type implements. + */ + getInterfaces(): any[]; + /** + * Returns the name of the type of the instance. + * @return A string representing the fully qualified name of the type of the instance. + * @example Object.getType(c[i]).getName() + */ + getName(): string; + /** + * Returns an Array object containing references to all the root namespaces of the client application. This method is static and is invoked without creating an instance of the object. + * Use the getRootNamespaces function to return an array containing references to all the root namespaces of the client application. + * @return An object containing references to all the root namespaces of the client application. + */ + static getRootNamespaces(): any; + /** + * Determines whether a class implements a specified interface type. + * @param interfaceType + * The interface to test. + * @return true if the class implements interfaceType; otherwise, false. + */ + implementsInterface(interfaceType: Type): boolean; + /** + * Determines whether an instance inherits from a specified class. + * @param parentType + * The fully qualified name of the class to test as a base class for the current instance. + * @return true if the instance inherits from parentType; otherwise, false. + */ + inheritsFrom(parentType: string); + /** + * Initializes the base class and its members in the context of a given instance, which provides the model for inheritance and for initializing base members. + * @param instance + * The instance to initialize the base class for. Usually this. + * @param baseArguments + * (Optional) The arguments for the base constructor. Can be null. + */ + initializeBase(instance: any, baseArguments?: any[]): any; + /** + * Returns a value that indicates whether the specified type is a class. This method is static and can be invoked without creating an instance of the object. + * @param type + * The type to test. + * @return true if the specified type is a class; otherwise, false. + */ + static isClass(type: any): boolean; + /** + * Indicates whether the specified type is an enumeration. + * @param type + * The type to test. + * @return true if the type is an enumeration; otherwise, false. + */ + static isEnum(type: any): boolean; + /** + * Get a value that indicates whether the specified type is an integer of flags. + * @param + * The type to test. + * @return true if the type is an integer of flags; otherwise, false. + */ + static isFlags(type: any): boolean; + /** + * Determines whether an instance implements an interface. + * @param typeInstanceVar + * The instance on which the interface is tested. + * @return + */ + isImplementedBy(typeInstanceVar: any): boolean; + /** + * Returns a value that indicates whether an object is an instance of a specified class or of one of its derived classes. + * @param instance + * The object to test. + * @return true if instance is an instance of the class; false if instance does not implement the interface, or if it is undefined or null. + */ + isInstanceOfType(instance: any): boolean; + /** + * Returns a value that indicates whether the specified type is an interface. This is a static member that is invoked directly without creating an instance of the class. + * @param type + * The type to test. + * @return true if the specified type is an interface; otherwise, false. + */ + static isInterface(type: any): boolean; + /** + * Returns a value that indicates whether the specified object is a namespace. This is a static member that is invoked directly without creating an instance of the class. + * @param object + * The object to test. + * @return true if the specified object is a namespace; otherwise, false. + */ + static isNamespace(object: any): boolean; + /** + * Returns an instance of the type specified by a type name. This is a static member that is invoked directly without creating an instance of its class. + * @param typeName + * A string that represents a fully qualified class name. Can be null. + * @param ns + * (Optional) The namespace that contains the class. + * @return The class represented by typeName, or null if a class that matches typeName does not occur in the namespace. + */ + static parse(typeName: string, ns?: string): any; + /** + * Registers a class as defined by a constructor with an optional base type and interface type. + * @param typeName + * A string that represents the fully qualified name of the type. + * @param baseType + * (Optional) The base type. + * @param interfaceTypes + * (Optional) An unbounded array of interface type definitions that the type implements. + * @return The registered type. + */ + registerClass(typeName: string, baseType?: any, interfaceTypes?: any[]): any; + /** + * Registers an enumeration. + * @param name + * The fully-qualified name of the enumeration. + * @param flags + * (Optional) true if the enumeration is a collection of flags; otherwise, false. + */ + registerEnum(name: string, flags?: boolean): void; + /** + * Registers an interface defined by a constructor. + * @param typeName + * A string that represents the fully qualified name of the class to be registered as an interface. + * @return The registered interface. + */ + registerInterface(typeName: string): any; + /** + * Creates a namespace. This member is static and can be invoked without creating an instance of the class. + * @param namespacePath + * A string that represents the fully qualified namespace to register. + */ + static registerNamespace(namespacePath: string): void; + /** + * Copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. This enables you to reflect on the inherited members of a derived type. + * Use the resolveInheritance method to reflect on the inherited members of a derived type. + * You invoke this method from the type that you want to reflect on. + * The resolveInheritance method copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. + * If the derived type overrides a base type member, the base type member is not copied to the derived type's prototype. + * After invoking a derived type's resolveInheritance method, you can examine the members of the derived type to discover all members, which includes inherited members. + */ + resolveInheritance(): void; } //#endregion @@ -1227,4 +1401,4 @@ declare module Sys { } -//#endregion \ No newline at end of file +//#endregion From e6904219b6f2962251640b78fb46621c203b8223 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 13 Mar 2014 08:40:43 +0000 Subject: [PATCH 06/24] Fixed some JSDocs and finished Component Added CultureInfo definition --- microsoft-ajax/microsoft.ajax.d.ts | 96 ++++++++++++++++++++++++++++-- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 06da80605..4084a803c 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1,4 +1,4 @@ -// Type definitions for microsoft asp.net ajax client side library +micro// Type definitions for microsoft asp.net ajax client side library // Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx // Definitions by: Patrick Magee // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -667,14 +667,18 @@ declare module Sys { * Raised when the dispose method is called for a component. */ add_disposing(handler: Function): void; - + /** + * Raised when the dispose method is called for a component. + */ remove_disposing(handler: Function): void; /** * Raised when the raisePropertyChanged method of the current Component object is called. */ add_propertyChanged(handler: Function): void; - + /** + * Raised when the raisePropertyChanged method of the current Component object is called. + */ remove_propertyChanged(handler: Function): void; //#endregion @@ -685,7 +689,6 @@ declare module Sys { * Called by the create method to indicate that the process of setting properties of a component instance has begun. */ beginUpdate(): void; - /** * Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. * @param type @@ -701,7 +704,33 @@ declare module Sys { * * @returns A new instance of a component that uses the specified parameters. */ - create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; + static create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; + /** + * Called by the create method to indicate that the process of setting properties of a component instance has finished. + * This method is called by the create method ($create). + * Sets the isUpdating property of the current Component object to false, calls the initialize method if it has not already been called, and then calls the updated method. + */ + endUpdate(): void; + /** + * Initializes the current Component object. + * The initialize method sets the isInitialized property of the current Component object to true. This function is called by the create method ($create) and overridden in derived classes to initialize the component. + */ + initialize(): void; + /** + * Raises the propertyChanged event for the specified property. + * @param propertyName + * The name of the property that changed. + */ + raisePropertyChanged(propertyName: string): void; + /** + * Called by the endUpdate method as a placeholder for additional logic in derived classes. + * Override the updated method in a derived class to add custom post-update logic. + */ + updated(): void; + /** + * Raises the disposing event of the current Component and removes the component from the application. + */ + dispose(): void; //#endregion @@ -710,6 +739,63 @@ declare module Sys { //#endregion } + /** + * Represents a culture definition that can be applied to objects that accept a culture-related setting. + */ + class CultureInfo { + + //#region Constructors + + /** + * Initializes a new instance of the Sys.CultureInfo class. + * @param name + * The culture value (locale) that represents a language and region. + * @param numberFormat + * A culture-sensitive numeric formatting string. + * @param dateTimeFormat + * A culture-sensitive date formatting string. + */ + constructor(name: string, numberFormat: string, dateTimeFormat: string); + + //#endregion + + //#region Properties + + /** + * Gets an object that contains an array of culture-sensitive formatting and parsing strings values that can be applied to Number type extensions. + * Use the numberFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture. + * Each formatting string can be used to specify how to format Number type extensions. + * @return An object that contains an array of culture-sensitive formatting strings. + */ + numberFormat: string[]; + /** + * Gets the culture value (locale) that represents a language and region. + * @return The culture value (locale) that represents a language and region. + */ + name: string; + /** + * Gets the globalization values of the invariant culture as sent by the server. This member is static and can be invoked without creating an instance of the class. + * The InvariantCulture field contains the following fields associated with the invariant (culture-independent) culture: name, dateTimeFormat, and numberFormat. + * @return A CultureInfo object. + */ + static InvariantCulture: CultureInfo; + /** + * Gets the globalization values of the current culture as sent by the server. This member is static and can be invoked without creating an instance of the class. + * The CurrentCulture field contains the following fields associated with the current culture: name, dateTimeFormat, and numberFormat. + * @return A Sys.CultureInfo object. + */ + static CurrentCulture: CultureInfo; + /** + * Gets an object that contains an array of culture-sensitive formatting and parsing string values that can be applied to Date type extensions. + * Use the dateTimeFormat field to retrieve an object that contains an array of formatting strings that are based on the current culture or on the invariant culture. + * Each formatting string can be used to specify how to format Date type extensions. + * @return An object that contains an array of culture-sensitive formatting strings. + */ + dateTimeFormat: string[]; + + //#endregion + } + /** * Provides debugging and tracing functionality for client ECMAScript (JavaScript) code. This class is static and can be invoked directly without creating an instance of the class. */ From d46fe63ef92f3598dadea9f328873029aacb99e1 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 13 Mar 2014 09:29:22 +0000 Subject: [PATCH 07/24] Sys classes added definitions need to be added. Added and defined IContainer interface, other interfaces need to be defined. --- microsoft-ajax/microsoft.ajax.d.ts | 111 +++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 5 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 4084a803c..4da78b840 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1,4 +1,4 @@ -micro// Type definitions for microsoft asp.net ajax client side library +// Type definitions for microsoft asp.net ajax client side library // Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx // Definitions by: Patrick Magee // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -472,7 +472,6 @@ declare function $create(type: Type, properties?: any, events?: any, references? declare function $find(id: string, parent?: Sys.Component): Sys.Component; - //#endregion //#endregion @@ -484,6 +483,9 @@ declare function $find(id: string, parent?: Sys.Component): Sys.Component; * @see {@link http://msdn.microsoft.com/en-us/library/bb397702(v=vs.100).aspx} */ declare module Sys { + + //#region Classes + /** * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} */ @@ -501,16 +503,25 @@ declare module Sys { * Raised after all scripts have been loaded but before objects are created. */ add_init(handler: Function): void; + /** + * Raised after all scripts have been loaded but before objects are created. + */ remove_init(handler: Function): void; /** * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. */ add_load(handler: Function): void; + /** + * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. + */ remove_load(handler: Function): void; /** * Occurs when the user clicks the browser's Back or Forward button. */ add_navigate(handler: Function): void; + /** + * Occurs when the user clicks the browser's Back or Forward button. + */ remove_navigate(handler: Function): void; //#endregion @@ -653,10 +664,16 @@ declare module Sys { //#endregion } + /** + * Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library. + */ class Component { //#region Constructors + /** + * When overridden in a derived class, initializes an instance of that class and registers it with the application as a disposable object. + */ constructor(); //#endregion @@ -841,6 +858,74 @@ declare module Sys { //#endregion } + + /** + * Describes a change in a collection. + */ + class CollectionChange { + // to define + } + + //#endregion + + //#region Interfaces + + /** + * Provides a common interface for all components that can contain other components. + */ + interface IContainer { + + /** + * Adds a Component object to the current container. + * Implement this method for an object that will contain one or more component objects in order to programmatically add components to that container. + * @param component + * The Component object to add. + */ + addComponent(component: Component): void; + /** + * Returns the specified Component instance. + * Implement this method for an object that will contain one or more component objects to access components within that container. + * @param id + * The ID of the Component object to search for. + * @return The Component instance with the specified ID. + */ + findComponent(id: string): Component; + /** + * Returns an array of all objects in the current container that inherit from Component. + * Implement this method for an object that will contain one or more component objects so that the components in that container are available. Types that implement this method should return a copy of the list of components so that modifying the array does not change the contents of the container. + * @return An array of all objects in the current container that inherit from Component. + */ + getComponents(): Component[]; + /** + * Removes a Component object from the current container. + * @param component + * The Component object to remove. + */ + removeComponent(component: Component): void; + } + + /** + * Provides a common interface for the application-defined tasks of closing, releasing, or resetting resources held by instances of a registered Microsoft Ajax Library class. + */ + interface IDisposable { + // to define + } + + /** + * Indicates that the type that implements the interface provides disposing notifications. + */ + interface INotifyDisposing { + // to define + } + + /** + * Defines the propertyChanged event. + */ + interface INotifyPropertyChange { + // to define + } + + //#endregion //#region Event Args @@ -868,6 +953,7 @@ declare module Sys { /** * Provides a class for command events. + * Event handlers can use the cancel property to cancel the operation in progress. The semantics of canceling an event depend on the event source. */ class CommandEventArgs extends EventArgs { @@ -902,6 +988,15 @@ declare module Sys { */ class CancelEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the CancelEventArgs class. + */ + constructor(); + + //#endregion + //#region Properties /** @@ -911,6 +1006,7 @@ declare module Sys { /* * true to request that the event be canceled; otherwise, false. The default is false. + * @return if the event is to be canceled; otherwise, false. */ get_cancel(): boolean; @@ -918,6 +1014,13 @@ declare module Sys { } + /** + * This class is used by the Sys.Application Class to hold event arguments for the navigate event. + */ + class HistoryEventArgs extends EventArgs { + + } + //#endregion //#region Exception Types @@ -951,7 +1054,7 @@ declare module Sys { */ class ArgumentUndefinedException { - } + } /** * */ @@ -1142,7 +1245,6 @@ declare module Sys { //#endregion - //#region Sys.UI Namespace /** @@ -1307,7 +1409,6 @@ declare module Sys { enum VisibilityMode { } - } //#endregion From 96bcc5b084e94ab2b4466478834d694676c183bb Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Fri, 14 Mar 2014 09:16:16 +0000 Subject: [PATCH 08/24] Added more defnitions and added @see JSDoc Including CollectionChange, Observer, Enumeration, IDisposable, INotifyDisposing, INotifyPropertyChanged including NotifyCollectionChangedEventArgs --- microsoft-ajax/microsoft.ajax.d.ts | 305 ++++++++++++++++++++++++++++- 1 file changed, 299 insertions(+), 6 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 4da78b840..ca4886125 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -487,6 +487,9 @@ declare module Sys { //#region Classes /** + * Provides a run-time object that exposes client events and manages client components that are registered with the application. + * The members of this object are available globally after the client application has been initialized. + * The members can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} */ class Application { @@ -666,6 +669,7 @@ declare module Sys { /** * Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397516(v=vs.100).aspx} */ class Component { @@ -758,6 +762,7 @@ declare module Sys { /** * Represents a culture definition that can be applied to objects that accept a culture-related setting. + * @see {@link http://msdn.microsoft.com/en-us/library/bb384004(v=vs.100).aspx} */ class CultureInfo { @@ -815,6 +820,7 @@ declare module Sys { /** * Provides debugging and tracing functionality for client ECMAScript (JavaScript) code. This class is static and can be invoked directly without creating an instance of the class. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397422(v=vs.100).aspx} */ class Debug { @@ -861,13 +867,238 @@ declare module Sys { /** * Describes a change in a collection. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393798(v=vs.100).aspx} */ class CollectionChange { - // to define + + //#region Constructors + + /** + * Creates a CollectionChange object based on the supplied parameters. + * @param action + * A NotifyCollectionChangedAction enumeration value. + * @param newItems + * (Optional) The items that were added when the action is add or replace. + * @param newStartingIndex + * (Optional) An integer that represents the index where new items have been inserted. + * @param oldItems + * (Optional) The items that were removed when the action is remove or replace. + * @param oldStartingIndex + * (Optional) An integer that represents the index where old items have been removed. + */ + constructor(action: NotifyCollectionChangedAction, newItems: any[], newStartingIndex: number, oldItems: any[], oldStartingIndex: number); + + //#endregion + + //#region Fields + + /** + * Gets a NotifyCollectionChangedAction object that contains the change action enumeration value. + * @return A NotifyCollectionChangedAction object. + */ + action: NotifyCollectionChangedAction; + /** + * @return An array of items that were added. + */ + newItems: any[]; + /** + * The index where new items have been inserted. + * @return An integer that represents the index where new items have been inserted. + */ + newStartingIndex: number; + /** + * The items that were removed when the NotifyCollectionChangedAction object is set to remove. + * @return An array containing the items that were removed. + */ + oldItems: any[]; + /** + * Gets the index where old items have been removed. + * @return An integer that represents the index where old items have been removed. + */ + oldStartingIndex: number; + + //#endregion } + /** + * Adds update and management functionality to target objects such as arrays, DOM elements, and objects. + * The Sys.Observer class is based on the Observer pattern. The Sys.Observer class maintains a list of interested dependents (observers) in a separate object (the subject). + * All methods that are contained in the Sys.Observer class are static. + * In order to be used with the Sys.Observer class, an object must be an object, array, or DOM element. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393710(v=vs.100).aspx} + */ + class Observer { + + //#region Methods + + /** + * Adds an item to the collection in an observable manner. + * @param target + * The array to which an item will be added. + * @param item + * The item to add. + */ + static add(target: any[], item): void; + + /** + * Adds an event handler to the target. + * @param target The array to which an event handler will be added. + * @param handler The event handler. + */ + static addCollectionChanged(target, handler: Function): void; + + /** + * Adds an observable event handler to the target. + * @param eventName A string that contains the event name. + * @param handler The added function. + */ + static addEventHandler(target, eventName: string, handler: Function): void; + + /** + * Adds a propertyChanged event handler to the target. + * @param target The object to observe. + * @param handler The function handler to add. + */ + static addPropertyChanged(target, handler: Function): void; + + /** + * Adds items to the collection in an observable manner. + * @param target The array to which items will be added. + * @param items The array of items to add. + */ + static addRange(target: any[], items: any[]): void; + + /** + * Begins the process of updating the target object. + * @param target The object to update. + */ + static beginUpdate(target: any): void; + + /** + * Clears the array of its elements in an observable manner. + * @param target The array to clear. + */ + static clear(target: any): void; + + /** + * Ends the process of updating the target object. + * @param target The object being updated. + */ + static endUpdate(target: any): void; + + /** + * Inserts an item at the specified index in an observable manner. + * @param target The array to which the item is inserted. + * @param index A number that represents the index where the item will be inserted. + * @param item The item to insert. + */ + static insert(target: any, index: number, item: any): void; + + /** + * Indicates that the target is being updated. + * @param target The target object to update. + * @return true if given target argument is currently updating; otherwise false. + */ + static isUpdating(target: any): boolean; + + /** + * Makes an object directly observable by adding observable methods to it. + * @param target The object, array, or DOM element to make observable. + * @return The observable object. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393633(v=vs.100).aspx} + */ + static makeObservable(target: any): any; + + /** + * Raises the collectionChanged event. + * @param target The collection to which an event is raised. + * @param changes A Sys.CollectionChange object that contains the list of changes that were performed on the collection since the last event. + */ + static raiseCollectionChanged(target: any[], changes: Sys.CollectionChange): void; + + /** + * Raises an observable event on the target. + * @param target The target object. + * @param eventName A string that contains the event name. + * @param eventArgs A Sys.EventArgs object used to pass event argument information. + */ + static raiseEvent(target: any, eventName: string, eventArgs: Sys.EventArgs): void; + + /** + * Raises a propertyChanged notification event. + * @param target The object to which an event is raised. + * @param propertyName The name of the property that changed. + */ + static raisePropertyChanged(target: any, propertyName: string): void; + + /** + * Removes the first occurrence of an item from the array in an observable manner. + * @param target The array to which the item will be removed. + * @param item The item to remove. + * @return true if the item is found in the array. Otherwise false. + */ + static remove(target: any[], item: any): boolean; + + /** + * Removes the item at the specified index from the array in an observable manner. + * @param target The array to which an item is removed. + * @param index A number that represents the index of the item to remove. + */ + static removeAt(target: any[], index: number): void; + + /** + * Removes the collectionChanged event handler from the target. + * @param target The array from which the collectionChanged event handler is removed. + * @param handler The function to remove. + */ + static removeCollectionChanged(target: any, handler: Function): void; + + /** + * Removes a propertyChanged event handler from the target. + * @param target The object to observe. + * @param handler The event handler to remove. + */ + static removeEventHandler(target: any, handler: Function): void; + + /** + * Sets a property or field on the target in an observable manner. + * The raisePropertyChanged method is called after the setValue method set the value of the target object property. + * @param target The object to which the property is set. + * @param propertyName A string that contains the name of the property or field to set. + * @param value The value to set. + */ + static setValue(target, propertyName, value): void; + + //#endregion + + } + + //#endregion + //#region Enumerations + + /** + * Describes how a collection has changed. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393774(v=vs.100).aspx} + */ + enum NotifyCollectionChangedAction { + /** + * The integer 0, indicating the changed action to the collection is add. + */ + add = 0, + /** + * The integer 1, indicating the changed action to the collection is remove. + */ + remove = 1, + /** + * The integer 2, indicating the changed action to the collection is reset. + */ + reset = 2 + } + + //#endregion + //#region Interfaces /** @@ -875,6 +1106,8 @@ declare module Sys { */ interface IContainer { + //#region Methods + /** * Adds a Component object to the current container. * Implement this method for an object that will contain one or more component objects in order to programmatically add components to that container. @@ -902,28 +1135,59 @@ declare module Sys { * The Component object to remove. */ removeComponent(component: Component): void; + + //#endregion } /** * Provides a common interface for the application-defined tasks of closing, releasing, or resetting resources held by instances of a registered Microsoft Ajax Library class. + * Implement the IDisposable interface to provide a common interface for closing or releasing resources held by instances of your registered Microsoft Ajax Library class. + * You register an interface by when you register the class by calling the Type.registerClass method. You specify IDisposable in the interfaceTypes parameter when you call Type.registerClass. */ interface IDisposable { - // to define + /** + * Releases resources held by an object that implements the Sys.IDisposable interface. + * Implement the dispose method to close or release resources held by an object, or to prepare an object for reuse. + */ + dispose(): void; } /** * Indicates that the type that implements the interface provides disposing notifications. + * Implement this interface if the class must notify other objects when it is releasing resources. The base component class already implements this interface. Therefore, typically this interface is already available. */ interface INotifyDisposing { - // to define + /** + * Occurs when an object's resources are released. + * @param handler + * The name of the event handler for the disposing event. + */ + add_disposing(handler: Function): void; + /** + * Occurs when an object's resources are released. + * @param handler + * The name of the event handler for the disposing event. + */ + remove_disposing(handler: Function): void; } /** * Defines the propertyChanged event. */ interface INotifyPropertyChange { - // to define - } + /** + * Occurs when a component property is set to a new value. + * @param handler + * The name of the event handler for the propertyChanged event. + */ + add_propertyChanged(handler: Function): void; + /** + * Occurs when a component property is set to a new value. + * @param handler + * The name of the event handler for the propertyChanged event. + */ + remove_propertyChanged(handler: Function): void; + } //#endregion @@ -1021,6 +1285,35 @@ declare module Sys { } + /** + * Describes how the collection was changed. + */ + class NotifyCollectionChangedEventArgs extends EventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the CancelEventArgs class. + * @param changes + * A CollectionChange object that contains an array of changes that were performed on the collection since the last event. + */ + constructor(changes: CollectionChange); + + //#endregion + + + //#region Properties + + /** + * Gets an array of changes that were performed on the collection since the last event. + * @return An array of CollectionChange objects that were performed on the collection since the last event. + */ + get_changes(): CollectionChange[]; + + //#endregion + + } + //#endregion //#region Exception Types @@ -1254,7 +1547,7 @@ declare module Sys { module UI { /** - * Provides a base class for all ASP.NET AJAX clientbehaviors. + * Provides a base class for all ASP.NET AJAX client behaviors. */ class Behavior extends Sys.Component { From 6ad82f88bd68d2bd13e0b29981abfbe1edc7a38a Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 17 Mar 2014 08:41:09 +0000 Subject: [PATCH 09/24] Added more definitions from the documentation Mainly in the Sys Namespace. --- microsoft-ajax/microsoft.ajax.d.ts | 269 ++++++++++++++++++++++++++++- 1 file changed, 266 insertions(+), 3 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index ca4886125..89eaeddd6 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1072,7 +1072,217 @@ declare module Sys { //#endregion } - + + /** + * Provides static, culture-neutral exception messages that are used by the Microsoft Ajax Library framework. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397705(v=vs.100).aspx} + * This type supports the .NET Framework infrastructure and is not intended to be used directly from your code. + */ + class Res { + + //#region Fields + + /** + * @return "Actual value was {0}." + */ + actualValue: string; + /** + * @return "The application failed to load within the specified time out period." + */ + appLoadTimedout: string; + /** + * @return "Value does not fall within the expected range." + */ + argument: string; + /** + * @return "Value cannot be null." + */ + argumentNull: string; + /** + * @return "Specified argument was out of the range of valid values. + */ + argumentOutOfRange: string; + /** + * @return "Object cannot be converted to the required type." + */ + argumentType: string; + /** + * @return "Object of type '{0}' cannot be converted to type '{1}'." + */ + argumentTypeWithTypes: string; + /** + * @return "Value cannot be undefined." + */ + argumentUndefined: string; + /** + * @return "Assertion Failed: {0}" + */ + assertFailed: string; + /** + * @return "Assertion Failed: {0}\r\nat {1}" + */ + assetFailedCaller: string; + /** + * @return "Base URL does not contain ://." + */ + badBaseUrl1: string; + /** + * @return "Base URL does not contain another /." + */ + badBaseUrl2: string; + /** + * @return "Cannot find last / in base URL." + */ + badBaseUrl3: string; + /** + * @return "{0}\r\n\r\nBreak into debugger?" + */ + breakIntoDebugger: string; + /** + * @return "Cannot abort when executor has not started." + */ + cannotAbortBeforeStart: string; + /** + * @return "Cannot call {0} when responseAvailable is false." + */ + cannotCallBeforeResponse: string; + /** + * @return "Cannot call {0} once started." + */ + cannotCallOnceStarted: string; + /** + * @return "Cannot call {0} outside of a completed event handler." + */ + cannotCallOutsideHandler: string; + /** + * @return "Cannot deserialize empty string." + */ + cannotDeserializeEmptyString: string; + /** + * @return "Cannot serialize non-finite numbers." + */ + cannotSerializeNonFiniteNumbers: string; + /** + * @return "The id property can't be set on a control." + */ + controlCantSetId: string; + /** + * @return "'{0}' is not a valid value for enum {1}." + */ + enumInvalidValue: string; + /** + * @return "Handler was not added through the Sys.UI.DomEvent.addHandler method. + */ + eventHandlerInvalid: string; + /** + * @return "One of the identified items was in an invalid format." + */ + format: string; + /** + * @return "The string was not recognized as a valid Date." + */ + formatBadDate: string; + /** + * @return "Format specifier was invalid." + */ + formatBadFormatSpecifier: string; + /** + * @return "Input string was not in a correct format." + */ + formatInvalidString: string; + /** + * @return "Could not create a valid Sys.Net.WebRequestExecutor from: {0}." + */ + invalidExecutorType: string; + /** + * @return "httpVerb cannot be set to an empty or null string." + */ + invalidHttpVerb: string; + /** + * @return "Operation is not valid due to the current state of the object." + */ + invalidOperation: string; + /** + * @return "Value must be greater than or equal to zero." + */ + invalidTimeout: string; + /** + * @return "Cannot call invoke more than once." + */ + invokeCalledTwice: string; + /** + * @return "The method or operation is not implemented." + */ + notImplemented: string; + /** + * @return "Cannot call executeRequest with a null webRequest." + */ + nullWebRequest: string; + + //#endregion + } + + /** + * Provides a mechanism to concatenate strings. + * The StringBuilder class represents a mutable string of characters and provides a mechanism to concatenate a sequence of strings. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310852(v=vs.100).aspx} + */ + class StringBuilder { + + //#region Constructors + + /** + * Creates a new instance of StringBuilder and optionally accepts initial text to concatenate. You can specify a string in the optional initialText parameter to initialize the value of the StringBuilder instance. + * @param initialText + * (Optional) The string that is used to initialize the value of the instance. If the value is null, the new StringBuilder instance will contain an empty string (""). + */ + constructor(initialText?: string); + + //#endregion + + //#region Methods + + /** + * Appends a copy of a specified string to the end of the Sys.StringBuilder instance. + * Use the append method to append a copy of a specified string to the end of a StringBuilder instance. If text is an empty string, null, or undefined, the StringBuilder instance remains unchanged. + * @param text + * The string to append to the end of the StringBuilder instance. + */ + append(text: string): void; + + /** + * Appends a string with a line terminator to the end of the Sys.StringBuilder instance. + * Use the appendLine method to append a specified string and a line terminator to the end of a Stringbuilder instance. The line terminator is a combination of a carriage return and a newline character. If no string is specified in text, only the line terminator is appended. + * @param text + * (Optional) The string to append with a line terminator to the end of the StringBuilder instance. + */ + appendLine(text: string): void; + + /** + * Clears the contents of the Sys.StringBuilder instance. + * Use the clear method to clear the StringBuilder instance of its current contents. + */ + clear(): void; + + /** + * Determines whether the Sys.StringBuilder object has content. + * Use the isEmpty method to determine whether a StringBuilder instance has any content. If you append an empty string, null, or an undefined value to an empty StringBuilder instance, the instance remains empty and unchanged. + * @return true if the StringBuilder instance contains no elements; otherwise, false. + */ + isEmpty(): boolean; + + /** + * Creates a string from the contents of a Sys.StringBuilder instance, and optionally inserts a delimiter between each element of the created string. + * Use the toString method to create a string from the contents of a StringBuilder instance. Use the toString method with the optional separator parameter to insert a specified string delimiter between each element of the created string. + * @param separator + * (Optional) A string to append between each element of the string that is returned. + * @return A string representation of the StringBuilder instance. If separator is specified, the delimiter string is inserted between each element of the returned string. + */ + toString(separator: string): string; + toString(): string; + + //#endregion + } //#endregion @@ -1195,6 +1405,7 @@ declare module Sys { /** * Provides a base class for classes that are used by event sources to pass event argument information. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383795(v=vs.100).aspx} */ class EventArgs { @@ -1218,6 +1429,7 @@ declare module Sys { /** * Provides a class for command events. * Event handlers can use the cancel property to cancel the operation in progress. The semantics of canceling an event depend on the event source. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393715(v=vs.100).aspx */ class CommandEventArgs extends EventArgs { @@ -1249,6 +1461,7 @@ declare module Sys { /** * Provides the base class for events that can be canceled. + * @see {@link http://msdn.microsoft.com/en-us/library/bb311009(v=vs.100).aspx} */ class CancelEventArgs extends EventArgs { @@ -1280,13 +1493,35 @@ declare module Sys { /** * This class is used by the Sys.Application Class to hold event arguments for the navigate event. + * @see {@link http://msdn.microsoft.com/en-us/library/cc488008(v=vs.100).aspx} */ class HistoryEventArgs extends EventArgs { + //#region Constructors + + /** + * For a live code example that demonstrates this event in action, and for a view of how this event is used in code, see Managing Browser History Using Client Script. + * @param state Object. A collection of key/value pairs that represent the state data. This data will be added to the main state to form the global state of the new history point. + */ + constructor(state: any); + + //#endregion + + //#region Methods + + /** + * Object. A collection of name/value pairs that represent the state of a Web page. + * The state object stores the data that is required in order to restore a Web page to a specified application state. + * @return Object. A collection of name/value pairs that represent the state of a Web page. + */ + get_State(): any; + + //#endregion } /** * Describes how the collection was changed. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393665(v=vs.100).aspx} */ class NotifyCollectionChangedEventArgs extends EventArgs { @@ -1301,7 +1536,6 @@ declare module Sys { //#endregion - //#region Properties /** @@ -1311,7 +1545,36 @@ declare module Sys { get_changes(): CollectionChange[]; //#endregion - + } + + /** + * Used by the propertyChanged event to indicate which property has changed. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310957(v=vs.100).aspx} + */ + class PropertyChangedEventArgs extends EventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the PropertyChangedEventArgs class. + * @param propertyName + * The name of the property that changed. + */ + constructor(propertyName: string); + + //#endregion + + //#region Methods + + /** + * Gets the name of the property that changed. + * Use the propertyName property to determine the name of the property that changed. + * @return A string that contains the name of the property that changed. + */ + propertyName(): string; + + + //#endregion } //#endregion From cdc76877d4a8d042a76b97dd09086d1ce3baa7a2 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 17 Mar 2014 09:11:53 +0000 Subject: [PATCH 10/24] Added BeginRequestEventArgs defintion --- microsoft-ajax/microsoft.ajax.d.ts | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 89eaeddd6..357bfd2b9 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1971,13 +1971,55 @@ declare module Sys { //#region Sys.WebForms Namespace + /** + * The Sys.WebForms namespace contains classes related to partial-page rendering in the Microsoft Ajax Library. + */ module WebForms { /** * Used by the beginRequest event of the PageRequestManager class to pass argument information to event handlers. + * @see {@link http://msdn.microsoft.com/en-us/library/bb384003(v=vs.100).aspx} */ class BeginRequestEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the BeginRequestEventArgs class. + * @param request + * A Sys.Net.WebRequest representing the web request for the EventArgs. + * @param postBackElement + * The postback element that initiated the async postback. + * @param updatePanelsToUpdate + * (Optional) A list of UniqueIDs for UpdatePanel controls that are requested to update their rendering by the client. Server-side processing may update additional UpdatePanels. + */ + constructor(request: Sys.Net.WebRequest, postBackElement: any, updatePanelsToUpdate: string[]); + + //#endregion + + //#region Properties + + /** + * Gets the postback element that initiated the asynchronous postback. This property is read-only. + * @readonly + * @return An HTML DOM element. + */ + get_postBackElement(): HTMLElement; + + /** + * Gets the request object that represents the current postback. + * @return An instance of the Sys.Net.WebRequest class. + */ + get_request(): Sys.Net.WebRequest; + + /** + * Gets a list of UniqueID values for UpdatePanel controls that should re-render their content, as requested by the client. + * Server-side processing might update additional UpdatePanel controls. + * @return An array of UniqueID values for UpdatePanel controls. + */ + get_updatePanelsToUpdate(): string[]; + + //#endregion } /** @@ -1985,6 +2027,8 @@ declare module Sys { */ class EndRequestEventArgs extends EventArgs { + + } /** From 44446bfc6cea44b585f0f3a66dc53b7da00658d1 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Tue, 18 Mar 2014 09:20:15 +0000 Subject: [PATCH 11/24] Added more definitions --- microsoft-ajax/microsoft.ajax.d.ts | 240 ++++++++++++++++++++++++++++- 1 file changed, 237 insertions(+), 3 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 357bfd2b9..d1bb1098b 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1767,18 +1767,173 @@ declare module Sys { /** * Provides the client proxy class for the authentication service. + * The AuthenticationService class is a singleton; it has only one instance with a global point of access. + * It is always available to your application and you do not have to instantiate it. + * The AuthenticationService class provides script access to user authentication. + * It calls methods of the authentication service through the same infrastructure used to call any other Web service method. * @see {@link http://msdn.microsoft.com/en-us/library/bb310861(v=vs.100).aspx} */ class AuthenticationService { + //#region Constructors + + /** + * Initializes a new instance of the Sys.Services.AuthenticationService class. + */ + constructor(); + + //#endregion + + //#region Fields + + /** + * Specifies the path of the default authentication service. + */ + DefaultWebServicePath: string; + + //#endregion + + //#region Methods + + /** + * Authenticates the user's credentials. + * @param userName (required) The user name to authenticate. + * @param password + * The user's password. The default is null. + * @param isPersistent + * true if the issued authentication ticket should be persistent across browser sessions; otherwise, false. The default is false. + * @param redirctUrl + * The URL to redirect the browser to on successful login. The default is null. + * @param customInfo + * + * @param loginCompletedCallback + * The function to call when the login has finished successfully. The default is null. + * @param failedCallback + * The function to call if the login fails. The default is null. + * @param userContext + * User context information that you are passing to the callback functions. + * @exception Sys.ArgumentNullException - username is null. + */ + login(userName: string, password: string, isPersistent: boolean, customInfo: any, redirectUrl: string, loginCompletedCallback: Function, failedCallback: Function, userContext: any): void; + + /** + * Logs out the currently authenticated user. + * + * If redirectUrl is null or is an empty string, the page is redirected to itself after the call to the authentication Web service finishes and the completed callback function is called. + * This makes sure that any user-related data is cleared from the page. If redirectUrl is not null or is a non-empty string, the page is redirected to the specified URL after a successful call to the Web service. + * This URL can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path. + * If the call to the Web service fails, the page is not redirected or refreshed. Instead, the failed callback function is called. + * + * @param redirectUrl + * The URL to redirect the browser to on successful logout. The default is null. + * @param logoutCompletedCallback + * The function that is called when the logout has finished. The default is null. + * @param failedCallback + * The function that is called if the logout has failed. The default is null. + * @param userContext + * User context information that you are passing to the callback functions. + */ + logout(redirectUrl: string, logoutCompletedCallback: Function, failedCallback: Function, userContext: any): void; + + //#endregion + + //#region Properties + + /** + * Gets or sets the name of the default failure callback function. + */ + get_defaultFailedCallback(): Function; + + /** + * Gets or sets the name of the default failure callback function. + * @param value + * A string that contains the name of the default failure callback function. + */ + set_defaultFailedCallback(value: string): void; + + /** + * Gets or sets the default succeeded callback function for the service. + * @return A reference to the succeeded callback function for the service. + */ + defaultSucceededCallback(): Function; + + /** + * Gets or sets the default succeeded callback function for the service. + * @param value + * A reference to the succeeded callback function for the service. + */ + defaultSucceededCallback(value: Function): void; + + /** + * Gets or sets the default user context for the service. + * @return A reference to the user context for the service. + */ + defaultUserContext(): Object + + /** + * Gets or sets the default user context for the service. + * @param value + * A reference to the user context for the service. + */ + defaultUserContext(value: Object): void; + + /** + * Gets the authentication state of the current user. + * The value of this property is set by the ScriptManager object during a page request. + * @return true if the current user is logged in; otherwise, false. + */ + get_isLoggedIn(): boolean; + + + /** + * Gets or sets the authentication service path. + * You usually set the path property in declarative markup. This value can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path. + * By default, the path property is set to an empty string. If you do not set the path property, the internal default path is used, which points to the built-in authentication service. + * @param value + * The authentication service path. + */ + set_path(value: string); + + /** + * Gets or sets the authentication service path. + * By default, the path property is set to an empty string. If you do not set the path property, the internal default path is used, which points to the built-in authentication service. + */ + get_path(): string; + + /** + * Gets or sets the authentication service time-out value. + * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. + * By setting a time-out interval, you can make sure that a pending request returns based on a time interval that you specify, instead of waiting for the asynchronous communication layer to time out. + * @param value + * The time-out value in milliseconds. + */ + set_timeout(value): void; + + /** + * Gets or sets the authentication service time-out value. + * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. + * The timeout in milliseconds + */ + get_timeout(): number; + + //#endregion } /** * Defines a profile group. + * The ProfileGroup class defines the type of an element as a group in the properties collection of the Sys.Services.ProfileService class. + * Profile group properties are accessed as subproperties of the related group, as shown in the following ECMAScript (JavaScript) example: * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} */ class ProfileGroup { + /** + * Initializes a new instance of the Sys.Services.ProfileGroup class. + * @param properties + * (Optional) An object that contains the settings for this profile group. This parameter can be null. + */ + constructor(properties: Object); + } /** @@ -1791,7 +1946,7 @@ declare module Sys { /** * Provides the client proxy class for the profile service. - * + * @see {@link http://msdn.microsoft.com/en-us/library/bb383800(v=vs.100).aspx} */ class ProfileService { @@ -1973,6 +2128,7 @@ declare module Sys { /** * The Sys.WebForms namespace contains classes related to partial-page rendering in the Microsoft Ajax Library. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397566(v=vs.100).aspx} */ module WebForms { @@ -2024,11 +2180,59 @@ declare module Sys { /** * Used by the endRequest event of the PageRequestManager class to pass argument information to event handlers. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397499.aspx} */ class EndRequestEventArgs extends EventArgs { - + /** + * Initializes a new instance of the EndRequestEventArgs class. + * @param error + * An error object. + * @param dataItems + * An object containing data items. + * @param response + * An object of type Sys.Net.WebRequestExecutor. + */ + constructor(error: Error, dataItems: any, response: Sys.Net.WebRequestExecutor); + + //#region Properties + + /** + * Gets a JSON data structure that contains data items that were registered by using the RegisterDataItem method of the ScriptManager class. + * The JavaScript Error object exposes several properties that define the error. The Microsoft Ajax Library provides additional functions for the Error object. + * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. + */ + get_dataItems(): any; + + /** + * Gets the Error object. + * @return A base ECMAScript (JavaScript) Error object. + */ + get_error(): Error; + + /** + * Get or sets a value that indicates whether the error has been handled. + * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. + * @return true if the error has been handled; otherwise false. + */ + get_errorHandled(): boolean; + + /** + * Get or sets a value that indicates whether the error has been handled. + * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. + * @param value + * true or false. + */ + set_errorHandled(value: boolean): void; + + /** + * Gets a response object that is represented by the Sys.Net.WebRequestExecutor class. + * @return A response object that is represented by the WebRequestExecutor class. + */ + get_response(): any; // todo + + //#endregion } /** @@ -2175,9 +2379,39 @@ declare module Sys { //#endregion } - //#region Exceptions + //#region Exceptions: Defines exceptions that can occur during partial-page updates. + /** + * Raised when an error occurs while processing the response from the server. + * If the response to an asynchronous postback returns without an error but there is an error processing the response in the client, the Sys.WebForms.PageRequestManagerParserErrorException is raised. + * For information about how to handle this error condition, see Debugging and Tracing Ajax Applications Overview. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} + */ + class PageRequestManagerParserErrorException { + } + + /** + * Raised when an error occurs on the server. + * If an error occurs on the server while the request is being processed, an error response is returned to the browser and the Sys.WebForms.PageRequestManagerServerErrorException exception is raised. + * To customize error handling and to display more information about the server error, handle the AsyncPostBackError event and use the AsyncPostBackErrorMessage and AllowCustomErrorsRedirect properties. + * For an example of how to provide custom error handling during partial-page updates, see Customizing Error Handling for ASP.NET UpdatePanel Controls. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} * + */ + class PageRequestManagerServerErrorException { + + } + + /** + * Raised when the request times out. + * A partial-page update is initiated by a client request (an asynchronous postback) to the server. The server processes the request and returns a response to the client. + * If the browser does not receive a response in a specified time, the Sys.WebForms.PageRequestManagerTimeoutException is raised. + * To change the interval that elapses before asynchronous postbacks time out, set the AsyncPostBackTimeout property of the ScriptManager control. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} + */ + class PageRequestManagerTimeoutException { + + } //#endregion From 25a829db98b4b29f055a52de62d5e7a8b5d32249 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Wed, 19 Mar 2014 09:11:48 +0000 Subject: [PATCH 12/24] Added WebRequestExecutor definitions --- microsoft-ajax/microsoft.ajax.d.ts | 112 +++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index d1bb1098b..abeb345bd 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1654,6 +1654,7 @@ declare module Sys { /** * Provides the script API to make a Web request. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310979(v=vs.100).aspx} */ class WebRequest { @@ -1701,6 +1702,117 @@ declare module Sys { //#endregion } + + /** + * Provides the abstract base class from which network executors derive. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397434(v=vs.100).aspx} + */ + class WebRequestExecutor { + + //#region Constructors + + /** + * Initializes a Sys.Net.WebRequestExecutor instance when implemented in a derived class. + */ + constructor(); + + //#endregion + + //#region Methods + + /** + * Stops the pending network request issued by the executor. + * The specifics of aborting a request vary depending on how an executor is implemented. + * However, all executors that derive from WebRequestExecutor must set their state to aborted and must raise the completed event of the associated Sys.Net.WebRequest object. + * The executor properties do not contain consistent data after abort has been called. + */ + abort(): void; + /** + * Instructs the executor to execute a Web request. + * When this method is called, the executor packages the content of the Web request instance and initiates processing. + * This method is intended to be used by a custom executor. If you are implementing a custom executor, you instantiate the executor, assign it to the Web request instance, and then invoke the method on the executor instance. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383834(v=vs.100).aspx} + */ + executeRequest(): void; + /** + * Gets all the response headers for the current request. + * If a request finished successfully and with valid response data, this method returns all the response headers. + * @return All the response headers + * @see {@link http://msdn.microsoft.com/en-us/library/bb310805(v=vs.100).aspx} + */ + getAllResponseHeaders(): string; + /** + * Gets the value of the specified response header. + * @return The specified response header. + */ + getResponseHeader(): string; + + //#endregion + + //#region Properties + + /** + * Gets the JSON-evaluated object from the response. + * @return The JSON-evaluated response object. + */ + object(): any; + /** + * Gets a value indicating whether the request associated with the executor was aborted. + * When the current instance of the Sys.Net.WebRequestExecutor class is aborted, it must set its state to aborted and it must raise the completed event of the associated request object. + * @return true if the request associated with the executor was aborted; otherwise, false. + */ + get_aborted(): boolean; + /** + * Gets a value indicating whether the request completed successfully. + * Successful completion usually means a well-formed response was received by the executor. + * If a response was received, the current instance of the Sys.Net.WebRequestExecutor class must set its state to completed. + * It must also raise the completed event of the associated request object. + * @return true if the request completed successfully; otherwise, false. + */ + get_responseAvailable(): boolean; + /** + * Gets the text representation of the response body. When a request has completed successfully with valid response data, this property returns the text that is contained in the response body. + * @return The text representation of the response body. + */ + get_responseData(): string; + /** + * Returns a value indicating whether the executor has started processing the request. + * The executor returns true if substantial processing of the request has started. For executors that make network calls, substantial processing means that a network call has been started. + * @return true if the executor has started processing the request; otherwise, false. + */ + get_started(): boolean; + /** + * Gets a success status code. + * The statusCode property returns an integer that specifies that a request completed successfully and with valid response data. + * @return An integer that represents a status code. + */ + get_statusCode(): number; + /** + * Gets status information about a request that completed successfully. + * The statusText property returns status information if a request completed successfully and with valid response data. + * @return the status text + */ + get_statusText(): string; + /** + * Gets a value indicating whether the request timed out. + * Executors use the time-out information associated with the request to raise the completed event on the associated WebRequest object. + * @return true if the request timed out; otherwise, false. + */ + get_timedOut(): boolean; + /** + * Attempts to get the response to the current request as an XMLDOM object. + * If a request finished successfully with valid response data, this method tries to get the response as an XMLDOM object. + */ + get_xml(): XMLDocument; + /** + * Gets the WebRequest object associated with the executor. + * @return The WebRequest object associated with the current executor instance. + */ + get_webRequest(): Sys.Net.WebRequest; + + //#endregion + } + } //#endregion From c5fcfbfc87d283fa695df5f15e33a22508e12141 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 20 Mar 2014 08:43:43 +0000 Subject: [PATCH 13/24] EventArg type definitions --- microsoft-ajax/microsoft.ajax.d.ts | 121 ++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index abeb345bd..0eb400641 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -2296,6 +2296,8 @@ declare module Sys { */ class EndRequestEventArgs extends EventArgs { + //#region Constructors + /** * Initializes a new instance of the EndRequestEventArgs class. * @param error @@ -2307,6 +2309,7 @@ declare module Sys { */ constructor(error: Error, dataItems: any, response: Sys.Net.WebRequestExecutor); + //#endregion //#region Properties @@ -2349,24 +2352,140 @@ declare module Sys { /** * Used by the initializeRequest event of the PageRequestManager class to pass argument information to event handlers. + * This class contains private members that support the client-script infrastructure and are not intended to be used directly from your code. Names of private members begin with an underscore ( _ ). + * @see {@link http://msdn.microsoft.com/en-us/library/bb311030(v=vs.100).aspx} */ class InitializeRequestEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the EndRequestEventArgs class. + * @param request + * A Sys.Net.WebRequest object that represents the Web request for the EventArgs object. + * @param datapostBackElementItems + * The postback element that initiated the asynchronous postback. + * @param updatePanelsToUpdate + * (Optional) A list of UniqueID values for UpdatePanel controls that are being requested to update their rendering by the client. Server-side processing might update additional UpdatePanel controls. + */ + constructor(request: Sys.Net.WebRequest, postBackElement: any, updatePanelsToUpdate: string[]); + + //#endregion + + //#region Properties + + /** + * Gets the postback element that initiated the asynchronous postback. + * @return An HTML DOM element. + */ + get_postBackElement(): HTMLElement; + + /** + * Gets the request object that represents the current postback. + * @return A request object that is represented by the Sys.Net.WebRequestExecutor class. + */ + get_request(): Sys.Net.WebRequestExecutor; + + /** + * Gets or sets a list of UniqueID values for UpdatePanel controls that should re-render their content, as requested by the client. + * The returned array can be modified by a client event handler to add or remove UpdatePanel controls that should re-render their content dynamically. Server processing can also modify the array. + * @return An array of UniqueID values for UpdatePanel controls. + */ + get_updatePanelsToUpdate(): string[]; + + //#endregion + } /** * Used by the pageLoaded event of the PageRequestManager class to send event data that represents the UpdatePanel controls that were updated and created in the most recent postback. + * @see {@link http://msdn.microsoft.com/en-us/library/bb397476(v=vs.100).aspx} */ class PageLoadedEventArgs extends EventArgs { - + //#region Constructors + + /** + * Initializes a new instance of the PageLoadedEventArgs class. + */ + constructor(); + + //#endregion + + //#region Properties + + /** + * Gets a JSON data structure that contains data items that were registered by using the RegisterDataItem method of the ScriptManager class. + * A page or control must be in partial-page rendering mode to register data items that use the RegisterDataItem method of the ScriptManager class + * Use the IsInAsyncPostBack property to check whether the page is in partial-page rendering mode.The dataItems property returns a JSON data structure that contains name/value pairs. + * The name is the unique ID of the control that is used in the control parameter of the RegisterDataItem method. The value is the dataItem parameter of the RegisterDataItem method. + * + * @return A JSON data structure that contains name/value pairs that were registered as data items that use the RegisterDataItem method of the ScriptManager class. + */ + get_dataItems(): any; + /** + * Gets an array of HTML div elements that represent UpdatePanel controls that were created when the DOM was updated during the last asynchronous postback. + * If an UpdatePanel control is updated as a result of a partial-page update, the array referenced in the panelsCreated property of the PageLoadedEventArgs class contains a reference to the corresponding div element. + * The pageLoaded event of the Sys.WebForms.PageRequestManager class uses a PageLoadedEventArgs object to return its event data. + * @return An array of div elements that were created during the DOM manipulation that was caused by the last asynchronous postback. If no elements were created, the property returns null. + */ + get_panelsCreated(): HTMLDivElement[]; + /** + * Gets an array of HTML
elements that represent UpdatePanel controls that were updated when the DOM was updated during the last asynchronous postback. + * If an UpdatePanel control is updated as a result of a partial-page update, the array referenced in the panelsUpdated property of the PageLoadedEventArgs class contains a reference to the corresponding
element. + * The pageLoaded event of the Sys.WebForms.PageRequestManager class uses a PageLoadedEventArgs object to return its event data. + * @return An array of
elements that were updated during the DOM manipulation that was the result of the last asynchronous postback. If no elements were created, the property returns null. + */ + get_panelsUpdated(): HTMLDivElement[]; + + //#endregion } /** * Used by the pageLoading event of the PageRequestManager class to send event data that represents the UpdatePanel controls that are being updated and deleted as a result of the most recent postback. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310960(v=vs.100).aspx} */ class PageLoadingEventArgs extends EventArgs { + //#region Constructors + + /** + * Initializes a new instance of the PageLoadingEventArgs class. + */ + constructor(); + + //#endregion + + //#region Properties + + /** + * Gets a JSON data structure that contains data items that were registered by using the RegisterDataItem method of the ScriptManager class. + * page or control must be in partial-page rendering mode to register data items that use the RegisterDataItem method of the ScriptManager class. + * Use the IsInAsyncPostBack property to check whether the page is in partial-page rendering mode. + * The dataItems property returns a JSON data structure that contains name/value pairs. + * The name is the unique ID of the control that is used in the control parameter of the RegisterDataItem method. The value is the dataItem parameter of the RegisterDataItem method. + * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. + */ + get_dataItems(): any; + + /** + * Gets an array of HTML
elements that represent UpdatePanel controls that will be deleted from the DOM as a result of the current asynchronous postback. + * If the contents of an UpdatePanel control will be deleted as the result of a partial-page update, the array that is referenced in the panelsDeleting property of the PageLoadingEventArgs class contains a reference to the corresponding
element. + * The pageLoading event of the Sys.WebForms.PageRequestManager class uses a PageLoadingEventArgs object to return its event data. + * @return An array of
elements that will be deleted from the DOM. If no elements will be deleted, the property returns null. + */ + get_panelsDeleted(): HTMLDivElement[]; + + /** + * Gets an array of HTML
elements that represent UpdatePanel controls that will be updated in the DOM as a result of the current asynchronous postback. + * If the contents of any UpdatePanel controls will be updated as the result of a partial-page update, the panelsUpdating property contains an array that references the corresponding
elements. + * The pageLoading event of the Sys.WebForms.PageRequestManager class uses a PageLoadingEventArgs object to return its event data. + * @return An array of
elements that will be updated in the DOM. If no elements will be updated, the property returns null. + */ + get_panelsUpdating(): HTMLDivElement[]; + + //#endregion + } /** From 13800d9fb0b7610353f0ab57294c5381f8c169f5 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Mon, 7 Apr 2014 09:20:29 +0100 Subject: [PATCH 14/24] Added missing global functions Beginning of some typescript tests to check typing are working. Need to resolve issue with extensions of built in types from lib.d.ts Array, Boolean, Number etc. --- microsoft-ajax/microsoft.ajax-tests.ts | 113 ++++++++++++ microsoft-ajax/microsoft.ajax.d.ts | 228 ++++++++++++++++--------- 2 files changed, 258 insertions(+), 83 deletions(-) create mode 100644 microsoft-ajax/microsoft.ajax-tests.ts diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts new file mode 100644 index 000000000..24ee4f034 --- /dev/null +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -0,0 +1,113 @@ +// Type definitions for Microsoft ASP.NET Ajax client side library +// Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx +// Definitions by: Patrick Magee +// Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + +//#region Global Namespace Tests + +var arrayVar = new Array("Saturn", "Mars", "Jupiter"); + +//#endregion + + +//#region Sys.Application Tests + +var component = new Sys.Component(); +var element = document.getElementById("#test"); +var id = "#test"; +var propertyName = "test"; +var parent = component; +var registerObject = new Object(); + +function loadHandler() { } +function initHandler() { } +function navigateHandler() { } +function unloadHandler() { } + +Sys.Application.add_load(loadHandler); +Sys.Application.remove_load(loadHandler); +Sys.Application.add_init(initHandler); +Sys.Application.remove_init(initHandler); +Sys.Application.add_navigate(navigateHandler); +Sys.Application.remove_navigate(navigateHandler); +Sys.Application.add_unload(unloadHandler); +Sys.Application.remove_unload(unloadHandler); +Sys.Application.addComponent(component); +Sys.Application.addHistoryPoint("state", "title"); +Sys.Application.beginCreateComponents(); +Sys.Application.beginUpdate(); +Sys.Application.dispose(); +Sys.Application.disposeElement(element, false); +Sys.Application.endCreateComponents(); +Sys.Application.endUpdate(); +Sys.Application.findComponent(id, parent); +Sys.Application.findComponent(id); +$find(id, parent); + +var componentArray = Sys.Application.getComponents(); +for (var i = 0; i < componentArray.length; i++) { + var id = componentArray[i].get_id(); +} + +Sys.Application.initialize(); +Sys.Application.notifyScriptLoaded(); +Sys.Application.raiseLoad(); +Sys.Application.raisePropertyChanged(propertyName); +Sys.Application.registerDisposableObject(registerObject); +Sys.Application.removeComponent(component); +Sys.Application.unregisterDisposableObject(registerObject); +Sys.Application.endUpdate(); +Sys.Application.get_enableHistory(); +Sys.Application.set_enableHistory(true); +Sys.Application.get_isCreatingComponents(); +Sys.Application.get_isDisposing(); + +//#endregion + +//#region ASP.NET Types Tests + +Type.registerNamespace("Samples"); + +var Samples; +Samples.A = function () { } +var a = Samples.A; +a.registerClass('Samples.A'); + + +Samples.B = function () { } +var b = Samples.B; +b.registerClass('Samples.B'); + +Samples.C = function () { + var c = Samples.C; + c.initializeBase(this); +} + +Samples.C.registerClass('Samples.C', Samples.A, Samples.B); + +var isDerived; +isDerived = Samples.B.inheritsFrom(Samples.A); +// Output: "false". +alert(isDerived); + +isDerived = Samples.C.inheritsFrom(Samples.A); +// Output: "true". +alert(isDerived); + +var implementsInterface; +implementsInterface = Samples.C.implementsInterface(Samples.B); +// Output: "true". +alert(implementsInterface); + +//#endregion + +//#region Global Shortcut Methods + +$addHandler($get("Button1"), "click", () => { }); +$addHandlers($get("Button1"), { }); +$removeHandler($get("Button1"), "click", () => { }); +$find('MyComponent'); +$find('MyComponent', $find('#test')); + +//#endregion \ No newline at end of file diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 0eb400641..f7defd1f5 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -1,4 +1,4 @@ -// Type definitions for microsoft asp.net ajax client side library +// Type definitions for Microsoft ASP.NET Ajax client side library // Project: http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx // Definitions by: Patrick Magee // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -18,15 +18,29 @@ * Array Type Extensions * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} */ -interface Array { +interface ArrayStatic { + + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; + /** - * Adds an element to the end of an Array object. + * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. + * @param array + * The array to add the item to. + * @param item + * */ - add(element: T): void; + add(array: any[], element: any): void; /** * Copies all the elements of the specified array to the end of an Array object. */ - addRange(array: T, items: T): void; + addRange(array: any, items: any): void; /** * Removes all elements from an Array object. */ @@ -34,31 +48,31 @@ interface Array { /** * Creates a shallow copy of an Array object. */ - clone(): Array; + clone(): any[]; /** * Determines whether an element is in an Array object. */ - contains(element: T): boolean; + contains(element: any): boolean; /** * Removes the first element from an Array object. */ - dequeue(): T; + dequeue(): any; /** * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. */ - enqueue(element: T): void; + enqueue(element: any): void; /** * Performs a specified action on each element of an Array object. */ - forEach(array: T[], method: Function, instance: T[]): void; + forEach(array: any[], method: Function, instance: any[]): void; /** * Searches for the specified element of an Array object and returns its index. */ - indexOf(array: T[], item: T, startIndex?: number): number; + indexOf(array: any[], item: any, startIndex?: number): number; /** * Inserts a value at the specified location in an Array object. */ - insert(array: T[], index: number, item: T); + insert(array: any[], index: number, item: any); /** * Creates an Array object from a string representation. */ @@ -66,11 +80,11 @@ interface Array { /** * Removes the first occurrence of an element in an Array object. */ - remove(array: T[], item: T): boolean; + remove(array: any[], item: any): boolean; /** * Removes an element at the specified location in an Array object. */ - removeAt(array: T[], index: number): void; + removeAt(array: any[], index: number): void; } /** @@ -356,20 +370,20 @@ declare class Type { * The type to test. * @return true if the type is an enumeration; otherwise, false. */ - static isEnum(type: any): boolean; + static isEnum(type: any): boolean; /** * Get a value that indicates whether the specified type is an integer of flags. * @param * The type to test. * @return true if the type is an integer of flags; otherwise, false. */ - static isFlags(type: any): boolean; + static isFlags(type: any): boolean; /** * Determines whether an instance implements an interface. * @param typeInstanceVar * The instance on which the interface is tested. * @return - */ + */ isImplementedBy(typeInstanceVar: any): boolean; /** * Returns a value that indicates whether an object is an instance of a specified class or of one of its derived classes. @@ -440,7 +454,7 @@ declare class Type { * The resolveInheritance method copies members from the base class to the prototype associated with the derived class, and continues this process up the inheritance chain. * If the derived type overrides a base type member, the base type member is not copied to the derived type's prototype. * After invoking a derived type's resolveInheritance method, you can examine the members of the derived type to discover all members, which includes inherited members. - */ + */ resolveInheritance(): void; } @@ -450,6 +464,8 @@ declare class Type { /** * Creates and initializes a component of the specified type. This method is static and can be called without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397487(v=vs.100).aspx} +* * @param type * The type of the component to create. * @param properties @@ -460,17 +476,63 @@ declare class Type { * (Optional) A JSON object that describes the properties that are references to other components. * @param element * (Optional) The DOM element that the component should be attached to. -* * @returns A new instance of a component that uses the specified parameters. */ declare function $create(type: Type, properties?: any, events?: any, references?: any, element?: HTMLElement): Sys.Component; /** * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397441(v=vs.100).aspx} +* @param id A string that contains the ID of the component to find. +* @param parent (Optional) The component or element that contains the component to find. * @return A Component object that contains the component requested by ID, if found; otherwise, null. */ declare function $find(id: string, parent?: Sys.Component): Sys.Component; +/* +* Provides a shortcut to the addHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb311019(v=vs.100).aspx} +* @param element The DOM element that exposes the event. +* @param eventName The name of the event. +* @param handler The event handler to add. +* @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. +*/ +declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean); + +/** +* Provides a shortcut to the addHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb384012(v=vs.100).aspx} +* @param element The DOM element that exposes the event. +* @param events A dictionary of events and their handlers. +* @param handlerOwner (Optional) The object instance that is the context for the delegates that should be created from the handlers. +* @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. +*/ +declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean); + +/** +* Provides a shortcut to the clearHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* For details about the method that this shortcut represents, see Sys.UI.DomEvent clearHandlers Method. +* @see {@link http://msdn.microsoft.com/en-us/library/bb310959(v=vs.100).aspx} +* @param The DOM element that exposes the events. +*/ +declare function $clearHandlers(element: Element); + +/** +* Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397717(v=vs.100).aspx} +* @param id The ID of the DOM element to find. +* @param element The parent element to search. The default is the document element. +*/ +declare function $get(id: string, element?: Element); + +/** +* Provides a shortcut to the removeHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397510(v=vs.100).aspx} +* @param element The DOM element that exposes the event. +* @param eventName The name of the DOM event. +* @param handler The event handler to remove. +*/ +declare function $removeHandler(element, eventName, handler); //#endregion @@ -514,9 +576,9 @@ declare module Sys { * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. */ add_load(handler: Function): void; - /** - * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. - */ + /** + * Raised after all scripts have been loaded and after the objects in the application have been created and initialized. + */ remove_load(handler: Function): void; /** * Occurs when the user clicks the browser's Back or Forward button. @@ -742,7 +804,7 @@ declare module Sys { * @param propertyName * The name of the property that changed. */ - raisePropertyChanged(propertyName: string): void; + raisePropertyChanged(propertyName: string): void; /** * Called by the endUpdate method as a placeholder for additional logic in derived classes. * Override the updated method in a derived class to add custom post-update logic. @@ -763,7 +825,7 @@ declare module Sys { /** * Represents a culture definition that can be applied to objects that accept a culture-related setting. * @see {@link http://msdn.microsoft.com/en-us/library/bb384004(v=vs.100).aspx} - */ + */ class CultureInfo { //#region Constructors @@ -864,13 +926,13 @@ declare module Sys { //#endregion } - + /** * Describes a change in a collection. * @see {@link http://msdn.microsoft.com/en-us/library/dd393798(v=vs.100).aspx} */ class CollectionChange { - + //#region Constructors /** @@ -937,7 +999,7 @@ declare module Sys { * The array to which an item will be added. * @param item * The item to add. - */ + */ static add(target: any[], item): void; /** @@ -965,9 +1027,9 @@ declare module Sys { * Adds items to the collection in an observable manner. * @param target The array to which items will be added. * @param items The array of items to add. - */ + */ static addRange(target: any[], items: any[]): void; - + /** * Begins the process of updating the target object. * @param target The object to update. @@ -998,7 +1060,7 @@ declare module Sys { * Indicates that the target is being updated. * @param target The target object to update. * @return true if given target argument is currently updating; otherwise false. - */ + */ static isUpdating(target: any): boolean; /** @@ -1013,7 +1075,7 @@ declare module Sys { * Raises the collectionChanged event. * @param target The collection to which an event is raised. * @param changes A Sys.CollectionChange object that contains the list of changes that were performed on the collection since the last event. - */ + */ static raiseCollectionChanged(target: any[], changes: Sys.CollectionChange): void; /** @@ -1021,9 +1083,9 @@ declare module Sys { * @param target The target object. * @param eventName A string that contains the event name. * @param eventArgs A Sys.EventArgs object used to pass event argument information. - */ + */ static raiseEvent(target: any, eventName: string, eventArgs: Sys.EventArgs): void; - + /** * Raises a propertyChanged notification event. * @param target The object to which an event is raised. @@ -1045,7 +1107,7 @@ declare module Sys { * @param index A number that represents the index of the item to remove. */ static removeAt(target: any[], index: number): void; - + /** * Removes the collectionChanged event handler from the target. * @param target The array from which the collectionChanged event handler is removed. @@ -1084,19 +1146,19 @@ declare module Sys { /** * @return "Actual value was {0}." - */ + */ actualValue: string; /** * @return "The application failed to load within the specified time out period." - */ + */ appLoadTimedout: string; /** * @return "Value does not fall within the expected range." - */ + */ argument: string; /** * @return "Value cannot be null." - */ + */ argumentNull: string; /** * @return "Specified argument was out of the range of valid values. @@ -1104,27 +1166,27 @@ declare module Sys { argumentOutOfRange: string; /** * @return "Object cannot be converted to the required type." - */ + */ argumentType: string; /** * @return "Object of type '{0}' cannot be converted to type '{1}'." - */ + */ argumentTypeWithTypes: string; /** * @return "Value cannot be undefined." - */ - argumentUndefined: string; + */ + argumentUndefined: string; /** * @return "Assertion Failed: {0}" - */ + */ assertFailed: string; /** * @return "Assertion Failed: {0}\r\nat {1}" - */ + */ assetFailedCaller: string; /** * @return "Base URL does not contain ://." - */ + */ badBaseUrl1: string; /** * @return "Base URL does not contain another /." @@ -1268,7 +1330,7 @@ declare module Sys { * Determines whether the Sys.StringBuilder object has content. * Use the isEmpty method to determine whether a StringBuilder instance has any content. If you append an empty string, null, or an undefined value to an empty StringBuilder instance, the instance remains empty and unchanged. * @return true if the StringBuilder instance contains no elements; otherwise, false. - */ + */ isEmpty(): boolean; /** @@ -1284,7 +1346,7 @@ declare module Sys { //#endregion } - //#endregion + //#endregion //#region Enumerations @@ -1315,7 +1377,7 @@ declare module Sys { * Provides a common interface for all components that can contain other components. */ interface IContainer { - + //#region Methods /** @@ -1353,7 +1415,7 @@ declare module Sys { * Provides a common interface for the application-defined tasks of closing, releasing, or resetting resources held by instances of a registered Microsoft Ajax Library class. * Implement the IDisposable interface to provide a common interface for closing or releasing resources held by instances of your registered Microsoft Ajax Library class. * You register an interface by when you register the class by calling the Type.registerClass method. You specify IDisposable in the interfaceTypes parameter when you call Type.registerClass. - */ + */ interface IDisposable { /** * Releases resources held by an object that implements the Sys.IDisposable interface. @@ -1397,7 +1459,7 @@ declare module Sys { * The name of the event handler for the propertyChanged event. */ remove_propertyChanged(handler: Function): void; - } + } //#endregion @@ -1469,7 +1531,7 @@ declare module Sys { /** * Initializes a new instance of the CancelEventArgs class. - */ + */ constructor(); //#endregion @@ -1552,7 +1614,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb310957(v=vs.100).aspx} */ class PropertyChangedEventArgs extends EventArgs { - + //#region Constructors /** @@ -1610,7 +1672,7 @@ declare module Sys { */ class ArgumentUndefinedException { - } + } /** * */ @@ -1643,7 +1705,7 @@ declare module Sys { } //#endregion - + //#region Sys.Net Namespace /** @@ -1678,7 +1740,7 @@ declare module Sys { /** * Removes the event handler added by the add_completed method. * @see {@link http://msdn.microsoft.com/en-us/library/bb397454(v=vs.100).aspx} - */ + */ remove_completed(handler: (reference: any, eventArgs: Sys.EventArgs) => void): void; /** @@ -1697,7 +1759,7 @@ declare module Sys { * @param eventArgs * The value to pass to the Web request completed event handler. */ - completed(eventArgs: Sys.EventArgs): void; + completed(eventArgs: Sys.EventArgs): void; //#endregion @@ -1739,7 +1801,7 @@ declare module Sys { * If a request finished successfully and with valid response data, this method returns all the response headers. * @return All the response headers * @see {@link http://msdn.microsoft.com/en-us/library/bb310805(v=vs.100).aspx} - */ + */ getAllResponseHeaders(): string; /** * Gets the value of the specified response header. @@ -1842,7 +1904,7 @@ declare module Sys { //#endregion //#region Methods - + /** * Converts an ECMAScript (JavaScript) object graph into a JSON string. This member is static and can be invoked without creating an instance of the class. * @static @@ -1891,7 +1953,7 @@ declare module Sys { /** * Initializes a new instance of the Sys.Services.AuthenticationService class. - */ + */ constructor(); //#endregion @@ -1900,7 +1962,7 @@ declare module Sys { /** * Specifies the path of the default authentication service. - */ + */ DefaultWebServicePath: string; //#endregion @@ -1944,7 +2006,7 @@ declare module Sys { * The function that is called if the logout has failed. The default is null. * @param userContext * User context information that you are passing to the callback functions. - */ + */ logout(redirectUrl: string, logoutCompletedCallback: Function, failedCallback: Function, userContext: any): void; //#endregion @@ -1988,7 +2050,7 @@ declare module Sys { * A reference to the user context for the service. */ defaultUserContext(value: Object): void; - + /** * Gets the authentication state of the current user. * The value of this property is set by the ScriptManager object during a page request. @@ -2036,7 +2098,7 @@ declare module Sys { * The ProfileGroup class defines the type of an element as a group in the properties collection of the Sys.Services.ProfileService class. * Profile group properties are accessed as subproperties of the related group, as shown in the following ECMAScript (JavaScript) example: * @see {@link http://msdn.microsoft.com/en-us/library/bb310801(v=vs.100).aspx} - */ + */ class ProfileGroup { /** @@ -2059,7 +2121,7 @@ declare module Sys { /** * Provides the client proxy class for the profile service. * @see {@link http://msdn.microsoft.com/en-us/library/bb383800(v=vs.100).aspx} - */ + */ class ProfileService { } @@ -2082,7 +2144,7 @@ declare module Sys { class Behavior extends Sys.Component { //#region Methods - + /** * Gets a Sys.UI.Behavior instance with the specified name property from the specified HTML Document Object Model (DOM) element. This member a static member and can be invoked without creating an instance of the class. * @return The specified Behavior object, if found; otherwise, null. @@ -2106,7 +2168,7 @@ declare module Sys { * The dispose method releases all resources from the Sys.UI.Behavior object, unbinds it from its associated HTML Document Object Model (DOM) element, and unregisters it from the application. */ dispose(): void; - + //#endregion //#region Properties @@ -2151,7 +2213,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397698(v=vs.100).aspx} */ class Bounds { - + //#region Constructors /** @@ -2194,43 +2256,43 @@ declare module Sys { * Provides the base class for all all ASP.NET AJAX client controls. */ class Control extends Sys.Component { - + } /** * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. */ class DomElement { - + } /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. */ class DomEvent { - + } /** * Describes key codes. */ enum Key { - + } /** * Describes mouse button locations. */ enum MouseButton { - + } /** * Creates an object that contains a set of integer coordinates that represent a position. */ class Point { - + } /** * Describes the layout of a DOM element in the page when the element's visible property is set to false. */ enum VisibilityMode { - + } } @@ -2247,7 +2309,7 @@ declare module Sys { /** * Used by the beginRequest event of the PageRequestManager class to pass argument information to event handlers. * @see {@link http://msdn.microsoft.com/en-us/library/bb384003(v=vs.100).aspx} - */ + */ class BeginRequestEventArgs extends EventArgs { //#region Constructors @@ -2293,7 +2355,7 @@ declare module Sys { /** * Used by the endRequest event of the PageRequestManager class to pass argument information to event handlers. * @see {@link http://msdn.microsoft.com/en-us/library/bb397499.aspx} - */ + */ class EndRequestEventArgs extends EventArgs { //#region Constructors @@ -2354,9 +2416,9 @@ declare module Sys { * Used by the initializeRequest event of the PageRequestManager class to pass argument information to event handlers. * This class contains private members that support the client-script infrastructure and are not intended to be used directly from your code. Names of private members begin with an underscore ( _ ). * @see {@link http://msdn.microsoft.com/en-us/library/bb311030(v=vs.100).aspx} - */ + */ class InitializeRequestEventArgs extends EventArgs { - + //#region Constructors /** @@ -2400,7 +2462,7 @@ declare module Sys { /** * Used by the pageLoaded event of the PageRequestManager class to send event data that represents the UpdatePanel controls that were updated and created in the most recent postback. * @see {@link http://msdn.microsoft.com/en-us/library/bb397476(v=vs.100).aspx} - */ + */ class PageLoadedEventArgs extends EventArgs { //#region Constructors @@ -2444,7 +2506,7 @@ declare module Sys { /** * Used by the pageLoading event of the PageRequestManager class to send event data that represents the UpdatePanel controls that are being updated and deleted as a result of the most recent postback. * @see {@link http://msdn.microsoft.com/en-us/library/bb310960(v=vs.100).aspx} - */ + */ class PageLoadingEventArgs extends EventArgs { //#region Constructors @@ -2490,7 +2552,7 @@ declare module Sys { /** * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. - */ + */ class PageRequestManager extends EventArgs { //#region Constructors @@ -2520,7 +2582,7 @@ declare module Sys { * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be called. - */ + */ add_endRequest(endRequestHandler: (sender, args) => void): void; /** * Raised after an asynchronous postback is finished and control has been returned to the browser. @@ -2628,7 +2690,7 @@ declare module Sys { * To customize error handling and to display more information about the server error, handle the AsyncPostBackError event and use the AsyncPostBackErrorMessage and AllowCustomErrorsRedirect properties. * For an example of how to provide custom error handling during partial-page updates, see Customizing Error Handling for ASP.NET UpdatePanel Controls. * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} * - */ + */ class PageRequestManagerServerErrorException { } From 07ace1a8e9c1748258d814b34a07e2c386c28bfc Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Thu, 10 Apr 2014 08:16:31 +0100 Subject: [PATCH 15/24] Added more tests Global shortcut method tests Application load event tests collection change tests command event arg tests Component tests Culture info tests --- microsoft-ajax/microsoft.ajax-tests.ts | 139 +++++++++++++++++++++++-- microsoft-ajax/microsoft.ajax.d.ts | 51 ++++++++- 2 files changed, 177 insertions(+), 13 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 24ee4f034..15b52ffcf 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -10,6 +10,15 @@ var arrayVar = new Array("Saturn", "Mars", "Jupiter"); //#endregion +//#region Global Shortcut Methods + +$addHandler($get("Button1"), "click", () => { }); +$addHandlers($get("Button1"), {}); +$removeHandler($get("Button1"), "click", () => { }); +$find('MyComponent'); +$find('MyComponent', $find('#test')); + +//#endregion //#region Sys.Application Tests @@ -65,6 +74,127 @@ Sys.Application.get_isDisposing(); //#endregion +//#region Sys.ApplicationLoadEventArgs Tests + +var a = new Sys.ApplicationLoadEventArgs(new Array(), true); + +var components = a.get_components(); +var isPartialReload = a.get_isPartialLoad(); + +//#endregion + +//#region Sys.Browser Tests + +var browser = Sys.Browser(); + +//#endregion + +//#region Sys.CancelEventArgs Tests + +var args = new Sys.CancelEventArgs(); + +var divElem = 'AlertDiv'; +var messageElem = 'AlertMessage'; + +Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); + +function CheckStatus(sender, args) { + + var prm = Sys.WebForms.PageRequestManager.getInstance(); + + if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') { + prm.abortPostBack(); + } + else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + + args.set_cancel(true); + ActivateAlertDiv('visible', 'Still working on previous request.'); + } + else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + ActivateAlertDiv('visible', 'Processing....'); + } +} + +function ActivateAlertDiv(visString, msg) { + var adiv = $get(divElem); + var aspan = $get(messageElem); + adiv.style.visibility = visString; + aspan.innerHTML = msg; +} + +//#endregion + +//#region Sys.CollectionChange Tests + +var action = Sys.NotifyCollectionChangedAction.add; +var newItems = []; +var newStartingIndex = 1; +var oldItems = []; +var oldStartingIndex = 2; + +var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); + +action = MyCChg.action; +newItems = MyCChg.newItems; +newStartingIndex = MyCChg.newStartingIndex; +oldItems = MyCChg.oldItems; +oldStartingIndex = MyCChg.oldStartingIndex; + +//#endregion + +//#region Sys.CommandEventArg Tests + +var commandName = "command name"; +var commandArgument = "command argument"; +var commandSource = "command source"; +var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource); +var empty = argsObj.Empty; +commandName = argsObj.get_commandName(); +commandArgument = argsObj.get_commandArgument(); + +//#endregion + +//#region Sys.Component Tests + +var aComponent = new Sys.Component(); + +aComponent.add_disposing(() => { }); +aComponent.remove_disposing(() => { }); + +aComponent.add_propertyChanged(() => { }); +aComponent.remove_propertyChanged(() => { }); + +aComponent.beginUpdate(); + +aComponent.create(type, properties, events, references, element); + +aComponent.dispose(); + +aComponent.endUpdate(); + +aComponent.initialize(); + +aComponent.raisePropertyChanged("propertyName"); + +aComponent.updated(); + +//#endregion + +//#region Sys.CultureInfo Tests + +var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; +var dtfCCObject = currentCultureInfoObj.dateTimeFormat; +var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; +var dtfICObject = invariantCultureInfoObj.dateTimeFormat; + +var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat"); + +var format = newCulture.dateTimeFormat; +var name = newCulture.name; +var numberFormat = newCulture.numberFormat; + +//#endregion + //#region ASP.NET Types Tests Type.registerNamespace("Samples"); @@ -102,12 +232,3 @@ alert(implementsInterface); //#endregion -//#region Global Shortcut Methods - -$addHandler($get("Button1"), "click", () => { }); -$addHandlers($get("Button1"), { }); -$removeHandler($get("Button1"), "click", () => { }); -$find('MyComponent'); -$find('MyComponent', $find('#test')); - -//#endregion \ No newline at end of file diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index f7defd1f5..5e00ecd0c 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -554,7 +554,7 @@ declare module Sys { * The members can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb384161(v=vs.100).aspx} */ - class Application { + interface Application { //#region Constructors @@ -697,11 +697,14 @@ declare module Sys { //#endregion } + var Application: Application; + /** * Provides information about the current Web browser. + * The Sys.Browser object determines which browser is being used and provides some information about it. You can use this object to help customize your code to the unique requirements or capabilities of the browser. * @see {@link http://msdn.microsoft.com/en-us/library/cc679064(v=vs.100).aspx} */ - class Browser { + interface IBrowser { //#region Fields @@ -729,6 +732,8 @@ declare module Sys { //#endregion } + export function Browser(): Sys.IBrowser; + /** * Provides the base class for the Control and Behavior classes, and for any other object whose lifetime should be managed by the ASP.NET AJAX client library. * @see {@link http://msdn.microsoft.com/en-us/library/bb397516(v=vs.100).aspx} @@ -1465,6 +1470,42 @@ declare module Sys { //#region Event Args + /* + * Used by the Application class to hold event arguments for the load event. + * @see {@link http://msdn.microsoft.com/en-us/library/bb383787(v=vs.100).aspx} + */ + class ApplicationLoadEventArgs { + + //#region Constructors + + /** + * Initializes a new instance of the ApplicationLoadEventArgs class. + * @param components + * The list of components that were created since the last time the load event was raised. + * @param isPartialLoad + * true to indicate that the event is a partial-page update. + */ + constructor(components: any, isPartialLoad: boolean); + + //#endregion + + //#region Properties + + /** + * Gets an array of all the components that were created since the last time the load event was raised. + * @return An array of all the components that were created since the last time the load event was raised. + */ + get_components(): Component[]; + + /** + * Returns a value that indicates whether the page is engaged in a partial-page update. + * @return true if the page is engaged in a partial-page update; otherwise, false. + */ + get_isPartialLoad(): boolean; + + //#endregion + } + /** * Provides a base class for classes that are used by event sources to pass event argument information. * @see {@link http://msdn.microsoft.com/en-us/library/bb383795(v=vs.100).aspx} @@ -2635,7 +2676,7 @@ declare module Sys { * Returns the instance of the PageRequestManager class for the page. * @return The current instance of the PageRequestManager class. You do not create a new instance of the PageRequestManager class directly. Instead, an instance is available when partial-page rendering is enabled. */ - getInstance(): PageRequestManager; + static getInstance(): PageRequestManager; /** * Stops all updates that would occur as a result of an asynchronous postback. @@ -2667,7 +2708,9 @@ declare module Sys { //#endregion - //#region Properties + //#region Properties + + get_isInAsyncPostBack(): boolean; //#endregion } From 489927d0b8a721ac6c19d1530e2ecb481d0ee063 Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Sat, 17 May 2014 11:46:38 -0400 Subject: [PATCH 16/24] Work on getting extensions for base types working -New MicrosoftAjaxBaseTypeExtensions module -A few other minor enhancements and JS doc stuff --- microsoft-ajax/microsoft.ajax.d.ts | 79 ++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 5e00ecd0c..be05be47d 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -269,6 +269,46 @@ interface String { //#endregion +declare module MicrosoftAjaxBaseTypeExtensions { + /** + * Provides static functions that extend the built-in ECMAScript (JavaScript) Function type by including exception + * details and support for application-compilation modes (debug or release). + * @see {@link http://msdn.microsoft.com/en-us/library/dd409270(v=vs.100).aspx} + */ + interface Function { + /** + * Creates a new function. + * @param args A list of arguments the function accepts. + */ + new (...args: string[]): Function; + (...args: string[]): Function; + prototype: Function; + + /** + * Creates a delegate function that retains the context first used during an objects creation. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx } + */ + createCallback(method: Function, ...context: any[]): Function; + /** + * Creates a callback function that retains the parameter initially used during an object's creation. + * @see {@link http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx } + */ + createDelegate(instance: any, method: Function): Function; + + /** + * A function that does nothing. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393667(v=vs.100).aspx } + */ + emptyMethod(): Function; + + /** + * Validates the parameters to a method are as expected. + * @see {@link http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx } + */ + validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; + } +} + //#region ASP.NET Types /** @@ -489,6 +529,15 @@ declare function $create(type: Type, properties?: any, events?: any, references? */ declare function $find(id: string, parent?: Sys.Component): Sys.Component; +/** +* Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. +* @see {@link http://msdn.microsoft.com/en-us/library/bb397441(v=vs.100).aspx} +* @param id A string that contains the ID of the component to find. +* @param parent (Optional) The component or element that contains the component to find. +* @return A Component object that contains the component requested by ID, if found; otherwise, null. +*/ +declare function $find(id: string, parent?: HTMLElement): Sys.Component; + /* * Provides a shortcut to the addHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb311019(v=vs.100).aspx} @@ -589,6 +638,16 @@ declare module Sys { */ remove_navigate(handler: Function): void; + /** + * Raised before all objects in the client application are disposed, typically when the DOM window.unload event is raised. + */ + add_unload(handler: Function): void; + + /** + * Raised before all objects in the client application are disposed, typically when the DOM window.unload event is raised. + */ + remove_unload(handler: Function): void; + //#endregion //#region Methods @@ -635,6 +694,11 @@ declare module Sys { */ findComponent(id: string, parent?: Sys.Component): Sys.Component; /** + * Returns the specified Component object. This member is static and can be invoked without creating an instance of the class. + * @return A Component object that contains the component requested by ID, if found; otherwise, null. + */ + findComponent(id: string, parent?: HTMLElement): Sys.Component; + /** * Returns an array of all components that have been registered with the application by using the addComponent method. This member is static and can be invoked without creating an instance of the class. */ getComponents(): Sys.Component[]; @@ -760,6 +824,16 @@ declare module Sys { */ remove_disposing(handler: Function): void; + /** + * Gets the ID of the current Component object. + */ + get_id(): string; + /** + * Sets the ID of the current Component object. + * @param value A string that contains the ID of the component. + */ + set_id(value: string): void; + /** * Raised when the raisePropertyChanged method of the current Component object is called. */ @@ -1523,6 +1597,11 @@ declare module Sys { /** * A static object of type EventArgs that is used as a convenient way to specify an empty EventArgs instance. */ + static Empty: EventArgs; + + /** + * An object of type EventArgs that is used as a convenient way to specify an empty EventArgs instance. + */ Empty: EventArgs; //#endregion From d87ed0be2e0de267e2f5a1c3eda34cd2de1e242f Mon Sep 17 00:00:00 2001 From: Steve Ognibene Date: Sat, 17 May 2014 11:47:40 -0400 Subject: [PATCH 17/24] Refactoring to ensure each set of tests is in its own function removed //#region declarations as the functions provide the same functionality (for compilation testing purposes anyway) plus eliminate scope conflicts. --- microsoft-ajax/microsoft.ajax-tests.ts | 558 ++++++++++++++++--------- 1 file changed, 349 insertions(+), 209 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 15b52ffcf..9e54d0c14 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -4,231 +4,371 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -//#region Global Namespace Tests +function GlobalNamespace_Tests() { -var arrayVar = new Array("Saturn", "Mars", "Jupiter"); + var arrayVar = new Array("Saturn", "Mars", "Jupiter"); -//#endregion - -//#region Global Shortcut Methods - -$addHandler($get("Button1"), "click", () => { }); -$addHandlers($get("Button1"), {}); -$removeHandler($get("Button1"), "click", () => { }); -$find('MyComponent'); -$find('MyComponent', $find('#test')); - -//#endregion - -//#region Sys.Application Tests - -var component = new Sys.Component(); -var element = document.getElementById("#test"); -var id = "#test"; -var propertyName = "test"; -var parent = component; -var registerObject = new Object(); - -function loadHandler() { } -function initHandler() { } -function navigateHandler() { } -function unloadHandler() { } - -Sys.Application.add_load(loadHandler); -Sys.Application.remove_load(loadHandler); -Sys.Application.add_init(initHandler); -Sys.Application.remove_init(initHandler); -Sys.Application.add_navigate(navigateHandler); -Sys.Application.remove_navigate(navigateHandler); -Sys.Application.add_unload(unloadHandler); -Sys.Application.remove_unload(unloadHandler); -Sys.Application.addComponent(component); -Sys.Application.addHistoryPoint("state", "title"); -Sys.Application.beginCreateComponents(); -Sys.Application.beginUpdate(); -Sys.Application.dispose(); -Sys.Application.disposeElement(element, false); -Sys.Application.endCreateComponents(); -Sys.Application.endUpdate(); -Sys.Application.findComponent(id, parent); -Sys.Application.findComponent(id); -$find(id, parent); - -var componentArray = Sys.Application.getComponents(); -for (var i = 0; i < componentArray.length; i++) { - var id = componentArray[i].get_id(); + $addHandler($get("Button1"), "click", () => { }); + $addHandlers($get("Button1"), {}); + $removeHandler($get("Button1"), "click", () => { }); + $find('MyComponent'); + $find('MyComponent', $find('#test')); } -Sys.Application.initialize(); -Sys.Application.notifyScriptLoaded(); -Sys.Application.raiseLoad(); -Sys.Application.raisePropertyChanged(propertyName); -Sys.Application.registerDisposableObject(registerObject); -Sys.Application.removeComponent(component); -Sys.Application.unregisterDisposableObject(registerObject); -Sys.Application.endUpdate(); -Sys.Application.get_enableHistory(); -Sys.Application.set_enableHistory(true); -Sys.Application.get_isCreatingComponents(); -Sys.Application.get_isDisposing(); - -//#endregion - -//#region Sys.ApplicationLoadEventArgs Tests - -var a = new Sys.ApplicationLoadEventArgs(new Array(), true); - -var components = a.get_components(); -var isPartialReload = a.get_isPartialLoad(); - -//#endregion - -//#region Sys.Browser Tests - -var browser = Sys.Browser(); - -//#endregion - -//#region Sys.CancelEventArgs Tests - -var args = new Sys.CancelEventArgs(); - -var divElem = 'AlertDiv'; -var messageElem = 'AlertMessage'; - -Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); - -function CheckStatus(sender, args) { - - var prm = Sys.WebForms.PageRequestManager.getInstance(); - - if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') { - prm.abortPostBack(); +function BaseClassExtensions_Function_Tests() { + + /** Sample code from http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx */ + var createDelegateTest = function () { + var context = ""; + var method: MicrosoftAjaxBaseTypeExtensions.Function; + var a = (Function).createCallback(method, context); } - else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { - - args.set_cancel(true); - ActivateAlertDiv('visible', 'Still working on previous request.'); + + /** Sample code from http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx */ + var createDelegateTest = function () { + var instance = this; + var method: MicrosoftAjaxBaseTypeExtensions.Function; + var a = (Function).createDelegate(instance, method); } - else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { - ActivateAlertDiv('visible', 'Processing....'); + + /** Sample code from http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx */ + var validateParametersTest = function () { + var arguments = ['test1', 'test2']; + var insert = function Array$insert(array, index, item) { + var e = (Function).validateParameters(arguments, [ + { name: "array", type: Array, elementMayBeNull: true }, + { name: "index", mayBeNull: true }, + { name: "item", mayBeNull: true } + ]); + if (e) throw e; + } + }; +} + + +function Sys_Application_Tests() { + + var component = new Sys.Component(); + var element = document.getElementById("#test"); + var id = "#test"; + var propertyName = "test"; + var registerObject = new Object(); + + function loadHandler() { } + function initHandler() { } + function navigateHandler() { } + function unloadHandler() { } + + Sys.Application.add_load(loadHandler); + Sys.Application.remove_load(loadHandler); + Sys.Application.add_init(initHandler); + Sys.Application.remove_init(initHandler); + Sys.Application.add_navigate(navigateHandler); + Sys.Application.remove_navigate(navigateHandler); + Sys.Application.add_unload(unloadHandler); + Sys.Application.remove_unload(unloadHandler); + Sys.Application.addComponent(component); + Sys.Application.addHistoryPoint("state", "title"); + Sys.Application.beginCreateComponents(); + Sys.Application.beginUpdate(); + Sys.Application.dispose(); + Sys.Application.disposeElement(element, false); + Sys.Application.endCreateComponents(); + Sys.Application.endUpdate(); + Sys.Application.findComponent(id, element); + Sys.Application.findComponent(id, component); + Sys.Application.findComponent(id); + $find(id, element); + + var componentArray = Sys.Application.getComponents(); + for (var i = 0; i < componentArray.length; i++) { + var cid = componentArray[i].get_id(); + } + + Sys.Application.initialize(); + Sys.Application.notifyScriptLoaded(); + Sys.Application.raiseLoad(); + Sys.Application.raisePropertyChanged(propertyName); + Sys.Application.registerDisposableObject(registerObject); + Sys.Application.removeComponent(component); + Sys.Application.unregisterDisposableObject(registerObject); + Sys.Application.endUpdate(); + Sys.Application.get_enableHistory(); + Sys.Application.set_enableHistory(true); + Sys.Application.get_isCreatingComponents(); + Sys.Application.get_isDisposing(); +} + + +function Sys_Application_LoadEventArgs_Tests() { + var a = new Sys.ApplicationLoadEventArgs(new Array(), true); + + var components = a.get_components(); + var isPartialReload = a.get_isPartialLoad(); +} + + +function Sys_Browser_Tests() { + var browser = Sys.Browser(); +} + + + +function Sys_CancelEventArgs_Tests() { + + var args = new Sys.CancelEventArgs(); + + var divElem = 'AlertDiv'; + var messageElem = 'AlertMessage'; + + Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); + + var CheckStatus = function(sender, args) { + + var prm = Sys.WebForms.PageRequestManager.getInstance(); + + if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'CancelRefresh') { + prm.abortPostBack(); + } + else if (prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + + args.set_cancel(true); + ActivateAlertDiv('visible', 'Still working on previous request.'); + } + else if (!prm.get_isInAsyncPostBack() && args.get_postBackElement().id == 'RefreshButton') { + ActivateAlertDiv('visible', 'Processing....'); + } + } + + var ActivateAlertDiv = function(visString, msg) { + var adiv = $get(divElem); + var aspan = $get(messageElem); + adiv.style.visibility = visString; + aspan.innerHTML = msg; } } -function ActivateAlertDiv(visString, msg) { - var adiv = $get(divElem); - var aspan = $get(messageElem); - adiv.style.visibility = visString; - aspan.innerHTML = msg; + +function Sys_CollectionChange_Tests() { + var action = Sys.NotifyCollectionChangedAction.add; + var newItems = []; + var newStartingIndex = 1; + var oldItems = []; + var oldStartingIndex = 2; + + var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); + + action = MyCChg.action; + newItems = MyCChg.newItems; + newStartingIndex = MyCChg.newStartingIndex; + oldItems = MyCChg.oldItems; + oldStartingIndex = MyCChg.oldStartingIndex; } -//#endregion -//#region Sys.CollectionChange Tests - -var action = Sys.NotifyCollectionChangedAction.add; -var newItems = []; -var newStartingIndex = 1; -var oldItems = []; -var oldStartingIndex = 2; - -var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); - -action = MyCChg.action; -newItems = MyCChg.newItems; -newStartingIndex = MyCChg.newStartingIndex; -oldItems = MyCChg.oldItems; -oldStartingIndex = MyCChg.oldStartingIndex; - -//#endregion - -//#region Sys.CommandEventArg Tests - -var commandName = "command name"; -var commandArgument = "command argument"; -var commandSource = "command source"; -var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource); -var empty = argsObj.Empty; -commandName = argsObj.get_commandName(); -commandArgument = argsObj.get_commandArgument(); - -//#endregion - -//#region Sys.Component Tests - -var aComponent = new Sys.Component(); - -aComponent.add_disposing(() => { }); -aComponent.remove_disposing(() => { }); - -aComponent.add_propertyChanged(() => { }); -aComponent.remove_propertyChanged(() => { }); - -aComponent.beginUpdate(); - -aComponent.create(type, properties, events, references, element); - -aComponent.dispose(); - -aComponent.endUpdate(); - -aComponent.initialize(); - -aComponent.raisePropertyChanged("propertyName"); - -aComponent.updated(); - -//#endregion - -//#region Sys.CultureInfo Tests - -var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; -var dtfCCObject = currentCultureInfoObj.dateTimeFormat; -var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; -var dtfICObject = invariantCultureInfoObj.dateTimeFormat; - -var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat"); - -var format = newCulture.dateTimeFormat; -var name = newCulture.name; -var numberFormat = newCulture.numberFormat; - -//#endregion - -//#region ASP.NET Types Tests - -Type.registerNamespace("Samples"); - -var Samples; -Samples.A = function () { } -var a = Samples.A; -a.registerClass('Samples.A'); - - -Samples.B = function () { } -var b = Samples.B; -b.registerClass('Samples.B'); - -Samples.C = function () { - var c = Samples.C; - c.initializeBase(this); +function Sys_CommandEventArg_Tests() { + var commandName = "command name"; + var commandArgument = "command argument"; + var commandSource = "command source"; + var argsObj = new Sys.CommandEventArgs(commandName, commandArgument, commandSource); + var empty = argsObj.Empty; + commandName = argsObj.get_commandName(); + commandArgument = argsObj.get_commandArgument(); } -Samples.C.registerClass('Samples.C', Samples.A, Samples.B); -var isDerived; -isDerived = Samples.B.inheritsFrom(Samples.A); -// Output: "false". -alert(isDerived); +function Sys_Component_Tests() { + var aComponent = new Sys.Component(); + var properties: any; + var events: any; + var references: any; + var element: HTMLElement; + var handler: Function; + var MyControl = new Type; + + aComponent.add_disposing(() => { }); + aComponent.remove_disposing(() => { }); -isDerived = Samples.C.inheritsFrom(Samples.A); -// Output: "true". -alert(isDerived); + aComponent.add_propertyChanged(() => { }); + aComponent.remove_propertyChanged(() => { }); -var implementsInterface; -implementsInterface = Samples.C.implementsInterface(Samples.B); -// Output: "true". -alert(implementsInterface); + aComponent.beginUpdate(); -//#endregion + $create(MyControl, { id: 'c1', visible: true }, { click: handler }, null, $get('button1')); + aComponent.dispose(); + + aComponent.endUpdate(); + + aComponent.initialize(); + + aComponent.raisePropertyChanged("propertyName"); + + aComponent.updated(); +} + +function Sys_CultureInfo_Tests() { + var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; + var dtfCCObject = currentCultureInfoObj.dateTimeFormat; + var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; + var dtfICObject = invariantCultureInfoObj.dateTimeFormat; + + var newCulture = new Sys.CultureInfo("name", "numberFormat", "dateTimeFormat"); + + var format = newCulture.dateTimeFormat; + var name = newCulture.name; + var numberFormat = newCulture.numberFormat; +} + + +function AspNetTypes_Tests() { + Type.registerNamespace("Samples"); + + + var Samples; + Samples.A = function () { }; + var a = Samples.A; + a.registerClass('Samples.A'); + + + Samples.B = function () { }; + var b = Samples.B; + b.registerClass('Samples.B'); + + Samples.C = function () { + var c = Samples.C; + c.initializeBase(this); + }; + + Samples.C.registerClass('Samples.C', Samples.A, Samples.B); + + var isDerived; + isDerived = Samples.B.inheritsFrom(Samples.A); + // Output: "false". + alert(isDerived); + + isDerived = Samples.C.inheritsFrom(Samples.A); + // Output: "true". + alert(isDerived); + + var implementsInterface; + implementsInterface = Samples.C.implementsInterface(Samples.B); + // Output: "true". + alert(implementsInterface); +} + + + +/** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ +function CreatingCustomNonVisualClientComponentsTests() { + var Demo: any; + Type.registerNamespace("Demo"); + + Demo.Timer = function () { + Demo.Timer.initializeBase(this); + + this._interval = 1000; + this._enabled = false; + this._timer = null; + } + + Demo.Timer.prototype = { + // OK to declare value types in the prototype + + + get_interval: function () { + /// Interval in milliseconds + return this._interval; + }, + set_interval: function (value) { + if (this._interval !== value) { + this._interval = value; + this.raisePropertyChanged('interval'); + + if (!this.get_isUpdating() && (this._timer !== null)) { + this._restartTimer(); + } + } + }, + + get_enabled: function () { + /// True if timer is enabled, false if disabled. + return this._enabled; + }, + set_enabled: function (value) { + if (value !== this.get_enabled()) { + this._enabled = value; + this.raisePropertyChanged('enabled'); + if (!this.get_isUpdating()) { + if (value) { + this._startTimer(); + } + else { + this._stopTimer(); + } + } + } + }, + + // events + add_tick: function (handler) { + /// Adds a event handler for the tick event. + /// The handler to add to the event. + this.get_events().addHandler("tick", handler); + }, + remove_tick: function (handler) { + /// Removes a event handler for the tick event. + /// The handler to remove from the event. + this.get_events().removeHandler("tick", handler); + }, + + dispose: function () { + // call set_enabled so the property changed event fires, for potentially attached listeners. + this.set_enabled(false); + // make sure it stopped so we aren't called after disposal + this._stopTimer(); + // be sure to call base.dispose() + Demo.Timer.callBaseMethod(this, 'dispose'); + }, + + updated: function () { + Demo.Timer.callBaseMethod(this, 'updated'); + // called after batch updates, this.beginUpdate(), this.endUpdate(). + if (this._enabled) { + this._restartTimer(); + } + }, + + _timerCallback: function () { + var handler = this.get_events().getHandler("tick"); + if (handler) { + handler(this, Sys.EventArgs.Empty); + } + }, + + _restartTimer: function () { + this._stopTimer(); + this._startTimer(); + }, + + _startTimer: function () { + // save timer cookie for removal later + this._timer = window.setInterval((Function).createDelegate(this, this._timerCallback), this._interval); + }, + + _stopTimer: function () { + if (this._timer) { + window.clearInterval(this._timer); + this._timer = null; + } + } + } + + Demo.Timer.registerClass('Demo.Timer', Sys.Component); + + // Since this script is not loaded by System.Web.Handlers.ScriptResourceHandler + // invoke Sys.Application.notifyScriptLoaded to notify ScriptManager + // that this is the end of the script. + if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); + +} \ No newline at end of file From f715b480369008c3d41b6ac0e255b0cfabebdd92 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 17:13:34 +0100 Subject: [PATCH 18/24] Further definitions have been added Removed some whitespaces added code formatting. Adding definitions to Sys.UI namespace. Added Sys.UI.Key test. --- microsoft-ajax/microsoft.ajax-tests.ts | 20 +-- microsoft-ajax/microsoft.ajax.d.ts | 221 ++++++++++++++++++++++--- 2 files changed, 209 insertions(+), 32 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 9e54d0c14..532c9c11c 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -45,7 +45,6 @@ function BaseClassExtensions_Function_Tests() { }; } - function Sys_Application_Tests() { var component = new Sys.Component(); @@ -99,7 +98,6 @@ function Sys_Application_Tests() { Sys.Application.get_isDisposing(); } - function Sys_Application_LoadEventArgs_Tests() { var a = new Sys.ApplicationLoadEventArgs(new Array(), true); @@ -107,13 +105,10 @@ function Sys_Application_LoadEventArgs_Tests() { var isPartialReload = a.get_isPartialLoad(); } - function Sys_Browser_Tests() { var browser = Sys.Browser(); } - - function Sys_CancelEventArgs_Tests() { var args = new Sys.CancelEventArgs(); @@ -148,7 +143,6 @@ function Sys_CancelEventArgs_Tests() { } } - function Sys_CollectionChange_Tests() { var action = Sys.NotifyCollectionChangedAction.add; var newItems = []; @@ -165,7 +159,6 @@ function Sys_CollectionChange_Tests() { oldStartingIndex = MyCChg.oldStartingIndex; } - function Sys_CommandEventArg_Tests() { var commandName = "command name"; var commandArgument = "command argument"; @@ -176,7 +169,6 @@ function Sys_CommandEventArg_Tests() { commandArgument = argsObj.get_commandArgument(); } - function Sys_Component_Tests() { var aComponent = new Sys.Component(); var properties: any; @@ -207,6 +199,15 @@ function Sys_Component_Tests() { aComponent.updated(); } +function Sys_UI_Key_Tests() { + + var a = Sys.UI.Key.backspace; + + var b = Sys.UI.Key.del; + + var c = Sys.UI.Key.down; +} + function Sys_CultureInfo_Tests() { var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; var dtfCCObject = currentCultureInfoObj.dateTimeFormat; @@ -220,7 +221,6 @@ function Sys_CultureInfo_Tests() { var numberFormat = newCulture.numberFormat; } - function AspNetTypes_Tests() { Type.registerNamespace("Samples"); @@ -257,8 +257,6 @@ function AspNetTypes_Tests() { alert(implementsInterface); } - - /** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ function CreatingCustomNonVisualClientComponentsTests() { var Demo: any; diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index be05be47d..1c877abae 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -2298,20 +2298,17 @@ declare module Sys { * @return The DOM element that the current Behavior object is associated with. */ get_element(): Sys.UI.DomElement; - /** * Gets or sets the identifier for the Sys.UI.Behavior object. * A generated identifier that consists of the ID of the associated Sys.UI.DomElement, the "$" character, and the name value of the Behavior object. */ get_id(): string; - /** * Gets or sets the identifier for the Sys.UI.Behavior object. * @param value * The string value to use as the identifier. */ set_id(value: string): void; - /* * Gets or sets the name of the Sys.UI.Behavior object. * If you do not explicitly set the name property, getting the property value sets it to its default value, which is equal to the type of the Behavior object. The name property remains null until it is accessed. @@ -2319,7 +2316,6 @@ declare module Sys { * A string value to use as the name. */ set_name(value: string): void; - /** * Gets or sets the name of the Sys.UI.Behavior object. */ @@ -2350,19 +2346,16 @@ declare module Sys { * @return A number that represents the height of an object in pixels. */ height: number; - /** * Gets the width of an object in pixels. This property is read-only. * @return A number that represents the width of an object in pixels. */ width: number; - /** * Gets the x-coordinate of an object in pixels. * @return A number that represents the x-coordinate of an object in pixels. */ x: number; - /** * Gets the y-coordinate of anobject in pixels. * @return A number that represents the y-coordinate of an object in pixels. @@ -2386,15 +2379,209 @@ declare module Sys { } /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. + * @see {@link http://msdn.microsoft.com/en-us/library/bb310935(v=vs.100).aspx} */ class DomEvent { + //#region Constructors + + /** + * Initializes a new instance of the Sys.UI.DomEvent class and associates it with the specified DomElement object. + * @param domElement + * The DomElement object to associate with the event. + */ + constructor(domElement: DomElement); + constructor(domElement: any); + + //#endregion + + //#region Methods + + /** + * Provides a method to add a DOM event handler to the DOM element that exposes the event. This member is static and can be invoked without creating an instance of the class. + * Use the addHandler method to add a DOM event handler to the element that exposes the event. The eventName parameter should not include the "on" prefix. For example, specify "click" instead of "onclick". + * This method can be accessed through the $addHandler shortcut method. + * + * @param element + * The element that exposes the event. + * @param eventName + * The name of the event. + * @param handler + * The client function that is called when the event occurs. + * @param autoRemove + * (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. + */ + static addHandler(element: any, eventName: string, handler: Function, autoRemove?: boolean): void; + /** + * Adds a list of DOM event handlers to the DOM element that exposes the events. This member is static and can be invoked without creating an instance of the class. + * Use the addHandlers method to add a list of DOM event handlers to the element that exposes the event. + * The events parameter takes a comma-separated list of name/value pairs in the format name:value, where name is the name of the DOM event and value is the name of the handler function. + * If there is more than one name/value pair, the list must be enclosed in braces ({}) to identify it as a single parameter. Multiple name/value pairs are separated with commas. + * Event names should not include the "on" prefix. For example, specify "click" instead of "onclick". + * If handlerOwner is specified, delegates are created for each handler. These delegates are attached to the specified object instance, and the this pointer from the delegate handler will refer to the handlerOwner object. + * This method can be accessed through the $addHandlers shortcut method. + * + * @param element + * The DOM element that exposes the events. + * @param events + * A dictionary of event handlers. + * @param handlerOwner + * (Optional) The object instance that is the context for the delegates that should be created from the handlers. + * @param autoRemove + * (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. + * + * @throws Error.invalidOperation - (Debug) One of the handlers specified in events is not a function. + * + */ + static addHandlers(element: any, events: any, handlerOwner?: any, autoRemove?: boolean): void; + /** + * Removes all DOM event handlers from a DOM element that were added through the Sys.UI.DomEvent addHandler or the Sys.UI.DomEvent addHandlers methods. + * This member is static and can be invoked without creating an instance of the class. + * This method can be accessed through the $clearHandlers shortcut method. + * + * @param element + * The element that exposes the events. + */ + static clearHandlers(element: any): void; + /** + * Removes a DOM event handler from the DOM element that exposes the event. This member is static and can be invoked without creating an instance of the class. + * + * @param element + * The element that exposes the event. + * @param eventName + * The name of the event. + * @param handler + * The event handler to remove. + */ + static removeHandler(element: any, eventName: string, handler: Function): void; + /** + * Prevents the default DOM event action from happening. + * Use the preventDefault method to prevent the default event action for the browser from occurring. + * For example, if you prevent the keydown event of an input element from occurring, the character typed by the user is not automatically appended to the input element's value. + */ + preventDefault(): void; + /** + * Prevents an event from being propagated (bubbled) to parent elements. + * By default, event notification is bubbled from a child object to parent objects until it reaches the document object. + * The event notification stops if the event is handled during the propagation process. + * Use the stopPropagation method to prevent an event from being propagated to parent elements. + */ + stopPropagation(): void; + + //#endregion + + //#region Fields + + /** + * Gets a Boolean value that indicates the state of the ALT key when the associated event occurred. + * Use the altKey field to determine whether the ALT key is pressed when the event occurred. + * + * @return true if the ALT key was pressed when the event occurred; otherwise, false. + */ + altKey: boolean; + /** + * Gets a Sys.UI.MouseButton enumeration value that indicates the button state of the mouse when the related event occurred. + * Use the button field to determine which mouse button was pressed when the related event occurred. + * @return A MouseButton value + */ + button: Sys.UI.MouseButton; + /** + * Gets the character code of the key that raised the associated keyPress event. + * Use the charCode field to get the character code of a pressed key or key combination that raised a keyPress event. + * The keyPress event provides a single character code that identifies key combinations. + * The keyPress event is not raised for single modifier keys such as ALT, CTRL, and SHIFT. + * + * @return An integer value that represents the character code of the key or key combination that was pressed to raise the keyPress event. + */ + charCode: number; + /** + * + */ + clientX: any; // todo + + clientY: any; // todo + + ctrlKey: any; // todo + + keyCode: any; // todo + + offsetX: any; // todo + + offsetY: any; // todo + + screenX: any; // todo + + screenY: any; // todo + + shiftKey: any; // todo + + target: any; // todo + + type: any; // todo + + //#endregion } /** * Describes key codes. + * The values correspond to values in the Document Object Model (DOM). */ enum Key { - + /** + * Represents the BACKSPACE key. + */ + backspace, + /* + * Represents the TAB key. + */ + tab, + /** + * Represents the ENTER key. + */ + enter, + /** + * Represents the ESC key. + */ + esc, + /* + * Represents the SPACEBAR key. + */ + space, + /** + * Represents the PAGE UP key. + */ + pageUp, + /** + * Represents the PAGE DOWN key. + */ + pageDown, + /** + * Represents the END key. + */ + end, + /** + * Represents the HOME key. + */ + home, + /** + * Represents the LEFT ARROW key. + */ + left, + /** + * Represents the UP ARROW key. + */ + up, + /** + * Represents the RIGHT ARROW key. + */ + right, + /** + * Represents the DOWN ARROW key. + */ + down, + /** + * Represents DELETE key. + */ + del } /** * Describes mouse button locations. @@ -2455,13 +2642,11 @@ declare module Sys { * @return An HTML DOM element. */ get_postBackElement(): HTMLElement; - /** * Gets the request object that represents the current postback. * @return An instance of the Sys.Net.WebRequest class. */ get_request(): Sys.Net.WebRequest; - /** * Gets a list of UniqueID values for UpdatePanel controls that should re-render their content, as requested by the client. * Server-side processing might update additional UpdatePanel controls. @@ -2501,20 +2686,17 @@ declare module Sys { * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. */ get_dataItems(): any; - /** * Gets the Error object. * @return A base ECMAScript (JavaScript) Error object. */ get_error(): Error; - /** * Get or sets a value that indicates whether the error has been handled. * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. * @return true if the error has been handled; otherwise false. */ get_errorHandled(): boolean; - /** * Get or sets a value that indicates whether the error has been handled. * Use this property to determine whether an asynchronous postback error has already been handled. If it has not and if you want to take action on the error, you can set the error as handled. @@ -2522,12 +2704,11 @@ declare module Sys { * true or false. */ set_errorHandled(value: boolean): void; - /** * Gets a response object that is represented by the Sys.Net.WebRequestExecutor class. * @return A response object that is represented by the WebRequestExecutor class. */ - get_response(): any; // todo + get_response(): Sys.Net.WebRequestExecutor; //#endregion } @@ -2649,7 +2830,6 @@ declare module Sys { * @return A JSON data structure that contains name/value pairs that were registered as data items by using the RegisterDataItem method of the ScriptManager class. */ get_dataItems(): any; - /** * Gets an array of HTML
elements that represent UpdatePanel controls that will be deleted from the DOM as a result of the current asynchronous postback. * If the contents of an UpdatePanel control will be deleted as the result of a partial-page update, the array that is referenced in the panelsDeleting property of the PageLoadingEventArgs class contains a reference to the corresponding
element. @@ -2657,7 +2837,6 @@ declare module Sys { * @return An array of
elements that will be deleted from the DOM. If no elements will be deleted, the property returns null. */ get_panelsDeleted(): HTMLDivElement[]; - /** * Gets an array of HTML
elements that represent UpdatePanel controls that will be updated in the DOM as a result of the current asynchronous postback. * If the contents of any UpdatePanel controls will be updated as the result of a partial-page update, the panelsUpdating property contains an array that references the corresponding
elements. @@ -2672,6 +2851,7 @@ declare module Sys { /** * Manages client partial-page updates of server UpdatePanel controls. In addition, defines properties, events, and methods that can be used to customize a Web page with client script. + * @see {@link http://msdn.microsoft.com/en-us/library/bb311028(v=vs.100).aspx} */ class PageRequestManager extends EventArgs { @@ -2803,7 +2983,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} */ class PageRequestManagerParserErrorException { - + // Nothing to define } /** @@ -2814,7 +2994,7 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} * */ class PageRequestManagerServerErrorException { - + // Nothing to define } /** @@ -2825,12 +3005,11 @@ declare module Sys { * @see {@link http://msdn.microsoft.com/en-us/library/bb397466(v=vs.100).aspx} */ class PageRequestManagerTimeoutException { - + // Nothing to define } //#endregion - } //#endregion From d9bfaa5a619ed14498212d2ec1a4225ce583d9a2 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 17:18:12 +0100 Subject: [PATCH 19/24] Updated contributors with Microsoft Ajax Added Project Name, Project URL, Typed definitions author name and Github link. --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f39e1f53d..6cc50e14f 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -206,6 +206,7 @@ All definitions files include a header with the author and editors, so at some p * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) * [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) +* [Microsoft Ajax](http://msdn.microsoft.com/en-us/library/ee341002(v=vs.100).aspx) (by [Patrick Magee](https://github.com/pjmagee)) * [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) * [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame)) * [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds)) From cfa54ee0ae46621a7e95476df102f2f3957cb1e7 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:11:02 +0100 Subject: [PATCH 20/24] Moved ECMAScript Extensions Moved extensions into a new declared module MicrosoftAjaxBaseTypeExtensions which can be used to cast between the real and declared type because lib.d.ts already has these types defined and cannot easily extend them. --- microsoft-ajax/microsoft.ajax.d.ts | 641 +++++++++++++++++------------ 1 file changed, 371 insertions(+), 270 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 1c877abae..1ccef3aaa 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -13,263 +13,8 @@ //#region JavaScript Base Type Extensions -/** -* Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. -* Array Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} -*/ -interface ArrayStatic { - - new (arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; - - /** - * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. - * @param array - * The array to add the item to. - * @param item - * - */ - add(array: any[], element: any): void; - /** - * Copies all the elements of the specified array to the end of an Array object. - */ - addRange(array: any, items: any): void; - /** - * Removes all elements from an Array object. - */ - clear(): void; - /** - * Creates a shallow copy of an Array object. - */ - clone(): any[]; - /** - * Determines whether an element is in an Array object. - */ - contains(element: any): boolean; - /** - * Removes the first element from an Array object. - */ - dequeue(): any; - /** - * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. - */ - enqueue(element: any): void; - /** - * Performs a specified action on each element of an Array object. - */ - forEach(array: any[], method: Function, instance: any[]): void; - /** - * Searches for the specified element of an Array object and returns its index. - */ - indexOf(array: any[], item: any, startIndex?: number): number; - /** - * Inserts a value at the specified location in an Array object. - */ - insert(array: any[], index: number, item: any); - /** - * Creates an Array object from a string representation. - */ - parse(value: string): any[]; - /** - * Removes the first occurrence of an element in an Array object. - */ - remove(array: any[], item: any): boolean; - /** - * Removes an element at the specified location in an Array object. - */ - removeAt(array: any[], index: number): void; -} - -/** -* Provides extensions to the base ECMAScript (JavaScript) Boolean object. -* Boolean Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} -*/ -interface Boolean { - /** - * Converts a string representation of a logical value to its Boolean object equivalent. - */ - parse(value: string): boolean; -} - -/** -* Provides extensions to the base ECMAScript (JavaScript) Date object. -* Date Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} -*/ -interface Date { - /** - * Formats a date by using the invariant (culture-independent) culture. - */ - format(value: string): string; - /** - * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. - */ - localeFormat(value: string): string; - /** - * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. - * @exception (Debug) formats contains an invalid format. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseLocale(value: string): string; - parseLocale(value: string, formats?: string[]): string; - parseLocale(value: string, ...formats: string[]): string; - /** - * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. - * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseInvariant(value: string): string; - parseInvariant(value: string, formats?: string[]): string; - parseInvariant(value: string, ...formats: string[]): string; -} - -/** -* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). -* Error Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} -*/ -interface Error { - /** - * Creates an Error object that represents the Sys.ParameterCountException exception. - */ - parameterCount(message?: string): Error; - /** - * Creates an Error object that represents the Sys.NotImplementedException exception. - */ - notImplemented(message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentException exception. - */ - argument(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentNullException exception. - */ - argumentNull(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. - */ - argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentTypeException exception. - */ - argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. - */ - argumentUndefined(paramName?: string, message?: string): Error; - /** - * Creates an Error object that can contain additional error information. - */ - create(message?: string, errorInfo?: Object): Error; - /** - * Creates an Error object that represents the Sys.FormatException exception. - */ - format(message?: string): Error; - /** - * Creates an Error object that represents the Sys.InvalidOperationException exception. - */ - invalidOperation(message?: string): Error; - /** - * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. - */ - popStackFrame(): void; -} - -/** -* Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. -* Number Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} -*/ -interface Number { - /** - * Formats a number by using the invariant culture. - */ - format(format: string): string; - /** - * Formats a number by using the current culture. - */ - localeFormat(format: string): string; - /** - * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. - */ - parseInvariant(format: string): number; - /** - * Creates a numeric value from a locale-specific string. - */ - parseLocale(format: string): number; -} - -/** -* Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. -* Object Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} -*/ -interface Object { - /** - * Formats a number by using the invariant culture. - */ - getType(instance: any): Type; - /** - * Returns a string that identifies the run-time type name of an object. - */ - getTypeName(instance: any): string; -} - -/** -* Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. -* String Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} -*/ -interface String { - /** - * Formats a number by using the invariant culture. - * @returns true if the end of the String object matches suffix; otherwise, false. - */ - endsWith(suffix: string): boolean; - /** - * Replaces each format item in a String object with the text equivalent of a corresponding object's value. - * @returns A copy of the string with the formatting applied. - */ - format(format: string, ...args: any[]): string; - /** - * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. - * @returns A copy of the string with the formatting applied. - */ - localeFormat(format: string, ...args: any[]): string; - /** - * Removes leading and trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start and end of the string. - */ - trim(): string; - /** - * Removes trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the end of the string. - */ - trimEnd(): string; - /** - * Removes leading white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start of the string. - */ - trimStart(): string; -} - -//#endregion - declare module MicrosoftAjaxBaseTypeExtensions { + /** * Provides static functions that extend the built-in ECMAScript (JavaScript) Function type by including exception * details and support for application-compilation modes (debug or release). @@ -307,8 +52,265 @@ declare module MicrosoftAjaxBaseTypeExtensions { */ validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; } + + /** + * Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. + * Object Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} + */ + interface Object { + /** + * Formats a number by using the invariant culture. + */ + getType(instance: any): Type; + /** + * Returns a string that identifies the run-time type name of an object. + */ + getTypeName(instance: any): string; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. + * String Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} + */ + interface String { + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; + } + + /** + * Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. + * Number Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} + */ + interface Number { + /** + * Formats a number by using the invariant culture. + */ + format(format: string): string; + /** + * Formats a number by using the current culture. + */ + localeFormat(format: string): string; + /** + * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. + */ + parseInvariant(format: string): number; + /** + * Creates a numeric value from a locale-specific string. + */ + parseLocale(format: string): number; + } + + /** + * Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). + * Error Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} + */ + interface Error { + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) Date object. + * Date Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} + */ + interface Date { + /** + * Formats a date by using the invariant (culture-independent) culture. + */ + format(value: string): string; + /** + * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. + */ + localeFormat(value: string): string; + /** + * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. + * @exception (Debug) formats contains an invalid format. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseLocale(value: string): string; + parseLocale(value: string, formats?: string[]): string; + parseLocale(value: string, ...formats: string[]): string; + /** + * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. + * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseInvariant(value: string): string; + parseInvariant(value: string, formats?: string[]): string; + parseInvariant(value: string, ...formats: string[]): string; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. + * Array Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} + */ + interface Array { + + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; + + /** + * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. + * @param array + * The array to add the item to. + * @param item + * + */ + add(array: any[], element: any): void; + /** + * Copies all the elements of the specified array to the end of an Array object. + */ + addRange(array: any, items: any): void; + /** + * Removes all elements from an Array object. + */ + clear(): void; + /** + * Creates a shallow copy of an Array object. + */ + clone(): any[]; + /** + * Determines whether an element is in an Array object. + */ + contains(element: any): boolean; + /** + * Removes the first element from an Array object. + */ + dequeue(): any; + /** + * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. + */ + enqueue(element: any): void; + /** + * Performs a specified action on each element of an Array object. + */ + forEach(array: any[], method: Function, instance: any[]): void; + /** + * Searches for the specified element of an Array object and returns its index. + */ + indexOf(array: any[], item: any, startIndex?: number): number; + /** + * Inserts a value at the specified location in an Array object. + */ + insert(array: any[], index: number, item: any); + /** + * Creates an Array object from a string representation. + */ + parse(value: string): any[]; + /** + * Removes the first occurrence of an element in an Array object. + */ + remove(array: any[], item: any): boolean; + /** + * Removes an element at the specified location in an Array object. + */ + removeAt(array: any[], index: number): void; + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) Boolean object. + * Boolean Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} + */ + interface Boolean { + /** + * Converts a string representation of a logical value to its Boolean object equivalent. + */ + parse(value: string): boolean; + } + } +//#endregion + //#region ASP.NET Types /** @@ -2260,6 +2262,7 @@ declare module Sys { /** * Provides a base class for all ASP.NET AJAX client behaviors. + * @see {@link http://msdn.microsoft.com/en-us/library/bb311020(v=vs.100).aspx} */ class Behavior extends Sys.Component { @@ -2370,12 +2373,90 @@ declare module Sys { */ class Control extends Sys.Component { + //#region Constructors + + /** + * When called from a derived class, initializes a new instance of that class. + * The Control constructor is a complete constructor function. However, because the Control class is an abstract base class, the constructor should be called only from derived classes. + * @param element + * The Sys.UI.DomElement object that the control will be associated with. + * + * @throws Error.invalidOperation Function + */ + constructor(element: Sys.UI.DomElement); + + //#endregion + + //#region Methods + + /** + * Adds a CSS class to the HTML Document Object Model (DOM) element that the control is attached to. + * Use the addCssClass method to add a CSS class to a control. If the CSS class has already been added to the control, addCssClass makes no changes to the control. + * @param className + * A string that contains the name of the CSS class to add. + */ + addCssClass(className: string): void; + /** + * Removes the current control from the application. + * The dispose method releases all resources from the Sys.UI.Control object, unbinds it from its associated HTML Document Object Model (DOM) element, and unregisters it from the application. + */ + dispose(): void; + /** + * Initializes the current Sys.UI.Control object. + * The initialize method initializes the control and sets the base Sys.Component.isInitialized property to true. You can override this method to include additional initialization logic for your derived class. + */ + initialize(): void; + /** + * Called when an event is raised by the raiseBubbleEvent method. + * + * The onBubbleEvent method returns false to make sure that unhandled events propagate (bubble) to the parent control. + * In derived classes, you should override the onBubbleEvent method and return true when events are handled to prevent the events from bubbling further. + * For an explanation of bubbling, see Sys.UI.Control raiseBubbleEvent Method. + * + * @param source + * The object that triggered the event. + * @param args + * The event arguments. + * @return + * false in all cases. + */ + onBubbleEvent(source: any, args: any): boolean; + /** + * Calls the onBubbleEvent method of the parent control. + * + * When the raiseBubbleEvent method is called, the source object and args values are sent to the onBubbleEvent handler of the current control. + * If onBubbleEvent returns false, they are sent to the onBubbleEvent handler of the parent control. + * This process continues until an onBubbleEvent event handler returns true, which indicates that the event has been handled. + * Any event that bubbles to the Sys.Application instance without being handled is ignored. + * + * @param source + * The object that triggered the event. + * @param args + * The event arguments. + */ + raiseBubbleEvent(source: any, args: any): void; + /** + * Removes a CSS class from the HTML Document Object Model (DOM) element that the control is attached to. + * Use the removeCssClass method to remove a CSS class from a control. If the CSS class has already been removed from the control, removeCssClass makes no changes to the control. + * + * @param className + * A string that contains the name of the CSS class to remove. + */ + removeCssClass(className: string): void; + /** + * Toggles a CSS class of the HTML Document Object Model (DOM) element that the control is attached to. + * @param className + * A string that contains the name of the CSS class to toggle. + */ + toggleCssClass(className: string): void; + + //#endregion } /** * Defines static methods and properties that provide helper APIs for manipulating and inspecting DOM elements. */ class DomElement { - + // todo } /** * Provides cross-browser access to DOM event properties and helper APIs that are used to attach handlers to DOM element events. @@ -2498,25 +2579,45 @@ declare module Sys { * */ clientX: any; // todo - + /** + * + */ clientY: any; // todo - + /** + * + */ ctrlKey: any; // todo - + /** + * + */ keyCode: any; // todo - + /** + * + */ offsetX: any; // todo - + /** + * + */ offsetY: any; // todo - + /** + * + */ screenX: any; // todo - + /** + * + */ screenY: any; // todo - + /** + * + */ shiftKey: any; // todo - + /** + * + */ target: any; // todo - + /** + * + */ type: any; // todo //#endregion @@ -2587,19 +2688,19 @@ declare module Sys { * Describes mouse button locations. */ enum MouseButton { - + // todo } /** * Creates an object that contains a set of integer coordinates that represent a position. */ class Point { - + // todo } /** * Describes the layout of a DOM element in the page when the element's visible property is set to false. */ enum VisibilityMode { - + // todo } } From f1dabc3be25e85c158e353578263affa11a86136 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:11:29 +0100 Subject: [PATCH 21/24] Added further tests and cleaned up tests. --- microsoft-ajax/microsoft.ajax-tests.ts | 55 ++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 532c9c11c..958ada9f9 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -8,11 +8,24 @@ function GlobalNamespace_Tests() { var arrayVar = new Array("Saturn", "Mars", "Jupiter"); + // Get + $get("Button1"); + $get("Button1", $get("Button2")); + + // Add handler $addHandler($get("Button1"), "click", () => { }); $addHandlers($get("Button1"), {}); + + // Remove handler $removeHandler($get("Button1"), "click", () => { }); + + // Find $find('MyComponent'); $find('MyComponent', $find('#test')); + + // Clear + $clearHandlers($get("Button1")); + } function BaseClassExtensions_Function_Tests() { @@ -99,6 +112,7 @@ function Sys_Application_Tests() { } function Sys_Application_LoadEventArgs_Tests() { + var a = new Sys.ApplicationLoadEventArgs(new Array(), true); var components = a.get_components(); @@ -106,7 +120,9 @@ function Sys_Application_LoadEventArgs_Tests() { } function Sys_Browser_Tests() { + var browser = Sys.Browser(); + } function Sys_CancelEventArgs_Tests() { @@ -144,6 +160,7 @@ function Sys_CancelEventArgs_Tests() { } function Sys_CollectionChange_Tests() { + var action = Sys.NotifyCollectionChangedAction.add; var newItems = []; var newStartingIndex = 1; @@ -160,6 +177,7 @@ function Sys_CollectionChange_Tests() { } function Sys_CommandEventArg_Tests() { + var commandName = "command name"; var commandArgument = "command argument"; var commandSource = "command source"; @@ -170,6 +188,7 @@ function Sys_CommandEventArg_Tests() { } function Sys_Component_Tests() { + var aComponent = new Sys.Component(); var properties: any; var events: any; @@ -200,15 +219,43 @@ function Sys_Component_Tests() { } function Sys_UI_Key_Tests() { - - var a = Sys.UI.Key.backspace; - var b = Sys.UI.Key.del; + var backspace = Sys.UI.Key.backspace; + var del = Sys.UI.Key.del; + var down = Sys.UI.Key.down; + var end = Sys.UI.Key.end; + var pageDown = Sys.UI.Key.pageDown; + var pageUp = Sys.UI.Key.pageUp; + var home = Sys.UI.Key.home; + var enter = Sys.UI.Key.enter; + var esc = Sys.UI.Key.esc; + var tab = Sys.UI.Key.tab; + var key = Sys.UI.Key.up; + var left = Sys.UI.Key.left; + var right = Sys.UI.Key.right; + var space = Sys.UI.Key.space; - var c = Sys.UI.Key.down; +} + +function Sys_UI_Control_Tests() { + + var domElementObj; + var className = "class Name"; + + var a = new Sys.UI.Control(domElementObj); + + a.addCssClass(className); + a.toggleCssClass(className); + a.removeCssClass(className); + + a.initialize(); + a.raiseBubbleEvent(domElementObj, className); + a.onBubbleEvent(domElementObj, className); + a.dispose(); } function Sys_CultureInfo_Tests() { + var currentCultureInfoObj = Sys.CultureInfo.CurrentCulture; var dtfCCObject = currentCultureInfoObj.dateTimeFormat; var invariantCultureInfoObj = Sys.CultureInfo.InvariantCulture; From 3e1b41f4c375dbc3501b164330a6229ca6567b32 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:49:26 +0100 Subject: [PATCH 22/24] Further Base Type Extension tests Realised i put all the base extensions into the declared module of BaseClassExtensions but shouldn't have. Added boolean to BaseClassExtensions to test Parse method. --- microsoft-ajax/microsoft.ajax-tests.ts | 44 +++ microsoft-ajax/microsoft.ajax.d.ts | 495 +++++++++++++------------ 2 files changed, 295 insertions(+), 244 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 958ada9f9..eadd53e37 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -57,6 +57,50 @@ function BaseClassExtensions_Function_Tests() { } }; } + +function BaseClassExtensions_Array_Tests() { + + var arrayVar = Array("one", "two", "three"); + + arrayVar.add(["one"], {}); + arrayVar.addRange({}, ["one", "two", "three"]); + arrayVar.clear(); + arrayVar.clone(); + arrayVar.contains({}); + arrayVar.dequeue(); + arrayVar.enqueue({}); + arrayVar.insert([1, 2, 3], 1, {}); + arrayVar.isArray({}); + arrayVar.parse("1, 2, 3, 4, 5"); + arrayVar.remove([1, 2, 3], 2); + arrayVar.removeAt([1, 2, 3], 1); + +} + +function BaseClassExtensions_Date_Tests() { + + var date = new Date(2014, 5, 25); + date.format("g"); + date.localeFormat("g"); + date.parseLocale("2014/05/25"); + date.parseInvariant("2014/05/25"); +} + +function BaseClassExtensions_Boolean_Tests() { + + (Boolean).parse("false"); + +} + +function BaseClassExtensions_Number_Tests() { + + var x: number = 5; + + x.format("d"); + x.localeFormat("c"); + x.parseInvariant("1"); + x.parseLocale("1"); +} function Sys_Application_Tests() { diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 1ccef3aaa..89803db41 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -13,6 +13,251 @@ //#region JavaScript Base Type Extensions + +/** +* Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. +* Object Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} +*/ +interface Object { + /** + * Formats a number by using the invariant culture. + */ + getType(instance: any): Type; + /** + * Returns a string that identifies the run-time type name of an object. + */ + getTypeName(instance: any): string; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. +* Array Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} +*/ +interface Array { + + new (arrayLength?: number): any[]; + new (arrayLength: number): T[]; + new (...items: T[]): T[]; + (arrayLength?: number): any[]; + (arrayLength: number): T[]; + (...items: T[]): T[]; + isArray(arg: any): boolean; + prototype: Array; + + /** + * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. + * @param array + * The array to add the item to. + * @param item + * + */ + add(array: any[], element: any): void; + /** + * Copies all the elements of the specified array to the end of an Array object. + */ + addRange(array: any, items: any): void; + /** + * Removes all elements from an Array object. + */ + clear(): void; + /** + * Creates a shallow copy of an Array object. + */ + clone(): any[]; + /** + * Determines whether an element is in an Array object. + */ + contains(element: any): boolean; + /** + * Removes the first element from an Array object. + */ + dequeue(): any; + /** + * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. + */ + enqueue(element: any): void; + /** + * Performs a specified action on each element of an Array object. + */ + forEach(array: any[], method: Function, instance: any[]): void; + /** + * Searches for the specified element of an Array object and returns its index. + */ + indexOf(array: any[], item: any, startIndex?: number): number; + /** + * Inserts a value at the specified location in an Array object. + */ + insert(array: any[], index: number, item: any); + /** + * Creates an Array object from a string representation. + */ + parse(value: string): any[]; + /** + * Removes the first occurrence of an element in an Array object. + */ + remove(array: any[], item: any): boolean; + /** + * Removes an element at the specified location in an Array object. + */ + removeAt(array: any[], index: number): void; +} + +/** + * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. + * String Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} + */ +interface String { + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; +} + +/** +* Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. +* Number Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} +*/ +interface Number { + /** + * Formats a number by using the invariant culture. + */ + format(format: string): string; + /** + * Formats a number by using the current culture. + */ + localeFormat(format: string): string; + /** + * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. + */ + parseInvariant(format: string): number; + /** + * Creates a numeric value from a locale-specific string. + */ + parseLocale(format: string): number; +} + +/** +* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). +* Error Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} +*/ +interface Error { + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; +} + +/** +* Provides extensions to the base ECMAScript (JavaScript) Date object. +* Date Type Extensions +* @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} +*/ +interface Date { + + /** + * Formats a date by using the invariant (culture-independent) culture. + */ + format(value: string): string; + /** + * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. + */ + localeFormat(value: string): string; + /** + * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. + * @exception (Debug) formats contains an invalid format. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseLocale(value: string): string; + parseLocale(value: string, formats?: string[]): string; + parseLocale(value: string, ...formats: string[]): string; + /** + * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. + * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. + * @param value + * A locale-specific string that represents a date. + * @param formats + * (Optional) An array of custom formats. + */ + parseInvariant(value: string): string; + parseInvariant(value: string, formats?: string[]): string; + parseInvariant(value: string, ...formats: string[]): string; +} + + declare module MicrosoftAjaxBaseTypeExtensions { /** @@ -53,260 +298,22 @@ declare module MicrosoftAjaxBaseTypeExtensions { validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; } - /** - * Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. - * Object Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb397554(v=vs.100).aspx} - */ - interface Object { - /** - * Formats a number by using the invariant culture. - */ - getType(instance: any): Type; - /** - * Returns a string that identifies the run-time type name of an object. - */ - getTypeName(instance: any): string; - } - - /** - * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. - * String Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} - */ - interface String { - /** - * Formats a number by using the invariant culture. - * @returns true if the end of the String object matches suffix; otherwise, false. - */ - endsWith(suffix: string): boolean; - /** - * Replaces each format item in a String object with the text equivalent of a corresponding object's value. - * @returns A copy of the string with the formatting applied. - */ - format(format: string, ...args: any[]): string; - /** - * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. - * @returns A copy of the string with the formatting applied. - */ - localeFormat(format: string, ...args: any[]): string; - /** - * Removes leading and trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start and end of the string. - */ - trim(): string; - /** - * Removes trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the end of the string. - */ - trimEnd(): string; - /** - * Removes leading white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start of the string. - */ - trimStart(): string; - } - - /** - * Extends the base ECMAScript (JavaScript) Number functionality with static and instance methods. - * Number Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb310835(v=vs.100).aspx} - */ - interface Number { - /** - * Formats a number by using the invariant culture. - */ - format(format: string): string; - /** - * Formats a number by using the current culture. - */ - localeFormat(format: string): string; - /** - * Returns a numeric value from a string representation of a number. This function is static and can be called without creating an instance of the object. - */ - parseInvariant(format: string): number; - /** - * Creates a numeric value from a locale-specific string. - */ - parseLocale(format: string): number; - } - - /** - * Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). - * Error Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} - */ - interface Error { - /** - * Creates an Error object that represents the Sys.ParameterCountException exception. - */ - parameterCount(message?: string): Error; - /** - * Creates an Error object that represents the Sys.NotImplementedException exception. - */ - notImplemented(message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentException exception. - */ - argument(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentNullException exception. - */ - argumentNull(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. - */ - argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentTypeException exception. - */ - argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. - */ - argumentUndefined(paramName?: string, message?: string): Error; - /** - * Creates an Error object that can contain additional error information. - */ - create(message?: string, errorInfo?: Object): Error; - /** - * Creates an Error object that represents the Sys.FormatException exception. - */ - format(message?: string): Error; - /** - * Creates an Error object that represents the Sys.InvalidOperationException exception. - */ - invalidOperation(message?: string): Error; - /** - * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. - */ - popStackFrame(): void; - } - - /** - * Provides extensions to the base ECMAScript (JavaScript) Date object. - * Date Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb310850(v=vs.100).aspx} - */ - interface Date { - /** - * Formats a date by using the invariant (culture-independent) culture. - */ - format(value: string): string; - /** - * Formats a date by using the current culture. This function is static and can be invoked without creating an instance of the object. - */ - localeFormat(value: string): string; - /** - * Creates a date from a locale-specific string by using the current culture. This function is static and can be invoked without creating an instance of the object. - * @exception (Debug) formats contains an invalid format. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseLocale(value: string): string; - parseLocale(value: string, formats?: string[]): string; - parseLocale(value: string, ...formats: string[]): string; - /** - * Creates a date from a string by using the invariant culture. This function is static and can be invoked without creating an instance of the object. - * @return If value is a valid string representation of a date in the invariant format, an object of type Date; otherwise, null. - * @param value - * A locale-specific string that represents a date. - * @param formats - * (Optional) An array of custom formats. - */ - parseInvariant(value: string): string; - parseInvariant(value: string, formats?: string[]): string; - parseInvariant(value: string, ...formats: string[]): string; - } - - /** - * Provides extensions to the base ECMAScript (JavaScript) Array functionality by adding static methods. - * Array Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} - */ - interface Array { - - new (arrayLength?: number): any[]; - new (arrayLength: number): T[]; - new (...items: T[]): T[]; - (arrayLength?: number): any[]; - (arrayLength: number): T[]; - (...items: T[]): T[]; - isArray(arg: any): boolean; - prototype: Array; - - /** - * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. - * @param array - * The array to add the item to. - * @param item - * - */ - add(array: any[], element: any): void; - /** - * Copies all the elements of the specified array to the end of an Array object. - */ - addRange(array: any, items: any): void; - /** - * Removes all elements from an Array object. - */ - clear(): void; - /** - * Creates a shallow copy of an Array object. - */ - clone(): any[]; - /** - * Determines whether an element is in an Array object. - */ - contains(element: any): boolean; - /** - * Removes the first element from an Array object. - */ - dequeue(): any; - /** - * Adds an element to the end of an Array object. Use the add function instead of the Array.enqueue function. - */ - enqueue(element: any): void; - /** - * Performs a specified action on each element of an Array object. - */ - forEach(array: any[], method: Function, instance: any[]): void; - /** - * Searches for the specified element of an Array object and returns its index. - */ - indexOf(array: any[], item: any, startIndex?: number): number; - /** - * Inserts a value at the specified location in an Array object. - */ - insert(array: any[], index: number, item: any); - /** - * Creates an Array object from a string representation. - */ - parse(value: string): any[]; - /** - * Removes the first occurrence of an element in an Array object. - */ - remove(array: any[], item: any): boolean; - /** - * Removes an element at the specified location in an Array object. - */ - removeAt(array: any[], index: number): void; - } - /** * Provides extensions to the base ECMAScript (JavaScript) Boolean object. * Boolean Type Extensions * @see {@link http://msdn.microsoft.com/en-us/library/bb397557(v=vs.100).aspx} */ interface Boolean { + + new (value?: any): Boolean; + (value?: any): boolean; + prototype: Boolean; + /** * Converts a string representation of a logical value to its Boolean object equivalent. */ - parse(value: string): boolean; + parse(value: string): Boolean; } - } //#endregion From 4eb8d6a16428b6f9de9dc87517326b75f00da1a7 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 18:50:25 +0100 Subject: [PATCH 23/24] Spacing and formatting. --- microsoft-ajax/microsoft.ajax-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index eadd53e37..7fe7dc9fe 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -313,8 +313,8 @@ function Sys_CultureInfo_Tests() { } function AspNetTypes_Tests() { - Type.registerNamespace("Samples"); + Type.registerNamespace("Samples"); var Samples; Samples.A = function () { }; @@ -350,6 +350,7 @@ function AspNetTypes_Tests() { /** Sample code from http://msdn.microsoft.com/en-us/library/bb386520(v=vs.100).aspx */ function CreatingCustomNonVisualClientComponentsTests() { + var Demo: any; Type.registerNamespace("Demo"); @@ -364,7 +365,6 @@ function CreatingCustomNonVisualClientComponentsTests() { Demo.Timer.prototype = { // OK to declare value types in the prototype - get_interval: function () { /// Interval in milliseconds return this._interval; From a73f6c8b118f7659fc34b298e6068e7e067a0354 Mon Sep 17 00:00:00 2001 From: Patrick Magee Date: Sun, 25 May 2014 19:56:10 +0100 Subject: [PATCH 24/24] Fixed issues with running npm test Identified several issues in many places both in tests and definitions. Fixed. --- microsoft-ajax/microsoft.ajax-tests.ts | 92 +++- microsoft-ajax/microsoft.ajax.d.ts | 612 +++++++++++++++++++------ 2 files changed, 560 insertions(+), 144 deletions(-) diff --git a/microsoft-ajax/microsoft.ajax-tests.ts b/microsoft-ajax/microsoft.ajax-tests.ts index 7fe7dc9fe..4a1266dab 100644 --- a/microsoft-ajax/microsoft.ajax-tests.ts +++ b/microsoft-ajax/microsoft.ajax-tests.ts @@ -28,6 +28,68 @@ function GlobalNamespace_Tests() { } +function BaseClassExtensions_Error_Tests() { + + // http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx + + function validateNumberRange(input: any, min: number, max: number) { + + // Verify the required parameters were defined. + if (input === undefined) { + // Throw a standard exception type. + var err = (Error).argumentNull("input", "A parameter was undefined."); + throw err; + } + else if (min === undefined) { + var err = (Error).argumentNull("min", "A parameter was undefined."); + throw err; + } + else if (max === undefined) { + var err = (Error).argumentNull("max", "A parameter was undefined."); + throw err; + } + else if (min >= max) { + var err = (Error).invalidOperation("The min parameter must be smaller than max parameter."); + throw err; + } + else if (isNaN(input)) { + var msg = "A number was not entered. "; + msg += (String).format("Please enter a number between {0} and {1}.", min, max); + + var err = (Error).create(msg); + throw err; + } + else if (input < min || input > max) { + msg = "The number entered was outside the acceptable range. "; + msg += (String).format("Please enter a number between {0} and {1}.", min, max); + + var err = (Error).create(msg); + + throw err; + } + + alert("The number entered was within the acceptable range."); + } + + var input: any = undefined; + var min = -10; + var max = 10; + + // Result: A thrown ErrorArgumentNull exception with the following Error object message: + // "Sys.ArgumentNullException: A parameter was undefined. Parameter name: input" + validateNumberRange(input, min, max); +} + +function BaseClassExtensions_String_Tests() { + + (String).format("Please enter a number between {0} and {1}.", 1, 2); + (String).endsWith("test"); + (String).localeFormat("Please enter a number between {0} and {1}", 1, 2); + (String).trim(); + (String).trimEnd(); + (String).trimStart(); +} + function BaseClassExtensions_Function_Tests() { /** Sample code from http://msdn.microsoft.com/en-us/library/dd409287(v=vs.100).aspx */ @@ -47,7 +109,7 @@ function BaseClassExtensions_Function_Tests() { /** Sample code from http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx */ var validateParametersTest = function () { var arguments = ['test1', 'test2']; - var insert = function Array$insert(array, index, item) { + var insert = function Array$insert(array: any[], index: number, item: any) { var e = (Function).validateParameters(arguments, [ { name: "array", type: Array, elementMayBeNull: true }, { name: "index", mayBeNull: true }, @@ -88,8 +150,7 @@ function BaseClassExtensions_Date_Tests() { function BaseClassExtensions_Boolean_Tests() { - (Boolean).parse("false"); - + (Boolean).parse("false"); } function BaseClassExtensions_Number_Tests() { @@ -178,7 +239,7 @@ function Sys_CancelEventArgs_Tests() { Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(CheckStatus); - var CheckStatus = function(sender, args) { + var CheckStatus = function(sender: any, args: any) { var prm = Sys.WebForms.PageRequestManager.getInstance(); @@ -195,7 +256,7 @@ function Sys_CancelEventArgs_Tests() { } } - var ActivateAlertDiv = function(visString, msg) { + var ActivateAlertDiv = function(visString: string, msg: string) { var adiv = $get(divElem); var aspan = $get(messageElem); adiv.style.visibility = visString; @@ -206,9 +267,9 @@ function Sys_CancelEventArgs_Tests() { function Sys_CollectionChange_Tests() { var action = Sys.NotifyCollectionChangedAction.add; - var newItems = []; + var newItems: any[] = []; var newStartingIndex = 1; - var oldItems = []; + var oldItems: any[] = []; var oldStartingIndex = 2; var MyCChg = new Sys.CollectionChange(action, newItems, newStartingIndex, oldItems, oldStartingIndex); @@ -283,7 +344,7 @@ function Sys_UI_Key_Tests() { function Sys_UI_Control_Tests() { - var domElementObj; + var domElementObj: any; var className = "class Name"; var a = new Sys.UI.Control(domElementObj); @@ -316,7 +377,8 @@ function AspNetTypes_Tests() { Type.registerNamespace("Samples"); - var Samples; + var Samples: any; + Samples.A = function () { }; var a = Samples.A; a.registerClass('Samples.A'); @@ -333,7 +395,7 @@ function AspNetTypes_Tests() { Samples.C.registerClass('Samples.C', Samples.A, Samples.B); - var isDerived; + var isDerived: boolean; isDerived = Samples.B.inheritsFrom(Samples.A); // Output: "false". alert(isDerived); @@ -342,7 +404,7 @@ function AspNetTypes_Tests() { // Output: "true". alert(isDerived); - var implementsInterface; + var implementsInterface: boolean; implementsInterface = Samples.C.implementsInterface(Samples.B); // Output: "true". alert(implementsInterface); @@ -369,7 +431,7 @@ function CreatingCustomNonVisualClientComponentsTests() { /// Interval in milliseconds return this._interval; }, - set_interval: function (value) { + set_interval: function (value: any) { if (this._interval !== value) { this._interval = value; this.raisePropertyChanged('interval'); @@ -384,7 +446,7 @@ function CreatingCustomNonVisualClientComponentsTests() { /// True if timer is enabled, false if disabled. return this._enabled; }, - set_enabled: function (value) { + set_enabled: function (value: any) { if (value !== this.get_enabled()) { this._enabled = value; this.raisePropertyChanged('enabled'); @@ -400,12 +462,12 @@ function CreatingCustomNonVisualClientComponentsTests() { }, // events - add_tick: function (handler) { + add_tick: function (handler: Function) { /// Adds a event handler for the tick event. /// The handler to add to the event. this.get_events().addHandler("tick", handler); }, - remove_tick: function (handler) { + remove_tick: function (handler: Function) { /// Removes a event handler for the tick event. /// The handler to remove from the event. this.get_events().removeHandler("tick", handler); diff --git a/microsoft-ajax/microsoft.ajax.d.ts b/microsoft-ajax/microsoft.ajax.d.ts index 89803db41..0f2be8007 100644 --- a/microsoft-ajax/microsoft.ajax.d.ts +++ b/microsoft-ajax/microsoft.ajax.d.ts @@ -13,7 +13,6 @@ //#region JavaScript Base Type Extensions - /** * Provides extended reflection-like functionality to the base ECMAScript (JavaScript) Object object. * Object Type Extensions @@ -35,7 +34,9 @@ interface Object { * Array Type Extensions * @see {@link http://msdn.microsoft.com/en-us/library/bb383786(v=vs.100).aspx} */ -interface Array { +interface Array { + + //#region lib.d.ts new (arrayLength?: number): any[]; new (arrayLength: number): T[]; @@ -46,6 +47,162 @@ interface Array { isArray(arg: any): boolean; prototype: Array; + ///** + // * Returns a string representation of an array. + // */ + //toString(): string; + //toLocaleString(): string; + ///** + // * Combines two or more arrays. + // * @param items Additional items to add to the end of array1. + // */ + //concat(...items: U[]): T[]; + ///** + // * Combines two or more arrays. + // * @param items Additional items to add to the end of array1. + // */ + //concat(...items: T[]): T[]; + ///** + // * Adds all the elements of an array separated by the specified separator string. + // * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + // */ + //join(separator?: string): string; + ///** + // * Removes the last element from an array and returns it. + // */ + //pop(): T; + ///** + // * Appends new elements to an array, and returns the new length of the array. + // * @param items New elements of the Array. + // */ + //push(...items: T[]): number; + ///** + // * Reverses the elements in an Array. + // */ + //reverse(): T[]; + ///** + // * Removes the first element from an array and returns it. + // */ + //shift(): T; + ///** + // * Returns a section of an array. + // * @param start The beginning of the specified portion of the array. + // * @param end The end of the specified portion of the array. + // */ + //slice(start?: number, end?: number): T[]; + + ///** + // * Sorts an array. + // * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. + // */ + //sort(compareFn?: (a: T, b: T) => number): T[]; + + ///** + // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + // * @param start The zero-based location in the array from which to start removing elements. + // */ + //splice(start: number): T[]; + + ///** + // * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + // * @param start The zero-based location in the array from which to start removing elements. + // * @param deleteCount The number of elements to remove. + // * @param items Elements to insert into the array in place of the deleted elements. + // */ + //splice(start: number, deleteCount: number, ...items: T[]): T[]; + + ///** + // * Inserts new elements at the start of an array. + // * @param items Elements to insert at the start of the Array. + // */ + //unshift(...items: T[]): number; + + ///** + // * Returns the index of the first occurrence of a value in an array. + // * @param searchElement The value to locate in the array. + // * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + // */ + //indexOf(searchElement: T, fromIndex?: number): number; + + ///** + // * Returns the index of the last occurrence of a specified value in an array. + // * @param searchElement The value to locate in the array. + // * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + // */ + //lastIndexOf(searchElement: T, fromIndex?: number): number; + + ///** + // * Determines whether all the members of an array satisfy the specified test. + // * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + ///** + // * Determines whether the specified callback function returns true for any element of an array. + // * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): boolean; + + ///** + // * Performs the specified action for each element in an array. + // * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; + + ///** + // * Calls a defined callback function on each element of an array, and returns an array that contains the results. + // * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; + + ///** + // * Returns the elements of an array that meet the condition specified in a callback function. + // * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + // * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + // */ + //filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; + + ///** + // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + ///** + // * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + ///** + // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; + ///** + // * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + // * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + // * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + // */ + //reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; + + ///** + // * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + // */ + //length: number; + + //[n: number]: T; + + //#endregion + + //#region Extensions + /** * Adds an element to the end of an Array object. This function is static and is invoked without creating an instance of the object. * @param array @@ -102,44 +259,8 @@ interface Array { * Removes an element at the specified location in an Array object. */ removeAt(array: any[], index: number): void; -} -/** - * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. - * String Type Extensions - * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} - */ -interface String { - /** - * Formats a number by using the invariant culture. - * @returns true if the end of the String object matches suffix; otherwise, false. - */ - endsWith(suffix: string): boolean; - /** - * Replaces each format item in a String object with the text equivalent of a corresponding object's value. - * @returns A copy of the string with the formatting applied. - */ - format(format: string, ...args: any[]): string; - /** - * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. - * @returns A copy of the string with the formatting applied. - */ - localeFormat(format: string, ...args: any[]): string; - /** - * Removes leading and trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start and end of the string. - */ - trim(): string; - /** - * Removes trailing white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the end of the string. - */ - trimEnd(): string; - /** - * Removes leading white-space characters from a String object. - * @returns A copy of the string with all white-space characters removed from the start of the string. - */ - trimStart(): string; + //#endregion } /** @@ -166,58 +287,6 @@ interface Number { parseLocale(format: string): number; } -/** -* Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). -* Error Type Extensions -* @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} -*/ -interface Error { - /** - * Creates an Error object that represents the Sys.ParameterCountException exception. - */ - parameterCount(message?: string): Error; - /** - * Creates an Error object that represents the Sys.NotImplementedException exception. - */ - notImplemented(message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentException exception. - */ - argument(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentNullException exception. - */ - argumentNull(paramName?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. - */ - argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentTypeException exception. - */ - argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; - /** - * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. - */ - argumentUndefined(paramName?: string, message?: string): Error; - /** - * Creates an Error object that can contain additional error information. - */ - create(message?: string, errorInfo?: Object): Error; - /** - * Creates an Error object that represents the Sys.FormatException exception. - */ - format(message?: string): Error; - /** - * Creates an Error object that represents the Sys.InvalidOperationException exception. - */ - invalidOperation(message?: string): Error; - /** - * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. - */ - popStackFrame(): void; -} - /** * Provides extensions to the base ECMAScript (JavaScript) Date object. * Date Type Extensions @@ -266,6 +335,9 @@ declare module MicrosoftAjaxBaseTypeExtensions { * @see {@link http://msdn.microsoft.com/en-us/library/dd409270(v=vs.100).aspx} */ interface Function { + + //#region lib.d.ts + /** * Creates a new function. * @param args A list of arguments the function accepts. @@ -273,7 +345,11 @@ declare module MicrosoftAjaxBaseTypeExtensions { new (...args: string[]): Function; (...args: string[]): Function; prototype: Function; - + + //#endregion + + //#region Extensions + /** * Creates a delegate function that retains the context first used during an objects creation. * @see {@link http://msdn.microsoft.com/en-us/library/dd393582(v=vs.100).aspx } @@ -296,6 +372,276 @@ declare module MicrosoftAjaxBaseTypeExtensions { * @see {@link http://msdn.microsoft.com/en-us/library/dd393712(v=vs.100).aspx } */ validateParameters(parameters: any, expectedParameters: Object[], validateParameterCount?: boolean): any; + + //#endregion + } + + /** + * Provides static functions that extend the built-in ECMAScript (JavaScript) Error type by including exception details and support for application-compilation modes (debug or release). + * Error Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb310947(v=vs.100).aspx} + */ + interface Error { + + //#region lib.d.ts + + name: string; + message: string; + + new (message?: string): Error; + (message?: string): Error; + prototype: Error; + + //#endregion + + //#region Extensions + + /** + * Creates an Error object that represents the Sys.ParameterCountException exception. + */ + parameterCount(message?: string): Error; + /** + * Creates an Error object that represents the Sys.NotImplementedException exception. + */ + notImplemented(message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentException exception. + */ + argument(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentNullException exception. + */ + argumentNull(paramName?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentOutOfRangeException exception. + */ + argumentOutOfRange(paramName?: string, actualValue?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentTypeException exception. + */ + argumentType(paramName?: string, actualType?: any, expectedType?: any, message?: string): Error; + /** + * Creates an Error object that represents the Sys.ArgumentUndefinedException exception. + */ + argumentUndefined(paramName?: string, message?: string): Error; + /** + * Creates an Error object that can contain additional error information. + */ + create(message?: string, errorInfo?: Object): Error; + /** + * Creates an Error object that represents the Sys.FormatException exception. + */ + format(message?: string): Error; + /** + * Creates an Error object that represents the Sys.InvalidOperationException exception. + */ + invalidOperation(message?: string): Error; + /** + * Updates the fileName and lineNumber properties of an Error instance to indicate where the error was thrown instead of where the error was created. Use this function if you are creating custom error types. + */ + popStackFrame(): void; + + //#endregion + } + + /** + * Provides extensions to the base ECMAScript (JavaScript) String object by including static and instance methods. + * String Type Extensions + * @see {@link http://msdn.microsoft.com/en-us/library/bb397472(v=vs.100).aspx} + */ + interface String { + + //#region lib.d.ts + + new (value?: any): String; + (value?: any): string; + prototype: String; + fromCharCode(...codes: number[]): string; + + /** Returns a string representation of a string. */ + toString(): string; + + /** + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ + charAt(pos: number): string; + + /** + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ + charCodeAt(index: number): number; + + /** + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ + concat(...strings: string[]): string; + + /** + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ + indexOf(searchString: string, position?: number): number; + + /** + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ + lastIndexOf(searchString: string, position?: number): number; + + /** + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ + localeCompare(that: string): number; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + match(regexp: string): string[]; + + /** + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + */ + match(regexp: RegExp): string[]; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: string, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A String object or string literal that represents the regular expression + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. + */ + replace(searchValue: RegExp, replaceValue: string): string; + + /** + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A Regular Expression object containing the regular expression pattern and applicable flags + * @param replaceValue A function that returns the replacement text. + */ + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: string): number; + + /** + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ + search(regexp: RegExp): number; + + /** + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ + slice(start?: number, end?: number): string; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: string, limit?: number): string[]; + + /** + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ + split(separator: RegExp, limit?: number): string[]; + + /** + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ + substring(start: number, end?: number): string; + + /** Converts all the alphabetic characters in a string to lowercase. */ + toLowerCase(): string; + + /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ + toLocaleLowerCase(): string; + + /** Converts all the alphabetic characters in a string to uppercase. */ + toUpperCase(): string; + + /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ + toLocaleUpperCase(): string; + + /** Returns the length of a String object. */ + length: number; + + // IE extensions + /** + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ + substr(from: number, length?: number): string; + + [index: number]: string; + + //#endregion + + //#region Extensions + + /** + * Formats a number by using the invariant culture. + * @returns true if the end of the String object matches suffix; otherwise, false. + */ + endsWith(suffix: string): boolean; + /** + * Replaces each format item in a String object with the text equivalent of a corresponding object's value. + * @returns A copy of the string with the formatting applied. + */ + format(format: string, ...args: any[]): string; + /** + * Replaces the format items in a String object with the text equivalent of a corresponding object's value. The current culture is used to format dates and numbers. + * @returns A copy of the string with the formatting applied. + */ + localeFormat(format: string, ...args: any[]): string; + /** + * Removes leading and trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start and end of the string. + */ + trim(): string; + /** + * Removes trailing white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the end of the string. + */ + trimEnd(): string; + /** + * Removes leading white-space characters from a String object. + * @returns A copy of the string with all white-space characters removed from the start of the string. + */ + trimStart(): string; + + //#endregion } /** @@ -305,17 +651,30 @@ declare module MicrosoftAjaxBaseTypeExtensions { */ interface Boolean { + //#region lib.d.ts + new (value?: any): Boolean; (value?: any): boolean; prototype: Boolean; + //#endregion + + //#region Extensions + /** * Converts a string representation of a logical value to its Boolean object equivalent. */ parse(value: string): Boolean; + + //#endregion } } +// declare var Error: MicrosoftAjaxBaseTypeExtensions.Error; +// declare var String: MicrosoftAjaxBaseTypeExtensions.String; +// declare var Boolean: MicrosoftAjaxBaseTypeExtensions.Boolean; +// declare var Function: MicrosoftAjaxBaseTypeExtensions.Function; + //#endregion //#region ASP.NET Types @@ -397,7 +756,7 @@ declare class Type { * The fully qualified name of the class to test as a base class for the current instance. * @return true if the instance inherits from parentType; otherwise, false. */ - inheritsFrom(parentType: string); + inheritsFrom(parentType: string): boolean; /** * Initializes the base class and its members in the context of a given instance, which provides the model for inheritance and for initializing base members. * @param instance @@ -555,7 +914,7 @@ declare function $find(id: string, parent?: HTMLElement): Sys.Component; * @param handler The event handler to add. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean); +declare function $addHandler(element: Element, eventName: string, handler: Function, autoRemove?: boolean): void; /** * Provides a shortcut to the addHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -565,7 +924,7 @@ declare function $addHandler(element: Element, eventName: string, handler: Funct * @param handlerOwner (Optional) The object instance that is the context for the delegates that should be created from the handlers. * @param autoRemove (Optional) A boolean value that determines whether the handler should be removed automatically when the element is disposed. */ -declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean); +declare function $addHandlers(element: Element, events: any, handlerOwner?: any, autoRemove?: boolean): void; /** * Provides a shortcut to the clearHandlers method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -573,15 +932,19 @@ declare function $addHandlers(element: Element, events: any, handlerOwner?: any, * @see {@link http://msdn.microsoft.com/en-us/library/bb310959(v=vs.100).aspx} * @param The DOM element that exposes the events. */ -declare function $clearHandlers(element: Element); +declare function $clearHandlers(element: Element): void; /** * Provides a shortcut to the getElementById method of the Sys.UI.DomElement class. This member is static and can be invoked without creating an instance of the class. * @see {@link http://msdn.microsoft.com/en-us/library/bb397717(v=vs.100).aspx} -* @param id The ID of the DOM element to find. -* @param element The parent element to search. The default is the document element. +* @param id +* The ID of the DOM element to find. +* @param element +* The parent element to search. The default is the document element. +* @return +* The element */ -declare function $get(id: string, element?: Element); +declare function $get(id: string, element?: Element): HTMLElement; /** * Provides a shortcut to the removeHandler method of the Sys.UI.DomEvent class. This member is static and can be invoked without creating an instance of the class. @@ -590,7 +953,7 @@ declare function $get(id: string, element?: Element); * @param eventName The name of the DOM event. * @param handler The event handler to remove. */ -declare function $removeHandler(element, eventName, handler); +declare function $removeHandler(element: Element, eventName: string, handler: Function): void; //#endregion @@ -616,7 +979,7 @@ declare module Sys { //#region Constructors - constructor(); + constructor(): void; //#endregion @@ -1088,28 +1451,28 @@ declare module Sys { * @param item * The item to add. */ - static add(target: any[], item): void; + static add(target: any[], item: any): void; /** * Adds an event handler to the target. * @param target The array to which an event handler will be added. * @param handler The event handler. */ - static addCollectionChanged(target, handler: Function): void; + static addCollectionChanged(target: any, handler: Function): void; /** * Adds an observable event handler to the target. * @param eventName A string that contains the event name. * @param handler The added function. */ - static addEventHandler(target, eventName: string, handler: Function): void; + static addEventHandler(target: any, eventName: string, handler: Function): void; /** * Adds a propertyChanged event handler to the target. * @param target The object to observe. * @param handler The function handler to add. */ - static addPropertyChanged(target, handler: Function): void; + static addPropertyChanged(target: any, handler: Function): void; /** * Adds items to the collection in an observable manner. @@ -1217,7 +1580,7 @@ declare module Sys { * @param propertyName A string that contains the name of the property or field to set. * @param value The value to set. */ - static setValue(target, propertyName, value): void; + static setValue(target: any, propertyName: string, value: any): void; //#endregion @@ -2146,48 +2509,40 @@ declare module Sys { * Gets or sets the name of the default failure callback function. */ get_defaultFailedCallback(): Function; - /** * Gets or sets the name of the default failure callback function. * @param value * A string that contains the name of the default failure callback function. */ set_defaultFailedCallback(value: string): void; - /** * Gets or sets the default succeeded callback function for the service. * @return A reference to the succeeded callback function for the service. */ defaultSucceededCallback(): Function; - /** * Gets or sets the default succeeded callback function for the service. * @param value * A reference to the succeeded callback function for the service. */ defaultSucceededCallback(value: Function): void; - /** * Gets or sets the default user context for the service. * @return A reference to the user context for the service. */ defaultUserContext(): Object - /** * Gets or sets the default user context for the service. * @param value * A reference to the user context for the service. */ defaultUserContext(value: Object): void; - /** * Gets the authentication state of the current user. * The value of this property is set by the ScriptManager object during a page request. * @return true if the current user is logged in; otherwise, false. */ get_isLoggedIn(): boolean; - - /** * Gets or sets the authentication service path. * You usually set the path property in declarative markup. This value can be an absolute virtual path, a relative virtual path, or a fully qualified domain name and a path. @@ -2195,14 +2550,12 @@ declare module Sys { * @param value * The authentication service path. */ - set_path(value: string); - + set_path(value: string): void; /** * Gets or sets the authentication service path. * By default, the path property is set to an empty string. If you do not set the path property, the internal default path is used, which points to the built-in authentication service. */ get_path(): string; - /** * Gets or sets the authentication service time-out value. * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. @@ -2210,12 +2563,13 @@ declare module Sys { * @param value * The time-out value in milliseconds. */ - set_timeout(value): void; - + set_timeout(value: number): void; /** * Gets or sets the authentication service time-out value. * The timeout property represents the time in milliseconds that the current instance of the Sys.Net.WebRequestExecutor class should wait before timing out the request. * The timeout in milliseconds + * @return + * The timeout */ get_timeout(): number; @@ -2979,7 +3333,7 @@ declare module Sys { * @param beginRequestHandler * The name of the handler method that will be called. */ - add_beginRequest(beginRequestHandler: (sender, args) => void): void; + add_beginRequest(beginRequestHandler: (sender: any, args: any) => void): void; /** * Raised before the processing of an asynchronous postback starts and the postback request is sent to the server. * @param beginRequestHandler @@ -2991,49 +3345,49 @@ declare module Sys { * @param endRequestHandler * The name of the handler method that will be called. */ - add_endRequest(endRequestHandler: (sender, args) => void): void; + add_endRequest(endRequestHandler: (sender: any, args: any) => void): void; /** * Raised after an asynchronous postback is finished and control has been returned to the browser. * @param endRequestHandler * The name of the handler method that will be removed. */ - remove_endRequest(endRequestHandler: (sender, args) => void): void; + remove_endRequest(endRequestHandler: (sender: any, args: any) => void): void; /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ - add_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + add_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; /** * Raised during the initialization of the asynchronous postback. * @param initializeRequestHandler * The name of the handler method that will be called. */ - remove_initializeRequest(initializeRequestHandler: (sender, args) => void): void; + remove_initializeRequest(initializeRequestHandler: (sender: any, args: any) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + add_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; /** * Raised after all content on the page is refreshed as a result of either a synchronous or an asynchronous postback. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoaded(pageLoadedHandler: (sender, args) => void): void; + remove_pageLoaded(pageLoadedHandler: (sender: any, args: any) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - add_pageLoading(pageLoadingHandler: (sender, args) => void): void; + add_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; /** * Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. * @param pageLoadedHandler * The name of the handler method that will be called. */ - remove_pageLoading(pageLoadingHandler: (sender, args) => void): void; + remove_pageLoading(pageLoadingHandler: (sender: any, args: any) => void): void; //#endregion @@ -3077,7 +3431,7 @@ declare module Sys { //#region Properties - get_isInAsyncPostBack(): boolean; + get_isInAsyncPostBack(): boolean; //#endregion }