Code Monkey home page Code Monkey logo

jgrowl's Introduction

jGrowl

jGrowl is a jQuery plugin that raises unobtrusive messages within the browser, similar to the way that OS X's Growl Framework works. The idea is simple, deliver notifications to the end user in a noticeable way that doesn't obstruct the work flow and yet keeps the user informed.

Installation

jGrowl can be added to your project using package managers like bower and npm or directly into your html using cdnjs, as well as the good old fashioned copy-paste into your project directory.

Use cdnjs:

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/jquery-jgrowl/1.4.8/jquery.jgrowl.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-jgrowl/1.4.8/jquery.jgrowl.min.js"></script>

Install with npm

npm install jgrowl
// Sample 1
$.jGrowl("Hello world!");
// Sample 2
$.jGrowl("Stick this!", { sticky: true });
// Sample 3
$.jGrowl("A message with a header", { header: 'Important' });
// Sample 4
$.jGrowl("A message that will live a little longer.", { life: 10000 });
// Sample 5
$.jGrowl("A message with a beforeOpen callback and a different opening animation.", {
	beforeClose: function(e,m) {
		alert('About to close this notification!');
	},
	animateOpen: {
		height: 'show'
	}
});

Configuration Options

Option Default Description
pool 0 Limit the number of messages appearing at a given time to the number in the pool.
header empty Optional header to prefix the message, this is often helpful for associating messages to each other.
group empty A css class to be applied to notifications when they are created, useful for 'grouping' notifications by a css selector.
sticky false When set to true a message will stick to the screen until it is intentionally closed by the user.
position top-right Designates a class which is applied to the jGrowl container and controls its position on the screen. By Default there are five options available, top-left, top-right, bottom-left, bottom-right, center. This must be changed in the defaults before the startup method is called.
appendTo body The element where our jGrowl messages are appended to. The default is body but feel free to define another one.
glue after Designates whether a jGrowl notification should be appended to the container after all notifications, or whether it should be prepended to the container before all notifications. Options are after or before.
theme default A CSS class designating custom styling for this particular message, intended for use with jQuery UI.
themeState highlight A CSS class designating custom styling for this particular message and its state, intended for use with jQuery UI.
corners 10px If the corners jQuery plugin is include this option specifies the curvature radius to be used for the notifications as they are created.
check 250 The frequency that jGrowl should check for messages to be scrubbed from the screen.This must be changed in the defaults before the startup method is called.
life 3000 The lifespan of a non-sticky message on the screen.
closeDuration normal The animation speed used to close a notification.
openDuration normal The animation speed used to open a notification.
easing swing The easing method to be used with the animation for opening and closing a notification.
closer true Whether or not the close-all button should be used when more then one notification appears on the screen. Optionally this property can be set to a function which will be used as a callback when the close all button is clicked. This must be changed in the defaults before the startup method is called.
closeTemplate ร— This content is used for the individual notification close links that are added to the corner of a notification. This must be changed in the defaults before the startup method is called.
closerTemplate <div>[ close all ]</div> This content is used for the close-all link that is added to the bottom of a jGrowl container when it contains more than one notification. This must be changed in the defaults before the startup method is called.
log function(e,m,o) {} Callback to be used before anything is done with the notification. This is intended to be used if the user would like to have some type of logging mechanism for all notifications passed to jGrowl. This callback receives the notification's DOM context, the notification's message and its option object.
beforeOpen function(e,m,o) {} Callback to be used before a new notification is opened. This callback receives the notification's DOM context, the notification's message and its option object.
afterOpen function(e,m,o) {} Callback to be used after a new notification is opened. This callback receives the notification's DOM context, the notification's message and its option object.
open function(e,m,o) {} Callback to be used when a new notification is opened. This callback receives the notification's DOM context, the notifications message and its option object.
beforeClose function(e,m,o) {} Callback to be used before a new notification is closed. This callback receives the notification's DOM context, the notification's message and its option object.
close function(e,m,o) {} Callback to be used when a new notification is closed. This callback receives the notification's DOM context, the notification's message and its option object.
click function(e,m,o) {} Callback to be used when a notification is clicked. This callback receives the notification's DOM context, the notification's message and its option object.
animateOpen { opacity: 'show' } The animation properties to use when opening a new notification (default to fadeOut).
animateClose { opacity: 'hide' } The animation properties to use when closing a new notification (defaults to fadeIn).

jgrowl's People

Contributors

artemgovorov avatar bpegirk avatar coddwrench avatar curtisgibby avatar dependabot[bot] avatar edofic avatar gustavonovaes avatar juanmcuello avatar mag382 avatar osvaldom avatar p3x-robot avatar reidlai avatar serzhenko avatar stanlemon avatar stefandroog avatar timotheeg avatar zedd45 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

jgrowl's Issues

Will there be a nuget package for v1.4.5

Hi there, I found this package on nuget, but it is version 1.4.0.
That version has an issue which prevents it from working with jQuery 3.x. I see in the commits that this issues has been fixed in 1.4.5 but there is no nuget package updated.

Will you be publishing an update to the nuget?

clearInterval during shutdown?

I have some code that erases a registration dialog upon submission and replaces it with a simple message. Part of the form that gets erased includes the element that a jGrowl message is attached to. When the form is switched and the message div is removed and I get the follwing error on the console:

"Uncaught TypeError: Cannot call method 'update' of undefined"

which points to jquery.jgrowl.js:334

this.interval = setInterval( function() {
L:334 $(e).data('jGrowl.instance').update();
"Uncaught TypeError: Cannot call method 'update' of undefined"
}, parseInt(this.defaults.check));

It appears that the setInterval is left hanging somehow?

I tried calling jGrowl('shutdown') just before removing the DOM elements and this does not fix the problem.

But, if I add the following to the end of the jGrowl shutdown method:

clearInterval(this.interval);

The error goes away.

So, I can certainly modify my local copy of jGrowl, but I am wondering if this points to a possible bugfix? Is the jGrowl setInterval call being properly terminated during the shutdown call?

Thanks!

I'm a hack admin of a Friendica site and this error is cryptic [RuntimeException]

I see this big red panel failure message during the php ~/bin/composer update command for Friendica maintenance and I don't know what it means or how to make it right. I'm not very skilled with composer, git or being a knowledgable admin. I activate a lot of plugins for my Friendica site so I don't even know why this is generated.

                                                                                                                                                                                
  [RuntimeException]                                                                                                                                                            
  Failed to execute git clone --mirror 'git+ssh://[email protected]/stanlemon/jGrowl.git' '/home/outmathadmin/.cache/composer/vcs/git-ssh---git-github.com-stanlemon-jGrowl.git/'  
                                                                                                                                                                                
  Cloning into bare repository '/home/outmathadmin/.cache/composer/vcs/git-ssh---git-github.com-stanlemon-jGrowl.git'...                                                        
  [email protected]: Permission denied (publickey).                                                                                                                                
  fatal: Could not read from remote repository.                                                                                                                                 
                                                                                                                                                                                
  Please make sure you have the correct access rights                                                                                                                           
  and the repository exists.                                                                                                                                                    
                                                                                                                                                                                

Breaklines break jGrowl

Here's an example:

$.jGrowl('Database Error: SQLSTATE[42000]| Syntax error or access violation| 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "alias = "/user/login/"
title = "User Login"" at line 9');

jQuery 1.9 and $.browser

Not sure if you are still maintaining this plugin (I think it's great by the way) but just wanted to give you a heads up that jQuery 1.9 has removed $.browser so you might want to remove the user of it if you can from your plugin.

Localization of label(s)

What can be done to help automate the translation of label(s) in the app? Currently, I only see

closerTemplate:	'<div>[ close all ]</div>'

as a label, but there may be others that I've missed.

I would imagine that you'd just need to override the default closerTemplate (and any other English-based strings that may exist) when you instantiate the jGrowl object, which isn't hard in and of itself. Other projects, like jQuery UI and datatables, have official or semi-official localization files to allow you to automatically override any strings. Something like this would be helpful in jGrowl as well.

How do i customize the growl messages

untitled
How do i customize the growl message, tried doing it like this
//jGrowl notifications
$("#defaultGrowl").click(function() {
$.jGrowl("Hello world!", {theme: test});
});

and .test{
background-color: green;
}

but to no avail, please help out

Different position on same request not available =(

Hello,

i find sad that i can not different positions on the same request make!

An sample:
2 notifications on top-left without sticky...
and one on 'center' as sticky but the plugin create not own instances for the positions so comes all only on the same psotion wo is the first notification printed =(

Best regards Stefan

Add tests

As part of 1.4.0 I would like to add some basic testing to run on travisci to verify jGrowl functionality.

Remove IE6 support

I think time to remove support for IE6 has come (long ago :) ). See *.css files

Maybe a little bug - $('#test1').jGrowl('shutdown');

Hi Stan, thank you, for this awesome plugin, i was working in my website, using your plugin, and when i tried to use the shutdown method, i realize that the div which contains the "hide all notifications" isn't closing with the rest of the div's.

Thank you for you attention

Joana Pereira

how to set a timer with jGrowl

Hi

I wirte a function on my page, this function will check the order from backend, I use ajax to do this, if there is order from backend, then invoke jGrowl to show message, but i tried many times, it didn't work.
the error was "Uncaught TypeError: undefined is not a function",below is my code,please help me to check is anytiny wrong with jGrowl.

(function($){
    $(function(){
        getUnreadOrder();
    });
})(jQuery);

function getUnreadOrder() {
    $.ajax({
        type : "POST",
        url : "${ctx}/store/storeBook!getUnreadOrders.do",
        dataType : 'json',
        async:false,
        success : function(data) {
            var len = data.length;
            if (len > 0) {
                $.jGrowl("You have a latest order!", {
                    header: 'Header',
                    life: 5000,
                    theme:  'manilla',
                    speed:  'slow'
                });
            }
        },
        error : function() {

        }
    });
    setTimeout("getUnreadOrder()",10000);
}

jquery-ui style not overloaded

From what I see on the jgrowl.core.less file here the jquery-ui .ui-state-highlight (among others) is meant to be overloaded. In the examples this looks alright, but if the jquery-ui css is included the style is not overloaded. Maybe the wrong css selector is generated?

Documentation

In the readme, the link to the hosted css file is trying to pull the javascript file instead of the css. Need to change .js to .css

JQuery 3 deprecations

I forked your JGrowl work, to make it jQuery 3 compatible using jQuery-migrate 3.4.0.js. In the process Grunt complained about a possible unsafe version of jshint which it replaced. I'm not a Javascript expert, just used the standard jQuery replacements for the deprecated functions. I couldn't get the Corners plugin support to work, I had to comment it out.

I can make a PR if you want, but althought I'm using the 'new' version successfully, I'm not sure it is useful and it's not fully tested.

Remove trailing comma

Trailing commas in Gruntfile.js causing dojo build stage encounter error. Can you remove those trailing commas? Thanks.

jquery text as 'render'

When you provide 'render' as the text for jQuery, it fails with some weird errors some times. Looks like the render is a keyword somewhere in the framework and it thinks it's a method or something like that but the bug does exist.
image

image

It is nuGet:
image

SyntaxError: Unexpected token & with new rails version

I was using the rails 3.2.1 version and everything was working great. I had to update to the 3.2.11 because of the rails bug and now I get this error and the notifications are not showed:

SyntaxError: syntax error

$(document).ready(function() { $.jGrowl('Ingreso exitoso', { header: &...

compatibility issue with jquery v3.1.1

After upgrading our jquery library to jquery v3.1.1 i could see that clicking on close button for non-sticky notification is not closing the notification. Can you please check ?

accessibility

Hi there. I am using jGrowl on my website, and working on accessibility improvements to said website. I noticed this discussion the owner of this repo had about accessibility: https://stackoverflow.com/questions/42764836/can-screen-reader-like-jaws-read-jgrowl-message but it looks like this was never followed up with any changes in the repository.

The only change that actually needs to happen for jGrowl to be much more accessible is for any div with id="jGrowl" to also have attributes role="alert" and aria-live="polite". Of course if you want to be even more accessible you should allow the $.jGrowl function to optionally accept a boolean for changing to aria-live="assertive" if true.

The other small change would be to add aria-label="close" to the x buttons, since right now a screenreader will read this as a multiplication sign.

I hope this helps the owner of this repo and anyone using jGrowl in the future!

less error

Hi,
I have an issue with following lines in jgrowl.core.less

    -ms-filter:         progid:DXImageTransform.Microsoft.Alpha(Opacity=(@jgrowl-opacity*100));
    filter:             progid:DXImageTransform.Microsoft.Alpha(Opacity=(@jgrowl-opacity*100));

could you enclose them with ~"" like this

    -ms-filter:         ~"progid:DXImageTransform.Microsoft.Alpha(Opacity=(@jgrowl-opacity*100))";
    filter:             ~"progid:DXImageTransform.Microsoft.Alpha(Opacity=(@jgrowl-opacity*100))";

Ability to allow prepend or append 'close all' button

This section of code in the render function:
.appendTo(self.element).animate(this.defaults.animateOpen, this.defaults.speed, this.defaults.easing)

only appends the 'close all' button to the bottom of the growl messages. We'd like a way to pass a option to allow prepending the close all button to the top of the jgrowl messages.

jGrowl and jQuery-ui Dialog compatibility issues

I am using jGrowl and jQuery ui dialog one the same page in one of my projects. The jGrowl notifications become visible when a link is clicked, the same applies for the dialog. I have noticed that after the page loads, if I open the dialog first, the jGrowl notifications don't work. I get a: TypeError: $.jGrowl is undefined.
If I click so that the jGrowl notifications appear first, then both the dialogs and notifications work fine. Do you have any idea why this is happening?

I also have the same issues when I use the qtip2 jquery plugin.

Latest code does not match up with published NPM

Just noticed that the current state of this code does not match up with the version published to NPM.

Can it be updated? For now, I'm pointing package.json to the last commit, but it would be great if someone could confirm this and re-publish to NPM. ๐Ÿ™

how to delay the appearance of notification by certain amount of time?

how to delay the appearance of notification by certain amount of time, say i want to display notification 10 seconds? i tried to use setTimeout JavaScript function but it does not seems to work.

Here is my code(its Ruby/ROR code):

    <% @site.notifications.active.each do |notification| -%>
      setTimeout($.jGrowl('<%= notification.message %>',
              { header: '<%= notification.header %>',
                  life: '<%= notification.life %>',
                  position: '<%= notification.position %>',
                  corners: '<%= notification.corners %>px'}),10000);
      <% end -%>
  });

closerTemplate property

The closerTemplate property not working.

I think the line 331 must be:
$(o.closerTemplate) ...

div positioning

Hi while using jgrowl i am facing div placement issue.
I am calling it like
$.jGrowl(item.message, { header: item.title, life: ' . $modSettings ['enotify_life'] . ' , position: "bottom-left"});
but it is coming as
'<'div class="top-right jGrowl" id="jGrowl"'>'<'div class="jGrowl-notification">some message '<'/div'>'<'/div'>'
I asked it to come at bottom left with postion attribute but it is coming at top right.
the thing is i want to dictate div postion
if it is new post top right but if some one thanks you or mention you in post than bottom left.

thanks and regards
sagrma

growl message does not close after it time outs until the hovered mouse is removed

  1. Bring up the following url - http://jsbin.com/yobowefoqo/1/edit?html,css,output
  2. Click "Create new message" link more than 2 times
  3. Hover mouse on "Close All" option located at the bottom of the last growl message
  4. Now move the mouse over the growl message and sit idle

Expected: Growl meesage should close after it times out
**Actual:
TNAV-20313-growl_does_not_close.zip

** Growl message does not close after it times out

Relative links doesnt work

Hi,

is there a way how to use relative links with jGrowl or do I have to edit my code and somehow add there site URL?

Cos it displays Here as Here (completly deletes href from code).

Closer All

Can't configure options of this element. Seems like it use only default values.

jGrowl including its own jQuery v3 when imported via Yarn/Webpack

Hi there -- been a long-time user of jGrowl in a legacy Rails app that we're migrating to Yarn/Webpack for dependency management.

At the moment, when I include jGrowl in our package.json file:

"jgrowl": "^1.4.6",

and run yarn install, the jGrowl module that shows up in node_modules also brings along its own node_modules subfolder, including its own jQuery v3.6.0.

We've been using JGrowl version 1.4.6 for a while but have been back on jQuery 2.x... and have never noticed a problem. However, the jGrowl package.json specifies jQuery ^3.4.1.

So... as you can imagine Webpack then ends up loading two copies of jQuery: the global v2.x that we install first, and the version 3.4 brought along by jGrowl.

jGrowl is then being attached to this second v3 jQuery instead of the first v2.x jQuery we install and export as a global for use by our legacy JS... so our legacy JS cannot access jGrowl.

I've confirmed that jGrowl does work as expected if I manually delete jGrowl's node_modules folder -- that removes the conflicting copy of jQuery and everything appears to work.

Which leads to the question:

Is jGrowl 1.4.6 only compatible with jQuery 3+?

I'm hoping that if 1.4.6 does in fact work with jQuery 2.x, perhaps adjusting the dependency in the package.json will fix the install issue.

Thanks in advance for any thoughts -- kind of miss the days when questions and issues were actually about using libraries, instead of just installing them...

hi, can't custom close all btn

hi,
jGrowl 1.2.12
line:297
$(this.defaults.closerTemplate).addClass('jGrowl-closer ' + this.defaults.themeState + ' ui-corner-all').addClass(this.defaults.theme)

is it
$(o.closerTemplate).addClass('jGrowl-closer ' + this.defaults.themeState + ' ui-corner-all').addClass(this.defaults.theme)

?

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.