From e22190c1c051678572798d6b15e37f512a1b16ba Mon Sep 17 00:00:00 2001 From: Victoria French Date: Fri, 28 Feb 2014 13:33:32 -0600 Subject: [PATCH] support for Opera Next --- CHANGELOG.md | 6 +++ CONTRIBUTING.md | 2 +- README.md | 40 ++++++++-------- nuget/Defunctr.1.1.1.nupkg | Bin 0 -> 6061 bytes nuget/Defunctr.nuspec | 10 ++-- src/defunctr-1.1.1.js | 93 +++++++++++++++++++++++++++++++++++++ src/defunctr-1.1.1.min.js | 2 + src/defunctr.js | 93 +++++++++++++++++++++++++++++++++++++ test/css/main.css | 3 +- test/test.html | 4 +- 10 files changed, 223 insertions(+), 30 deletions(-) create mode 100755 nuget/Defunctr.1.1.1.nupkg create mode 100755 src/defunctr-1.1.1.js create mode 100755 src/defunctr-1.1.1.min.js create mode 100755 src/defunctr.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 80f4eb5..9f4d971 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ### HEAD +### 1.1.1 (February 28, 2014) + +* Added Support for Opera Next +* Updated Readme.md +* Updated Changelog.md + ### 1.1.0 (February 8, 2013) * Added simple Test Page diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c4d5893..17841c2 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,4 +1,4 @@ -# Contributing to HTML5 Boilerplate +# Contributing to Defunctr ♥ [Defunctr](http://github.com/victoriafrench/defunctr) and want to get involved? Thanks! There are plenty of ways you can help! diff --git a/README.md b/README.md index e751cbb..20c2814 100644 --- a/README.md +++ b/README.md @@ -14,34 +14,32 @@ Defunctr has the ability to exclude testing and tagging by appending any of the * `defunctr-version-off`: Defunctr will not add browser version classes to the `` element * `defunctr-lt-off`: Defunctr will not add less than version classes to the `` elememnt * `defunctr-gt-off`: Defunctr will not add greater than version classes to the `` element - + ### Classes created by Defunctr * `.ie` or `.no-ie`: Defines if the browser is Internet Explorer. This feature is always on. -* `.chrome` or `.no-chrome`: Defines if the browser is Chrome. This feature is turned off by adding `defunctr-ie-only`. -* `.safari` or `.no-safari`: Defines if the browser is Safari. This feature is turned off by adding `defunctr-ie-only`. -* `.webkit` or `.no-webkit`: Defines if the browser is Webkit including Chrome and Safari. This feature is turned off by adding `defunctr-ie-only`. -* `.firefox` or `.no-firefox`: Defines if the browser is Firefox. This feature is turned off by adding `defunctr-ie-only`. -* `.opera` or `.no-opera`: Defines if the browser is Opera. This feature is turned off by adding `defunctr-ie-only`. - - -* `.ie-version-7` and `.no-ie-version-7`: Defines if the browser is IE 7. This feature is turned off by adding `defunctr-version-off`. -* `.ie-version-8` and `.no-ie-version-8`: Defines if the browser is IE 8. This feature is turned off by adding `defunctr-version-off`. -* `.ie-version-9` and `.no-ie-version-9`: Defines if the browser is IE 9. This feature is turned off by adding `defunctr-version-off`. - -* `.ie-gt-6` and `.no-ie-gt-6`: Defines if the browser is IE 7+. This feature is turned off by adding `defunctr-gt-off`. -* `.ie-gt-7` and `.no-ie-gt-7`: Defines if the browser is IE 8+. This feature is turned off by adding `defunctr-gt-off`. -* `.ie-gt-8` and `.no-ie-gt-8`: Defines if the browser is IE 9+. This feature is turned off by adding `defunctr-gt-off`. -* `.ie-gt-9` and `.no-ie-gt-9`: Defines if the browser is IE 10+. This feature is turned off by adding `defunctr-gt-off`. - -* `.ie-lt-7` and `.no-ie-lt-7`: Defines if the browser is less than IE 7. This feature is turned off by adding `defunctr-lt-off`. -* `.ie-lt-8` and `.no-ie-lt-8`: Defines if the browser is less than IE 8. This feature is turned off by adding `defunctr-lt-off`. -* `.ie-lt-9` and `.no-ie-lt-9`: Defines if the browser is less than IE 9. This feature is turned off by adding `defunctr-lt-off`. -* `.ie-lt-10` and `.no-ie-lt-10`: Defines if the browser is less than IE 10. This feature is turned off by adding `defunctr-lt-off`. +* `.chrome` or `.no-chrome`: Defines if the browser is Chrome. +* `.safari` or `.no-safari`: Defines if the browser is Safari. +* `.webkit` or `.no-webkit`: Defines if the browser is Webkit including Chrome, Safari, and Opera Next. +* `.firefox` or `.no-firefox`: Defines if the browser is Firefox. +* `.opera` or `.no-opera`: Defines if the browser is Opera (non-webkit). +* `.opera-next` or `.no-opera-next`: Defines if the browser is Opera Next (webkit). +* `.ie-version-7` and `.no-ie-version-7`: Defines if the browser is IE 7. +* `.ie-version-8` and `.no-ie-version-8`: Defines if the browser is IE 8. +* `.ie-version-9` and `.no-ie-version-9`: Defines if the browser is IE 9. +* `.ie-gt-6` and `.no-ie-gt-6`: Defines if the browser is IE 7+. +* `.ie-gt-7` and `.no-ie-gt-7`: Defines if the browser is IE 8+. +* `.ie-gt-8` and `.no-ie-gt-8`: Defines if the browser is IE 9+. +* `.ie-gt-9` and `.no-ie-gt-9`: Defines if the browser is IE 10+. +* `.ie-lt-7` and `.no-ie-lt-7`: Defines if the browser is less than IE 7. +* `.ie-lt-8` and `.no-ie-lt-8`: Defines if the browser is less than IE 8. +* `.ie-lt-9` and `.no-ie-lt-9`: Defines if the browser is less than IE 9. +* `.ie-lt-10` and `.no-ie-lt-10`: Defines if the browser is less than IE 10. ### Limitations on this release * Opera can only be detected from version 8.0+ +* Opera Next is detected as Opera-Next not Opera. * Firefox can only be detected from version 0.8+ * Safari can only be detected from version 3.0+ * Chrome can only be detected from version 1.0+ diff --git a/nuget/Defunctr.1.1.1.nupkg b/nuget/Defunctr.1.1.1.nupkg new file mode 100755 index 0000000000000000000000000000000000000000..f8d98d0ed93148eed734416e3912fb8d18bcbb90 GIT binary patch literal 6061 zcmb_g2{=@H*dJv{DM}*C?Ie;IV~iMOUy?OzbWz5c!wj>T1tS&7T1q0iWf!_xT5P2( zk&8;H8NleQCuVt@pQjAN)!X%Gc| z;z^~GaZLDA4Go;SIu?sn$L+v*dScO_Cj?@4c&gACWIRY)$PWu@pw%?h&{!>14|S{- zo|_-)o1*F3z#X$5u?(?-+c8fCUSyqFhCrO>Lm-6Vj`?oge$+Jy4pxk(sv>tVHAkP1 zY8A)5L(A0p3cSR*XU7|bl*<;9LzFi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LRt5|g>S@d^HCz~FV2^{9rUkoEMKQh z$3#kIB}~V04pDg8xEOuLp$9ok7sE}3L%aPa)Ew8||C5qiz{W@>CnlJZgEtnAMPkAU z!;twiBgo+pWr2m@Ilgpcxh(>6>x=TE;J+jOkPCB_!#;lH`;_2(xvbP*xcEZV{jC!! z$b?{$59aLtLfiXC;r&qa3x)Q#et(eMcO2hhdMIu=;9lTahD3brhHnYl?|IlIbnR!w zzvJnaDyqTk-IqbQz;=GG{4Eu-R9Oh7{T7P<&xw)m&3_96mYS!+ng2`kpFzR*>-Oz` s_EHz}!ifL=AN+gw-)`ci?$3%M{%T9xSn%<4#Q5Rw6uk3O#W+|01FP4mF8}}l literal 0 HcmV?d00001 diff --git a/nuget/Defunctr.nuspec b/nuget/Defunctr.nuspec index 27f7e71..1a05bba 100755 --- a/nuget/Defunctr.nuspec +++ b/nuget/Defunctr.nuspec @@ -2,7 +2,7 @@ Defunctr - 1.1.0 + 1.1.1 Defunctr Victoria French Victoria French @@ -10,15 +10,15 @@ false Defunctr is a module for Modernizr that will detect the current browser using feature detection. It will then append browser informational classes to the head element of the page, giving the designer the ability to override CSS styles without using older browser hacks. Changing the browsers compatability mode will cause the correct classes to be applied and changing a user-agent will have not effect on the class generation. Defunctr is a module for Modernizr that will append browser versioning information into the head element of your web pages using feature detection. - Better detection of Internet Explorer and experimental support for KHtml - 2013 Victoria French + Now includes support for Opera Next. + 2013, 2104 Victoria French Modernizr, Browser Detection, HTML5, Shiv - - + + \ No newline at end of file diff --git a/src/defunctr-1.1.1.js b/src/defunctr-1.1.1.js new file mode 100755 index 0000000..f2e6625 --- /dev/null +++ b/src/defunctr-1.1.1.js @@ -0,0 +1,93 @@ +/* Defunctr 1.1.1 | MIT & BSD | Copyright 2013, 2014 Victoria French | http://github.com/victoriafrench/defunctr */ +window.Defunctr = (function (window, document, undefined) { + var version = '1.1.0', + r = {}; + docElement = document.documentElement, + docHead = document.head || document.getElementsByTagName('head')[0], + defunctr = 'defunctr'; + prefix = '', + gtoff = docElement.className.indexOf('defunctr-gt-off') > 0, + ltoff = docElement.className.indexOf('defunctr-lt-off') > 0, + voff = docElement.className.indexOf('defunctr-version-off') > 0, + onlyie = docElement.className.indexOf('defunctr-ie-only') > 0, + tests = []; + + r.detective = (function (window, document, undefined) { + var r = {}; + r.isWebkit = (function (document, undefined) { return 'WebkitTransform' in document.documentElement.style; /* v 1+ */})(document); + r.isOpera = (function (window, undefined) { return !!(window.opera && window.opera.version); /* 8.0+ */ })(window); + r.isIE = (function (window, undefined) { return 'ActiveXObject' in window; /*return (document.all != undefined) && !self.isOpera;*/ })(window); + r.isFirefox = (function (document, undefined) { return 'MozBoxSizing' in document.documentElement.style; /* 0.8+ */ })(document); + r.isSafari = (function (window, undefined) { return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; /*v 3+ */ })(window); + r.isKhtml = (function (document, undefined) { return 'KhtmlMarquee' in document.documentElement.style })(document); + r.isOperaNext = (function (self, navigator, undefined) { return self.isWebkit && /(Opera|OPR)/.test(navigator.userAgent); })(r, navigator); + r.isChrome = (function (self, undefined) { return !self.isSafari && !self.isOperaNext && self.isWebkit; })(r); + + r.ieBelowVersion6 = (function (self, document, undefined) { return self.isIE && !(document.compatMode != undefined); })(r, document); + r.ieBelowVersion7 = (function (self, window, undefined) { return self.isIE && !(window.XMLHttpRequest != undefined); })(r, window); + r.ieBelowVersion8 = (function (self, document, undefined) { return self.isIE && !(document.querySelector != undefined); })(r, document); + r.ieBelowVersion9 = (function (self, document, undefined) { return self.isIE && !(document.addEventListener != undefined); })(r, document); + r.ieBelowVersion10 = (function (self, window, undefined) { return self.isIE && !(window.atob != undefined); })(r, window); + r.ieAboveVersion5 = (function (self, window, undefined) { return self.isIE && (document.compatMode != undefined); })(r, window); + r.ieAboveVersion6 = (function (self, window, undefined) { return self.isIE && (window.XMLHttpRequest != undefined); })(r, window); + r.ieAboveVersion7 = (function (self, document, undefined) { return r.isIE && (document.querySelector != undefined); })(r, document); + r.ieAboveVersion8 = (function (self, window, undefined) { return self.isIE && (document.addEventListener != undefined); })(r, window); + r.ieAboveVersion9 = (function (self, window, undefined) { return self.isIE && (window.atob != undefined); })(r, window); + r.ieIsVersion6 = (function (self, undefined) { return self.ieAboveVersion5 && self.ieBelowVersion7; })(r); + r.ieIsVersion7 = (function (self, undefined) { return self.ieAboveVersion6 && self.ieBelowVersion8; })(r); + r.ieIsVersion8 = (function (self, undefined) { return self.ieAboveVersion7 && self.ieBelowVersion9; })(r); + r.ieIsVersion9 = (function (self, undefined) { return self.ieAboveVersion8 && self.ieBelowVersion10; })(r); + + + r.chromeIsAbove15 = (function (window, undefined) { return !!(window.chrome && window.chrome.webstore && window.chrome.webstore.install); })(window); + + + r.standardsCompliant = (function (self, undefined) { return r.ieAboveVersion9; })(r); + return r; + })(window, document); + + tests[prefix + 'ie'] = function () { return r.detective.isIE; }; + if (!onlyie) { + tests[prefix + 'chrome'] = function () { return r.detective.isChrome; }; + tests[prefix + 'safari'] = function () { return r.detective.isSafari; }; + tests[prefix + 'opera'] = function () { return r.detective.isOpera; }; + tests[prefix + 'opera-next'] = function() { return r.detective.isOperaNext; }; + tests[prefix + 'firefox'] = function () { return r.detective.isFirefox; }; + tests[prefix + 'khtml'] = function () { return r.detective.isKhtml; }; + tests[prefix + 'webkit'] = function () { return r.detective.isWebkit; }; + } + + if (!ltoff) { + tests[prefix + 'ie-lt-7'] = function () { return r.detective.ieBelowVersion7; }; + tests[prefix + 'ie-lt-8'] = function () { return r.detective.ieBelowVersion8; }; + tests[prefix + 'ie-lt-9'] = function () { return r.detective.ieBelowVersion9; }; + tests[prefix + 'ie-lt-10'] = function () { return r.detective.ieBelowVersion10; }; + } + + if (!gtoff) { + tests[prefix + 'ie-gt-6'] = function () { return r.detective.ieAboveVersion6; }; + tests[prefix + 'ie-gt-7'] = function () { return r.detective.ieAboveVersion7; }; + tests[prefix + 'ie-gt-8'] = function () { return r.detective.ieAboveVersion8; }; + tests[prefix + 'ie-gt-9'] = function () { return r.detective.ieAboveVersion9; }; + } + + if (!voff) { + tests[prefix + 'ie-version-7'] = function () { return r.detective.ieIsVersion7; }; + tests[prefix + 'ie-version-8'] = function () { return r.detective.ieIsVersion8; }; + tests[prefix + 'ie-version-9'] = function () { return r.detective.ieIsVersion9; }; + } + + r.version = version; + + for (key in tests) { + window.Modernizr.addTest(key, tests[key]); + } + + docElement.className = docElement.className.replace(/\bdefunctr-gt-off\b/, ''); + docElement.className = docElement.className.replace(/\bdefunctr-lt-off\b/, ''); + docElement.className = docElement.className.replace(/\bdefunctr-version-off\b/, ''); + docElement.className = docElement.className.replace(/\bdefunctr-ie-only\b/, ''); + + return r; +})(this, this.document); + diff --git a/src/defunctr-1.1.1.min.js b/src/defunctr-1.1.1.min.js new file mode 100755 index 0000000..62716ec --- /dev/null +++ b/src/defunctr-1.1.1.min.js @@ -0,0 +1,2 @@ +/* Defunctr 1.1.1 | MIT & BSD | Copyright 2013, 2014 Victoria French | http://github.com/victoriafrench/defunctr */ +window.Defunctr=(function(d,a,e){var b="1.1.0",c={};docElement=a.documentElement,docHead=a.head||a.getElementsByTagName("head")[0],defunctr="defunctr";prefix="",gtoff=docElement.className.indexOf("defunctr-gt-off")>0,ltoff=docElement.className.indexOf("defunctr-lt-off")>0,voff=docElement.className.indexOf("defunctr-version-off")>0,onlyie=docElement.className.indexOf("defunctr-ie-only")>0,tests=[];c.detective=(function(h,f,i){var g={};g.isWebkit=(function(j,k){return"WebkitTransform" in j.documentElement.style;})(f);g.isOpera=(function(j,k){return !!(j.opera&&j.opera.version);})(h);g.isIE=(function(j,k){return"ActiveXObject" in j;})(h);g.isFirefox=(function(j,k){return"MozBoxSizing" in j.documentElement.style;})(f);g.isSafari=(function(j,k){return Object.prototype.toString.call(j.HTMLElement).indexOf("Constructor")>0;})(h);g.isKhtml=(function(j,k){return"KhtmlMarquee" in j.documentElement.style;})(f);g.isOperaNext=(function(k,j,l){return k.isWebkit&&/(Opera|OPR)/.test(j.userAgent);})(g,navigator);g.isChrome=(function(j,k){return !j.isSafari&&!j.isOperaNext&&j.isWebkit;})(g);g.ieBelowVersion6=(function(k,j,l){return k.isIE&&!(j.compatMode!=l);})(g,f);g.ieBelowVersion7=(function(j,k,l){return j.isIE&&!(k.XMLHttpRequest!=l);})(g,h);g.ieBelowVersion8=(function(k,j,l){return k.isIE&&!(j.querySelector!=l);})(g,f);g.ieBelowVersion9=(function(k,j,l){return k.isIE&&!(j.addEventListener!=l);})(g,f);g.ieBelowVersion10=(function(j,k,l){return j.isIE&&!(k.atob!=l);})(g,h);g.ieAboveVersion5=(function(j,k,l){return j.isIE&&(f.compatMode!=l);})(g,h);g.ieAboveVersion6=(function(j,k,l){return j.isIE&&(k.XMLHttpRequest!=l);})(g,h);g.ieAboveVersion7=(function(k,j,l){return g.isIE&&(j.querySelector!=l);})(g,f);g.ieAboveVersion8=(function(j,k,l){return j.isIE&&(f.addEventListener!=l);})(g,h);g.ieAboveVersion9=(function(j,k,l){return j.isIE&&(k.atob!=l);})(g,h);g.ieIsVersion6=(function(j,k){return j.ieAboveVersion5&&j.ieBelowVersion7;})(g);g.ieIsVersion7=(function(j,k){return j.ieAboveVersion6&&j.ieBelowVersion8;})(g);g.ieIsVersion8=(function(j,k){return j.ieAboveVersion7&&j.ieBelowVersion9;})(g);g.ieIsVersion9=(function(j,k){return j.ieAboveVersion8&&j.ieBelowVersion10;})(g);g.chromeIsAbove15=(function(j,k){return !!(j.chrome&&j.chrome.webstore&&j.chrome.webstore.install);})(h);g.standardsCompliant=(function(j,k){return g.ieAboveVersion9;})(g);return g;})(d,a);tests[prefix+"ie"]=function(){return c.detective.isIE;};if(!onlyie){tests[prefix+"chrome"]=function(){return c.detective.isChrome;};tests[prefix+"safari"]=function(){return c.detective.isSafari;};tests[prefix+"opera"]=function(){return c.detective.isOpera;};tests[prefix+"opera-next"]=function(){return c.detective.isOperaNext;};tests[prefix+"firefox"]=function(){return c.detective.isFirefox;};tests[prefix+"khtml"]=function(){return c.detective.isKhtml;};tests[prefix+"webkit"]=function(){return c.detective.isWebkit;};}if(!ltoff){tests[prefix+"ie-lt-7"]=function(){return c.detective.ieBelowVersion7;};tests[prefix+"ie-lt-8"]=function(){return c.detective.ieBelowVersion8;};tests[prefix+"ie-lt-9"]=function(){return c.detective.ieBelowVersion9;};tests[prefix+"ie-lt-10"]=function(){return c.detective.ieBelowVersion10;};}if(!gtoff){tests[prefix+"ie-gt-6"]=function(){return c.detective.ieAboveVersion6;};tests[prefix+"ie-gt-7"]=function(){return c.detective.ieAboveVersion7;};tests[prefix+"ie-gt-8"]=function(){return c.detective.ieAboveVersion8;};tests[prefix+"ie-gt-9"]=function(){return c.detective.ieAboveVersion9;};}if(!voff){tests[prefix+"ie-version-7"]=function(){return c.detective.ieIsVersion7;};tests[prefix+"ie-version-8"]=function(){return c.detective.ieIsVersion8;};tests[prefix+"ie-version-9"]=function(){return c.detective.ieIsVersion9;};}c.version=b;for(key in tests){d.Modernizr.addTest(key,tests[key]);}docElement.className=docElement.className.replace(/\bdefunctr-gt-off\b/,"");docElement.className=docElement.className.replace(/\bdefunctr-lt-off\b/,"");docElement.className=docElement.className.replace(/\bdefunctr-version-off\b/,"");docElement.className=docElement.className.replace(/\bdefunctr-ie-only\b/,"");return c;})(this,this.document); \ No newline at end of file diff --git a/src/defunctr.js b/src/defunctr.js new file mode 100755 index 0000000..d72a096 --- /dev/null +++ b/src/defunctr.js @@ -0,0 +1,93 @@ +/* Defunctr Nightly 1.1.Next | MIT & BSD | Copyright 2013 Victoria French | http://github.com/victoriafrench/defunctr */ +window.Defunctr = (function (window, document, undefined) { + var version = '1.1.0', + r = {}; + docElement = document.documentElement, + docHead = document.head || document.getElementsByTagName('head')[0], + defunctr = 'defunctr'; + prefix = '', + gtoff = docElement.className.indexOf('defunctr-gt-off') > 0, + ltoff = docElement.className.indexOf('defunctr-lt-off') > 0, + voff = docElement.className.indexOf('defunctr-version-off') > 0, + onlyie = docElement.className.indexOf('defunctr-ie-only') > 0, + tests = []; + + r.detective = (function (window, document, undefined) { + var r = {}; + r.isWebkit = (function (document, undefined) { return 'WebkitTransform' in document.documentElement.style; /* v 1+ */})(document); + r.isOpera = (function (window, undefined) { return !!(window.opera && window.opera.version); /* 8.0+ */ })(window); + r.isIE = (function (window, undefined) { return 'ActiveXObject' in window; /*return (document.all != undefined) && !self.isOpera;*/ })(window); + r.isFirefox = (function (document, undefined) { return 'MozBoxSizing' in document.documentElement.style; /* 0.8+ */ })(document); + r.isSafari = (function (window, undefined) { return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; /*v 3+ */ })(window); + r.isKhtml = (function (document, undefined) { return 'KhtmlMarquee' in document.documentElement.style })(document); + r.isOperaNext = (function (self, navigator, undefined) { return self.isWebkit && /(Opera|OPR)/.test(navigator.userAgent); })(r, navigator); + r.isChrome = (function (self, undefined) { return !self.isSafari && !self.isOperaNext && self.isWebkit; })(r); + + r.ieBelowVersion6 = (function (self, document, undefined) { return self.isIE && !(document.compatMode != undefined); })(r, document); + r.ieBelowVersion7 = (function (self, window, undefined) { return self.isIE && !(window.XMLHttpRequest != undefined); })(r, window); + r.ieBelowVersion8 = (function (self, document, undefined) { return self.isIE && !(document.querySelector != undefined); })(r, document); + r.ieBelowVersion9 = (function (self, document, undefined) { return self.isIE && !(document.addEventListener != undefined); })(r, document); + r.ieBelowVersion10 = (function (self, window, undefined) { return self.isIE && !(window.atob != undefined); })(r, window); + r.ieAboveVersion5 = (function (self, window, undefined) { return self.isIE && (document.compatMode != undefined); })(r, window); + r.ieAboveVersion6 = (function (self, window, undefined) { return self.isIE && (window.XMLHttpRequest != undefined); })(r, window); + r.ieAboveVersion7 = (function (self, document, undefined) { return r.isIE && (document.querySelector != undefined); })(r, document); + r.ieAboveVersion8 = (function (self, window, undefined) { return self.isIE && (document.addEventListener != undefined); })(r, window); + r.ieAboveVersion9 = (function (self, window, undefined) { return self.isIE && (window.atob != undefined); })(r, window); + r.ieIsVersion6 = (function (self, undefined) { return self.ieAboveVersion5 && self.ieBelowVersion7; })(r); + r.ieIsVersion7 = (function (self, undefined) { return self.ieAboveVersion6 && self.ieBelowVersion8; })(r); + r.ieIsVersion8 = (function (self, undefined) { return self.ieAboveVersion7 && self.ieBelowVersion9; })(r); + r.ieIsVersion9 = (function (self, undefined) { return self.ieAboveVersion8 && self.ieBelowVersion10; })(r); + + + r.chromeIsAbove15 = (function (window, undefined) { return !!(window.chrome && window.chrome.webstore && window.chrome.webstore.install); })(window); + + + r.standardsCompliant = (function (self, undefined) { return r.ieAboveVersion9; })(r); + return r; + })(window, document); + + tests[prefix + 'ie'] = function () { return r.detective.isIE; }; + if (!onlyie) { + tests[prefix + 'chrome'] = function () { return r.detective.isChrome; }; + tests[prefix + 'safari'] = function () { return r.detective.isSafari; }; + tests[prefix + 'opera'] = function () { return r.detective.isOpera; }; + tests[prefix + 'opera-next'] = function() { return r.detective.isOperaNext; }; + tests[prefix + 'firefox'] = function () { return r.detective.isFirefox; }; + tests[prefix + 'khtml'] = function () { return r.detective.isKhtml; }; + tests[prefix + 'webkit'] = function () { return r.detective.isWebkit; }; + } + + if (!ltoff) { + tests[prefix + 'ie-lt-7'] = function () { return r.detective.ieBelowVersion7; }; + tests[prefix + 'ie-lt-8'] = function () { return r.detective.ieBelowVersion8; }; + tests[prefix + 'ie-lt-9'] = function () { return r.detective.ieBelowVersion9; }; + tests[prefix + 'ie-lt-10'] = function () { return r.detective.ieBelowVersion10; }; + } + + if (!gtoff) { + tests[prefix + 'ie-gt-6'] = function () { return r.detective.ieAboveVersion6; }; + tests[prefix + 'ie-gt-7'] = function () { return r.detective.ieAboveVersion7; }; + tests[prefix + 'ie-gt-8'] = function () { return r.detective.ieAboveVersion8; }; + tests[prefix + 'ie-gt-9'] = function () { return r.detective.ieAboveVersion9; }; + } + + if (!voff) { + tests[prefix + 'ie-version-7'] = function () { return r.detective.ieIsVersion7; }; + tests[prefix + 'ie-version-8'] = function () { return r.detective.ieIsVersion8; }; + tests[prefix + 'ie-version-9'] = function () { return r.detective.ieIsVersion9; }; + } + + r.version = version; + + for (key in tests) { + window.Modernizr.addTest(key, tests[key]); + } + + docElement.className = docElement.className.replace(/\bdefunctr-gt-off\b/, ''); + docElement.className = docElement.className.replace(/\bdefunctr-lt-off\b/, ''); + docElement.className = docElement.className.replace(/\bdefunctr-version-off\b/, ''); + docElement.className = docElement.className.replace(/\bdefunctr-ie-only\b/, ''); + + return r; +})(this, this.document); + diff --git a/test/css/main.css b/test/css/main.css index 25673d4..f2d732b 100755 --- a/test/css/main.css +++ b/test/css/main.css @@ -99,7 +99,7 @@ textarea { .no-js .js-on { display: none; } .js .js-off { display: none; } .js .js-on { display: block; } - + .js-on span { display: none; } .ie .ielabel { display: inline; } .ie-lt-6 .ieoldlabel { display: inline; } @@ -114,6 +114,7 @@ textarea { .chrome .chromelabel { display: inline; } .webkit .wlabel { display: inline; } .firefox .fflabel { display: inline; } + .opera-next .operalabel { display: inline; } diff --git a/test/test.html b/test/test.html index 98691d8..843c756 100755 --- a/test/test.html +++ b/test/test.html @@ -15,10 +15,10 @@ -

Hello Unsupported (pre 6) Internet Explorer 6 7 8 9 10+ Firefox Opera KHtml Webkit (Safari) (Chrome)!

+

Hello Unsupported (pre 6) Internet Explorer 6 7 8 9 10+ Firefox Opera KHtml Webkit (Safari) (Chrome) (Opera)!

Please enable Javascript

- +