widget Singleton
The widget instance has several things that usefull for the application scope.
widget()
Example
//metadata.json example file
{
"identifier": "com.metrological.app.EmptyTemplate",
"name": "Empty App Template",
"version": "0.0.1",
"author": "Metrological Widgets",
"company": "Metrological Widgets",
"copyright": "Metrological Widgets 2014",
"description": "A clean App structure",
"categories": [
"video"
],
"scripts": "Javascript/init.js",
"images": {
"about": "Images/Icon.png",
"icon": {
"192x192": "Images/Icon.png"
}
}
}
Members
active :Boolean static
Defines if the application is running or not.
author :String staticconstant
Author of the app as defined in the metadata.json
company :String staticconstant
Company that made the app as defined in the metadata.json
copyright :String staticconstant
Copyright text as defined in the metadata.json
description :String staticconstant
Description of the app as defined in the metadata.json
identifier :String staticconstant
App identifier as defined in the metadata.json
isDialogActive :Boolean static
Defines if the application has a dialog active on the screen or not.
locale :String staticconstant
The locale the app is currently running in.
name :String staticconstant
Name of the app as defined in the metadata.json
version :String staticconstant
Version of the app as defined in the metadata.json
Methods
close()
Close down the app.
getImage(key, type) → {Element}
Get a image (as element) with the source as defined in metadata.json Get the image source string defined in the metadata of the app.
Parameters:
Name Type Argument Description key String Key of the image source string to retrieve.
type String optional Type of the image source string to retrieve.
Returns:
The image as a HTML Dom element.
getImageSource(key, type) → {String}
Get the image source string defined in the metadata of the app.
Parameters:
Name Type Argument Description key String Key of the image source string to retrieve.
type String optional Type of the image source string to retrieve.
Returns:
Image location string.
Example
widget.getImageSource('about'); //Returns: 'Images/about.png' widget.getImageSource('icon', '192x192'); //Returns: 'Images/Icon.png'
getLocalizedString(key, args) → {String}
Translate the language key in the active language.
Parameters:
Name Type Description key String Translation key.
args Array Array with the values to fill in the string. These can be parsed to certain types specified in the translation string.
The type specifier says what type the argument data should be treated as. Possible types:- % - a literal percent character. No argument is required.
- b - the argument is treated as an integer, and presented as a binary number.
- c - the argument is treated as an integer, and presented as the character with that ASCII value.
- d - the argument is treated as an integer, and presented as a (signed) decimal number.
- e - the argument is treated as scientific notation (e.g. 1.2e+2). The precision specifier stands for the number of digits after the decimal point.
- E - like %e but uses uppercase letter (e.g. 1.2E+2).
- f - the argument is treated as a float, and presented as a floating-point number.
- F - the argument is treated as a float, and presented as a floating-point number.
- g - shorter of %e and %f.
- G - shorter of %E and %f.
- o - the argument is treated as an integer, and presented as an octal number.
- s - the argument is treated as and presented as a string.
- u - the argument is treated as an integer, and presented as an unsigned decimal number.
- x - the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
- X - the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).
Returns:
The translated string or the key.
Example
widget.getLocalizedString('close_button'); $_('close_button'); //Translation string: //"nrMonkeys" = "There are %d monkeys in the %s."; widget.getLocalizedString('nrMonkeys', [2, 'tree']); // Returns -> There are 2 monkeys in the tree.
getPath(file) → {String}
Parameters:
Name Type Description file String File to get the path for.
Returns:
Path to the file, or path of your application when file is not given.
Example
styles: { transformOrigin: '50% 50%', backgroundRepeat: 'no-repeat', backgroundImage: widget.getPath( 'Images/background.jpg' ) }