3.0.0 • Published 3 years ago

ember-notifyme v3.0.0

Weekly downloads
161
License
MIT
Repository
github
Last release
3 years ago

Ember-notifyme

Simple addon that adds ability to show popup notifications.

DEMO: http://igorkvasn.github.io/ember-notifyme/

Features

  • countdown (notification message will disappear after certain timeout) + countdown progress bar
  • onClick and onClose callbacks
  • animations (VelocityJS)
  • full customization of icons (by default FontAwesome is supported, but any HTML element can be used instead - e.g. Glyphicons, IcoMoon,...)
  • supports HTML content

Installation

ember install ember-notifyme

  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

Usage

Add this component anywhere into your hbs file (eg. application.hbs)

{{notification-panel}}

To trigger a notification message you can either:

this.notifications.addMessage({
  message: "My message"
  //other options here
});

or use convenience methods success, info or error:

this.notifications.info("My info message", options);

To hide a notification:

this.notifications.removeMessage(message);

To hide all notifications:

 this.notifications.removeAll();

Note: by default, FontAwesome must be included in your project - to use different icon set, see Global Configuration section below for a configuration hints

Callbacks

You can also use callbacks onClick and onClose that take a function with one parameter (message that triggered this callback);

this.notifications.addMessage({
  message: "My message"
  onClick(message){
    alert('message clicked!');
  },
  onClose(message){
    alert('message closed!');
  }
});

Another callback available is onCloseTimeout that is called whenever notification's timeout expires and the notification message is auto-closing.

this.notifications.addMessage({
  message: "My message"
  onCloseTimeout(message){
    alert('message timeout expired');
  }
});

List of available options:

OptionDescriptionDefault value
typetype of message; possible values: 'info', 'error', 'success'; CSS class of the same name will be added to notification message to allow styling'info'
messagetext of a message
timeouttime before notification disappearsbased on notification type (errors have no timeout, otherwise 8000 milis)
stickyif true, notification will not disappearbased on notification type (errors are sticky=true)
htmlContentenabled/disables HTML content in message (Warning: be sure to properly escape message if this option is set to true)false
closeOnClickif set to true, message is closed when user clicks on itfalse
onClosecallback triggered when user clicks on X button to close the notification
onClickcallback triggered when user clicks on the notification
onCloseTimeoutcallback triggered when message timeout expires and message is automatically closed (see timeout option above)false
dataany arbitrary data

Global configuration

Some options can be globally configured so you do not have to set the same options over and over. Additionally icons can be configured as well. In config/environment.js you can configure globals such as (every entry is optional, eg. if you do not specify success timeout, default will be used):

ENV['ember-notifyme']={
  closeIconHTML: '<i class="fa fa-times"></i>',
  messages:{
    success: {
      timeout: 8000,
      icon: '<span class="fa-stack fa-sm"><i class="fa fa-circle-thin fa-stack-2x"></i>  <i class="fa fa-check fa-stack-1x"></i></span>'
    },
    error: {
      sticky: true,
      icon: '<span class="fa-stack fa-sm"><i class="fa fa-circle-thin fa-stack-2x"></i>  <i class="fa fa-exclamation fa-stack-1x"></i></span>'
    },
    info: {
      timeout: 8000,
      icon: '<span class="fa-stack fa-sm"><i class="fa fa-circle-thin fa-stack-2x"></i>  <i class="fa fa-info fa-stack-1x"></i></span>'
    },
  }
}

Addon Development

  • git clone this repository
  • npm install
  • bower install

Linting

Running tests

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Running the dummy application

For more information on using ember-cli, visit http://www.ember-cli.com/.

3.0.0

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

1.14.3

3 years ago

1.14.2

4 years ago

1.14.1

4 years ago

1.14.0

4 years ago

1.13.1

4 years ago

1.13.0

4 years ago

1.12.1

4 years ago

1.12.0

5 years ago

1.11.2

5 years ago

1.11.1

5 years ago

1.11.0

5 years ago

1.10.0

6 years ago

1.9.0

6 years ago

1.8.0

7 years ago

1.7.0

7 years ago

1.6.0

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.1

8 years ago