From 7f74fc1a314a0cecaab10522e5e84a804711fa48 Mon Sep 17 00:00:00 2001 From: Dustin Wehr Date: Thu, 11 Jun 2015 17:43:06 -0400 Subject: [PATCH] Add definition for gapi.drive.realtime.Document --- .../google-drive-realtime-api.d.ts | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/google-drive-realtime-api/google-drive-realtime-api.d.ts b/google-drive-realtime-api/google-drive-realtime-api.d.ts index 8bb4af5c0..b1d970e3c 100644 --- a/google-drive-realtime-api/google-drive-realtime-api.d.ts +++ b/google-drive-realtime-api/google-drive-realtime-api.d.ts @@ -19,6 +19,9 @@ declare module gapi.drive.realtime { type GoogEventHandler = ((evt:ObjectChangedEvent) => void) | ((e:Event) => void) | EventListener; + // TODO + export class Collaborator {} + // Complete // https://developers.google.com/google-apps/realtime/reference/gapi.drive.realtime.CollaborativeObject export class CollaborativeObject { @@ -395,18 +398,57 @@ declare module gapi.drive.realtime { } - // INCOMPLETE + // Complete // https://developers.google.com/google-apps/realtime/reference/gapi.drive.realtime.Document export class Document { - // Gets the collaborative model associated with this document. - // @return non-null Model - getModel():Model; + // Whether the document is closed. Read-only; call close() to close the document. + isClosed : boolean; + + // Whether the document is stored in Google Drive. Read-only. + // This property is false for documents created using gapi.drive.realtime.newInMemoryDocument or + // gapi.drive.realtime.loadFromJson and true for all other documents. + isInGoogleDrive : boolean; + + // The approximate amount of time (in milliseconds) that changes have been waiting to be saved in Google Drive. + // If there are no unsaved changes or this is an in-memory document, this value is always 0. + // This value should remain low (for example, less than a few seconds) as long as the network is healthy and + // changes are being saved as quickly as they are generated. If the network is unreliable or down, or if changes + // are being made to the model more quickly than they can be saved, this value will continue to grow until the + // network catches up and the changes are successfully saved. + saveDelay : number; + + // Adds an event listener to the event target. The same handler can only be added once per the type. + // Even if you add the same handler multiple times using the same type then it will only be called once when + // the event is dispatched. + addEventListener(type:string, listener:GoogEventHandler, opt_capture?:boolean) : void; // Closes the document and disconnects from the server. // After this function is called, event listeners will no longer fire and attempts to access the document, model, // or model objects will throw a gapi.drive.realtime.DocumentClosedError. // Calling this function after the document has been closed will have no effect. close():void; + + // Gets an array of collaborators active in this session. Each collaborator is a jsMap with these fields: + // sessionId, userId, displayName, color, isMe, isAnonymous. + getCollaborators() : Collaborator[]; + + // Gets the collaborative model associated with this document. + // @return non-null Model + getModel():Model; + + // Removes all event listeners from this object. + removeAllEventListeners() : void; + + // Removes an event listener from the event target. The handler must be the same object as the one added. + // If the handler has not been added then nothing is done. + removeEventListener(type:string, listener:GoogEventHandler, opt_capture?:boolean) : void; + + // Saves a copy of this document to a new file. After this function is called, all changes to this document no + // longer affect the old document and are instead saved to the new file. + // The provided file ID must refer to a valid file in Drive which does not have any Realtime data for your app. + // This function can also be used on an in-memory file to convert it to a Drive-connected file. + saveAs(fileId:string) : void; + } }