Merge pull request #4050 from niklasf/dispatch-event-ie11

fix dispatchEvent on ie 11
This commit is contained in:
Thibault Duplessis 2018-02-28 18:11:58 -06:00 committed by GitHub
commit ea2429026d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -150,7 +150,7 @@ lichess.startEmbeddedAnalyse = function(opts) {
ground.style.width = groundSize + 'px';
ground.style.maxWidth = groundSize + 'px';
ground.style.height = boardSize + 'px';
document.body.dispatchEvent(new Event('chessground.resize'));
lichess.dispatchEvent(document.body, 'chessground.resize');
};
onResize();
window.addEventListener('resize', onResize);

View file

@ -403,9 +403,9 @@ lichess.topMenuIntent = function() {
}
// reflow charts
window.dispatchEvent(new Event('resize'));
lichess.dispatchEvent(window, 'resize');
document.body.dispatchEvent(new Event('chessground.resize'));
lichess.dispatchEvent(document.body, 'chessground.resize');
};
lichess.pubsub.on('reset_zoom', function() {
if (currentZoom > 1 || $('body').data('zoom') > 100) setZoom(currentZoom);

View file

@ -4,6 +4,12 @@ lichess.engineName = 'Stockfish 9+';
lichess.raf = (window.requestAnimationFrame || window.setTimeout).bind(window);
lichess.requestIdleCallback = (window.requestIdleCallback || window.setTimeout).bind(window);
lichess.dispatchEvent = function(el, eventName) {
// compability for ie 11 instead of el.dispatchEvent(new Event(eventName)))
var ev = document.createEvent('Event');
ev.initEvent(eventName, false, false);
el.dispatchEvent(ev);
};
lichess.storage = (function() {
try {
// just accessing localStorage can throw an exception...