2787 |
rexy |
1 |
/* Bootstrap 4 for IE9 - v4.3.100 */
|
|
|
2 |
/* https://github.com/namiltd/bootstrap-ie */
|
|
|
3 |
|
|
|
4 |
/**
|
|
|
5 |
* Modified code based on remPolyfill.js (c) Nicolas Bouvrette https://github.com/nbouvrette/remPolyfill
|
|
|
6 |
*
|
|
|
7 |
* Customizations:
|
|
|
8 |
*
|
|
|
9 |
* 1) Added new method `addCallBackWhenReady` to perform callbacks once the polyfill has been applied (especially useful for
|
|
|
10 |
* onload scrolling events.
|
|
|
11 |
* 2) Added REM support.
|
|
|
12 |
*
|
|
|
13 |
**/
|
|
|
14 |
|
|
|
15 |
// adds classList support (as Array) to Element.prototype for IE8-9
|
|
|
16 |
(function() {
|
|
|
17 |
Object.defineProperty(Element.prototype, 'classList', {
|
|
|
18 |
get:function(){
|
|
|
19 |
var element=this,domTokenList=(element.getAttribute('class')||'').replace(/^\s+|\s$/g,'').split(/\s+/g);
|
|
|
20 |
if (domTokenList[0]==='') domTokenList.splice(0,1);
|
|
|
21 |
function setClass(){
|
|
|
22 |
if (domTokenList.length > 0) element.setAttribute('class', domTokenList.join(' '));
|
|
|
23 |
else element.removeAttribute('class');
|
|
|
24 |
}
|
|
|
25 |
domTokenList.toggle=function(className,force){
|
|
|
26 |
if (force!==undefined){
|
|
|
27 |
if (force) domTokenList.add(className);
|
|
|
28 |
else domTokenList.remove(className);
|
|
|
29 |
}
|
|
|
30 |
else {
|
|
|
31 |
if (domTokenList.indexOf(className)!==-1) domTokenList.splice(domTokenList.indexOf(className),1);
|
|
|
32 |
else domTokenList.push(className);
|
|
|
33 |
}
|
|
|
34 |
setClass();
|
|
|
35 |
};
|
|
|
36 |
domTokenList.add=function(){
|
|
|
37 |
var args=[].slice.call(arguments);
|
|
|
38 |
for (var i=0,l=args.length;i<l;i++){
|
|
|
39 |
if (domTokenList.indexOf(args[i])===-1) domTokenList.push(args[i]);
|
|
|
40 |
}
|
|
|
41 |
setClass();
|
|
|
42 |
};
|
|
|
43 |
domTokenList.remove=function(){
|
|
|
44 |
var args=[].slice.call(arguments);
|
|
|
45 |
for (var i=0,l=args.length;i<l;i++){
|
|
|
46 |
if (domTokenList.indexOf(args[i])!==-1) domTokenList.splice(domTokenList.indexOf(args[i]),1);
|
|
|
47 |
}
|
|
|
48 |
setClass();
|
|
|
49 |
};
|
|
|
50 |
domTokenList.item=function(i){
|
|
|
51 |
return domTokenList[i];
|
|
|
52 |
};
|
|
|
53 |
domTokenList.contains=function(className){
|
|
|
54 |
return domTokenList.indexOf(className)!==-1;
|
|
|
55 |
};
|
|
|
56 |
domTokenList.replace=function(oldClass,newClass){
|
|
|
57 |
if (domTokenList.indexOf(oldClass)!==-1) domTokenList.splice(domTokenList.indexOf(oldClass),1,newClass);
|
|
|
58 |
setClass();
|
|
|
59 |
};
|
|
|
60 |
domTokenList.value = (element.getAttribute('class')||'');
|
|
|
61 |
return domTokenList;
|
|
|
62 |
}
|
|
|
63 |
});
|
|
|
64 |
})();
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* For browsers that do not support REM units, fallback to pixels.
|
|
|
68 |
*/
|
|
|
69 |
window.remPolyfill = {
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* Implement this script on a given element.
|
|
|
73 |
*
|
|
|
74 |
* @private
|
|
|
75 |
*
|
|
|
76 |
* @param {string} cssText - The CSS text of the link element.
|
|
|
77 |
*/
|
|
|
78 |
replaceCSS: function (cssText) {
|
|
|
79 |
if (cssText) {
|
|
|
80 |
// Replace all properties containing REM units with their pixel equivalents.
|
|
|
81 |
return cssText.replace(
|
|
|
82 |
/:invalid/g, '._invalid'
|
|
|
83 |
).replace(
|
|
|
84 |
/:valid/g, '._valid'
|
|
|
85 |
);
|
|
|
86 |
}
|
|
|
87 |
},
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Implement this script on a given element.
|
|
|
91 |
*
|
|
|
92 |
* @param {HTMLLinkElement} linkElement - The link element to polyfill.
|
|
|
93 |
*/
|
|
|
94 |
implement: function (linkElement) {
|
|
|
95 |
if (!linkElement.href) {
|
|
|
96 |
return;
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
var request = null;
|
|
|
100 |
|
|
|
101 |
if (window.XMLHttpRequest) {
|
|
|
102 |
request = new XMLHttpRequest();
|
|
|
103 |
} else if (window.ActiveXObject) {
|
|
|
104 |
try {
|
|
|
105 |
request = new ActiveXObject("Msxml2.XMLHTTP");
|
|
|
106 |
} catch (exception) {
|
|
|
107 |
try {
|
|
|
108 |
request = new ActiveXObject("Microsoft.XMLHTTP");
|
|
|
109 |
} catch (exception) {
|
|
|
110 |
request = null;
|
|
|
111 |
}
|
|
|
112 |
}
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
if (!request) {
|
|
|
116 |
return;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
request.open('GET', linkElement.href, true);
|
|
|
120 |
request.onreadystatechange = function() {
|
|
|
121 |
if ( request.readyState === 4 ) {
|
|
|
122 |
linkElement.styleSheet.cssText = remPolyfill.replaceCSS(request.responseText);
|
|
|
123 |
}
|
|
|
124 |
};
|
|
|
125 |
|
|
|
126 |
request.send(null);
|
|
|
127 |
}
|
|
|
128 |
};
|
|
|
129 |
|
|
|
130 |
var linkElements = document.querySelectorAll('link[rel=stylesheet]');
|
|
|
131 |
for (var linkElementId in linkElements) {
|
|
|
132 |
if (Object.prototype.hasOwnProperty.call(linkElements, linkElementId)) {
|
|
|
133 |
remPolyfill.implement(linkElements[linkElementId]);
|
|
|
134 |
}
|
|
|
135 |
}
|