From 1c3a97a71af18d8eb43f341ec16b10e31e338b64 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Wed, 2 Nov 2016 22:53:18 +0000 Subject: [PATCH] Make red.min.js a reusable library --- Gruntfile.js | 88 +++++++++++++++++++------------------- editor/js/main.js | 6 +-- editor/js/red.js | 16 +++++++ editor/templates/index.mst | 1 + red/api/theme.js | 4 +- 5 files changed, 66 insertions(+), 49 deletions(-) create mode 100644 editor/js/red.js diff --git a/Gruntfile.js b/Gruntfile.js index 4c25cd822..05890225d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -98,7 +98,7 @@ module.exports = function(grunt) { src: [ // Ensure editor source files are concatenated in // the right order - "editor/js/main.js", + "editor/js/red.js", "editor/js/events.js", "editor/js/i18n.js", "editor/js/settings.js", @@ -150,11 +150,6 @@ module.exports = function(grunt) { "public/vendor/vendor.css": [ // TODO: resolve relative resource paths in // bootstrap/FA/jquery - ], - "public/vendor/vendor-jquery.js": [ - "editor/vendor/jquery/js/jquery-1.11.3.min.js", - "editor/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js", - "editor/vendor/jquery/js/jquery.ui.touch-punch.min.js", ] } } @@ -162,7 +157,8 @@ module.exports = function(grunt) { uglify: { build: { files: { - 'public/red/red.min.js': 'public/red/red.js' + 'public/red/red.min.js': 'public/red/red.js', + 'public/red/main.min.js': 'public/red/main.js' } } }, @@ -193,7 +189,8 @@ module.exports = function(grunt) { attachCopyright: { js: { src: [ - 'public/red/red.min.js' + 'public/red/red.min.js', + 'public/red/main.min.js' ] }, css: { @@ -272,40 +269,45 @@ module.exports = function(grunt) { copy: { build: { - files:[{ - cwd: 'editor/images', - src: '**', - expand: true, - dest: 'public/red/images/' - }, - { - cwd: 'editor/vendor', - src: [ - 'ace/**', - //'bootstrap/css/**', - 'bootstrap/img/**', - 'jquery/css/**', - 'font-awesome/**' - ], - expand: true, - dest: 'public/vendor/' - }, - { - cwd: 'editor/icons', - src: '**', - expand: true, - dest: 'public/icons/' - }, - { - expand: true, - src: ['editor/index.html','editor/favicon.ico'], - dest: 'public/', - flatten: true - }, - { - src: 'CHANGELOG.md', - dest: 'public/red/about' - } + files:[ + { + src: 'editor/js/main.js', + dest: 'public/red/main.js' + }, + { + cwd: 'editor/images', + src: '**', + expand: true, + dest: 'public/red/images/' + }, + { + cwd: 'editor/vendor', + src: [ + 'ace/**', + //'bootstrap/css/**', + 'bootstrap/img/**', + 'jquery/css/**', + 'font-awesome/**' + ], + expand: true, + dest: 'public/vendor/' + }, + { + cwd: 'editor/icons', + src: '**', + expand: true, + dest: 'public/icons/' + }, + { + expand: true, + src: ['editor/index.html','editor/favicon.ico'], + dest: 'public/', + flatten: true + }, + { + src: 'CHANGELOG.md', + dest: 'public/red/about' + } ] }, release: { @@ -431,7 +433,7 @@ module.exports = function(grunt) { grunt.registerTask('build', 'Builds editor content', - ['clean:build','concat:build','concat:vendor','uglify:build','sass:build','jsonlint:messages','copy:build','attachCopyright']); + ['clean:build','concat:build','concat:vendor','copy:build','uglify:build','sass:build','jsonlint:messages','attachCopyright']); grunt.registerTask('dev', 'Developer mode: run node-red, watch for source changes and build/restart', diff --git a/editor/js/main.js b/editor/js/main.js index 436e3611f..22726bec0 100644 --- a/editor/js/main.js +++ b/editor/js/main.js @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -var RED = (function() { +(function() { function loadNodeList() { @@ -261,8 +261,4 @@ var RED = (function() { RED.settings.init(loadEditor); }) }); - - - return { - }; })(); diff --git a/editor/js/red.js b/editor/js/red.js new file mode 100644 index 000000000..0bcbc3c87 --- /dev/null +++ b/editor/js/red.js @@ -0,0 +1,16 @@ +/** + * Copyright 2013, 2016 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ +var RED = {}; diff --git a/editor/templates/index.mst b/editor/templates/index.mst index 6fa473c93..146cc866b 100644 --- a/editor/templates/index.mst +++ b/editor/templates/index.mst @@ -163,6 +163,7 @@ + diff --git a/red/api/theme.js b/red/api/theme.js index 74c765abb..22acc313b 100644 --- a/red/api/theme.js +++ b/red/api/theme.js @@ -31,7 +31,9 @@ var defaultContext = { image: "red/images/node-red.png" }, asset: { - red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js" + red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js", + main: (process.env.NODE_ENV == "development")? "red/main.js":"red/main.min.js", + } };