Skip to content

Commit

Permalink
fix issue #5 (first check stronger tablet rules, then phone)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgoebl committed Jun 5, 2014
1 parent cbf60cd commit 398ab6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
15 changes: 8 additions & 7 deletions generate/mobile-detect.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,21 @@
}
var phone, tablet, phoneSized;

phone = findMatch(mobileDetectRules.phones, userAgent);
if (phone) {
cache.mobile = cache.phone = phone;
cache.tablet = null;
return; // unambiguously identified as phone
}

// first check for stronger tablet rules, then phone (see issue#5)
tablet = findMatch(mobileDetectRules.tablets, userAgent);
if (tablet) {
cache.mobile = cache.tablet = tablet;
cache.phone = null;
return; // unambiguously identified as tablet
}

phone = findMatch(mobileDetectRules.phones, userAgent);
if (phone) {
cache.mobile = cache.phone = phone;
cache.tablet = null;
return; // unambiguously identified as phone
}

// our rules haven't found a match -> try more general fallback rules
if (isMobileFallback(userAgent)) {
phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth);
Expand Down
15 changes: 8 additions & 7 deletions mobile-detect.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,20 +371,21 @@
}
var phone, tablet, phoneSized;

phone = findMatch(mobileDetectRules.phones, userAgent);
if (phone) {
cache.mobile = cache.phone = phone;
cache.tablet = null;
return; // unambiguously identified as phone
}

// first check for stronger tablet rules, then phone (see issue#5)
tablet = findMatch(mobileDetectRules.tablets, userAgent);
if (tablet) {
cache.mobile = cache.tablet = tablet;
cache.phone = null;
return; // unambiguously identified as tablet
}

phone = findMatch(mobileDetectRules.phones, userAgent);
if (phone) {
cache.mobile = cache.phone = phone;
cache.tablet = null;
return; // unambiguously identified as phone
}

// our rules haven't found a match -> try more general fallback rules
if (isMobileFallback(userAgent)) {
phoneSized = MobileDetect.isPhoneSized(maxPhoneWidth);
Expand Down
Loading

0 comments on commit 398ab6e

Please sign in to comment.