|
93 | 93 | } |
94 | 94 | }.bind(this)); |
95 | 95 |
|
| 96 | + // Setup the drop zone for the new templates |
| 97 | + var self = this; |
| 98 | + var drop = $(document.body) |
| 99 | + .on("dragenter", function(ev){ |
| 100 | + ev.preventDefault(); |
| 101 | + drop.addClass(DRAG_CLASS); |
| 102 | + }) |
| 103 | + .on("dragover", function(ev){ |
| 104 | + ev.preventDefault(); |
| 105 | + if(!drop.hasClass(DRAG_CLASS)) |
| 106 | + drop.addClass(DRAG_CLASS); |
| 107 | + }) |
| 108 | + .on("dragleave", function(ev){ |
| 109 | + ev.preventDefault(); |
| 110 | + drop.removeClass(DRAG_CLASS); |
| 111 | + }) |
| 112 | + .on("drop", function(ev){ |
| 113 | + ev.preventDefault(); |
| 114 | + drop.removeClass(DRAG_CLASS); |
| 115 | + var fileList = ev.originalEvent.dataTransfer.files; |
| 116 | + if (fileList.length > 1) |
| 117 | + { |
| 118 | + alert("Only one template at a time."); |
| 119 | + return; |
| 120 | + } |
| 121 | + |
| 122 | + // Select the first entry |
| 123 | + var file = fileList[0]; |
| 124 | + |
| 125 | + // Directories only! |
| 126 | + if (APP) |
| 127 | + { |
| 128 | + if (!fs.lstatSync(file.path).isDirectory()) |
| 129 | + { |
| 130 | + alert("Folders only. Please drag a project folder."); |
| 131 | + return; |
| 132 | + } |
| 133 | + self.openProject(file.path); |
| 134 | + } |
| 135 | + }); |
| 136 | + |
| 137 | + |
96 | 138 | // Set the current project state based on the project |
97 | 139 | var project = localStorage.getItem('project'); |
98 | 140 | if (project) |
|
108 | 150 | // Reference to the prototype |
109 | 151 | var p = extend(SpringRollStudio, NodeWebkitApp); |
110 | 152 |
|
| 153 | + // The class name for when dragging a file |
| 154 | + var DRAG_CLASS = "dragging"; |
| 155 | + |
111 | 156 | /** |
112 | 157 | * Handle when an item is clicked on in the system menu |
113 | 158 | * @method _menuHandler |
|
0 commit comments