Git Product home page Git Product logo

bootstrap-growl's Introduction

bootstrap-growl

Pretty simple jQuery plugin that turns standard Bootstrap alerts into hovering "Growl-like" notifications.

Demo

I have a basic demo set up at jsfiddle for the time being which you can view here: http://jsfiddle.net/ifightcrime/Us6WX/1008/

Features

  • Uses standard Twitter Bootstrap alerts which provides 'info', 'danger', and 'success' styles.
  • Multiple growls called consecutively are stacked up one after another in a list.
  • Automatically fades growls away after a default of 4 seconds.

Dependencies

  1. Latest version of jQuery. (tested on 1.11.0)
  2. Twitter Bootstrap. (current rev tested with 3.3.1)

Usage

Include the dependencies and jquery.bootstrap-growl.min.js into your page and call the following:

$.bootstrapGrowl("My message");

Available Options

By default, growls use the standard 'alert' Bootstrap style, are 250px wide, right aligned, and are positioned 20px from the top right of the page.

$.bootstrapGrowl("another message, yay!", {
  ele: 'body', // which element to append to
  type: 'info', // (null, 'info', 'danger', 'success')
  offset: {from: 'top', amount: 20}, // 'top', or 'bottom'
  align: 'right', // ('left', 'right', or 'center')
  width: 250, // (integer, or 'auto')
  delay: 4000, // Time while the message will be displayed. It's not equivalent to the *demo* timeOut!
  allow_dismiss: true, // If true then will display a cross to close the popup.
  stackup_spacing: 10 // spacing between consecutively stacked growls.
});

Note: Previous top_offset is not broken by this latest change.

Additional Contributors

bootstrap-growl's People

Contributors

brentjanderson avatar c0bra avatar callado4 avatar edelbluth avatar gdw2 avatar jhicken avatar jrschumacher avatar kosolapov avatar linuxonrails avatar lloydwatkin avatar longlostnick avatar sophietk avatar vadorequest avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bootstrap-growl's Issues

It doesn't seem to be responsive

Here is what I have:

$(document).ready(function(e) {
    $.bootstrapGrowl('My Message Goes Here. If it is long, it does not wrap on my mobile device.', {
        ele: 'body',
        type: 'danger',
        offset: {from: 'top', amount: 20},
        align: 'right',
        width: 400,
        delay: 5000,
        allow_dismiss: true,
        stackup_spacing: 10
    });
});

If my message is of any length, when viewing on smaller mobile phones like iPhone 5s, the message doesn't wrap, it just shoots off the screen.

I attached an example.

growl_example

Tag releases

I'd like to submit bootstrap-growl to cdnjs, but I need a version number. Will you tag versions to make my task easier?

persist stackup offset

Need to persist the stackup offset to prevent overlap if a user dismisses a growl when another is about to load.

Stack doesn't seem to work in FireFox

If you visit http://habitrpg.com and rapid-fire click those plus & minus icons under Habits, you get a nice bootstrap-growl stack of notifications. Repeat in FireFox, and for me on [FF 15.0, OSX 10.7.4], I only get the first growl alert (the others don't appear), and I have to wait a few seconds before clicking again to get another alert. Could be my code, but just in case it flags anything to you.

Close button wasn't wired up.

Unless I misunderstood, the close button isn't wired up..

Added to allow the alert to be dismissed when clicked (not just the close button)

if (options.allow_dismiss) {
  $alert.append('<a class="close" data-dismiss="alert" href="#" onclick="return false;">&times;</a>');
  $alert.bind('click', function () { $(this).remove(); });
  $alert.css('cursor', 'pointer');
}

Do not create inline HTML, instead use the relevant jQuery functions

It's best to do something like this when creating a new HTML element...

// Close button
var $button = $('<button/>')
        .attr('type', 'button')
        .addClass('close')
        .attr('data-dismiss', 'alert')
        .attr('aria-label', 'Close'),

    // The small 'x'
    $cross = $('<span/>')
        .attr('aria-hidden', 'true')
        .html('&times;');

// Append the cross to the button element
$button.append($cross);

// Append the close button to the alert and add the class
// that it's dimissible
$alert.append($button)
    .addClass('alert-dismissible');

You can see that I have done this in my fork

License?

@ifightcrime, it is a great plugin. Can you add a LICENSE file? :-)

Not compatible with Glyphicons PRO fonts v1.9

I recently installed the new font package from: http://glyphicons.com/

They change their classes from:

example: ".glyphicons .leaf" to ".glyphicons .glyphicons-leaf"

Once installing the following files:

Web Fonts
glyphicons.css

My bootstrap growl alerts now loop the fade in animation. I wish I could show a jsfiddle, however the files require a license, which i cannot preview.

Not sure how the conflict is happening since there is no js errors in the console. Maybe you might have perspective on what may be causing this.

Thank you.

Do not dismiss while mouseover

Little enhancement propably:

When user hovers the mouse above the notification it shouldn't dismiss and it should wait for the mouse to leave.

Also it would be nice not to dismiss any of the visible notifications while hovering over single one of them.

[enhancement] Add missing bower.json.

Hey, maintainer(s) of ifightcrime/bootstrap-growl!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library ifightcrime/bootstrap-growl is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "ifightcrime/bootstrap-growl",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

bootstrap.js doesn't need to be required

I guess you can change a few things in a way that you could use this plugin only with bootstrap.css, whitout bootstrap.js.

I had to change this

if (options.delay > 0)
{
    $alert.delay(options.delay).fadeOut(function()
    {
        return $(this).alert("close");
    });
}

into this

function removeAlert()
{
    $alert.fadeOut(function() {
        return $alert.remove();
    });
}

if (options.delay > 0)
{
    setTimeout(removeAlert, options.delay);
}

$alert.find("[data-dismiss=\"alert\"]").click(removeAlert);

What do you think?

Failing JSHint

Kind of a serious issue, as it states Did you mean to return a conditional instead of an assignment?. I have fixed in my custom fork for now.

New tag

Can you add new tag or retag v1.0.0 with current master version.
Because v1.0.0 has bug with position absolute/fixed

.alert("close") on line 57 causes no method 'alert' error

When the alerts close, this line of code returns:

  • TypeError: [Object object] has no method 'alert'

Deleting the alert part removes the error but may have some consequence I am not seeing. See below the code before and after my edit:

Before:

  • $alert.delay(options.delay).fadeOut(function() { return $(this).alert("close"); });

After:

  • $alert.delay(options.delay).fadeOut(function() { return $(this) });

Display several messages at the same time

Personally, display several messages at the same time doesn't works, only one is displayed. Sometimes if I change the content or the message type it works again.

github.io page needs updating

Under Available Options the code says:
type: 'info', // (null, 'info', 'error', 'success')

Need to update error to danger.

Notification is fixed to the page instead to the screen

For me the growler notification doesn't have a fixed position to the screen when scrolling down the page.

When it was at the top it was shown only at the top of the whole page not just the vieport, so user couldn't see it when page was scrolled down. Same thing then for bottom offset where it wasn't at the bottom of the viewport when page was scrolled but at a fixed position on the page.

Solution I found is to have the 'position' CSS rule set to 'fixed' instead of 'absolute'.

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.