Skip to content

Commit 1c3a97a

Browse files
committed
Make red.min.js a reusable library
1 parent 3489fe0 commit 1c3a97a

5 files changed

Lines changed: 66 additions & 49 deletions

File tree

Gruntfile.js

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ module.exports = function(grunt) {
9898
src: [
9999
// Ensure editor source files are concatenated in
100100
// the right order
101-
"editor/js/main.js",
101+
"editor/js/red.js",
102102
"editor/js/events.js",
103103
"editor/js/i18n.js",
104104
"editor/js/settings.js",
@@ -150,19 +150,15 @@ module.exports = function(grunt) {
150150
"public/vendor/vendor.css": [
151151
// TODO: resolve relative resource paths in
152152
// bootstrap/FA/jquery
153-
],
154-
"public/vendor/vendor-jquery.js": [
155-
"editor/vendor/jquery/js/jquery-1.11.3.min.js",
156-
"editor/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js",
157-
"editor/vendor/jquery/js/jquery.ui.touch-punch.min.js",
158153
]
159154
}
160155
}
161156
},
162157
uglify: {
163158
build: {
164159
files: {
165-
'public/red/red.min.js': 'public/red/red.js'
160+
'public/red/red.min.js': 'public/red/red.js',
161+
'public/red/main.min.js': 'public/red/main.js'
166162
}
167163
}
168164
},
@@ -193,7 +189,8 @@ module.exports = function(grunt) {
193189
attachCopyright: {
194190
js: {
195191
src: [
196-
'public/red/red.min.js'
192+
'public/red/red.min.js',
193+
'public/red/main.min.js'
197194
]
198195
},
199196
css: {
@@ -272,40 +269,45 @@ module.exports = function(grunt) {
272269

273270
copy: {
274271
build: {
275-
files:[{
276-
cwd: 'editor/images',
277-
src: '**',
278-
expand: true,
279-
dest: 'public/red/images/'
280-
},
281-
{
282-
cwd: 'editor/vendor',
283-
src: [
284-
'ace/**',
285-
//'bootstrap/css/**',
286-
'bootstrap/img/**',
287-
'jquery/css/**',
288-
'font-awesome/**'
289-
],
290-
expand: true,
291-
dest: 'public/vendor/'
292-
},
293-
{
294-
cwd: 'editor/icons',
295-
src: '**',
296-
expand: true,
297-
dest: 'public/icons/'
298-
},
299-
{
300-
expand: true,
301-
src: ['editor/index.html','editor/favicon.ico'],
302-
dest: 'public/',
303-
flatten: true
304-
},
305-
{
306-
src: 'CHANGELOG.md',
307-
dest: 'public/red/about'
308-
}
272+
files:[
273+
{
274+
src: 'editor/js/main.js',
275+
dest: 'public/red/main.js'
276+
},
277+
{
278+
cwd: 'editor/images',
279+
src: '**',
280+
expand: true,
281+
dest: 'public/red/images/'
282+
},
283+
{
284+
cwd: 'editor/vendor',
285+
src: [
286+
'ace/**',
287+
//'bootstrap/css/**',
288+
'bootstrap/img/**',
289+
'jquery/css/**',
290+
'font-awesome/**'
291+
],
292+
expand: true,
293+
dest: 'public/vendor/'
294+
},
295+
{
296+
cwd: 'editor/icons',
297+
src: '**',
298+
expand: true,
299+
dest: 'public/icons/'
300+
},
301+
{
302+
expand: true,
303+
src: ['editor/index.html','editor/favicon.ico'],
304+
dest: 'public/',
305+
flatten: true
306+
},
307+
{
308+
src: 'CHANGELOG.md',
309+
dest: 'public/red/about'
310+
}
309311
]
310312
},
311313
release: {
@@ -431,7 +433,7 @@ module.exports = function(grunt) {
431433

432434
grunt.registerTask('build',
433435
'Builds editor content',
434-
['clean:build','concat:build','concat:vendor','uglify:build','sass:build','jsonlint:messages','copy:build','attachCopyright']);
436+
['clean:build','concat:build','concat:vendor','copy:build','uglify:build','sass:build','jsonlint:messages','attachCopyright']);
435437

436438
grunt.registerTask('dev',
437439
'Developer mode: run node-red, watch for source changes and build/restart',

editor/js/main.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
**/
16-
var RED = (function() {
16+
(function() {
1717

1818

1919
function loadNodeList() {
@@ -261,8 +261,4 @@ var RED = (function() {
261261
RED.settings.init(loadEditor);
262262
})
263263
});
264-
265-
266-
return {
267-
};
268264
})();

editor/js/red.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright 2013, 2016 IBM Corp.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
**/
16+
var RED = {};

editor/templates/index.mst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<script src="vendor/ace/ace.js"></script>
164164
<script src="vendor/ace/ext-language_tools.js"></script>
165165
<script src="{{ asset.red }}"></script>
166+
<script src="{{ asset.main }}"></script>
166167

167168
</body>
168169
</html>

red/api/theme.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ var defaultContext = {
3131
image: "red/images/node-red.png"
3232
},
3333
asset: {
34-
red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js"
34+
red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js",
35+
main: (process.env.NODE_ENV == "development")? "red/main.js":"red/main.min.js",
36+
3537
}
3638
};
3739

0 commit comments

Comments
 (0)