{"version":3,"sources":["device.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"device.min.js","sourcesContent":["// Device.js\r\n// (c) 2014 Matthew Hudson\r\n// Device.js is freely distributable under the MIT license.\r\n// For all details and documentation:\r\n// http://matthewhudson.me/projects/device.js/\r\n\r\n(function() {\r\n\r\n var device,\r\n previousDevice,\r\n addClass,\r\n documentElement,\r\n find,\r\n handleOrientation,\r\n hasClass,\r\n orientationEvent,\r\n removeClass,\r\n userAgent;\r\n\r\n // Save the previous value of the device variable.\r\n previousDevice = window.device;\r\n\r\n device = {};\r\n\r\n // Add device as a global object.\r\n window.device = device;\r\n\r\n // The element.\r\n documentElement = window.document.documentElement;\r\n\r\n // The client user agent string.\r\n // Lowercase, so we can use the more efficient indexOf(), instead of Regex\r\n userAgent = window.navigator.userAgent.toLowerCase();\r\n\r\n // Main functions\r\n // --------------\r\n\r\n device.ios = function () {\r\n return device.iphone() || device.ipod() || device.ipad();\r\n };\r\n\r\n device.iphone = function () {\r\n return !device.windows() && find('iphone');\r\n };\r\n\r\n device.ipod = function () {\r\n return find('ipod');\r\n };\r\n\r\n device.ipad = function () {\r\n return find('ipad');\r\n };\r\n\r\n device.android = function () {\r\n return !device.windows() && find('android');\r\n };\r\n\r\n device.androidPhone = function () {\r\n return device.android() && find('mobile');\r\n };\r\n\r\n device.androidTablet = function () {\r\n return device.android() && !find('mobile');\r\n };\r\n\r\n device.blackberry = function () {\r\n return find('blackberry') || find('bb10') || find('rim');\r\n };\r\n\r\n device.blackberryPhone = function () {\r\n return device.blackberry() && !find('tablet');\r\n };\r\n\r\n device.blackberryTablet = function () {\r\n return device.blackberry() && find('tablet');\r\n };\r\n\r\n device.windows = function () {\r\n return find('windows');\r\n };\r\n\r\n device.windowsPhone = function () {\r\n return device.windows() && find('phone');\r\n };\r\n\r\n device.windowsTablet = function () {\r\n return device.windows() && (find('touch') && !device.windowsPhone());\r\n };\r\n\r\n device.fxos = function () {\r\n return (find('(mobile;') || find('(tablet;')) && find('; rv:');\r\n };\r\n\r\n device.fxosPhone = function () {\r\n return device.fxos() && find('mobile');\r\n };\r\n\r\n device.fxosTablet = function () {\r\n return device.fxos() && find('tablet');\r\n };\r\n\r\n device.meego = function () {\r\n return find('meego');\r\n };\r\n\r\n device.cordova = function () {\r\n return window.cordova && location.protocol === 'file:';\r\n };\r\n\r\n device.nodeWebkit = function () {\r\n return typeof window.process === 'object';\r\n };\r\n\r\n device.mobile = function () {\r\n return device.androidPhone() || device.iphone() || device.ipod() || device.windowsPhone() || device.blackberryPhone() || device.fxosPhone() || device.meego();\r\n };\r\n\r\n device.tablet = function () {\r\n return device.ipad() || device.androidTablet() || device.blackberryTablet() || device.windowsTablet() || device.fxosTablet();\r\n };\r\n\r\n device.desktop = function () {\r\n return !device.tablet() && !device.mobile();\r\n };\r\n\r\n device.television = function() {\r\n var i, television = [\r\n \"googletv\",\r\n \"viera\",\r\n \"smarttv\",\r\n \"internet.tv\",\r\n \"netcast\",\r\n \"nettv\",\r\n \"appletv\",\r\n \"boxee\",\r\n \"kylo\",\r\n \"roku\",\r\n \"dlnadoc\",\r\n \"roku\",\r\n \"pov_tv\",\r\n \"hbbtv\",\r\n \"ce-html\"\r\n ];\r\n\r\n i = 0;\r\n while (i < television.length) {\r\n if (find(television[i])) {\r\n return true;\r\n }\r\n i++;\r\n }\r\n return false;\r\n };\r\n\r\n device.portrait = function () {\r\n return (window.innerHeight / window.innerWidth) > 1;\r\n };\r\n\r\n device.landscape = function () {\r\n return (window.innerHeight / window.innerWidth) < 1;\r\n };\r\n\r\n // Public Utility Functions\r\n // ------------------------\r\n\r\n // Run device.js in noConflict mode,\r\n // returning the device variable to its previous owner.\r\n device.noConflict = function () {\r\n window.device = previousDevice;\r\n return this;\r\n };\r\n\r\n // Private Utility Functions\r\n // -------------------------\r\n\r\n // Simple UA string search\r\n find = function (needle) {\r\n return userAgent.indexOf(needle) !== -1;\r\n };\r\n\r\n // Check if documentElement already has a given class.\r\n hasClass = function (className) {\r\n var regex;\r\n regex = new RegExp(className, 'i');\r\n return documentElement.className.match(regex);\r\n };\r\n\r\n // Add one or more CSS classes to the element.\r\n addClass = function (className) {\r\n var currentClassNames = null;\r\n if (!hasClass(className)) {\r\n currentClassNames = documentElement.className.replace(/^\\s+|\\s+$/g, '');\r\n documentElement.className = currentClassNames + \" \" + className;\r\n }\r\n };\r\n\r\n // Remove single CSS class from the element.\r\n removeClass = function (className) {\r\n if (hasClass(className)) {\r\n documentElement.className = documentElement.className.replace(\" \" + className, \"\");\r\n }\r\n };\r\n\r\n // HTML Element Handling\r\n // ---------------------\r\n\r\n // Insert the appropriate CSS class based on the _user_agent.\r\n\r\n if (device.ios()) {\r\n if (device.ipad()) {\r\n addClass(\"ios ipad tablet\");\r\n } else if (device.iphone()) {\r\n addClass(\"ios iphone mobile\");\r\n } else if (device.ipod()) {\r\n addClass(\"ios ipod mobile\");\r\n }\r\n } else if (device.android()) {\r\n if (device.androidTablet()) {\r\n addClass(\"android tablet\");\r\n } else {\r\n addClass(\"android mobile\");\r\n }\r\n } else if (device.blackberry()) {\r\n if (device.blackberryTablet()) {\r\n addClass(\"blackberry tablet\");\r\n } else {\r\n addClass(\"blackberry mobile\");\r\n }\r\n } else if (device.windows()) {\r\n if (device.windowsTablet()) {\r\n addClass(\"windows tablet\");\r\n } else if (device.windowsPhone()) {\r\n addClass(\"windows mobile\");\r\n } else {\r\n addClass(\"desktop\");\r\n }\r\n } else if (device.fxos()) {\r\n if (device.fxosTablet()) {\r\n addClass(\"fxos tablet\");\r\n } else {\r\n addClass(\"fxos mobile\");\r\n }\r\n } else if (device.meego()) {\r\n addClass(\"meego mobile\");\r\n } else if (device.nodeWebkit()) {\r\n addClass(\"node-webkit\");\r\n } else if (device.television()) {\r\n addClass(\"television\");\r\n } else if (device.desktop()) {\r\n addClass(\"desktop\");\r\n }\r\n\r\n if (device.cordova()) {\r\n addClass(\"cordova\");\r\n }\r\n\r\n // Orientation Handling\r\n // --------------------\r\n\r\n // Handle device orientation changes.\r\n handleOrientation = function () {\r\n if (device.landscape()) {\r\n removeClass(\"portrait\");\r\n addClass(\"landscape\");\r\n } else {\r\n removeClass(\"landscape\");\r\n addClass(\"portrait\");\r\n }\r\n };\r\n\r\n // Detect whether device supports orientationchange event,\r\n // otherwise fall back to the resize event.\r\n if (Object.prototype.hasOwnProperty.call(window, \"onorientationchange\")) {\r\n orientationEvent = \"orientationchange\";\r\n } else {\r\n orientationEvent = \"resize\";\r\n }\r\n\r\n // Listen for changes in orientation.\r\n if (window.addEventListener) {\r\n window.addEventListener(orientationEvent, handleOrientation, false);\r\n } else if (window.attachEvent) {\r\n window.attachEvent(orientationEvent, handleOrientation);\r\n } else {\r\n window[orientationEvent] = handleOrientation;\r\n }\r\n\r\n handleOrientation();\r\n\r\n if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\r\n define(function() {\r\n return device;\r\n });\r\n } else if (typeof module !== 'undefined' && module.exports) {\r\n module.exports = device;\r\n } else {\r\n window.device = device;\r\n }\r\n\r\n}).call(this);"]}