Giter Site home page Giter Site logo

matthewhudson / current-device Goto Github PK

View Code? Open in Web Editor NEW
3.9K 3.9K 587.0 1.04 MB

๐Ÿ“ฑ The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).

Home Page: https://matthewhudson.github.io/current-device/

License: MIT License

JavaScript 93.70% Makefile 6.30%
device-detection javascript mobile

current-device's People

Contributors

allcontributors[bot] avatar athou avatar dependabot[bot] avatar girvan avatar gitter-badger avatar gordeyev avatar greenkeeper[bot] avatar guilhermesimoes avatar higimo avatar hvish avatar hypernurb avatar jonasjonny avatar jpuffer avatar jsteunou avatar kkirsche avatar leekatz1 avatar lotterfriends avatar marcelblum avatar martinwepner avatar matthewhudson avatar mchambaud avatar mkai avatar mustardandrew avatar noobsarepeople2 avatar patrickjs avatar poteto avatar renovate[bot] avatar rteran avatar sergeybochkarev avatar thomasjonas 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

current-device's Issues

Add bower support

This looks like a nice tool we could need for our project. But it has no bower support :/

Any chance Bower support can be added soon? It's easy ...

Thanks!

Like to add orientation based javascript changes

Would really like to see support for orientation based javascript changes. So on orientation we can adapt the javascript content of an element (as opposed to the current media query change in the html tag)

Would love to see OS versions

For mobile devices, I'd love to see OS versions integrated, considering the major differences between Android browsers.

Add device.js to cdnjs

Previous to doing this, I need to adjust the build process for new version releases.

  • I need to start tagging versions
  • I need to fix the grunt 'bump/release' task, because the package.json version update isn't updated in grunt.initConfig({ pkg: ... })

Clarify Phone vs. OS Methods & Classes

I should add two new methods:

  • device.androidPhone()
  • device.blackberryPhone()

This will provide conceptual symmetry with the device.windowsPhone() method and provide stronger methods for writing Conditional JavaScript.

Note: device.android() or device.blackberry() will remain intact. They provide a nice general condition check since they are both implemented similarly to device.ios()

BB10 detection

Since the BlackBerry 10 browser uses the string "BB10" instead of "BlackBerry", device.js now detects it as being a 'desktop' browser, when it should be mobile.

Add grunt.js

Useful for building the CoffeeScript into dev & prod versions.

CSS Combinator is not applying along with device.js class.

Hi,
CSS Combinator is not applying along with device.js class.

In our development, we are dynamically adding html element and along with that we are also writing device specific css.

Combinator with those dynamically added html element is not working for us?
(Example Combinators, pseudo class)

Example : .mobile > div
here ".mobile" is class

Thanks,
Anish Jain

Add phablet devices

Thank you for great script.
Can you add support for phablet devices (additional class .phablet), which is tablets, but in portrait orientation it has <640 px width? It is logically to show mobile page version on it, but I can't detect them as mobile.

Orientation: undefined on firefox beta on android

Hello,

On Android 4.1.1 + firefox beta (16)

UA String: mozilla/5.0 (android; tablet; rv:16.0) gecko/16.0 firefox/16.0
Dimensions: 980x1345
Orientation: undefined
CSS Classes: android tablet portrait

Add Contributing guidelines

If I want to contribute, I don't know what files I'm supposed to change. I can:

  1. Change just the src coffee file.
  2. Change the src coffee file and compile it using the grunt build command.

The problem with the second option is that the grunt task also changes the version number of the project. Changing the version should be up to the maintainer of the project, no?

Add Best Practices guidelines to README

Environment detection has a high rate of misuse. Often times, folks will attempt to work around browser support problems by checking for the affected browser and doing something different in response. The preferred solution for those kinds of problems, of course, is to check for the feature, not the browser (ala Modernizr).

However, that common misuse of device detection doesn't mean it should never be done. A library such as this one could be employed to change the interface of your web app such that it uses interaction patterns and UI elements common to the device it's being presented on. Android devices might get a slightly different treatment than Windows or iOS, for instance.

In light of this, I think this library deserves a foreword talking about the dangers of misusing device detection and highlighting some use cases where it should be applied.

remove unnecessary space in function _addClass

was:

_addClass = function(class_name) {
        if (!_hasClass(class_name)) {
            return _doc_element.className += " " + class_name;
        }
    };

fix:

_addClass = function(class_name) {
        if (!_hasClass(class_name)) {
            return _doc_element.className = _doc_element.className.trim() + " " + class_name;
        }
    };

this function added space before last class in html tag every time when it was called

Add Conditional CSS/JS support for Phones

Great work! Here are some methods I would like:

  • isMobile: Checks if user is viewing from a mobile device (boolean)
  • isTablet: Checks if user is viewing from a tablet (boolean)
  • isPhone: Checks if user is viewing from a phone (boolean)

Correct version?

The package.json shows that this library is at 0.1.59 but the version at the top of the minified file shows 0.1.58

No-conflict mode for use with PhoneGap

It would be useful to have a no-conflict mode (similar to jQuerys) for use with PhoneGap/Cordova, which also sets window.device.

I realised this when I got errors after packaging an html/js app with PhoneGap Build - PhoneGap was overwriting window.device. As a workaround, I did a find+replace to use window.devicejs instead.

Maybe have a note in the readme about use with PhoneGap too, as I expect it'll be a popular combination.

Problem with touch-enabled Windows laptops

I've met some problems with device.js's way to detect Windows Tablets.

Detection is done correctly in some cases, but when user has a Windows laptop, with touchscreen and Win8 (or 8.1) device.js detects user as tablet user. And some cases that detection is wrong, as user should be detected as desktop user, instead of tablet user.

One (maybe the only) way to handle this, for now, is to detect these users by OS architecture. ARM is tablet and Win64, x86 and wow64 are desktops.

Sample UA-string for some Lenovo model:

Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0; Touch; MALNJS)

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.