WeavyApp

Base class for representation of apps in Weavy.

Kind: global class

Eventhandling

.on()

Event listener registration for the specific app. Only recieves events that belong to the app.

Kind: instance method of WeavyApp
Category: eventhandling
Example
weavy.space("myspace").app("myapp").on("open", function(e) { ... })

.one()

One time event listener registration for the specific app. Is only triggered once and only recieves events that belong to the app.

Kind: instance method of WeavyApp
Category: eventhandling
Example
weavy.space("myspace").app("myapp").one("open", function(e) { ... })

.off()

Event listener unregistration for the specific app.

Kind: instance method of WeavyApp
Category: eventhandling
Example
weavy.space("myspace").app("myapp").off("open", function(e) { ... })

.triggerEvent()

Triggers events on the specific app. The events will also bubble up to the space and then the weavy instance.

Kind: instance method of WeavyApp
Category: eventhandling
Example
weavy.space("myspace").app("myapp").triggerEvent("myevent", [eventData])

Events

"open" ⇒ Object

Triggered when the app panel is opened.

Kind: event emitted by WeavyApp
Extends: WeavyPanel#event:panel-open
Category: events
Properties
NameDescription
space : WeavySpace

The space that the app belongs to

app : WeavyApp

The app that fires the event


"toggle" ⇒ Object

Triggered when the app panel is toggled. Is always followed by either open event or close event.

Kind: event emitted by WeavyApp
Extends: WeavyPanel#event:panel-toggle
Category: events
Properties
NameDescription
space : WeavySpace

The space that the app belongs to

app : WeavyApp

The app that fires the event


"close" ⇒ Object

Triggered when the app panel is closed.

Kind: event emitted by WeavyApp
Extends: WeavyPanel#event:panel-close
Category: events
Properties
NameDescription
space : WeavySpace

The space that the app belongs to

app : WeavyApp

The app that fires the event


"message" ⇒ Object

Triggered when the app receives a postMessage sent from the panel frame.

Kind: event emitted by WeavyApp
Extends: message
Category: events
Properties
NameDescription
space : WeavySpace

The space that the app belongs to

app : WeavyApp

The app that fires the event


Methods

.configure(options, data)

Configure the app with options or data. If the app has data it will also be built. Currently existing options are extended with new options. Data will resolve whenLoaded promise.

Kind: instance method of WeavyApp
Category: methods
Resolves: whenLoaded
Param
options : options
data : data

.fetchOrCreate([options]) ⇒ whenLoaded

Sets options and fetches (or creates) the app on the server. Options will replace existing options. When data is fetched, the whenLoaded promise is resolved.

Kind: instance method of WeavyApp
Category: methods
Resolves: whenLoaded
ParamDescription
[options : options ]

Optional new app options


.build()

Builds the app. Creates a shadow root and a panel. Is executed on the build event.

Kind: instance method of WeavyApp
Category: methods
Resolves: whenBuilt

.remove() ⇒ Promise

Removes the app in the client and the DOM. The app will not be removed on the server and can be added and fetched at any point again.

Kind: instance method of WeavyApp
Category: methods

.match(options) ⇒ boolean

Check if another app or an object is matching this app. It checks for a match of the id property or the key property.

Kind: instance method of WeavyApp
Category: methods
ParamDescription
options : WeavyApp : Object
[options.id : int ]

Optional id to match.

[options.key : string ]

Optional key to match.


Options

.options : Object

Options for defining the app. Key and type is required.

Kind: instance property of WeavyApp
Category: options
Properties
NameDescription
id : int

The server id of the app. Usually only used to reference a specific app on the server.

key : string

The id representing the app in the context environment.

name : string

The display name of the app.

open : boolean

Should the app panel open automatically? Looks for the options if not defined. Defaults to true unless space.options.tabbed is true

container : Element : jQuery : string

The container where the app should be placed.

type : string

The kind of app.
• posts
• files
• messenger
• search
• tasks
• notifications
• posts
• comments

controls : boolean

Show or hide the panel controls. Defaults to false unless space.options.controls is true.

Example
space.app({
  key: "mykey",
  name: "Posts",
  type: "posts",
  container: "#myappcontainer",
  open: false,
  controls: true
});

Panel

.open([destination]) ⇒ Promise

Opens the app panel and optionally loads a destination url after waiting for whenBuilt. If the space is tabbed it also closes the other apps in the space.

Kind: instance method of WeavyApp
Category: panel
ParamDescription
[destination : string ]

Destination url to navigate to on open


.close() ⇒ Promise

Closes the app panel.

Kind: instance method of WeavyApp
Category: panel

.toggle([destination]) ⇒ Promise

Toggles the app panel open or closed. It optionally loads a destination url on toggle open. If the space is tabbed it also closes the other apps in the space.

Kind: instance method of WeavyApp
Category: panel
ParamDescription
[destination : string ]

Destination url to navigate to on open


.postMessage(message, [transfer]) ⇒ Promise

Sends postMessage to the app panel frame. Returns a promise that is resolved when the message has been delivered and rejected if the message fails or has timed out.

Kind: instance method of WeavyApp
Category: panel
See: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
ParamDescription
message : object

The Message to send

[transfer : Array.<Transferable> ]

A sequence of Transferable objects that are transferred with the message.


Promises

.whenLoaded : WeavyPromise

Promise that resolves when the app is loaded.

Kind: instance property of WeavyApp
Category: promises

.whenBuilt : WeavyPromise

Promise that resolves when the app is built.

Kind: instance property of WeavyApp
Category: promises

Properties

.container : Element \| jQuery \| string

The container passed in from options.

Kind: instance property of WeavyApp
Category: properties

.root : Object

The root object for the container of the app.

Kind: instance property of WeavyApp
Category: properties
Properties
NameDescription
container : Element

The inner container to put nodes in.

id : string

The id of the root

parent : Element

The element defined in options to contain the app.

root : ShadowRoot

The isolated ShadowRoot in the section.

section : Element

The <weavy>-section within the parent.

remove() : function

Method for removing the root from the DOM.


.panel : panel

The Panel displaying the app.

Kind: instance property of WeavyApp
Category: properties

.url : string

The url of the app, received from app data.

Kind: instance property of WeavyApp
Category: properties

.id : int

The server id of the app, received from app data.

Kind: instance property of WeavyApp
Category: properties

.name : string

The name of the app, defined in options or received from app data.

Kind: instance property of WeavyApp
Category: properties

.key : string

The key of the app, defined in options or recieved from app data.

Kind: instance property of WeavyApp
Category: properties

.guid : string

The guid of the app type. May also be used to define the app type in options.

Kind: instance property of WeavyApp
Category: properties

.type : string

The short readable type of the app, such as "files" .

Kind: instance property of WeavyApp
Category: properties

.typeName : string

The full type name of the app, such as "Weavy.Core.Models.Files".

Kind: instance property of WeavyApp
Category: properties

.autoOpen : boolean

Will the app open automatically when loaded? Defaults to true.

Kind: instance property of WeavyApp
Category: properties
See: WeavyApp#options

.weavy : Weavy

The Weavy instance the app belongs to.

Kind: instance property of WeavyApp
Category: properties

.space : WeavySpace

The WeavySpace the app belongs to.

Kind: instance property of WeavyApp
Category: properties

.data : Object

The server data for the app.

Kind: instance property of WeavyApp
Category: properties
Properties
NameDescription
id : int

The server id for the app.

key : string

The client key for the app.

guid : string

The GUID for the app type.

name : string

User readable title for the app.

url : string

The base url to the app.

typeName : string

The full app type, e.g. "Weavy.Core.Models.Posts"

[options : options ]

Any app definition passed to the server. Should match options.

Example
{
  id: 2136,
  guid: "523edd88-4bbf-4547-b60f-2859a6d2ddc1",
  key: "files",
  name: "Files",
  url: "/e/apps/2136",
  typeName: "Weavy.Core.Models.Files",
  options: {
    key: "files",
    type: "files"
  }
}

.isOpen : boolean

Is the app currently open? Returns the open status of the app panel.

Kind: instance property of WeavyApp
Category: properties

.isLoaded : boolean

Has the app loaded?

Kind: instance property of WeavyApp
Category: properties

.isBuilt : boolean

Is the app built?

Kind: instance property of WeavyApp
Category: properties