1 // ========================================================================== 2 // Project: SproutCore - JavaScript Application Framework 3 // Copyright: ©2006-2011 Strobe Inc. and contributors. 4 // Portions ©2008-2011 Apple Inc. All rights reserved. 5 // License: Licensed under MIT license (see license.js) 6 // ========================================================================== 7 8 // sc_require("system/browser"); 9 10 SC.setupBodyClassNames = function() { 11 var el = document.body, 12 browser, platform, shadows, borderRad, classNames, style, ieVersion; 13 if (!el) return ; 14 15 browser = SC.browser.current ; 16 platform = SC.browser.isWindows ? 'windows' : SC.browser.isMac ? 'mac' : 'other-platform' ; 17 style = document.documentElement.style; 18 shadows = (style.MozBoxShadow !== undefined) || 19 (style.webkitBoxShadow !== undefined) || 20 (style.oBoxShadow !== undefined) || 21 (style.boxShadow !== undefined); 22 23 borderRad = (style.MozBorderRadius !== undefined) || 24 (style.webkitBorderRadius !== undefined) || 25 (style.oBorderRadius !== undefined) || 26 (style.borderRadius !== undefined); 27 28 classNames = el.className ? el.className.split(' ') : [] ; 29 if(shadows) classNames.push('box-shadow'); 30 if(borderRad) classNames.push('border-rad'); 31 classNames.push(browser, platform) ; 32 33 // This isn't a perfectly correct way to compare versions, but should be okay 34 // in practical usage. 35 ieVersion = parseInt(SC.browser.version, 10); 36 if (SC.browser.isIE) { 37 classNames.push('msie'); // Used by several framework CSS declarations, including the one to address issue #971. 38 if (ieVersion === 7) { 39 classNames.push('ie7'); 40 } 41 else if (ieVersion === 8) { 42 classNames.push('ie8'); 43 } 44 else if (ieVersion === 9) { 45 classNames.push('ie9'); 46 } 47 else if (ieVersion === 10) { 48 classNames.push('ie10'); 49 } 50 } 51 52 if(browser==="safari" || browser==="chrome") classNames.push('webkit'); 53 if (SC.browser.isMobileSafari) classNames.push('mobile-safari') ; 54 if ('createTouch' in document) classNames.push('touch'); 55 el.className = classNames.join(' ') ; 56 } ; 57 58 59 60