0.1.2 • Published 9 years ago

cordova-plugin-webapptoolkit v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

Web App Toolkit

The Web App Toolkit is a plugin for creating Windows, Android and iOS apps based on existing web content. It depends on the Hosted Web App Plugin. Used in the right way, it can facilitate the creation of compelling extensions to your web content for users across platforms.

Getting Started

The following tutorial requires you to install the Cordova Command-Line Inteface.

Hosting a Web Application

The plugin leverages the functionalimaty from the Hosted WebApp Plugin. The following steps describe how you can create and configure a sample application and use it with the Web App Toolkit.

  1. Create a new Cordova application.
    cordova create sampleapp yourdomain.sampleapp SampleHostedApp

  2. Go to the sampleapp directory created by the previous command.

  3. Download or create a W3C manifest describing the website to be hosted by the Cordova application and copy this file to its root folder, alongside config.xml. If necessary, rename the file as manifest.json.

    Note: You can find a sample manifest file at the start of this document.

  4. Add the Web App Toolkit plugin to the project.
    cordova plugin add cordova-plugin-webapptoolkit

  5. Add one or more platforms, for example, to support Android.
    cordova platform add android

  6. Build the application.
    cordova build

Known Issues Windows only

  1. The cordova build command will fail on a machine that does not have the SDK and tools for Windows 8.1 because WinJS 2 is not installed. For the plugin to work correctly, and if you are on Windows 10, before running the build command, open the Visual Studio solution and remove the references to WinJS 2 in the Windows 8.1 and Windows Phone 8.1 projects. The cordova build command should succeed after this.

  2. Uninstalling the plugin will not remove the WinJS files that were added during the installation process.

Manual steps required Windows only

In order to make the project work there are a few things that need to be taken care of:

  1. Changing the TargetDeviceFamily's MaxVersionTested and MinVersion values to 10.0.00000.0 in the appxmanifest.

Before you submit your app Windows only

Make sure you replace the reference to Windows.ApplicationModel.Store.CurrentAppSimulator with Windows.Applicationmodel.Store.CurrentApp, which is located in WATShare.js

Features

The following section shows examples of how you can enable the plugin's features in the manifest.json file.

The following table describes the supported features for each of the platforms.

WindowsiOSAndroid
wat_shareyes
wat_customScriptyesyesyes
wat_appBaryes
wat_navBaryes
wat_livetileyes
wat_redirectsyesyesyes
wat_settingsyes
wat_stylesyesyesyes
wat_headeryes
wat_secondaryPinyes
wat_navigationyesyes

wat_share

This controls the use of the share charm within the application.

OptionDescription
enabledToggles the share charm functionality on or off (true/false)
showButtonToggles visibility of a Share button on the app bar (true/false)
buttonTextText used for the Share app bar button if it is enabled
buttonSectionThis sets the sharebutton into a particular section of the app bar (if you have sections set up) the default is primary http://msdn.microsoft.com/en-us/library/windows/apps/Hh700497.aspx
titleDefines the title passed into the share charm
urlDefines a url that is shared via the share contract. You can use {currentURL} to share the current URL of the webview.
screenshotEnables the sharing of a screenshot (true/false)
messageDefines a message for the share contract contents. You can use {currentURL} to reference the current url or {url} to reference the base url.

Example

wat_customScript

An array of custom script files stored within the app package that are injected into the DOM. Paths are relative to the root of the app package.

Example

wat_appBar

This controls the application bar at the bottom of the screen.

OptionDescription
enabledToggles the app bar visibility (true/false)
buttonsAn array of objects, each of which represent a button within the application bar. Each object has three parameters:
     labelthe text for the button. Leave this blank to omit the text
     iconthe icon for the button. A list of available icons is at dev.windows.com. Leave this blank to omit the icon
     actionThe action for the button. This defines either the url location that the button links to or it can be set to a eval to executes the javascript defined in the 'data' field
     dataJavascript that gets executed if the action is set to 'eval'

Example

wat_navBar

This controls the navigation bar at the top of the screen.

OptionDescription
enabledToggles the navigation bar visibility (true/false)
maxRowsSets the maximum number of rows that are used to display buttons before the nav bar starts paging
buttonsAn array of objects, each of which represent a button within the navigation bar.Each object has the following parameters:
     labelThe text for the button. Leave this blank to omit the text
     iconThe icon for the button. A list of available icons is at dev.windows.com. Leave this blank to omit the icon
     actionThe action for the button. This defines either the url location that the button links to or a special keyword. back Takes the app back to the most recent page. home Takes the app to the base url. nested Allows the inclusion of children node. eval Executes the javascript defined in the 'data' field
     dataJavascript that gets executed if the action is set to 'eval'
     childrenAn array of nodes that are shown beneath the parent node. Children nodes take the same format as parent nodes. Only used if the parent node's action is set to 'nested'.

Example

wat_livetile

This controls the applications live tile notifications on the users start screen.

OptionDescription
enabledToggles the live tile functionality (true/false)
periodicUpdateNumber which defines how often the tile updates based on the PeriodicUpdateRecurrence enumeration. Valid values are 0, 1, 2, 3 or 4. 0 is most frequent (half an hour), 4 is the least frequent (daily)
enableQueueToggles multiple live tile updates on or off. When set to true the live tile on the start screen will cycle through muliple tile updates either via the RSS feed or multple push notification updates. (true/false)
tilePollFeedThe url for the RSS feed that will drive the live tile updates. This can be any RSS feed.

Example

wat_redirects

Enables you to specify which urls remain inside the app and which ones open in the browser. This feature is useful for those users who are already using the Web App Template and want to keep their configuration file unmodified.

OptionDescription
enabledToggles the redirect functionality (true/false)
enableCaptureWindowOpenThis captures popups (new windows) think about this as a way to catch facebook logins and things like that that need to happen in the app, once this value is enabled, you can control this on each of the redirects (true/false)
refreshOnModalCloseIf you need to have the app refresh when this model closes, (like in a login scenario) set this to true (true/false)
rulesAn array of objects, each of which represent a re-direction. Each object has three parameters:
     patternThe pattern that the rule should match to take effect
     actionThe action associated with this operation, this can be one of four options showMessage, popout, redirect or modal.
     urlThe url to redirect to if action is set to url
     messageThe message that is used if the action is set to showMessage
     hideCloseButtonHides close button on modal windows
     closeOnMatchA url that when it is loaded, it forces the modal to close (usefull for login scenario)

Example

wat_settings

This controls the use of the setting items within the application bar.

OptionDescription
enabledToggles the settings functionality (true/false)
privacyUrlDefines a url link to the application's privacy policy. A privacy policy is typically required for app to pass store certification.
itemsDefines an array of item that are used in the settings charm
titleDefines the text for the settings item
pageDefines the url for the settings item
loadInAppDefines whether the url is opened in the app or the browser (true/false)

Example

wat_styles

This allows the user to configure the application's view of their website.

OptionDescription
suppressTouchAction(Windows only) Toggles whether the top level touch events are surpressed or not. This is quite helpful with SPA where you don’t want to be able to see scrolling or ruberbanding of the page (true/false)
hiddenElementsAn array of strings that reference HTML elements. This enables you to hide any website HTML elements from your application. This is ideal for removing any unwanted top navigation, footers etc from the application view
backButton(Windows only) An array of style rules that are applied to the back button
wrapperCssFile(Windows only) A path to the /css/wrapper-styles.css file. This file applies styles to the native aspects of the app such as app bars, back button etc. Generally speaking you should not need to change this
customCssFileA path to the /css/injected-styles.css file. This file injects styles into the web view control and can overide CSS within the website itself. Generally speaking you should not need to change this
customCssStringThis enables you to embed CSS styles which get inserted over the existing styles on your website. This is great for adjusting the style of the site when it is presented as an application. This can be used as an alterntive to the injected-styles.css.

Example

wat_header

This enables use of a native page header within the application. This can make the app appear less like a website when use in conjunction with hiding the website's header elements.

OptionDescription
enabledToggles the header on or off (true/false)
backgroundColorA hex coe that defines tha background colour for the header
logoThe path to an image that is used as a logo in the header. This is only used if the title is disabled
titleSettings that control the title text that is used in the header. The text is taken from the Title metadata of the page that is being displayed
enabledToggles the title text functionality (true/false)
displayOnHomePageToggles whether to display the title text on the home page. If false, the title text will still be applied to all other pages (true/false)

Example

wat_secondaryPin

This option sets the secondary pin functionality in the app bar.

OptionDescription
enabledToggles the secondary pin functionality (true/false)
buttonTextText that is used on the pin button
tileTextThemeThe visual theme for the tile (light/dark)
buttonSectionThis sets the sharebutton into a particular section of the app bar (if you have sections set up) the default is primary http://msdn.microsoft.com/en-us/library/windows/apps/Hh700497.aspx
squareImageA path to a square image that is used for secondary tiles
wideImageA path to a wide image that is used for secondary tiles
customImageSelectorA CSS selector that specifies the img element corresponding to the image that will be used for the tile.

Example

wat_navigation

Controls options on how users navigate around the app.

OptionDescription
hideOnPageBackButtonThis toggles visibility of the back button on the main canvas across the entire application (true/false)
hideBackButtonOnMatchThis toggles visibility of the back button on specific pages. An array of objects, each of which is a url on which back button will be hidden. You can use {baseUrl} to signify the url defined in 'start_url'

Example