WeavyApp
Base class for representation of apps in Weavy.
Kind: global classEventhandling
.on()
Event listener registration for the specific app. Only recieves events that belong to the app.
Kind: instance method ofWeavyApp
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 ofWeavyApp
Category: eventhandling
Example
weavy.space("myspace").app("myapp").one("open", function(e) { ... })
.off()
Event listener unregistration for the specific app.
Kind: instance method ofWeavyApp
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 ofWeavyApp
Category: eventhandling
Example
weavy.space("myspace").app("myapp").triggerEvent("myevent", [eventData])
Events
"open" ⇒ Object
Triggered when the app panel is opened.
Kind: event emitted byWeavyApp
Extends:
WeavyPanel#event:panel-open
Category: events
Properties
Name | Description |
---|---|
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 byWeavyApp
Extends:
WeavyPanel#event:panel-toggle
Category: events
Properties
Name | Description |
---|---|
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 byWeavyApp
Extends:
WeavyPanel#event:panel-close
Category: events
Properties
Name | Description |
---|---|
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 byWeavyApp
Extends:
message
Category: events
Properties
Name | Description |
---|---|
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 ofWeavyApp
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 ofWeavyApp
Category: methods
Resolves:
whenLoaded
Param | Description |
---|---|
[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 ofWeavyApp
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 ofWeavyApp
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 ofWeavyApp
Category: methods
Param | Description |
---|---|
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 ofWeavyApp
Category: options
Properties
Name | Description |
---|---|
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. |
controls : boolean
| Show or hide the panel controls. Defaults to false unless space.options.controls is true. |
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 ofWeavyApp
Category: panel
Param | Description |
---|---|
[destination : string
] | Destination url to navigate to on open |
.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 ofWeavyApp
Category: panel
Param | Description |
---|---|
[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 ofWeavyApp
Category: panel
See: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
Param | Description |
---|---|
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 ofWeavyApp
Category: promises
.whenBuilt : WeavyPromise
Properties
.container : Element
\| jQuery
\| string
.root : Object
The root object for the container of the app.
Kind: instance property ofWeavyApp
Category: properties
Properties
Name | Description |
---|---|
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
.url : string
The url of the app, received from app data.
Kind: instance property ofWeavyApp
Category: properties
.id : int
The server id of the app, received from app data.
Kind: instance property ofWeavyApp
Category: properties
.name : string
The name of the app, defined in options or received from app data.
Kind: instance property ofWeavyApp
Category: properties
.key : string
The key of the app, defined in options or recieved from app data.
Kind: instance property ofWeavyApp
Category: properties
.guid : string
The guid of the app type. May also be used to define the app type in options.
Kind: instance property ofWeavyApp
Category: properties
.type : string
The short readable type of the app, such as "files" .
Kind: instance property ofWeavyApp
Category: properties
.typeName : string
The full type name of the app, such as "Weavy.Core.Models.Files".
Kind: instance property ofWeavyApp
Category: properties
.autoOpen : boolean
Will the app open automatically when loaded? Defaults to true.
Kind: instance property ofWeavyApp
Category: properties
See: WeavyApp#options
.weavy : Weavy
.space : WeavySpace
.data : Object
The server data for the app.
Kind: instance property ofWeavyApp
Category: properties
Properties
Name | Description |
---|---|
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. |
{
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 ofWeavyApp
Category: properties