Skip to content

Commit c4342d8

Browse files
committed
added polyfill for settimeout for <=IE9 and added forgotten CSS requirement
1 parent 57ea82b commit c4342d8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

code/DropdownImageField.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public function __construct($name, $title=null, $sourceObject='Group', $keyField
6868
public function Field($properties = array()) {
6969
$dirName = basename(dirname(dirname(__FILE__)));;
7070

71+
Requirements::javascript($dirName.'/javascript/Polyfill.js');
7172
Requirements::javascript($dirName.'/javascript/ImageSelect.jquery.js');
73+
Requirements::css($dirName.'/css/ImageSelect.css');
7274

7375
$source = $this->getSourceObject();
7476
$options = array();

javascript/Polyfill.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*\
2+
|*|
3+
|*| IE-specific polyfill which enables the passage of arbitrary arguments to the
4+
|*| callback functions of JavaScript timers (HTML5 standard syntax).
5+
|*|
6+
|*| https://developer.mozilla.org/en-US/docs/DOM/window.setInterval
7+
|*|
8+
|*| Syntax:
9+
|*| var timeoutID = window.setTimeout(func, delay, [param1, param2, ...]);
10+
|*| var timeoutID = window.setTimeout(code, delay);
11+
|*| var intervalID = window.setInterval(func, delay[, param1, param2, ...]);
12+
|*| var intervalID = window.setInterval(code, delay);
13+
|*|
14+
\*/
15+
16+
if (document.all && !window.setTimeout.isPolyfill) {
17+
var __nativeST__ = window.setTimeout;
18+
window.setTimeout = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
19+
var aArgs = Array.prototype.slice.call(arguments, 2);
20+
return __nativeST__(vCallback instanceof Function ? function () {
21+
vCallback.apply(null, aArgs);
22+
} : vCallback, nDelay);
23+
};
24+
window.setTimeout.isPolyfill = true;
25+
}
26+
27+
if (document.all && !window.setInterval.isPolyfill) {
28+
var __nativeSI__ = window.setInterval;
29+
window.setInterval = function (vCallback, nDelay /*, argumentToPass1, argumentToPass2, etc. */) {
30+
var aArgs = Array.prototype.slice.call(arguments, 2);
31+
return __nativeSI__(vCallback instanceof Function ? function () {
32+
vCallback.apply(null, aArgs);
33+
} : vCallback, nDelay);
34+
};
35+
window.setInterval.isPolyfill = true;
36+
}

0 commit comments

Comments
 (0)