diff --git a/Gruntfile.js b/Gruntfile.js index 04273c683..ad46baee9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -93,6 +93,7 @@ module.exports = function(grunt) { // Ensure editor source files are concatenated in // the right order "editor/js/main.js", + "editor/js/events.js", "editor/js/i18n.js", "editor/js/settings.js", "editor/js/user.js", @@ -301,7 +302,7 @@ module.exports = function(grunt) { mode: '755' }, release: { - // Target-specific file/dir lists and/or options go here. + // Target-specific file/dir lists and/or options go here. src: [ path.resolve('<%= paths.dist %>/node-red-<%= pkg.version %>/nodes/core/hardware/nrgpio*') ] @@ -332,7 +333,7 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-chmod'); grunt.loadNpmTasks('grunt-jsonlint'); - + grunt.registerMultiTask('attachCopyright', function() { var files = this.data.src; var copyright = "/**\n"+ diff --git a/editor/js/events.js b/editor/js/events.js new file mode 100644 index 000000000..804027af9 --- /dev/null +++ b/editor/js/events.js @@ -0,0 +1,48 @@ +/** + * Copyright 2015 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. + **/ + + RED.events = (function() { + var handlers = {}; + + function on(evt,func) { + handlers[evt] = handlers[evt]||[]; + handlers[evt].push(func); + } + function off(evt,func) { + var handler = handlers[evt]; + if (handler) { + for (var i=0;i