Permalink
Browse files

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

…a few strokes :)
  • Loading branch information...
remy committed Jan 3, 2011
1 parent ba147b2 commit 547ae48340d64be033b95c9b3a395ba933d74cef
Showing with 31 additions and 0 deletions.
  1. +1 −0 js/chrome/app.js
  2. +30 −0 js/chrome/file-drop.js
View
@@ -3,6 +3,7 @@
//= require "navigation"
//= require "save"
//= require "stream"
+//= require "file-drop"
var debug = false,
$bin = $('#bin'),
View
@@ -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');

0 comments on commit 547ae48

Please sign in to comment.