Font Awesome Ti.Widget
- Version:
-
- 1.2.0
Examples
<Widget id = "fa" src = "com.mattmcfarland.fontawesome" />
var fa = Alloy.createWidget("com.mattmcfarland.fontawesome"); win.add(fa);
Members
-
debugMode :Boolean
Toggle debugMode.
-
If enabled, prints debug output to console if your log level is at debug.
Type:
- Boolean
- Since:
-
- v1.0.0
- Default Value:
-
- false
Example
$.fa.debugMode = true;
-
iconPrefex :String
Prefix for parser.
-
The iconPrefix property declares what the parser should look for when applying icons to View elements. Therefore, it only will parse view elements that have an icon property with the declared value.
IMPORTANT: This will override any settings in your custom icons.js
Type:
- String
- Since:
-
- v1.2.0
- Default Value:
-
- 'icons.iconPrefix-' ('fa-')
Examples
var glyph = Alloy.createWidget("com.mattmcfarland.fontawesome"); var glyph.iconPrefix = 'glyph-' win.add(glyph);
<Widget src = "com.mattmcfarland.fontawesome" iconPrefix = "glyph-" /> <Label icon = "gylph-star"/>
-
icons :Object
Set a custom charmap.js file.
-
Add your own icon character map if you want to use custom icons. It is recommended that you have a basic understanding of how to add custom fonts with Titanium Alloy. Because Android, IOS, and mobileweb interpret font files differently, you should read up on the custom font docs. Once you put your font files in the proper assets directory, you can must /require/ your character map in your lib folder.
IMPORTANT: Set parse to false for best results.
Type:
- Object
- Since:
-
- v1.2.0
- Default Value:
-
- require(WPATH('icons'));
Examples
var glyph = Alloy.createWidget("com.mattmcfarland.fontawesome"); var glyphicons = require('glyphicons'); glyph.icons = MyIconFile; win.add(glyph);
<Widget id = "fa" src = "com.mattmcfarland.fontawesome" icons = "require('glyphicons')" />
-
instaParse :Boolean
Configure if Parser starts immediately.
-
When enabled (and is by default), widget will parse viewport (excluding parent objects!) for icons immediately. If you wish to parse the document at a later time (after data is loaded), set it to false then call the
init()
method.Type:
- Boolean
- Since:
-
- v1.2.0
- Default Value:
-
- true
Examples
var fa = Alloy.createWidget("com.mattmcfarland.fontawesome"); fa.instaParse = false; win.add(fa);
<Alloy> <Window id = "index"> <Label id = "MyLabel" icon="fa-star"></Label> <Button id = "MyButton" icon="fa-file"></Button> <Widget id="fa" src = "com.mattmcfarland.fontawesome" instaParse = "false" /> <Window> </Alloy>
$.index.open() // Do Stuff // Do More Stuff // Ok, Now Parse! $.fa.refresh()
Methods
-
add(el, icon)
Add a new Icon
-
Adds an Icon to an existing view element and prepends it to the title or text.
Parameters:
Name Type Description el
Ti.UI.View Create and Prepend To Target Element (label, button, view, etc)
icon
String font-awesome icon (ie: "fa-flag")
- Since:
-
- v1.1.0
Example
$.fa.add(MyLabel,"fa-star")
-
change(el, icon)
Changes an Icon
-
Changes an already existing Icon to another Icon on an existing view element.
Parameters:
Name Type Description el
Ti.UI.View Element with existing icon property (label, button, view, etc)
icon
String Change existing icon property to (e.g. : "fa-flag")
- Since:
-
- v1.1.0
Example
$.fa.change(MyLabel, "fa-flag")
-
refresh()
Parse and apply icons in view.
-
Parse existing viewport along with siblings and descendants for icon properties that only have the proper prefix (default 'fa-'), then apply icons respectivly.
IMPORTANT: MUST be ran if instaParse is set to false!
Example
$.fa.refresh();
-
remove(el)
Remove an Icon
-
Removes an Icon from an existing view element.
Parameters:
Name Type Description el
Ti.UI.View Removes icon property from target element and from text/title.
- Since:
-
- v1.1.0
Example
$.fa.remove(MyButton)