Socket
Socket
Sign inDemoInstall

current-device

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

current-device - npm Package Compare versions

Comparing version 0.7.1 to 0.7.2

123

es/index.js
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
// current-device
// (c) 2012-present Matthew Hudson
// current-device is freely distributable under the MIT license.
// For all details and documentation:
// http://thematthewhudson.com/current-device/
var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent, changeOrientationList, walkOnChangeOrientationList;
// Save the previous value of the device variable.
previousDevice = window.device;
var previousDevice = window.device;
device = {};
var device = {};
changeOrientationList = [];
var changeOrientationList = [];

@@ -22,8 +14,11 @@ // Add device as a global object.

// The <html> element.
documentElement = window.document.documentElement;
var documentElement = window.document.documentElement;
// The client user agent string.
// Lowercase, so we can use the more efficient indexOf(), instead of Regex
userAgent = window.navigator.userAgent.toLowerCase();
var userAgent = window.navigator.userAgent.toLowerCase();
// Detectable television devices.
var television = ['googletv', 'viera', 'smarttv', 'internet.tv', 'netcast', 'nettv', 'appletv', 'boxee', 'kylo', 'roku', 'dlnadoc', 'roku', 'pov_tv', 'hbbtv', 'ce-html'];
// Main functions

@@ -89,3 +84,3 @@ // --------------

device.fxos = function () {
return (find('(mobile;') || find('(tablet;')) && find('; rv:');
return (find('(mobile') || find('(tablet')) && find(' rv:');
};

@@ -126,6 +121,3 @@

device.television = function () {
var i,
television = ["googletv", "viera", "smarttv", "internet.tv", "netcast", "nettv", "appletv", "boxee", "kylo", "roku", "dlnadoc", "roku", "pov_tv", "hbbtv", "ce-html"];
i = 0;
var i = 0;
while (i < television.length) {

@@ -162,28 +154,26 @@ if (find(television[i])) {

// Simple UA string search
find = function find(needle) {
function find(needle) {
return userAgent.indexOf(needle) !== -1;
};
}
// Check if documentElement already has a given class.
hasClass = function hasClass(className) {
var regex;
regex = new RegExp(className, 'i');
return documentElement.className.match(regex);
};
function hasClass(className) {
return documentElement.className.match(new RegExp(className, 'i'));
}
// Add one or more CSS classes to the <html> element.
addClass = function addClass(className) {
function addClass(className) {
var currentClassNames = null;
if (!hasClass(className)) {
currentClassNames = documentElement.className.replace(/^\s+|\s+$/g, '');
documentElement.className = currentClassNames + " " + className;
documentElement.className = currentClassNames + ' ' + className;
}
};
}
// Remove single CSS class from the <html> element.
removeClass = function removeClass(className) {
function removeClass(className) {
if (hasClass(className)) {
documentElement.className = documentElement.className.replace(" " + className, "");
documentElement.className = documentElement.className.replace(' ' + className, '');
}
};
}

@@ -197,48 +187,48 @@ // HTML Element Handling

if (device.ipad()) {
addClass("ios ipad tablet");
addClass('ios ipad tablet');
} else if (device.iphone()) {
addClass("ios iphone mobile");
addClass('ios iphone mobile');
} else if (device.ipod()) {
addClass("ios ipod mobile");
addClass('ios ipod mobile');
}
} else if (device.macos()) {
addClass("macos desktop");
addClass('macos desktop');
} else if (device.android()) {
if (device.androidTablet()) {
addClass("android tablet");
addClass('android tablet');
} else {
addClass("android mobile");
addClass('android mobile');
}
} else if (device.blackberry()) {
if (device.blackberryTablet()) {
addClass("blackberry tablet");
addClass('blackberry tablet');
} else {
addClass("blackberry mobile");
addClass('blackberry mobile');
}
} else if (device.windows()) {
if (device.windowsTablet()) {
addClass("windows tablet");
addClass('windows tablet');
} else if (device.windowsPhone()) {
addClass("windows mobile");
addClass('windows mobile');
} else {
addClass("windows desktop");
addClass('windows desktop');
}
} else if (device.fxos()) {
if (device.fxosTablet()) {
addClass("fxos tablet");
addClass('fxos tablet');
} else {
addClass("fxos mobile");
addClass('fxos mobile');
}
} else if (device.meego()) {
addClass("meego mobile");
addClass('meego mobile');
} else if (device.nodeWebkit()) {
addClass("node-webkit");
addClass('node-webkit');
} else if (device.television()) {
addClass("television");
addClass('television');
} else if (device.desktop()) {
addClass("desktop");
addClass('desktop');
}
if (device.cordova()) {
addClass("cordova");
addClass('cordova');
}

@@ -250,24 +240,24 @@

// Handle device orientation changes.
handleOrientation = function handleOrientation() {
function handleOrientation() {
if (device.landscape()) {
removeClass("portrait");
addClass("landscape");
walkOnChangeOrientationList("landscape");
removeClass('portrait');
addClass('landscape');
walkOnChangeOrientationList('landscape');
} else {
removeClass("landscape");
addClass("portrait");
walkOnChangeOrientationList("portrait");
removeClass('landscape');
addClass('portrait');
walkOnChangeOrientationList('portrait');
}
setOrientationCache();
};
}
walkOnChangeOrientationList = function walkOnChangeOrientationList(newOrientation) {
function walkOnChangeOrientationList(newOrientation) {
for (var index in changeOrientationList) {
changeOrientationList[index](newOrientation);
}
};
}
device.onChangeOrientation = function (func) {
if (typeof func == 'function') {
changeOrientationList.push(func);
device.onChangeOrientation = function (cb) {
if (typeof cb == 'function') {
changeOrientationList.push(cb);
}

@@ -278,6 +268,5 @@ };

// otherwise fall back to the resize event.
if (Object.prototype.hasOwnProperty.call(window, "onorientationchange")) {
orientationEvent = "onorientationchange";
} else {
orientationEvent = "resize";
var orientationEvent = 'resize';
if (Object.prototype.hasOwnProperty.call(window, 'onorientationchange')) {
orientationEvent = 'onorientationchange';
}

@@ -310,7 +299,9 @@

device.os = findMatch(['ios', 'iphone', 'ipad', 'ipod', 'android', 'blackberry', 'windows', 'fxos', 'meego', 'television']);
function setOrientationCache() {
device.orientation = findMatch(['portrait', 'landscape']);
}
setOrientationCache();
export default device;

@@ -7,16 +7,8 @@ 'use strict';

// current-device
// (c) 2012-present Matthew Hudson
// current-device is freely distributable under the MIT license.
// For all details and documentation:
// http://thematthewhudson.com/current-device/
var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent, changeOrientationList, walkOnChangeOrientationList;
// Save the previous value of the device variable.
previousDevice = window.device;
var previousDevice = window.device;
device = {};
var device = {};
changeOrientationList = [];
var changeOrientationList = [];

@@ -27,8 +19,11 @@ // Add device as a global object.

// The <html> element.
documentElement = window.document.documentElement;
var documentElement = window.document.documentElement;
// The client user agent string.
// Lowercase, so we can use the more efficient indexOf(), instead of Regex
userAgent = window.navigator.userAgent.toLowerCase();
var userAgent = window.navigator.userAgent.toLowerCase();
// Detectable television devices.
var television = ['googletv', 'viera', 'smarttv', 'internet.tv', 'netcast', 'nettv', 'appletv', 'boxee', 'kylo', 'roku', 'dlnadoc', 'roku', 'pov_tv', 'hbbtv', 'ce-html'];
// Main functions

@@ -94,3 +89,3 @@ // --------------

device.fxos = function () {
return (find('(mobile;') || find('(tablet;')) && find('; rv:');
return (find('(mobile') || find('(tablet')) && find(' rv:');
};

@@ -131,6 +126,3 @@

device.television = function () {
var i,
television = ["googletv", "viera", "smarttv", "internet.tv", "netcast", "nettv", "appletv", "boxee", "kylo", "roku", "dlnadoc", "roku", "pov_tv", "hbbtv", "ce-html"];
i = 0;
var i = 0;
while (i < television.length) {

@@ -167,28 +159,26 @@ if (find(television[i])) {

// Simple UA string search
find = function find(needle) {
function find(needle) {
return userAgent.indexOf(needle) !== -1;
};
}
// Check if documentElement already has a given class.
hasClass = function hasClass(className) {
var regex;
regex = new RegExp(className, 'i');
return documentElement.className.match(regex);
};
function hasClass(className) {
return documentElement.className.match(new RegExp(className, 'i'));
}
// Add one or more CSS classes to the <html> element.
addClass = function addClass(className) {
function addClass(className) {
var currentClassNames = null;
if (!hasClass(className)) {
currentClassNames = documentElement.className.replace(/^\s+|\s+$/g, '');
documentElement.className = currentClassNames + " " + className;
documentElement.className = currentClassNames + ' ' + className;
}
};
}
// Remove single CSS class from the <html> element.
removeClass = function removeClass(className) {
function removeClass(className) {
if (hasClass(className)) {
documentElement.className = documentElement.className.replace(" " + className, "");
documentElement.className = documentElement.className.replace(' ' + className, '');
}
};
}

@@ -202,48 +192,48 @@ // HTML Element Handling

if (device.ipad()) {
addClass("ios ipad tablet");
addClass('ios ipad tablet');
} else if (device.iphone()) {
addClass("ios iphone mobile");
addClass('ios iphone mobile');
} else if (device.ipod()) {
addClass("ios ipod mobile");
addClass('ios ipod mobile');
}
} else if (device.macos()) {
addClass("macos desktop");
addClass('macos desktop');
} else if (device.android()) {
if (device.androidTablet()) {
addClass("android tablet");
addClass('android tablet');
} else {
addClass("android mobile");
addClass('android mobile');
}
} else if (device.blackberry()) {
if (device.blackberryTablet()) {
addClass("blackberry tablet");
addClass('blackberry tablet');
} else {
addClass("blackberry mobile");
addClass('blackberry mobile');
}
} else if (device.windows()) {
if (device.windowsTablet()) {
addClass("windows tablet");
addClass('windows tablet');
} else if (device.windowsPhone()) {
addClass("windows mobile");
addClass('windows mobile');
} else {
addClass("windows desktop");
addClass('windows desktop');
}
} else if (device.fxos()) {
if (device.fxosTablet()) {
addClass("fxos tablet");
addClass('fxos tablet');
} else {
addClass("fxos mobile");
addClass('fxos mobile');
}
} else if (device.meego()) {
addClass("meego mobile");
addClass('meego mobile');
} else if (device.nodeWebkit()) {
addClass("node-webkit");
addClass('node-webkit');
} else if (device.television()) {
addClass("television");
addClass('television');
} else if (device.desktop()) {
addClass("desktop");
addClass('desktop');
}
if (device.cordova()) {
addClass("cordova");
addClass('cordova');
}

@@ -255,24 +245,24 @@

// Handle device orientation changes.
handleOrientation = function handleOrientation() {
function handleOrientation() {
if (device.landscape()) {
removeClass("portrait");
addClass("landscape");
walkOnChangeOrientationList("landscape");
removeClass('portrait');
addClass('landscape');
walkOnChangeOrientationList('landscape');
} else {
removeClass("landscape");
addClass("portrait");
walkOnChangeOrientationList("portrait");
removeClass('landscape');
addClass('portrait');
walkOnChangeOrientationList('portrait');
}
setOrientationCache();
};
}
walkOnChangeOrientationList = function walkOnChangeOrientationList(newOrientation) {
function walkOnChangeOrientationList(newOrientation) {
for (var index in changeOrientationList) {
changeOrientationList[index](newOrientation);
}
};
}
device.onChangeOrientation = function (func) {
if (typeof func == 'function') {
changeOrientationList.push(func);
device.onChangeOrientation = function (cb) {
if (typeof cb == 'function') {
changeOrientationList.push(cb);
}

@@ -283,6 +273,5 @@ };

// otherwise fall back to the resize event.
if (Object.prototype.hasOwnProperty.call(window, "onorientationchange")) {
orientationEvent = "onorientationchange";
} else {
orientationEvent = "resize";
var orientationEvent = 'resize';
if (Object.prototype.hasOwnProperty.call(window, 'onorientationchange')) {
orientationEvent = 'onorientationchange';
}

@@ -315,5 +304,7 @@

device.os = findMatch(['ios', 'iphone', 'ipad', 'ipod', 'android', 'blackberry', 'windows', 'fxos', 'meego', 'television']);
function setOrientationCache() {
device.orientation = findMatch(['portrait', 'landscape']);
}
setOrientationCache();

@@ -320,0 +311,0 @@

{
"name": "current-device",
"version": "0.7.1",
"version": "0.7.2",
"homepage": "https://github.com/matthewhudson/current-device",
"description": "The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo, AppleTV, etc), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).",
"description":
"The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo, AppleTV, etc), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).",
"main": "lib/index.js",
"module": "es/index.js",
"files": [
"es",
"lib",
"umd"
],
"files": ["es", "lib", "umd"],
"scripts": {
"build": "nwb build-web-module",
"clean": "nwb clean-module",
"style": "eslint src/*.js",
"test": "nwb test",
"test:coverage": "nwb test --coverage",
"test:watch": "nwb test --server"
"test:watch": "nwb test --server",
"validate": "npm run style && npm run test"
},
"devDependencies": {
"nwb": "0.19.x"
"eslint": "4.12.1",
"eslint-plugin-import": "2.8.0",
"nwb": "0.20.0",
"prettier": "1.8.2"
},

@@ -23,0 +25,0 @@ "author": {

/*!
* current-device v0.7.1 - https://github.com/matthewhudson/current-device
* current-device v0.7.2 - https://github.com/matthewhudson/current-device
* MIT Licensed

@@ -95,16 +95,8 @@ */

// current-device
// (c) 2012-present Matthew Hudson
// current-device is freely distributable under the MIT license.
// For all details and documentation:
// http://thematthewhudson.com/current-device/
var device, previousDevice, addClass, documentElement, find, handleOrientation, hasClass, orientationEvent, removeClass, userAgent, changeOrientationList, walkOnChangeOrientationList;
// Save the previous value of the device variable.
previousDevice = window.device;
var previousDevice = window.device;
device = {};
var device = {};
changeOrientationList = [];
var changeOrientationList = [];

@@ -115,8 +107,11 @@ // Add device as a global object.

// The <html> element.
documentElement = window.document.documentElement;
var documentElement = window.document.documentElement;
// The client user agent string.
// Lowercase, so we can use the more efficient indexOf(), instead of Regex
userAgent = window.navigator.userAgent.toLowerCase();
var userAgent = window.navigator.userAgent.toLowerCase();
// Detectable television devices.
var television = ['googletv', 'viera', 'smarttv', 'internet.tv', 'netcast', 'nettv', 'appletv', 'boxee', 'kylo', 'roku', 'dlnadoc', 'roku', 'pov_tv', 'hbbtv', 'ce-html'];
// Main functions

@@ -182,3 +177,3 @@ // --------------

device.fxos = function () {
return (find('(mobile;') || find('(tablet;')) && find('; rv:');
return (find('(mobile') || find('(tablet')) && find(' rv:');
};

@@ -219,6 +214,3 @@

device.television = function () {
var i,
television = ["googletv", "viera", "smarttv", "internet.tv", "netcast", "nettv", "appletv", "boxee", "kylo", "roku", "dlnadoc", "roku", "pov_tv", "hbbtv", "ce-html"];
i = 0;
var i = 0;
while (i < television.length) {

@@ -255,28 +247,26 @@ if (find(television[i])) {

// Simple UA string search
find = function find(needle) {
function find(needle) {
return userAgent.indexOf(needle) !== -1;
};
}
// Check if documentElement already has a given class.
hasClass = function hasClass(className) {
var regex;
regex = new RegExp(className, 'i');
return documentElement.className.match(regex);
};
function hasClass(className) {
return documentElement.className.match(new RegExp(className, 'i'));
}
// Add one or more CSS classes to the <html> element.
addClass = function addClass(className) {
function addClass(className) {
var currentClassNames = null;
if (!hasClass(className)) {
currentClassNames = documentElement.className.replace(/^\s+|\s+$/g, '');
documentElement.className = currentClassNames + " " + className;
documentElement.className = currentClassNames + ' ' + className;
}
};
}
// Remove single CSS class from the <html> element.
removeClass = function removeClass(className) {
function removeClass(className) {
if (hasClass(className)) {
documentElement.className = documentElement.className.replace(" " + className, "");
documentElement.className = documentElement.className.replace(' ' + className, '');
}
};
}

@@ -290,48 +280,48 @@ // HTML Element Handling

if (device.ipad()) {
addClass("ios ipad tablet");
addClass('ios ipad tablet');
} else if (device.iphone()) {
addClass("ios iphone mobile");
addClass('ios iphone mobile');
} else if (device.ipod()) {
addClass("ios ipod mobile");
addClass('ios ipod mobile');
}
} else if (device.macos()) {
addClass("macos desktop");
addClass('macos desktop');
} else if (device.android()) {
if (device.androidTablet()) {
addClass("android tablet");
addClass('android tablet');
} else {
addClass("android mobile");
addClass('android mobile');
}
} else if (device.blackberry()) {
if (device.blackberryTablet()) {
addClass("blackberry tablet");
addClass('blackberry tablet');
} else {
addClass("blackberry mobile");
addClass('blackberry mobile');
}
} else if (device.windows()) {
if (device.windowsTablet()) {
addClass("windows tablet");
addClass('windows tablet');
} else if (device.windowsPhone()) {
addClass("windows mobile");
addClass('windows mobile');
} else {
addClass("windows desktop");
addClass('windows desktop');
}
} else if (device.fxos()) {
if (device.fxosTablet()) {
addClass("fxos tablet");
addClass('fxos tablet');
} else {
addClass("fxos mobile");
addClass('fxos mobile');
}
} else if (device.meego()) {
addClass("meego mobile");
addClass('meego mobile');
} else if (device.nodeWebkit()) {
addClass("node-webkit");
addClass('node-webkit');
} else if (device.television()) {
addClass("television");
addClass('television');
} else if (device.desktop()) {
addClass("desktop");
addClass('desktop');
}
if (device.cordova()) {
addClass("cordova");
addClass('cordova');
}

@@ -343,24 +333,24 @@

// Handle device orientation changes.
handleOrientation = function handleOrientation() {
function handleOrientation() {
if (device.landscape()) {
removeClass("portrait");
addClass("landscape");
walkOnChangeOrientationList("landscape");
removeClass('portrait');
addClass('landscape');
walkOnChangeOrientationList('landscape');
} else {
removeClass("landscape");
addClass("portrait");
walkOnChangeOrientationList("portrait");
removeClass('landscape');
addClass('portrait');
walkOnChangeOrientationList('portrait');
}
setOrientationCache();
};
}
walkOnChangeOrientationList = function walkOnChangeOrientationList(newOrientation) {
function walkOnChangeOrientationList(newOrientation) {
for (var index in changeOrientationList) {
changeOrientationList[index](newOrientation);
}
};
}
device.onChangeOrientation = function (func) {
if (typeof func == 'function') {
changeOrientationList.push(func);
device.onChangeOrientation = function (cb) {
if (typeof cb == 'function') {
changeOrientationList.push(cb);
}

@@ -371,6 +361,5 @@ };

// otherwise fall back to the resize event.
if (Object.prototype.hasOwnProperty.call(window, "onorientationchange")) {
orientationEvent = "onorientationchange";
} else {
orientationEvent = "resize";
var orientationEvent = 'resize';
if (Object.prototype.hasOwnProperty.call(window, 'onorientationchange')) {
orientationEvent = 'onorientationchange';
}

@@ -403,5 +392,7 @@

device.os = findMatch(['ios', 'iphone', 'ipad', 'ipod', 'android', 'blackberry', 'windows', 'fxos', 'meego', 'television']);
function setOrientationCache() {
device.orientation = findMatch(['portrait', 'landscape']);
}
setOrientationCache();

@@ -408,0 +399,0 @@

/*!
* current-device v0.7.1 - https://github.com/matthewhudson/current-device
* current-device v0.7.2 - https://github.com/matthewhudson/current-device
* MIT Licensed
*/
!function(n,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.device=o():n.device=o()}(this,function(){return function(n){function o(t){if(e[t])return e[t].exports;var i=e[t]={i:t,l:!1,exports:{}};return n[t].call(i.exports,i,i.exports,o),i.l=!0,i.exports}var e={};return o.m=n,o.c=e,o.d=function(n,e,t){o.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:t})},o.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return o.d(e,"a",e),e},o.o=function(n,o){return Object.prototype.hasOwnProperty.call(n,o)},o.p="",o(o.s=0)}([function(n,o,e){n.exports=e(1)},function(n,o,e){"use strict";function t(n){for(var o=0;o<n.length;o++)if(r[n[o]]())return n[o];return"unknown"}function i(){r.orientation=t(["portrait","landscape"])}Object.defineProperty(o,"__esModule",{value:!0});var r,a,d,c,u,l,s,f,b,p,w,m,y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};a=window.device,r={},w=[],window.device=r,c=window.document.documentElement,p=window.navigator.userAgent.toLowerCase(),r.macos=function(){return u("mac")},r.ios=function(){return r.iphone()||r.ipod()||r.ipad()},r.iphone=function(){return!r.windows()&&u("iphone")},r.ipod=function(){return u("ipod")},r.ipad=function(){return u("ipad")},r.android=function(){return!r.windows()&&u("android")},r.androidPhone=function(){return r.android()&&u("mobile")},r.androidTablet=function(){return r.android()&&!u("mobile")},r.blackberry=function(){return u("blackberry")||u("bb10")||u("rim")},r.blackberryPhone=function(){return r.blackberry()&&!u("tablet")},r.blackberryTablet=function(){return r.blackberry()&&u("tablet")},r.windows=function(){return u("windows")},r.windowsPhone=function(){return r.windows()&&u("phone")},r.windowsTablet=function(){return r.windows()&&u("touch")&&!r.windowsPhone()},r.fxos=function(){return(u("(mobile;")||u("(tablet;"))&&u("; rv:")},r.fxosPhone=function(){return r.fxos()&&u("mobile")},r.fxosTablet=function(){return r.fxos()&&u("tablet")},r.meego=function(){return u("meego")},r.cordova=function(){return window.cordova&&"file:"===location.protocol},r.nodeWebkit=function(){return"object"===y(window.process)},r.mobile=function(){return r.androidPhone()||r.iphone()||r.ipod()||r.windowsPhone()||r.blackberryPhone()||r.fxosPhone()||r.meego()},r.tablet=function(){return r.ipad()||r.androidTablet()||r.blackberryTablet()||r.windowsTablet()||r.fxosTablet()},r.desktop=function(){return!r.tablet()&&!r.mobile()},r.television=function(){var n,o=["googletv","viera","smarttv","internet.tv","netcast","nettv","appletv","boxee","kylo","roku","dlnadoc","roku","pov_tv","hbbtv","ce-html"];for(n=0;n<o.length;){if(u(o[n]))return!0;n++}return!1},r.portrait=function(){return window.innerHeight/window.innerWidth>1},r.landscape=function(){return window.innerHeight/window.innerWidth<1},r.noConflict=function(){return window.device=a,this},u=function(n){return-1!==p.indexOf(n)},s=function(n){var o;return o=new RegExp(n,"i"),c.className.match(o)},d=function(n){var o=null;s(n)||(o=c.className.replace(/^\s+|\s+$/g,""),c.className=o+" "+n)},b=function(n){s(n)&&(c.className=c.className.replace(" "+n,""))},r.ios()?r.ipad()?d("ios ipad tablet"):r.iphone()?d("ios iphone mobile"):r.ipod()&&d("ios ipod mobile"):r.macos()?d("macos desktop"):r.android()?d(r.androidTablet()?"android tablet":"android mobile"):r.blackberry()?d(r.blackberryTablet()?"blackberry tablet":"blackberry mobile"):r.windows()?d(r.windowsTablet()?"windows tablet":r.windowsPhone()?"windows mobile":"windows desktop"):r.fxos()?d(r.fxosTablet()?"fxos tablet":"fxos mobile"):r.meego()?d("meego mobile"):r.nodeWebkit()?d("node-webkit"):r.television()?d("television"):r.desktop()&&d("desktop"),r.cordova()&&d("cordova"),l=function(){r.landscape()?(b("portrait"),d("landscape"),m("landscape")):(b("landscape"),d("portrait"),m("portrait")),i()},m=function(n){for(var o in w)w[o](n)},r.onChangeOrientation=function(n){"function"==typeof n&&w.push(n)},f=Object.prototype.hasOwnProperty.call(window,"onorientationchange")?"onorientationchange":"resize",window.addEventListener?window.addEventListener(f,l,!1):window.attachEvent?window.attachEvent(f,l):window[f]=l,l(),r.type=t(["mobile","tablet","desktop"]),r.os=t(["ios","iphone","ipad","ipod","android","blackberry","windows","fxos","meego","television"]),i(),o.default=r}])});
!function(n,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define([],o):"object"==typeof exports?exports.device=o():n.device=o()}(this,function(){return function(n){function o(t){if(e[t])return e[t].exports;var i=e[t]={i:t,l:!1,exports:{}};return n[t].call(i.exports,i,i.exports,o),i.l=!0,i.exports}var e={};return o.m=n,o.c=e,o.d=function(n,e,t){o.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:t})},o.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return o.d(e,"a",e),e},o.o=function(n,o){return Object.prototype.hasOwnProperty.call(n,o)},o.p="",o(o.s=0)}([function(n,o,e){n.exports=e(1)},function(n,o,e){"use strict";function t(n){return-1!==m.indexOf(n)}function i(n){return w.className.match(new RegExp(n,"i"))}function r(n){var o=null;i(n)||(o=w.className.replace(/^\s+|\s+$/g,""),w.className=o+" "+n)}function a(n){i(n)&&(w.className=w.className.replace(" "+n,""))}function d(){b.landscape()?(a("portrait"),r("landscape"),c("landscape")):(a("landscape"),r("portrait"),c("portrait")),l()}function c(n){for(var o in p)p[o](n)}function u(n){for(var o=0;o<n.length;o++)if(b[n[o]]())return n[o];return"unknown"}function l(){b.orientation=u(["portrait","landscape"])}Object.defineProperty(o,"__esModule",{value:!0});var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},f=window.device,b={},p=[];window.device=b;var w=window.document.documentElement,m=window.navigator.userAgent.toLowerCase(),v=["googletv","viera","smarttv","internet.tv","netcast","nettv","appletv","boxee","kylo","roku","dlnadoc","roku","pov_tv","hbbtv","ce-html"];b.macos=function(){return t("mac")},b.ios=function(){return b.iphone()||b.ipod()||b.ipad()},b.iphone=function(){return!b.windows()&&t("iphone")},b.ipod=function(){return t("ipod")},b.ipad=function(){return t("ipad")},b.android=function(){return!b.windows()&&t("android")},b.androidPhone=function(){return b.android()&&t("mobile")},b.androidTablet=function(){return b.android()&&!t("mobile")},b.blackberry=function(){return t("blackberry")||t("bb10")||t("rim")},b.blackberryPhone=function(){return b.blackberry()&&!t("tablet")},b.blackberryTablet=function(){return b.blackberry()&&t("tablet")},b.windows=function(){return t("windows")},b.windowsPhone=function(){return b.windows()&&t("phone")},b.windowsTablet=function(){return b.windows()&&t("touch")&&!b.windowsPhone()},b.fxos=function(){return(t("(mobile")||t("(tablet"))&&t(" rv:")},b.fxosPhone=function(){return b.fxos()&&t("mobile")},b.fxosTablet=function(){return b.fxos()&&t("tablet")},b.meego=function(){return t("meego")},b.cordova=function(){return window.cordova&&"file:"===location.protocol},b.nodeWebkit=function(){return"object"===s(window.process)},b.mobile=function(){return b.androidPhone()||b.iphone()||b.ipod()||b.windowsPhone()||b.blackberryPhone()||b.fxosPhone()||b.meego()},b.tablet=function(){return b.ipad()||b.androidTablet()||b.blackberryTablet()||b.windowsTablet()||b.fxosTablet()},b.desktop=function(){return!b.tablet()&&!b.mobile()},b.television=function(){for(var n=0;n<v.length;){if(t(v[n]))return!0;n++}return!1},b.portrait=function(){return window.innerHeight/window.innerWidth>1},b.landscape=function(){return window.innerHeight/window.innerWidth<1},b.noConflict=function(){return window.device=f,this},b.ios()?b.ipad()?r("ios ipad tablet"):b.iphone()?r("ios iphone mobile"):b.ipod()&&r("ios ipod mobile"):b.macos()?r("macos desktop"):b.android()?r(b.androidTablet()?"android tablet":"android mobile"):b.blackberry()?r(b.blackberryTablet()?"blackberry tablet":"blackberry mobile"):b.windows()?r(b.windowsTablet()?"windows tablet":b.windowsPhone()?"windows mobile":"windows desktop"):b.fxos()?r(b.fxosTablet()?"fxos tablet":"fxos mobile"):b.meego()?r("meego mobile"):b.nodeWebkit()?r("node-webkit"):b.television()?r("television"):b.desktop()&&r("desktop"),b.cordova()&&r("cordova"),b.onChangeOrientation=function(n){"function"==typeof n&&p.push(n)};var y="resize";Object.prototype.hasOwnProperty.call(window,"onorientationchange")&&(y="onorientationchange"),window.addEventListener?window.addEventListener(y,d,!1):window.attachEvent?window.attachEvent(y,d):window[y]=d,d(),b.type=u(["mobile","tablet","desktop"]),b.os=u(["ios","iphone","ipad","ipod","android","blackberry","windows","fxos","meego","television"]),l(),o.default=b}])});
//# sourceMappingURL=current-device.min.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc