Giter VIP home page Giter VIP logo

ember-notify's Introduction

Build Status

ember-notify

ember-notify displays wee little notification messages down the bottom of your Ember.js app.

The CSS classes are compatible with Zurb Foundation 5, Thoughtbot's Refills, and Bootstrap. For Bootstrap use {{ember-notify messageStyle='bootstrap'}} and for Refills use {{ember-notify messageStyle='refills'}}.

The CSS animations are inspired by CSS from alertify.js.

Usage

  1. Add {{ember-notify}} to one of your templates, usually in application.hbs
  2. Inject the notify service
  3. Display messages using the info, success, warning, alert and error methods

Examples

import {
  Component,
  inject
} from 'ember';
export default Component.extend({
  notify: inject.service('notify'),
  actions: {
    sayHello() {
      this.get('notify').info('Hello there!');
    }
  }
});

By default the notifications close after 2.5 seconds, although you can control this in your template:

{{ember-notify closeAfter=4000}}

Or you can control when each message is closed:

var notify = this.get('notify');
var message = notify.alert('You can control how long it\'s displayed', {
  closeAfter: 10000 // or set to null to disable auto-hiding
});

...and you can hide messages programatically:

message.set('visible', false);

You can specify raw HTML:

notify.info({html: '<div class="my-div">Hooray!</div>'});

Rounded corners, if that's your thing:

notify.alert('This one\'s got rounded corners.', {
  radius: true
});

Initializer

If you prefer not to call Ember.inject.service('notify') you can use an initializer:

// app/initializers/ember-notify.js
export {default} from 'ember-notify/initializer';

Multiple Containers

If you want to have separate notifications and control where they're inserted into the DOM you can have multiple {{ember-notify}} components, but only one of them can be accessed using the injected service. The others you will need to provide a source property, so secondary containers should be used as follows:

{{ember-notify source=someProperty}} 
export default Ember.Component.extend({
  someProperty: Notify.property(), // or this.set('someProperty', Notify.create())
  actions: {
    clicked: function() {
      this.get('someProperty').success('Hello from the controller');
    }
  }
});

Installation

This module is an ember-cli addon, so installation is easy as pie.

npm install ember-notify --save-dev

Upgrading from a previous version

See the CHANGELOG.

Compatibility

Some users have reported issues with IE8, so this is currently not supported.

ember-notify's People

Contributors

simonexmachina avatar josemarluedke avatar kbullaughey avatar frekw avatar mjanda avatar anilmaurya avatar heroiceric avatar jcope2013 avatar tygriffin avatar

Watchers

Cătălin Pintea avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.