fix dispatchEvent on ie 11

pull/4050/head
Niklas Fiekas 2018-02-17 11:53:48 +01:00
parent 43d37f1094
commit fb40fb6c9e
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...