Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
    - use Mobile-Detect@2.8.12
    - breaking change: phone() and tablet() won't return 'UnknownMobile' -> have to check mobile() as well (issue #20)
    - breaking change: fallback detection phone/tablet is now based on smaller screen side (issue #23)
    - expose internal implementation in case somebody wants to quick fix or monkey-patch the behaviour
    - add demo page for gh-pages
    - tweak jshint
  • Loading branch information
hgoebl committed Mar 22, 2015
1 parent 8c53eb2 commit 96d0c57
Show file tree
Hide file tree
Showing 11 changed files with 1,386 additions and 1,160 deletions.
17 changes: 17 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"sub": true,
"undef": true,
"unused": true,
"boss": true,
"eqnull": true,
"browser": true,
"globals": {
"Modernizr": true
}
}
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
v1.0.0:
date: 2015-03-22
changes:
- use Mobile-Detect@2.8.12
- breaking change: phone() and tablet() won't return 'UnknownMobile' -> have to check mobile() as well (issue #20)
- breaking change: fallback detection phone/tablet is now based on smaller screen side (issue #23)
- expose internal implementation in case somebody wants to quick fix or monkey-patch the behaviour

v0.4.3:
date: 2014-12-08
changes:
Expand Down
22 changes: 1 addition & 21 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,7 @@ module.exports = function (grunt) {
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
browser: true,
globals: {
jQuery: true,
Backbone: true,
Modernizr: true,
Mustache: true,
App: true,
console: true,
_: true
}
jshintrc: '.jshintrc'
},
gruntfile: {
src: 'Gruntfile.js'
Expand Down
41 changes: 35 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ You can find out information about the device rendering your web page:
* [Mobile Grade (A, B, C)](http://jquerymobile.com/gbs/)
* specific versions (e.g. WebKit)

Current `master` branch is using detection logic from **Mobile-Detect@2.8.11**
Current `master` branch is using detection logic from **Mobile-Detect@2.8.12**

# Live Demo

Expand All @@ -20,6 +20,28 @@ See it in action with your device:

**[Demo](http://zeno.github.io/mobile-detect-demo/)**

Another Demo/check (though without any styling) can be found [here](http://hgoebl.github.io/mobile-detect.js/check/).

# Warning

As mentioned later, "User-Agent" based detection is not a reliable solution in most cases, because:

* The rules (regular expressions) are constantly out-dated and incomplete
* You have to update the detection code continuously
* There are other ways to detect how your web application should behave:
* feature detection, e.g. [Modernizr](http://modernizr.com/)
* [Media Queries](https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries), examples at <http://mediaqueri.es/>
* Maybe there are some libraries out there (which are probably not free) doing a more reliable job

If you still want to (or have to) use this library, you should always **encapsulate it with your own code**,
because chances a very high that you have to tweak the behaviour a bit or are not satisfied with the
result of mobile-detect.js. **Don't spread usage of MobileDetect all over your own code!** As you can see
in the issues, there are some "bugs", feature-requests, pull-requests where people are not so happy
how MobileDetect works. But I cannot change its behaviour from version to version, even if this was
reasonable from new users' point of view. I hope you show understanding.

At least there is a way to monkey-patch the library (see "Extending" below).

# Usage

## Browser
Expand Down Expand Up @@ -82,9 +104,9 @@ You can easily extend it, e.g. `android`, `iphone`, etc.

## Size (bytes)

* development: 59382
* minified: 33281
* minified + gzipped: 13939 (`cat mobile-detect.min.js | gzip -9f | wc -c`)
* development: 62001
* minified: 34907
* minified + gzipped: 14598 (`cat mobile-detect.min.js | gzip -9f | wc -c`)

# Installation

Expand All @@ -98,12 +120,19 @@ You can easily extend it, e.g. `android`, `iphone`, etc.

## CDN - [jsDelivr](http://www.jsdelivr.com/#!mobile-detect.js)

<script src="//cdn.jsdelivr.net/mobile-detect.js/0.4.3/mobile-detect.min.js"></script>
<script src="//cdn.jsdelivr.net/mobile-detect.js/1.0.0/mobile-detect.min.js"></script>

## cdnjs - [cdnjs.com](https://cdnjs.com/libraries/mobile-detect)

<script src="//cdnjs.cloudflare.com/ajax/libs/mobile-detect/0.4.3/mobile-detect.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/mobile-detect/1.0.0/mobile-detect.min.js"></script>

# Extending/Modifying Behaviour

Though it is not recommended to rely on internal methods or structures of MobileDetect, you can alter
the behaviour by replacing particular internal methods with your own implementations.
If you feel like this is the only possibility, then go ahead and have a look at the source code and
examples in tests/spec/MobileDetectSpec.js (search for "Extensibility").

# Alternatives / Infos

Often device detection is the first solution in your mind. Please consider looking for other solutions
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mobile-detect",
"version": "0.4.3",
"version": "1.0.0",
"description": "Device detection (phone, tablet, desktop, mobile grade, os, versions)",
"homepage": "http://hgoebl.github.io/mobile-detect.js/",
"keywords": [
Expand Down
Loading

0 comments on commit 96d0c57

Please sign in to comment.