wavded / humane-js Goto Github PK
View Code? Open in Web Editor NEWA simple, modern, browser notification system
Home Page: http://wavded.github.io/humane-js/
A simple, modern, browser notification system
Home Page: http://wavded.github.io/humane-js/
The log()
function on line 183-184:
log: function (html, o, cb, defaults) {
var msg = defaults || {}
Since the defaults
object is being passed by reference rather than cloned, every queued notification will share the same html, options and callback. My proposed fix does a shallow clone:
log: function (html, o, cb, defaults) {
var msg = {}
if (defaults)
for (var opt in defaults)
msg[opt] = defaults[opt]
Hi there!
humane is a very helpful js and I really enjoyed using it.
However, today I need to add a notifier when a page is loaded. In Chrome, it worked just fine with Jquery 1.7.1 and I put humane.log() inside $document.ready. However, when I use IE9 the notifier won't show up. So I put the humane.log() into window.onload to getting throught that. But when go back to IE8, the notifier disappears again.
If I create a DOM which clicked to trigger the notifier to show up in IE8, it just work fine, so I doubt it might be conflicts with onload or Jquery $document.ready functions,
Any suggestions to show the notifier when the page is loaded in IE8?
Not all notifications, even within one 'type' are created equal. Some I know I would like to appear very briefly; others, not.
E.g.:
Seems kind of odd not to have this option, actually. I’d rather see a config object than a post-display function as the second argument of humane[.<type>]()
calls.
Hi, we are running into the issue that humane setting up a min-height of 100% , I can't see why this is usable at all. Maybe you? Can it be removed?
When I use this in the head of my page, it tries to run this.container = o.container || doc.body
before body
exists.
Adding that line to Human#_setupEl
would fix it for me.
First, thanks for humane, we like a lot and it works great.
There are certain goings-on in our application where a number of humane notifications can get shown in a short period of time. It's good that they queue up and can all eventually be seen by clicking or waiting.
I had the idea that perhaps each notification could have some indicator of how many more notifications are queued up. That is, along with the text in the notification there could be a number saying how many more messages there are "behind" the current one.
Does that make sense?
Kind thanks again and in advance. Take care.
I will open a PR later if you think this is a good idea - currently (with bigbox at least) the humane notification is not centered correctly on all sizes. We can use media queries to make it be a set width on 320-768px / 768-992px (phone / tablet)
Is there any specific reason that the notification elements that are not visible any more are not removed from the DOM?
Hi there!
Was just checking out the online demo's and noticed that support for IE8 on the demo page is limited. When I change the theme to something (ie. Jacked up), it results in a javascript error.
This is adapted from the email I sent to @wavded, as I figured that this would be an all-around better forum for the issue than either twitter or email, especially since you indicated in a tweet that you'd been thinking of this for the next version, anyhow.
I'm working on a site and humane.js is going a long way to making one of its central features /possible/, so many thanks and kudos to you for your fabulous work on it. However, one showstopper that I've realized is that I'm not able to "stack" the notifications concurrently and that there can only be one concurrently visible notification on the screen at a time, while any others that get logged before it times out get a slot in a backlog queue. So I guess I'm looking to hack on humane. But I'm not the best JS dev in the world, so I suppose I'm in need of some minor guidance. Which are the relevant sections of code? Would you be able to tell me what needs to happen in either English or pseudocode? If you could, I'm sure I could implement the patch with no problems.
Here are some examples of what I'm trying to achieve:
<-- webkit already has this, coming up from the bottom.
<-- though I've never used it and so can't say for sure, this appears to be growl and is more or less exactly what I'm looking for.
Thanks again,
@adlwalrus
The current amd / node friendly definition format doesn't play well with the loading functionality of requirejs. I needed to stripe the module.exports code and directly assign window.humane = new Humane in a single closure structure.
Here is a gist of the simplified code, sans all node js support, that works with requirejs. https://gist.github.com/gregory80/b451035746ad8479bf04
allow users to fork and issue pull requests for additional theme css
I'm wondering if there is the ability to customise the markup?
Hey... so I am currently using humanejs in development and am going with the original theme so far and it's been great for errors and bold notifications.
However, I have a situation where I've been using it to indicate when a user has saved a draft and now I'm implementing an autosave feature to save drafts every 10 seconds. Where the original theme notification was perfect to indicate when they (un)successfully saved a draft on user action, it's way too obtrusive to pop-up in the middle of editing to indicate a successful autosave.
What I would like to do is use one of the less obtrusive themes for the autosave (jackedup or libnotify) while keeping the bolder notifications for intentional user actions. I was thinking that if there was an option to specify a class for the dialog you could include two of the theme css' which were modified to style descending from those classes. However, there doesn't seem to be a way to do this with any of the available options or hooks. Is there any ways to do something like this?
when using bower to install humane-js the current master branch is not pulled. 3.2.0 is.
this is a problem for automated builds because main property does not exist in 3.2.0
3.2.0
{
"name": "humane-js",
"version": "3.2.0",
"author": "Marc Harter <@wavded> (wavded.com)",
"description": "A simple, modern, browser notification system",
"keywords": [ "notification", "alert" ],
}
master
{
"name": "humane-js",
"version": "3.2.0",
"author": "Marc Harter <@wavded> (wavded.com)",
"description": "A simple, modern, browser notification system",
"keywords": [ "notification", "alert" ],
"main":"./humane.min.js"
}
The quick fix for this is to use bower to directly pull humane-js.get#master
"dependencies": {
"humane-js": "https://github.com/wavded/humane-js.git#master",
},
I hope there is time to employ a more robust fix since the humane-js module is quite nice!
Hope this helps!
I love the styling and effects, but there's a problem. What if a notification is being displayed and just after a second a new notification is fired?
You need to add stacking.
I have been using humane and its awesome, however I have a call to humane:
<div id="notify"></div>
<!-- rest of the html -->
<script>
var notify = humane.create({container: document.getElementById('notify')});
notify.log("<h2>Order successfully submitted for 435645 of the Test Brochure</h2><p>You will be contacted shortly with confirmation of your order</p>", { timeout: 5000, clickToClose: false, addnCls: "success"});
</script>
</body>
I am including the style sheet and humane.js in the top and when I try and run the above notify.log
call i get an error in IE8 reported on line 124 which is:
this.el.filters.item('DXImageTransform.Microsoft.Alpha').Opacity = opacity*100
As far as I can see I have my document matching that of http://wavded.github.com/humane-js/ in terms of where I run the notify.log
call and where I include the js and css files. Is it possible that the issue with me setting a container?
In the demo page I've selected 'jackedup' and the 'Welcome back' demo is initially green if you run it after the list demo.
How to replicate
jackedup
list of items
(or any other non-grey item)Lets say I do something like this:
humane.waitForMove = true;
humane.info("not so interesting");
humane.error("important!");
In some cases it would be great to see the error message in addition to the info message.
Could we integrate an option like humane.maxMessages = 5;
to see five message at the same time?
With opacity: 0, if there are links or form elements below the notification div they are unable to be clicked.
This could be solved by setting display: none when the div is not being used.
This has been tested in Firefox, Safari, and Chrome.
I'm using humane with Aurelia, and found that humane attaches its div to the body of the dom. However, Aurelia will replace all of the contents inside body with its own, which orphans the div.
Aurelia uses system-js, so there's not a whole lot of control over when you can make it run.
Would it be possible to have an init() option or something similar?
This is not a big deal, but it would be helpful to someone who is not that familiar with the rules of minification. My setup is such that I include all my vendor libraries unminified and then run concat + uglifyjs later. The problem I was having today is that I was getting a random undefined error on the minified javascript. Took me about 30 minutes to realize that I was probably missing a semicolon at the end of one of my js files. Turned out to be in humane.js.
As I said, not a big deal, but people who concat + minify this file with all their other source may have a hard time figuring out the issue.
The screen flicker with a very noticeable black area while a new message is displayed. It happens for all the type of messages viz., log, error, info and success.
I'm using Android 2.3.x phone with its bultin webkit based browser.
On the demo page, after a notification disapears, all the content on the page disapears too. But as soon I scroll the page everything reapears again. It's very strange, maybe even a bug in the browser?
Hi, I've just deployed humanejs instead of spinner/ticker icon on http://greptweet.com
The problem is that I want to show Please wait or loading,... ... still working (like Gmail), whilst the long running script happens in the background. I tried setting timeout to zero but that didn't work.
Any suggestions? Many thanks,
https://github.com/kaihendry/Greptweet/blob/master/index.shtml#L14
There could be some cutoff point on the number of pending notifications. So that if many notifications are triggered, they are not added anymore to the queue (or they override those in the queue).
For example, I would like errors to stay on the screen indefinitely but notices & successes to disappear rather quickly.
I would like to create multiple instances of a notification and am using var variablename = humane.create({baseCls: 'hhumane-libnotify', timeout: 0}); to do that. This part works. Now the first and second labels are on top of each other so you can't see both at the same time. How can I customize the top of the second (and any additional) notifications to show up below each other so they are all visible?
Is there a way to add clickable hyperlinks to the Humane notifications?
I've tried simply adding the links to the notification text, but although they appear in the notification, they're not clickable — even if I disable dismissing the notification on-click.
Maybe I missed this in the docs, but I didn't see a way to make the notifications disappear on a click directly on the notification, instead of just on any mouse movement.
Well humane.log("Test")
works, but not the below, missing something? 👨
<? php
$str = json_encode($my_array);
print $str;
echo "<script>humane.log('$str');</script>";
?>
Safari 5.0.5 on Snow Leopard 10.6.8
There are no errors, my guess is that it's related to the css transitions.
<html>
<head>
<link rel="stylesheet" type="text/css" href="bold-light.css" />
<script type="text/javascript" src="humane.js"></script>
</head>
<body>
<a href="#" onclick="humane('test'); return false;">display</a>
</body>
</html>
Version tag in component.json is set to 3.0.6 while the version tag in package.json features 3.1.0. This raises a warning when using bowerjs.
Please fix this.
Bower is a package manager for the web from Twitter.
Add component.json
to project:
{
"name": "humane",
"version": "3.0.6",
"main": "./humane.js"
}
bower register humane git://github.com/wavded/humane-js.git
On the github.io page you stated
A simple, modern, framework-independent, well-tested, unobtrusive, notification system.
But I see no test
script in your project. Please add (unit) tests
You can do
humane.log('test', function(){console.log('done');});
And you can do
humane.log('test', {timeout: 5000});
but you cannot combine the two, like this
humane.log('test', {callback: function(){console.log('done');}, timeout: 5000});
Or can you? Would that be a hard thing to implement?
The forceNew
option doesn't work. In fact, it isn't even used. o_O
Option to stack messages instead of wait for each to appear.
The notification stay stuck on top of the screen with IE9
I am using humane.js as an AMD module, which I fetch asynchronously when an on-page event needs to fire a notification. However, when humane.js is initialized after window.load, it doesn't work, and the notification isn't displayed (tested in Chrome 21 on Windows 7).
The problem is in lines 58-59
if (ENV.domLoaded) this._setupEl()
else ENV.on(win,'load',ENV.bind(this._setupEl, this))
Since ENV.domLoaded
is initialized to false
, the first constructor invocation will always try to bind _setupEl
to the window.load
event, but since we are running the constructor on-demand, the event has already fired.
My workaround was to simply initialize domReady to true
, but a true fix would use a proper domReady implementation (specifically https://github.com/ded/domready/) instead of the hardcoded default value.
Ran into this using timeout 0 while tweaking CSS.
Since the default options are set in the constructor using logic expressions supplying 0 for the timeout option with humane.create() will get you the default value instead.
I think there should be also a way to have notifications stacked one below the other and not be displayed in series. Sometimes it is really painful to display many notifications one after another, user having to click on many of them to get faster closing.
Hello,
Is it possible to use HTML in the messages ?
I would like to use some css classes to style some text and although it's accepting the HTML code it's not applying the styling. What's wrong ?
Thanks
Went to use the fatty theme after installing from bower and it looks like it's not included in 3.1.0. Maybe it's time for a new release :)
Great Lib btw!
Hey there,
I really like that library! I might be wrong, but clickToClose is not working for me :( I have to do the following, right?
humane.clickToClose = true
humane.log('foo')
Or am I missing something?
Hello.
I have the following snippet of code: https://gist.github.com/9e8913c73bc7347c2c74
Everything works fine after first click on "a1" span, but on every second click after that, the notification is removed and is showed back again but stays only for 2,5 seconds.
Hi!
Currently I'm trying to hack my way in order to include some icon/image in the notification with no luck so far.
Have you thought about something like this?
humane.log("Options can be passed", { image: 'http://www.asknature.org/images/avatars/avatar-default.jpg', timeout: 4000, clickToClose: true, addnCls: 'humane-error' });
Sometimes there is a need of two or more logs one after another. So the second log must appear without waiting the first one. We can do this with remove() method:
humane.error("something wrong happened...");
(by the way another wrong happens, so log must appear and no wait:)
humane.remove();
humane.error("another wrong...");
It would be nice if there was an option something like
humane.dontWaitForDisappear = true
and we didn't have to call "remove()" method again and again
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.