Add custom event file.

This commit is contained in:
Neil Fraser
2016-01-12 16:47:18 -08:00
parent 8fad5b1b16
commit 4b0ed0d372
6 changed files with 70 additions and 17 deletions

View File

@@ -177,19 +177,16 @@ Blockly.fireUiEventNow = function(node, eventName) {
list.splice(i, 1);
}
}
// Fire the event in a browser-compatible way.
if (document.createEvent) {
// Create a UI event in a browser-compatible way.
if (typeof UIEvent == 'function') {
// W3
var evt = document.createEvent('UIEvents');
evt.initEvent(eventName, true, true); // event type, bubbling, cancelable
node.dispatchEvent(evt);
} else if (document.createEventObject) {
// MSIE
var evt = document.createEventObject();
node.fireEvent('on' + eventName, evt);
var evt = new UIEvent(eventName, {});
} else {
throw 'FireEvent: No event creation mechanism.';
// MSIE
var evt = document.createEvent('UIEvent');
evt.initUIEvent(eventName, false, false, window, 0);
}
node.dispatchEvent(evt);
};
/**