]> khamidou — GitHub mirrors - electron.git/commitdiff
Enable dragging to open an app.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 5 May 2014 08:30:37 +0000 (16:30 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 5 May 2014 08:30:37 +0000 (16:30 +0800)
atom/browser/default_app/index.html

index 94a5f23f186b575503e7ac55173db29591ed9a51..6013948c58162801a4b31488b4c9d98de5ef55dc 100644 (file)
       overflow: auto;
       padding: 6px 10px;
     }
+
+    #holder {
+      border: 4px dashed #ccc;
+      margin: 0 auto;
+      height: 300px;
+      color: #ccc;
+      font-size: 40px;
+      line-height: 300px;
+      text-align: center;
+    }
+    #holder.hover {
+      border: 4px dashed #999;
+      color: #eee;
+    }
   </style>
 </head>
 <body>
     var openWiki = function() {
       require('shell').openExternal('https://github.com/atom/atom-shell/blob/master/docs/tutorial/quick-start.md');
     }
+
+    document.ondragover = document.ondrop = function(e) {
+      e.preventDefault();
+      return false;
+    }
   </script>
 
   <h2>Welcome to Atom Shell</h2>
   app, you can read the <a href="javascript:openWiki()">Quick Start</a> guide
   in atom-shell's docs on how to write one.
   </p>
+
+  <p>
+  Or you can just drag your app here to run it:
+  </p>
+
+  <div id="holder">
+    Drag your app here to run it
+  </div>
+
+  <script>
+    var holder = document.getElementById('holder');
+    holder.ondragover = function () {
+      this.className = 'hover';
+      return false;
+    };
+    holder.ondragleave = holder.ondragend = function () {
+      this.className = '';
+      return false;
+    };
+    holder.ondrop = function (e) {
+      this.className = '';
+      e.preventDefault();
+
+      var file = e.dataTransfer.files[0];
+      require('child_process').execFile(execPath, [file.path], {
+        detached: true, stdio: 'ignore'
+      }).unref();
+      return false;
+    };
+  </script>
 </body>
 </html>