Commits

Stephen McKamey committed 03d4cf0

- mobile tweaks

Comments (0)

Files changed (3)

 	User-agent specific CSS support
 
 	Created: 2006-06-10-1635
-	Modified: 2011-01-06-1132
+	Modified: 2011-01-06-1227
 
 	Copyright (c)2006-2011 Stephen M. McKamey
 	Distributed under The MIT License.
 		R_MSPIE = /\b(mspie|microsoft pocket internet explorer)[\s\/]*(\d+(\.\d+)*)/,
 		R_iCab = /\bicab[\s\/]*(\d+(\.\d+)*)/,
 		R_BlackBerry = /\bblackberry\w*[\s\/]+(\d+(\.\d+)*)/,
-		R_mobile = /(\w*mobile[\/]\w*|\bandroid\b|\bipad\b|\bipod\b|\w*phone\w*|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b|blackberry\w*|\bwebos\b|windows ce\b|palm\w*\b|symbian\w*\b)/;
+		R_mobile = /(\w*mobile[\/]\w*|\bandroid\b|\bipad\b|\bipod\b|blackberry\w*|\bwebos\b|windows ce\b|palm\w*\b|symbian\w*\b|\w*phone\w*|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b)/;
 
 	var cssua = {
 
 
 			// version standardization
 			if (ua.safari) {
-				if (ua.chrome || ua.android || ua.blackberry || ua.webos) {
+				if (ua.chrome || (ua.mobile && !ua.ios)) {
 					delete ua.safari;
 
 				} else if (ua.version) {
 					ua.safari = ua.version;
 
-				} else /*if (ua.safari > 80 && ua.safari < 500)*/ {
+				} else {
 					ua.safari = ({
 						"419": "2.0.4",
 						"417": "2.0.3",
-var cssua=function(i,l){var m=/[\w\-\.]+[\/][v]?\d+(\.\d+)*/g,n=/\b(aol|america online browser)[\s\/]*(\d+(\.\d+)*)/,o=/\b(msie|microsoft internet explorer)[\s\/]*(\d+(\.\d+)*)/,p=/rv[:](\d+(\.\d+)*).*?\bgecko[\/]\d+/,q=/\bopera[\s\/]*(\d+(\.\d+)*)/,r=/\bandroid[\s]+(\d+(\.\d+)*)/,s=/\bos[\s]+(\d+(\_\d+)*) like mac os x/,t=/\b(mspie|microsoft pocket internet explorer)[\s\/]*(\d+(\.\d+)*)/,u=/\bicab[\s\/]*(\d+(\.\d+)*)/,v=/\bblackberry\w*[\s\/]+(\d+(\.\d+)*)/,w=/(\w*mobile[\/]\w*|\bandroid\b|\bipad\b|\bipod\b|\w*phone\w*|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b|blackberry\w*|\bwebos\b|windows ce\b|palm\w*\b|symbian\w*\b)/,
+var cssua=function(i,l){var m=/[\w\-\.]+[\/][v]?\d+(\.\d+)*/g,n=/\b(aol|america online browser)[\s\/]*(\d+(\.\d+)*)/,o=/\b(msie|microsoft internet explorer)[\s\/]*(\d+(\.\d+)*)/,p=/rv[:](\d+(\.\d+)*).*?\bgecko[\/]\d+/,q=/\bopera[\s\/]*(\d+(\.\d+)*)/,r=/\bandroid[\s]+(\d+(\.\d+)*)/,s=/\bos[\s]+(\d+(\_\d+)*) like mac os x/,t=/\b(mspie|microsoft pocket internet explorer)[\s\/]*(\d+(\.\d+)*)/,u=/\bicab[\s\/]*(\d+(\.\d+)*)/,v=/\bblackberry\w*[\s\/]+(\d+(\.\d+)*)/,w=/(\w*mobile[\/]\w*|\bandroid\b|\bipad\b|\bipod\b|blackberry\w*|\bwebos\b|windows ce\b|palm\w*\b|symbian\w*\b|\w*phone\w*|\bpda\b|\bchtml\b|\bmidp\b|\bcldc\b)/,
 g={parse:function(b){var a={};b=(""+b).toLowerCase();if(!b)return a;var c=b.match(m);if(c)for(var e=0;e<c.length;e++){var f=c[e].indexOf("/"),d=c[e].substring(0,f);if(d&&d!=="mozilla"){if(d==="applewebkit")d="webkit";a[d]=c[e].substr(f+1)}}if(n.exec(b))a.aol=RegExp.$2;if(q.exec(b))a.opera=RegExp.$1;else if(u.exec(b))a.icab=RegExp.$1;else if(o.exec(b))a.ie=RegExp.$2;else if(t.exec(b))a.mspie=RegExp.$2;else if(p.exec(b))a.gecko=RegExp.$1;else if(r.exec(b))a.android=RegExp.$1;else if(s.exec(b))a.ios=
-RegExp.$1.split("_").join(".");if(!a.blackberry&&v.exec(b))a.blackberry=RegExp.$1;if(w.exec(b))a.mobile=RegExp.$1;if(a.safari)if(a.chrome||a.android||a.blackberry||a.webos)delete a.safari;else a.safari=a.version?a.version:{"419":"2.0.4","417":"2.0.3","416":"2.0.2","412":"2.0","312":"1.3","125":"1.2","85":"1.0"}[parseInt(a.safari,10)]||a.safari;else if(a.opera&&a.version)a.opera=a.version;a.version&&delete a.version;return a},format:function(b){function a(f,d){f=f.split(".").join("-");var j=" ua-"+
-f;if(d){d=d.split(".").join("-");for(var h=d.indexOf("-");h>0;){j+=" ua-"+f+"-"+d.substring(0,h);h=d.indexOf("-",h+1)}j+=" ua-"+f+"-"+d}return j}var c="",e;for(e in b)if(e&&b.hasOwnProperty(e))c+=a(e,b[e]);return c},encode:function(b){var a="",c;for(c in b)if(c&&b.hasOwnProperty(c)){if(a)a+="&";a+=encodeURIComponent(c)+"="+encodeURIComponent(b[c])}return a}};g.userAgent=g.ua=g.parse(l);var k=g.format(g.ua);if(i.className)i.className+=k;else i.className=k.substr(1);return g}(document.documentElement,
-navigator.userAgent);
+RegExp.$1.split("_").join(".");if(!a.blackberry&&v.exec(b))a.blackberry=RegExp.$1;if(w.exec(b))a.mobile=RegExp.$1;if(a.safari)if(a.chrome||a.mobile&&!a.ios)delete a.safari;else a.safari=a.version?a.version:{"419":"2.0.4","417":"2.0.3","416":"2.0.2","412":"2.0","312":"1.3","125":"1.2","85":"1.0"}[parseInt(a.safari,10)]||a.safari;else if(a.opera&&a.version)a.opera=a.version;a.version&&delete a.version;return a},format:function(b){function a(f,d){f=f.split(".").join("-");var j=" ua-"+f;if(d){d=d.split(".").join("-");
+for(var h=d.indexOf("-");h>0;){j+=" ua-"+f+"-"+d.substring(0,h);h=d.indexOf("-",h+1)}j+=" ua-"+f+"-"+d}return j}var c="",e;for(e in b)if(e&&b.hasOwnProperty(e))c+=a(e,b[e]);return c},encode:function(b){var a="",c;for(c in b)if(c&&b.hasOwnProperty(c)){if(a)a+="&";a+=encodeURIComponent(c)+"="+encodeURIComponent(b[c])}return a}};g.userAgent=g.ua=g.parse(l);var k=g.format(g.ua);if(i.className)i.className+=k;else i.className=k.substr(1);return g}(document.documentElement,navigator.userAgent);

test/parseTests.js

 	same(actual, expected, "");
 });
 
+test("Nokia 3650 (Symbian)", function() {
+
+	var input = "Nokia3650/1.0 SymbianOS/6.1 Series60/1.2 Profile/MIDP-1.0 Configuration/CLDC-1.0";
+
+	var expected =
+		{
+			"nokia3650" : "1.0",
+			"symbianos" : "6.1",
+			"series60" : "1.2",
+			"mobile" : "symbianos"
+		};
+
+	var actual = cssua.parse(input);
+
+	same(actual, expected, "");
+});
+
+test("Nokia 6120c (WebKit)", function() {
+
+	var input = "Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 Nokia6120c/3.83; Profile/MIDP-2.0 Configuration/CLDC-1.1) AppleWebKit/413 (KHTML, like Gecko) Safari/413";
+
+	var expected =
+		{
+			"symbianos" : "9.2",
+			"series60" : "3.1",
+			"nokia6120c" : "3.83",
+			"webkit" : "413",
+			"mobile" : "symbianos"
+		};
+
+	var actual = cssua.parse(input);
+
+	same(actual, expected, "");
+});
+
+test("Nokia 3650 (Netfront)", function() {
+
+	var input = "Mozilla/4.0 (compatible; MSIE 4.0; SmartPhone; Symbian OS/1.1.0) Netfront/3.1";
+
+	var expected =
+		{
+			"ie" : "4.0",
+			"os" : "1.1.0",
+			"netfront" : "3.1",
+			"mobile" : "smartphone"
+		};
+
+	var actual = cssua.parse(input);
+
+	same(actual, expected, "");
+});
+
 test("AOL 9.6 (IE 8)", function() {
 
 	var input = "Mozilla/4.0 (compatible; MSIE 8.0; AOL 9.6; AOLBuild 4340.122; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; MS-RTC LM 8)";
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.