From 0ab8629a1b5d0ee8ff13f842b4d6cdcd622e5065 Mon Sep 17 00:00:00 2001 From: Eric Villard Date: Tue, 26 Nov 2013 13:46:39 +0100 Subject: [PATCH 1/3] add ie 11 support fix issue Issue #22 Signed-off-by:Eric Villard --- css_browser_selector.js | 2 +- css_browser_selector_dev.js | 2 +- tests/tester.html | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/css_browser_selector.js b/css_browser_selector.js index 0668aa7..4508f6f 100644 --- a/css_browser_selector.js +++ b/css_browser_selector.js @@ -5,4 +5,4 @@ http://rafael.adm.br/css_browser_selector License: http://creativecommons.org/licenses/by/2.5/ Contributors: http://rafael.adm.br/css_browser_selector#contributors */ -function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent); +function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv|firefox/i.test(ua))&&/trident|msie/i.test(ua)&&/(msie\s|rv\:)(\d+)/.test(ua))?('ie ie'+RegExp.$2):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent); diff --git a/css_browser_selector_dev.js b/css_browser_selector_dev.js index 3fddee5..c4ce8a4 100644 --- a/css_browser_selector_dev.js +++ b/css_browser_selector_dev.js @@ -40,7 +40,7 @@ function css_browser_selector(u) b= [ // browser - (!(/opera|webtv/i.test(ua))&&/msie\s(\d+)/.test(ua))?('ie ie'+(/trident\/4\.0/.test(ua) ? '8' : RegExp.$1)) + (!(/opera|webtv|firefox/i.test(ua))&&/trident|msie/i.test(ua)&&/(msie\s|rv\:)(\d+)/.test(ua))?('ie ie'+(/trident\/4\.0/.test(ua) ? '8' : RegExp.$2)) :is('firefox/')?g+ " " + f+(/firefox\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)?' '+f+RegExp.$2 + ' '+f+RegExp.$2+"_"+RegExp.$4:'') :is('gecko/')?g :is('opera')?o+(/version\/((\d+)(\.(\d+))(\.\d+)*)/.test(ua)?' '+o+RegExp.$2 + ' '+o+RegExp.$2+"_"+RegExp.$4 : (/opera(\s|\/)(\d+)\.(\d+)/.test(ua)?' '+o+RegExp.$2+" "+o+RegExp.$2+"_"+RegExp.$3:'')) diff --git a/tests/tester.html b/tests/tester.html index c13b3bf..37168da 100644 --- a/tests/tester.html +++ b/tests/tester.html @@ -113,6 +113,9 @@ ["Mozilla/4.0 (compatible; MSIE 5.0; Windows 95) Opera 6.01 [en]" , "opera opera6 win"], // Opera 6.01 on Windows 95. ["Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 5.0 [en]" , "opera opera5 mac"], // Opera 5.0 on the Mac (OS8.6) // Internet Explorer + ["Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" , "ie ie11 win"], + ["Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" , "ie ie10 win"], + ["Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" , "ie ie9 win"], ["mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0; mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1) ; .net clr 1.1.4322; .net clr 2.0.50727; .net clr 3.0.4506.2152; .net clr 3.5.30729; officeliveconnector.1.4; officelivepatch.1.3)", "ie ie8 win"], ["Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.2; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)" , "ie ie8 win"], ["Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; Media Center PC 6.0; InfoPath.2; MS-RTC LM 8)" , "ie ie8 win"], From 527e2f83aabfc50656d5226dac235a2e2d365160 Mon Sep 17 00:00:00 2001 From: Eric Villard Date: Thu, 20 Feb 2014 10:10:17 +0100 Subject: [PATCH 2/3] add new user agent strings for ie11 support Signed-off-by:Eric Villard --- tests/tester.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/tester.html b/tests/tester.html index 37168da..974453f 100644 --- a/tests/tester.html +++ b/tests/tester.html @@ -113,7 +113,10 @@ ["Mozilla/4.0 (compatible; MSIE 5.0; Windows 95) Opera 6.01 [en]" , "opera opera6 win"], // Opera 6.01 on Windows 95. ["Mozilla/4.0 (compatible; MSIE 5.0; Mac_PowerPC) Opera 5.0 [en]" , "opera opera5 mac"], // Opera 5.0 on the Mac (OS8.6) // Internet Explorer - ["Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" , "ie ie11 win"], + ["Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" , "ie ie11 win"], + ["Mozilla/5.0 (IE 11.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko" , "ie ie11 win"], + ["Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko" , "ie ie11 win"], + ["mozilla/5.0 (windows nt 6.1; wow64; trident/7.0; slcc2; .net clr 2.0.50727; .net clr 3.5.30729; .net clr 3.0.30729; media center pc 6.0; infopath.3; .net4.0c; .net4.0e; rv:11.0) like gecko" , "ie ie11 win"], ["Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)" , "ie ie10 win"], ["Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" , "ie ie9 win"], ["mozilla/4.0 (compatible; msie 8.0; windows nt 5.1; trident/4.0; mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1) ; .net clr 1.1.4322; .net clr 2.0.50727; .net clr 3.0.4506.2152; .net clr 3.5.30729; officeliveconnector.1.4; officelivepatch.1.3)", "ie ie8 win"], From 86f71ac69b5b2387b01a123cc66e676a39be03c7 Mon Sep 17 00:00:00 2001 From: Eric Villard Date: Thu, 20 Feb 2014 10:28:16 +0100 Subject: [PATCH 3/3] add example file Signed-off-by:Eric Villard --- tests/example.html | 71 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/example.html diff --git a/tests/example.html b/tests/example.html new file mode 100644 index 0000000..911c5e1 --- /dev/null +++ b/tests/example.html @@ -0,0 +1,71 @@ + + + + CSS Browser Selector - Example + + + + + + + +

CSS Browser Selector - Example

+
+

The JavaScript support is disabled on your browser. Please, enable JavaScript and refresh this page.

+
+
+
+ +

The color of this box will change on different os/browsers:

+
    +
  • Internet Explorer - yellow
  • +
  • Internet Explorer 7 - orange
  • +
  • Gecko Engine on Windows (Firefox, Mozilla, Camino) - red
  • +
  • Gecko Engine on Linux (Firefox, Mozilla, Camino) - pink
  • +
  • Gecko Engine on Other OS (Firefox, Mozilla, Camino) - gray
  • +
  • Opera - green
  • +
  • Konqueror - blue
  • +
  • Safari - black
  • +
  • Chrome - cyan
  • +
+

Current browser UserAgent string:

+
+ +
+ +