/** Copyright 2013 Colm Delaney * Released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * To use this file, remove .txt extension, and place it within the appropriate project directory */ // Detect browser and add appropriate classes to calling element, typically 'html' // Run on document.ready only; omit true if Modernizr is running // Usage: $('html').add_browser_classes(true); // Test function: alert('html classes: ' + jQuery('html').attr('class')); // Add true arg if Modernizr/HTML5 Boilerplate isn't in use: function will then detect all IE lte 9 (function(n){n.fn.add_browser_classes=function(t){if(n(this).addClass("not-webkit not-firefox not-opera not-ie"),/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))n(this).removeClass("not-webkit").addClass("webkit chrome");else if(/Safari/.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor))n(this).removeClass("not-webkit").addClass("webkit safari");else if(/Firefox/.test(navigator.userAgent))n(this).removeClass("not-firefox").addClass("firefox");else if(window.opera&&window.opera.buildNumber)n(this).removeClass("not-opera").addClass("opera");else if(Function("/*@cc_on return /^10/.test(@_jscript_version) @*/")())n(this).removeClass("not-ie").addClass("ie ie10");else if(t==!0){var i=function(){for(var r,n=3,t=document.createElement("div"),i=t.getElementsByTagName("i");t.innerHTML="",i[0];);return n>4?n:r}();i>=4&&i<=9&&(n(this).removeClass("not-ie"),i<=6?n(this).addClass("ie ie6 lt-ie10 lt-ie9 lt-ie8 lt-ie7"):i===7?n(this).addClass("ie ie7 lt-ie10 lt-ie9 lt-ie8"):i===8?n(this).addClass("ie ie8 lt-ie10 lt-ie9"):i===9&&n(this).addClass("ie ie9 lt-ie10"))}return this}})(jQuery);