Wizcorp / cordova-plugin-wizviewmanager

PhoneGap plugin for creating/showing/hiding/messaging/animating additional views outside of the main window.
MIT License
57 stars 37 forks source link

cordova-plugin-wizviewmanager

Description

Cordova plugin for

Install (with Plugman - example iOS)

cordova plugin add https://github.com/Wizcorp/cordova-plugin-wizviewmanager
cordova build ios

< or >

phonegap local plugin add https://github.com/Wizcorp/cordova-plugin-wizviewmanager
phonegap build ios

APIs

Create

There is no limit to the amount of views you can create, but you cannot re-use the same name.

wizViewManager.create(String viewName, JSONObject options, Function success, Function fail);

Options list;

{
    src: "http://google.com", [local or remote http, for valid URI paths see Load API]
    height: 300, [accepts "300px", "30%" - default : fills height]
    width: 300, [accepts "300px", "30%" - default : fills width]
    x: 0,
    y: 0,
    top: 0, [string, pixels or percent - default : 0]
    bottom: 0, [string, pixels or percent - default : 0]
    left: 0, [pixels or percent - default : 0]
    right: 0, [string, pixels or percent - default : 0]
    scalesPageToFit: true [Boolean (iOS only) - default: false]
    bounces: true [Boolean (iOS only) - default: false]
};

NOTE:- Android only accepts ints

Load

wizViewManager.load(String viewName, String URI or URL, Function success, Function fail);

Valid URI and URLs : URIs are first resolved to cache, secondly bundle, then loaded exactly as passed.

URIs

URIs

Set Layout

wizViewManager.setLayout(String viewName, JSONObject options, Function success, Function fail);

See Create API for a list of options.

Show

wizViewManager.show(String viewName, JSONObject options, Function success, Function fail);

NOTE:- Animations not currently supported on Android, they are ignored

A list of animations;

Example options Object;

options : {
    animation: {
        type: "fadeIn",
        duration: "300"
    }
};

Hide

wizViewManager.hide(String viewName, JSONObject options, Function success, Function fail);

NOTE:- Animations not currently supported on Android, they are ignored

A list of animations;

Example options Object;

options : {
    animation : {
        type: "fadeOut",
        duration: "300"
    }
};

Messaging

To send a messsage to a view based on W3C post message API... for more information on the MessageEvent API, see: http://www.w3.org/TR/2008/WD-html5-20080610/comms.HTMLElement

wizViewMessenger.postMessage(Data message, String targetView);

Add an event listener in the html that wishes to receive the message...

window.addEventListener('message', wizMessageReceiver);

Example receiver;

function wizMessageReceiver (event) {
    // Event data object comes in here
}