Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / docs / assets / js / ie-emulation-modes-warning.js
1 // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
2 // IT'S JUST JUNK FOR OUR DOCS!
3 // ++++++++++++++++++++++++++++++++++++++++++
4 /*!
5  * Copyright 2014 Twitter, Inc.
6  *
7  * Licensed under the Creative Commons Attribution 3.0 Unported License. For
8  * details, see http://creativecommons.org/licenses/by/3.0/.
9  */
10 // Intended to prevent false-positive bug reports about Bootstrap not working properly in old versions of IE due to folks testing using IE's unreliable emulation modes.
11 (function () {
12   'use strict';
13
14   function emulatedIEMajorVersion() {
15     var groups = /MSIE ([0-9.]+)/.exec(window.navigator.userAgent)
16     if (groups === null) {
17       return null
18     }
19     var ieVersionNum = parseInt(groups[1], 10)
20     var ieMajorVersion = Math.floor(ieVersionNum)
21     return ieMajorVersion
22   }
23
24   function actualNonEmulatedIEMajorVersion() {
25     // Detects the actual version of IE in use, even if it's in an older-IE emulation mode.
26     // IE JavaScript conditional compilation docs: http://msdn.microsoft.com/en-us/library/ie/121hztk3(v=vs.94).aspx
27     // @cc_on docs: http://msdn.microsoft.com/en-us/library/ie/8ka90k2e(v=vs.94).aspx
28     var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')() // jshint ignore:line
29     if (jscriptVersion === undefined) {
30       return 11 // IE11+ not in emulation mode
31     }
32     if (jscriptVersion < 9) {
33       return 8 // IE8 (or lower; haven't tested on IE<8)
34     }
35     return jscriptVersion // IE9 or IE10 in any mode, or IE11 in non-IE11 mode
36   }
37
38   var ua = window.navigator.userAgent
39   if (ua.indexOf('Opera') > -1 || ua.indexOf('Presto') > -1) {
40     return // Opera, which might pretend to be IE
41   }
42   var emulated = emulatedIEMajorVersion()
43   if (emulated === null) {
44     return // Not IE
45   }
46   var nonEmulated = actualNonEmulatedIEMajorVersion()
47
48   if (emulated !== nonEmulated) {
49     window.alert('WARNING: You appear to be using IE' + nonEmulated + ' in IE' + emulated + ' emulation mode.\nIE emulation modes can behave significantly differently from ACTUAL older versions of IE.\nPLEASE DON\'T FILE BOOTSTRAP BUGS based on testing in IE emulation modes!')
50   }
51 })();