This repository has been archived by the owner on Jun 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathpgwbrowser.min.js
9 lines (9 loc) · 6.42 KB
/
pgwbrowser.min.js
1
2
3
4
5
6
7
8
9
/**
* PgwBrowser - Version 1.3
*
* Copyright 2014-2015, Jonathan M. Piat
* http://pgwjs.com - http://pagawa.com
*
* Released under the GNU GPLv3 license - http://opensource.org/licenses/gpl-3.0
*/
!function(e){e.pgwBrowser=function(){var r={};r.userAgent=navigator.userAgent,r.browser={},r.viewport={},r.os={},resizeEvent=null;var n=[{name:"Chromium",group:"Chrome",identifier:"Chromium/([0-9.]*)"},{name:"Chrome Mobile",group:"Chrome",identifier:"Chrome/([0-9.]*) Mobile",versionIdentifier:"Chrome/([0-9.]*)"},{name:"Chrome",group:"Chrome",identifier:"Chrome/([0-9.]*)"},{name:"Chrome for iOS",group:"Chrome",identifier:"CriOS/([0-9.]*)"},{name:"Android Browser",group:"Chrome",identifier:"CrMo/([0-9.]*)"},{name:"Firefox",group:"Firefox",identifier:"Firefox/([0-9.]*)"},{name:"Opera Mini",group:"Opera",identifier:"Opera Mini/([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera ([0-9.]*)"},{name:"Opera",group:"Opera",identifier:"Opera/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"},{name:"IEMobile",group:"Explorer",identifier:"IEMobile/([0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"MSIE ([a-zA-Z0-9.]*)"},{name:"Internet Explorer",group:"Explorer",identifier:"Trident/([0-9.]*)",versionIdentifier:"rv:([0-9.]*)"},{name:"Spartan",group:"Spartan",identifier:"Edge/([0-9.]*)",versionIdentifier:"Edge/([0-9.]*)"},{name:"Safari",group:"Safari",identifier:"Safari/([0-9.]*)",versionIdentifier:"Version/([0-9.]*)"}],o=[{name:"Windows 2000",group:"Windows",identifier:"Windows NT 5.0",version:"5.0"},{name:"Windows XP",group:"Windows",identifier:"Windows NT 5.1",version:"5.1"},{name:"Windows Vista",group:"Windows",identifier:"Windows NT 6.0",version:"6.0"},{name:"Windows 7",group:"Windows",identifier:"Windows NT 6.1",version:"7.0"},{name:"Windows 8",group:"Windows",identifier:"Windows NT 6.2",version:"8.0"},{name:"Windows 8.1",group:"Windows",identifier:"Windows NT 6.3",version:"8.1"},{name:"Windows 10",group:"Windows",identifier:"Windows NT 10.0",version:"10.0"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone ([0-9.]*)"},{name:"Windows Phone",group:"Windows Phone",identifier:"Windows Phone OS ([0-9.]*)"},{name:"Windows",group:"Windows",identifier:"Windows"},{name:"Chrome OS",group:"Chrome OS",identifier:"CrOS"},{name:"Android",group:"Android",identifier:"Android",versionIdentifier:"Android ([a-zA-Z0-9.-]*)"},{name:"iPad",group:"iOS",identifier:"iPad",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPod",group:"iOS",identifier:"iPod",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"iPhone",group:"iOS",identifier:"iPhone OS",versionIdentifier:"OS ([0-9_]*)",versionSeparator:"[_|.]"},{name:"Mac OS X El Capitan",group:"Mac OS",identifier:"Mac OS X (10([_|.])11([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Yosemite",group:"Mac OS",identifier:"Mac OS X (10([_|.])10([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mavericks",group:"Mac OS",identifier:"Mac OS X (10([_|.])9([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Mountain Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])8([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Lion",group:"Mac OS",identifier:"Mac OS X (10([_|.])7([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Snow Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])6([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Leopard",group:"Mac OS",identifier:"Mac OS X (10([_|.])5([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Tiger",group:"Mac OS",identifier:"Mac OS X (10([_|.])4([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Panther",group:"Mac OS",identifier:"Mac OS X (10([_|.])3([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Jaguar",group:"Mac OS",identifier:"Mac OS X (10([_|.])2([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Puma",group:"Mac OS",identifier:"Mac OS X (10([_|.])1([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS X Cheetah",group:"Mac OS",identifier:"Mac OS X (10([_|.])0([0-9_.]*))",versionSeparator:"[_|.]"},{name:"Mac OS",group:"Mac OS",identifier:"Mac OS"},{name:"Ubuntu",group:"Linux",identifier:"Ubuntu",versionIdentifier:"Ubuntu/([0-9.]*)"},{name:"Debian",group:"Linux",identifier:"Debian"},{name:"Gentoo",group:"Linux",identifier:"Gentoo"},{name:"Linux",group:"Linux",identifier:"Linux"},{name:"BlackBerry",group:"BlackBerry",identifier:"BlackBerry"}],a=function(){var e=r.userAgent.toLowerCase();for(i in n){var o=new RegExp(n[i].identifier.toLowerCase()),a=o.exec(e);if(null!=a&&a[1]){if(r.browser.name=n[i].name,r.browser.group=n[i].group,n[i].versionIdentifier){var s=new RegExp(n[i].versionIdentifier.toLowerCase()),d=s.exec(e);null!=d&&d[1]&&t(d[1])}else t(a[1]);break}}return!0},t=function(e){var i=e.split(".",2);return r.browser.fullVersion=e,i[0]&&(r.browser.majorVersion=parseInt(i[0])),i[1]&&(r.browser.minorVersion=parseInt(i[1])),!0},s=function(){var e=r.userAgent.toLowerCase();for(i in o){var n=new RegExp(o[i].identifier.toLowerCase()),a=n.exec(e);if(null!=a){if(r.os.name=o[i].name,r.os.group=o[i].group,o[i].version)d(o[i].version,o[i].versionSeparator?o[i].versionSeparator:".");else if(a[1])d(a[1],o[i].versionSeparator?o[i].versionSeparator:".");else if(o[i].versionIdentifier){var t=new RegExp(o[i].versionIdentifier.toLowerCase()),s=t.exec(e);null!=s&&s[1]&&d(s[1],o[i].versionSeparator?o[i].versionSeparator:".")}break}}return!0},d=function(e,i){if("["==i.substr(0,1))var n=e.split(new RegExp(i,"g"),2);else var n=e.split(i,2);return"."!=i&&(e=e.replace(new RegExp(i,"g"),".")),r.os.fullVersion=e,n[0]&&(r.os.majorVersion=parseInt(n[0])),n[1]&&(r.os.minorVersion=parseInt(n[1])),!0},p=function(i){return r.viewport.width=e(window).width(),r.viewport.height=e(window).height(),"undefined"==typeof i&&(null==resizeEvent?e(window).trigger("PgwBrowser::StartResizing"):clearTimeout(resizeEvent),resizeEvent=setTimeout(function(){e(window).trigger("PgwBrowser::StopResizing"),clearTimeout(resizeEvent),resizeEvent=null},300)),!0},u=function(){if("undefined"==typeof window.orientation)r.viewport.width>=r.viewport.height?r.viewport.orientation="landscape":r.viewport.orientation="portrait";else switch(window.orientation){case-90:case 90:r.viewport.orientation="landscape";break;default:r.viewport.orientation="portrait"}return e(window).trigger("PgwBrowser::OrientationChange"),!0};return"undefined"!=typeof window.pgwJsUserAgentTester&&(r.userAgent=window.pgwJsUserAgentTester),a(),s(),p(!0),u(),e(window).on("orientationchange",function(e){u()}),e(window).resize(function(e){p()}),r}}(window.Zepto||window.jQuery);