From d4728b8c6dfb06b9e65d3ec31f8c7d3fe34b7c75 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Thu, 24 Apr 2014 15:27:42 -0700 Subject: [PATCH 1/4] add script to warn folks trying to test old IE using IE's unreliable emulation modes --- docs/assets/js/ie-emulation-modes-warning.js | 51 ++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docs/assets/js/ie-emulation-modes-warning.js diff --git a/docs/assets/js/ie-emulation-modes-warning.js b/docs/assets/js/ie-emulation-modes-warning.js new file mode 100644 index 0000000000..82a4cac348 --- /dev/null +++ b/docs/assets/js/ie-emulation-modes-warning.js @@ -0,0 +1,51 @@ +// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT +// IT'S JUST JUNK FOR OUR DOCS! +// ++++++++++++++++++++++++++++++++++++++++++ +/*! + * Copyright 2014 Twitter, Inc. + * + * Licensed under the Creative Commons Attribution 3.0 Unported License. For + * details, see http://creativecommons.org/licenses/by/3.0/. + */ +// 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. +(function () { + 'use strict'; + + function emulatedIEMajorVersion() { + var groups = /MSIE ([0-9.]+)/.exec(window.navigator.userAgent); + if (groups === null) { + return null; + } + var ieVersionNum = parseInt(groups[1], 10); + var ieMajorVersion = Math.floor(ieVersionNum); + return ieMajorVersion; + } + + function actualNonEmulatedIEMajorVersion() { + // Detects the actual version of IE in use, even if it's in an older-IE emulation mode. + // IE JavaScript conditional compilation docs: http://msdn.microsoft.com/en-us/library/ie/121hztk3(v=vs.94).aspx + // @cc_on docs: http://msdn.microsoft.com/en-us/library/ie/8ka90k2e(v=vs.94).aspx + var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')(); // jshint ignore:line + if (jscriptVersion === undefined) { + return 11; // IE11+ not in emulation mode + } + if (jscriptVersion < 9) { + return 8; // IE8 (or lower; haven't tested on IE<8) + } + return jscriptVersion; // IE9 or IE10 in any mode, or IE11 in non-IE11 mode + } + + var ua = window.navigator.userAgent; + if (ua.indexOf('Opera') > -1 || ua.indexOf('Presto') > -1) { + return; // Opera, which might pretend to be IE + } + var emulated = emulatedIEMajorVersion(); + if (emulated === null) { + return; // Not IE + } + var nonEmulated = actualNonEmulatedIEMajorVersion(); + + if (emulated !== nonEmulated) { + 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!'); + } +})(); From 937ef4824e544343252e00a5aa5462e60e5ddd19 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Thu, 24 Apr 2014 16:00:13 -0700 Subject: [PATCH 2/4] remove semicolons :'-( --- docs/assets/js/ie-emulation-modes-warning.js | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/assets/js/ie-emulation-modes-warning.js b/docs/assets/js/ie-emulation-modes-warning.js index 82a4cac348..896ed6225b 100644 --- a/docs/assets/js/ie-emulation-modes-warning.js +++ b/docs/assets/js/ie-emulation-modes-warning.js @@ -12,40 +12,40 @@ 'use strict'; function emulatedIEMajorVersion() { - var groups = /MSIE ([0-9.]+)/.exec(window.navigator.userAgent); + var groups = /MSIE ([0-9.]+)/.exec(window.navigator.userAgent) if (groups === null) { - return null; + return null } - var ieVersionNum = parseInt(groups[1], 10); - var ieMajorVersion = Math.floor(ieVersionNum); - return ieMajorVersion; + var ieVersionNum = parseInt(groups[1], 10) + var ieMajorVersion = Math.floor(ieVersionNum) + return ieMajorVersion } function actualNonEmulatedIEMajorVersion() { // Detects the actual version of IE in use, even if it's in an older-IE emulation mode. // IE JavaScript conditional compilation docs: http://msdn.microsoft.com/en-us/library/ie/121hztk3(v=vs.94).aspx // @cc_on docs: http://msdn.microsoft.com/en-us/library/ie/8ka90k2e(v=vs.94).aspx - var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')(); // jshint ignore:line + var jscriptVersion = new Function('/*@cc_on return @_jscript_version; @*/')() // jshint ignore:line if (jscriptVersion === undefined) { - return 11; // IE11+ not in emulation mode + return 11 // IE11+ not in emulation mode } if (jscriptVersion < 9) { - return 8; // IE8 (or lower; haven't tested on IE<8) + return 8 // IE8 (or lower; haven't tested on IE<8) } - return jscriptVersion; // IE9 or IE10 in any mode, or IE11 in non-IE11 mode + return jscriptVersion // IE9 or IE10 in any mode, or IE11 in non-IE11 mode } - var ua = window.navigator.userAgent; + var ua = window.navigator.userAgent if (ua.indexOf('Opera') > -1 || ua.indexOf('Presto') > -1) { - return; // Opera, which might pretend to be IE + return // Opera, which might pretend to be IE } - var emulated = emulatedIEMajorVersion(); + var emulated = emulatedIEMajorVersion() if (emulated === null) { - return; // Not IE + return // Not IE } - var nonEmulated = actualNonEmulatedIEMajorVersion(); + var nonEmulated = actualNonEmulatedIEMajorVersion() if (emulated !== nonEmulated) { - 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!'); + 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!') } })(); From eab6d3ead83446cfa383b3e00b289a96b8a354e8 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Thu, 24 Apr 2014 15:35:58 -0700 Subject: [PATCH 3/4] add IE warning scripts to linter config --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 925368e527..57d2c19254 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -56,7 +56,7 @@ module.exports = function (grunt) { src: 'js/tests/unit/*.js' }, assets: { - src: 'docs/assets/js/_src/*.js' + src: ['docs/assets/js/_src/*.js', 'docs/assets/js/*.js', '!docs/assets/js/*.min.js'] } }, From a84a3693b12f549e075424a63d34a83dc19d277b Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Thu, 24 Apr 2014 15:35:05 -0700 Subject: [PATCH 4/4] add ie-emulation-modes-warning.js to docs & examples --- docs/_includes/header.html | 3 ++- docs/examples/blog/index.html | 3 ++- docs/examples/carousel/index.html | 3 ++- docs/examples/cover/index.html | 3 ++- docs/examples/dashboard/index.html | 3 ++- docs/examples/equal-height-columns/index.html | 3 ++- docs/examples/grid/index.html | 3 ++- docs/examples/jumbotron-narrow/index.html | 3 ++- docs/examples/jumbotron/index.html | 3 ++- docs/examples/justified-nav/index.html | 3 ++- docs/examples/navbar-fixed-top/index.html | 3 ++- docs/examples/navbar-static-top/index.html | 3 ++- docs/examples/navbar/index.html | 3 ++- docs/examples/non-responsive/index.html | 3 ++- docs/examples/offcanvas/index.html | 3 ++- docs/examples/rtl/index.html | 3 ++- docs/examples/signin/index.html | 3 ++- docs/examples/starter-template/index.html | 3 ++- docs/examples/sticky-footer-navbar/index.html | 3 ++- docs/examples/sticky-footer/index.html | 3 ++- docs/examples/theme/index.html | 3 ++- docs/examples/tooltip-viewport/index.html | 3 ++- 22 files changed, 44 insertions(+), 22 deletions(-) diff --git a/docs/_includes/header.html b/docs/_includes/header.html index 4eee52a3c9..e12545eccf 100644 --- a/docs/_includes/header.html +++ b/docs/_includes/header.html @@ -20,7 +20,8 @@ - + + - + + diff --git a/docs/examples/carousel/index.html b/docs/examples/carousel/index.html index 3372c87efd..8283146030 100644 --- a/docs/examples/carousel/index.html +++ b/docs/examples/carousel/index.html @@ -13,8 +13,9 @@ - + + diff --git a/docs/examples/cover/index.html b/docs/examples/cover/index.html index f4765685dc..26e4d6f386 100644 --- a/docs/examples/cover/index.html +++ b/docs/examples/cover/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/dashboard/index.html b/docs/examples/dashboard/index.html index 0b83d30d0c..e14cf390c1 100644 --- a/docs/examples/dashboard/index.html +++ b/docs/examples/dashboard/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/equal-height-columns/index.html b/docs/examples/equal-height-columns/index.html index b31e7bd7d5..3c74c7a5cf 100644 --- a/docs/examples/equal-height-columns/index.html +++ b/docs/examples/equal-height-columns/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/grid/index.html b/docs/examples/grid/index.html index 7e55b5b900..3d77f358a8 100644 --- a/docs/examples/grid/index.html +++ b/docs/examples/grid/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/jumbotron-narrow/index.html b/docs/examples/jumbotron-narrow/index.html index 372bac7e39..742fb5c622 100644 --- a/docs/examples/jumbotron-narrow/index.html +++ b/docs/examples/jumbotron-narrow/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/jumbotron/index.html b/docs/examples/jumbotron/index.html index 9cc8ae5923..ebae0a246e 100644 --- a/docs/examples/jumbotron/index.html +++ b/docs/examples/jumbotron/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/justified-nav/index.html b/docs/examples/justified-nav/index.html index 0b682cee80..c7599c1c08 100644 --- a/docs/examples/justified-nav/index.html +++ b/docs/examples/justified-nav/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/navbar-fixed-top/index.html b/docs/examples/navbar-fixed-top/index.html index 2224c49caa..a0ab56d664 100644 --- a/docs/examples/navbar-fixed-top/index.html +++ b/docs/examples/navbar-fixed-top/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/navbar-static-top/index.html b/docs/examples/navbar-static-top/index.html index b040d500c8..6228abefee 100644 --- a/docs/examples/navbar-static-top/index.html +++ b/docs/examples/navbar-static-top/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/navbar/index.html b/docs/examples/navbar/index.html index 77fbab6052..81c9274e66 100644 --- a/docs/examples/navbar/index.html +++ b/docs/examples/navbar/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/non-responsive/index.html b/docs/examples/non-responsive/index.html index aa95550fe9..6148fcd572 100644 --- a/docs/examples/non-responsive/index.html +++ b/docs/examples/non-responsive/index.html @@ -18,8 +18,9 @@ - + + diff --git a/docs/examples/offcanvas/index.html b/docs/examples/offcanvas/index.html index df596fdce8..1df7bca9da 100644 --- a/docs/examples/offcanvas/index.html +++ b/docs/examples/offcanvas/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/rtl/index.html b/docs/examples/rtl/index.html index 42cea4fb6b..0708314616 100644 --- a/docs/examples/rtl/index.html +++ b/docs/examples/rtl/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/signin/index.html b/docs/examples/signin/index.html index 6a898f427a..d2ae9f3aa3 100644 --- a/docs/examples/signin/index.html +++ b/docs/examples/signin/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/starter-template/index.html b/docs/examples/starter-template/index.html index e9eb5592bd..de26a02a64 100644 --- a/docs/examples/starter-template/index.html +++ b/docs/examples/starter-template/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/sticky-footer-navbar/index.html b/docs/examples/sticky-footer-navbar/index.html index 73dfe3ef07..3e2d76df26 100644 --- a/docs/examples/sticky-footer-navbar/index.html +++ b/docs/examples/sticky-footer-navbar/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/sticky-footer/index.html b/docs/examples/sticky-footer/index.html index f714a13837..d71aceee43 100644 --- a/docs/examples/sticky-footer/index.html +++ b/docs/examples/sticky-footer/index.html @@ -16,8 +16,9 @@ - + + diff --git a/docs/examples/theme/index.html b/docs/examples/theme/index.html index a2e228c844..f312df4eec 100644 --- a/docs/examples/theme/index.html +++ b/docs/examples/theme/index.html @@ -18,8 +18,9 @@ - + + diff --git a/docs/examples/tooltip-viewport/index.html b/docs/examples/tooltip-viewport/index.html index ccf6ef0782..3bb44f3f87 100644 --- a/docs/examples/tooltip-viewport/index.html +++ b/docs/examples/tooltip-viewport/index.html @@ -16,8 +16,9 @@ - + +