From 704fb61af713634247f5ac687918d41524005088 Mon Sep 17 00:00:00 2001 From: gandjustas Date: Sun, 4 Aug 2013 18:25:39 +0400 Subject: [PATCH] SharePoint definitions: Added RequestExecutor, Animations, improved SOD, small bug fixes. --- sharepoint/SharePoint.d.ts | 362 ++++++++++++++++++++++++++++++------- 1 file changed, 293 insertions(+), 69 deletions(-) diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 056087bed..335c48a2d 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped + declare module Sys { export class EventArgs { static Empty: Sys.EventArgs; @@ -34,8 +35,86 @@ declare module Sys { } } module Net { - export class WebRequest { } - export class WebRequestExecutor { } + export class WebRequest { + get_url(): string; + set_url(value: string): void; + get_httpVerb(): string; + set_httpVerb(value: string): void; + get_timeout(): number; + set_timeout(value: number): void; + get_body(): string; + set_body(value: string): void; + get_headers(): { [key: string]: string; }; + get_userContext(): any; + set_userContext(value: any): void; + get_executor(): WebRequestExecutor; + set_executor(value: WebRequestExecutor): void; + + getResolvedUrl(); string; + invoke(): void; + completed(args: Sys.EventArgs): void; + + add_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + remove_completed(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + } + + export class WebRequestExecutor { + get_aborted(): boolean; + get_responseAvailable(): boolean; + get_responseData(): string; + get_object(): any; + get_started(): boolean; + get_statusCode(): number; + get_statusText(): string; + get_timedOut(): boolean; + get_xml(): Document; + get_webRequest(): WebRequest; + abort(): void; + executeRequest(): void; + getAllResponseHeaders(): string; + getResponseHeader(key: string): string; + } + + export class NetworkRequestEventArgs extends EventArgs { + get_webRequest(): WebRequest; + } + + + export class WebRequestManager { + static get_defaultExecutorType(): string; + static set_defaultExecutorType(value: string): void; + static get_defaultTimeout(): number; + static set_defaultTimeout(value: number): void; + + static executeRequest(request: WebRequest):void; + static add_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + static remove_completedRequest(handler: (executor: WebRequestExecutor, args: Sys.EventArgs) => void ): void; + static add_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs) => void ): void; + static remove_invokingRequest(handler: (executor: WebRequestExecutor, args: NetworkRequestEventArgs ) => void ): void; + } + + export class WebServiceProxy { + static invoke( + servicePath: string, + methodName: string, + useGet?: boolean, + params?: any, + onSuccess?: (result: string, eventArgs: EventArgs) => void , + onFailure?: (error: WebServiceError) => void , + userContext?: any, + timeout?: number, + enableJsonp?: boolean, + jsonpCallbackParameter?: string): WebRequest; + } + + export class WebServiceError { + get_errorObject(): any; + get_exceptionType(): any; + get_message(): string; + get_stackTrace(): string; + get_statusCode(): number; + get_timedOut(): bool; + } } interface IDisposable { dispose(): void; @@ -47,6 +126,139 @@ declare var $get: { (id: string): HTMLElement; }; declare var $addHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void ): void; }; declare var $removeHandler: { (element: HTMLElement, eventName: string, handler: (e: Event) => void ): void; }; +declare module SP { + export class SOD { + static execute(fileName: string, functionName: string, ...args: any[]): void; + static executeFunc(fileName: string, typeName: string, fn: () => void ): void; + static executeOrDelayUntilEventNotified(func: Function, eventName: string): bool; + static executeOrDelayUntilScriptLoaded(func: () => void , depScriptFileName: string): bool; + static notifyScriptLoadedAndExecuteWaitingJobs(scriptFileName: string): void; + static notifyEventAndExecuteWaitingJobs(eventName: string, args?: any[]): void; + static registerSod(fileName: string, url: string): void; + static registerSodDep(fileName: string, dependentFileName: string): void; + static loadMultiple(keys: string[], fn: () => void , bSync?: boolean): void; + static delayUntilEventNotified(func: Function, eventName: string): void; + + static get_prefetch(): bool; + static set_prefetch(value: bool): void; + + static get_ribbonImagePrefetchEnabled(): bool; + static set_ribbonImagePrefetchEnabled(value: bool): void; + + + } +} + +/** Register function to rerun on partial update in MDS-enabled site.*/ +declare function RegisterModuleInit(scriptFileName: string, initFunc: () => void ): void; + +/** Provides access to url and query string parts.*/ +declare class JSRequest { + /** Query string parts.*/ + static QueryString: { [parameter: string]: string; }; + + /** initializes class.*/ + static EnsureSetup(): void; + + /** Current file name (after last '/' in url).*/ + static FileName: string; + + /** Current file path (before last '/' in url).*/ + static PathName: string; +} + +declare class _spPageContextInfo { + static alertsEnabled: bool; //true + static allowSilverlightPrompt: string; //"True" + static clientServerTimeDelta: number; //-182 + static crossDomainPhotosEnabled: bool; //true + static currentCultureName: string; //"ru-RU" + static currentLanguage: number; //1049 + static currentUICultureName: string; //"ru-RU" + static layoutsUrl: string; //"_layouts/15" + static pageListId: string; //"{06ee6d96-f27f-4160-b6bb-c18f187b18a7}" + static pagePersonalizationScope: string; //1 + static serverRequestPath: string; //"/SPTypeScript/Lists/ConditionalFormattingTasksList/AllItems.aspx" + static siteAbsoluteUrl: string; // "https://gandjustas-7b20d3715e8ed4.sharepoint.com" + static siteClientTag: string; //"0$$15.0.4454.1021" + static siteServerRelativeUrl: string; // "/" + static systemUserKey: string; //"i:0h.f|membership|10033fff84e7cb2b@live.com" + static tenantAppVersion: string; //"0" + static userId: number; //12 + static webAbsoluteUrl: string; //"https://gandjustas-7b20d3715e8ed4.sharepoint.com/SPTypeScript" + static webLanguage: number; //1049 + static webLogoUrl: string; //"/_layouts/15/images/siteIcon.png?rev=23" + static webPermMasks: { High: number; Low: number; }; + static webServerRelativeUrl: string; //"/SPTypeScript" + static webTemplate: string; //"17" + static webTitle: string; //"SPTypeScript" + static webUIVersion: number; //15 +} + +declare function STSHtmlEncode(value: string): string; + +declare function AddEvtHandler(element: HTMLElement, event: string, func: EventListener): void; + +/** Gets query string parameter */ +declare function GetUrlKeyValue(key: string): string; +declare module SP { + export enum RequestExecutorErrors { + requestAbortedOrTimedout, + unexpectedResponse, + httpError, + noAppWeb, + domainDoesNotMatch, + noTrustedOrigins, + iFrameLoadError + } + + export class RequestExecutor { + constructor(url: string, options?: any); + get_formDigestHandlingEnabled(): boolean; + set_formDigestHandlingEnabled(value: boolean): void; + get_iFrameSourceUrl(): string; + set_iFrameSourceUrl(value: string): void; + executeAsync(requestInfo:RequestInfo): void; + attemptLogin(returnUrl:string, success: (response: ResponseInfo) => void , error?: (response: ResponseInfo, error: RequestExecutorErrors, statusText: string) => void): void; + } + + export interface RequestInfo { + url: string; + method?: string; + headers?: { [key: string]: string; }; + /** Can be string or bytearray depending on binaryStringRequestBody field */ + body?: any; + binaryStringRequestBody?: boolean; + + /** Currently need fix to get ginary response. Details: http://techmikael.blogspot.ru/2013/07/how-to-copy-files-between-sites-using.html */ + binaryStringResponseBody?: boolean; + timeout?: number; + success?: (response: ResponseInfo) => void; + error?: (response: ResponseInfo, error: RequestExecutorErrors, statusText: string) => void; + state?: any; + } + + export interface ResponseInfo { + statusCode?: number; + statusText?: string; + responseAvailable: boolean; + allResponseHeaders?: string; + headers?: { [key: string]: string; }; + contentType?: string; + /** Can be string or bytearray depending on request.binaryStringResponseBody field */ + body?: any; + state?: any; + } + + export class ProxyWebRequestExecutor extends Sys.Net.WebRequestExecutor { + constructor(url: string, options?: any); + } + + export class ProxyWebRequestExecutorFactory implements SP.IWebRequestExecutorFactory { + constructor(url: string, options?: any); + createWebRequestExecutor(): ProxyWebRequestExecutor; + } +} interface MQuery { (selector: string, context?: any): MQueryResultSetElements; @@ -63,7 +275,7 @@ interface MQuery extend(target: any, ...objs: any[]): Object; extend(deep: boolean, target: any, ...objs: any[]): Object; - makeArray(obj: any): any[]; + makeArray(obj: any): any[]; isDefined(obj: any): boolean; isNotNull(obj: any): boolean; @@ -237,6 +449,7 @@ interface MQueryResultSetElements extends MQueryResultSet{ } interface MQueryResultSet { + [index: number]: T; contains(contained: T): boolean; filter(fn: (elementOfArray: T, indexInArray: number) => boolean, context?: any): MQueryResultSet; @@ -1033,7 +1246,7 @@ declare module SPClientTemplates { ListTemplateType?: number; /** Base view ID (SPView.BaseViewID) for which the template should be applied. If not defined, the templates will be applied to all views. */ - BaseViewID?: number; + BaseViewID?: any; } export class TemplateManager { static RegisterTemplateOverrides(renderCtx: TemplateOverridesOptions): void; @@ -1148,6 +1361,82 @@ declare module SPClientForms { } +declare module SPAnimation { + export enum Attribute { + PositionX, + PositionY, + Height, + Width, + Opacity + } + + export enum ID { + Basic_Show, + Basic_SlowShow, + Basic_Fade, + Basic_Move, + Basic_Size, + Content_SlideInFadeInRight, + Content_SlideInFadeInRightInc, + Content_SlideOutFadeOutRight, + Content_SlideInFadeInLeft, + Content_SlideInFadeInLeftInc, + SmallObject_SlideInFadeInTop, + SmallObject_SlideInFadeInLeft, + Test_Instant, + Test_Hold, + Basic_Opacity, + Basic_QuickShow, + Basic_QuickFade, + Content_SlideInFadeInGeneric, + Basic_StrikeThrough, + SmallObject_SlideInFadeInBottom, + SmallObject_SlideOutFadeOutBottom, + Basic_QuickSize + } + + export class Settings { + static DisableAnimation(): void; + static DisableSessionAnimation(): void; + static IsAnimationEnabled(): boolean; + } + + + export class State { + SetAttribute(attributeId: Attribute, value: number); + GetAttribute(attributeId: Attribute): number; + GetDataIndex(attributeId: Attribute): number + } + + export class Object{ + constructor(animationID: ID, delay: number, element: HTMLElement, finalState: State, finishFunc?: (data: any) => void , data?: any); + constructor(animationID: ID, delay: number, element: HTMLElement[], finalState: State, finishFunc?: (data: any) => void , data?: any); + RunAnimation(): void; + } +} + +declare module SPAnimationUtility{ + export class BasicAnimator { + static FadeIn(element: HTMLElement, finishFunc?: (data: any) => void , data?: any): void; + static FadeOut (element: HTMLElement, finishFunc?: (data: any) => void , data?: any): void; + static Move(element: HTMLElement, posX:number, posY:number, finishFunc?: (data: any) => void , data?: any): void; + static StrikeThrough(element: HTMLElement, strikeThroughWidth: number, finishFunc?: (data: any) => void , data?: any): void; + static Resize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void , data?: any): void; + static CommonResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: (data: any) => void , data: any, animationId:SPAnimation.ID): void; + static QuickResize(element: HTMLElement, newHeight: number, newWidth: number, finishFunc?: (data: any) => void , data?: any): void; + static ResizeContainerAndFillContent(element: HTMLElement, newHeight: number, newWidth: number, finishFunc: () => void , fAddToEnd: boolean): void; + static GetWindowScrollPosition(): { x: number; y: number; }; + static GetLeftOffset(element: HTMLElement): number; + static GetTopOffset(element: HTMLElement): number; + static GetRightOffset(element: HTMLElement): number; + static PositionElement(element: HTMLElement, topValue: number, leftValue: number, heightValue: number, widthValue: number): void; + static PositionAbsolute(element: HTMLElement): void; + static PositionRelative(element: HTMLElement): void; + static PositionRelativeExact(element: HTMLElement, topValue: number, leftValue: number, heightValue: number, widthValue: number): void; + static PositionAbsoluteExact(element: HTMLElement, topValue: number, leftValue: number, heightValue: number, widthValue: number): void; + static IsPositioned(element: HTMLElement): boolean; + } +} interface IEnumerator { get_current(): T; @@ -5337,71 +5626,6 @@ declare module SP { } } } -declare module SP { - export class SOD { - static execute(fileName: string, functionName: string, args?: any[]): void; - static executeFunc(fileName: string, functionName: string, fn: () => void): void; - static executeOrDelayUntilEventNotified(func: () => void, eventName: string): bool; - static executeOrDelayUntilScriptLoaded(func: () => void, depScriptFileName: string): bool; - static notifyScriptLoadedAndExecuteWaitingJobs(scriptFileName: string): void; - static notifyEventAndExecuteWaitingJobs(eventName: string): void; - static registerSod(fileName: string, url: string): void; - static registerSodDep(fileName: string, dependentFileName: string): void; - } -} - -/** Register function to rerun on partial update in MDS-enabled site.*/ -declare function RegisterModuleInit(scriptFileName: string, initFunc: () => void ): void; - -/** Provides access to url and query string parts.*/ -declare class JSRequest { - /** Query string parts.*/ - static QueryString: { [parameter: string]: string; }; - - /** initializes class.*/ - static EnsureSetup(): void; - - /** Current file name (after last '/' in url).*/ - static FileName: string; - - /** Current file path (before last '/' in url).*/ - static PathName: string; -} - -declare class _spPageContextInfo { - static alertsEnabled: bool; //true - static allowSilverlightPrompt: string; //"True" - static clientServerTimeDelta: number; //-182 - static crossDomainPhotosEnabled: bool; //true - static currentCultureName: string; //"ru-RU" - static currentLanguage: number; //1049 - static currentUICultureName: string; //"ru-RU" - static layoutsUrl: string; //"_layouts/15" - static pageListId: string; //"{06ee6d96-f27f-4160-b6bb-c18f187b18a7}" - static pagePersonalizationScope: string; //1 - static serverRequestPath: string; //"/SPTypeScript/Lists/ConditionalFormattingTasksList/AllItems.aspx" - static siteAbsoluteUrl: string; // "https://gandjustas-7b20d3715e8ed4.sharepoint.com" - static siteClientTag: string; //"0$$15.0.4454.1021" - static siteServerRelativeUrl: string; // "/" - static systemUserKey: string; //"i:0h.f|membership|10033fff84e7cb2b@live.com" - static tenantAppVersion: string; //"0" - static userId: number; //12 - static webAbsoluteUrl: string; //"https://gandjustas-7b20d3715e8ed4.sharepoint.com/SPTypeScript" - static webLanguage: number; //1049 - static webLogoUrl: string; //"/_layouts/15/images/siteIcon.png?rev=23" - static webPermMasks: { High: number; Low: number; }; - static webServerRelativeUrl: string; //"/SPTypeScript" - static webTemplate: string; //"17" - static webTitle: string; //"SPTypeScript" - static webUIVersion: number; //15 -} - -declare function STSHtmlEncode(value: string): string; - -declare function AddEvtHandler(element: HTMLElement, event:string, func: EventListener): void; - -/** Gets query string parameter */ -declare function GetUrlKeyValue(key: string): string; declare module SP { export module Sharing {