API Docs for:
Show:

IOSBadge Class

Defined in: dist/iosbadge.js:27

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

()

Defined in dist/iosbadge.js:27

Example:

var badge = new IOSBadge();

Methods

_generate

() private

Defined in dist/iosbadge.js:67

Generate elements used by the plugin.

_setClasses

(
  • position
  • size
  • type
  • theme
)
private

Set the classnames used by the plugin.

Parameters:

  • position String

    Badge position.

  • size String

    Badge size.

  • type String

    Badge type (number or string).

  • theme String

    Badge theme.

_setContent

(
  • content
)
private

Set the content of badge element.

Parameters:

  • content Number | String

    content for the badge element.

_setOptions

(
  • options
)
private

Defined in dist/iosbadge.js:89

Set jQuery/Zepto options from the user.

Parameters:

  • options Object | String

    Plugin options given with jQuery or Zepto.

decreaseBy

(
  • amount
)
chainable

Decrease the current number in your badge.

Parameters:

  • amount Number

    The amount to decrease by.

Example:

badge.decreaseBy(2);

getContent

() Number | String

Returns the current content set for badge. Not chainable.

Returns:

Number | String:

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
)
chainable

Increase the current number in your badge.

Parameters:

  • amount Number

    The amount to increase by.

Example:

badge.increaseBy(2);

setContent

(
  • content
)
chainable

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 | String

    Badge content.

Example:

badge.setContent(6);

setPosition

(
  • position
)
chainable

Set the position of your badge. Positions are: 'top-left', 'top-right', 'bottom-left' or 'bottom-right'.

Parameters:

  • position String

    Badge position.

Example:

badge.setPosition('bottom-left');

setSize

(
  • size
)
chainable

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 | String

    Badge size.

Example:

badge.setSize(30);

setTheme

(
  • theme
)
chainable

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 String

    Badge theme.

Example:

badge.setTheme('ios');