Basic Widget usage
Paste the code anywhere on your website (preferably HEAD or before closing BODY tag).
For example if you have a heading with a logo on your page that looks like:
You can set the code to inject the badge into the h1
tag:
The end result will look like this:
Options
account
(required) - Your account IDselector
(required) - CSS selector where to inject the badgeenabled
- a boolean value if the widget should automatically initialize itself. If set tofalse
it's up the the developer to initialize the widget withHeadway.init()
orHeadway.init(config)
translations
- See Translations section below.position.x
(experimental) - force horizontal position of the widget ("left" or "right")position.y
(experimental) - force vertical position of the widget ("top" or "bottom")trigger
- Selector for externally triggering the widget popover. The popover will still be anchored to the badge, not the external trigger.callbacks.onWidgetReady
- callback fired when widget has loaded.callbacks.onShowWidget
- callback fired when widget is shown.callbacks.onShowDetails
- callback fired when an item in the widget is clicked.callbacks.onReadMore
- callback fired when user clicks on readMore link.callbacks.onHideWidget
- callback fired when user closes the widget.
Initializing widget programmatically (SPA)
Some apps reload content dynamically (through Angular, React or other means), this means that you'll probably want to initialize the widget inside of your JavaScript code. To do this you need to use Headway.init()
– this will create a new widget instance.
You can pass a single argument with Headway.init(config)
which is the config object, in this case it doesn't have to be named HW_config
but anything, for example:
Tip:
Running
Headway.init()
again will destroy the previous widget and replace it with a new instance.In Angular/React you should initialize the widget every time the badge element container is re-rendered.
Translating the text inside of the widget
title
changes the title of the widget from Latest awesome changes to anything you wishlabels
will replace current labels with provided onesreadMore
changes the read more link from Read the whole scoopfooter
link at the bottom of the widget
Styling the badge
Since the badge is injected into your HTML, you can simply style it with CSS.
For example if you need the badge to overlay an element on your page, you can either inject it into your own element container that is positioned over an element, or alter the badge styles:
Similarly you can change the color of the badge itself:
Last updated