Skip to content

Commit 21ef6be

Browse files
author
Matt Karl
committed
Fixed the drag-n-drop functionality
1 parent f9f7429 commit 21ef6be

File tree

11 files changed

+70
-69
lines changed

11 files changed

+70
-69
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.9",
3+
"version": "0.2.10",
44
"private": true,
55
"dependencies": {
66
"jqueryui": "*",

deploy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"description": "Application for SpringRoll projects",
4-
"version": "0.2.9",
4+
"version": "0.2.10",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/SpringRoll/SpringRollStudio"

installer/win32.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# These three must be integers
55
!define VERSIONMAJOR 0
66
!define VERSIONMINOR 2
7-
!define VERSIONBUILD 9
7+
!define VERSIONBUILD 10
88
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
99
# It is possible to use "mailto:" links in here to open the email client
1010
!define HELPURL "https://github.com/SpringRoll/SpringRollStudio/issues"

installer/win64.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# These three must be integers
55
!define VERSIONMAJOR 0
66
!define VERSIONMINOR 2
7-
!define VERSIONBUILD 9
7+
!define VERSIONBUILD 10
88
# These will be displayed by the "Click here for support information" link in "Add/Remove Programs"
99
# It is possible to use "mailto:" links in here to open the email client
1010
!define HELPURL "https://github.com/SpringRoll/SpringRollStudio/issues"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"private": true,
4-
"version": "0.2.9",
4+
"version": "0.2.10",
55
"dependencies": {
66
"grunt": "^0.4.5",
77
"grunt-appdmg": "^0.3.1",

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.9",
3+
"version": "0.2.10",
44
"main": [
55
"components/node-webkit-app/src/utils/UpdateChecker.js",
66
"components/node-webkit-app/src/utils/Browser.js",

src/js/Module.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
}
3939
}
4040

41+
// Turn off all file dragging
42+
$(document.body).on("dragover drop", function(e){
43+
e.preventDefault();
44+
return false;
45+
});
46+
4147
// Initialize the browser utility
4248
Browser.init();
4349
};

src/js/SpringRollStudio.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,48 @@
9393
}
9494
}.bind(this));
9595

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+
96138
// Set the current project state based on the project
97139
var project = localStorage.getItem('project');
98140
if (project)
@@ -108,6 +150,9 @@
108150
// Reference to the prototype
109151
var p = extend(SpringRollStudio, NodeWebkitApp);
110152

153+
// The class name for when dragging a file
154+
var DRAG_CLASS = "dragging";
155+
111156
/**
112157
* Handle when an item is clicked on in the system menu
113158
* @method _menuHandler

src/js/captions/Captions.js

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -104,59 +104,7 @@
104104

105105
var list = this.list.parent;
106106
var self = this;
107-
108-
$(document.body).on("dragover drop", function(e) {
109-
e.preventDefault();
110-
return false;
111-
});
112-
113-
/*list.on("dragenter", function(event){
114-
event.preventDefault();
115-
list.addClass("dragover");
116-
})
117-
.on("dragover", function(event) {
118-
event.preventDefault();
119-
if(!list.hasClass("dragover"))
120-
list.addClass("dragover");
121-
})
122-
.on("dragleave", function(event) {
123-
event.preventDefault();
124-
list.removeClass("dragover");
125-
})
126-
.on("drop", function(event) {
127-
event.preventDefault();
128-
list.removeClass("dragover");
129-
130-
var fileList = event.originalEvent.dataTransfer.files;
131-
132-
if (fileList.length > 1)
133-
{
134-
throw "Only one project at a time";
135-
}
136-
137-
// Select the first entry
138-
var file = fileList[0];
139-
140-
// Directories only!
141-
if (APP)
142-
{
143-
var fs = require('fs');
144-
if (!fs.lstatSync(file.path).isDirectory())
145-
{
146-
throw "Folders only. Please drag a project folder.";
147-
}
148-
}
149-
else
150-
{
151-
if (file.type !== "")
152-
{
153-
throw "Folders only. Please drag a project folder.";
154-
}
155-
}
156-
157-
self.open(APP ? file.path : file.name);
158-
});*/
159-
107+
160108
this.open(localStorage.getItem('project'));
161109
};
162110

src/js/new/TemplateManager.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@
7575
this._modal = $("#templateModal")
7676
.on('hidden.bs.modal', this.onModalClose.bind(this));
7777

78-
// Turn off all file dragging
79-
$(document.body).on("dragover drop", function(e){
80-
e.preventDefault();
81-
return false;
82-
});
83-
8478
var self = this;
8579

8680
// Setup the drop zone for the new templates

src/less/SpringRollStudio.less

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@ body {
55
cursor:default;
66
font-family:'OpenSans', sans-serif;
77
font-weight: lighter;
8+
width:100%;
9+
height:100%;
10+
position:absolute;
11+
padding:0 10px;
12+
background-color:#fff;
13+
&.dragging {
14+
box-shadow: inset 0px 0px 10px 0px rgba(0,0,0,0.3);
15+
background-color:#eee;
16+
}
817
}
918

1019
.modules {
1120
width:100%;
12-
border:10px solid #fff;
13-
border-bottom-width: 0;
21+
margin-top: 10px;
1422
&:last-child {
15-
border-bottom-width: 10px;
23+
margin-bottom: 10px;
1624
}
1725
a, button {
1826
font-weight:lighter;
@@ -26,7 +34,7 @@ body {
2634
border-top-left-radius: 0;
2735
border-top-right-radius: 0;
2836
text-align: center;
29-
margin:0 10px;
37+
margin:0;
3038
width:auto;
3139
color:#fff;
3240
border:0;

0 commit comments

Comments
 (0)