Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support to drop files directly in to the editor - saves typing …

…a few strokes :)
  • Loading branch information...
commit 547ae48340d64be033b95c9b3a395ba933d74cef 1 parent ba147b2
@remy remy authored
Showing with 31 additions and 0 deletions.
  1. +1 −0  js/chrome/app.js
  2. +30 −0 js/chrome/file-drop.js
View
1  js/chrome/app.js
@@ -3,6 +3,7 @@
//= require "navigation"
//= require "save"
//= require "stream"
+//= require "file-drop"
var debug = false,
$bin = $('#bin'),
View
30 js/chrome/file-drop.js
@@ -0,0 +1,30 @@
+function allowDrop(panel) {
+ var holder = editors[panel].win;
+
+ if (typeof window.FileReader !== 'undefined') {
+ holder.ondragover = function () {
+ return false;
+ };
+
+ holder.ondragend = function () {
+ return false;
+ };
+
+ holder.ondrop = function (e) {
+ e.preventDefault();
+
+ var file = e.dataTransfer.files[0],
+ reader = new FileReader();
+ reader.onload = function (event) {
+ // put JS in the JavaScript panel
+ editors[file.type.indexOf('javascript') > 0 ? 'javascript' : 'html'].setCode(event.target.result);
+ };
+ reader.readAsText(file);
+
+ return false;
+ };
+ }
+}
+
+allowDrop('html');
+allowDrop('javascript');
Please sign in to comment.
Something went wrong with that request. Please try again.