GithubHelp home page GithubHelp logo

isabella232 / childbrowser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from phonegap-build/childbrowser

0.0 0.0 0.0 1.47 MB

cross-platform ChildBrowser plugin for PhoneGap/Cordova

JavaScript 7.38% Objective-C 18.52% Java 64.83% C# 9.28%

childbrowser's Introduction

ChildBrowser plugin for PhoneGap

This is a prototype of a cross-platform ChildBrowser PhoneGap plugin. Android and iOS are currently supported. Support for BlackBerry and Windows Phone is also planned.

The goal is for a single JavaScript file to be usable on all supported platforms, and the native code to be installed in a project through a separate script.

The Structure

plugin.xml
-- src
  -- android
    -- ChildBrowser.java
  -- ios
    -- ChildBrowser.bundle
      -- arrow_left.png
      -- [email protected]
      -- ...
    -- ChildBrowserCommand.h
    -- ChildBrowserCommand.m
    -- etc
-- www
  -- childbrowser.js
  -- childbrowser
    -- icon_arrow_left.png
    -- icon_arrow_right.png
    -- ...

plugin.xml

The plugin.xml file is loosely based on the W3C's Widget Config spec.

It is in XML to facilitate transfer of nodes from this cross platform manifest to native XML manifests (AndroidManifest.xml, App-Info.plist, config.xml (BB)).

A specification for this file format will be forthcoming once more feedback has been received, and the tooling around plugin installation is more mature.

ChildBrowser JavaScript API

As with most Cordova/PhoneGap APIs, functionality is not available until the deviceready event has fired on the document. The childbrowser.js file should be included after the phonegap.js file.

All functions are called on the singleton ChildBrowser instance - accessible as window.plugins.childBrowser.

Methods

showWebPage

showWebPage(url, [options])

Displays a new ChildBrowser with the specified URL. Defaults to true.

Available options:

  • showLocationBar (Android and iOS): show/hide a location bar in the generated browser
  • showAddress (Android and iOS): show/hide the address bar in the generated browser
  • showNavigationBar (Android and IOS): show/hide the entire navigation bar. Important: since there is no "Done"-Button anymore, the ChildBrowser can only be closed with the api call close() (see below).

Example:

window.plugins.childBrowser.showWebPage('http://www.google.com',
                                        { showLocationBar: true });

close

close()

Closes the ChildBrowser.

Example:

window.plugins.childBrowser.close();

openExternal

openExternal(url, usePhoneGap)

(Android only) Opens the URL in a regular browser - if usePhoneGap, that browser will be a PhoneGap-enabled webview

Example:

window.plugins.childBrowser.openExternal('http://www.google.com');

Events

All events can be subscribed to by assigning a function to window.plugins.childBrowser['on' + eventName]; see examples below

close

Called when the ChildBrowser has been closed

Example:

window.plugins.childBrowser.onClose = function () {
    alert('childBrowser has closed');
};

locationChange

Called when the ChildBrowser loads a URL (including the initial location, when showWebPage is called). The callback function is passed the new URL being loaded.

Example:

window.plugins.childBrowser.onLocationChange = function (url) {
    alert('childBrowser has loaded ' + url);
};

openExternal

(iOS only) Called when the user opts to load an app in the device's browser (exiting the PhoneGap app in the process).

Example:

window.plugins.childBrowser.onOpenExternal = function () {
    alert('opening Mobile Safari');
};

Thank you GitHub People

  • @RandyMcMillan
  • @reinberger
  • @yimingkuan

License

MIT License (2008). See http://opensource.org/licenses/alphabetical for full text.

Copyright 2012, Andrew Lunny, Adobe Systems

Copyright (c) 2005-2010, Nitobi Software Inc.

Copyright (c) 2011, IBM Corporation

Copyright (c) 2010 Jesse MacFadyen, Nitobi

Copyright (c) 2012 Randy McMillan

childbrowser's People

Contributors

alunny avatar fattomhk avatar filmaj avatar goya avatar maartenr35 avatar randymcmillan avatar reinberger avatar yimingkuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.