1/** 2 * isMobile.js v0.3.6 3 * 4 * A simple library to detect Apple phones and tablets, 5 * Android phones and tablets, other mobile devices (like blackberry, mini-opera and windows phone), 6 * and any kind of seven inch device, via user agent sniffing. 7 * 8 * @author: Kai Mallea ([email protected]) 9 * 10 * @license: http://creativecommons.org/publicdomain/zero/1.0/ 11 */ 12 13(function (global) { 14 var apple_phone = /iPhone/i, 15 apple_ipod = /iPod/i, 16 apple_tablet = /iPad/i, 17 android_phone = /(?=.*\bAndroid\b)(?=.*\bMobile\b)/i, // Match 'Android' AND 'Mobile' 18 android_tablet = /Android/i, 19 windows_phone = /IEMobile/i, 20 windows_tablet = /(?=.*\bWindows\b)(?=.*\bARM\b)/i, // Match 'Windows' AND 'ARM' 21 other_blackberry = /BlackBerry/i, 22 other_blackberry_10 = /BB10/i, 23 other_opera = /Opera Mini/i, 24 other_firefox = /(?=.*\bFirefox\b)(?=.*\bMobile\b)/i, // Match 'Firefox' AND 'Mobile' 25 seven_inch = new RegExp( 26 '(?:' + // Non-capturing group 27 28 'Nexus 7' + // Nexus 7 29 30 '|' + // OR 31 32 'BNTV250' + // B&N Nook Tablet 7 inch 33 34 '|' + // OR 35 36 'Kindle Fire' + // Kindle Fire 37 38 '|' + // OR 39 40 'Silk' + // Kindle Fire, Silk Accelerated 41 42 '|' + // OR 43 44 'GT-P1000' + // Galaxy Tab 7 inch 45 46 '|' + // OR 47 48 'PlayBook' + // Blackberry Playbook 49 50 ')', // End non-capturing group 51 52 'i'); // Case-insensitive matching 53 54 var match = function(regex, userAgent) { 55 return regex.test(userAgent); 56 }; 57 58 var IsMobileClass = function(userAgent) { 59 var ua = userAgent || navigator.userAgent; 60 61 this.apple = { 62 phone: match(apple_phone, ua), 63 ipod: match(apple_ipod, ua), 64 tablet: match(apple_tablet, ua), 65 device: match(apple_phone, ua) || match(apple_ipod, ua) || match(apple_tablet, ua) 66 }; 67 this.android = { 68 phone: match(android_phone, ua), 69 tablet: !match(android_phone, ua) && match(android_tablet, ua), 70 device: match(android_phone, ua) || match(android_tablet, ua) 71 }; 72 this.windows = { 73 phone: match(windows_phone, ua), 74 tablet: match(windows_tablet, ua), 75 device: match(windows_phone, ua) || match(windows_tablet, ua) 76 }; 77 this.other = { 78 blackberry: match(other_blackberry, ua), 79 blackberry10: match(other_blackberry_10, ua), 80 opera: match(other_opera, ua), 81 firefox: match(other_firefox, ua), 82 device: match(other_blackberry, ua) || match(other_blackberry_10, ua) || match(other_opera, ua) || match(other_firefox, ua) 83 }; 84 this.seven_inch = match(seven_inch, ua); 85 this.any = this.apple.device || this.android.device || this.windows.device || this.other.device || this.seven_inch; 86 // excludes 'other' devices and ipods, targeting touchscreen phones 87 this.phone = this.apple.phone || this.android.phone || this.windows.phone; 88 // excludes 7 inch devices, classifying as phone or tablet is left to the user 89 this.tablet = this.apple.tablet || this.android.tablet || this.windows.tablet; 90 91 if (typeof window === 'undefined') { 92 return this; 93 } 94 }; 95 96 var instantiate = function() { 97 var IM = new IsMobileClass(); 98 IM.Class = IsMobileClass; 99 return IM; 100 }; 101 102 if (typeof module != 'undefined' && module.exports && typeof window === 'undefined') { 103 //node 104 module.exports = IsMobileClass; 105 } else if (typeof module != 'undefined' && module.exports && typeof window !== 'undefined') { 106 //browserify 107 module.exports = instantiate(); 108 } else if (typeof define === 'function' && define.amd) { 109 //AMD 110 define('isMobile', [], global.isMobile = instantiate()); 111 } else { 112 global.isMobile = instantiate(); 113 } 114 115})(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.