Giter Club home page Giter Club logo

bs-notifier's Introduction

bs-notifier

Growl-like notification plugin using Twitter Bootsrap's alert component. The project originally started to extend bootstrap-notify. Therefore, the plugin works pretty much the same as bootstrap-notify.

Usage

HTML

Add a container element with a position indicator class in your html.

<div class="notifications top-right"></div>

Available position indicator classes are .top-right, .top-left, .bottom-right and .bottom-left.

JavaScript

Get a new (or existing) plugin instance with the notifier() method.

var notifier = $('.notifications.top-right').notifier({
    // ...your own default options
});

If a plugin instance is already bound to the element, notifier() returns the instance instead of createing a new one. In this case, notifier() also re-initializes the instance if the options argument is passed.

Then, display a notification using the show() method.

notifier.show({
    type: 'info',
    message: 'Hello world!',
    // ...onetime options
});

notifier.show({
    type: 'warning',
    title: 'Watch out!',
    message: 'She will chew you up.'
});

You can simply pass a message text (or html) to show a notification with the default options.

notifier.show('Lorem ipsum dolor sit amet...');

To remove the plugin from the element, execute the destroy() method.

notifier.destroy();

Options

type

Notification type corresponding to .alert- contextual class. success, info, warning and danger are available.

Default: 'success'

title

Title text/html of the notification. This option is not set by default.

message

Text/html for the body of the notification. This option is not set by default. You need to set this option every time you show a new notification.

useIcon

Whether to display an icon at the begining of the title (or the body when the title is omitted).

Default: true

icons

Set of icon-classes used for each nortification type.

Default: {
success: 'glyphicon glyphicon-ok-sign',
info: 'glyphicon glyphicon-info-sign',
warning: 'glyphicon glyphicon-exclamation-sign',
danger: 'glyphicon glyphicon-remove-sign'
}

icon

Css class for icon. This option is not set by default. Use this option when you want to use one-time custom icon for a particular notification.

iconTemplate

Icon tag template. The plugin replaces the string {{icon}} in the template with the icon class chosen from the icons option or given as the icon option.

Default: '<i class="{{icon}}"></i>'

titleTag

HTML tag for the title block.

Default: 'h4'

titleClass

CSS class for the title block.

Default: 'alert-title'

fade

Whether to perform fade-out animation.

Default: true

autoClose

Whether to close notification automatically after the time set to the duration option.

Default: true

duration

Milliseconds to auto-close notification.

Default: 3000

onClose

Event handler for close.bs.alert event.

Default: null

Note: Since Bootstrap fires close event twice when notification has .fade.in class, you need to set false to the fade option when you use this option.

onClosed

Event handler for closed.bs.alert event.

Default: null

bs-notifier's People

Contributors

mymth avatar

Stargazers

 avatar

Watchers

 avatar  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.