Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ <h2><i class="fa fa-unlock-alt"></i> <strong>{{ title }}</strong></h2>
<script src="static/js/intel-hex.browser.js" type="application/javascript"></script>
<script src="static/js/ResizeSensor.js"></script>
<script src="static/js/ElementQueries.js"></script>
<script src="static/js/custom-event-polyfill.js"></script>
<script src="lzma/lzma_worker.js"></script>
<script src="base64-js/base64.js"></script>
<script src="hexlify.js"
Expand Down
7 changes: 5 additions & 2 deletions python-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ function web_editor(config) {
}).map(function(f) {
return encodeURIComponent(f) + "=true";
}).join("&");
helpAnchor.attr("href", helpAnchor.attr("href") + "?" + featureQueryString);
helpAnchor.attr("href", helpAnchor.attr("href") + "?" + featureQueryString);
}

// Update the docs link to append MicroPython version
var docsAnchor = $("#docs-link");
var docsAnchor = $("#docs-link");
docsAnchor.attr("href", docsAnchor.attr("href") + "en/" + "v" + UPY_VERSION);

// This function is called to initialise the editor. It sets things up so
Expand Down Expand Up @@ -401,6 +401,9 @@ function web_editor(config) {
$('#load-drag-target').removeClass('is-dragover');
})
.on('drop', function(e) {
// Dispatch an event to allow others to listen to it
var event = new CustomEvent("load-drop", { detail: e.originalEvent.dataTransfer.files[0] });
document.dispatchEvent(event);
doDrop(e);
vex.close();
EDITOR.focus();
Expand Down
19 changes: 19 additions & 0 deletions static/js/custom-event-polyfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*!
* CustomEvent Polyfill to support IE
* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
* Source - https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
*/

(function () {

if ( typeof window.CustomEvent === "function" ) return false;

function CustomEvent ( event, params ) {
params = params || { bubbles: false, cancelable: false, detail: null };
var evt = document.createEvent( 'CustomEvent' );
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
return evt;
}

window.CustomEvent = CustomEvent;
})();