Skip to content

Commit 12d8834

Browse files
lafrikslunny
authored andcommitted
Fix heatmap and repository menu display in Internet Explorer 9+ (#6117) (#6137)
1 parent 597a30b commit 12d8834

File tree

5 files changed

+121
-8
lines changed

5 files changed

+121
-8
lines changed

public/js/index.js

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,115 @@ function htmlEncode(text) {
77
var csrf;
88
var suburl;
99

10+
// Polyfill for IE9+ support (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from)
11+
if (!Array.from) {
12+
Array.from = (function () {
13+
var toStr = Object.prototype.toString;
14+
var isCallable = function (fn) {
15+
return typeof fn === 'function' || toStr.call(fn) === '[object Function]';
16+
};
17+
var toInteger = function (value) {
18+
var number = Number(value);
19+
if (isNaN(number)) { return 0; }
20+
if (number === 0 || !isFinite(number)) { return number; }
21+
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
22+
};
23+
var maxSafeInteger = Math.pow(2, 53) - 1;
24+
var toLength = function (value) {
25+
var len = toInteger(value);
26+
return Math.min(Math.max(len, 0), maxSafeInteger);
27+
};
28+
29+
// The length property of the from method is 1.
30+
return function from(arrayLike/*, mapFn, thisArg */) {
31+
// 1. Let C be the this value.
32+
var C = this;
33+
34+
// 2. Let items be ToObject(arrayLike).
35+
var items = Object(arrayLike);
36+
37+
// 3. ReturnIfAbrupt(items).
38+
if (arrayLike == null) {
39+
throw new TypeError("Array.from requires an array-like object - not null or undefined");
40+
}
41+
42+
// 4. If mapfn is undefined, then let mapping be false.
43+
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
44+
var T;
45+
if (typeof mapFn !== 'undefined') {
46+
// 5. else
47+
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
48+
if (!isCallable(mapFn)) {
49+
throw new TypeError('Array.from: when provided, the second argument must be a function');
50+
}
51+
52+
// 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
53+
if (arguments.length > 2) {
54+
T = arguments[2];
55+
}
56+
}
57+
58+
// 10. Let lenValue be Get(items, "length").
59+
// 11. Let len be ToLength(lenValue).
60+
var len = toLength(items.length);
61+
62+
// 13. If IsConstructor(C) is true, then
63+
// 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.
64+
// 14. a. Else, Let A be ArrayCreate(len).
65+
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
66+
67+
// 16. Let k be 0.
68+
var k = 0;
69+
// 17. Repeat, while k < len… (also steps a - h)
70+
var kValue;
71+
while (k < len) {
72+
kValue = items[k];
73+
if (mapFn) {
74+
A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
75+
} else {
76+
A[k] = kValue;
77+
}
78+
k += 1;
79+
}
80+
// 18. Let putStatus be Put(A, "length", len, true).
81+
A.length = len;
82+
// 20. Return A.
83+
return A;
84+
};
85+
}());
86+
}
87+
88+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
89+
if (typeof Object.assign != 'function') {
90+
// Must be writable: true, enumerable: false, configurable: true
91+
Object.defineProperty(Object, "assign", {
92+
value: function assign(target, varArgs) { // .length of function is 2
93+
'use strict';
94+
if (target == null) { // TypeError if undefined or null
95+
throw new TypeError('Cannot convert undefined or null to object');
96+
}
97+
98+
var to = Object(target);
99+
100+
for (var index = 1; index < arguments.length; index++) {
101+
var nextSource = arguments[index];
102+
103+
if (nextSource != null) { // Skip over if undefined or null
104+
for (var nextKey in nextSource) {
105+
// Avoid bugs when hasOwnProperty is shadowed
106+
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
107+
to[nextKey] = nextSource[nextKey];
108+
}
109+
}
110+
}
111+
}
112+
return to;
113+
},
114+
writable: true,
115+
configurable: true
116+
});
117+
}
118+
10119
function initCommentPreviewTab($form) {
11120
var $tabMenu = $form.find('.tabular.menu');
12121
$tabMenu.find('.item').tab();
@@ -2348,7 +2457,6 @@ function initHeatmap(appElementId, heatmapUser, locale) {
23482457
this.getColor(4),
23492458
this.getColor(5)
23502459
];
2351-
console.log(this.colorRange);
23522460
this.endDate = new Date();
23532461
this.loadHeatmap(this.user);
23542462
},

public/vendor/librejs.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<tr>
4949
<td><a href="./plugins/vue/vue.min.js">vue.min.js</a></td>
5050
<td><a href="https://github.com/vuejs/vue/blob/dev/LICENSE">Expat</a></td>
51-
<td><a href="https://github.com/vuejs/vue/archive/v2.1.10.tar.gz">vue.js-v2.1.10.tar.gz</a></td>
51+
<td><a href="https://github.com/vuejs/vue/archive/v2.6.6.tar.gz">vue.js-v2.6.6.tar.gz</a></td>
5252
</tr>
5353
<tr>
5454
<td><a href="./plugins/emojify/emojify.min.js">emojify.min.js</a></td>
@@ -136,7 +136,7 @@
136136
<td><a href="https://github.com/swagger-api/swagger-ui/archive/v3.0.4.tar.gz">swagger-ui-v3.0.4.tar.gz</a></td>
137137
</tr>
138138
<tr>
139-
<td><a href="./plugins/vue-calendar-heatmap">vue-calendar-heatmap</a></td>
139+
<td><a href="./plugins/vue-calendar-heatmap/">vue-calendar-heatmap</a></td>
140140
<td><a href="https://github.com/WildCodeSchool/vue-calendar-heatmap/blob/master/README.md">MIT</a></td>
141141
<td><a href="https://github.com/WildCodeSchool/vue-calendar-heatmap/archive/master.zip">7f48b20.zip</a></td>
142142
</tr>
@@ -145,6 +145,11 @@
145145
<td><a href="https://github.com/moment/moment/blob/develop/LICENSE">MIT</a></td>
146146
<td><a href="https://github.com/moment/moment/archive/2.22.2.tar.gz">0.4.1.tar.gz</a></td>
147147
</tr>
148+
<tr>
149+
<td><a href="./plugins/es6-promise/">es6-promise</a></td>
150+
<td><a href="https://github.com/stefanpenner/es6-promise/blob/master/LICENSE">MIT</a></td>
151+
<td><a href="https://github.com/stefanpenner/es6-promise/archive/v4.2.6.tar.gz">4.2.6.tar.gz</a></td>
152+
</tr>
148153
</tbody>
149154
</table>
150155
</body>

public/vendor/plugins/es6-promise/es6-promise.auto.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/vendor/plugins/vue/vue.min.js

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/base/footer.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
<script src="{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.js"></script>
113113
<script src="{{AppSubUrl}}/js/index.js?v={{MD5 AppVer}}"></script>
114114
{{if .EnableHeatmap}}
115+
<script src="{{AppSubUrl}}/vendor/plugins/es6-promise/es6-promise.auto.min.js" charset="utf-8"></script>
115116
<script src="{{AppSubUrl}}/vendor/plugins/moment/moment.min.js" charset="utf-8"></script>
116117
<script src="{{AppSubUrl}}/vendor/plugins/vue-calendar-heatmap/vue-calendar-heatmap.browser.js" charset="utf-8"></script>
117118
<script type="text/javascript">

0 commit comments

Comments
 (0)