Skip to content

Commit 329054f

Browse files
author
Matt Karl
committed
0.2.0-alpha project-aware modules
1 parent 83a1de5 commit 329054f

27 files changed

+502
-746
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.0",
3+
"version": "0.2.0-alpha",
44
"private": true,
55
"dependencies": {
66
"jqueryui": "*",

deploy/assets/html/project.html

-10
This file was deleted.

deploy/assets/html/tasks.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
<div id="tasks_<%=id%>" data-id="<%=id%>" class="tasks container-fluid">
1+
<div class="tasks container-fluid">
22
<% for (var i = 0; i < tasks.length; i++ ) { %>
3-
<div id="task_item_<%=id%>_<%=tasks[i].name%>" class="tasks-item row JS-Task-Toggle-Info" title="<%=tasks[i].info%>">
3+
<div id="task_item_<%=tasks[i].name%>" class="tasks-item row JS-Task-Toggle-Info" title="<%=tasks[i].info%>">
44
<div class="tasks-actions btn-group pull-right">
55
<button
66
class="btn btn-default run JS-Task-Run"
7-
data-project-id="<%=id%>"
87
data-task-name="<%=tasks[i].name%>"
98
title="Run">
109
<span class="play glyphicon glyphicon-play"></span>
1110
<span class="stop glyphicon glyphicon-stop"></span>
1211
</button>
1312
<button
1413
class="btn btn-default terminal JS-Task-Terminal"
15-
data-project-id="<%=id%>"
1614
data-task-name="<%=tasks[i].name%>"
1715
title="Terminal"><span class="glyphicon glyphicon-align-left"></span>
1816
</button>
1917
</div>
2018
<div class="name"><%=tasks[i].name%></div>
2119
</div>
22-
<pre id="console_<%=id%>_<%=tasks[i].name%>" class="JS-Console console"></pre>
20+
<pre id="console_<%=tasks[i].name%>" class="JS-Console console"></pre>
2321
<% } %>
2422
</div>

deploy/assets/images/loader.gif

3.13 KB
Loading

deploy/index.html

+23-14
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,37 @@
33
<head>
44
<meta charset="utf-8">
55
<title>SpringRoll Studio</title>
6-
<link href="assets/css/libraries.css?v=0.2.0" rel="stylesheet">
7-
<link href="assets/css/main.css?v=0.2.0" rel="stylesheet">
8-
<script src="assets/js/libraries.js?v=0.2.0"></script>
9-
<script src="assets/js/main.js?v=0.2.0"></script>
6+
<link href="assets/css/libraries.css?v=0.2.0-alpha" rel="stylesheet">
7+
<link href="assets/css/main.css?v=0.2.0-alpha" rel="stylesheet">
8+
<script src="assets/js/libraries.js?v=0.2.0-alpha"></script>
9+
<script src="assets/js/main.js?v=0.2.0-alpha"></script>
1010
</head>
1111
<body>
12+
<header>
13+
<img src="assets/images/icon.png?v=0.2.0-alpha" class="logo">
14+
</header>
15+
<nav class="modules btn-group">
16+
<a class="btn btn-primary" href="new.html" id="new" target="_blank" title="New Project" data-width="550" data-height="670" data-resizable="false">
17+
<span class="icon glyphicon glyphicon-file"></span> New
18+
</a>
19+
<button class="btn btn-primary" id="openButton" title="Open Project">
20+
<span class="icon glyphicon glyphicon-folder-open"></span> Open
21+
</button>
22+
<button class="btn btn-primary" id="closeButton" title="Close Project">
23+
<span class="icon glyphicon glyphicon-remove"></span> Close
24+
</button>
25+
</nav>
1226
<div class="modules btn-group-vertical">
13-
<a class="btn btn-primary btn-lg" href="captions.html" id="captions" target="_blank" title="Caption Creator" data-width="640" data-height="480" data-min-width="510" data-min-height="400">
27+
<a class="btn btn-primary btn-lg requires-project" href="captions.html" id="captions" target="_blank" title="Caption Creator" data-width="640" data-height="480" data-min-width="510" data-min-height="400">
1428
Caption Creator
1529
</a>
16-
<a class="btn btn-primary btn-lg" href="remote.html" id="remote" target="_blank" title="Remote Trace" data-width="480" data-height="400" data-min-height="275" data-min-width="400">
17-
Remote Trace
18-
</a>
19-
<a class="btn btn-primary btn-lg" href="tasks.html" id="tasks" target="_blank" title="Task Runner" data-width="480" data-height="400" data-min-height="275" data-min-width="400">
30+
<a class="btn btn-primary btn-lg requires-project" href="tasks.html" id="tasks" target="_blank" title="Task Runner" data-width="480" data-height="400" data-min-height="275" data-min-width="280">
2031
Task Runner
2132
</a>
22-
</div>
23-
<div class="modules btn-group-vertical">
24-
<!-- <button class="btn btn-default" id="open" title="Open Project">Open Project</button> -->
25-
<a class="btn btn-default" href="new.html" id="new" target="_blank" title="New Project" data-width="550" data-height="670" data-resizable="false">
26-
New Project
33+
<a class="btn btn-primary btn-lg" href="remote.html" id="remote" target="_blank" title="Remote Trace" data-width="480" data-height="400" data-min-height="275" data-min-width="400">
34+
Remote Trace
2735
</a>
2836
</div>
37+
<footer class="version">Version <span id="version">0.2.0-alpha</span></footer>
2938
</body>
3039
</html>

deploy/package.json

100755100644
+5-3
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.0",
4+
"version": "0.2.0-alpha",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/SpringRoll/SpringRollStudio"
@@ -14,8 +14,8 @@
1414
"toolbar": false,
1515
"frame": true,
1616
"position": "center",
17-
"width": 300,
18-
"height": 222,
17+
"width": 340,
18+
"height": 350,
1919
"resizable": false
2020
},
2121
"webkit": {
@@ -27,7 +27,9 @@
2727
"ansi2html": "~0.0.1",
2828
"fs-extra": "~0.12.0",
2929
"glob": "~4.0.6",
30+
"grunt-cli": "^0.1.13",
3031
"node-watch": "~0.3.4",
32+
"npm": "^2.4.1",
3133
"replace": "~0.3.0",
3234
"request": "^2.48.0",
3335
"semver": "~4.0.3",

deploy/tasks.html

+1-10
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
<header class="fixed">
1313
<h1>Task Runner</h1>
1414
</header>
15-
<div class="sidebar">
16-
<div class="sidebar-shadow"></div>
17-
<button class="sidebar-toggle">
18-
<span class="icon-left left"></span>
19-
<span class="icon-right right"></span>
20-
</button>
21-
<div class="sidebar-title">Projects</div>
22-
<div class="sidebar-list"></div>
23-
</div>
24-
<div class="task-tab"></div>
15+
<div id="tasks" class="loading"></div>
2516
</body>
2617
</html>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "SpringRollStudio",
33
"private": true,
4-
"version": "0.2.0",
4+
"version": "0.2.0-alpha",
55
"dependencies": {
66
"grunt": "~0.4.5",
77
"grunt-exec": "~0.4.6",

project.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "SpringRollStudio",
3-
"version": "0.2.0",
3+
"version": "0.2.0-alpha",
44
"main": [
55
"components/node-webkit-app/src/utils/UpdateChecker.js",
6+
"components/node-webkit-app/src/utils/Browser.js",
67
"components/node-webkit-app/src/NodeWebkitApp.js",
78
"src/springroll/ModuleButton.js",
89
"src/springroll/SpringRollStudio.js",

src/springroll/ModuleButton.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@
1111
* @namespace springroll
1212
* @constructor
1313
* @param {Element} dom The DOM element link
14+
* @param {springroll.SpringRollStudio} app Reference to the app
1415
*/
15-
var ModuleButton = function(dom, parent)
16+
var ModuleButton = function(dom, app)
1617
{
1718
/**
1819
* The reference to the DOM link
1920
* @property {Element} dom
2021
*/
2122
this.dom = dom;
2223

23-
this.parent = parent;
24+
/**
25+
* The parent main app
26+
* @property {springroll.SpringRollStudio} parent
27+
*/
28+
this.parent = app;
2429

2530
// jquery object
2631
var link = $(dom).click(this._onOpen.bind(this));
@@ -142,6 +147,19 @@
142147
this.window.module.focus();
143148
};
144149

150+
/**
151+
* Close the module
152+
* @method close
153+
* @param {boolean} [force=false] If we should force the close
154+
*/
155+
p.close = function(force)
156+
{
157+
if (this.main)
158+
{
159+
this.main.close(force);
160+
}
161+
};
162+
145163
/**
146164
* Upon closing save the window
147165
* @method _onClose

src/springroll/SpringRollStudio.js

+102-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
if (APP)
44
{
55
var gui = require('nw.gui');
6+
var fs = require('fs');
7+
var path = require('path');
68
}
79

810
// Import classes
911
var NodeWebkitApp = cloudkid.NodeWebkitApp,
10-
ModuleButton = springroll.ModuleButton;
12+
ModuleButton = springroll.ModuleButton,
13+
Browser = cloudkid.Browser;
1114

1215
/**
1316
* Node Webkit Application
@@ -20,6 +23,13 @@
2023

2124
var modules = this.modules = [];
2225

26+
/**
27+
* The buttons only active when a project is opened
28+
* @property {jquery} requiresProject
29+
*/
30+
this.requiresProject = $(".requires-project")
31+
.addClass('disabled active');
32+
2333
if (APP)
2434
{
2535
this.menu = new gui.Menu({ type: 'menubar' });
@@ -35,12 +45,46 @@
3545
this.main.on('focus', this.focus.bind(this));
3646
this.focus();
3747

38-
var main = this.main;
48+
// Local cache of instance
49+
var app = this;
3950

4051
// Add the modules
4152
$(".modules a").each(function(){
42-
modules.push(new ModuleButton(this, main));
53+
modules.push(new ModuleButton(this, app));
4354
});
55+
56+
57+
58+
}
59+
60+
// Bind reference to the open project handler
61+
var openProject = this.openProject.bind(this);
62+
63+
/**
64+
* Open button
65+
* @property {jquery} openButton
66+
*/
67+
this.openButton = $("#openButton")
68+
.click(function(){
69+
Browser.folder(openProject);
70+
});
71+
72+
/**
73+
* Close button
74+
* @property {jquery} closeButton
75+
*/
76+
this.closeButton = $("#closeButton")
77+
.click(this.closeProject.bind(this));
78+
79+
// Set the current project state based on the project
80+
var project = localStorage.getItem('project');
81+
if (project)
82+
{
83+
this.openProject(project);
84+
}
85+
else
86+
{
87+
this.closeProject();
4488
}
4589
};
4690

@@ -57,6 +101,61 @@
57101
this.main.menu = this.menu;
58102
};
59103

104+
/**
105+
* Open a project file
106+
* @method openProject
107+
* @param {string} project Path to the folder
108+
*/
109+
p.openProject = function(project)
110+
{
111+
this.requiresProject.removeClass('disabled active');
112+
113+
if (!fs.existsSync(path.join(project, 'springroll.json')))
114+
{
115+
alert("Folder is not a valid SpringRoll project");
116+
return;
117+
}
118+
this.closeButton.removeClass('disabled active');
119+
if (localStorage.getItem('project') != project)
120+
{
121+
localStorage.setItem('project', project);
122+
this.closeModules(true);
123+
}
124+
};
125+
126+
/**
127+
* Open a project file
128+
* @method closeProject
129+
*/
130+
p.closeProject = function()
131+
{
132+
this.requiresProject.addClass('disabled active');
133+
this.closeButton.addClass('disabled active');
134+
localStorage.removeItem('project');
135+
this.closeModules();
136+
};
137+
138+
/**
139+
* Close the window
140+
* @method closeModules
141+
* @param {boolean} [force=false] Force-close the window
142+
*/
143+
p.closeModules = function(force)
144+
{
145+
for (var i = 0; i < this.modules.length; i++)
146+
{
147+
this.modules[i].close(force);
148+
}
149+
};
150+
151+
/**
152+
* Close the window
153+
* @method close
154+
*/
155+
p.close = function()
156+
{
157+
};
158+
60159
// Create the application
61160
$(function(){ window.app = new SpringRollStudio(); });
62161

0 commit comments

Comments
 (0)