Weavy

The core class for Weavy.

Kind: global class

new Weavy(...options)

Most options are optional except url. You may use multiple Weavy.presets together with options when constructing a weavy instance. Multiple option sets are merged together.

These option presets are available for easy configuration

  • Weavy.presets.core - All plugins disabled and minimal styles applied
  • Weavy.presets.panel - A minimal recommended configuration for making only a panel.
ParamTypeDescription
...optionsoptions

One or multiple option sets. Options will be merged together in order.

Example
var weavy = new Weavy({ url: "http://myweavysite.test" });
var coreWeavy = new Weavy(Weavy.presets.core, { url: "http://myweavysite.test" });

Instance members

weavy.nodes

Placeholder for all DOM node references. Put any created elements or DOM related objects here.

Kind: instance property of Weavy

weavy.nodes.root : Element

The root node where the Shadow root is attached. Uses Weavy#options.container if specified.

Kind: instance property of nodes

weavy.nodes.container : Element

The main container under the root. This is where all weavy Elements are placed.

Kind: instance property of nodes

weavy.nodes.overlay : Element

Container for displaying elements that needs to be full viewport and on top of other elements. Uses options.overlay if specified.

Kind: instance property of nodes

weavy.init()

Initializes weavy. This is done automatically unless you specify init: false in options.

Kind: instance method of Weavy
Emits: init

weavy.getId([id]) ⇒ string

Appends the weavy-id to an id. This makes the id unique per weavy instance. You may define a specific weavy-id for the instance in the options. If no id is provided it only returns the weavy id. The weavy id will not be appended more than once.

Kind: instance method of Weavy
Returns: string - Id completed with weavy-id. If no id was provided it returns the weavy-id only.
ParamTypeDescription
[id]string

Any id that should be completed with the weavy id.


weavy.removeId(id) ⇒ string

Removes the weavy id from an id created with getId

Kind: instance method of Weavy
Returns: string - Id without weavy id.
ParamTypeDescription
idstring

The id from which the weavy id will be removed.


weavy.destroy([keepConnection])

Destroys the inctance of Weavy. You should also remove any references to weavy after you have destroyed it. The destroy event will be triggered before anything else is removed so that plugins etc may unregister and clean up, before the instance is gone.

Kind: instance method of Weavy
Emits: destroy
ParamTypeDefaultDescription
[keepConnection]boolean false

Set to true if you want the realtime-connection to remain connected.


Authentication

weavy.isAuthenticated([optionalData]) ⇒ boolean

Checks if the user is signed in. May chack against any optional provided data.

Kind: instance method of Weavy
Returns: boolean - True if the user is signed in
Category: authentication
ParamTypeDescription
[optionalData]Object

Data that contains userId to verify against current user { userId: id }, such as options.


Eventhandling

weavy.eventNamespaces : Object.<string, string>

List of internal namespaces for events.

Kind: instance property of Weavy
Category: eventhandling
Properties
NameTypeDefaultDescription
globalstring "​"

Empty namespace for global events that should not use any specific namespace: "".

connectionstring ".connection.weavy"

Used by wvy.connection events: ".connection.weavy".

realtimestring ".rtmweavy"

Used by wvy.realtime events: ".rtmweavy".

weavystring ".event.weavy"

Default namespace used by all weavy events: ".event.weavy".


weavy.on([context], events, [selector], handler, [namespace])

Registers one or several event listneres. All event listners are managed and automatically unregistered on destroy.

When listening to weavy events, you may also listen to before: and after: events by simply adding the prefix to a weavy event. Eventhandlers listening to weavy events may return modified data that is returned to the trigger. The data is passed on to the next event in the trigger event chain. If an event handler calls event.stopPropagation() or returns false, the event chain will be stopped and the value is returned.

Kind: instance method of Weavy
Category: eventhandling
See: The underlying jQuery.on: http://api.jquery.com/on/
ParamTypeDescription
[context]Element

Context Element. If omitted it defaults to the Widget instance. wvy.connection and wvy.realtime may also be used as contexts.

eventsstring

One or several event names separated by spaces. You may provide any namespaces in the names or use the general namespace parameter instead.

[selector]string

Only applicable if the context is an Element. Uses the underlying jQuery.on syntax.

handlerfunction

The listener. The first argument is always the event, followed by any data arguments provided by the trigger.

[namespace]string

Optional namespace applied to all the event names. Namespaces are automatically selected for weavy-, realtime- and connection- events. Any eventNamespaces may be used as parameter.

Example (Widget event)
weavy.on("before:options", function(e, options) { ... })
weavy.on("options", function(e, options) { ... })
weavy.on("after:options", function(e, options) { ... })
 
Example (Realtime event)
weavy.on(wvy.realtime, "eventname", function(e, message) { ... })
  
Example (Connection event)
weavy.on(wvy.connection, "disconnect", function(e) { ... })
  
Example (Button event)
weavy.on(myButton, "click", function() { ... })
  
Example (Multiple document listeners with custom namespace)
weavy.on(document, ".modal", "show hide", function() { ... }, ".bs.modal")

weavy.one([context], events, [selector], handler, [namespace])

Registers one or several event listneres that are executed once. All event listners are managed and automatically unregistered on destroy.

Similar to on.

Kind: instance method of Weavy
Category: eventhandling
ParamTypeDescription
[context]Element

Context Element. If omitted it defaults to the Widget instance. wvy.connection and wvy.realtime may also be used as contexts.

eventsstring

One or several event names separated by spaces. You may provide any namespaces in the names or use the general namespace parameter instead.

[selector]string

Only applicable if the context is an Element. Uses the underlying jQuery.on syntax.

handlerfunction

The listener. The first argument is always the event, folowed by any data arguments provided by the trigger.

[namespace]string

Optional namespace applied to all the event names. Namespaces are automatically selected for weavy-, realtime- and connection- events. Any eventNamespaces may be used as parameter.


weavy.off([context], events, [selector], handler, [namespace])

Unregisters event listneres. The arguments must match the arguments provided on registration using .on() or .one().

Kind: instance method of Weavy
Category: eventhandling
ParamTypeDescription
[context]Element

Context Element. If omitted it defaults to the Widget instance. wvy.connection and wvy.realtime may also be used as contexts.

eventsstring

One or several event names separated by spaces. You may provide any namespaces in the names or use the general namespace parameter instead.

[selector]string

Only applicable if the context is an Element. Uses the underlying jQuery.on syntax.

handlerfunction

The listener. The first argument is always the event, folowed by any data arguments provided by the trigger.

[namespace]string

Optional namespace applied to all the event names. Namespaces are automatically selected for weavy-, realtime- and connection- events. Any eventNamespaces may be used as parameter.


weavy.triggerEvent(name, [data], [namespace], [context], [originalEvent]) ⇒ data

Trigger a custom event. Events are per default triggered on the weavy instance using the weavy.eventNamespaces.weavy namespace.

The trigger has an event chain that adds before: and after: events automatically for all events except when any custom prefix: is specified. This way you may customize the eventchain by specifying before:, on: and after: in your event name to fire them one at the time. The on: prefix will then be removed from the name when the event is fired.

Eventhandlers listening to the event may return modified data that is returned by the trigger event. The data is passed on to the next event in the trigger event chain. If an event handler calls event.stopPropagation() or return false, the event chain will be stopped and the value is returned.

Kind: instance method of Weavy
Returns: data - The data passed to the event trigger including any modifications by event handlers.
Category: eventhandling
ParamTypeDescription
nameany

The name of the event.

[data]Array/Object/JSON

Data may be an array or plain object with data or a JSON encoded string. Unlike jQuery, an array of data will be passed as an array and not as multiple arguments.

[namespace]string

The namespace is applied to the name. It defaults to the weavy namespace. Any weavy.eventNamespaces may also be used as parameter.

[context]Element

Context Element to trigger the event on. If omitted it defaults to the Widget instance.

[originalEvent]Event

When relaying another event, you may pass the original Event to access it in handlers.

Example
// Normal triggering
weavy.triggerEvent("myevent");

// Will trigger the following events on the weavy instance
// 1. `before:myevent.event.weavy`
// 2. `myevent.event.weavy`
// 3. `after:myevent.event.weavy`

// Custom triggering, one at the time
weavy.triggerEvent("before:myevent");
weavy.triggerEvent("on:myevent");
weavy.triggerEvent("after:myevent");

Events

"init" ⇒ Promise

Event that is triggered when the weavy instance is initiated. This is done automatically unless you specify init: false in options. You may use the before:init event together with event.stopPropagation() if you want to intercept the initialization.

Kind: event emitted by Weavy
Category: events

"frame-check" ⇒ object

Event triggered when frame blocking check has finished. You may also use the whenBlockChecked promise to make sure the blocked check has finished.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
blockedboolean

Indicates if frames are blocked.


"build"

Event triggered when weavy is building up the DOM elements.

Use this event to build all your elements and attach them to weavy. At this point you may safely assume that weavy.nodes.container is built.

Good practice is to build all elements in the build event and store them as properties on weavy. Then you can attach them to other Elements in the after:build event. This ensures that all Elements are built before they are attached to each other.

If you have dependencies to Elements built by plugins you should also check that they actually exist before attaching to them.

Often it's a good idea to check if the user is signed-in using isAuthenticated unless you're building something that doesn't require a signed in user.

Kind: event emitted by Weavy
Category: events
Example
weavy.on("build", function() {
    if (weavy.isAuthenticated()) {
        weavy.nodes.myElement = document.createElement("DIV");
    }
});

weavy.on("after:build", function() {
    if (weavy.isAuthenticated()) {
        if (weavy.nodes.dock) {
            weavy.nodes.dock.appendChild(weavy.nodes.myElement);
        }
    }
})

"resize"

Triggered when the panel is resized due to a state change.

Kind: event emitted by Weavy
Category: events

"maximize"

Triggered when the panel is maximized to full broser window size

Kind: event emitted by Weavy
Category: events

"reload" ⇒ options

Triggered when weavy is reloaded with any new data. Current options are provided as event data.

Kind: event emitted by Weavy
Category: events

"refresh" ⇒ Object

Event triggered when a panel is resfreshed and needs to reload it's content.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
panelIdstring

The id of the panel being refreshed.


"open" ⇒ Object

Event triggered when a panel is opened.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
panelIdstring

The id of the panel being openened.

[destination]string

Any url being requested to open in the panel.


"close"

Event triggered when weavy closes all panels. Wait for the whenClosed Promise to do additional things when weavy has finished closing.

Kind: event emitted by Weavy
Category: events

"toggle" ⇒ Object

Event triggered when a panel is toggled open or closed.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
panelIdstring

The id of the panel toggled.

closedboolean

True if the panel is closed.


"panel-loading" ⇒ Object

Event triggered when panel is starting to load or stops loading.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
panelIdstring

The id of the panel loading.

isLoadingboolean

Indicating wheter the panel is loading or not.

fillBackgroundboolean

True if the panel has an opaque background during loading.


"destroy"

Event triggered when the Weavy instance is about to be destroyed. Use this event for clean up.

  • Any events registered using on and one will be unregistered automatically.
  • Timers using timeout will be cleared automatically.
  • All elements under the root will be removed.
Kind: event emitted by Weavy
Category: events

"signing-in" ⇒ Object

Event triggered when signing in process has begun. The user is still not authenticated. The authentication may result in signed-in or authentication-error. This event may be triggered from anywhere, not only the Weavy instance.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
isLocalboolean

Is the origin of the event from this weavy instance


"signing-out" ⇒ Object

Event triggered when signing out process has begun. Use this event to do signing out animations and eventually clean up your elements. It will be followed by signed-out This event may be triggered from anywhere, not only the Weavy instance.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
isLocalboolean

Is the origin of the event from this weavy instance


"authentication-error"

Event triggered when a sign-in attempt was unsuccessful. This event may be triggered from anywhere, not only the Weavy instance.

Kind: event emitted by Weavy
Category: events

"message" ⇒ Object.<string, data>

Event for window messages directed to the current weavy instance, such as messages sent from panels belonging to the weavy instance. The original message event is attached as event.originalEvent.

Use data.name to determine which type of message theat was receivied.

Kind: event emitted by Weavy
Category: events
See: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
Properties
NameTypeDescription
namestring

The name of the message


"ready" ⇒ Object

Event triggered when a panel sends a ready message. Check the sourcePanelId or sourceWindowName to see which panel that sent the ready message.

Kind: event emitted by Weavy
Category: events
Properties
NameTypeDescription
sourceWindowNamestring

The name of the frame (or window) for the panel.

sourcePanelIdstring

The panelId of the panel


"signed-in"

Event triggered when the user is successfully signed in using any authentication method. The realtime connection gets automatically reconnected before this event occurs. This event is triggered when the server has recieved a sucessful sign-in using any method.

Kind: event emitted by Weavy
Category: events

"signed-out"

Event triggered when the user has been signed out. The realtime connection gets automatically reset when this event occurs. This event is triggered when the user is signed out from the server for any reason.

Kind: event emitted by Weavy
Category: events

"options" ⇒ options

Event triggered when options are processed and recieved from the server. Use this event to react to option changes from the server. You may modify the data using the before:options event. This event is mostly followed by build. If you want to prevent the build event from triggering, you may set weavy.isLoaded = true.

Kind: event emitted by Weavy
Category: events

"load"

Event triggered when weavy has initialized, connected to the server and recieved and processed options, and built all components. Use this event to do stuff when everything is loaded.

Often it's a good idea to check if the user is signed-in using isAuthenticated unless you're building something that doesn't require a signed in user.

Kind: event emitted by Weavy
Category: events
Example
weavy.on("load", function() {
    if (weavy.isAuthenticated()) {
        weavy.alert("Widget successfully loaded");
    }
});

Logging

weavy.debug() : console.debug

Wrapper for console.debug() that adds the instance id of weavy as prefix using the logColor.

Kind: instance method of Weavy
Category: logging
See: https://developer.mozilla.org/en-US/docs/Web/API/Console/debug

weavy.error() : console.error

Wrapper for console.error() that adds the instance id of weavy as prefix using the logColor.

Kind: instance method of Weavy
Category: logging
See: https://developer.mozilla.org/en-US/docs/Web/API/Console/error

weavy.info() : console.info

Wrapper for console.info() that adds the instance id of weavy as prefix using the logColor.

Kind: instance method of Weavy
Category: logging
See: https://developer.mozilla.org/en-US/docs/Web/API/Console/info

weavy.log() : console.log

Wrapper for console.log() that adds the instance id of weavy as prefix using the logColor.

Kind: instance method of Weavy
Category: logging
See: https://developer.mozilla.org/en-US/docs/Web/API/Console/log

weavy.warn() : console.warn

Wrapper for console.warn() that adds the instance id of weavy as prefix using the logColor.

Kind: instance method of Weavy
Category: logging
See: https://developer.mozilla.org/en-US/docs/Web/API/Console/warn

Options

weavy.options : Object

Main options for Weavy. When weavy initializes, it connects to the server and processes the options and sends them back to weavy again. The options may then contain additional data. Weavy triggers a options event when options are recieved from the server.

Kind: instance property of Weavy
Category: options
Properties
NameTypeDefaultDescription
[container]Element

Container where weavy should be placed. If no Element is provided, a <section> is created next to the <body>-element.

[className]string

Additional classNames added to weavy.

[https]string "adaptive"

How to enforce https-links.
force - makes all urls https.
adaptive - enforces https if the calling site uses https.
default - makes no change.

[id]string

An id for the instance. A unique id is always generated.

[init]boolean true

Should weavy initialize automatically.

[isMobile]boolean

Indicates if the browser is mobile. Defaults to the RegExp expression /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)

[includePlugins]boolean true

Whether all registered plugins should be enabled by default. If false, then each plugin needs to be enabled in plugin-options.

[logColor]string

Hex color (#bada55) used for logging. A random color is generated as default.

[overlay]Element

Element to use for overlay purposes. May for instance use the overlay of another Weavy instance.

[plugins]Object.<string, Object>

Properties with the name of the plugins to configure. Each plugin may be enabled or disabled by setting the options to true or false. Providing an Object instead of true will enable the plugin and pass options to the plugin. See the reference for each plugin for available options.

urlstring

The URL to the Weavy-installation to connect to.


weavy.reload([options]) ⇒ Promise

Reload weavy data.

Kind: instance method of Weavy
Returns: Promise - whenLoaded
Category: options
Emits: reload
ParamTypeDescription
[options]options

Any new or additional options.


weavy.storeItem(key, value, [asJson])

Stores data for the current domain in the weavy namespace.

Kind: instance method of Weavy
Category: options
ParamTypeDefaultDescription
keystring

The name of the data

valuedata

Data to store

[asJson]boolean false

True if the data in value should be stored as JSON


weavy.retrieveItem(key, [isJson])

Retrieves data for the current domain from the weavy namespace.

Kind: instance method of Weavy
Category: options
ParamTypeDefaultDescription
keystring

The name of the data to retrevie

[isJson]boolean false

True if the data shoul be decoded from JSON


weavy.extendDefaults(source, properties, [recursive]) ⇒ Object

Method for extending options. It merges together options. If the recursive setting is applied it will merge any plain object children. Note that Arrays are treated as data and not as tree structure when merging.

The original options passed are left untouched. Weavy.httpsUrl settings is applied to all url options.

Kind: instance method of Weavy
Returns: Object - A new object containing the merged options.
Category: options
ParamTypeDefaultDescription
sourceObject

Original options.

propertiesObject

Merged options that will replace options from the source.

[recursive]boolean false

True will merge any sub-objects of the options recursively. Otherwise sub-objects are treated as data.


weavy.httpsUrl(url, [baseUrl], [https]) ⇒ string

Applies https enforcement to an url. Optionally adds a baseUrl to relative urls.

Kind: instance method of Weavy
Returns: string - url
Category: options
ParamTypeDescription
urlstring

The url to process

[baseUrl]string

Url to preprend to relative urls. Ie. weavy.options.url

[https]string

How to treat http enforcement for the url. Default to settings from options.
enforce - makes all urls https.
adaptive - enforces https if the calling site uses https.
nochange - makes no change.


Panels

weavy.panelPrefix : string

Common prefix for panel naming

Kind: instance property of Weavy
Category: panels

weavy.openPanelId : string

Id of any currently open panel, otherwise null.

Kind: instance property of Weavy
Category: panels

weavy.sendWindowId(contentWindow, windowName, [panelId])

Sends the id of a frame to the frame content scripts, so that the frame gets aware of which id it has. The frame needs to have a unique name attribute.

Kind: instance method of Weavy
Category: panels
ParamTypeDescription
contentWindowWindow

The frame window to send the data to.

windowNamestring

The frame name attribute.

[panelId]string

If the frame is a panel, the panelId may also be provided.


weavy.postMessage(panelId, message, [transfer])

Sends a postMessage to a panel iframe

Kind: instance method of Weavy
Category: panels
See: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage
ParamTypeDescription
panelIdstring

If the frame is a panel, the panelId may also be provided.

messageobject

The Message to send

[transfer]Array.<Transferable>

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


weavy.resize()

Maximizes or restores the size of current panel.

Kind: instance method of Weavy
Category: panels
Emits: resize

weavy.maximize()

Maximize the size of current panel.

Kind: instance method of Weavy
Category: panels
Emits: maximize

weavy.panelIsLoading(panelId) ⇒ boolean

Check if a panel is currently loading.

Kind: instance method of Weavy
Returns: boolean - True if the panel curerently is loading
Category: panels
ParamTypeDescription
panelIdstring

The id of the panel to check.


weavy.panelIsLoaded(panelId) ⇒ boolean

Check if a panel has finished loading.

Kind: instance method of Weavy
Returns: boolean - True if the panel has finished loading.
Category: panels
ParamTypeDescription
panelIdstring

The id of the panel to check.


weavy.refresh(panelId)

Tells a panel that it need to reload it's content.

Kind: instance method of Weavy
Category: panels
Emits: refresh
ParamTypeDescription
panelIdstring

The id of the panel to refresh.


weavy.reset(panelId)

Resets a panel to its original url. This can be used if the panel has ended up in an incorrect state.

Kind: instance method of Weavy
Category: panels
ParamTypeDescription
panelIdstring

The id of the panel to reset.


weavy.open(panelId, [destination]) ⇒ Promise

Open a specific panel. The open waits for the block check to complete, then opens the panel. Adds the weavy-open class to the container.

Kind: instance method of Weavy
Category: panels
Emits: open
ParamTypeDescription
panelIdstring

The id of the panel to open.

[destination]string

Tells the panel to navigate to a specified url.


weavy.close([panelId]) ⇒ Promise

Closes all panels and removes the weavy-open class from the container. Sets the whenClosed Promise if not already closing.

Kind: instance method of Weavy
Returns: Promise - whenClosed
Category: panels
Emits: close
ParamTypeDescription
[panelId]string

The id of any specific panel to close. If that panel is open, the panel will be closed, otherwise no panel will be closed.


weavy.toggle(panelId, [destination])

Open or close a specific panel.

Kind: instance method of Weavy
Category: panels
Emits: toggle
ParamTypeDescription
panelIdstring

The id of the panel toggled.

[destination]string

Tells the panel to navigate to a specified url when opened.


weavy.setPanelLoading(panelId, isLoading, [fillBackground])

Set the loading indicator on the specified panel. The loading indicatior is automatically removed on loading. It also makes sure the panel is registered and sends frame id when loaded.

Kind: instance method of Weavy
Category: panels
Emits: panel-loading
ParamTypeDescription
panelIdstring

The id of the panel that is loading.

isLoadingboolean

Sets whether the panel is loading or not.

[fillBackground]boolean

Sets an opaque background that hides any panel content during loading.


weavy.load(panelId, url, [data], [method], [replace]) ⇒ Promise

Load an url with data directly in a specific panel. Uses turbolinks forms if the panel is loaded and a form post to the frame if the panel isn't loaded.

Kind: instance method of Weavy
Category: panels
ParamTypeDefaultDescription
panelIdstring

The id of the panel to load in.

urlstring

The url to load in the panel.

[data]any

URL/form-encoded data to send

[method]any GET

HTTP Request Method https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

[replace]bool

Replace the content in the panel and load it fresh.


Plugins

weavy.plugins : Object.<string, WeavyPlugin>

All enabled plugins are available in the plugin list. Anything exposed by the plugin is accessible here. You may use this to check if a plugin is enabled and active.

Set plugin options and enable/disable plugins using options.

Kind: instance property of Weavy
Category: plugins
Example
if (weavy.plugins.alert) {
  weavy.plugins.alert.alert("Alert plugin is enabled");
}

Promises

weavy.whenClosed : Promise

Promise that weavy has finished transitions for closing. If weavy already is closed, the promise is resolved instantly.

Kind: instance property of Weavy
Category: promises
Resolved: when weavy is closed
Example
weavy.whenClosed.then(function() { ... })

weavy.whenBlockChecked : Promise

Promise that the blocking check has finished. Resolves when frame-check is triggered.

Kind: instance property of Weavy
Category: promises
Resolved: when frames are not blocked.
Rejected: when frames are blocked
Example
weavy.whenBlockChecked.then(function() { ... })

weavy.whenLoaded : Promise

Promise that weavy has recieved the after:load event

Kind: instance property of Weavy
Category: promises
Resolves: when init is called, the websocket has connected, data is received from the server and weavy is built and the load event has finished.
Example
weavy.whenLoaded.then(function() { ... })

weavy.timeout(time) ⇒ Promise

Creates a managed timeout promise. Use this instead of window.setTimeout to get a timeout that is automatically managed and unregistered on destroy.

Kind: instance method of Weavy
Category: promises
ParamTypeDefaultDescription
timeint 0

Timeout in milliseconds

Example
var mytimeout = weavy.timeout(200).then(function() { ... });
mytimeout.reject(); // Cancel the timeout

timeout.resolve()

Additional Promise method for resolving the timeout before it has finished.

Kind: static method of timeout

timeout.reject()

Additional Promise method for cancelling the timout and reject the promise before it has finished.

Kind: static method of timeout

Properties

weavy.logColor : string

The unique instance color used by console logging.

Kind: instance property of Weavy
Category: properties

weavy.supportsShadowDOM : boolean

Indicating if the browser supports using ShadowDOM

Kind: instance property of Weavy
Category: properties

weavy.isBlocked : boolean

True when frames are blocked by Content Policy or the browser

Kind: instance property of Weavy
Category: properties

weavy.isLoaded : boolean

True when weavy has loaded options from the server.

Kind: instance property of Weavy
Category: properties

Static members

Weavy.version : string

The hardcoded semver version of the weavy-script.

Kind: static property of Weavy

Weavy.plugins : Object.<string, WeavyPlugin>

Placeholder for registering plugins. Plugins must be registered and available here to be accessible and initialized in the Widget. Register any plugins after you have loaded weavy.js and before you create a new Weavy instance.

Kind: static property of Weavy

Weavy.instances : Object.<string, Weavy>

Placeholder for all created instances.

Kind: static property of Weavy

Options

Weavy.presets : Object

Option preset configurations. Use these for simple configurations of common options. You may add your own presets also. The presets may be merged with custom options when you create a new Weavy, since the contructor accepts multiple option sets.

Kind: static property of Weavy
Category: options
Properties
NameTypeDescription
Weavy.presets.coreoptions

Disable all plugins.

Weavy.presets.paneloptions

Minimal plugin set to only have one or more panels.

Weavy.presets.fulloptions

Enable all plugins.

Example
// Load the minimal weavy core without any panels.
var weavy = new Weavy(Weavy.presets.core, { url: "https://myweavysite.com" });

Weavy.defaults : Object

Default options. These options are general for all Weavy instances and may be overridden in options. You may add any general options you like here.

Kind: static property of Weavy
Category: options
Properties
NameTypeDefaultDescription
[container]Element

Container where weavy should be placed. If no Element is provided, a <section> is created next to the <body>-element.

[className]string

Additional classNames added to weavy.

[https]string "adaptive"

How to enforce https-links.
force - makes all urls https.
adaptive - enforces https if the calling site uses https.
default - makes no change.

[init]boolean true

Should weavy initialize automatically.

[isMobile]boolean

Indicates if the browser is mobile. Defaults to the RegExp expression /iPhone|iPad|iPod|Android/i.test(navigator.userAgent)

[includePlugins]boolean true

Whether all registered plugins should be enabled by default. If false, then each plugin needs to be enabled in plugin-options.

[overlay]Element

Element to use for overlay purposes. May for instance use the overlay of another Weavy instance.

urlstring

The URL to the Weavy-installation to connect to.

Example
// Defaults
Weavy.defaults = {
    container: null,
    className: "",
    https: "adaptive",
    init: true,
    isMobile: /iPhone|iPad|iPod|Android/i.test(navigator.userAgent),
    includePlugins: true,
    overlay: null,
    url: "/"
};

// Set a general url to connect all weavy instances to
Weavy.defaults.url = "https://myweavysite.com";
var weavy = new Weavy();