Code Monkey home page Code Monkey logo

humane-js's Introduction

humane.js

This project was heavily inspired by humanmsg project for jQuery. I really liked the project but I wanted to remove the jQuery dependency, add support for CSS transitions, and have more control over the timing. I consider the project complete and don't plan on adding any new features except for any bug fixes.

About

humane.js tries to be as unobtrusive as possible to the user experience while providing helpful information that is clear and grabs the users attention. It is framework independent. Customizable.

Setup

Setup is simple:

  • Download tar/zip
  • Select a theme from themes dir.
  • Include the theme CSS in your page
  • Include humane.min.js in your page

Demo/Usage

You can see a demo and usage here

Custom Themes

Got a neat theme/animation, love to see it. View theme-src/bigbox.styl for an template to get started (uses Stylus w/ Nib and Canvas).

To get setup with Stylus use npm:

npm install --development

With Stylus installed you can watch for changes and compile into CSS by running:

npm run watch

Desktop and Mobile Browser Support

humane.js has been tested for the following browsers.

  • Internet Explorer 7+
  • Firefox 3+
  • Chrome 9+
  • Safari 3+
  • Opera 10+
  • iOS 4+
  • Android 2+

AMD and Node.js Support

humane.js works for AMD systems like require.js and within Node.js CommonJS module system like browserify.

Contributers

Many thanks to the JS/Browser wizards that helped make this better, community rocks!

  • @bga_ (Alexander)
  • @joseanpg (Jose)
  • @OiNutter (Will McKenzie)
  • @ianmassey (Ian Massey)

License

(The MIT License)

Copyright (c) 2018 Marc Harter <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

humane-js's People

Contributors

avoidwork avatar elomerc avatar gwokae avatar ianmassey avatar jackmcdade avatar jaeh avatar jakutis avatar jensroland avatar jisaacks avatar johanneszorn avatar kkirsche avatar louisrli avatar monir avatar msurguy avatar ninir avatar wavded 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

humane-js's Issues

unable to show notifier when page is loaded

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?

Support Bower

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

Unable to supply timeout: 0 option using create()

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.

option for showing multiple messages

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?

Mismatched version tag in component.json

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.

fetching as AMD after window.load doesn't work

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.

Feature: Per-notification options

Not all notifications, even within one 'type' are created equal. Some I know I would like to appear very briefly; others, not.

E.g.:

  • “Sending…” ← Want to appear briefly, even shorter than any other info/generic notification
  • “Offline – will retry” ← Go away on its own after 2 or 3 sec
  • An error message from the server or form validation ← I don’t want this to go away on its own

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.

Demo page doesn't work in IE8

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.

Wrong initial color in demo page notification

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

  • select jackedup
  • click list of items (or any other non-grey item)
  • click the first one
  • the clour of the notification will change from the previous item color to grey color

fatty theme not on bower

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!

Indicator count for queued notifications

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.

remove before log (or error/info/etc) together option

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

Cannot combine callback with options

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?

IE8 error on line 124

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?

Adding hyperlinks to notification?

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.

json_encode issue?

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>";
?>

Humane.js Customize Style

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?

css styling in messages

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

bower install humane-js does not reflect #master

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!

Missing semicolon at the end of the non-minified source

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.

Very cool but no Stacking

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.

"Stacking" notifications.

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 <-- webkit already has this, coming up from the bottom.

growl? <-- 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

Doesn't Work with Latest Safari 5

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>

Queued notification overwrites previous

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]

Option to manually attach humane div.

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?

Limiting number of pending notifications

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

Add unit tests

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

clickToClose is not working

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?

page contents disapear on android

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?

Using multiple themes in single implementation

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?

Stacking of notifications

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.

bigbox: Use media queries to fix centering on small devices

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)

Removing notification elements

Is there any specific reason that the notification elements that are not visible any more are not removed from the DOM?

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.