shawnmclean / Idle.js

Javascript activity library for the browser. (away, idle, etc)
Other
402 stars 59 forks source link

Document Supported Browsers #7

Open thorst opened 11 years ago

thorst commented 11 years ago

This script looks/works good, and I'm sure the documentation will come when you release a beta.

But when you get to that point (or sooner) please document the browsers you have tested in.

Tested http://shawnmclean.github.io/Idle.js/

PASS:: Windows 7: Firefox 20.0.1 Chrome Version 27.0.1453.73 beta-m IE 10

FAIL:: Windows XP: IE 8

SCRIPT438: Object doesn't support property or method 'addEventListener' idle.js, line 43 character 7

I've committed to compatibility down to ie8. Unfortunately this fails in ie8. To get rid of the above error i added:

        if (document.addEventListener) {
            document.addEventListener("visibilitychange", (function () {
                return activity.handleVisibilityChange();
            }), false);
            document.addEventListener("webkitvisibilitychange", (function () {
                return activity.handleVisibilityChange();
            }), false);
            document.addEventListener("msvisibilitychange", (function () {
                return activity.handleVisibilityChange();
            }), false);
        } else {
            document.attachEvent("onvisibilitychange", (function () {
                return activity.handleVisibilityChange();
            }));
        }

This will then run, but it doesn't work. I will see if i can figure out some more fixes.

thorst commented 11 years ago

Everything seems to work now. I changed to:

        document.onclick = activeMethod;
        document.onmousemove = activeMethod;
        document.onmouseenter = activeMethod;
        document.onkeydown = activeMethod;
        document.onscroll = activeMethod;

Im not sure the below code ever fires though:

        document.attachEvent("onvisibilitychange", (function () {
            return activity.handleVisibilityChange();
        }));
thorst commented 11 years ago

The achieve the active tab functionality in ie8 you can reference https://github.com/mathiasbynens/jquery-visibility

shawnmclean commented 11 years ago

Hello Thorst, thanks for taking an interest in the project. I'll look into these issues. So the only problem is ie8 and the visibility api?

thorst commented 11 years ago

ie8 doesn't have addEventListener or visibility api. So the jquery-visibility project could help with that, if you want that feature to be in ie8. I don't really need that for my implementation, so that doesn't bother me.

It also doesn't like binding window.on* instead preferring document.on* for everything but scroll.

Correction from previous post: window.onscroll = activeMethod; scrolling event on document doesn't work. So i changed it back to window and it does work in ie8 that way.

chrisbloom7 commented 10 years ago

Any progress on this?

shawnmclean commented 10 years ago

@chrisbloom7 what would you like to see changed?

chrisbloom7 commented 10 years ago

@shawnmclean Oops, I actually meant to ask after progress on issue #9, not this one.