IOSBadge Class
Constructor and plugin settings
Make sure that the plugin works even without the new
keyword.
Check for any user defined settings and initialize the plugin.
Constructor
IOSBadge
()
Example:
var badge = new IOSBadge();
Item Index
Methods
_generate
()
private
Generate elements used by the plugin.
_setClasses
-
position
-
size
-
type
-
theme
Set the classnames used by the plugin.
Parameters:
-
position
StringBadge position.
-
size
StringBadge size.
-
type
StringBadge type (number or string).
-
theme
StringBadge theme.
_setContent
-
content
Set the content of badge element.
Parameters:
-
content
Number | Stringcontent for the badge element.
_setOptions
-
options
Set jQuery/Zepto options from the user.
Parameters:
-
options
Object | StringPlugin options given with jQuery or Zepto.
decreaseBy
-
amount
Decrease the current number in your badge.
Parameters:
-
amount
NumberThe amount to decrease by.
Example:
badge.decreaseBy(2);
getContent
()
Number | String
Returns the current content set for badge. Not chainable.
Returns:
Badge content.
Example:
badge.getContent();
hide
()
chainable
Show your badge element.
Example:
badge.show();
hide
()
chainable
Hide your badge element.
Example:
badge.hide();
increaseBy
-
amount
Increase the current number in your badge.
Parameters:
-
amount
NumberThe amount to increase by.
Example:
badge.increaseBy(2);
setContent
-
content
Set the content of your badge. Content can be a number or a string.
Increase or decrease your current badge number by passing a '+'
or '-'
prefixed
number in a string e.g. .setContent('+7')
Parameters:
-
content
Number | StringBadge content.
Example:
badge.setContent(6);
setPosition
-
position
Set the position of your badge.
Positions are: 'top-left'
, 'top-right'
, 'bottom-left'
or 'bottom-right'
.
Parameters:
-
position
StringBadge position.
Example:
badge.setPosition('bottom-left');
setSize
-
size
Set the size of your badge.
Available default sizes are: 20
, 22
, 24
, 26
, 28
, 30
, 32
, 34
and 36
.
Sizes can be configured in the iosbadge.scss
file.
Parameters:
-
size
Number | StringBadge size.
Example:
badge.setSize(30);
setTheme
-
theme
Set the theme of your badge.
Available default themes are: 'red'
, 'blue'
, 'green'
, 'grey'
and 'ios'
.
Themes can be configured in the iosbadge.scss
file.
Parameters:
-
theme
StringBadge theme.
Example:
badge.setTheme('ios');