1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge branch 'dev' into pr_2258

This commit is contained in:
Nick O'Leary 2019-08-21 12:52:58 +01:00
commit 8ccbd2d8f9
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
392 changed files with 17228 additions and 16987 deletions

View File

@ -2,6 +2,7 @@ sudo: false
language: node_js
matrix:
include:
- node_js: "12"
- node_js: "10"
script:
- ./node_modules/.bin/grunt && istanbul report text && ( cat coverage/lcov.info | $(npm get prefix)/bin/coveralls || true ) && rm -rf coverage

View File

@ -1,3 +1,51 @@
#### 1.0.0-beta.2: Beta Release
Runtime
- Fix length calculation when loading library file
#### 1.0.0-beta.1: Beta Release
Runtime
- Update runtime apis to support multiple libraries
- Add Node 12 to travis (allow_failures)
- Bump all dependencies Fixes #2152
Editor
- [BREAKING] complete overhaul of editor DOM/CSS structure
- [BREAKING] Get rid of Bootstrap
- Simplify index.mst to a single div to insert the editor
- Append node configs to div rather than body
- Only redraw node status when it has changed
- Minimise work done to calculate node label widths
- Allow script tags with src to reference esm modules
- Upgrade to jq 3.4.1 / jq-ui 1.12.1
- Allow editor language to be chosen in editor settings
- Only NLS status text that starts with a letter Fixes #2128
- Fix display of link node list within subflow Fixes #2140
- Blur the active element when closing edit dialog via action Fixes #2097
- Trigger change evnt on typedInput when type changes and options present Fixes #2160
- Move library import/export to single dialog
- Move type-library dialogs to new style dialog
- Fix node drag and drop animation
- let status be simple text if wanted
- Add workspace statusBar
- Complete refresh of German translations
- Fix memory leak in Debug sidebar #2163
- Introduce toggleButton and move flow-disabled to use it
- Allow RED.settings.get/set to use full property desc
- Add auto-refresh toggle to context sidebar
- Add build-custom-theme script
- Add RED.view.selectNodes api for node selection whilst editing
- Add node-select to typedInput
Nodes
- http request node: warn user if msg.requestTimeout == 0
- hide delay node reset label on deploy
- Fix CSV regex to treat strings starting e as text
- Add "don't parse numbers" option to csv node
- Add expand editor button to Template node
- Update catch/status nodes to use selectNodes api and treeList
#### 0.20.7: Maintenance Release
- Update jsonata to 1.6.5 which should fix #2183

View File

@ -145,11 +145,13 @@ module.exports = function(grunt) {
"packages/node_modules/@node-red/editor-client/src/js/ui/common/tabs.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/stack.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/typedInput.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/common/toggleButton.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/actions.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/deploy.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/diff.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/keyboard.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/workspaces.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/statusBar.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/view.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/view-navigator.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/view-tools.js",
@ -167,6 +169,7 @@ module.exports = function(grunt) {
"packages/node_modules/@node-red/editor-client/src/js/ui/library.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/notifications.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/search.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/actionList.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js",
"packages/node_modules/@node-red/editor-client/src/js/ui/userSettings.js",
@ -181,22 +184,22 @@ module.exports = function(grunt) {
vendor: {
files: {
"packages/node_modules/@node-red/editor-client/public/vendor/vendor.js": [
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery-1.11.3.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/bootstrap/js/bootstrap.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery-3.4.1.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery-migrate-3.0.1.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery-ui.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jquery/js/jquery.ui.touch-punch.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/marked/marked.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/d3/d3.v3.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/i18next/i18next.min.js"
],
"packages/node_modules/@node-red/editor-client/public/vendor/vendor.css": [
// TODO: resolve relative resource paths in
// bootstrap/FA/jquery
],
"packages/node_modules/@node-red/editor-client/public/vendor/jsonata/jsonata.min.js": [
"packages/node_modules/@node-red/editor-client/src/vendor/i18next/i18next.min.js",
"node_modules/jsonata/jsonata-es5.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js"
"packages/node_modules/@node-red/editor-client/src/vendor/jsonata/formatter.js",
"packages/node_modules/@node-red/editor-client/src/vendor/ace/ace.js",
"packages/node_modules/@node-red/editor-client/src/vendor/ace/ext-language_tools.js",
],
// "packages/node_modules/@node-red/editor-client/public/vendor/vendor.css": [
// // TODO: resolve relative resource paths in
// // bootstrap/FA/jquery
// ],
"packages/node_modules/@node-red/editor-client/public/vendor/ace/worker-jsonata.js": [
"node_modules/jsonata/jsonata-es5.min.js",
"packages/node_modules/@node-red/editor-client/src/vendor/jsonata/worker-jsonata.js"
@ -222,10 +225,6 @@ module.exports = function(grunt) {
files: [{
dest: 'packages/node_modules/@node-red/editor-client/public/red/style.min.css',
src: 'packages/node_modules/@node-red/editor-client/src/sass/style.scss'
},
{
dest: 'packages/node_modules/@node-red/editor-client/public/vendor/bootstrap/css/bootstrap.min.css',
src: 'packages/node_modules/@node-red/editor-client/src/vendor/bootstrap/css/bootstrap.css'
}]
}
},
@ -352,9 +351,7 @@ module.exports = function(grunt) {
cwd: 'packages/node_modules/@node-red/editor-client/src/vendor',
src: [
'ace/**',
//'bootstrap/css/**',
'bootstrap/img/**',
'jquery/css/**',
'jquery/css/base/**',
'font-awesome/**'
],
expand: true,
@ -499,7 +496,9 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-chmod');
grunt.loadNpmTasks('grunt-jsonlint');
grunt.loadNpmTasks('grunt-mocha-istanbul');
grunt.loadNpmTasks('grunt-webdriver');
if (fs.existsSync(path.join("node_modules", "grunt-webdriver"))) {
grunt.loadNpmTasks('grunt-webdriver');
}
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-jsdoc-to-markdown');
grunt.loadNpmTasks('grunt-npm-command');
@ -558,8 +557,8 @@ module.exports = function(grunt) {
});
grunt.registerTask('verifyUiTestDependencies', function() {
if (!fs.existsSync(path.join("node_modules", "chromedriver"))) {
grunt.fail.fatal('You need to run "npm install chromedriver@2" before running UI test.');
if (!fs.existsSync(path.join("node_modules", "grunt-webdriver"))) {
grunt.fail.fatal('You need to install the UI test dependencies first.\nUse the script in "scripts/install-ui-test-dependencies.sh"');
return false;
}
});
@ -582,9 +581,15 @@ module.exports = function(grunt) {
'Runs code style check on editor code',
['jshint:editor']);
grunt.registerTask('test-ui',
'Builds editor content then runs unit tests on editor ui',
['verifyUiTestDependencies','build','jshint:editor','webdriver:all']);
if (!fs.existsSync(path.join("node_modules", "grunt-webdriver"))) {
grunt.registerTask('test-ui',
'Builds editor content then runs unit tests on editor ui',
['verifyUiTestDependencies']);
} else {
grunt.registerTask('test-ui',
'Builds editor content then runs unit tests on editor ui',
['verifyUiTestDependencies','build','jshint:editor','webdriver:all']);
}
grunt.registerTask('test-nodes',
'Runs unit tests on core nodes',

View File

@ -1,6 +1,6 @@
{
"name": "node-red",
"version": "0.20.7",
"version": "1.0.0-beta.2",
"description": "A visual tool for wiring the Internet of Things",
"homepage": "http://nodered.org",
"license": "Apache-2.0",
@ -42,7 +42,7 @@
"fs.notify": "0.0.4",
"hash-sum": "2.0.0",
"https-proxy-agent": "2.2.1",
"i18next": "15.1.0",
"i18next": "15.1.2",
"iconv-lite": "0.5.0",
"is-utf8": "0.2.1",
"js-yaml": "3.13.1",
@ -54,12 +54,9 @@
"mqtt": "2.18.8",
"multer": "1.4.1",
"mustache": "3.0.1",
"node-red-node-email": "^1.6.2",
"node-red-node-feedparser": "^0.1.14",
"node-red-node-rbe": "^0.2.4",
"node-red-node-sentiment": "^0.1.3",
"node-red-node-tail": "^0.0.2",
"node-red-node-twitter": "^1.1.5",
"nopt": "4.0.1",
"oauth2orize": "1.11.0",
"on-headers": "1.0.2",
@ -98,7 +95,6 @@
"grunt-npm-command": "~0.1.2",
"grunt-sass": "~2.0.0",
"grunt-simple-mocha": "~0.4.1",
"grunt-webdriver": "^2.0.3",
"http-proxy": "^1.16.2",
"istanbul": "0.4.5",
"minami": "1.2.3",
@ -108,11 +104,7 @@
"sinon": "1.17.7",
"stoppable": "^1.1.0",
"supertest": "3.4.2",
"wdio-chromedriver-service": "^0.1.5",
"wdio-mocha-framework": "^0.6.4",
"wdio-spec-reporter": "^0.1.5",
"webdriverio": "^4.14.1",
"node-red-node-test-helper": "^0.2.2",
"node-red-node-test-helper": "^0.2.3",
"jsdoc-nr-template": "node-red/jsdoc-nr-template"
},
"engines": {

View File

@ -30,7 +30,8 @@ module.exports = {
scope: req.params.scope,
id: req.params.id,
key: req.params[0],
store: req.query['store']
store: req.query['store'],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.context.getValue(opts).then(function(result) {
res.json(result);
@ -45,7 +46,8 @@ module.exports = {
scope: req.params.scope,
id: req.params.id,
key: req.params[0],
store: req.query['store']
store: req.query['store'],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.context.delete(opts).then(function(result) {
res.status(204).end();

View File

@ -24,7 +24,8 @@ module.exports = {
get: function(req,res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.getFlow(opts).then(function(result) {
return res.json(result);
@ -35,7 +36,8 @@ module.exports = {
post: function(req,res) {
var opts = {
user: req.user,
flow: req.body
flow: req.body,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.addFlow(opts).then(function(id) {
return res.json({id:id});
@ -47,7 +49,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
flow: req.body
flow: req.body,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.updateFlow(opts).then(function(id) {
return res.json({id:id});
@ -58,7 +61,8 @@ module.exports = {
delete: function(req,res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.deleteFlow(opts).then(function() {
res.status(204).end();

View File

@ -27,7 +27,8 @@ module.exports = {
return res.status(400).json({code:"invalid_api_version", message:"Invalid API Version requested"});
}
var opts = {
user: req.user
user: req.user,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.flows.getFlows(opts).then(function(result) {
if (version === "v1") {
@ -46,7 +47,8 @@ module.exports = {
}
var opts = {
user: req.user,
deploymentType: req.get("Node-RED-Deployment-Type")||"full"
deploymentType: req.get("Node-RED-Deployment-Type")||"full",
req: apiUtils.getRequestLogObject(req)
}
if (opts.deploymentType !== 'reload') {

View File

@ -24,7 +24,8 @@ module.exports = {
},
getAll: function(req,res) {
var opts = {
user: req.user
user: req.user,
req: apiUtils.getRequestLogObject(req)
}
if (req.get("accept") == "application/json") {
runtimeAPI.nodes.getNodeList(opts).then(function(list) {
@ -42,7 +43,8 @@ module.exports = {
var opts = {
user: req.user,
module: req.body.module,
version: req.body.version
version: req.body.version,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.addModule(opts).then(function(info) {
res.json(info);
@ -54,7 +56,8 @@ module.exports = {
delete: function(req,res) {
var opts = {
user: req.user,
module: req.params[0]
module: req.params[0],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.removeModule(opts).then(function() {
res.status(204).end();
@ -66,7 +69,8 @@ module.exports = {
getSet: function(req,res) {
var opts = {
user: req.user,
id: req.params[0] + "/" + req.params[2]
id: req.params[0] + "/" + req.params[2],
req: apiUtils.getRequestLogObject(req)
}
if (req.get("accept") === "application/json") {
runtimeAPI.nodes.getNodeInfo(opts).then(function(result) {
@ -87,7 +91,8 @@ module.exports = {
getModule: function(req,res) {
var opts = {
user: req.user,
module: req.params[0]
module: req.params[0],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.getModuleInfo(opts).then(function(result) {
res.send(result);
@ -106,7 +111,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params[0] + "/" + req.params[2],
enabled: body.enabled
enabled: body.enabled,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.setNodeSetState(opts).then(function(result) {
res.send(result);
@ -125,7 +131,8 @@ module.exports = {
var opts = {
user: req.user,
module: req.params[0],
enabled: body.enabled
enabled: body.enabled,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.setModuleState(opts).then(function(result) {
res.send(result);
@ -139,7 +146,8 @@ module.exports = {
var opts = {
user: req.user,
module: req.params[0],
lang: req.query.lng
lang: req.query.lng,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.getModuleCatalog(opts).then(function(result) {
res.json(result);
@ -152,7 +160,8 @@ module.exports = {
getModuleCatalogs: function(req,res) {
var opts = {
user: req.user,
lang: req.query.lng
lang: req.query.lng,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.getModuleCatalogs(opts).then(function(result) {
res.json(result);
@ -164,7 +173,8 @@ module.exports = {
getIcons: function(req,res) {
var opts = {
user: req.user
user: req.user,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.nodes.getIconList(opts).then(function(list) {
res.json(list);

View File

@ -25,8 +25,8 @@ var auth = require("../auth");
var nodes = require("../admin/nodes"); // TODO: move /icons into here
var needsPermission;
var runtimeAPI;
var log = require("@node-red/util").log; // TODO: separate module
var i18n = require("@node-red/util").i18n; // TODO: separate module
var log = require("@node-red/util").log;
var i18n = require("@node-red/util").i18n;
var apiUtil = require("../util");
@ -93,9 +93,8 @@ module.exports = {
// Library
var library = require("./library");
library.init(runtimeAPI);
editorApp.get("/library/flows",needsPermission("library.read"),library.getAll,apiUtil.errorHandler);
editorApp.get(/library\/([^\/]+)(?:$|\/(.*))/,needsPermission("library.read"),library.getEntry);
editorApp.post(/library\/([^\/]+)\/(.*)/,needsPermission("library.write"),library.saveEntry);
editorApp.get(/library\/([^\/]+)\/([^\/]+)(?:$|\/(.*))/,needsPermission("library.read"),library.getEntry);
editorApp.post(/library\/([^\/]+)\/([^\/]+)\/(.*)/,needsPermission("library.write"),library.saveEntry);
// Credentials

View File

@ -25,23 +25,12 @@ module.exports = {
init: function(_runtimeAPI) {
runtimeAPI = _runtimeAPI;
},
getAll: function(req,res) {
var opts = {
user: req.user,
type: 'flows'
}
runtimeAPI.library.getEntries(opts).then(function(result) {
res.json(result);
}).catch(function(err) {
apiUtils.rejectHandler(req,res,err);
});
},
getEntry: function(req,res) {
var opts = {
user: req.user,
type: req.params[0],
path: req.params[1]||""
library: req.params[0],
type: req.params[1],
path: req.params[2]||""
}
runtimeAPI.library.getEntry(opts).then(function(result) {
if (typeof result === "string") {
@ -62,8 +51,9 @@ module.exports = {
saveEntry: function(req,res) {
var opts = {
user: req.user,
type: req.params[0],
path: req.params[1]||""
library: req.params[0],
type: req.params[1],
path: req.params[2]||""
}
// TODO: horrible inconsistencies between flows and all other types
if (opts.type === "flows") {

View File

@ -22,7 +22,8 @@ var needsPermission = require("../auth").needsPermission;
function listProjects(req,res) {
var opts = {
user: req.user
user: req.user,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.listProjects(opts).then(function(result) {
res.json(result);
@ -33,7 +34,8 @@ function listProjects(req,res) {
function getProject(req,res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getProject(opts).then(function(data) {
if (data) {
@ -49,7 +51,8 @@ function getProjectStatus(req,res) {
var opts = {
user: req.user,
id: req.params.id,
remote: req.query.remote
remote: req.query.remote,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getStatus(opts).then(function(data){
if (data) {
@ -64,7 +67,8 @@ function getProjectStatus(req,res) {
function getProjectRemotes(req,res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getRemotes(opts).then(function(data) {
res.json(data);
@ -98,7 +102,8 @@ module.exports = {
app.post("/", needsPermission("projects.write"), function(req,res) {
var opts = {
user: req.user,
project: req.body
project: req.body,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.createProject(opts).then(function(result) {
res.json(result);
@ -112,7 +117,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
project: req.body
project: req.body,
req: apiUtils.getRequestLogObject(req)
}
if (req.body.active) {
@ -150,7 +156,8 @@ module.exports = {
app.delete("/:id", needsPermission("projects.write"), function(req,res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.deleteProject(opts).then(function() {
res.status(204).end();
@ -168,7 +175,8 @@ module.exports = {
app.get("/:id/files", needsPermission("projects.read"), function(req,res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getFiles(opts).then(function(data) {
res.json(data);
@ -185,7 +193,8 @@ module.exports = {
user: req.user,
id: req.params.id,
path: req.params[0],
tree: req.params.treeish
tree: req.params.treeish,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getFile(opts).then(function(data) {
res.json({content:data});
@ -199,7 +208,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
path: req.params[0]
path: req.params[0],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.revertFile(opts).then(function() {
@ -214,7 +224,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
path: req.params[0]
path: req.params[0],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.stageFile(opts).then(function() {
getProjectStatus(req,res);
@ -228,7 +239,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
path: req.body.files
path: req.body.files,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.stageFile(opts).then(function() {
getProjectStatus(req,res);
@ -242,7 +254,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
message: req.body.message
message: req.body.message,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.commit(opts).then(function() {
getProjectStatus(req,res);
@ -256,7 +269,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
path: req.params[0]
path: req.params[0],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.unstageFile(opts).then(function() {
getProjectStatus(req,res);
@ -269,7 +283,8 @@ module.exports = {
app.delete("/:id/stage", needsPermission("projects.write"), function(req, res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.unstageFile(opts).then(function() {
getProjectStatus(req,res);
@ -284,7 +299,8 @@ module.exports = {
user: req.user,
id: req.params.id,
path: req.params[0],
type: req.params.type
type: req.params.type,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getFileDiff(opts).then(function(data) {
res.json({
@ -301,7 +317,8 @@ module.exports = {
user: req.user,
id: req.params.id,
limit: req.query.limit || 20,
before: req.query.before
before: req.query.before,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getCommits(opts).then(function(data) {
res.json(data);
@ -315,7 +332,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
sha: req.params.sha
sha: req.params.sha,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getCommit(opts).then(function(data) {
res.json({commit:data});
@ -330,7 +348,8 @@ module.exports = {
user: req.user,
id: req.params.id,
remote: req.params[0],
track: req.query.u
track: req.query.u,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.push(opts).then(function(data) {
res.status(204).end();
@ -346,7 +365,8 @@ module.exports = {
id: req.params.id,
remote: req.params[0],
track: req.query.setUpstream,
allowUnrelatedHistories: req.query.allowUnrelatedHistories
allowUnrelatedHistories: req.query.allowUnrelatedHistories,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.pull(opts).then(function(data) {
res.status(204).end();
@ -359,7 +379,8 @@ module.exports = {
app.delete("/:id/merge", needsPermission("projects.write"), function(req, res) {
var opts = {
user: req.user,
id: req.params.id
id: req.params.id,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.abortMerge(opts).then(function() {
res.status(204).end();
@ -374,7 +395,8 @@ module.exports = {
user: req.user,
id: req.params.id,
path: req.params[0],
resolution: req.body.resolutions
resolution: req.body.resolutions,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.resolveMerge(opts).then(function() {
res.status(204).end();
@ -388,7 +410,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
remote: false
remote: false,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getBranches(opts).then(function(data) {
res.json(data);
@ -403,7 +426,8 @@ module.exports = {
user: req.user,
id: req.params.id,
branch: req.params.branchName,
force: !!req.query.force
force: !!req.query.force,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.deleteBranch(opts).then(function(data) {
res.status(204).end();
@ -417,7 +441,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
remote: true
remote: true,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getBranches(opts).then(function(data) {
res.json(data);
@ -431,7 +456,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
branch: req.params[0]
branch: req.params[0],
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.getBranchStatus(opts).then(function(data) {
res.json(data);
@ -446,7 +472,8 @@ module.exports = {
user: req.user,
id: req.params.id,
branch: req.body.name,
create: req.body.create
create: req.body.create,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.setBranch(opts).then(function(data) {
res.json(data);
@ -463,7 +490,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
remote: req.body
remote: req.body,
req: apiUtils.getRequestLogObject(req)
}
if (/^https?:\/\/[^/]+@/i.test(req.body.url)) {
res.status(400).json({error:"unexpected_error", message:"Git http url must not include username/password"});
@ -481,7 +509,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
remote: req.params.remoteName
remote: req.params.remoteName,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.removeRemote(opts).then(function(data) {
getProjectRemotes(req,res);
@ -497,7 +526,8 @@ module.exports = {
var opts = {
user: req.user,
id: req.params.id,
remote: remote
remote: remote,
req: apiUtils.getRequestLogObject(req)
}
runtimeAPI.projects.updateRemote(opts).then(function() {
res.status(204).end();

View File

@ -19,6 +19,8 @@ var sshkeys = require("./sshkeys");
var theme = require("./theme");
var clone = require("clone");
var i18n = require("@node-red/util").i18n
function extend(target, source) {
var keys = Object.keys(source);
var i = keys.length;
@ -53,12 +55,14 @@ module.exports = {
user: req.user
}
runtimeAPI.settings.getRuntimeSettings(opts).then(function(result) {
result.editorTheme = result.editorTheme||{};
var themeSettings = theme.settings();
if (themeSettings) {
// result.editorTheme may already exist with the palette
// disabled. Need to merge that into the receive settings
result.editorTheme = extend(clone(themeSettings),result.editorTheme||{});
result.editorTheme = extend(clone(themeSettings),result.editorTheme);
}
result.editorTheme.languages = i18n.availableLanguages("editor");
res.json(result);
});
},

View File

@ -28,7 +28,7 @@ var defaultContext = {
},
header: {
title: "Node-RED",
image: "red/images/node-red.png"
image: "red/images/node-red.svg"
},
asset: {
red: (process.env.NODE_ENV == "development")? "red/red.js":"red/red.min.js",
@ -169,6 +169,9 @@ module.exports = {
}
}
}
themeApp.get("/", function(req,res) {
res.json(themeContext);
})
if (theme.hasOwnProperty("menu")) {
themeSettings.menu = theme.menu;

View File

@ -25,7 +25,7 @@ var theme = require("./theme");
var runtimeAPI;
var editorClientDir = path.dirname(require.resolve("@node-red/editor-client"));
var defaultNodeIcon = path.join(editorClientDir,"public","red","images","icons","arrow-in.png");
var defaultNodeIcon = path.join(editorClientDir,"public","red","images","icons","arrow-in.svg");
var editorTemplatePath = path.join(editorClientDir,"templates","index.mst");
var editorTemplate;

View File

@ -47,5 +47,12 @@ module.exports = {
code: err.code||"unexpected_error",
message: err.message||err.toString()
});
},
getRequestLogObject: function(req) {
return {
user: req.user,
path: req.path,
ip: (req.headers && req.headers['x-forwarded-for']) || (req.connection && req.connection.remoteAddress) || undefined
}
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@node-red/editor-api",
"version": "0.20.7",
"version": "1.0.0-beta.2",
"license": "Apache-2.0",
"main": "./lib/index.js",
"repository": {
@ -16,8 +16,8 @@
}
],
"dependencies": {
"@node-red/util": "0.20.7",
"@node-red/editor-client": "0.20.7",
"@node-red/util": "1.0.0-beta.2",
"@node-red/editor-client": "1.0.0-beta.2",
"bcryptjs": "2.4.3",
"body-parser": "1.19.0",
"clone": "2.1.2",

View File

@ -26,8 +26,7 @@
"status" : "Status",
"enabled" : "Aktiviert",
"disabled" : "Inaktiviert",
"info" : "Beschreibung",
"tip" : "Beschreibung akzeptiert Markdown und wird auf der Registerkarte Info angezeigt."
"info" : "Beschreibung"
},
"menu" : {
"label" : {
@ -55,9 +54,6 @@
"export" : "Exportieren",
"search" : "Flows durchsuchen",
"searchInput" : "durchsuchen Sie Ihre Flows",
"clipboard" : "Zwischenablage",
"library" : "Bibliothek",
"examples" : "Beispiele",
"subflows" : "Subflow",
"createSubflow" : "Subflow erstellen",
"selectionToSubflow" : "Auswahl für Subflow",
@ -136,8 +132,8 @@
}
},
"clipboard" : {
"clipboard" : "Zwischenablage",
"nodes" : "Nodes",
"selectNodes" : "Wählen Sie den Text oben aus, und kopieren Sie die Datei in die Zwischenablage.",
"pasteNodes" : "Nodes hier einfügen",
"importNodes" : "Nodes importieren",
"exportNodes" : "Nodes in Zwischenablage exportieren",
@ -240,7 +236,6 @@
"deleteSubflow" : "Subflow löschen",
"info" : "Beschreibung",
"category" : "Kategorie",
"format" : "Markdown-Format",
"errors" : {
"noNodesSelected" : "<strong> Subflow kann nicht erstellt werden </strong>: Es wurden keine Nodes ausgewählt.",
"multipleInputsToSelection" : "<strong> Subflow kann nicht erstellt werden </strong>: Mehrere Eingaben zur Auswahl"
@ -297,22 +292,19 @@
"managePalette" : "Palette verwalten"
},
"library" : {
"library" : "Bibliothek",
"openLibrary" : "Bibliothek öffnen ...",
"saveToLibrary" : "In Bibliothek speichern ...",
"typeLibrary" : "__type__, Bibliothek",
"unnamedType" : "Unbenannt __type__",
"exportToLibrary" : "Node in Bibliothek exportieren",
"dialogSaveOverwrite" : "Ein __libraryType__ mit dem Namen __libraryName__ ist bereits vorhanden. Überschreiben?",
"invalidFilename" : "Ungültiger Dateiname",
"savedNodes" : "Gespeicherte Nodes",
"savedType" : "Gespeichert __type__",
"saveFailed" : "Speichern fehlgeschlagen: __message__",
"filename" : "Name der Datei",
"folder" : "Ordner",
"filenamePlaceholder" : "Datei",
"fullFilenamePlaceholder" : "a/b/Datei",
"folderPlaceholder" : "a/b",
"breadcrumb" : "Bibliothek"
"types": {
"examples" : "Beispiele"
}
},
"palette" : {
"noInfo" : "Keine Informationen verfügbar",
@ -826,4 +818,4 @@
"code" : "code"
}
}
}
}

View File

@ -28,7 +28,8 @@
"status": "Status",
"enabled": "Enabled",
"disabled":"Disabled",
"info": "Description"
"info": "Description",
"selectNodes": "Click nodes to select"
},
"menu": {
"label": {
@ -42,7 +43,9 @@
"defaultDir": "Default",
"ltr": "Left-to-right",
"rtl": "Right-to-left",
"auto": "Contextual"
"auto": "Contextual",
"language": "Language",
"browserDefault": "Browser default"
},
"sidebar": {
"show": "Show sidebar"
@ -59,9 +62,6 @@
"export": "Export",
"search": "Search flows",
"searchInput": "search your flows",
"clipboard": "Clipboard",
"library": "Library",
"examples": "Examples",
"subflows": "Subflows",
"createSubflow": "Create Subflow",
"selectionToSubflow": "Selection to Subflow",
@ -154,6 +154,7 @@
}
},
"clipboard": {
"clipboard": "Clipboard",
"nodes": "Nodes",
"node": "__count__ node",
"node_plural": "__count__ nodes",
@ -163,7 +164,6 @@
"flow_plural": "__count__ flows",
"subflow": "__count__ subflow",
"subflow_plural": "__count__ subflows",
"selectNodes": "Select the text above and copy to the clipboard.",
"pasteNodes": "Paste flow json or",
"selectFile": "select a file to import",
"importNodes": "Import nodes",
@ -182,7 +182,11 @@
"all":"all flows",
"compact":"compact",
"formatted":"formatted",
"copy": "Export to clipboard"
"copy": "Copy to clipboard",
"export": "Export to library",
"exportAs": "Export as",
"overwrite": "Replace",
"exists": "<p><b>\"__file__\"</b> already exists.</p><p>Do you want to replace it?</p>"
},
"import": {
"import": "Import to",
@ -306,6 +310,7 @@
"addNewType": "Add new __type__...",
"nodeProperties": "node properties",
"label": "Label",
"color": "Color",
"portLabels": "Port labels",
"labelInputs": "Inputs",
"labelOutputs": "Outputs",
@ -317,8 +322,43 @@
"description": "Description",
"show": "Show",
"hide": "Hide",
"locale": "Select UI Language",
"icon": "Icon",
"inputType": "Input type",
"inputs" : {
"input": "input",
"select": "select",
"checkbox": "checkbox",
"spinner": "spinner",
"none": "none",
"hidden": "hide property"
},
"types": {
"str": "string",
"num": "number",
"bool": "bool",
"json": "JSON",
"bin": "buffer",
"env": "env variable"
},
"menu": {
"input": "input",
"select": "select",
"checkbox": "checkbox",
"spinner": "spinner",
"hidden": "label only"
},
"select": {
"label": "Label",
"value": "Value"
},
"spinner": {
"min": "Minimum",
"max": "Maximum"
},
"errors": {
"scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it"
"scopeChange": "Changing the scope will make it unavailable to nodes in other flows that use it",
"invalidProperties": "Invalid properties:"
}
},
"keyboard": {
@ -346,25 +386,26 @@
"pasteNode": "Paste nodes",
"undoChange": "Undo the last change performed",
"searchBox": "Open search box",
"managePalette": "Manage palette"
"managePalette": "Manage palette",
"actionList":"Action list"
},
"library": {
"library": "Library",
"openLibrary": "Open Library...",
"saveToLibrary": "Save to Library...",
"typeLibrary": "__type__ library",
"unnamedType": "Unnamed __type__",
"exportToLibrary": "Export nodes to library",
"exportedToLibrary": "Nodes exported to library",
"dialogSaveOverwrite": "A __libraryType__ called __libraryName__ already exists. Overwrite?",
"invalidFilename": "Invalid filename",
"savedNodes": "Saved nodes",
"savedType": "Saved __type__",
"saveFailed": "Save failed: __message__",
"filename": "Filename",
"folder": "Folder",
"filenamePlaceholder": "file",
"fullFilenamePlaceholder": "a/b/file",
"folderPlaceholder": "a/b",
"breadcrumb": "Library"
"newFolder": "New folder",
"types": {
"local": "Local",
"examples": "Examples"
}
},
"palette": {
"noInfo": "no information available",
@ -525,7 +566,10 @@
"node": "Node",
"flow": "Flow",
"global": "Global",
"deleteConfirm": "Are you sure you want to delete this item?"
"deleteConfirm": "Are you sure you want to delete this item?",
"autoRefresh": "Auto-refresh",
"refrsh": "Refresh",
"delete": "Delete"
},
"palette": {
"name": "Palette management",
@ -726,9 +770,21 @@
"jsEditor": {
"title": "JavaScript editor"
},
"textEditor": {
"title": "Text editor"
},
"jsonEditor": {
"title": "JSON editor",
"format": "format JSON"
"format": "format JSON",
"rawMode": "Edit JSON",
"uiMode": "Visual editor",
"insertAbove": "Insert above",
"insertBelow": "Insert below",
"addItem": "Add item",
"copyPath": "Copy path to item",
"expandItems": "Expand items",
"collapseItems": "Collapse items",
"duplicate": "Duplicate"
},
"markdownEditor": {
"title": "Markdown editor",
@ -918,8 +974,17 @@
},
"editor-tab": {
"properties": "Properties",
"envProperties": "Environment Variables",
"description": "Description",
"appearance": "Appearance",
"env": "Environment Variables"
"preview": "UI Preview",
"defaultValue": "Default value"
},
"languages" : {
"de": "German",
"en-US": "English",
"ja": "Japanese",
"ko": "Korean",
"zh-CN": "Chinese(Simplified)"
}
}

View File

@ -28,7 +28,8 @@
"status": "状態",
"enabled": "有効",
"disabled": "無効",
"info": "詳細"
"info": "詳細",
"selectNodes": "ノードをクリックして選択"
},
"menu": {
"label": {
@ -42,7 +43,9 @@
"defaultDir": "標準",
"ltr": "左から右",
"rtl": "右から左",
"auto": "文脈"
"auto": "文脈",
"language": "表示言語",
"browserDefault": "ブラウザのデフォルト"
},
"sidebar": {
"show": "サイドバーを表示"
@ -59,9 +62,6 @@
"export": "書き出し",
"search": "ノードを検索",
"searchInput": "ノードを検索",
"clipboard": "クリップボード",
"library": "ライブラリ",
"examples": "サンプル",
"subflows": "サブフロー",
"createSubflow": "サブフローを作成",
"selectionToSubflow": "選択部分をサブフロー化",
@ -80,7 +80,7 @@
"projects-new": "新規",
"projects-open": "開く",
"projects-settings": "設定",
"showNodeLabelDefault": "追加したノードのラベルを表示する"
"showNodeLabelDefault": "追加したノードのラベルを表示"
}
},
"actions": {
@ -154,6 +154,7 @@
}
},
"clipboard": {
"clipboard": "クリップボード",
"nodes": "ノード",
"node": "__count__ 個のノード",
"node_plural": "__count__ 個のノード",
@ -163,7 +164,6 @@
"flow_plural": "__count__ 個のフロー",
"subflow": "__count__ 個のサブフロー",
"subflow_plural": "__count__ 個のサブフロー",
"selectNodes": "上のテキストを選択し、クリップボードへコピーしてください",
"pasteNodes": "JSON形式のフローデータを貼り付けてください",
"selectFile": "読み込むファイルを選択してください",
"importNodes": "フローをクリップボートから読み込み",
@ -182,7 +182,11 @@
"all": "全てのタブ",
"compact": "インデントのないJSONフォーマット",
"formatted": "インデント付きのJSONフォーマット",
"copy": "書き出し"
"copy": "書き出し",
"export": "ライブラリに書き出し",
"exportAs": "書き出し先",
"overwrite": "更新",
"exists": "<p><b>\"__file__\"</b>は既に存在します。</p><p>更新しますか?</p>"
},
"import": {
"import": "読み込み先",
@ -306,6 +310,7 @@
"addNewType": "新規に __type__ を追加...",
"nodeProperties": "プロパティ",
"label": "ラベル",
"color": "色",
"portLabels": "ポートラベル",
"labelInputs": "入力",
"labelOutputs": "出力",
@ -317,8 +322,45 @@
"description": "詳細",
"show": "表示",
"hide": "非表示",
"locale": "UI言語の選択",
"icon": "記号",
"inputType": "入力形式",
"previewUI": "UI確認",
"previewOK": "確認OK",
"inputs" : {
"input": "入力",
"select": "メニュー",
"checkbox": "チェックボックス",
"spinner": "スピナー",
"none": "無し",
"hidden": "非表示"
},
"types": {
"str": "文字列",
"num": "数値",
"bool": "真偽",
"json": "JSON",
"bin": "バッファ",
"env": "環境変数"
},
"menu": {
"input": "入力",
"select": "選択",
"checkbox": "チェックボックス",
"spinner": "数値",
"hidden": "ラベルのみ"
},
"select": {
"label": "ラベル",
"value": "値"
},
"spinner": {
"min": "最小値",
"max": "最大値"
},
"errors": {
"scopeChange": "スコープの変更は、他のフローで使われているノードを無効にします"
"scopeChange": "スコープの変更は、他のフローで使われているノードを無効にします",
"invalidProperties": "プロパティが不正です:"
}
},
"keyboard": {
@ -346,25 +388,26 @@
"pasteNode": "ノードを貼り付け",
"undoChange": "変更操作を戻す",
"searchBox": "ノードを検索",
"managePalette": "パレットの管理"
"managePalette": "パレットの管理",
"actionList": "動作一覧"
},
"library": {
"library": "ライブラリ",
"openLibrary": "ライブラリを開く",
"saveToLibrary": "ライブラリへ保存",
"typeLibrary": "__type__ ライブラリ",
"unnamedType": "名前なし __type__",
"exportToLibrary": "ライブラリへフローを書き出す",
"exportedToLibrary": "ライブラリにノードを書き出しました",
"dialogSaveOverwrite": "__libraryName__ という __libraryType__ は既に存在しています 上書きしますか?",
"invalidFilename": "不正なファイル名",
"savedNodes": "フローを保存しました",
"savedType": "__type__ を保存しました",
"saveFailed": "保存に失敗しました: __message__",
"filename": "ファイル名",
"folder": "フォルダ",
"filenamePlaceholder": "ファイル",
"fullFilenamePlaceholder": "a/b/file",
"folderPlaceholder": "a/b",
"breadcrumb": "ライブラリ"
"newFolder": "新規フォルダ",
"types": {
"local": "ローカル",
"examples": "サンプル"
}
},
"palette": {
"noInfo": "情報がありません",
@ -522,10 +565,13 @@
"none": "選択されていません",
"refresh": "読み込みのため更新してください",
"empty": "データが存在しません",
"node": "Node",
"flow": "Flow",
"global": "Global",
"deleteConfirm": "データを削除しても良いですか?"
"node": "ノード",
"flow": "フロー",
"global": "グローバル",
"deleteConfirm": "データを削除しても良いですか?",
"autoRefresh": "自動更新",
"refrsh": "更新",
"delete": "削除"
},
"palette": {
"name": "パレットの管理",
@ -725,9 +771,21 @@
"jsEditor": {
"title": "JavaScriptエディタ"
},
"textEditor": {
"title": "テキストエディタ"
},
"jsonEditor": {
"title": "JSONエディタ",
"format": "JSONフォーマット"
"format": "JSONフォーマット",
"rawMode": "JSONを編集",
"uiMode": "ビジュアルエディタ",
"insertAbove": "上に挿入",
"insertBelow": "下に挿入",
"addItem": "要素を追加",
"copyPath": "要素のパスをコピー",
"expandItems": "要素を展開",
"collapseItems": "要素を折り畳む",
"duplicate": "複製"
},
"markdownEditor": {
"title": "マークダウンエディタ",
@ -917,8 +975,17 @@
},
"editor-tab": {
"properties": "プロパティ",
"envProperties": "環境変数",
"description": "説明",
"appearance": "外観",
"env": "環境変数"
"preview": "UIプレビュー",
"defaultValue": "デフォルト値"
},
"languages": {
"de": "ドイツ語",
"en-US": "英語",
"ja": "日本語",
"ko": "韓国語",
"zh-CN": "中国語(簡体)"
}
}

View File

@ -58,9 +58,6 @@
"export": "내보내기",
"search": "플로우 겅색",
"searchInput": "플로우 검색",
"clipboard": "클립보드",
"library": "라이브러리",
"examples": "예시",
"subflows": "보조 플로우",
"createSubflow": "보조 플로우 생성",
"selectionToSubflow": "보조 플로우 선택",
@ -148,6 +145,7 @@
}
},
"clipboard": {
"clipboard": "클립보드",
"nodes": "노드",
"node": "__count__ 개의 노드",
"node_plural": "__count__ 개의 노드",
@ -157,7 +155,6 @@
"flow_plural": "__count__ 개의 플로우",
"subflow": "__count__ 개의 서브 플로우",
"subflow_plural": "__count__ 개의 서브 플로우",
"selectNodes": "텍스트를 선택하고 클립보드에 복사하세요",
"pasteNodes": "여기에 노드를 붙여넣기 하세요",
"selectFile": "불러올 파일을 선택하세요",
"importNodes": "노드 불러오기",
@ -276,7 +273,6 @@
"deleteSubflow": "서브 플로우 삭제",
"info": "상세내역",
"category": "카테고리",
"format": "Markdown 형식",
"errors": {
"noNodesSelected": "<strong>서브 플로우를 생성할 수 없습니다</strong> : 노드가 선택되지 않았습니다",
"multipleInputsToSelection": "<strong>서브 플로우를 생성할 수 없습니다</strong> : 복수의 입력이 선택되었습니다"
@ -338,22 +334,19 @@
"managePalette": "팔렛트 관리"
},
"library": {
"library": "라이브러리",
"openLibrary": "라이브러리 열기...",
"saveToLibrary": "라이브러리로 저장...",
"typeLibrary": "__type__ 라이브러리",
"unnamedType": "이름없는 __type__",
"exportToLibrary": "라이브러리로 노드 내보내기",
"dialogSaveOverwrite": "__libraryType__이 __libraryName__으로 이미 등록되어있습니다. 덮어쓸까요?",
"invalidFilename": "파일명이 올바르지 않습니다",
"savedNodes": "저장된 노드",
"savedType": "저장된 __type__",
"saveFailed": "저장 실패 : __message__",
"filename": "파일명",
"folder": "폴더명",
"filenamePlaceholder": "파일",
"fullFilenamePlaceholder": "a/b/file",
"folderPlaceholder": "a/b",
"breadcrumb": "라이브러리"
"types": {
"examples": "예시"
}
},
"palette": {
"noInfo": "정보 없음",
@ -904,4 +897,4 @@
"description": "상세 내역",
"appearance": "모양"
}
}
}

View File

@ -50,9 +50,6 @@
"export": "导出",
"search": "查找流程",
"searchInput": "查找流程",
"clipboard": "剪贴板",
"library": "库",
"examples": "例子",
"subflows": "子流程",
"createSubflow": "新建子流程",
"selectionToSubflow": "将选择部分更改为子流程",
@ -100,8 +97,8 @@
}
},
"clipboard": {
"clipboard": "剪贴板",
"nodes": "节点",
"selectNodes": "选择上面的文本并复制到剪贴板",
"pasteNodes": "在这里粘贴节点",
"importNodes": "导入节点",
"exportNodes": "导出节点至剪贴板",
@ -237,6 +234,7 @@
"managePalette": "管理面板"
},
"library": {
"library": "库",
"openLibrary": "打开库...",
"saveToLibrary": "保存到库...",
"typeLibrary": "__type__类型库",
@ -247,12 +245,9 @@
"savedNodes": "保存的节点",
"savedType": "已保存__type__",
"saveFailed": "保存失败: __message__",
"filename": "文件名",
"folder": "文件夹",
"filenamePlaceholder": "文件",
"fullFilenamePlaceholder": "a/b/文件",
"folderPlaceholder": "a/b",
"breadcrumb": "库"
"types": {
"examples": "例子"
}
},
"palette": {
"noInfo": "无可用信息",

View File

@ -1,6 +1,6 @@
{
"name": "@node-red/editor-client",
"version": "0.20.7",
"version": "1.0.0-beta.2",
"license": "Apache-2.0",
"repository": {
"type": "git",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 B

View File

@ -0,0 +1 @@
<svg width="27" height="18" xmlns="http://www.w3.org/2000/svg"><g color="#000"><path fill="#fff" d="M0 5.002h10v5H0zM17 .002h10v5H17z"/><path d="M17 13.002h10v5H17z"/></g><path d="M9.5 7.502h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

View File

@ -0,0 +1 @@
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><path color="#000" fill="#8c101c" d="M0 .002h32v32H0z"/><g color="#000"><path fill="#fff" d="M2 13.002h10v5H2zM19 8.002h10v5H19z"/><path d="M19 21.002h10v5H19z"/></g><path d="M11.5 15.502h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

View File

@ -0,0 +1 @@
<svg width="27" height="18" xmlns="http://www.w3.org/2000/svg"><g fill="#fff" color="#000"><path d="M0 5h10v5H0zM17 0h10v5H17zM17 13h10v5H17z"/></g><path d="M9.5 7.5h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

View File

@ -0,0 +1 @@
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><path color="#000" fill="#8c101c" d="M0 0h32v32H0z"/><g fill="#fff" color="#000"><path d="M2 13h10v5H2zM19 8h10v5H19zM19 21h10v5H19z"/></g><path d="M11.5 15.5h2l4-5h2" fill="none" stroke="#fff" stroke-width="1.5"/></svg>

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

View File

@ -0,0 +1 @@
<svg width="27" height="18" xmlns="http://www.w3.org/2000/svg"><path color="#000" d="M0 5.002h10v5H0zM17 13.002h10v5H17z"/><path d="M9.5 7.502h2l4-5h2" fill="none" stroke="#000" stroke-width="1.5"/><path color="#000" fill="#fff" d="M17 .002h10v5H17z"/></svg>

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

View File

@ -0,0 +1 @@
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><path color="#000" fill="#8c101c" d="M0 .002h32v32H0z"/><path color="#000" d="M2 13.002h10v5H2zM19 21.002h10v5H19z"/><path d="M11.5 15.502h2l4-5h2" fill="none" stroke="#000" stroke-width="1.5"/><path color="#000" fill="#fff" d="M19 8.002h10v5H19z"/></svg>

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1015 B

View File

@ -0,0 +1 @@
<svg width="32" height="32" xmlns="http://www.w3.org/2000/svg"><g color="#000"><path fill="#8c101c" d="M0 .006h32v32H0z"/><path d="M11.81 25.429a10.02 10.02 0 0 0 4.19.914c5.562 0 10.107-4.545 10.107-10.106S21.562 6.131 16 6.131 5.895 10.676 5.895 16.237h3.368c0-3.74 2.997-6.737 6.738-6.737s6.737 2.996 6.737 6.737-2.996 6.738-6.737 6.738a6.775 6.775 0 0 1-2.533-.486l1.43-3.48-6.947 1.317 2.13 8.485z" fill="#fff" style="isolation:auto;mix-blend-mode:normal;text-decoration-color:#000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-transform:none;white-space:normal"/></g></svg>

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

View File

@ -0,0 +1 @@
<svg width="40" height="60" xmlns="http://www.w3.org/2000/svg"><path d="M18 5v12H7v26h11v12l14-25z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1019 B

View File

@ -0,0 +1 @@
<svg width="46.994" height="18.006" xmlns="http://www.w3.org/2000/svg"><g stroke="#d6d6d6"><g fill="#9e3131" stroke-linejoin="round" stroke-width="3.847" transform="matrix(.25848 0 0 .2614 -63.87 -108.483)"><rect x="249.04" y="435.92" width="50.294" height="22.953" ry="6.608"/><rect x="345.63" y="416.93" width="50.294" height="22.953" ry="6.608"/><rect x="376.71" y="459.01" width="50.294" height="22.953" ry="6.608"/></g><path d="M301.04 447.43c24.406.184 7.107-18.84 42.708-19.03M374.82 470.48c-46.966.538-28.989-22.664-73.619-22.944" fill="none" stroke-width="5.771" transform="matrix(.25848 0 0 .2614 -63.87 -108.483)"/></g></svg>

After

Width:  |  Height:  |  Size: 636 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 410 B

View File

@ -0,0 +1 @@
<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg"><path d="M25 16h7c.58 0 1-.42 1-1v-2c0-.58-.42-1-1-1h-7c-.58 0-1 .42-1 1v2c0 .58.42 1 1 1zM8 28h7c.58 0 1-.42 1-1v-2c0-.58-.42-1-1-1H8c-.58 0-1 .42-1 1v2c0 .58.42 1 1 1zm-.416 11C5.624 39 4 37.375 4 35.416V4.582C4 2.622 5.625 1 7.584 1h24.832C34.376 1 36 2.623 36 4.582v30.834C36 37.376 34.375 39 32.416 39zM32 27H19c0 2.19-1.81 4-4 4H7v4.416c0 .35.235.584.584.584h24.832c.35 0 .584-.235.584-.584v-8.417zm1-2v-6h-8c-2.19 0-4-1.81-4-4h-1c-4.333-.002-8.667.004-13 0v6h8c2.19 0 4 1.81 4 4h13zm0-16V4.582c0-.35-.235-.582-.584-.582H7.584C7.234 4 7 4.233 7 4.582v8.417c4.333.002 8.667.001 13 .001h1c0-2.19 1.81-4 4-4z" color="#000" fill="#333"/></svg>

After

Width:  |  Height:  |  Size: 708 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M14.16 27.38l1.555-.144c.132.731.383 1.261.755 1.591.371.33.848.494 1.429.494.497 0 .931-.114 1.303-.341.377-.228.686-.53.926-.908.24-.383.44-.899.602-1.546a8.122 8.122 0 0 0 .233-2.3 3.732 3.732 0 0 1-1.33 1.258 3.605 3.605 0 0 1-1.815.476c-1.09 0-2.013-.395-2.768-1.186s-1.133-1.834-1.133-3.128c0-1.336.393-2.411 1.178-3.226.79-.815 1.78-1.223 2.966-1.223.856 0 1.638.231 2.345.692.713.462 1.253 1.12 1.618 1.978.372.85.557 2.085.557 3.702 0 1.684-.182 3.026-.548 4.027-.365.994-.91 1.752-1.636 2.274-.719.52-1.563.781-2.534.781-1.03 0-1.872-.284-2.525-.853-.654-.576-1.046-1.381-1.178-2.418zm6.624-5.815c0-.928-.249-1.666-.746-2.21-.492-.546-1.085-.819-1.78-.819-.719 0-1.345.294-1.878.881s-.8 1.348-.8 2.283c0 .839.252 1.522.755 2.05.51.52 1.135.781 1.878.781.75 0 1.363-.26 1.843-.782.485-.527.728-1.255.728-2.184zM4.858 10.466c0-1.558.158-2.81.476-3.757.324-.952.8-1.686 1.429-2.201.635-.516 1.432-.773 2.39-.773.708 0 1.328.143 1.861.431.533.282.974.692 1.321 1.231.348.534.62 1.187.818 1.96.198.767.297 1.803.297 3.11 0 1.545-.16 2.794-.477 3.747-.317.947-.794 1.68-1.429 2.202-.629.515-1.426.773-2.39.773-1.27 0-2.268-.456-2.993-1.366-.869-1.097-1.303-2.882-1.303-5.357zm1.662 0c0 2.163.252 3.604.755 4.323.51.713 1.136 1.07 1.879 1.07.743 0 1.366-.36 1.87-1.079.508-.719.763-2.157.763-4.314 0-2.169-.255-3.61-.764-4.323-.503-.713-1.132-1.07-1.887-1.07-.743 0-1.336.315-1.78.944-.557.803-.836 2.286-.836 4.45z" fill="#444"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 546 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M13.27 29.15l6.733-8.143h-6.235V19.3h8.8v1.559l-6.69 8.09h6.892v1.707h-9.5zm4.909-10.125zM6.577 12.58q0 .827.604 1.304.605.478 1.432.478 1.007 0 1.95-.467 1.59-.774 1.59-2.534V9.824q-.349.222-.9.37-.552.15-1.082.213l-1.155.148q-1.04.138-1.56.435-.88.498-.88 1.59zM11.2 8.721q.657-.085.88-.551.127-.255.127-.732 0-.975-.7-1.41-.689-.445-1.983-.445-1.495 0-2.12.805-.35.446-.456 1.326H5.167q.053-2.1 1.357-2.916 1.315-.827 3.043-.827 2.004 0 3.255.763 1.24.764 1.24 2.375v6.542q0 .297.117.477.127.18.52.18.127 0 .286-.01.159-.021.34-.053v1.41q-.446.127-.68.16-.233.031-.636.031-.986 0-1.43-.7-.234-.37-.33-1.05-.583.764-1.675 1.326t-2.407.562q-1.58 0-2.587-.954-.996-.965-.996-2.407 0-1.58.986-2.45.986-.869 2.587-1.07zm-1.58-4.75z" fill="#444"/></svg>

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M18.8 33.9c3.328 0 4.776-2.603 4.776-7.066s-1.448-7.066-4.776-7.066-4.776 2.603-4.776 7.066S15.473 33.9 18.8 33.9zm0-1.429c-2.192 0-3.073-1.781-3.073-4.522v-2.23c0-2.741.88-4.523 3.073-4.523s3.073 1.782 3.073 4.522v2.231c0 2.74-.88 4.522-3.073 4.522zm-6.306 1.194v-1.429H8.892V20.002H6.328l-3.621 3.386.959 1.038 3.445-3.21h.137v11.02H3.333v1.429zm11.2-17.7v-1.429h-3.602V2.302h-2.564l-3.621 3.386.959 1.038 3.445-3.21h.137v11.02h-3.915v1.429zM7.5 16.2c3.327 0 4.776-2.603 4.776-7.066S10.828 2.068 7.5 2.068 2.725 4.67 2.725 9.134 4.173 16.2 7.5 16.2zm0-1.429c-2.193 0-3.074-1.781-3.074-4.522V8.02c0-2.741.881-4.523 3.074-4.523s3.073 1.782 3.073 4.522v2.231c0 2.74-.881 4.522-3.073 4.522z" fill="#444"/></svg>

After

Width:  |  Height:  |  Size: 781 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 646 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M9.96 21.98a5 5 0 1 1 6.11-7.917zm3.035-13.973c-5.512 0-10 4.488-10 10s4.488 9.998 10 9.998 10-4.486 10-9.998-4.488-10-10-10zm0 1.816c4.53 0 8.182 3.655 8.182 8.184s-3.652 8.182-8.182 8.182-8.181-3.653-8.181-8.182 3.652-8.184 8.181-8.184z" color="#000" fill="#444"/></svg>

After

Width:  |  Height:  |  Size: 345 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 809 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M14.33 27.19q2.916-.136 4.024-2.131.58-1.024.58-2.37 0-2.132-1.569-3.24-.904-.648-3.035-1.228zM8.55 10.736q0 1.688 1.108 2.643 1.125.955 3.018 1.33V6.695q-2.234.085-3.189 1.364-.937 1.279-.937 2.677zm-3.07.205q0-2.592 1.893-4.672 1.91-2.08 5.337-2.115V1.887h1.62V4.12q3.393.239 5.2 2.012 1.825 1.757 1.91 4.655h-2.984q-.119-1.296-.699-2.233-1.074-1.723-3.427-1.808v8.287q3.956 1.108 5.371 2.08 2.302 1.603 2.302 4.74 0 4.536-2.95 6.446-1.637 1.057-4.723 1.398v3.308h-1.62v-3.308q-4.962-.324-6.735-3.513-.972-1.722-.972-4.655h3.018q.136 2.336.733 3.41 1.057 1.927 3.922 2.166v-9.293q-3.683-.699-5.44-2.336Q5.48 13.84 5.48 10.941z" fill="#444"/></svg>

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 563 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-337.103 -913.25) scale(1.2585)" fill="#444" stroke-width=".795"><circle cx="284.36" cy="733.68" r="1.5" color="#000" style="isolation:auto;mix-blend-mode:normal"/><circle cx="284.33" cy="740.74" r="1.5" color="#000" style="isolation:auto;mix-blend-mode:normal"/><path d="M276.18 727.78l4.396-1.565v18.515c-.711 2.606-2.922 4.394-5.812 5.812l-4.135 1.974-.559-1.192 3.353-1.639c1.459-.724 2.689-1.87 2.869-4.955z" fill-rule="evenodd"/></g></svg>

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M15 5.225v-1.92h2.24q.608 0 1.216.288.608.256 1.12.8.48.512.8 1.312.32.768.32 1.792v5.824q0 .832.224 1.536t.608 1.216q.352.48.832.768.48.256.992.256v2.176q-.512 0-.992.256t-.832.736q-.384.48-.608 1.184t-.224 1.568v5.792q0 1.024-.32 1.792-.32.8-.8 1.312-.512.544-1.12.8-.608.288-1.216.288H15v-1.92h1.6q.48 0 .768-.256.288-.224.48-.64.16-.384.224-.896.064-.48.064-.96v-5.824q0-1.216.352-2.016.32-.8.768-1.28.448-.512.928-.736.448-.224.736-.256v-.096q-.288-.064-.736-.32-.48-.256-.928-.768t-.768-1.28q-.352-.8-.352-1.92V7.977q0-.512-.064-.992-.064-.512-.224-.896-.192-.384-.48-.608-.288-.256-.768-.256zm-3.648 0v-1.92h-2.24q-.608 0-1.216.288-.608.256-1.12.8-.48.512-.8 1.312-.32.768-.32 1.792v5.824q0 .832-.224 1.536t-.608 1.216q-.352.48-.832.768-.48.256-.992.256v2.176q.512 0 .992.256t.832.736q.384.48.608 1.184t.224 1.568v5.792q0 1.024.32 1.792.32.8.8 1.312.512.544 1.12.8.608.288 1.216.288h2.24v-1.92h-1.6q-.48 0-.768-.256-.288-.224-.48-.64-.16-.384-.224-.896-.064-.48-.064-.96v-5.824q0-1.216-.352-2.016-.32-.8-.768-1.28-.448-.512-.928-.736-.448-.224-.736-.256v-.096q.288-.064.736-.32.48-.256.928-.768t.768-1.28q.352-.8.352-1.92V7.977q0-.512.064-.992.064-.512.224-.896.192-.384.48-.608.288-.256.768-.256z" fill="#444"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M2 19h5v5H2zm16.099-3.304v-5.659h-2.654v5.66l-5.309-2.004-.901 2.404L14.543 18l-3.255 4.557 2.254 1.553 3.255-4.808 3.455 4.808 2.054-1.553L19 18l5.46-1.903-1.002-2.404z" color="#000" fill="#444444"/></svg>

After

Width:  |  Height:  |  Size: 279 B

View File

@ -0,0 +1 @@
<svg width="26" height="36" xmlns="http://www.w3.org/2000/svg"><path d="M11 5v5.77a7.542 7.542 0 0 0-5.234 5.25L1 16c-1.432 1.397-1.232 2.722 0 4l4.75-.078a7.542 7.542 0 0 0 5.22 5.297L11 31c1.316 1.303 2.649 1.363 4 0l.009-5.775A7.542 7.542 0 0 0 20.228 20H25c1.261-1.294 1.404-2.623 0-4l-4.774-.01a7.542 7.542 0 0 0-5.23-5.22L15 5c-1.3-1.273-2.63-1.393-4 0zm2 7.499c3.05 0 5.5 2.45 5.5 5.5s-2.45 5.5-5.5 5.5-5.5-2.45-5.5-5.5 2.45-5.5 5.5-5.5z" color="#000" fill="#444"/></svg>

After

Width:  |  Height:  |  Size: 479 B

View File

@ -143,7 +143,7 @@ RED.comms = (function() {
} else {
var msg = RED._("notification.errors.lostConnectionReconnect",{time: connectCountdown})+' <a href="#">'+ RED._("notification.errors.lostConnectionTry")+'</a>';
errornotification.update(msg,{silent:true});
$(errornotification).find("a").click(function(e) {
$(errornotification).find("a").on("click", function(e) {
e.preventDefault();
errornotification.update(RED._("notification.errors.lostConnection"),{silent:true});
clearInterval(connectCountdownTimer);

View File

@ -14,7 +14,8 @@
* limitations under the License.
**/
RED.history = (function() {
var undo_history = [];
var undoHistory = [];
var redoHistory = [];
function undoEvent(ev) {
var i;
@ -22,52 +23,81 @@ RED.history = (function() {
var node;
var subflow;
var modifiedTabs = {};
var inverseEv;
if (ev) {
if (ev.t == 'multi') {
inverseEv = {
t: 'multi',
events: []
};
len = ev.events.length;
for (i=len-1;i>=0;i--) {
undoEvent(ev.events[i]);
var r = undoEvent(ev.events[i]);
inverseEv.events.push(r);
}
} else if (ev.t == 'replace') {
inverseEv = {
t: 'replace',
config: RED.nodes.createCompleteNodeSet(),
changed: [],
rev: RED.nodes.version()
};
RED.nodes.clear();
var imported = RED.nodes.import(ev.config);
imported[0].forEach(function(n) {
if (ev.changed[n.id]) {
n.changed = true;
inverseEv.changed[n.id] = true;
}
})
RED.nodes.version(ev.rev);
} else if (ev.t == 'add') {
inverseEv = {
t: "delete",
};
if (ev.nodes) {
inverseEv.nodes = [];
for (i=0;i<ev.nodes.length;i++) {
node = RED.nodes.node(ev.nodes[i]);
if (node.z) {
modifiedTabs[node.z] = true;
}
inverseEv.nodes.push(node);
RED.nodes.remove(ev.nodes[i]);
}
}
if (ev.links) {
inverseEv.links = [];
for (i=0;i<ev.links.length;i++) {
inverseEv.links.push(ev.links[i]);
RED.nodes.removeLink(ev.links[i]);
}
}
if (ev.workspaces) {
inverseEv.workspaces = [];
for (i=0;i<ev.workspaces.length;i++) {
var workspaceOrder = RED.nodes.getWorkspaceOrder();
ev.workspaces[i]._index = workspaceOrder.indexOf(ev.workspaces[i].id);
inverseEv.workspaces.push(ev.workspaces[i]);
RED.nodes.removeWorkspace(ev.workspaces[i].id);
RED.workspaces.remove(ev.workspaces[i]);
}
}
if (ev.subflows) {
inverseEv.subflows = [];
for (i=0;i<ev.subflows.length;i++) {
inverseEv.subflows.push(ev.subflows[i]);
RED.nodes.removeSubflow(ev.subflows[i]);
RED.workspaces.remove(ev.subflows[i]);
}
}
if (ev.subflow) {
inverseEv.subflow = {};
if (ev.subflow.instances) {
inverseEv.subflow.instances = [];
ev.subflow.instances.forEach(function(n) {
inverseEv.subflow.instances.push(n);
var node = RED.nodes.node(n.id);
if (node) {
node.changed = n.changed;
@ -83,21 +113,30 @@ RED.history = (function() {
}
}
if (ev.removedLinks) {
inverseEv.createdLinks = [];
for (i=0;i<ev.removedLinks.length;i++) {
inverseEv.createdLinks.push(ev.removedLinks[i]);
RED.nodes.addLink(ev.removedLinks[i]);
}
}
} else if (ev.t == "delete") {
inverseEv = {
t: "add"
};
if (ev.workspaces) {
inverseEv.workspaces = [];
for (i=0;i<ev.workspaces.length;i++) {
inverseEv.workspaces.push(ev.workspaces[i]);
RED.nodes.addWorkspace(ev.workspaces[i],ev.workspaces[i]._index);
RED.workspaces.add(ev.workspaces[i],undefined,ev.workspaces[i]._index);
delete ev.workspaces[i]._index;
}
}
if (ev.subflows) {
inverseEv.subflows = [];
for (i=0;i<ev.subflows.length;i++) {
inverseEv.subflows.push(ev.subflows[i]);
RED.nodes.addSubflow(ev.subflows[i]);
}
}
@ -126,8 +165,11 @@ RED.history = (function() {
}
}
if (ev.subflow) {
inverseEv.subflow = {};
if (ev.subflow.hasOwnProperty('instances')) {
inverseEv.subflow.instances = [];
ev.subflow.instances.forEach(function(n) {
inverseEv.subflow.instances.push(n);
var node = RED.nodes.node(n.id);
if (node) {
node.changed = n.changed;
@ -152,14 +194,25 @@ RED.history = (function() {
});
}
if (ev.nodes) {
inverseEv.nodes = [];
for (i=0;i<ev.nodes.length;i++) {
RED.nodes.add(ev.nodes[i]);
modifiedTabs[ev.nodes[i].z] = true;
inverseEv.nodes.push(ev.nodes[i].id);
}
}
if (ev.links) {
inverseEv.links = [];
for (i=0;i<ev.links.length;i++) {
RED.nodes.addLink(ev.links[i]);
inverseEv.links.push(ev.links[i]);
}
}
if (ev.createdLinks) {
inverseEv.removedLinks = [];
for (i=0;i<ev.createdLinks.length;i++) {
inverseEv.removedLinks.push(ev.createdLinks[i]);
RED.nodes.removeLink(ev.createdLinks[i]);
}
}
if (ev.changes) {
@ -179,8 +232,14 @@ RED.history = (function() {
}
} else if (ev.t == "move") {
inverseEv = {
t: 'move',
nodes: []
};
for (i=0;i<ev.nodes.length;i++) {
var n = ev.nodes[i];
var rn = {n: n.n, ox: n.n.x, oy: n.n.y, dirty: true, moved: n.moved};
inverseEv.nodes.push(rn);
n.n.x = n.ox;
n.n.y = n.oy;
n.n.dirty = true;
@ -188,18 +247,28 @@ RED.history = (function() {
}
// A move could have caused a link splice
if (ev.links) {
inverseEv.removedLinks = [];
for (i=0;i<ev.links.length;i++) {
inverseEv.removedLinks.push(ev.links[i]);
RED.nodes.removeLink(ev.links[i]);
}
}
if (ev.removedLinks) {
inverseEv.links = [];
for (i=0;i<ev.removedLinks.length;i++) {
inverseEv.links.push(ev.removedLinks[i]);
RED.nodes.addLink(ev.removedLinks[i]);
}
}
} else if (ev.t == "edit") {
inverseEv = {
t: "edit",
changes: {}
};
inverseEv.node = ev.node;
for (i in ev.changes) {
if (ev.changes.hasOwnProperty(i)) {
inverseEv.changes[i] = ev.node[i];
if (ev.node._def.defaults && ev.node._def.defaults[i] && ev.node._def.defaults[i].type) {
// This is a config node property
var currentConfigNode = RED.nodes.node(ev.node[i]);
@ -214,23 +283,34 @@ RED.history = (function() {
ev.node[i] = ev.changes[i];
}
}
if (ev.node.type === 'tab' && ev.changes.hasOwnProperty('disabled')) {
$("#red-ui-tab-"+(ev.node.id.replace(".","-"))).toggleClass('red-ui-workspace-disabled',!!ev.node.disabled);
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!ev.node.disabled);
}
if (ev.subflow) {
inverseEv.subflow = {};
if (ev.subflow.hasOwnProperty('inputCount')) {
inverseEv.subflow.inputCount = ev.node.in.length;
if (ev.node.in.length > ev.subflow.inputCount) {
inverseEv.subflow.inputs = ev.node.in.slice(ev.subflow.inputCount);
ev.node.in.splice(ev.subflow.inputCount);
} else if (ev.subflow.inputs.length > 0) {
ev.node.in = ev.node.in.concat(ev.subflow.inputs);
}
}
if (ev.subflow.hasOwnProperty('outputCount')) {
inverseEv.subflow.outputCount = ev.node.out.length;
if (ev.node.out.length > ev.subflow.outputCount) {
inverseEv.subflow.outputs = ev.node.out.slice(ev.subflow.outputCount);
ev.node.out.splice(ev.subflow.outputCount);
} else if (ev.subflow.outputs.length > 0) {
ev.node.out = ev.node.out.concat(ev.subflow.outputs);
}
}
if (ev.subflow.hasOwnProperty('instances')) {
inverseEv.subflow.instances = [];
ev.subflow.instances.forEach(function(n) {
inverseEv.subflow.instances.push(n);
var node = RED.nodes.node(n.id);
if (node) {
node.changed = n.changed;
@ -254,9 +334,11 @@ RED.history = (function() {
var outputMap;
if (ev.outputMap) {
outputMap = {};
inverseEv.outputMap = {};
for (var port in ev.outputMap) {
if (ev.outputMap.hasOwnProperty(port) && ev.outputMap[port] !== "-1") {
outputMap[ev.outputMap[port]] = port;
inverseEv.outputMap[ev.outputMap[port]] = port;
}
}
}
@ -264,39 +346,107 @@ RED.history = (function() {
RED.editor.validateNode(ev.node);
}
if (ev.links) {
inverseEv.createdLinks = [];
for (i=0;i<ev.links.length;i++) {
RED.nodes.addLink(ev.links[i]);
inverseEv.createdLinks.push(ev.links[i]);
}
}
if (ev.createdLinks) {
inverseEv.links = [];
for (i=0;i<ev.createdLinks.length;i++) {
RED.nodes.removeLink(ev.createdLinks[i]);
inverseEv.links.push(ev.createdLinks[i]);
}
}
ev.node.dirty = true;
ev.node.changed = ev.changed;
} else if (ev.t == "createSubflow") {
inverseEv = {
t: "deleteSubflow",
activeWorkspace: ev.activeWorkspace,
dirty: RED.nodes.dirty()
};
if (ev.nodes) {
inverseEv.movedNodes = [];
var z = ev.activeWorkspace;
RED.nodes.filterNodes({z:ev.subflow.subflow.id}).forEach(function(n) {
n.x += ev.subflow.offsetX;
n.y += ev.subflow.offsetY;
n.z = ev.activeWorkspace;
n.dirty = true;
inverseEv.movedNodes.push(n.id);
RED.nodes.moveNodeToTab(n, z);
});
inverseEv.subflows = [];
for (i=0;i<ev.nodes.length;i++) {
inverseEv.subflows.push(RED.nodes.node(ev.nodes[i]));
RED.nodes.remove(ev.nodes[i]);
}
}
if (ev.links) {
inverseEv.links = [];
for (i=0;i<ev.links.length;i++) {
inverseEv.links.push(ev.links[i]);
RED.nodes.removeLink(ev.links[i]);
}
}
inverseEv.subflow = ev.subflow;
RED.nodes.removeSubflow(ev.subflow.subflow);
RED.workspaces.remove(ev.subflow.subflow);
if (ev.removedLinks) {
inverseEv.createdLinks = [];
for (i=0;i<ev.removedLinks.length;i++) {
inverseEv.createdLinks.push(ev.removedLinks[i]);
RED.nodes.addLink(ev.removedLinks[i]);
}
}
} else if (ev.t == "deleteSubflow") {
inverseEv = {
t: "createSubflow",
activeWorkspace: ev.activeWorkspace,
dirty: RED.nodes.dirty(),
};
if (ev.subflow) {
RED.nodes.addSubflow(ev.subflow.subflow);
inverseEv.subflow = ev.subflow;
}
if (ev.subflows) {
inverseEv.nodes = [];
for (i=0;i<ev.subflows.length;i++) {
RED.nodes.add(ev.subflows[i]);
inverseEv.nodes.push(ev.subflows[i].id);
}
}
if (ev.movedNodes) {
ev.movedNodes.forEach(function(nid) {
nn = RED.nodes.node(nid);
nn.x -= ev.subflow.offsetX;
nn.y -= ev.subflow.offsetY;
nn.dirty = true;
RED.nodes.moveNodeToTab(nn, ev.subflow.subflow.id);
});
}
if (ev.links) {
inverseEv.links = [];
for (i=0;i<ev.links.length;i++) {
inverseEv.links.push(ev.links[i]);
RED.nodes.addLink(ev.links[i]);
}
}
if (ev.createdLinks) {
inverseEv.removedLinks = [];
for (i=0;i<ev.createdLinks.length;i++) {
inverseEv.removedLinks.push(ev.createdLinks[i]);
RED.nodes.removeLink(ev.createdLinks[i]);
}
}
} else if (ev.t == "reorder") {
inverseEv = {
t: 'reorder',
order: RED.nodes.getWorkspaceOrder()
};
if (ev.order) {
RED.workspaces.order(ev.order);
}
@ -316,6 +466,8 @@ RED.history = (function() {
RED.workspaces.refresh();
RED.sidebar.config.refresh();
RED.subflow.refresh();
return inverseEv;
}
}
@ -323,28 +475,42 @@ RED.history = (function() {
return {
//TODO: this function is a placeholder until there is a 'save' event that can be listened to
markAllDirty: function() {
for (var i=0;i<undo_history.length;i++) {
undo_history[i].dirty = true;
for (var i=0;i<undoHistory.length;i++) {
undoHistory[i].dirty = true;
}
},
list: function() {
return undo_history
return undoHistory;
},
depth: function() {
return undo_history.length;
return undoHistory.length;
},
push: function(ev) {
undo_history.push(ev);
undoHistory.push(ev);
redoHistory = [];
},
pop: function() {
var ev = undo_history.pop();
undoEvent(ev);
var ev = undoHistory.pop();
var rev = undoEvent(ev);
if (rev) {
redoHistory.push(rev);
}
},
peek: function() {
return undo_history[undo_history.length-1];
return undoHistory[undoHistory.length-1];
},
clear: function() {
undo_history = [];
undoHistory = [];
redoHistory = [];
},
redo: function() {
var ev = redoHistory.pop();
if (ev) {
var uev = undoEvent(ev);
if (uev) {
undoHistory.push(uev);
}
}
}
}

View File

@ -21,7 +21,8 @@ RED.i18n = (function() {
return {
init: function(options, done) {
apiRootUrl = options.apiRootUrl||"";
i18n.init({
var preferredLanguage = localStorage.getItem("editor-language");
var opts = {
resGetPath: apiRootUrl+'locales/__ns__?lng=__lng__',
dynamicLoad: false,
load:'current',
@ -32,7 +33,11 @@ RED.i18n = (function() {
fallbackLng: ['en-US'],
useCookie: false,
returnObjectTrees: true
},function() {
};
if (preferredLanguage) {
opts.lng = preferredLanguage;
}
i18n.init(opts,function() {
done();
});
RED["_"] = function() {
@ -45,8 +50,21 @@ RED.i18n = (function() {
}
},
lang: function() {
// Gets the active message catalog language. This is based on what
// locale the editor is using and what languages are available.
//
var preferredLangs = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
var knownLangs = RED.settings.theme("languages")||["en-US"];
for (var i=0;i<preferredLangs.length;i++) {
if (knownLangs.indexOf(preferredLangs[i]) > -1) {
return preferredLangs[i]
}
}
return 'end-US'
},
loadNodeCatalog: function(namespace,done) {
var languageList = i18n.functions.toLanguages(i18n.detectLanguage());
var languageList = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
var toLoad = languageList.length;
languageList.forEach(function(lang) {
$.ajax({
@ -68,7 +86,7 @@ RED.i18n = (function() {
},
loadNodeCatalogs: function(done) {
var languageList = i18n.functions.toLanguages(i18n.detectLanguage());
var languageList = i18n.functions.toLanguages(localStorage.getItem("editor-language")||i18n.detectLanguage());
var toLoad = languageList.length;
languageList.forEach(function(lang) {

View File

@ -1,6 +1,6 @@
{
"*": {
"ctrl-shift-p":"core:manage-palette",
"alt-shift-p":"core:manage-palette",
"ctrl-f": "core:search",
"ctrl-shift-f": "core:list-flows",
"ctrl-=": "core:zoom-in",
@ -8,6 +8,7 @@
"ctrl-0": "core:zoom-reset",
"ctrl-enter": "core:confirm-edit-tray",
"ctrl-escape": "core:cancel-edit-tray",
"ctrl-d": "core:deploy-flows",
"ctrl-g i": "core:show-info-tab",
"ctrl-g d": "core:show-debug-tab",
"ctrl-g c": "core:show-config-tab",
@ -17,19 +18,22 @@
"ctrl-space": "core:toggle-sidebar",
"ctrl-p": "core:toggle-palette",
"ctrl-,": "core:show-user-settings",
"ctrl-alt-l": "core:clear-debug-messages",
"ctrl-alt-r": "core:show-remote-diff",
"ctrl-alt-n": "core:new-project",
"ctrl-alt-o": "core:open-project",
"ctrl-g v": "core:show-version-control-tab",
"ctrl-shift-l": "core:show-event-log"
"ctrl-shift-l": "core:show-event-log",
"ctrl-shift-p":"core:show-action-list"
},
"sidebar-node-config": {
"red-ui-sidebar-node-config": {
"backspace": "core:delete-config-selection",
"delete": "core:delete-config-selection",
"ctrl-a": "core:select-all-config-nodes",
"ctrl-z": "core:undo"
"ctrl-z": "core:undo",
"ctrl-y": "core:redo"
},
"workspace": {
"red-ui-workspace": {
"backspace": "core:delete-selection",
"delete": "core:delete-selection",
"enter": "core:edit-selected-node",
@ -37,6 +41,7 @@
"ctrl-x": "core:cut-selection-to-internal-clipboard",
"ctrl-v": "core:paste-from-internal-clipboard",
"ctrl-z": "core:undo",
"ctrl-y": "core:redo",
"ctrl-a": "core:select-all-nodes",
"shift-?": "core:show-help",
"up": "core:move-selection-up",

View File

@ -17,6 +17,8 @@ RED.nodes = (function() {
var node_defs = {};
var nodes = [];
var nodeTabMap = {};
var configNodes = {};
var links = [];
var defaultWorkspace;
@ -213,6 +215,11 @@ RED.nodes = (function() {
n.i = nextId+1;
}
nodes.push(n);
if (nodeTabMap[n.z]) {
nodeTabMap[n.z][n.id] = n;
} else {
console.warn("Node added to unknown tab/subflow:",n);
}
}
RED.events.emit('nodes:add',n);
}
@ -246,6 +253,9 @@ RED.nodes = (function() {
node = getNode(id);
if (node) {
nodes.splice(nodes.indexOf(node),1);
if (nodeTabMap[node.z]) {
delete nodeTabMap[node.z][node.id];
}
removedLinks = links.filter(function(l) { return (l.source === node) || (l.target === node); });
removedLinks.forEach(function(l) {links.splice(links.indexOf(l), 1); });
var updatedConfigNode = false;
@ -291,6 +301,17 @@ RED.nodes = (function() {
return {links:removedLinks,nodes:removedNodes};
}
function moveNodeToTab(node, z) {
if (nodeTabMap[node.z]) {
delete nodeTabMap[node.z][node.id];
}
if (!nodeTabMap[z]) {
nodeTabMap[z] = {};
}
nodeTabMap[z][node.id] = node;
node.z = z;
}
function removeLink(l) {
var index = links.indexOf(l);
if (index != -1) {
@ -300,6 +321,8 @@ RED.nodes = (function() {
function addWorkspace(ws,targetIndex) {
workspaces[ws.id] = ws;
nodeTabMap[ws.id] = {};
ws._def = RED.nodes.getType('tab');
if (targetIndex === undefined) {
workspacesOrder.push(ws.id);
@ -312,6 +335,7 @@ RED.nodes = (function() {
}
function removeWorkspace(id) {
delete workspaces[id];
delete nodeTabMap[id];
workspacesOrder.splice(workspacesOrder.indexOf(id),1);
var removedNodes = [];
@ -357,30 +381,32 @@ RED.nodes = (function() {
sf.name = subflowName;
}
subflows[sf.id] = sf;
nodeTabMap[sf.id] = {};
RED.nodes.registerType("subflow:"+sf.id, {
defaults:{
name:{value:""},
env:{value:[]}
},
icon: function() { return sf.icon||"subflow.png" },
icon: function() { return sf.icon||"subflow.svg" },
category: sf.category || "subflows",
inputs: sf.in.length,
outputs: sf.out.length,
color: "#da9",
color: sf.color || "#da9",
label: function() { return this.name||RED.nodes.subflow(sf.id).name },
labelStyle: function() { return this.name?"node_label_italic":""; },
labelStyle: function() { return this.name?"red-ui-flow-node-label-italic":""; },
paletteLabel: function() { return RED.nodes.subflow(sf.id).name },
inputLabels: function(i) { return sf.inputLabels?sf.inputLabels[i]:null },
outputLabels: function(i) { return sf.outputLabels?sf.outputLabels[i]:null },
oneditresize: function(size) {
var rows = $("#dialog-form>div:not(.node-input-env-container-row)");
// var rows = $(".dialog-form>div:not(.node-input-env-container-row)");
var height = size.height;
for (var i=0; i<rows.size(); i++) {
height -= $(rows[i]).outerHeight(true);
}
var editorRow = $("#dialog-form>div.node-input-env-container-row");
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#node-input-env-container").editableList('height',height-80);
// for (var i=0; i<rows.size(); i++) {
// height -= $(rows[i]).outerHeight(true);
// }
// var editorRow = $("#dialog-form>div.node-input-env-container-row");
// height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("ol.red-ui-editor-subflow-env-list").editableList('height',height);
},
set:{
module: "node-red"
@ -393,6 +419,7 @@ RED.nodes = (function() {
}
function removeSubflow(sf) {
delete subflows[sf.id];
delete nodeTabMap[sf.id];
registry.removeNodeType("subflow:"+sf.id);
}
@ -463,7 +490,9 @@ RED.nodes = (function() {
node.id = n.id;
node.type = n.type;
node.z = n.z;
if (n.d === true) {
node.d = true;
}
if (node.type == "unknown") {
for (var p in n._orig) {
if (n._orig.hasOwnProperty(p)) {
@ -549,6 +578,7 @@ RED.nodes = (function() {
node.in = [];
node.out = [];
node.env = n.env;
node.color = n.color;
n.in.forEach(function(p) {
var nIn = {x:p.x,y:p.y,wires:[]};
@ -581,7 +611,7 @@ RED.nodes = (function() {
node.outputLabels = n.outputLabels.slice();
}
if (n.icon) {
if (n.icon !== "node-red/subflow.png") {
if (n.icon !== "node-red/subflow.svg") {
node.icon = n.icon;
}
}
@ -967,6 +997,9 @@ RED.nodes = (function() {
users:[],
_config:{}
};
if (n.hasOwnProperty('d')) {
configNode.d = n.d;
}
for (d in def.defaults) {
if (def.defaults.hasOwnProperty(d)) {
configNode[d] = n[d];
@ -1016,6 +1049,9 @@ RED.nodes = (function() {
if (n.hasOwnProperty('l')) {
node.l = n.l;
}
if (n.hasOwnProperty('d')) {
node.d = n.d;
}
if (createNewIds) {
if (subflow_blacklist[n.z]) {
continue;
@ -1072,7 +1108,7 @@ RED.nodes = (function() {
color:"#fee",
defaults: {},
label: "unknown: "+n.type,
labelStyle: "node_label_italic",
labelStyle: "red-ui-flow-node-label-italic",
outputs: n.outputs||n.wires.length,
set: registry.getNodeSet("node-red/unknown")
}
@ -1258,12 +1294,13 @@ RED.nodes = (function() {
// TODO: supports filter.z|type
function filterNodes(filter) {
var result = [];
var searchSet = nodes;
if (filter.hasOwnProperty("z") && Object.hasOwnProperty("values") && nodeTabMap.hasOwnProperty(filter.z) ) {
searchSet = Object.values(nodeTabMap[filter.z]);
}
for (var n=0;n<nodes.length;n++) {
var node = nodes[n];
if (filter.hasOwnProperty("z") && node.z !== filter.z) {
continue;
}
for (var n=0;n<searchSet.length;n++) {
var node = searchSet[n];
if (filter.hasOwnProperty("type") && node.type !== filter.type) {
continue;
}
@ -1331,6 +1368,7 @@ RED.nodes = (function() {
function clear() {
nodes = [];
links = [];
nodeTabMap = {};
configNodes = {};
workspacesOrder = [];
var subflowIds = Object.keys(subflows);
@ -1440,6 +1478,8 @@ RED.nodes = (function() {
remove: removeNode,
clear: clear,
moveNodeToTab: moveNodeToTab,
addLink: addLink,
removeLink: removeLink,

View File

@ -38,11 +38,14 @@ var RED = (function() {
newScript.onload = function() {
scriptCount--;
if (scriptCount === 0) {
$("body").append(nodeConfigEls);
$("#red-ui-editor-node-configs").append(nodeConfigEls);
done()
}
}
$('body').append(newScript);
if ($(el).attr('type') === "module") {
newScript.type = "module";
}
$("#red-ui-editor-node-configs").append(newScript);
newScript.src = RED.settings.apiRootUrl+srcUrl;
hasDeferred = true;
} else {
@ -58,7 +61,7 @@ var RED = (function() {
}
})
if (!hasDeferred) {
$("body").append(nodeConfigEls);
$("#red-ui-editor-node-configs").append(nodeConfigEls);
done();
}
} catch(err) {
@ -104,9 +107,12 @@ var RED = (function() {
}
function loadNodes() {
var lang = localStorage.getItem("editor-language")||i18n.detectLanguage();
$.ajax({
headers: {
"Accept":"text/html"
"Accept":"text/html",
"Accept-Language": lang
},
cache: false,
url: 'nodes',
@ -114,10 +120,10 @@ var RED = (function() {
var configs = data.trim().split(/(?=<!-- --- \[red-module:\S+\] --- -->)/);
var stepConfig = function() {
if (configs.length === 0) {
$("body").i18n();
$("#palette > .palette-spinner").hide();
$(".palette-scroll").removeClass("hide");
$("#palette-search").removeClass("hide");
$("#red-ui-editor").i18n();
$("#red-ui-palette > .red-ui-palette-spinner").hide();
$(".red-ui-palette-scroll").removeClass("hide");
$("#red-ui-palette-search").removeClass("hide");
loadFlows(function() {
if (RED.settings.theme("projects.enabled",false)) {
RED.projects.refresh(function(activeProject) {
@ -351,6 +357,7 @@ var RED = (function() {
msg.text = node._(msg.text.toString(),{defaultValue:msg.text.toString()});
}
node.status = msg;
node.dirtyStatus = true;
node.dirty = true;
RED.view.redraw();
}
@ -431,7 +438,7 @@ var RED = (function() {
});
}
function loadEditor() {
function buildMainMenu() {
var menuOptions = [];
if (RED.settings.theme("projects.enabled",false)) {
menuOptions.push({id:"menu-item-projects-menu",label:RED._("menu.label.projects"),options:[
@ -440,34 +447,16 @@ var RED = (function() {
{id:"menu-item-projects-settings",label:RED._("menu.label.projects-settings"),disabled:false,onselect:"core:show-project-settings"}
]});
}
menuOptions.push({id:"menu-item-view-menu",label:RED._("menu.label.view.view"),options:[
// {id:"menu-item-view-show-grid",setting:"view-show-grid",label:RED._("menu.label.view.showGrid"),toggle:true,onselect:"core:toggle-show-grid"},
// {id:"menu-item-view-snap-grid",setting:"view-snap-grid",label:RED._("menu.label.view.snapGrid"),toggle:true,onselect:"core:toggle-snap-grid"},
// {id:"menu-item-status",setting:"node-show-status",label:RED._("menu.label.displayStatus"),toggle:true,onselect:"core:toggle-status", selected: true},
//null,
// {id:"menu-item-bidi",label:RED._("menu.label.view.textDir"),options:[
// {id:"menu-item-bidi-default",toggle:"text-direction",label:RED._("menu.label.view.defaultDir"),selected: true, onselect:function(s) { if(s){RED.text.bidi.setTextDirection("")}}},
// {id:"menu-item-bidi-ltr",toggle:"text-direction",label:RED._("menu.label.view.ltr"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("ltr")}}},
// {id:"menu-item-bidi-rtl",toggle:"text-direction",label:RED._("menu.label.view.rtl"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("rtl")}}},
// {id:"menu-item-bidi-auto",toggle:"text-direction",label:RED._("menu.label.view.auto"), onselect:function(s) { if(s){RED.text.bidi.setTextDirection("auto")}}}
// ]},
// null,
{id:"menu-item-palette",label:RED._("menu.label.palette.show"),toggle:true,onselect:"core:toggle-palette", selected: true},
{id:"menu-item-sidebar",label:RED._("menu.label.sidebar.show"),toggle:true,onselect:"core:toggle-sidebar", selected: true},
{id:"menu-item-event-log",label:RED._("eventLog.title"),onselect:"core:show-event-log"},
{id:"menu-item-action-list",label:RED._("keyboard.actionList"),onselect:"core:show-action-list"},
null
]});
menuOptions.push(null);
menuOptions.push({id:"menu-item-import",label:RED._("menu.label.import"),options:[
{id:"menu-item-import-clipboard",label:RED._("menu.label.clipboard"),onselect:"core:show-import-dialog"},
{id:"menu-item-import-library",label:RED._("menu.label.library"),options:[]}
]});
menuOptions.push({id:"menu-item-export",label:RED._("menu.label.export"),options:[
{id:"menu-item-export-clipboard",label:RED._("menu.label.clipboard"),onselect:"core:show-export-dialog"},
{id:"menu-item-export-library",label:RED._("menu.label.library"),disabled:true,onselect:"core:library-export"}
]});
menuOptions.push({id:"menu-item-import",label:RED._("menu.label.import"),onselect:"core:show-import-dialog"});
menuOptions.push({id:"menu-item-export",label:RED._("menu.label.export"),onselect:"core:show-export-dialog"});
menuOptions.push(null);
menuOptions.push({id:"menu-item-search",label:RED._("menu.label.search"),onselect:"core:search"});
menuOptions.push(null);
@ -498,13 +487,24 @@ var RED = (function() {
menuOptions.push({id:"menu-item-node-red-version", label:"v"+RED.settings.version, onselect: "core:show-about" });
$('<li><a id="red-ui-header-button-sidemenu" class="button" href="#"><i class="fa fa-bars"></i></a></li>').appendTo(".red-ui-header-toolbar")
RED.menu.init({id:"red-ui-header-button-sidemenu",options: menuOptions});
}
function loadEditor() {
RED.workspaces.init();
RED.statusBar.init();
RED.view.init();
RED.userSettings.init();
RED.user.init();
RED.notifications.init();
RED.library.init();
RED.keyboard.init();
RED.palette.init();
RED.eventLog.init();
if (RED.settings.theme('palette.editable') !== false) {
RED.palette.editor.init();
} else {
@ -520,27 +520,57 @@ var RED = (function() {
}
RED.subflow.init();
RED.workspaces.init();
RED.clipboard.init();
RED.search.init();
RED.actionList.init();
RED.editor.init();
RED.diff.init();
RED.menu.init({id:"btn-sidemenu",options: menuOptions});
RED.deploy.init(RED.settings.theme("deployButton",null));
RED.notifications.init();
RED.actions.add("core:show-about", showAbout);
buildMainMenu();
RED.nodes.init();
RED.comms.connect();
$("#main-container").show();
$(".header-toolbar").show();
$("#red-ui-main-container").show();
$(".red-ui-header-toolbar").show();
RED.actions.add("core:show-about", showAbout);
loadNodeList();
}
function buildEditor(options) {
var header = $('<div id="red-ui-header"></div>').appendTo(options.target);
var logo = $('<span class="red-ui-header-logo"></span>').appendTo(header);
$('<ul class="red-ui-header-toolbar hide"></ul>').appendTo(header);
$('<div id="red-ui-header-shade" class="hide"></div>').appendTo(header);
$('<div id="red-ui-main-container" class="red-ui-sidebar-closed hide">'+
'<div id="red-ui-workspace"></div>'+
'<div id="red-ui-editor-stack"></div>'+
'<div id="red-ui-palette"></div>'+
'<div id="red-ui-sidebar"></div>'+
'<div id="red-ui-sidebar-separator"></div>'+
'</div>').appendTo(options.target);
$('<div id="red-ui-editor-node-configs"></div>').appendTo(options.target);
$('<div id="red-ui-full-shade" class="hide"></div>').appendTo(options.target);
$.getJSON(options.apiRootUrl+"theme", function(theme) {
if (theme.header) {
if (theme.header.url) {
logo = $("<a>",{href:theme.header.url}).appendTo(logo);
}
if (theme.header.image) {
$('<img>',{src:theme.header.image}).appendTo(logo);
}
if (theme.header.title) {
$('<span>').html(theme.header.title).appendTo(logo);
}
}
});
}
var initialised = false;
function init(options) {
@ -554,6 +584,10 @@ var RED = (function() {
if (options.apiRootUrl && !/\/$/.test(options.apiRootUrl)) {
options.apiRootUrl = options.apiRootUrl+"/";
}
options.target = $("#red-ui-editor");
options.target.addClass("red-ui-editor");
buildEditor(options);
RED.i18n.init(options, function() {
RED.settings.init(options, loadEditor);
})

View File

@ -37,7 +37,7 @@ RED.settings = (function () {
if (key === "auth-tokens") {
localStorage.setItem(key, JSON.stringify(value));
} else {
userSettings[key] = value;
RED.utils.setMessageProperty(userSettings,key,value);
saveUserSettings();
}
};
@ -46,16 +46,25 @@ RED.settings = (function () {
* If the key is not set in the localStorage it returns <i>undefined</i>
* Else return the JSON parsed value
* @param key
* @param defaultIfUndefined
* @returns {*}
*/
var get = function (key) {
var get = function (key,defaultIfUndefined) {
if (!hasLocalStorage()) {
return undefined;
}
if (key === "auth-tokens") {
return JSON.parse(localStorage.getItem(key));
} else {
return userSettings[key];
try {
var v = RED.utils.getMessageProperty(userSettings,key);
if (v === undefined) {
v = defaultIfUndefined;
}
} catch(err) {
v = defaultIfUndefined;
}
return v;
}
};
@ -131,6 +140,12 @@ RED.settings = (function () {
RED.settings.remove("auth-tokens");
}
console.log("Node-RED: " + data.version);
console.groupCollapsed("Versions");
console.log("jQuery",$().jquery)
console.log("jQuery UI",$.ui.version);
console.log("ACE",ace.version);
console.log("D3",d3.version);
console.groupEnd();
loadUserSettings(done);
},
error: function(jqXHR,textStatus,errorThrown) {

View File

@ -97,14 +97,14 @@ RED.text.bidi = (function() {
}
/**
* Enforces the text direction for all the spans with style bidiAware under
* Enforces the text direction for all the spans with style red-ui-text-bidi-aware under
* workspace or sidebar div
*/
function enforceTextDirectionOnPage() {
$("#workspace").find('span.bidiAware').each(function() {
$("#red-ui-workspace").find('span.red-ui-text-bidi-aware').each(function() {
$(this).attr("dir", resolveBaseTextDir($(this).html()));
});
$("#sidebar").find('span.bidiAware').each(function() {
$("#red-ui-sidebar").find('span.red-ui-text-bidi-aware').each(function() {
$(this).attr("dir", resolveBaseTextDir($(this).text()));
});
}

View File

@ -0,0 +1,230 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* 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.actionList = (function() {
var disabled = false;
var dialog = null;
var searchInput;
var searchResults;
var selected = -1;
var visible = false;
var filterTerm = "";
var filterTerms = [];
var previousActiveElement;
function ensureSelectedIsVisible() {
var selectedEntry = searchResults.find("li.selected");
if (selectedEntry.length === 1) {
var scrollWindow = searchResults.parent();
var scrollHeight = scrollWindow.height();
var scrollOffset = scrollWindow.scrollTop();
var y = selectedEntry.position().top;
var h = selectedEntry.height();
if (y+h > scrollHeight) {
scrollWindow.animate({scrollTop: '-='+(scrollHeight-(y+h)-10)},50);
} else if (y<0) {
scrollWindow.animate({scrollTop: '+='+(y-10)},50);
}
}
}
function createDialog() {
dialog = $("<div>",{id:"red-ui-actionList",class:"red-ui-search"}).appendTo("#red-ui-main-container");
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
searchInput = $('<input type="text" data-i18n="[placeholder]keyboard.filterActions">').appendTo(searchDiv).searchBox({
change: function() {
filterTerm = $(this).val().trim();
filterTerms = filterTerm.split(" ");
searchResults.editableList('filter');
searchResults.find("li.selected").removeClass("selected");
var children = searchResults.children(":visible");
if (children.length) {
$(children[0]).addClass('selected');
}
}
});
searchInput.on('keydown',function(evt) {
var selectedChild;
if (evt.keyCode === 40) {
// Down
selectedChild = searchResults.find("li.selected");
if (!selectedChild.length) {
var children = searchResults.children(":visible");
if (children.length) {
$(children[0]).addClass('selected');
}
} else {
var nextChild = selectedChild.nextAll(":visible").first();
if (nextChild.length) {
selectedChild.removeClass('selected');
nextChild.addClass('selected');
}
}
ensureSelectedIsVisible();
evt.preventDefault();
} else if (evt.keyCode === 38) {
// Up
selectedChild = searchResults.find("li.selected");
var nextChild = selectedChild.prevAll(":visible").first();
if (nextChild.length) {
selectedChild.removeClass('selected');
nextChild.addClass('selected');
}
ensureSelectedIsVisible();
evt.preventDefault();
} else if (evt.keyCode === 13) {
// Enter
selectedChild = searchResults.find("li.selected");
selectCommand(searchResults.editableList('getItem',selectedChild));
}
});
searchInput.i18n();
var searchResultsDiv = $("<div>",{class:"red-ui-search-results-container"}).appendTo(dialog);
searchResults = $('<ol>',{style:"position: absolute;top: 5px;bottom: 5px;left: 5px;right: 5px;"}).appendTo(searchResultsDiv).editableList({
addButton: false,
addItem: function(container,i,action) {
if (action.id === undefined) {
$('<div>',{class:"red-ui-search-empty"}).text(RED._('search.empty')).appendTo(container);
} else {
var div = $('<a>',{href:'#',class:"red-ui-search-result"}).appendTo(container);
var contentDiv = $('<div>',{class:"red-ui-search-result-action"}).appendTo(div);
$('<div>').text(action.label).appendTo(contentDiv);
// $('<div>',{class:"red-ui-search-result-node-type"}).text(node.type).appendTo(contentDiv);
// $('<div>',{class:"red-ui-search-result-node-id"}).text(node.id).appendTo(contentDiv);
if (action.key) {
$('<div>',{class:"red-ui-search-result-action-key"}).html(RED.keyboard.formatKey(action.key)).appendTo(contentDiv);
}
div.on("click", function(evt) {
evt.preventDefault();
selectCommand(action);
});
}
},
scrollOnAdd: false,
filter: function(item) {
if (filterTerm !== "") {
var pos=0;
for (var i=0;i<filterTerms.length;i++) {
var j = item._label.indexOf(filterTerms[i],pos);
if (j > -1) {
pos = j;
} else {
return false;
}
}
return true;
}
return true;
}
});
}
function selectCommand(command) {
hide();
if (command) {
RED.actions.invoke(command.id);
}
}
function show(v) {
if (disabled) {
return;
}
if (!visible) {
previousActiveElement = document.activeElement;
RED.keyboard.add("*","escape",function(){hide()});
$("#red-ui-header-shade").show();
$("#red-ui-editor-shade").show();
$("#red-ui-palette-shade").show();
$("#red-ui-sidebar-shade").show();
$("#red-ui-sidebar-separator").hide();
if (dialog === null) {
createDialog();
}
dialog.slideDown(300);
searchInput.searchBox('value',v)
searchResults.editableList('empty');
results = [];
var actions = RED.actions.list();
actions.sort(function(A,B) {
return A.id.localeCompare(B.id);
});
actions.forEach(function(action) {
action.label = action.id.replace(/:/,": ").replace(/-/g," ").replace(/(^| )./g,function() { return arguments[0].toUpperCase()});
action._label = action.label.toLowerCase();
searchResults.editableList('addItem',action)
})
RED.events.emit("actionList:open");
visible = true;
}
searchInput.trigger("focus");
var children = searchResults.children(":visible");
if (children.length) {
$(children[0]).addClass('selected');
}
}
function hide() {
if (visible) {
RED.keyboard.remove("escape");
visible = false;
$("#red-ui-header-shade").hide();
$("#red-ui-editor-shade").hide();
$("#red-ui-palette-shade").hide();
$("#red-ui-sidebar-shade").hide();
$("#red-ui-sidebar-separator").show();
if (dialog !== null) {
dialog.slideUp(200,function() {
searchInput.searchBox('value','');
});
}
RED.events.emit("actionList:close");
if (previousActiveElement) {
$(previousActiveElement).trigger("focus");
previousActiveElement = null;
}
}
}
function init() {
RED.actions.add("core:show-action-list",show);
RED.events.on("editor:open",function() { disabled = true; });
RED.events.on("editor:close",function() { disabled = false; });
RED.events.on("search:open",function() { disabled = true; });
RED.events.on("search:close",function() { disabled = false; });
RED.events.on("type-search:open",function() { disabled = true; });
RED.events.on("type-search:close",function() { disabled = false; });
$("#red-ui-header-shade").on('mousedown',hide);
$("#red-ui-editor-shade").on('mousedown',hide);
$("#red-ui-palette-shade").on('mousedown',hide);
$("#red-ui-sidebar-shade").on('mousedown',hide);
}
return {
init: init,
show: show,
hide: hide
};
})();

View File

@ -24,38 +24,38 @@ RED.clipboard = (function() {
var disabled = false;
var popover;
var currentPopoverError;
var activeTab;
var libraryBrowser;
var examplesBrowser;
function setupDialogs() {
dialog = $('<div id="clipboard-dialog" class="hide node-red-dialog"><form class="dialog-form form-horizontal"></form></div>')
.appendTo("body")
dialog = $('<div id="red-ui-clipboard-dialog" class="hide"><form class="dialog-form form-horizontal"></form></div>')
.appendTo("#red-ui-editor")
.dialog({
modal: true,
autoOpen: false,
width: 500,
width: 700,
resizable: false,
classes: {
"ui-dialog": "red-ui-editor-dialog",
"ui-dialog-titlebar-close": "hide",
"ui-widget-overlay": "red-ui-editor-dialog"
},
buttons: [
{
id: "clipboard-dialog-cancel",
id: "red-ui-clipboard-dialog-cancel",
text: RED._("common.label.cancel"),
click: function() {
$( this ).dialog( "close" );
}
},
{
id: "clipboard-dialog-close",
class: "primary",
text: RED._("common.label.close"),
click: function() {
$( this ).dialog( "close" );
}
},
{
id: "clipboard-dialog-download",
id: "red-ui-clipboard-dialog-download",
class: "primary",
text: RED._("clipboard.download"),
click: function() {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent($("#clipboard-export").val()));
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent($("#red-ui-clipboard-dialog-export-text").val()));
element.setAttribute('download', "flows.json");
element.style.display = 'none';
document.body.appendChild(element);
@ -65,30 +65,100 @@ RED.clipboard = (function() {
}
},
{
id: "clipboard-dialog-copy",
id: "red-ui-clipboard-dialog-export",
class: "primary",
text: RED._("clipboard.export.copy"),
click: function() {
$("#clipboard-export").select();
document.execCommand("copy");
document.getSelection().removeAllRanges();
RED.notify(RED._("clipboard.nodesExported"),{id:"clipboard"});
$( this ).dialog( "close" );
if (activeTab === "red-ui-clipboard-dialog-export-tab-clipboard") {
$("#red-ui-clipboard-dialog-export-text").select();
document.execCommand("copy");
document.getSelection().removeAllRanges();
RED.notify(RED._("clipboard.nodesExported"),{id:"clipboard"});
$( this ).dialog( "close" );
} else {
var flowToExport = $("#red-ui-clipboard-dialog-export-text").val();
var selectedPath = libraryBrowser.getSelected();
if (!selectedPath.children) {
selectedPath = selectedPath.parent;
}
var filename = $("#red-ui-clipboard-dialog-tab-library-name").val().trim();
var saveFlow = function() {
$.ajax({
url:'library/'+selectedPath.library+'/'+selectedPath.type+'/'+selectedPath.path + filename,
type: "POST",
data: flowToExport,
contentType: "application/json; charset=utf-8"
}).done(function() {
$(dialog).dialog( "close" );
RED.notify(RED._("library.exportedToLibrary"),"success");
}).fail(function(xhr,textStatus,err) {
if (xhr.status === 401) {
RED.notify(RED._("library.saveFailed",{message:RED._("user.notAuthorized")}),"error");
} else {
RED.notify(RED._("library.saveFailed",{message:xhr.responseText}),"error");
}
});
}
if (selectedPath.children) {
var exists = false;
selectedPath.children.forEach(function(f) {
if (f.label === filename) {
exists = true;
}
});
if (exists) {
dialog.dialog("close");
var notification = RED.notify(RED._("clipboard.export.exists",{file:RED.utils.sanitize(filename)}),{
type: "warning",
fixed: true,
buttons: [{
text: RED._("common.label.cancel"),
click: function() {
notification.hideNotification()
dialog.dialog( "open" );
}
},{
text: RED._("clipboard.export.overwrite"),
click: function() {
notification.hideNotification()
saveFlow();
}
}]
});
} else {
saveFlow();
}
} else {
saveFlow();
}
}
}
},
{
id: "clipboard-dialog-ok",
id: "red-ui-clipboard-dialog-ok",
class: "primary",
text: RED._("common.label.import"),
click: function() {
RED.view.importNodes($("#clipboard-import").val(),$("#import-tab > a.selected").attr('id') === 'import-tab-new');
var addNewFlow = ($("#red-ui-clipboard-dialog-import-opt > a.selected").attr('id') === 'red-ui-clipboard-dialog-import-opt-new');
if (activeTab === "red-ui-clipboard-dialog-import-tab-clipboard") {
RED.view.importNodes($("#red-ui-clipboard-dialog-import-text").val(),addNewFlow);
} else {
var selectedPath;
if (activeTab === "red-ui-clipboard-dialog-import-tab-library") {
selectedPath = libraryBrowser.getSelected();
} else {
selectedPath = examplesBrowser.getSelected();
}
if (selectedPath.path) {
$.get('library/'+selectedPath.library+'/'+selectedPath.type+'/'+selectedPath.path, function(data) {
RED.view.importNodes(data,addNewFlow);
});
}
}
$( this ).dialog( "close" );
}
}
],
open: function(e) {
$(this).parent().find(".ui-dialog-titlebar-close").hide();
},
close: function(e) {
if (popover) {
popover.close(true);
@ -101,152 +171,281 @@ RED.clipboard = (function() {
exportNodesDialog =
'<div class="form-row">'+
'<label style="width:auto;margin-right: 10px;" data-i18n="clipboard.export.copy"></label>'+
'<span id="export-range-group" class="button-group">'+
'<a id="export-range-selected" class="editor-button toggle" href="#" data-i18n="clipboard.export.selected"></a>'+
'<a id="export-range-flow" class="editor-button toggle" href="#" data-i18n="clipboard.export.current"></a>'+
'<a id="export-range-full" class="editor-button toggle" href="#" data-i18n="clipboard.export.all"></a>'+
'<label style="width:auto;margin-right: 10px;" data-i18n="common.label.export"></label>'+
'<span id="red-ui-clipboard-dialog-export-rng-group" class="button-group">'+
'<a id="red-ui-clipboard-dialog-export-rng-selected" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.selected"></a>'+
'<a id="red-ui-clipboard-dialog-export-rng-flow" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.current"></a>'+
'<a id="red-ui-clipboard-dialog-export-rng-full" class="red-ui-button toggle" href="#" data-i18n="clipboard.export.all"></a>'+
'</span>'+
'</div>'+
'<div class="form-row">'+
'<textarea readonly style="resize: none; width: 100%; border-radius: 4px;font-family: monospace; font-size: 12px; background:#f3f3f3; padding-left: 0.5em; box-sizing:border-box;" id="clipboard-export" rows="5"></textarea>'+
'</div>'+
'<div class="form-row" style="text-align: right;">'+
'<span id="export-format-group" class="button-group">'+
'<a id="export-format-mini" class="editor-button editor-button-small toggle" href="#" data-i18n="clipboard.export.compact"></a>'+
'<a id="export-format-full" class="editor-button editor-button-small toggle" href="#" data-i18n="clipboard.export.formatted"></a>'+
'</span>'+
'</div>';
'<div class="red-ui-clipboard-dialog-box">'+
'<div class="red-ui-clipboard-dialog-tabs">'+
'<ul id="red-ui-clipboard-dialog-export-tabs"></ul>'+
'</div>'+
'<div id="red-ui-clipboard-dialog-export-tabs-content" class="red-ui-clipboard-dialog-tabs-content">'+
'<div id="red-ui-clipboard-dialog-export-tab-clipboard" class="red-ui-clipboard-dialog-tab-clipboard">'+
'<div class="form-row">'+
'<textarea readonly id="red-ui-clipboard-dialog-export-text"></textarea>'+
'</div>'+
'<div class="form-row" style="text-align: right;">'+
'<span id="red-ui-clipboard-dialog-export-fmt-group" class="button-group">'+
'<a id="red-ui-clipboard-dialog-export-fmt-mini" class="red-ui-button red-ui-button-small toggle" href="#" data-i18n="clipboard.export.compact"></a>'+
'<a id="red-ui-clipboard-dialog-export-fmt-full" class="red-ui-button red-ui-button-small toggle" href="#" data-i18n="clipboard.export.formatted"></a>'+
'</span>'+
'</div>'+
'</div>'+
'<div id="red-ui-clipboard-dialog-export-tab-library" class="red-ui-clipboard-dialog-tab-library">'+
'<div id="red-ui-clipboard-dialog-export-tab-library-browser"></div>'+
'<div class="form-row">'+
'<label data-i18n="clipboard.export.exportAs"></label><input id="red-ui-clipboard-dialog-tab-library-name" type="text">'+
'</div>'+
'</div>'+
'</div>'+
'</div>'
;
importNodesDialog =
'<div class="form-row"><span data-i18n="clipboard.pasteNodes"></span>'+
' <a class="editor-button" id="import-file-upload-btn"><i class="fa fa-upload"></i> <span data-i18n="clipboard.selectFile"></span></a>'+
'<input type="file" id="import-file-upload" accept=".json" style="display:none">'+
'<div class="red-ui-clipboard-dialog-box" style="margin-bottom: 12px">'+
'<div class="red-ui-clipboard-dialog-tabs">'+
'<ul id="red-ui-clipboard-dialog-import-tabs"></ul>'+
'</div>'+
'<div id="red-ui-clipboard-dialog-import-tabs-content" class="red-ui-clipboard-dialog-tabs-content">'+
'<div id="red-ui-clipboard-dialog-import-tab-clipboard" class="red-ui-clipboard-dialog-tab-clipboard">'+
'<div class="form-row"><span data-i18n="clipboard.pasteNodes"></span>'+
' <a class="red-ui-button" id="red-ui-clipboard-dialog-import-file-upload-btn"><i class="fa fa-upload"></i> <span data-i18n="clipboard.selectFile"></span></a>'+
'<input type="file" id="red-ui-clipboard-dialog-import-file-upload" accept=".json" style="display:none">'+
'</div>'+
'<div class="form-row">'+
'<textarea id="red-ui-clipboard-dialog-import-text"></textarea>'+
'</div>'+
'</div>'+
'<div id="red-ui-clipboard-dialog-import-tab-library" class="red-ui-clipboard-dialog-tab-library"></div>'+
'<div id="red-ui-clipboard-dialog-import-tab-examples" class="red-ui-clipboard-dialog-tab-library"></div>'+
'</div>'+
'</div>'+
'<div class="form-row">'+
'<textarea style="resize: none; width: 100%; border-radius: 0px;font-family: monospace; font-size: 12px; background:#eee; padding-left: 0.5em; box-sizing:border-box;" id="clipboard-import" rows="5"></textarea>'+
'</div>'+
'<div class="form-row">'+
'<label style="width:auto;margin-right: 10px;" data-i18n="clipboard.import.import"></label>'+
'<span id="import-tab" class="button-group">'+
'<a id="import-tab-current" class="editor-button toggle selected" href="#" data-i18n="clipboard.export.current"></a>'+
'<a id="import-tab-new" class="editor-button toggle" href="#" data-i18n="clipboard.import.newFlow"></a>'+
'</span>'+
'<label style="width:auto;margin-right: 10px;" data-i18n="clipboard.import.import"></label>'+
'<span id="red-ui-clipboard-dialog-import-opt" class="button-group">'+
'<a id="red-ui-clipboard-dialog-import-opt-current" class="red-ui-button toggle selected" href="#" data-i18n="clipboard.export.current"></a>'+
'<a id="red-ui-clipboard-dialog-import-opt-new" class="red-ui-button toggle" href="#" data-i18n="clipboard.import.newFlow"></a>'+
'</span>'+
'</div>';
}
var validateImportTimeout;
function validateImport() {
if (validateImportTimeout) {
clearTimeout(validateImportTimeout);
var validateExportFilenameTimeout
function validateExportFilename() {
if (validateExportFilenameTimeout) {
clearTimeout(validateExportFilenameTimeout);
}
validateImportTimeout = setTimeout(function() {
var importInput = $("#clipboard-import");
var v = importInput.val().trim();
if (v === "") {
popover.close(true);
currentPopoverError = null;
importInput.removeClass("input-error");
$("#clipboard-dialog-ok").button("disable");
return;
}
try {
if (!/^\[[\s\S]*\]$/m.test(v)) {
throw new Error(RED._("clipboard.import.errors.notArray"));
}
var res = JSON.parse(v);
for (var i=0;i<res.length;i++) {
if (typeof res[i] !== "object") {
throw new Error(RED._("clipboard.import.errors.itemNotObject",{index:i}));
}
if (!res[i].hasOwnProperty('id')) {
throw new Error(RED._("clipboard.import.errors.missingId",{index:i}));
}
if (!res[i].hasOwnProperty('type')) {
throw new Error(RED._("clipboard.import.errors.missingType",{index:i}));
}
}
currentPopoverError = null;
popover.close(true);
importInput.removeClass("input-error");
importInput.val(v);
$("#clipboard-dialog-ok").button("enable");
} catch(err) {
if (v !== "") {
importInput.addClass("input-error");
var errString = err.toString();
if (errString !== currentPopoverError) {
// Display the error as-is.
// Error messages are only in English. Each browser has its
// own set of messages with very little consistency.
// To provide translated messages this code will either need to:
// - reduce everything down to 'unexpected token at position x'
// which is the least useful, but most consistent message
// - use a custom/library parser that gives consistent messages
// which can be translated.
var message = $('<div class="clipboard-import-error"></div>').text(errString);
var errorPos;
// Chrome error messages
var m = /at position (\d+)/i.exec(errString);
if (m) {
errorPos = parseInt(m[1]);
} else {
// Firefox error messages
m = /at line (\d+) column (\d+)/i.exec(errString);
if (m) {
var line = parseInt(m[1])-1;
var col = parseInt(m[2])-1;
var lines = v.split("\n");
errorPos = 0;
for (var i=0;i<line;i++) {
errorPos += lines[i].length+1;
}
errorPos += col;
} else {
// Safari doesn't provide any position information
// IE: tbd
}
}
if (errorPos !== undefined) {
v = v.replace(/\n/g,"↵");
var index = parseInt(m[1]);
var parseError = $('<div>').appendTo(message);
var code = $('<pre>').appendTo(parseError);
$('<span>').text(v.substring(errorPos-12,errorPos)).appendTo(code)
$('<span class="error">').text(v.charAt(errorPos)).appendTo(code);
$('<span>').text(v.substring(errorPos+1,errorPos+12)).appendTo(code);
}
popover.close(true).setContent(message).open();
currentPopoverError = errString;
}
} else {
currentPopoverError = null;
}
$("#clipboard-dialog-ok").button("disable");
validateExportFilenameTimeout = setTimeout(function() {
var filenameInput = $("#red-ui-clipboard-dialog-tab-library-name");
var filename = filenameInput.val().trim();
var valid = filename.length > 0 && !/[\/\\]/.test(filename);
if (valid) {
filenameInput.removeClass("input-error");
$("#red-ui-clipboard-dialog-export").button("enable");
} else {
filenameInput.addClass("input-error");
$("#red-ui-clipboard-dialog-export").button("disable");
}
},100);
}
function importNodes() {
var validateImportTimeout;
function validateImport() {
if (activeTab === "red-ui-clipboard-dialog-import-tab-clipboard") {
if (validateImportTimeout) {
clearTimeout(validateImportTimeout);
}
validateImportTimeout = setTimeout(function() {
var importInput = $("#red-ui-clipboard-dialog-import-text");
var v = importInput.val().trim();
if (v === "") {
popover.close(true);
currentPopoverError = null;
importInput.removeClass("input-error");
$("#red-ui-clipboard-dialog-ok").button("disable");
return;
}
try {
if (!/^\[[\s\S]*\]$/m.test(v)) {
throw new Error(RED._("clipboard.import.errors.notArray"));
}
var res = JSON.parse(v);
for (var i=0;i<res.length;i++) {
if (typeof res[i] !== "object") {
throw new Error(RED._("clipboard.import.errors.itemNotObject",{index:i}));
}
if (!res[i].hasOwnProperty('id')) {
throw new Error(RED._("clipboard.import.errors.missingId",{index:i}));
}
if (!res[i].hasOwnProperty('type')) {
throw new Error(RED._("clipboard.import.errors.missingType",{index:i}));
}
}
currentPopoverError = null;
popover.close(true);
importInput.removeClass("input-error");
importInput.val(v);
$("#red-ui-clipboard-dialog-ok").button("enable");
} catch(err) {
if (v !== "") {
importInput.addClass("input-error");
var errString = err.toString();
if (errString !== currentPopoverError) {
// Display the error as-is.
// Error messages are only in English. Each browser has its
// own set of messages with very little consistency.
// To provide translated messages this code will either need to:
// - reduce everything down to 'unexpected token at position x'
// which is the least useful, but most consistent message
// - use a custom/library parser that gives consistent messages
// which can be translated.
var message = $('<div class="red-ui-clipboard-import-error"></div>').text(errString);
var errorPos;
// Chrome error messages
var m = /at position (\d+)/i.exec(errString);
if (m) {
errorPos = parseInt(m[1]);
} else {
// Firefox error messages
m = /at line (\d+) column (\d+)/i.exec(errString);
if (m) {
var line = parseInt(m[1])-1;
var col = parseInt(m[2])-1;
var lines = v.split("\n");
errorPos = 0;
for (var i=0;i<line;i++) {
errorPos += lines[i].length+1;
}
errorPos += col;
} else {
// Safari doesn't provide any position information
// IE: tbd
}
}
if (errorPos !== undefined) {
v = v.replace(/\n/g,"↵");
var index = parseInt(m[1]);
var parseError = $('<div>').appendTo(message);
var code = $('<pre>').appendTo(parseError);
$('<span>').text(v.substring(errorPos-12,errorPos)).appendTo(code)
$('<span class="error">').text(v.charAt(errorPos)).appendTo(code);
$('<span>').text(v.substring(errorPos+1,errorPos+12)).appendTo(code);
}
popover.close(true).setContent(message).open();
currentPopoverError = errString;
}
} else {
currentPopoverError = null;
}
$("#red-ui-clipboard-dialog-ok").button("disable");
}
},100);
} else {
var file = libraryBrowser.getSelected();
if (file && file.label && !file.children) {
$("#red-ui-clipboard-dialog-ok").button("enable");
} else {
$("#red-ui-clipboard-dialog-ok").button("disable");
}
}
}
function importNodes(mode) {
if (disabled) {
return;
}
mode = mode || "clipboard";
dialogContainer.empty();
dialogContainer.append($(importNodesDialog));
var tabs = RED.tabs.create({
id: "red-ui-clipboard-dialog-import-tabs",
vertical: true,
onchange: function(tab) {
$("#red-ui-clipboard-dialog-import-tabs-content").children().hide();
$("#" + tab.id).show();
activeTab = tab.id;
if (popover) {
popover.close(true);
currentPopoverError = null;
}
if (tab.id === "red-ui-clipboard-dialog-import-tab-clipboard") {
$("#red-ui-clipboard-dialog-import-text").trigger("focus");
} else {
libraryBrowser.focus();
}
validateImport();
}
});
tabs.addTab({
id: "red-ui-clipboard-dialog-import-tab-clipboard",
label: RED._("clipboard.clipboard")
});
tabs.addTab({
id: "red-ui-clipboard-dialog-import-tab-library",
label: RED._("library.library")
});
tabs.addTab({
id: "red-ui-clipboard-dialog-import-tab-examples",
label: RED._("library.types.examples")
});
$("#red-ui-clipboard-dialog-tab-library-name").on("keyup", validateExportFilename);
$("#red-ui-clipboard-dialog-tab-library-name").on('paste',function() { setTimeout(validateExportFilename,10)});
$("#red-ui-clipboard-dialog-export").button("enable");
libraryBrowser = RED.library.createBrowser({
container: $("#red-ui-clipboard-dialog-import-tab-library"),
onselect: function(file) {
if (file && file.label && !file.children) {
$("#red-ui-clipboard-dialog-ok").button("enable");
} else {
$("#red-ui-clipboard-dialog-ok").button("disable");
}
},
onconfirm: function(item) {
if (item && item.label && !item.children) {
$("#red-ui-clipboard-dialog-ok").trigger("click");
}
}
})
loadFlowLibrary(libraryBrowser,"local",RED._("library.types.local"));
examplesBrowser = RED.library.createBrowser({
container: $("#red-ui-clipboard-dialog-import-tab-examples"),
onselect: function(file) {
if (file && file.label && !file.children) {
$("#red-ui-clipboard-dialog-ok").button("enable");
} else {
$("#red-ui-clipboard-dialog-ok").button("disable");
}
},
onconfirm: function(item) {
if (item && item.label && !item.children) {
$("#red-ui-clipboard-dialog-ok").trigger("click");
}
}
})
loadFlowLibrary(examplesBrowser,"_examples_",RED._("library.types.examples"));
dialogContainer.i18n();
$("#clipboard-dialog-ok").show();
$("#clipboard-dialog-cancel").show();
$("#clipboard-dialog-close").hide();
$("#clipboard-dialog-copy").hide();
$("#clipboard-dialog-download").hide();
$("#clipboard-dialog-ok").button("disable");
$("#clipboard-import").keyup(validateImport);
$("#clipboard-import").on('paste',function() { setTimeout(validateImport,10)});
$("#red-ui-clipboard-dialog-ok").show();
$("#red-ui-clipboard-dialog-cancel").show();
$("#red-ui-clipboard-dialog-export").hide();
$("#red-ui-clipboard-dialog-download").hide();
$("#red-ui-clipboard-dialog-ok").button("disable");
$("#red-ui-clipboard-dialog-import-text").on("keyup", validateImport);
$("#red-ui-clipboard-dialog-import-text").on('paste',function() { setTimeout(validateImport,10)});
$("#import-tab > a").click(function(evt) {
$("#red-ui-clipboard-dialog-import-opt > a").on("click", function(evt) {
evt.preventDefault();
if ($(this).hasClass('disabled') || $(this).hasClass('selected')) {
return;
@ -255,66 +454,122 @@ RED.clipboard = (function() {
$(this).addClass('selected');
});
$("#import-file-upload").change(function() {
$("#red-ui-clipboard-dialog-import-file-upload").on("change", function() {
var fileReader = new FileReader();
fileReader.onload = function () {
$("#clipboard-import").val(fileReader.result);
$("#red-ui-clipboard-dialog-import-text").val(fileReader.result);
validateImport();
};
fileReader.readAsText($(this).prop('files')[0]);
})
$("#import-file-upload-btn").click(function(evt) {
$("#red-ui-clipboard-dialog-import-file-upload-btn").on("click", function(evt) {
evt.preventDefault();
$("#import-file-upload").click();
$("#red-ui-clipboard-dialog-import-file-upload").trigger("click");
})
tabs.activateTab("red-ui-clipboard-dialog-import-tab-"+mode);
if (mode === 'clipboard') {
setTimeout(function() {
$("#red-ui-clipboard-dialog-import-text").trigger("focus");
},100)
}
dialog.dialog("option","title",RED._("clipboard.importNodes")).dialog("open");
popover = RED.popover.create({
target: $("#clipboard-import"),
target: $("#red-ui-clipboard-dialog-import-text"),
trigger: "manual",
direction: "bottom",
content: ""
});
}
function exportNodes() {
function exportNodes(mode) {
if (disabled) {
return;
}
mode = mode || "clipboard";
dialogContainer.empty();
dialogContainer.append($(exportNodesDialog));
dialogContainer.i18n();
var format = RED.settings.flowFilePretty ? "export-format-full" : "export-format-mini";
$("#export-format-group > a").click(function(evt) {
var tabs = RED.tabs.create({
id: "red-ui-clipboard-dialog-export-tabs",
vertical: true,
onchange: function(tab) {
$("#red-ui-clipboard-dialog-export-tabs-content").children().hide();
$("#" + tab.id).show();
activeTab = tab.id;
if (tab.id === "red-ui-clipboard-dialog-export-tab-clipboard") {
$("#red-ui-clipboard-dialog-export").button("option","label", RED._("clipboard.export.copy"))
$("#red-ui-clipboard-dialog-download").show();
} else {
$("#red-ui-clipboard-dialog-export").button("option","label", RED._("clipboard.export.export"))
$("#red-ui-clipboard-dialog-download").hide();
libraryBrowser.focus();
}
}
});
tabs.addTab({
id: "red-ui-clipboard-dialog-export-tab-clipboard",
label: RED._("clipboard.clipboard")
});
tabs.addTab({
id: "red-ui-clipboard-dialog-export-tab-library",
label: RED._("library.library")
});
$("#red-ui-clipboard-dialog-tab-library-name").on("keyup", validateExportFilename);
$("#red-ui-clipboard-dialog-tab-library-name").on('paste',function() { setTimeout(validateExportFilename,10)});
$("#red-ui-clipboard-dialog-export").button("enable");
libraryBrowser = RED.library.createBrowser({
container: $("#red-ui-clipboard-dialog-export-tab-library-browser"),
folderTools: true,
onselect: function(file) {
if (file && file.label && !file.children) {
$("#red-ui-clipboard-dialog-tab-library-name").val(file.label);
}
}
})
loadFlowLibrary(libraryBrowser,"local",RED._("library.types.local"));
$("#red-ui-clipboard-dialog-tab-library-name").val("flows.json").select();
dialogContainer.i18n();
var format = RED.settings.flowFilePretty ? "red-ui-clipboard-dialog-export-fmt-full" : "red-ui-clipboard-dialog-export-fmt-mini";
$("#red-ui-clipboard-dialog-export-fmt-group > a").on("click", function(evt) {
evt.preventDefault();
if ($(this).hasClass('disabled') || $(this).hasClass('selected')) {
$("#clipboard-export").focus();
$("#red-ui-clipboard-dialog-export-text").trigger("focus");
return;
}
$(this).parent().children().removeClass('selected');
$(this).addClass('selected');
var flow = $("#clipboard-export").val();
var flow = $("#red-ui-clipboard-dialog-export-text").val();
if (flow.length > 0) {
var nodes = JSON.parse(flow);
format = $(this).attr('id');
if (format === 'export-format-full') {
if (format === 'red-ui-clipboard-dialog-export-fmt-full') {
flow = JSON.stringify(nodes,null,4);
} else {
flow = JSON.stringify(nodes);
}
$("#clipboard-export").val(flow);
$("#clipboard-export").focus();
$("#red-ui-clipboard-dialog-export-text").val(flow);
setTimeout(function() { $("#red-ui-clipboard-dialog-export-text").scrollTop(0); },50);
$("#red-ui-clipboard-dialog-export-text").trigger("focus");
}
});
$("#export-range-group > a").click(function(evt) {
$("#red-ui-clipboard-dialog-export-rng-group > a").on("click", function(evt) {
evt.preventDefault();
if ($(this).hasClass('disabled') || $(this).hasClass('selected')) {
$("#clipboard-export").focus();
return;
}
$(this).parent().children().removeClass('selected');
@ -322,7 +577,7 @@ RED.clipboard = (function() {
var type = $(this).attr('id');
var flow = "";
var nodes = null;
if (type === 'export-range-selected') {
if (type === 'red-ui-clipboard-dialog-export-rng-selected') {
var selection = RED.workspaces.selection();
if (selection.length > 0) {
nodes = [];
@ -335,77 +590,97 @@ RED.clipboard = (function() {
}
// Don't include the subflow meta-port nodes in the exported selection
nodes = RED.nodes.createExportableNodeSet(nodes.filter(function(n) { return n.type !== 'subflow'}));
} else if (type === 'export-range-flow') {
} else if (type === 'red-ui-clipboard-dialog-export-rng-flow') {
var activeWorkspace = RED.workspaces.active();
nodes = RED.nodes.filterNodes({z:activeWorkspace});
var parentNode = RED.nodes.workspace(activeWorkspace)||RED.nodes.subflow(activeWorkspace);
nodes.unshift(parentNode);
nodes = RED.nodes.createExportableNodeSet(nodes);
} else if (type === 'export-range-full') {
} else if (type === 'red-ui-clipboard-dialog-export-rng-full') {
nodes = RED.nodes.createCompleteNodeSet(false);
}
if (nodes !== null) {
if (format === "export-format-full") {
if (format === "red-ui-clipboard-dialog-export-fmt-full") {
flow = JSON.stringify(nodes,null,4);
} else {
flow = JSON.stringify(nodes);
}
}
if (flow.length > 0) {
$("#export-copy").removeClass('disabled');
$("#red-ui-clipboard-dialog-export").removeClass('disabled');
} else {
$("#export-copy").addClass('disabled');
$("#red-ui-clipboard-dialog-export").addClass('disabled');
}
$("#clipboard-export").val(flow);
$("#clipboard-export").focus();
$("#red-ui-clipboard-dialog-export-text").val(flow);
setTimeout(function() { $("#red-ui-clipboard-dialog-export-text").scrollTop(0); },50);
$("#red-ui-clipboard-dialog-export-text").trigger("focus");
})
$("#clipboard-dialog-ok").hide();
$("#clipboard-dialog-cancel").hide();
$("#clipboard-dialog-copy").hide();
$("#clipboard-dialog-close").hide();
$("#red-ui-clipboard-dialog-ok").hide();
$("#red-ui-clipboard-dialog-cancel").hide();
$("#red-ui-clipboard-dialog-export").hide();
var selection = RED.workspaces.selection();
if (selection.length > 0) {
$("#export-range-selected").click();
$("#red-ui-clipboard-dialog-export-rng-selected").trigger("click");
} else {
selection = RED.view.selection();
if (selection.nodes) {
$("#export-range-selected").click();
$("#red-ui-clipboard-dialog-export-rng-selected").trigger("click");
} else {
$("#export-range-selected").addClass('disabled').removeClass('selected');
$("#export-range-flow").click();
$("#red-ui-clipboard-dialog-export-rng-selected").addClass('disabled').removeClass('selected');
$("#red-ui-clipboard-dialog-export-rng-flow").trigger("click");
}
}
if (format === "export-format-full") {
$("#export-format-full").click();
if (format === "red-ui-clipboard-dialog-export-fmt-full") {
$("#red-ui-clipboard-dialog-export-fmt-full").trigger("click");
} else {
$("#export-format-mini").click();
$("#red-ui-clipboard-dialog-export-fmt-mini").trigger("click");
}
$("#clipboard-export")
.focus(function() {
var textarea = $(this);
textarea.select();
textarea.mouseup(function() {
textarea.unbind("mouseup");
return false;
})
});
tabs.activateTab("red-ui-clipboard-dialog-export-tab-"+mode);
dialog.dialog("option","title",RED._("clipboard.exportNodes")).dialog( "open" );
$("#clipboard-export").focus();
if (!document.queryCommandSupported("copy")) {
$("#clipboard-dialog-cancel").hide();
$("#clipboard-dialog-close").show();
} else {
$("#clipboard-dialog-cancel").show();
$("#clipboard-dialog-copy").show();
}
$("#clipboard-dialog-download").show();
$("#red-ui-clipboard-dialog-export-text").trigger("focus");
$("#red-ui-clipboard-dialog-cancel").show();
$("#red-ui-clipboard-dialog-export").show();
$("#red-ui-clipboard-dialog-download").show();
}
function loadFlowLibrary(browser,library,label) {
// if (includeExamples) {
// listing.push({
// library: "_examples_",
// type: "flows",
// icon: 'fa fa-hdd-o',
// label: RED._("library.types.examples"),
// path: "",
// children: function(done,item) {
// RED.library.loadLibraryFolder("_examples_","flows","",function(children) {
// item.children = children;
// done(children);
// })
// }
// })
// }
browser.data([{
library: library,
type: "flows",
icon: 'fa fa-hdd-o',
label: label,
path: "",
expanded: true,
children: function(done, item) {
RED.library.loadLibraryFolder(library,"flows","",function(children) {
item.children = children;
done(children);
})
}
}], true);
}
function hideDropTarget() {
$("#dropTarget").hide();
$("#red-ui-drop-target").hide();
RED.keyboard.remove("escape");
}
function copyText(value,element,msg) {
@ -435,7 +710,7 @@ RED.clipboard = (function() {
if (truncated) {
msg += "_truncated";
}
$("#clipboard-hidden").val(value).select();
$("#red-ui-clipboard-hidden").val(value).select();
var result = document.execCommand("copy");
if (result && element) {
var popover = RED.popover.create({
@ -455,29 +730,34 @@ RED.clipboard = (function() {
init: function() {
setupDialogs();
$('<input type="text" id="clipboard-hidden">').appendTo("body");
$('<input type="text" id="red-ui-clipboard-hidden" tabIndex="-1">').appendTo("#red-ui-editor");
RED.actions.add("core:show-export-dialog",exportNodes);
RED.actions.add("core:show-import-dialog",importNodes);
RED.actions.add("core:show-library-export-dialog",function() { exportNodes('library') });
RED.actions.add("core:show-library-import-dialog",function() { importNodes('library') });
RED.events.on("editor:open",function() { disabled = true; });
RED.events.on("editor:close",function() { disabled = false; });
RED.events.on("search:open",function() { disabled = true; });
RED.events.on("search:close",function() { disabled = false; });
RED.events.on("actionList:open",function() { disabled = true; });
RED.events.on("actionList:close",function() { disabled = false; });
RED.events.on("type-search:open",function() { disabled = true; });
RED.events.on("type-search:close",function() { disabled = false; });
$('<div id="red-ui-drop-target"><div data-i18n="[append]workspace.dropFlowHere"><i class="fa fa-download"></i><br></div></div>').appendTo('#red-ui-editor');
$('#chart').on("dragenter",function(event) {
$('#red-ui-workspace-chart').on("dragenter",function(event) {
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1 ||
$.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
$("#dropTarget").css({display:'table'});
$("#red-ui-drop-target").css({display:'table'});
RED.keyboard.add("*", "escape" ,hideDropTarget);
}
});
$('#dropTarget').on("dragover",function(event) {
$('#red-ui-drop-target').on("dragover",function(event) {
if ($.inArray("text/plain",event.originalEvent.dataTransfer.types) != -1 ||
$.inArray("Files",event.originalEvent.dataTransfer.types) != -1) {
event.preventDefault();

View File

@ -38,7 +38,7 @@
this.options[0].show();
}
this.element.change(function() {
this.element.on("change", function() {
if (this.checked) {
that.options[0].hide();
that.options[1].show();
@ -53,7 +53,7 @@
child.checkboxSet('state',isChecked,false,true);
})
})
this.uiElement.click(function(e) {
this.uiElement.on("click", function(e) {
e.stopPropagation();
// state returns null for a partial state. Clicking on that should
// result in false.

View File

@ -32,7 +32,10 @@
* - scrollOnAdd : boolean - whether to scroll to newly added items
* methods:
* - addItem(itemData)
* - insertItemAt : function(data,index) - add an item at the specified index
* - removeItem(itemData)
* - getItemAt(index)
* - indexOf(itemData)
* - width(width)
* - height(height)
* - items()
@ -75,9 +78,9 @@
addLabel = 'add';
}
}
$('<a href="#" class="editor-button editor-button-small red-ui-editableList-addButton" style="margin-top: 4px;"><i class="fa fa-plus"></i> '+addLabel+'</a>')
$('<a href="#" class="red-ui-button red-ui-button-small red-ui-editableList-addButton" style="margin-top: 4px;"><i class="fa fa-plus"></i> '+addLabel+'</a>')
.appendTo(this.topContainer)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
that.addItem({});
});
@ -185,6 +188,11 @@
}
},
_destroy: function() {
if (this.topContainer) {
var tc = this.topContainer;
delete this.topContainer;
tc.remove();
}
},
_refreshFilter: function() {
var that = this;
@ -230,7 +238,24 @@
this.uiHeight = desiredHeight;
this._resize();
},
addItem: function(data) {
getItemAt: function(index) {
var items = this.items();
if (index >= 0 && index < items.length) {
return $(items[index]).data('data');
} else {
return;
}
},
indexOf: function(data) {
var items = this.items();
for (var i=0;i<items.length;i++) {
if ($(items[i]).data('data') === data) {
return i
}
}
return -1
},
insertItemAt: function(data,index) {
var that = this;
data = data || {};
var li = $('<li>');
@ -248,7 +273,13 @@
});
}
if (!added) {
li.appendTo(this.element);
if (index <= 0) {
li.prependTo(this.element);
} else if (index > that.element.children().length-1) {
li.appendTo(this.element);
} else {
li.insertBefore(this.element.children().eq(index));
}
}
var row = $('<div/>').addClass("red-ui-editableList-item-content").appendTo(li);
row.data('data',data);
@ -257,10 +288,10 @@
li.addClass("red-ui-editableList-item-sortable");
}
if (this.options.removable) {
var deleteButton = $('<a/>',{href:"#",class:"red-ui-editableList-item-remove editor-button editor-button-small"}).appendTo(li);
var deleteButton = $('<a/>',{href:"#",class:"red-ui-editableList-item-remove red-ui-button red-ui-button-small"}).appendTo(li);
$('<i/>',{class:"fa fa-remove"}).appendTo(deleteButton);
li.addClass("red-ui-editableList-item-removable");
deleteButton.click(function(evt) {
deleteButton.on("click", function(evt) {
evt.preventDefault();
var data = row.data('data');
li.addClass("red-ui-editableList-item-deleting")
@ -293,6 +324,9 @@
},0);
}
},
addItem: function(data) {
this.insertItemAt(data,this.element.children().length)
},
addItems: function(items) {
for (var i=0; i<items.length;i++) {
this.addItem(items[i]);
@ -312,6 +346,7 @@
},
empty: function() {
this.element.empty();
this.uiContainer.scrollTop(0);
},
filter: function(filter) {
if (filter !== undefined) {
@ -335,6 +370,14 @@
if (items.length > 0) {
this.uiContainer.scrollTop(this.uiContainer.scrollTop()+items.position().top)
}
},
getItem: function(li) {
var el = li.find(".red-ui-editableList-item-content");
if (el.length) {
return el.data('data');
} else {
return null;
}
}
});
})(jQuery);

View File

@ -56,12 +56,12 @@ RED.menu = (function() {
}
if (opt === null) {
item = $('<li class="divider"></li>');
item = $('<li class="red-ui-menu-divider"></li>');
} else {
item = $('<li></li>');
if (opt.group) {
item.addClass("menu-group-"+opt.group);
item.addClass("red-ui-menu-group-"+opt.group);
}
var linkContent = '<a '+(opt.id?'id="'+opt.id+'" ':'')+'tabindex="-1" href="#">';
@ -71,7 +71,7 @@ RED.menu = (function() {
}
if (opt.icon !== undefined) {
if (/\.png/.test(opt.icon)) {
if (/\.(png|svg)/.test(opt.icon)) {
linkContent += '<img src="'+opt.icon+'"/> ';
} else {
linkContent += '<i class="'+(opt.icon?opt.icon:'" style="display: inline-block;"')+'"></i> ';
@ -79,10 +79,10 @@ RED.menu = (function() {
}
if (opt.sublabel) {
linkContent += '<span class="menu-label-container"><span class="menu-label">'+opt.label+'</span>'+
'<span class="menu-sublabel">'+opt.sublabel+'</span></span>'
linkContent += '<span class="red-ui-menu-label-container"><span class="red-ui-menu-label">'+opt.label+'</span>'+
'<span class="red-ui-menu-sublabel">'+opt.sublabel+'</span></span>'
} else {
linkContent += '<span class="menu-label">'+opt.label+'</span>'
linkContent += '<span class="red-ui-menu-label">'+opt.label+'</span>'
}
linkContent += '</a>';
@ -92,27 +92,16 @@ RED.menu = (function() {
menuItems[opt.id] = opt;
if (opt.onselect) {
link.click(function(e) {
link.on("click", function(e) {
e.preventDefault();
if ($(this).parent().hasClass("disabled")) {
return;
}
if (opt.toggle) {
var selected = isSelected(opt.id);
if (typeof opt.toggle === "string") {
if (!selected) {
for (var m in menuItems) {
if (menuItems.hasOwnProperty(m)) {
var mi = menuItems[m];
if (mi.id != opt.id && opt.toggle == mi.toggle) {
setSelected(mi.id,false);
}
}
}
setSelected(opt.id,true);
}
if (opt.toggle === true) {
setSelected(opt.id, !isSelected(opt.id));
} else {
setSelected(opt.id, !selected);
setSelected(opt.id, true);
}
} else {
triggerAction(opt.id);
@ -125,13 +114,13 @@ RED.menu = (function() {
link.attr("target","_blank").attr("href",opt.href);
} else if (!opt.options) {
item.addClass("disabled");
link.click(function(event) {
link.on("click", function(event) {
event.preventDefault();
});
}
if (opt.options) {
item.addClass("dropdown-submenu pull-left");
var submenu = $('<ul id="'+opt.id+'-submenu" class="dropdown-menu"></ul>').appendTo(item);
item.addClass("red-ui-menu-dropdown-submenu pull-left");
var submenu = $('<ul id="'+opt.id+'-submenu" class="red-ui-menu-dropdown"></ul>').appendTo(item);
for (var i=0;i<opt.options.length;i++) {
var li = createMenuItem(opt.options[i]);
@ -150,13 +139,29 @@ RED.menu = (function() {
}
function createMenu(options) {
var topMenu = $("<ul/>",{class:"dropdown-menu pull-right"});
var topMenu = $("<ul/>",{class:"red-ui-menu red-ui-menu-dropdown pull-right"});
if (options.id) {
topMenu.attr({id:options.id+"-submenu"});
var menuParent = $("#"+options.id);
if (menuParent.length === 1) {
topMenu.insertAfter(menuParent);
menuParent.on("click", function(evt) {
evt.stopPropagation();
evt.preventDefault();
if (topMenu.is(":visible")) {
$(document).off("click.red-ui-menu");
topMenu.hide();
} else {
$(document).on("click.red-ui-menu", function(evt) {
$(document).off("click.red-ui-menu");
activeMenu = null;
topMenu.hide();
});
$(".red-ui-menu").hide();
topMenu.show();
}
})
}
}
@ -193,8 +198,9 @@ RED.menu = (function() {
}
function setSelected(id,state) {
var alreadySet = false;
if (isSelected(id) == state) {
return;
alreadySet = true;
}
var opt = menuItems[id];
if (state) {
@ -202,10 +208,26 @@ RED.menu = (function() {
} else {
$("#"+id).removeClass("active");
}
if (opt && opt.onselect) {
triggerAction(opt.id,state);
if (opt) {
if (opt.toggle && typeof opt.toggle === "string") {
if (state) {
for (var m in menuItems) {
if (menuItems.hasOwnProperty(m)) {
var mi = menuItems[m];
if (mi.id != opt.id && opt.toggle == mi.toggle) {
setSelected(mi.id,false);
}
}
}
}
}
if (!alreadySet && opt.onselect) {
triggerAction(opt.id,state);
}
}
if (!opt.local && !alreadySet) {
RED.settings.set(opt.setting||("menu-"+opt.id), state);
}
RED.settings.set(opt.setting||("menu-"+opt.id), state);
}
function toggleSelected(id) {
@ -223,13 +245,13 @@ RED.menu = (function() {
function addItem(id,opt) {
var item = createMenuItem(opt);
if (opt.group) {
var groupItems = $("#"+id+"-submenu").children(".menu-group-"+opt.group);
var groupItems = $("#"+id+"-submenu").children(".red-ui-menu-group-"+opt.group);
if (groupItems.length === 0) {
item.appendTo("#"+id+"-submenu");
} else {
for (var i=0;i<groupItems.length;i++) {
var groupItem = groupItems[i];
var label = $(groupItem).find(".menu-label").html();
var label = $(groupItem).find(".red-ui-menu-label").html();
if (opt.label < label) {
$(groupItem).before(item);
break;
@ -263,6 +285,5 @@ RED.menu = (function() {
addItem: addItem,
removeItem: removeItem,
setAction: setAction
//TODO: add an api for replacing a submenu - see library.js:loadFlowLibrary
}
})();

View File

@ -21,6 +21,7 @@ RED.panels = (function() {
var container = options.container || $("#"+options.id);
var children = container.children();
if (children.length !== 2) {
console.log(options.id);
throw new Error("Container must have exactly two children");
}
var vertical = (!options.dir || options.dir === "vertical");
@ -86,10 +87,10 @@ RED.panels = (function() {
resize: function(size) {
var panelSizes;
if (vertical) {
panelSizes = [$(children[0]).height(),$(children[1]).height()];
panelSizes = [$(children[0]).outerHeight(),$(children[1]).outerHeight()];
container.height(size);
} else {
panelSizes = [$(children[0]).width(),$(children[1]).width()];
panelSizes = [$(children[0]).outerWidth(),$(children[1]).outerWidth()];
container.width(size);
}
if (modifiedSizes) {
@ -105,6 +106,11 @@ RED.panels = (function() {
}
}
if (options.resize) {
if (vertical) {
panelSizes = [$(children[0]).height(),$(children[1]).height()];
} else {
panelSizes = [$(children[0]).width(),$(children[1]).width()];
}
options.resize(panelSizes[0],panelSizes[1]);
}
}

View File

@ -52,6 +52,11 @@ RED.popover = (function() {
var openPopup = function(instant) {
if (active) {
var existingPopover = target.data("red-ui-popover");
if (options.tooltip && existingPopover) {
active = false;
return;
}
div = $('<div class="red-ui-popover"></div>');
if (size !== "default") {
div.addClass("red-ui-popover-size-"+size);
@ -122,7 +127,10 @@ RED.popover = (function() {
}
}
div.addClass('red-ui-popover-'+d).css({top: top, left: left});
if (existingPopover) {
existingPopover.close(true);
}
target.data("red-ui-popover",res)
if (instant) {
div.show();
} else {
@ -131,7 +139,7 @@ RED.popover = (function() {
}
}
var closePopup = function(instant) {
$(document).off('mousedown.modal-popover-close');
$(document).off('mousedown.red-ui-popover');
if (!active) {
if (div) {
if (instant) {
@ -142,6 +150,7 @@ RED.popover = (function() {
});
}
div = null;
target.removeData("red-ui-popover",res)
}
}
}
@ -162,7 +171,7 @@ RED.popover = (function() {
}
});
} else if (trigger === 'click') {
target.click(function(e) {
target.on("click", function(e) {
e.preventDefault();
e.stopPropagation();
active = !active;
@ -185,7 +194,7 @@ RED.popover = (function() {
}
} else if (trigger === 'modal') {
$(document).on('mousedown.modal-popover-close', function (event) {
$(document).on('mousedown.red-ui-popover', function (event) {
var target = event.target;
while (target.nodeName !== 'BODY' && target !== div[0]) {
target = target.parentElement;
@ -236,6 +245,7 @@ RED.popover = (function() {
}
}
return RED.popover.create({
tooltip: true,
target:target,
trigger: "hover",
size: "small",
@ -243,6 +253,71 @@ RED.popover = (function() {
content: label,
delay: { show: 750, hide: 50 }
});
},
panel: function(content) {
var panel = $('<div class="red-ui-editor-dialog red-ui-popover-panel"></div>');
panel.css({ display: "none" });
panel.appendTo(document.body);
content.appendTo(panel);
var closeCallback;
function hide() {
$(document).off("mousedown.red-ui-popover-panel-close");
panel.hide();
panel.css({
height: "auto"
});
panel.remove();
}
function show(options) {
var closeCallback = options.onclose;
var target = options.target;
var align = options.align || "left";
var pos = target.offset();
var targetWidth = target.width();
var targetHeight = target.height();
var panelHeight = panel.height();
var panelWidth = panel.width();
var top = (targetHeight+pos.top);
if (top+panelHeight > $(window).height()) {
top -= (top+panelHeight)-$(window).height() + 5;
}
if (top < 0) {
panelHeight.height(panelHeight+top)
top = 0;
}
if (align === "left") {
panel.css({
top: top+"px",
left: (pos.left)+"px",
});
} else if(align === "right") {
panel.css({
top: top+"px",
left: (pos.left-panelWidth)+"px",
});
}
panel.slideDown(100);
$(document).on("mousedown.red-ui-popover-panel-close", function(event) {
if(!$(event.target).closest(panel).length && !$(event.target).closest(".red-ui-editor-dialog").length) {
if (closeCallback) {
closeCallback();
}
hide();
}
// if ($(event.target).closest(target).length) {
// event.preventDefault();
// }
})
}
return {
container: panel,
show:show,
hide:hide
}
}
}

View File

@ -35,6 +35,7 @@
this.currentTimeout = null;
this.lastSent = "";
this.element.val("");
this.element.addClass("red-ui-searchBox-input");
this.uiContainer = this.element.wrap("<div>").parent();
this.uiContainer.addClass("red-ui-searchBox-container");
@ -44,7 +45,7 @@
e.preventDefault();
that.element.val("");
that._change("",true);
that.element.focus();
that.element.trigger("focus");
});
this.resultCount = $('<span>',{class:"red-ui-searchBox-resultCount hide"}).appendTo(this.uiContainer);
@ -60,7 +61,7 @@
});
this.element.on("focus",function() {
$("body").one("mousedown",function() {
$(document).one("mousedown",function() {
that.element.blur();
});
});
@ -86,6 +87,7 @@
that._trigger("change");
},this.options.delay);
} else {
this.lastSent = this.element.val();
this._trigger("change");
}
}

View File

@ -39,17 +39,17 @@ RED.stack = (function() {
}
}
if (options.fill && options.singleExpanded) {
$(window).resize(resizeStack);
$(window).focus(resizeStack);
$(window).on("resize", resizeStack);
$(window).on("focus", resizeStack);
}
return {
add: function(entry) {
entries.push(entry);
entry.container = $('<div class="palette-category">').appendTo(container);
entry.container = $('<div class="red-ui-palette-category">').appendTo(container);
if (!visible) {
entry.container.hide();
}
var header = $('<div class="palette-header"></div>').appendTo(entry.container);
var header = $('<div class="red-ui-palette-header"></div>').appendTo(entry.container);
entry.header = header;
entry.contentWrap = $('<div></div>',{style:"position:relative"}).appendTo(entry.container);
if (options.fill) {
@ -57,7 +57,7 @@ RED.stack = (function() {
}
entry.content = $('<div></div>').appendTo(entry.contentWrap);
if (entry.collapsible !== false) {
header.click(function() {
header.on("click", function() {
if (options.singleExpanded) {
if (!entry.isExpanded()) {
for (var i=0;i<entries.length;i++) {
@ -82,7 +82,7 @@ RED.stack = (function() {
var icon = $('<i class="fa fa-angle-down"></i>').appendTo(header);
if (entry.expanded) {
entry.container.addClass("palette-category-expanded");
entry.container.addClass("expanded");
icon.addClass("expanded");
} else {
entry.contentWrap.hide();
@ -118,7 +118,7 @@ RED.stack = (function() {
}
icon.addClass("expanded");
entry.container.addClass("palette-category-expanded");
entry.container.addClass("expanded");
entry.contentWrap.slideDown(200);
return true;
}
@ -126,13 +126,13 @@ RED.stack = (function() {
entry.collapse = function() {
if (entry.isExpanded()) {
icon.removeClass("expanded");
entry.container.removeClass("palette-category-expanded");
entry.container.removeClass("expanded");
entry.contentWrap.slideUp(200);
return true;
}
};
entry.isExpanded = function() {
return entry.container.hasClass("palette-category-expanded");
return entry.container.hasClass("expanded");
};
if (options.fill && options.singleExpanded) {
resizeStack();

View File

@ -37,7 +37,7 @@ RED.tabs = (function() {
if (options.addButton) {
wrapper.addClass("red-ui-tabs-add");
var addButton = $('<div class="red-ui-tab-button red-ui-tabs-add"><a href="#"><i class="fa fa-plus"></i></a></div>').appendTo(wrapper);
addButton.find('a').click(function(evt) {
addButton.find('a').on("click", function(evt) {
evt.preventDefault();
if (typeof options.addButton === 'function') {
options.addButton();
@ -73,7 +73,7 @@ RED.tabs = (function() {
if (options.searchButton) {
wrapper.addClass("red-ui-tabs-search");
var searchButton = $('<div class="red-ui-tab-button red-ui-tabs-search"><a href="#"><i class="fa fa-list-ul"></i></a></div>').appendTo(wrapper);
searchButton.find('a').click(function(evt) {
searchButton.find('a').on("click", function(evt) {
evt.preventDefault();
if (typeof options.searchButton === 'function') {
options.searchButton()
@ -96,7 +96,7 @@ RED.tabs = (function() {
if (options.scrollable) {
wrapper.addClass("red-ui-tabs-scrollable");
scrollContainer.addClass("red-ui-tabs-scroll-container");
scrollContainer.scroll(updateScroll);
scrollContainer.on("scroll",updateScroll);
scrollLeft = $('<div class="red-ui-tab-button red-ui-tab-scroll red-ui-tab-scroll-left"><a href="#" style="display:none;"><i class="fa fa-caret-left"></i></a></div>').appendTo(wrapper).find("a");
scrollLeft.on('mousedown',function(evt) { scrollEventHandler(evt,'-=150') }).on('click',function(evt){ evt.preventDefault();});
scrollRight = $('<div class="red-ui-tab-button red-ui-tab-scroll red-ui-tab-scroll-right"><a href="#" style="display:none;"><i class="fa fa-caret-right"></i></a></div>').appendTo(wrapper).find("a");
@ -113,7 +113,7 @@ RED.tabs = (function() {
if (options.menu !== false) {
var selectButton = $('<a href="#"><i class="fa fa-caret-down"></i></a>').appendTo(collapsedButtonsRow);
selectButton.addClass("red-ui-tab-link-button-menu")
selectButton.click(function(evt) {
selectButton.on("click", function(evt) {
evt.stopPropagation();
evt.preventDefault();
if (!collapsibleMenu) {
@ -136,7 +136,7 @@ RED.tabs = (function() {
}
});
options = pinnedOptions.concat(options);
collapsibleMenu = RED.menu.init({id:"debug-message-option-menu",options: options});
collapsibleMenu = RED.menu.init({options: options});
collapsibleMenu.css({
position: "absolute"
})
@ -148,10 +148,11 @@ RED.tabs = (function() {
left: (elementPos.left - collapsibleMenu.width() + selectButton.width())+"px"
})
if (collapsibleMenu.is(":visible")) {
$(document).off("click.tabmenu");
$(document).off("click.red-ui-tabmenu");
} else {
$(document).on("click.tabmenu", function(evt) {
$(document).off("click.tabmenu");
$(".red-ui-menu").hide();
$(document).on("click.red-ui-tabmenu", function(evt) {
$(document).off("click.red-ui-tabmenu");
collapsibleMenu.hide();
});
}
@ -348,7 +349,7 @@ RED.tabs = (function() {
}
var tabs = ul.find("li.red-ui-tab");
var width = wrapper.width();
var tabCount = tabs.size();
var tabCount = tabs.length;
var tabWidth;
if (options.collapsible) {
@ -434,7 +435,7 @@ RED.tabs = (function() {
var li = ul.find("a[href='#"+id+"']").parent();
if (li.hasClass("active")) {
var tab = li.prev();
if (tab.size() === 0) {
if (tab.length === 0) {
tab = li.next();
}
activateTab(tab.find("a"));
@ -448,7 +449,10 @@ RED.tabs = (function() {
}
delete tabs[id];
updateTabWidths();
collapsibleMenu = null;
if (collapsibleMenu) {
collapsibleMenu.remove();
collapsibleMenu = null;
}
}
return {
@ -484,7 +488,7 @@ RED.tabs = (function() {
} else if (tab.iconClass) {
$('<i>',{class:"red-ui-tab-icon "+tab.iconClass}).appendTo(link);
}
var span = $('<span/>',{class:"bidiAware"}).text(tab.label).appendTo(link);
var span = $('<span/>',{class:"red-ui-text-bidi-aware"}).text(tab.label).appendTo(link);
span.attr('dir', RED.text.bidi.resolveBaseTextDir(tab.label));
if (options.collapsible) {
li.addClass("red-ui-tab-pinned");
@ -509,7 +513,7 @@ RED.tabs = (function() {
} else {
$('<i>',{class:defaultTabIcon}).appendTo(pinnedLink);
}
pinnedLink.click(function(evt) {
pinnedLink.on("click", function(evt) {
evt.preventDefault();
activateTab(tab.id);
});
@ -543,7 +547,7 @@ RED.tabs = (function() {
options.onadd(tab);
}
link.attr("title",tab.label);
if (ul.find("li.red-ui-tab").size() == 1) {
if (ul.find("li.red-ui-tab").length == 1) {
activateTab(link);
}
if (options.onreorder) {
@ -626,7 +630,10 @@ RED.tabs = (function() {
setTimeout(function() {
updateTabWidths();
},10);
collapsibleMenu = null;
if (collapsibleMenu) {
collapsibleMenu.remove();
collapsibleMenu = null;
}
},
removeTab: removeTab,
activateTab: activateTab,
@ -634,7 +641,7 @@ RED.tabs = (function() {
previousTab: activatePreviousTab,
resize: updateTabWidths,
count: function() {
return ul.find("li.red-ui-tab").size();
return ul.find("li.red-ui-tab").length;
},
contains: function(id) {
return ul.find("a[href='#"+id+"']").length > 0;
@ -643,7 +650,7 @@ RED.tabs = (function() {
tabs[id].label = label;
var tab = ul.find("a[href='#"+id+"']");
tab.attr("title",label);
tab.find("span.bidiAware").text(label).attr('dir', RED.text.bidi.resolveBaseTextDir(label));
tab.find("span.red-ui-text-bidi-aware").text(label).attr('dir', RED.text.bidi.resolveBaseTextDir(label));
updateTabWidths();
},
selection: getSelection,

View File

@ -0,0 +1,100 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* 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.
**/
(function($) {
/**
* options:
* - invertState : boolean - if "true" the button will show "enabled" when the
* checkbox is not selected and vice versa.
* - enabledIcon : string - the icon for "enabled" state, default "fa-check-square-o"
* - enabledLabel : string - the label for "enabled" state, default "Enabled" ("editor:workspace.enabled")
* - disabledIcon : string - the icon for "disabled" state, default "fa-square-o"
* - disabledLabel : string - the label for "disabled" state, default "Disabled" ("editor:workspace.disabled")
* - baseClass : string - the base css class to apply, default "red-ui-button" (alternative eg "red-ui-sidebar-header-button")
* - class : string - additional classes to apply to the button - eg "red-ui-button-small"
* methods:
* -
*/
$.widget( "nodered.toggleButton", {
_create: function() {
var that = this;
var invertState = false;
if (this.options.hasOwnProperty("invertState")) {
invertState = this.options.invertState;
}
var baseClass = this.options.baseClass || "red-ui-button";
var enabledIcon = this.options.enabledIcon || "fa-check-square-o";
var disabledIcon = this.options.disabledIcon || "fa-square-o";
var enabledLabel = this.options.enabledLabel || RED._("editor:workspace.enabled");
var disabledLabel = this.options.disabledLabel || RED._("editor:workspace.disabled");
this.element.css("display","none");
this.element.on("focus", function() {
that.button.focus();
});
this.button = $('<button type="button" class="red-ui-toggleButton '+baseClass+' toggle single"><i class="fa"></i> <span></span></button>');
if (this.options.class) {
this.button.addClass(this.options.class)
}
this.element.after(this.button);
this.buttonIcon = this.button.find("i");
this.buttonLabel = this.button.find("span");
// Quick hack to find the maximum width of the button
this.button.addClass("selected");
this.buttonIcon.addClass(enabledIcon);
this.buttonLabel.text(enabledLabel);
var width = this.button.width();
this.button.removeClass("selected");
this.buttonIcon.removeClass(enabledIcon);
that.buttonIcon.addClass(disabledIcon);
that.buttonLabel.text(disabledLabel);
width = Math.max(width,this.button.width());
this.buttonIcon.removeClass(disabledIcon);
// Fix the width of the button so it doesn't jump around when toggled
if (width > 0) {
this.button.width(Math.ceil(width));
}
this.button.on("click",function(e) {
e.stopPropagation();
if (that.buttonIcon.hasClass(disabledIcon)) {
that.element.prop("checked",!invertState);
} else {
that.element.prop("checked",invertState);
}
that.element.trigger("change");
})
this.element.on("change", function(e) {
if ($(this).prop("checked") !== invertState) {
that.button.addClass("selected");
that.buttonIcon.addClass(enabledIcon);
that.buttonIcon.removeClass(disabledIcon);
that.buttonLabel.text(enabledLabel);
} else {
that.button.removeClass("selected");
that.buttonIcon.addClass(disabledIcon);
that.buttonIcon.removeClass(enabledIcon);
that.buttonLabel.text(disabledLabel);
}
})
this.element.trigger("change");
}
});
})(jQuery);

View File

@ -18,32 +18,70 @@
/**
* options:
* - data : array - initial items to display in tree
* - multi : boolean - if true, .selected will return an array of results
* otherwise, returns the first selected item
* - sortable: boolean/string - TODO: see editableList
* - rootSortable: boolean - if 'sortable' is set, then setting this to
* false, prevents items being sorted to the
* top level of the tree
*
* methods:
* - data(items) - clears existing items and replaces with new data
*
* events:
* - treelistselect : function(event, item) {}
*
* - treelistconfirm : function(event,item) {}
* - treelistchangeparent: function(event,item, oldParent, newParent) {}
*
* data:
* [
* {
* label: 'Local', // label for the item
* sublabel: 'Local', // a sub-label for the item
* icon: 'fa fa-rocket', // (optional) icon for the item
* selected: true/false, // (optional) if present, display checkbox accordingly
* children: [] | function(done) // (optional) an array of child items, or a function
* children: [] | function(done,item) // (optional) an array of child items, or a function
* // that will call the `done` callback with an array
* // of child items
* expanded: true/false, // show the child items by default
* deferBuild: true/false, // don't build any ui elements for the item's children
* until it is expanded by the user.
* element: // custom dom element to use for the item - ignored if `label` is set
* }
* ]
*
*
*
* var treeList = $("<div>").css({width: "100%", height: "100%"}).treeList({data:[...]})
* treeList.on('treelistselect', function(e,item) { console.log(item)})
* treeList.treeList('data',[ ... ] )
*
*
* After `data` has been added to the tree, each item is augmented the following
* properties and functions:
*
* item.parent - set to the parent item
* item.treeList.container
* item.treeList.label - the label element for the item
* item.treeList.depth - the depth in the tree (0 == root)
* item.treeList.parentList - the editableList instance this item is in
* item.treeList.remove() - removes the item from the tree
* item.treeList.makeLeaf(detachChildElements) - turns an element with children into a leaf node,
* removing the UI decoration etc.
* detachChildElements - any children with custom
* elements will be detached rather than removed
* so jQuery event handlers are preserved in case
* the child elements need to be reattached later
* item.treeList.makeParent(children) - turns an element into a parent node, adding the necessary
* UI decoration.
* item.treeList.insertChildAt(newItem,position,select) - adds a child item an the specified position.
* Optionally selects the item after adding.
* item.treeList.addChild(newItem,select) - appends a child item.
* Optionally selects the item after adding.
* item.treeList.expand(done) - expands the parent item to show children. Optional 'done' callback.
* item.treeList.collapse() - collapse the parent item to hide children.
*
*
*
*
*/
$.widget( "nodered.treeList", {
@ -51,110 +89,449 @@
var that = this;
this.element.addClass('red-ui-treeList');
this.element.attr("tabIndex",0);
var wrapper = $('<div>',{class:'red-ui-treeList-container'}).appendTo(this.element);
this.element.on('keydown', function(evt) {
var selected = that._topList.find(".selected").parent().data('data');
if (!selected && (evt.keyCode === 40 || evt.keyCode === 38)) {
that.select(that._data[0]);
return;
}
var target;
switch(evt.keyCode) {
case 13: // ENTER
if (selected.children) {
if (selected.treeList.container.hasClass("expanded")) {
selected.treeList.collapse()
} else {
selected.treeList.expand()
}
} else {
that._trigger("confirm",null,selected)
}
break;
case 37: // LEFT
if (selected.children&& selected.treeList.container.hasClass("expanded")) {
selected.treeList.collapse()
} else if (selected.parent) {
target = selected.parent;
}
break;
case 38: // UP
target = that._getPreviousSibling(selected);
if (target) {
target = that._getLastDescendant(target);
}
if (!target && selected.parent) {
target = selected.parent;
}
break;
case 39: // RIGHT
if (selected.children) {
if (!selected.treeList.container.hasClass("expanded")) {
selected.treeList.expand()
}
}
break
case 40: //DOWN
if (selected.children && Array.isArray(selected.children) && selected.children.length > 0 && selected.treeList.container.hasClass("expanded")) {
target = selected.children[0];
} else {
target = that._getNextSibling(selected);
while (!target && selected.parent) {
selected = selected.parent;
target = that._getNextSibling(selected);
}
}
break
}
if (target) {
that.select(target);
}
});
this._data = [];
this._topList = $('<ol>').css({
this._topList = $('<ol class="red-ui-treeList-list">').css({
position:'absolute',
top: 0,
left:0,
right:0,
bottom:0
}).appendTo(wrapper).editableList({
}).appendTo(wrapper);
var topListOptions = {
addButton: false,
scrollOnAdd: false,
height: '100%',
addItem: function(container,i,item) {
that._addSubtree(container,item,0);
that._addSubtree(that._topList,container,item,0);
}
});
};
if (this.options.rootSortable !== false && !!this.options.sortable) {
topListOptions.sortable = this.options.sortable;
topListOptions.connectWith = '.red-ui-treeList-sortable';
this._topList.addClass('red-ui-treeList-sortable');
}
this._topList.editableList(topListOptions)
if (this.options.data) {
this.data(this.options.data);
}
},
_addChildren: function(container,children,depth) {
_getLastDescendant: function(item) {
// Gets the last visible descendant of the item
if (!item.children || !item.treeList.container.hasClass("expanded") || item.children.length === 0) {
return item;
}
return this._getLastDescendant(item.children[item.children.length-1]);
},
_getPreviousSibling: function(item) {
var candidates;
if (!item.parent) {
candidates = this._data;
} else {
candidates = item.parent.children;
}
var index = candidates.indexOf(item);
if (index === 0) {
return null;
} else {
return candidates[index-1];
}
},
_getNextSibling: function(item) {
var candidates;
if (!item.parent) {
candidates = this._data;
} else {
candidates = item.parent.children;
}
var index = candidates.indexOf(item);
if (index === candidates.length - 1) {
return null;
} else {
return candidates[index+1];
}
},
_addChildren: function(container,parent,children,depth) {
var that = this;
var subtree = $('<ol>').appendTo(container).editableList({
var subtree = $('<ol class="red-ui-treeList-list">').appendTo(container).editableList({
connectWith: ".red-ui-treeList-sortable",
sortable: that.options.sortable,
addButton: false,
scrollOnAdd: false,
height: 'auto',
addItem: function(container,i,item) {
that._addSubtree(container,item,depth+1);
that._addSubtree(subtree,container,item,depth+1);
},
sortItems: function(data) {
var children = [];
var reparented = [];
data.each(function() {
var child = $(this).data('data');
children.push(child);
var evt = that._fixDepths(parent,child);
if (evt) {
reparented.push(evt);
}
})
if (Array.isArray(parent.children)) {
parent.children = children;
}
reparented.forEach(function(evt) {
that._trigger("changeparent",null,evt);
});
that._trigger("sort",null,parent);
}
});
if (!!that.options.sortable) {
subtree.addClass('red-ui-treeList-sortable');
}
for (var i=0;i<children.length;i++) {
children[i].parent = parent;
subtree.editableList('addItem',children[i])
}
return subtree;
},
_addSubtree: function(container, item, depth) {
_fixDepths: function(parent,child) {
// If child has just been moved into parent in the UI
// this will fix up the internal data structures to match.
// The calling function must take care of getting child
// into the parent.children array. The rest is up to us.
var that = this;
var labelNodeType = "<label>";
if (item.children && item.hasOwnProperty('selected')) {
labelNodeType = "<div>";
var reparentedEvent = null;
if (child.parent !== parent) {
reparented = true;
var oldParent = child.parent;
child.parent = parent;
reparentedEvent = {
item: child,
old: oldParent,
}
}
var label = $(labelNodeType,{tabindex:"0",class:"red-ui-treeList-label"}).appendTo(container);
if (child.depth !== parent.depth+1) {
child.depth = parent.depth+1;
var labelPaddingWidth = ((child.gutter?child.gutter.width()+2:0)+(child.depth*20));
child.treeList.labelPadding.width(labelPaddingWidth+'px');
if (child.element) {
$(child.element).css({
width: "calc(100% - "+(labelPaddingWidth+20+(child.icon?20:0))+"px)"
})
}
// This corrects all child item depths
if (child.children && Array.isArray(child.children)) {
child.children.forEach(function(item) {
that._fixDepths(child,item);
})
}
}
return reparentedEvent;
},
_addSubtree: function(parentList, container, item, depth) {
var that = this;
item.treeList = {};
item.treeList.depth = depth;
item.treeList.container = container;
item.treeList.parentList = parentList;
item.treeList.remove = function() {
parentList.editableList('removeItem',item);
if (item.parent) {
var index = item.parent.children.indexOf(item);
item.parent.children.splice(index,1)
that._trigger("sort",null,item.parent);
}
}
var label = $("<div>",{class:"red-ui-treeList-label"}).appendTo(container);
item.treeList.label = label;
if (item.class) {
label.addClass(item.class);
}
label.css({
paddingLeft: (depth*15)+'px'
})
if (item.gutter) {
item.gutter.css({
position: 'absolute'
}).appendTo(label)
}
var labelPaddingWidth = (item.gutter?item.gutter.width()+2:0)+(depth*20);
item.treeList.labelPadding = $('<span>').css({
display: "inline-block",
width: labelPaddingWidth+'px'
}).appendTo(label);
label.on('mouseover',function(e) { that._trigger('itemmouseover',e,item); })
label.on('mouseout',function(e) { that._trigger('itemmouseout',e,item); })
label.on('mouseenter',function(e) { that._trigger('itemmouseenter',e,item); })
label.on('mouseleave',function(e) { that._trigger('itemmouseleave',e,item); })
if (item.children) {
$('<span class="red-ui-treeList-icon"><i class="fa fa-angle-right" /></span>').appendTo(label);
item.treeList.makeLeaf = function(detachChildElements) {
if (!treeListIcon.children().length) {
// Already a leaf
return
}
if (detachChildElements && item.children) {
var detachChildren = function(item) {
if (item.children) {
item.children.forEach(function(child) {
if (child.element) {
child.element.detach();
}
if (child.gutter) {
child.gutter.detach();
}
detachChildren(child);
});
}
}
detachChildren(item);
}
treeListIcon.empty();
if (!item.deferBuild) {
item.treeList.childList.remove();
delete item.treeList.childList;
}
label.off("click.red-ui-treeList-expand");
treeListIcon.off("click.red-ui-treeList-expand");
delete item.children;
container.removeClass("expanded");
}
item.treeList.makeParent = function(children) {
if (treeListIcon.children().length) {
// Already a parent because we've got the angle-right icon
return;
}
$('<i class="fa fa-angle-right" />').appendTo(treeListIcon);
treeListIcon.on("click.red-ui-treeList-expand", function(e) {
e.stopPropagation();
e.preventDefault();
if (container.hasClass("expanded")) {
item.treeList.collapse();
} else {
item.treeList.expand();
}
});
// $('<span class="red-ui-treeList-icon"><i class="fa fa-folder-o" /></span>').appendTo(label);
label.click(function(e) {
if (!container.hasClass("built") && typeof item.children === 'function') {
container.addClass('built');
var childrenAdded = false;
var spinner;
item.children(function(children) {
childrenAdded = true;
that._addChildren(container,children,depth);
label.on("click.red-ui-treeList-expand", function(e) {
if (container.hasClass("expanded")) {
if (item.hasOwnProperty('selected') || label.hasClass("selected")) {
item.treeList.collapse();
}
} else {
item.treeList.expand();
}
})
if (!item.children) {
item.children = children||[];
item.treeList.childList = that._addChildren(container,item,item.children,depth).hide();
}
}
item.treeList.insertChildAt = function(newItem,position,select) {
newItem.parent = item;
item.children.splice(position,0,newItem);
if (!item.deferBuild) {
item.treeList.childList.editableList('insertItemAt',newItem,position)
if (select) {
setTimeout(function() {
that.select(newItem)
},100);
}
that._trigger("sort",null,item);
}
}
item.treeList.addChild = function(newItem,select) {
item.treeList.insertChildAt(newItem,item.children.length,select);
}
item.treeList.expand = function(done) {
if (!item.children) {
return;
}
if (container.hasClass("expanded")) {
done && done();
return;
}
if (!container.hasClass("built") && (item.deferBuild || typeof item.children === 'function')) {
container.addClass('built');
var childrenAdded = false;
var spinner;
var startTime = 0;
var completeBuild = function(children) {
childrenAdded = true;
item.treeList.childList = that._addChildren(container,item,children,depth).hide();
var delta = Date.now() - startTime;
if (delta < 400) {
setTimeout(function() {
item.treeList.childList.slideDown('fast');
if (spinner) {
spinner.remove();
}
},400-delta);
} else {
item.treeList.childList.slideDown('fast');
if (spinner) {
spinner.remove();
}
});
if (!childrenAdded) {
spinner = $('<div class="red-ui-treeList-spinner">').css({
"background-position": (35+depth*15)+'px 50%'
}).appendTo(container);
}
done && done();
that._trigger("childrenloaded",null,item)
}
container.toggleClass("expanded");
})
} else {
$('<span class="red-ui-treeList-icon"></span>').appendTo(label);
if (typeof item.children === 'function') {
item.children(completeBuild,item);
} else {
delete item.deferBuild;
completeBuild(item.children);
}
if (!childrenAdded) {
startTime = Date.now();
spinner = $('<div class="red-ui-treeList-spinner">').css({
"background-position": (35+depth*20)+'px 50%'
}).appendTo(container);
}
} else {
if (that._loadingData) {
item.treeList.childList.show();
} else {
item.treeList.childList.slideDown('fast');
}
done && done();
}
container.addClass("expanded");
}
item.treeList.collapse = function() {
if (!item.children) {
return;
}
item.treeList.childList.slideUp('fast');
container.removeClass("expanded");
}
var treeListIcon = $('<span class="red-ui-treeList-icon"></span>').appendTo(label);
if (item.children) {
item.treeList.makeParent();
}
if (item.hasOwnProperty('selected')) {
var selectWrapper = $('<span class="red-ui-treeList-icon"></span>').appendTo(label);
var cb = $('<input type="checkbox">').prop('checked',item.selected).appendTo(selectWrapper);
var cb = $('<input class="red-ui-treeList-checkbox" type="checkbox">').prop('checked',item.selected).appendTo(selectWrapper);
label.toggleClass("selected",item.selected);
cb.on('click', function(e) {
e.stopPropagation();
});
cb.on('change', function(e) {
item.selected = this.checked;
label.toggleClass("selected",this.checked);
that._trigger("select",e,item);
})
} else if (!item.children) {
label.click(function(e) {
if (!item.children) {
label.on("click", function(e) {
e.stopPropagation();
cb.trigger("click");
})
}
item.treeList.select = function(v) {
if (v !== item.selected) {
cb.trigger("click");
}
}
} else {
label.on("click", function(e) {
that._topList.find(".selected").removeClass("selected");
label.addClass("selected");
that._trigger("select",e,item)
})
label.on("dblclick", function(e) {
if (!item.children) {
that._trigger("confirm",e,item);
}
})
}
if (item.icon) {
$('<span class="red-ui-treeList-icon"><i class="'+item.icon+'" /></span>').appendTo(label);
}
$('<span class="red-ui-treeList-label-text"></span>').text(item.label).appendTo(label);
if (item.hasOwnProperty('label') || item.hasOwnProperty('sublabel')) {
if (item.hasOwnProperty('label')) {
$('<span class="red-ui-treeList-label-text"></span>').text(item.label).appendTo(label);
}
if (item.hasOwnProperty('sublabel')) {
$('<span class="red-ui-treeList-sublabel-text"></span>').text(item.sublabel).appendTo(label);
}
} else if (item.element) {
$(item.element).appendTo(label);
$(item.element).css({
width: "calc(100% - "+(labelPaddingWidth+20+(item.icon?20:0))+"px)"
})
}
if (item.children) {
if (Array.isArray(item.children)) {
that._addChildren(container,item.children,depth);
if (Array.isArray(item.children) && !item.deferBuild) {
item.treeList.childList = that._addChildren(container,item,item.children,depth).hide();
}
if (item.expanded) {
label.click();
item.treeList.expand();
}
}
},
@ -162,12 +539,19 @@
this._topList.editableList('empty');
},
data: function(items) {
var that = this;
if (items !== undefined) {
this._data = items;
this._topList.editableList('empty');
this._loadingData = true;
for (var i=0; i<items.length;i++) {
this._topList.editableList('addItem',items[i]);
}
setTimeout(function() {
delete that._loadingData;
},200);
this._trigger("select")
} else {
return this._data;
}
@ -178,6 +562,27 @@
this._topList.editableList('show',this._data[i]);
}
}
},
select: function(item) {
this._topList.find(".selected").removeClass("selected");
item.treeList.label.addClass("selected");
this._trigger("select",null,item)
},
selected: function() {
var s = this._topList.find(".selected");
if (this.options.multi) {
var res = [];
s.each(function() {
res.push($(this).parent().data('data'));
})
return res;
}
if (s.length) {
return s.parent().data('data');
} else {
return undefined;
}
}
});

View File

@ -32,6 +32,12 @@
return v;
}
}
var mapDeprecatedIcon = function(icon) {
if (/^red\/images\/typedInput\/.+\.png$/.test(icon)) {
icon = icon.replace(/.png$/,".svg");
}
return icon;
}
var allOptions = {
msg: {value:"msg",label:"msg.",validate:RED.utils.validatePropertyExpression},
flow: {value:"flow",label:"flow.",hasValue:true,
@ -46,13 +52,13 @@
parse: contextParse,
export: contextExport
},
str: {value:"str",label:"string",icon:"red/images/typedInput/az.png"},
num: {value:"num",label:"number",icon:"red/images/typedInput/09.png",validate:/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/},
bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.png",options:["true","false"]},
str: {value:"str",label:"string",icon:"red/images/typedInput/az.svg"},
num: {value:"num",label:"number",icon:"red/images/typedInput/09.svg",validate:/^[+-]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?$/},
bool: {value:"bool",label:"boolean",icon:"red/images/typedInput/bool.svg",options:["true","false"]},
json: {
value:"json",
label:"JSON",
icon:"red/images/typedInput/json.png",
icon:"red/images/typedInput/json.svg",
validate: function(v) { try{JSON.parse(v);return true;}catch(e){return false;}},
expand: function() {
var that = this;
@ -74,12 +80,12 @@
})
}
},
re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.png"},
date: {value:"date",label:"timestamp",hasValue:false},
re: {value:"re",label:"regular expression",icon:"red/images/typedInput/re.svg"},
date: {value:"date",label:"timestamp",icon:"fa fa-clock-o",hasValue:false},
jsonata: {
value: "jsonata",
label: "expression",
icon: "red/images/typedInput/expr.png",
icon: "red/images/typedInput/expr.svg",
validate: function(v) { try{jsonata(v);return true;}catch(e){return false;}},
expand:function() {
var that = this;
@ -94,7 +100,7 @@
bin: {
value: "bin",
label: "buffer",
icon: "red/images/typedInput/bin.png",
icon: "red/images/typedInput/bin.svg",
expand: function() {
var that = this;
RED.editor.editBuffer({
@ -108,7 +114,56 @@
env: {
value: "env",
label: "env variable",
icon: "red/images/typedInput/env.png"
icon: "red/images/typedInput/env.svg"
},
node: {
value: "node",
label: "node",
icon: "red/images/typedInput/target.svg",
valueLabel: function(container,value) {
var node = RED.nodes.node(value);
var nodeDiv = $('<div>',{class:"red-ui-search-result-node"}).css({
"margin-top": "2px",
"margin-left": "3px"
}).appendTo(container);
var nodeLabel = $('<span>').css({
"line-height": "32px",
"margin-left": "6px"
}).appendTo(container);
if (node) {
var colour = RED.utils.getNodeColor(node.type,node._def);
var icon_url = RED.utils.getNodeIcon(node._def,node);
if (node.type === 'tab') {
colour = "#C0DEED";
}
nodeDiv.css('backgroundColor',colour);
var iconContainer = $('<div/>',{class:"red-ui-palette-icon-container"}).appendTo(nodeDiv);
RED.utils.createIconElement(icon_url, iconContainer, true);
var l = RED.utils.getNodeLabel(node,node.id);
nodeLabel.text(l);
} else {
nodeDiv.css({
'backgroundColor': '#eee',
'border-style' : 'dashed'
});
}
},
expand: function() {
var that = this;
RED.tray.hide();
RED.view.selectNodes({
single: true,
selected: [that.value()],
onselect: function(selection) {
that.value(selection.id);
RED.tray.show();
},
oncancel: function() {
RED.tray.show();
}
})
}
}
};
var nlsd = false;
@ -124,7 +179,7 @@
}
var contextStores = RED.settings.context.stores;
var contextOptions = contextStores.map(function(store) {
return {value:store,label: store, icon:'<i class="red-ui-typedInput-icon fa fa-database" style="color: #'+(store==='memory'?'ddd':'777')+'"></i>'}
return {value:store,label: store, icon:'<i class="red-ui-typedInput-icon fa fa-database"></i>'}
})
if (contextOptions.length < 2) {
allOptions.flow.options = [];
@ -138,12 +193,12 @@
var that = this;
this.disarmClick = false;
this.input = $('<input type="text"></input>');
this.input = $('<input class="red-ui-typedInput-input" type="text"></input>');
this.input.insertAfter(this.element);
this.input.val(this.element.val());
this.element.addClass('red-ui-typedInput');
this.uiWidth = this.element.outerWidth();
this.elementDiv = this.input.wrap("<div>").parent().addClass('red-ui-typedInput-input');
this.elementDiv = this.input.wrap("<div>").parent().addClass('red-ui-typedInput-input-wrap');
this.uiSelect = this.elementDiv.wrap( "<div>" ).parent();
var attrStyle = this.element.attr('style');
var m;
@ -160,7 +215,7 @@
that.input.css("margin"+d,0);
});
["type","placeholder","data-i18n"].forEach(function(d) {
["type","placeholder","autocomplete","data-i18n"].forEach(function(d) {
var m = that.element.attr(d);
that.input.attr(d,m);
});
@ -171,11 +226,13 @@
this.options.types = this.options.types||Object.keys(allOptions);
this.selectTrigger = $('<button tabindex="0"></button>').prependTo(this.uiSelect);
$('<i class="red-ui-typedInput-icon fa fa-sort-desc"></i>').toggle(this.options.types.length > 1).appendTo(this.selectTrigger);
this.selectTrigger = $('<button class="red-ui-typedInput-type-select" tabindex="0"></button>').prependTo(this.uiSelect);
$('<i class="red-ui-typedInput-icon fa fa-caret-down"></i>').toggle(this.options.types.length > 1).appendTo(this.selectTrigger);
this.selectLabel = $('<span class="red-ui-typedInput-type-label"></span>').appendTo(this.selectTrigger);
this.valueLabelContainer = $('<div class="red-ui-typedInput-value-label">').appendTo(this.uiSelect)
this.types(this.options.types);
if (this.options.typeField) {
@ -198,9 +255,15 @@
that.validate();
that.element.val(that.value());
that.element.trigger('change',that.propertyType,that.value());
});
this.input.on('keydown', function(evt) {
if (evt.keyCode >= 37 && evt.keyCode <= 40) {
evt.stopPropagation();
}
})
this.selectTrigger.click(function(event) {
this.selectTrigger.on("click", function(event) {
event.preventDefault();
event.stopPropagation();
that._showTypeMenu();
});
this.selectTrigger.on('keydown',function(evt) {
@ -208,31 +271,35 @@
// Down
that._showTypeMenu();
}
evt.stopPropagation();
}).on('focus', function() {
that.uiSelect.addClass('red-ui-typedInput-focus');
})
// explicitly set optionSelectTrigger display to inline-block otherwise jQ sets it to 'inline'
this.optionSelectTrigger = $('<button tabindex="0" class="red-ui-typedInput-option-trigger" style="display:inline-block"><span class="red-ui-typedInput-option-caret"><i class="red-ui-typedInput-icon fa fa-sort-desc"></i></span></button>').appendTo(this.uiSelect);
this.optionSelectTrigger = $('<button tabindex="0" class="red-ui-typedInput-option-trigger" style="display:inline-block"><span class="red-ui-typedInput-option-caret"><i class="red-ui-typedInput-icon fa fa-caret-down"></i></span></button>').appendTo(this.uiSelect);
this.optionSelectLabel = $('<span class="red-ui-typedInput-option-label"></span>').prependTo(this.optionSelectTrigger);
RED.popover.tooltip(this.optionSelectLabel,function() {
return that.optionValue;
});
this.optionSelectTrigger.click(function(event) {
this.optionSelectTrigger.on("click", function(event) {
event.preventDefault();
event.stopPropagation();
that._showOptionSelectMenu();
}).on('keydown', function(evt) {
if (evt.keyCode === 40) {
// Down
that._showOptionSelectMenu();
}
evt.stopPropagation();
}).on('blur', function() {
that.uiSelect.removeClass('red-ui-typedInput-focus');
}).on('focus', function() {
that.uiSelect.addClass('red-ui-typedInput-focus');
});
this.optionExpandButton = $('<button tabindex="0" class="red-ui-typedInput-option-expand" style="display:inline-block"><i class="red-ui-typedInput-icon fa fa-ellipsis-h"></i></button>').appendTo(this.uiSelect);
this.optionExpandButton = $('<button tabindex="0" class="red-ui-typedInput-option-expand" style="display:inline-block"></button>').appendTo(this.uiSelect);
this.optionExpandButtonIcon = $('<i class="red-ui-typedInput-icon fa fa-ellipsis-h"></i>').appendTo(this.optionExpandButton);
this.type(this.options.default||this.typeList[0].value);
}catch(err) {
console.log(err.stack);
@ -241,9 +308,12 @@
_showTypeMenu: function() {
if (this.typeList.length > 1) {
this._showMenu(this.menu,this.selectTrigger);
this.menu.find("[value='"+this.propertyType+"']").focus();
var selected = this.menu.find("[value='"+this.propertyType+"']");
setTimeout(function() {
selected.trigger("focus");
},120);
} else {
this.input.focus();
this.input.trigger("focus");
}
},
_showOptionSelectMenu: function() {
@ -257,25 +327,41 @@
if (selectedOption.length === 0) {
selectedOption = this.optionMenu.children(":first");
}
selectedOption.focus();
selectedOption.trigger("focus");
}
},
_hideMenu: function(menu) {
$(document).off("mousedown.close-property-select");
$(document).off("mousedown.red-ui-typedInput-close-property-select");
menu.hide();
menu.css({
height: "auto"
});
if (menu.opts.multiple) {
var selected = [];
menu.find('input[type="checkbox"]').each(function() {
if ($(this).prop("checked")) {
selected.push($(this).data('value'))
}
})
menu.callback(selected);
}
if (this.elementDiv.is(":visible")) {
this.input.focus();
this.input.trigger("focus");
} else if (this.optionSelectTrigger.is(":visible")){
this.optionSelectTrigger.focus();
this.optionSelectTrigger.trigger("focus");
} else {
this.selectTrigger.focus();
this.selectTrigger.trigger("focus");
}
},
_createMenu: function(opts,callback) {
_createMenu: function(menuOptions,opts,callback) {
var that = this;
var menu = $("<div>").addClass("red-ui-typedInput-options");
opts.forEach(function(opt) {
var menu = $("<div>").addClass("red-ui-typedInput-options red-ui-editor-dialog");
menu.opts = opts;
menu.callback = callback;
menuOptions.forEach(function(opt) {
if (typeof opt === 'string') {
opt = {value:opt,label:opt};
}
@ -287,7 +373,7 @@
if (opt.icon.indexOf("<") === 0) {
$(opt.icon).prependTo(op);
} else if (opt.icon.indexOf("/") !== -1) {
$('<img>',{src:opt.icon,style:"margin-right: 4px; height: 18px;"}).prependTo(op);
$('<img>',{src:mapDeprecatedIcon(opt.icon),style:"margin-right: 4px; height: 18px;"}).prependTo(op);
} else {
$('<i>',{class:"red-ui-typedInput-icon "+opt.icon}).prependTo(op);
}
@ -297,32 +383,43 @@
if (!opt.icon && !opt.label) {
op.text(opt.value);
}
var cb;
if (opts.multiple) {
cb = $('<input type="checkbox">').css("pointer-events","none").data('value',opt.value).prependTo(op).on("mousedown", function(evt) { evt.preventDefault() });
}
op.click(function(event) {
op.on("click", function(event) {
event.preventDefault();
callback(opt.value);
that._hideMenu(menu);
event.stopPropagation();
if (!opts.multiple) {
callback(opt.value);
that._hideMenu(menu);
} else {
cb.prop("checked",!cb.prop("checked"));
}
});
});
menu.css({
display: "none",
display: "none"
});
menu.appendTo(document.body);
menu.on('keydown', function(evt) {
if (evt.keyCode === 40) {
evt.preventDefault();
// DOWN
$(this).children(":focus").next().focus();
$(this).children(":focus").next().trigger("focus");
} else if (evt.keyCode === 38) {
evt.preventDefault();
// UP
$(this).children(":focus").prev().focus();
$(this).children(":focus").prev().trigger("focus");
} else if (evt.keyCode === 27) {
// ESCAPE
evt.preventDefault();
that._hideMenu(menu);
}
evt.stopPropagation();
})
return menu;
},
@ -331,22 +428,37 @@
this.disarmClick = false;
return
}
if (menu.opts.multiple) {
var selected = {};
this.value().split(",").forEach(function(f) {
selected[f] = true;
})
menu.find('input[type="checkbox"]').each(function() {
$(this).prop("checked",selected[$(this).data('value')])
})
}
var that = this;
var pos = relativeTo.offset();
var height = relativeTo.height();
var menuHeight = menu.height();
var top = (height+pos.top-3);
var top = (height+pos.top);
if (top+menuHeight > $(window).height()) {
top -= (top+menuHeight)-$(window).height()+5;
}
if (top < 0) {
menu.height(menuHeight+top)
top = 0;
}
menu.css({
top: top+"px",
left: (2+pos.left)+"px",
left: (pos.left)+"px",
});
menu.slideDown(100);
this._delay(function() {
that.uiSelect.addClass('red-ui-typedInput-focus');
$(document).on("mousedown.close-property-select", function(event) {
$(document).on("mousedown.red-ui-typedInput-close-property-select", function(event) {
if(!$(event.target).closest(menu).length) {
that._hideMenu(menu);
}
@ -357,21 +469,27 @@
})
});
},
_getLabelWidth: function(label) {
_getLabelWidth: function(label, done) {
var labelWidth = label.outerWidth();
if (labelWidth === 0) {
var container = $('<div class="red-ui-typedInput-container"></div>').css({
var wrapper = $('<div class="red-ui-editor"></div>').css({
position:"absolute",
top:0,
left:-1000
"white-space": "nowrap",
top:-2000
}).appendTo(document.body);
var container = $('<div class="red-ui-typedInput-container"></div>').appendTo(wrapper);
var newTrigger = label.clone().appendTo(container);
labelWidth = newTrigger.outerWidth();
container.remove();
setTimeout(function() {
labelWidth = newTrigger.outerWidth();
wrapper.remove();
done(labelWidth);
},50)
} else {
done(labelWidth);
}
return labelWidth;
},
_resize: function() {
var that = this;
if (this.uiWidth !== null) {
this.uiSelect.width(this.uiWidth);
}
@ -380,68 +498,78 @@
this.selectTrigger.addClass("red-ui-typedInput-full-width");
} else {
this.selectTrigger.removeClass("red-ui-typedInput-full-width");
var labelWidth = this._getLabelWidth(this.selectTrigger);
this.elementDiv.css('left',labelWidth+"px");
if (this.optionExpandButton.is(":visible")) {
this.elementDiv.css('right',"22px");
} else {
this.elementDiv.css('right','0');
this.input.css({
'border-top-right-radius': '4px',
'border-bottom-right-radius': '4px'
});
}
// if (this.optionSelectTrigger) {
// this.optionSelectTrigger.css({'left':(labelWidth)+"px",'width':'calc( 100% - '+labelWidth+'px )'});
// }
if (this.optionSelectTrigger) {
if (type && type.options && type.hasValue === true) {
this.optionSelectLabel.css({'left':'auto'})
var lw = this._getLabelWidth(this.optionSelectLabel);
this.optionSelectTrigger.css({'width':(23+lw)+"px"});
this.elementDiv.css('right',(23+lw)+"px");
this.input.css({
'border-top-right-radius': 0,
'border-bottom-right-radius': 0
});
this._getLabelWidth(this.selectTrigger, function(labelWidth) {
that.elementDiv.css('left',labelWidth+"px");
that.valueLabelContainer.css('left',labelWidth+"px");
if (that.optionExpandButton.shown) {
that.elementDiv.css('right',"22px");
that.valueLabelContainer.css('right',"22px");
} else {
this.optionSelectLabel.css({'left':'0'})
this.optionSelectTrigger.css({'width':'calc( 100% - '+labelWidth+'px )'});
if (!this.optionExpandButton.is(":visible")) {
this.elementDiv.css({'right':0});
this.input.css({
'border-top-right-radius': '4px',
'border-bottom-right-radius': '4px'
that.elementDiv.css('right','0');
that.valueLabelContainer.css('right','0');
that.input.css({
'border-top-right-radius': '4px',
'border-bottom-right-radius': '4px'
});
}
if (that.optionSelectTrigger) {
if (type && type.options && type.hasValue === true) {
that.optionSelectLabel.css({'left':'auto'})
that._getLabelWidth(that.optionSelectLabel, function(lw) {
that.optionSelectTrigger.css({'width':(23+lw)+"px"});
that.elementDiv.css('right',(23+lw)+"px");
that.input.css({
'border-top-right-radius': 0,
'border-bottom-right-radius': 0
});
});
} else {
that.optionSelectLabel.css({'left':'0'})
that.optionSelectTrigger.css({'width':'calc( 100% - '+labelWidth+'px )'});
if (!that.optionExpandButton.shown) {
that.elementDiv.css({'right':0});
that.input.css({
'border-top-right-radius': '4px',
'border-bottom-right-radius': '4px'
});
}
}
}
}
});
}
},
_updateOptionSelectLabel: function(o) {
var opt = this.typeMap[this.propertyType];
this.optionSelectLabel.empty();
if (o.icon) {
if (o.icon.indexOf("<") === 0) {
$(o.icon).prependTo(this.optionSelectLabel);
} else if (o.icon.indexOf("/") !== -1) {
// url
$('<img>',{src:o.icon,style:"height: 18px;"}).prependTo(this.optionSelectLabel);
if (this.typeMap[this.propertyType].valueLabel) {
if (opt.multiple) {
this.typeMap[this.propertyType].valueLabel.call(this,this.optionSelectLabel,o);
} else {
// icon class
$('<i>',{class:"red-ui-typedInput-icon "+o.icon}).prependTo(this.optionSelectLabel);
this.typeMap[this.propertyType].valueLabel.call(this,this.optionSelectLabel,o.value);
}
} else if (!opt.multiple) {
if (o.icon) {
if (o.icon.indexOf("<") === 0) {
$(o.icon).prependTo(this.optionSelectLabel);
} else if (o.icon.indexOf("/") !== -1) {
// url
$('<img>',{src:mapDeprecatedIcon(o.icon),style:"height: 18px;"}).prependTo(this.optionSelectLabel);
} else {
// icon class
$('<i>',{class:"red-ui-typedInput-icon "+o.icon}).prependTo(this.optionSelectLabel);
}
} else if (o.label) {
this.optionSelectLabel.text(o.label);
} else {
this.optionSelectLabel.text(o.value);
}
if (opt.hasValue) {
this.optionValue = o.value;
this._resize();
this.input.trigger('change',this.propertyType,this.value());
}
} else if (o.label) {
this.optionSelectLabel.text(o.label);
} else {
this.optionSelectLabel.text(o.value);
}
if (opt.hasValue) {
this.optionValue = o.value;
this._resize();
this.input.trigger('change',this.propertyType,this.value());
this.optionSelectLabel.text(o.length+" selected");
}
},
_destroy: function() {
@ -449,6 +577,7 @@
this.optionMenu.remove();
}
this.menu.remove();
this.uiSelect.remove();
},
types: function(types) {
var that = this;
@ -465,11 +594,11 @@
return result;
});
this.selectTrigger.toggleClass("disabled", this.typeList.length === 1);
this.selectTrigger.find(".fa-sort-desc").toggle(this.typeList.length > 1)
this.selectTrigger.find(".fa-caret-down").toggle(this.typeList.length > 1)
if (this.menu) {
this.menu.remove();
}
this.menu = this._createMenu(this.typeList, function(v) { that.type(v) });
this.menu = this._createMenu(this.typeList,{},function(v) { that.type(v) });
if (currentType && !this.typeMap.hasOwnProperty(currentType)) {
this.type(this.typeList[0].value);
} else {
@ -483,33 +612,52 @@
this._resize();
},
value: function(value) {
var that = this;
var opt = this.typeMap[this.propertyType];
if (!arguments.length) {
var v = this.input.val();
if (this.typeMap[this.propertyType].export) {
v = this.typeMap[this.propertyType].export(v,this.optionValue)
if (opt.export) {
v = opt.export(v,this.optionValue)
}
return v;
} else {
var selectedOption;
if (this.typeMap[this.propertyType].options) {
for (var i=0;i<this.typeMap[this.propertyType].options.length;i++) {
var op = this.typeMap[this.propertyType].options[i];
if (typeof op === "string") {
if (op === value) {
selectedOption = this.activeOptions[op];
var selectedOption = [];
if (opt.options) {
var checkValues = [value];
if (opt.multiple) {
selectedOption = [];
checkValues = value.split(",");
}
checkValues.forEach(function(value) {
for (var i=0;i<opt.options.length;i++) {
var op = opt.options[i];
if (typeof op === "string") {
if (op === value) {
selectedOption.push(that.activeOptions[op]);
break;
}
} else if (op.value === value) {
selectedOption.push(op);
break;
}
} else if (op.value === value) {
selectedOption = op;
break;
}
})
this.input.val(value);
if (!opt.multiple) {
if (!selectedOption.length === 0) {
selectedOption = [{value:""}];
}
this._updateOptionSelectLabel(selectedOption[0])
} else {
this._updateOptionSelectLabel(selectedOption)
}
if (!selectedOption) {
selectedOption = {value:""}
} else {
this.input.val(value);
if (opt.valueLabel) {
this.valueLabelContainer.empty();
opt.valueLabel.call(this,this.valueLabelContainer,value);
}
this._updateOptionSelectLabel(selectedOption)
}
this.input.val(value);
this.input.trigger('change',this.type(),value);
}
},
@ -526,20 +674,23 @@
}
this.selectLabel.empty();
var image;
if (opt.icon) {
if (opt.icon && opt.showLabel !== false) {
if (opt.icon.indexOf("<") === 0) {
$(opt.icon).prependTo(this.selectLabel);
}
else if (opt.icon.indexOf("/") !== -1) {
image = new Image();
image.onload = function() { that._resize(); }
image.onerror = function() { that._resize(); }
image.name = opt.icon;
image.src = opt.icon;
$('<img>',{src:opt.icon,style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel);
image.src = mapDeprecatedIcon(opt.icon);
$('<img>',{src:mapDeprecatedIcon(opt.icon),style:"margin-right: 4px;height: 18px;"}).prependTo(this.selectLabel);
}
else {
$('<i>',{class:"red-ui-typedInput-icon "+opt.icon}).prependTo(this.selectLabel);
}
} else {
}
if (opt.hasValue === false || (opt.showLabel !== false && !opt.icon)) {
this.selectLabel.text(opt.label);
}
if (this.optionMenu) {
@ -549,13 +700,16 @@
if (opt.options) {
if (this.optionExpandButton) {
this.optionExpandButton.hide();
this.optionExpandButton.shown = false;
}
if (this.optionSelectTrigger) {
this.optionSelectTrigger.show();
if (!opt.hasValue) {
this.elementDiv.hide();
this.valueLabelContainer.hide();
} else {
this.elementDiv.show();
this.valueLabelContainer.hide();
}
this.activeOptions = {};
opt.options.forEach(function(o) {
@ -569,36 +723,50 @@
if (!that.activeOptions.hasOwnProperty(that.optionValue)) {
that.optionValue = null;
}
this.optionMenu = this._createMenu(opt.options,function(v){
that._updateOptionSelectLabel(that.activeOptions[v]);
if (!opt.hasValue) {
that.value(that.activeOptions[v].value)
}
});
var op;
if (!opt.hasValue) {
var currentVal = this.input.val();
var validValue = false;
for (var i=0;i<opt.options.length;i++) {
op = opt.options[i];
if (typeof op === "string" && op === currentVal) {
that._updateOptionSelectLabel({value:currentVal});
validValue = true;
break;
} else if (op.value === currentVal) {
that._updateOptionSelectLabel(op);
validValue = true;
break;
var currentVal = this.input.val();
if (!opt.multiple) {
for (var i=0;i<opt.options.length;i++) {
op = opt.options[i];
if (typeof op === "string" && op === currentVal) {
that._updateOptionSelectLabel({value:currentVal});
validValue = true;
break;
} else if (op.value === currentVal) {
that._updateOptionSelectLabel(op);
validValue = true;
break;
}
}
}
if (!validValue) {
op = opt.options[0];
if (typeof op === "string") {
this.value(op);
that._updateOptionSelectLabel({value:op});
} else {
this.value(op.value);
that._updateOptionSelectLabel(op);
if (!validValue) {
op = opt.options[0];
if (typeof op === "string") {
this.value(op);
that._updateOptionSelectLabel({value:op});
} else {
this.value(op.value);
that._updateOptionSelectLabel(op);
}
}
} else {
// Check to see if value is a valid csv of
// options.
var currentValues = {};
currentVal.split(",").forEach(function(v) {
if (v) {
currentValues[v] = true;
}
});
for (var i=0;i<opt.options.length;i++) {
op = opt.options[i];
delete currentValues[op.value||op];
}
if (!$.isEmptyObject(currentValues)) {
// Invalid, set to default/empty
this.value((opt.default||[]).join(","));
}
}
} else {
@ -634,7 +802,21 @@
this.optionSelectTrigger.hide();
}
}
this.optionMenu = this._createMenu(opt.options,opt,function(v){
if (!opt.multiple) {
that._updateOptionSelectLabel(that.activeOptions[v]);
if (!opt.hasValue) {
that.value(that.activeOptions[v].value)
}
} else {
that._updateOptionSelectLabel(v);
if (!opt.hasValue) {
that.value(v.join(","))
}
}
});
}
this._trigger("typechange",null,this.propertyType);
this.input.trigger('change',this.propertyType,this.value());
} else {
if (this.optionSelectTrigger) {
@ -644,31 +826,62 @@
this.oldValue = this.input.val();
this.input.val("");
this.elementDiv.hide();
this.valueLabelContainer.hide();
} else if (opt.valueLabel) {
this.valueLabelContainer.show();
this.valueLabelContainer.empty();
opt.valueLabel.call(this,this.valueLabelContainer,this.input.val());
this.elementDiv.hide();
} else {
if (this.oldValue !== undefined) {
this.input.val(this.oldValue);
delete this.oldValue;
}
this.valueLabelContainer.hide();
this.elementDiv.show();
}
if (this.optionExpandButton) {
if (opt.expand && typeof opt.expand === 'function') {
if (opt.expand) {
if (opt.expand.icon) {
this.optionExpandButtonIcon.removeClass().addClass("red-ui-typedInput-icon fa "+opt.expand.icon)
} else {
this.optionExpandButtonIcon.removeClass().addClass("red-ui-typedInput-icon fa fa-ellipsis-h")
}
this.optionExpandButton.shown = true;
this.optionExpandButton.show();
this.optionExpandButton.off('click');
this.optionExpandButton.on('click',function(evt) {
evt.preventDefault();
opt.expand.call(that);
if (typeof opt.expand === 'function') {
opt.expand.call(that);
} else {
var container = $('<div>');
var content = opt.expand.content.call(that,container);
var panel = RED.popover.panel(container);
panel.container.css({
width:that.valueLabelContainer.width()
});
if (opt.expand.minWidth) {
panel.container.css({
minWidth: opt.expand.minWidth+"px"
});
}
panel.show({
target:that.optionExpandButton,
onclose:content.onclose,
align: "right"
});
}
})
} else {
this.optionExpandButton.shown = false;
this.optionExpandButton.hide();
}
}
this._trigger("typechange",null,this.propertyType);
this.input.trigger('change',this.propertyType,this.value());
}
if (image) {
image.onload = function() { that._resize(); }
image.onerror = function() { that._resize(); }
} else {
if (!image) {
this._resize();
}
}

View File

@ -17,9 +17,9 @@
RED.deploy = (function() {
var deploymentTypes = {
"full":{img:"red/images/deploy-full-o.png"},
"nodes":{img:"red/images/deploy-nodes-o.png"},
"flows":{img:"red/images/deploy-flows-o.png"}
"full":{img:"red/images/deploy-full-o.svg"},
"nodes":{img:"red/images/deploy-nodes-o.svg"},
"flows":{img:"red/images/deploy-flows-o.svg"}
}
var ignoreDeployWarnings = {
@ -36,7 +36,7 @@ RED.deploy = (function() {
function changeDeploymentType(type) {
deploymentType = type;
$("#btn-deploy-icon").attr("src",deploymentTypes[type].img);
$("#red-ui-header-button-deploy-icon").attr("src",deploymentTypes[type].img);
}
/**
@ -44,62 +44,68 @@ RED.deploy = (function() {
* type: "default" - Button with drop-down options - no further customisation available
* type: "simple" - Button without dropdown. Customisations:
* label: the text to display - default: "Deploy"
* icon : the icon to use. Null removes the icon. default: "red/images/deploy-full-o.png"
* icon : the icon to use. Null removes the icon. default: "red/images/deploy-full-o.svg"
*/
function init(options) {
options = options || {};
var type = options.type || "default";
if (type == "default") {
$('<li><span class="deploy-button-group button-group">'+
'<a id="btn-deploy" class="deploy-button disabled" href="#">'+
'<span class="deploy-button-content">'+
'<img id="btn-deploy-icon" src="red/images/deploy-full-o.png"> '+
$('<li><span class="red-ui-deploy-button-group button-group">'+
'<a id="red-ui-header-button-deploy" class="red-ui-deploy-button disabled" href="#">'+
'<span class="red-ui-deploy-button-content">'+
'<img id="red-ui-header-button-deploy-icon" src="red/images/deploy-full-o.svg"> '+
'<span>'+RED._("deploy.deploy")+'</span>'+
'</span>'+
'<span class="deploy-button-spinner hide">'+
'<span class="red-ui-deploy-button-spinner hide">'+
'<img src="red/images/spin.svg"/>'+
'</span>'+
'</a>'+
'<a id="btn-deploy-options" data-toggle="dropdown" class="deploy-button" href="#"><i class="fa fa-caret-down"></i></a>'+
'</span></li>').prependTo(".header-toolbar");
RED.menu.init({id:"btn-deploy-options",
'<a id="red-ui-header-button-deploy-options" class="red-ui-deploy-button" href="#"><i class="fa fa-caret-down"></i></a>'+
'</span></li>').prependTo(".red-ui-header-toolbar");
RED.menu.init({id:"red-ui-header-button-deploy-options",
options: [
{id:"deploymenu-item-full",toggle:"deploy-type",icon:"red/images/deploy-full.png",label:RED._("deploy.full"),sublabel:RED._("deploy.fullDesc"),selected: true, onselect:function(s) { if(s){changeDeploymentType("full")}}},
{id:"deploymenu-item-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.png",label:RED._("deploy.modifiedFlows"),sublabel:RED._("deploy.modifiedFlowsDesc"), onselect:function(s) {if(s){changeDeploymentType("flows")}}},
{id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.png",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
{id:"deploymenu-item-full",toggle:"deploy-type",icon:"red/images/deploy-full.svg",label:RED._("deploy.full"),sublabel:RED._("deploy.fullDesc"),selected: true, onselect:function(s) { if(s){changeDeploymentType("full")}}},
{id:"deploymenu-item-flow",toggle:"deploy-type",icon:"red/images/deploy-flows.svg",label:RED._("deploy.modifiedFlows"),sublabel:RED._("deploy.modifiedFlowsDesc"), onselect:function(s) {if(s){changeDeploymentType("flows")}}},
{id:"deploymenu-item-node",toggle:"deploy-type",icon:"red/images/deploy-nodes.svg",label:RED._("deploy.modifiedNodes"),sublabel:RED._("deploy.modifiedNodesDesc"),onselect:function(s) { if(s){changeDeploymentType("nodes")}}},
null,
{id:"deploymenu-item-reload", icon:"red/images/deploy-reload.png",label:RED._("deploy.restartFlows"),sublabel:RED._("deploy.restartFlowsDesc"),onselect:"core:restart-flows"},
{id:"deploymenu-item-reload", icon:"red/images/deploy-reload.svg",label:RED._("deploy.restartFlows"),sublabel:RED._("deploy.restartFlowsDesc"),onselect:"core:restart-flows"},
]
});
} else if (type == "simple") {
var label = options.label || RED._("deploy.deploy");
var icon = 'red/images/deploy-full-o.png';
var icon = 'red/images/deploy-full-o.svg';
if (options.hasOwnProperty('icon')) {
icon = options.icon;
}
$('<li><span class="deploy-button-group button-group">'+
'<a id="btn-deploy" class="deploy-button disabled" href="#">'+
'<span class="deploy-button-content">'+
(icon?'<img id="btn-deploy-icon" src="'+icon+'"> ':'')+
$('<li><span class="red-ui-deploy-button-group button-group">'+
'<a id="red-ui-header-button-deploy" class="red-ui-deploy-button disabled" href="#">'+
'<span class="red-ui-deploy-button-content">'+
(icon?'<img id="red-ui-header-button-deploy-icon" src="'+icon+'"> ':'')+
'<span>'+label+'</span>'+
'</span>'+
'<span class="deploy-button-spinner hide">'+
'<span class="red-ui-deploy-button-spinner hide">'+
'<img src="red/images/spin.svg"/>'+
'</span>'+
'</a>'+
'</span></li>').prependTo(".header-toolbar");
'</span></li>').prependTo(".red-ui-header-toolbar");
}
$('#btn-deploy').click(function(event) {
$('#red-ui-header-button-deploy').on("click", function(event) {
event.preventDefault();
save();
});
RED.actions.add("core:deploy-flows",save);
RED.actions.add("core:restart-flows",restart);
if (type === "default") {
RED.actions.add("core:restart-flows",restart);
RED.actions.add("core:set-deploy-type-to-full",function() { RED.menu.setSelected("deploymenu-item-full",true);});
RED.actions.add("core:set-deploy-type-to-modified-flows",function() { RED.menu.setSelected("deploymenu-item-flow",true); });
RED.actions.add("core:set-deploy-type-to-modified-nodes",function() { RED.menu.setSelected("deploymenu-item-node",true); });
}
RED.events.on('nodes:change',function(state) {
@ -107,10 +113,10 @@ RED.deploy = (function() {
window.onbeforeunload = function() {
return RED._("deploy.confirm.undeployedChanges");
}
$("#btn-deploy").removeClass("disabled");
$("#red-ui-header-button-deploy").removeClass("disabled");
} else {
window.onbeforeunload = null;
$("#btn-deploy").addClass("disabled");
$("#red-ui-header-button-deploy").addClass("disabled");
}
});
@ -176,14 +182,14 @@ RED.deploy = (function() {
function resolveConflict(currentNodes, activeDeploy) {
var message = $('<div>');
$('<p data-i18n="deploy.confirm.conflict"></p>').appendTo(message);
var conflictCheck = $('<div id="node-dialog-confirm-deploy-conflict-checking" class="node-dialog-confirm-conflict-row">'+
var conflictCheck = $('<div class="red-ui-deploy-dialog-confirm-conflict-row">'+
'<img src="red/images/spin.svg"/><div data-i18n="deploy.confirm.conflictChecking"></div>'+
'</div>').appendTo(message);
var conflictAutoMerge = $('<div class="node-dialog-confirm-conflict-row">'+
'<i style="color: #3a3;" class="fa fa-check"></i><div data-i18n="deploy.confirm.conflictAutoMerge"></div>'+
var conflictAutoMerge = $('<div class="red-ui-deploy-dialog-confirm-conflict-row">'+
'<i class="fa fa-check"></i><div data-i18n="deploy.confirm.conflictAutoMerge"></div>'+
'</div>').hide().appendTo(message);
var conflictManualMerge = $('<div id="node-dialog-confirm-deploy-conflict-manual-merge" class="node-dialog-confirm-conflict-row">'+
'<i style="color: #999;" class="fa fa-exclamation"></i><div data-i18n="deploy.confirm.conflictManualMerge"></div>'+
var conflictManualMerge = $('<div class="red-ui-deploy-dialog-confirm-conflict-row">'+
'<i class="fa fa-exclamation"></i><div data-i18n="deploy.confirm.conflictManualMerge"></div>'+
'</div>').hide().appendTo(message);
message.i18n();
@ -196,22 +202,22 @@ RED.deploy = (function() {
}
},
{
id: "node-dialog-confirm-deploy-review",
id: "red-ui-deploy-dialog-confirm-deploy-review",
text: RED._("deploy.confirm.button.review"),
class: "primary disabled",
click: function() {
if (!$("#node-dialog-confirm-deploy-review").hasClass('disabled')) {
if (!$("#red-ui-deploy-dialog-confirm-deploy-review").hasClass('disabled')) {
RED.diff.showRemoteDiff();
conflictNotification.close();
}
}
},
{
id: "node-dialog-confirm-deploy-merge",
id: "red-ui-deploy-dialog-confirm-deploy-merge",
text: RED._("deploy.confirm.button.merge"),
class: "primary disabled",
click: function() {
if (!$("#node-dialog-confirm-deploy-merge").hasClass('disabled')) {
if (!$("#red-ui-deploy-dialog-confirm-deploy-merge").hasClass('disabled')) {
RED.diff.mergeDiff(currentDiff);
conflictNotification.close();
}
@ -220,7 +226,7 @@ RED.deploy = (function() {
];
if (activeDeploy) {
buttons.push({
id: "node-dialog-confirm-deploy-overwrite",
id: "red-ui-deploy-dialog-confirm-deploy-overwrite",
text: RED._("deploy.confirm.button.overwrite"),
class: "primary",
click: function() {
@ -245,11 +251,11 @@ RED.deploy = (function() {
var d = Object.keys(diff.conflicts);
if (d.length === 0) {
conflictAutoMerge.show();
$("#node-dialog-confirm-deploy-merge").removeClass('disabled')
$("#red-ui-deploy-dialog-confirm-deploy-merge").removeClass('disabled')
} else {
conflictManualMerge.show();
}
$("#node-dialog-confirm-deploy-review").removeClass('disabled')
$("#red-ui-deploy-dialog-confirm-deploy-review").removeClass('disabled')
},ellapsed);
})
}
@ -266,15 +272,15 @@ RED.deploy = (function() {
}
function restart() {
var startTime = Date.now();
$(".deploy-button-content").css('opacity',0);
$(".deploy-button-spinner").show();
var deployWasEnabled = !$("#btn-deploy").hasClass("disabled");
$("#btn-deploy").addClass("disabled");
$(".red-ui-deploy-button-content").css('opacity',0);
$(".red-ui-deploy-button-spinner").show();
var deployWasEnabled = !$("#red-ui-header-button-deploy").hasClass("disabled");
$("#red-ui-header-button-deploy").addClass("disabled");
deployInflight = true;
$("#header-shade").show();
$("#editor-shade").show();
$("#palette-shade").show();
$("#sidebar-shade").show();
$("#red-ui-header-shade").show();
$("#red-ui-editor-shade").show();
$("#red-ui-palette-shade").show();
$("#red-ui-sidebar-shade").show();
$.ajax({
url:"flows",
@ -284,12 +290,12 @@ RED.deploy = (function() {
}
}).done(function(data,textStatus,xhr) {
if (deployWasEnabled) {
$("#btn-deploy").removeClass("disabled");
$("#red-ui-header-button-deploy").removeClass("disabled");
}
RED.notify('<p>'+RED._("deploy.successfulRestart")+'</p>',"success");
}).fail(function(xhr,textStatus,err) {
if (deployWasEnabled) {
$("#btn-deploy").removeClass("disabled");
$("#red-ui-header-button-deploy").removeClass("disabled");
}
if (xhr.status === 401) {
RED.notify(RED._("deploy.deployFailed",{message:RED._("user.notAuthorized")}),"error");
@ -304,17 +310,17 @@ RED.deploy = (function() {
deployInflight = false;
var delta = Math.max(0,300-(Date.now()-startTime));
setTimeout(function() {
$(".deploy-button-content").css('opacity',1);
$(".deploy-button-spinner").hide();
$("#header-shade").hide();
$("#editor-shade").hide();
$("#palette-shade").hide();
$("#sidebar-shade").hide();
$(".red-ui-deploy-button-content").css('opacity',1);
$(".red-ui-deploy-button-spinner").hide();
$("#red-ui-header-shade").hide();
$("#red-ui-editor-shade").hide();
$("#red-ui-palette-shade").hide();
$("#red-ui-sidebar-shade").hide();
},delta);
});
}
function save(skipValidation,force) {
if (!$("#btn-deploy").hasClass("disabled")) {
if (!$("#red-ui-header-button-deploy").hasClass("disabled")) {
if (!RED.user.hasPermission("flows.write")) {
RED.notify(RED._("user.errors.deploy"),"error");
return;
@ -355,13 +361,13 @@ RED.deploy = (function() {
if (hasUnknown && !ignoreDeployWarnings.unknown) {
showWarning = true;
notificationMessage = "<p>"+RED._('deploy.confirm.unknown')+"</p>"+
'<ul class="node-dialog-configm-deploy-list"><li>'+cropList(unknownNodes).map(function(n) { return sanitize(n) }).join("</li><li>")+"</li></ul><p>"+
'<ul class="red-ui-deploy-dialog-confirm-list"><li>'+cropList(unknownNodes).map(function(n) { return sanitize(n) }).join("</li><li>")+"</li></ul><p>"+
RED._('deploy.confirm.confirm')+
"</p>";
notificationButtons= [
{
id: "node-dialog-confirm-deploy-deploy",
id: "red-ui-deploy-dialog-confirm-deploy-deploy",
text: RED._("deploy.confirm.button.confirm"),
class: "primary",
click: function() {
@ -375,12 +381,12 @@ RED.deploy = (function() {
invalidNodes.sort(sortNodeInfo);
notificationMessage = "<p>"+RED._('deploy.confirm.improperlyConfigured')+"</p>"+
'<ul class="node-dialog-configm-deploy-list"><li>'+cropList(invalidNodes.map(function(A) { return sanitize( (A.tab?"["+A.tab+"] ":"")+A.label+" ("+A.type+")")})).join("</li><li>")+"</li></ul><p>"+
'<ul class="red-ui-deploy-dialog-confirm-list"><li>'+cropList(invalidNodes.map(function(A) { return sanitize( (A.tab?"["+A.tab+"] ":"")+A.label+" ("+A.type+")")})).join("</li><li>")+"</li></ul><p>"+
RED._('deploy.confirm.confirm')+
"</p>";
notificationButtons= [
{
id: "node-dialog-confirm-deploy-deploy",
id: "red-ui-deploy-dialog-confirm-deploy-deploy",
text: RED._("deploy.confirm.button.confirm"),
class: "primary",
click: function() {
@ -411,9 +417,9 @@ RED.deploy = (function() {
var nns = RED.nodes.createCompleteNodeSet();
var startTime = Date.now();
$(".deploy-button-content").css('opacity',0);
$(".deploy-button-spinner").show();
$("#btn-deploy").addClass("disabled");
$(".red-ui-deploy-button-content").css('opacity',0);
$(".red-ui-deploy-button-spinner").show();
$("#red-ui-header-button-deploy").addClass("disabled");
var data = {flows:nns};
@ -422,10 +428,10 @@ RED.deploy = (function() {
}
deployInflight = true;
$("#header-shade").show();
$("#editor-shade").show();
$("#palette-shade").show();
$("#sidebar-shade").show();
$("#red-ui-header-shade").show();
$("#red-ui-editor-shade").show();
$("#red-ui-palette-shade").show();
$("#red-ui-sidebar-shade").show();
$.ajax({
url:"flows",
type: "POST",
@ -476,7 +482,7 @@ RED.deploy = (function() {
RED.events.emit("deploy");
}).fail(function(xhr,textStatus,err) {
RED.nodes.dirty(true);
$("#btn-deploy").removeClass("disabled");
$("#red-ui-header-button-deploy").removeClass("disabled");
if (xhr.status === 401) {
RED.notify(RED._("deploy.deployFailed",{message:RED._("user.notAuthorized")}),"error");
} else if (xhr.status === 409) {
@ -490,12 +496,12 @@ RED.deploy = (function() {
deployInflight = false;
var delta = Math.max(0,300-(Date.now()-startTime));
setTimeout(function() {
$(".deploy-button-content").css('opacity',1);
$(".deploy-button-spinner").hide();
$("#header-shade").hide();
$("#editor-shade").hide();
$("#palette-shade").hide();
$("#sidebar-shade").hide();
$(".red-ui-deploy-button-content").css('opacity',1);
$(".red-ui-deploy-button-spinner").hide();
$("#red-ui-header-shade").hide();
$("#red-ui-editor-shade").hide();
$("#red-ui-palette-shade").hide();
$("#red-ui-sidebar-shade").hide();
},delta);
});
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
**/
(function() {
var template = '<script type="text/x-red" data-template-name="_buffer"><div id="node-input-buffer-panels"><div id="node-input-buffer-panel-str" class="red-ui-panel"><div class="form-row" style="margin-bottom: 3px; text-align: right;"><span class="node-input-buffer-type"><i class="fa fa-exclamation-circle"></i> <span id="node-input-buffer-type-string" data-i18n="bufferEditor.modeString"></span><span id="node-input-buffer-type-array" data-i18n="bufferEditor.modeArray"></span></span></div><div class="form-row node-text-editor-row"><div class="node-text-editor" id="node-input-buffer-str"></div></div></div><div id="node-input-buffer-panel-bin" class="red-ui-panel"><div class="form-row node-text-editor-row" style="margin-top: 10px"><div class="node-text-editor" id="node-input-buffer-bin"></div></div></div></div></script>';
var template = '<script type="text/x-red" data-template-name="_buffer"><div id="red-ui-editor-type-buffer-panels"><div id="red-ui-editor-type-buffer-panel-str" class="red-ui-panel"><div class="form-row" style="margin-bottom: 3px; text-align: right;"><button class="red-ui-editor-type-buffer-type red-ui-button red-ui-button-small"><i class="fa fa-exclamation-circle"></i> <span id="red-ui-editor-type-buffer-type-string" data-i18n="bufferEditor.modeString"></span><span id="red-ui-editor-type-buffer-type-array" data-i18n="bufferEditor.modeArray"></span></button></div><div class="form-row node-text-editor-row"><div class="node-text-editor" id="red-ui-editor-type-buffer-str"></div></div></div><div id="red-ui-editor-type-buffer-panel-bin" class="red-ui-panel"><div class="form-row node-text-editor-row" style="margin-top: 10px"><div class="node-text-editor" id="red-ui-editor-type-buffer-bin"></div></div></div></div></script>';
function stringToUTF8Array(str) {
var data = [];
@ -49,6 +49,9 @@
var value = options.value;
var onComplete = options.complete;
var type = "_buffer"
if ($("script[data-template-name='"+type+"']").length === 0) {
$(template).appendTo("#red-ui-editor-node-configs");
}
RED.view.state(RED.state.EDITING);
var bufferStringEditor = [];
var bufferBinValue;
@ -83,18 +86,18 @@
}
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
var trayBody = tray.find('.red-ui-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form',type,'editor');
bufferStringEditor = RED.editor.createEditor({
id: 'node-input-buffer-str',
id: 'red-ui-editor-type-buffer-str',
value: "",
mode:"ace/mode/text"
});
bufferStringEditor.getSession().setValue(value||"",-1);
bufferBinEditor = RED.editor.createEditor({
id: 'node-input-buffer-bin',
id: 'red-ui-editor-type-buffer-bin',
value: "",
mode:"ace/mode/text",
readOnly: true
@ -132,8 +135,8 @@
binBuffer.push((d<16?"0":"")+d.toString(16).toUpperCase());
}
if (valid) {
$("#node-input-buffer-type-string").toggle(isString);
$("#node-input-buffer-type-array").toggle(!isString);
$("#red-ui-editor-type-buffer-type-string").toggle(isString);
$("#red-ui-editor-type-buffer-type-array").toggle(!isString);
bufferBinEditor.setValue(binBuffer.join(""),1);
}
return valid;
@ -165,24 +168,24 @@
dialogForm.i18n();
panels = RED.panels.create({
id:"node-input-buffer-panels",
id:"red-ui-editor-type-buffer-panels",
resize: function(p1Height,p2Height) {
var p1 = $("#node-input-buffer-panel-str");
var p1 = $("#red-ui-editor-type-buffer-panel-str");
p1Height -= $(p1.children()[0]).outerHeight(true);
var editorRow = $(p1.children()[1]);
p1Height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#node-input-buffer-str").css("height",(p1Height-5)+"px");
$("#red-ui-editor-type-buffer-str").css("height",(p1Height-5)+"px");
bufferStringEditor.resize();
var p2 = $("#node-input-buffer-panel-bin");
var p2 = $("#red-ui-editor-type-buffer-panel-bin");
editorRow = $(p2.children()[0]);
p2Height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#node-input-buffer-bin").css("height",(p2Height-5)+"px");
$("#red-ui-editor-type-buffer-bin").css("height",(p2Height-5)+"px");
bufferBinEditor.resize();
}
});
$(".node-input-buffer-type").click(function(e) {
$(".red-ui-editor-type-buffer-type").on("click", function(e) {
e.preventDefault();
RED.sidebar.info.set(RED._("bufferEditor.modeDesc"));
RED.sidebar.info.show();
@ -202,7 +205,6 @@
RED.tray.show(trayOptions);
}
}
$(template).appendTo(document.body);
RED.editor.registerTypeEditor("_buffer", definition);
})();

View File

@ -17,28 +17,28 @@
var template = '<script type="text/x-red" data-template-name="_expression">'+
'<div id="node-input-expression-panels">'+
'<div id="node-input-expression-panel-expr" class="red-ui-panel">'+
'<div class="form-row" style="margin-bottom: 3px; text-align: right;"><span class="node-input-expression-legacy"><i class="fa fa-exclamation-circle"></i> <span data-i18n="expressionEditor.compatMode"></span></span><button id="node-input-expression-reformat" class="editor-button editor-button-small"><span data-i18n="expressionEditor.format"></span></button></div>'+
'<div class="form-row node-text-editor-row"><div class="node-text-editor" id="node-input-expression"></div></div>'+
'<div id="red-ui-editor-type-expression-panels">'+
'<div id="red-ui-editor-type-expression-panel-expr" class="red-ui-panel">'+
'<div class="form-row" style="margin-bottom: 3px; text-align: right;"><button class="red-ui-editor-type-expression-legacy red-ui-button red-ui-button-small"><i class="fa fa-exclamation-circle"></i> <span data-i18n="expressionEditor.compatMode"></span></button><button id="red-ui-editor-type-expression-reformat" class="red-ui-button red-ui-button-small"><span data-i18n="expressionEditor.format"></span></button></div>'+
'<div class="form-row node-text-editor-row"><div class="node-text-editor" id="red-ui-editor-type-expression"></div></div>'+
'</div>'+
'<div id="node-input-expression-panel-info" class="red-ui-panel">'+
'<div id="red-ui-editor-type-expression-panel-info" class="red-ui-panel">'+
'<div class="form-row">'+
'<ul id="node-input-expression-tabs"></ul>'+
'<div id="node-input-expression-tab-help" class="node-input-expression-tab-content hide">'+
'<ul id="red-ui-editor-type-expression-tabs"></ul>'+
'<div id="red-ui-editor-type-expression-tab-help" class="red-ui-editor-type-expression-tab-content hide">'+
'<div>'+
'<select id="node-input-expression-func"></select>'+
'<button id="node-input-expression-func-insert" class="editor-button" data-i18n="expressionEditor.insert"></button>'+
'<select id="red-ui-editor-type-expression-func"></select>'+
'<button id="red-ui-editor-type-expression-func-insert" class="red-ui-button" data-i18n="expressionEditor.insert"></button>'+
'</div>'+
'<div id="node-input-expression-help"></div>'+
'<div id="red-ui-editor-type-expression-help"></div>'+
'</div>'+
'<div id="node-input-expression-tab-test" class="node-input-expression-tab-content hide">'+
'<div id="red-ui-editor-type-expression-tab-test" class="red-ui-editor-type-expression-tab-content hide">'+
'<div>'+
'<span style="display: inline-block; width: calc(50% - 5px);"><span data-i18n="expressionEditor.data"></span><button style="float: right; margin-right: 5px;" id="node-input-example-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button></span>'+
'<span style="display: inline-block; width: calc(50% - 5px);" data-i18n="expressionEditor.result"></span>'+
'<span style="display: inline-block; width: calc(50% - 5px);"><span data-i18n="expressionEditor.data"></span><button style="float: right; margin-right: 5px;" id="node-input-example-reformat" class="red-ui-button red-ui-button-small"><span data-i18n="jsonEditor.format"></span></button></span>'+
'<span style="display: inline-block; margin-left: 10px; width: calc(50% - 5px);" data-i18n="expressionEditor.result"></span>'+
'</div>'+
'<div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="node-input-expression-test-data"></div>'+
'<div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="node-input-expression-test-result"></div>'+
'<div style="display: inline-block; width: calc(50% - 5px);" class="node-text-editor" id="red-ui-editor-type-expression-test-data"></div>'+
'<div style="display: inline-block; margin-left: 10px; width:calc(50% - 5px);" class="node-text-editor" id="red-ui-editor-type-expression-test-result"></div>'+
'</div>'+
'</div>'+
'</div>'+
@ -52,6 +52,9 @@
var value = options.value;
var onComplete = options.complete;
var type = "_expression"
if ($("script[data-template-name='"+type+"']").length === 0) {
$(template).appendTo("#red-ui-editor-node-configs");
}
RED.view.state(RED.state.EDITING);
var expressionEditor;
var testDataEditor;
@ -74,7 +77,7 @@
text: RED._("common.label.done"),
class: "primary",
click: function() {
$("#node-input-expression-help").text("");
$("#red-ui-editor-type-expression-help").text("");
onComplete(expressionEditor.getValue());
RED.tray.close();
}
@ -88,23 +91,23 @@
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
trayBody.addClass("node-input-expression-editor")
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form','_expression','editor');
var funcSelect = $("#node-input-expression-func");
var trayBody = tray.find('.red-ui-tray-body');
trayBody.addClass("red-ui-editor-type-expression")
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form','_expression','editor');
var funcSelect = $("#red-ui-editor-type-expression-func");
Object.keys(jsonata.functions).forEach(function(f) {
funcSelect.append($("<option></option>").val(f).text(f));
})
funcSelect.change(function(e) {
funcSelect.on("change", function(e) {
var f = $(this).val();
var args = RED._('jsonata:'+f+".args",{defaultValue:''});
var title = "<h5>"+f+"("+args+")</h5>";
var body = marked(RED._('jsonata:'+f+'.desc',{defaultValue:''}));
$("#node-input-expression-help").html(title+"<p>"+body+"</p>");
$("#red-ui-editor-type-expression-help").html(title+"<p>"+body+"</p>");
})
expressionEditor = RED.editor.createEditor({
id: 'node-input-expression',
id: 'red-ui-editor-type-expression',
value: "",
mode:"ace/mode/jsonata",
options: {
@ -180,13 +183,13 @@
expressionEditor.session.removeMarker(currentFunctionMarker);
if (scopedFunction) {
//console.log(token,.map(function(t) { return t.type}));
funcSelect.val(scopedFunction.value).change();
funcSelect.val(scopedFunction.value).trigger("change");
}
}
});
dialogForm.i18n();
$("#node-input-expression-func-insert").click(function(e) {
$("#red-ui-editor-type-expression-func-insert").on("click", function(e) {
e.preventDefault();
var pos = expressionEditor.getCursorPosition();
var f = funcSelect.val();
@ -194,7 +197,7 @@
expressionEditor.insertSnippet(snippet);
expressionEditor.focus();
});
$("#node-input-expression-reformat").click(function(evt) {
$("#red-ui-editor-type-expression-reformat").on("click", function(evt) {
evt.preventDefault();
var v = expressionEditor.getValue()||"";
try {
@ -206,9 +209,9 @@
});
var tabs = RED.tabs.create({
element: $("#node-input-expression-tabs"),
element: $("#red-ui-editor-type-expression-tabs"),
onchange:function(tab) {
$(".node-input-expression-tab-content").hide();
$(".red-ui-editor-type-expression-tab-content").hide();
tab.content.show();
trayOptions.resize();
}
@ -217,21 +220,21 @@
tabs.addTab({
id: 'expression-help',
label: RED._('expressionEditor.functionReference'),
content: $("#node-input-expression-tab-help")
content: $("#red-ui-editor-type-expression-tab-help")
});
tabs.addTab({
id: 'expression-tests',
label: RED._('expressionEditor.test'),
content: $("#node-input-expression-tab-test")
content: $("#red-ui-editor-type-expression-tab-test")
});
testDataEditor = RED.editor.createEditor({
id: 'node-input-expression-test-data',
id: 'red-ui-editor-type-expression-test-data',
value: expressionTestCache[expressionTestCacheId] || '{\n "payload": "hello world"\n}',
mode:"ace/mode/json",
lineNumbers: false
});
var changeTimer;
$(".node-input-expression-legacy").click(function(e) {
$(".red-ui-editor-type-expression-legacy").on("click", function(e) {
e.preventDefault();
RED.sidebar.info.set(RED._("expressionEditor.compatModeDesc"));
RED.sidebar.info.show();
@ -243,7 +246,7 @@
var expr;
var usesContext = false;
var legacyMode = /(^|[^a-zA-Z0-9_'"])msg([^a-zA-Z0-9_'"]|$)/.test(currentExpression);
$(".node-input-expression-legacy").toggle(legacyMode);
$(".red-ui-editor-type-expression-legacy").toggle(legacyMode);
try {
expr = jsonata(currentExpression);
expr.assign('flowContext',function(val) {
@ -295,33 +298,33 @@
});
testResultEditor = RED.editor.createEditor({
id: 'node-input-expression-test-result',
id: 'red-ui-editor-type-expression-test-result',
value: "",
mode:"ace/mode/json",
lineNumbers: false,
readOnly: true
});
panels = RED.panels.create({
id:"node-input-expression-panels",
id:"red-ui-editor-type-expression-panels",
resize: function(p1Height,p2Height) {
var p1 = $("#node-input-expression-panel-expr");
var p1 = $("#red-ui-editor-type-expression-panel-expr");
p1Height -= $(p1.children()[0]).outerHeight(true);
var editorRow = $(p1.children()[1]);
p1Height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$("#node-input-expression").css("height",(p1Height-5)+"px");
$("#red-ui-editor-type-expression").css("height",(p1Height-5)+"px");
expressionEditor.resize();
var p2 = $("#node-input-expression-panel-info > .form-row > div:first-child");
var p2 = $("#red-ui-editor-type-expression-panel-info > .form-row > div:first-child");
p2Height -= p2.outerHeight(true) + 20;
$(".node-input-expression-tab-content").height(p2Height);
$("#node-input-expression-test-data").css("height",(p2Height-5)+"px");
$(".red-ui-editor-type-expression-tab-content").height(p2Height);
$("#red-ui-editor-type-expression-test-data").css("height",(p2Height-5)+"px");
testDataEditor.resize();
$("#node-input-expression-test-result").css("height",(p2Height-5)+"px");
$("#red-ui-editor-type-expression-test-result").css("height",(p2Height-5)+"px");
testResultEditor.resize();
}
});
$("#node-input-example-reformat").click(function(evt) {
$("#node-input-example-reformat").on("click", function(evt) {
evt.preventDefault();
var v = testDataEditor.getValue()||"";
try {
@ -346,6 +349,5 @@
RED.tray.show(trayOptions);
}
}
$(template).appendTo(document.body);
RED.editor.registerTypeEditor("_expression", definition);
})();

View File

@ -23,6 +23,9 @@
var value = options.value;
var onComplete = options.complete;
var type = "_js"
if ($("script[data-template-name='"+type+"']").length === 0) {
$(template).appendTo("#red-ui-editor-node-configs");
}
RED.view.state(RED.state.EDITING);
var expressionEditor;
var changeTimer;
@ -59,8 +62,8 @@
expressionEditor.resize();
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
var trayBody = tray.find('.red-ui-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form',type,'editor');
expressionEditor = RED.editor.createEditor({
id: 'node-input-js',
mode: options.mode || 'ace/mode/javascript',
@ -96,7 +99,6 @@
RED.tray.show(trayOptions);
}
}
$(template).appendTo(document.body);
RED.editor.registerTypeEditor("_js", definition);
})();

View File

@ -16,13 +16,428 @@
(function() {
var template = '<script type="text/x-red" data-template-name="_json"><div class="form-row" style="margin-bottom: 3px; text-align: right;"><button id="node-input-json-reformat" class="editor-button editor-button-small"><span data-i18n="jsonEditor.format"></span></button></div><div class="form-row node-text-editor-row"><div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-json"></div></div></script>';
// var template = '<script type="text/x-red" data-template-name="_json"></script>';
var template = '<script type="text/x-red" data-template-name="_json">'+
'<ul id="red-ui-editor-type-json-tabs"></ul>'+
'<div id="red-ui-editor-type-json-tab-raw" class="red-ui-editor-type-json-tab-content hide">'+
'<div class="form-row" style="margin-bottom: 3px; text-align: right;">'+
'<button id="node-input-json-reformat" class="red-ui-button red-ui-button-small"><span data-i18n="jsonEditor.format"></span></button>'+
'</div>'+
'<div class="form-row node-text-editor-row">'+
'<div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-json"></div>'+
'</div>'+
'</div>'+
'<div id="red-ui-editor-type-json-tab-ui" class="red-ui-editor-type-json-tab-content hide">'+
'<div id="red-ui-editor-type-json-tab-ui-container"></div>'+
'</div>'+
'</script>';
var activeTab;
function insertNewItem(parent,index,copyIndex) {
var newValue = "";
if (parent.children.length > 0) {
switch (parent.children[Math.max(0,Math.min(parent.children.length-1,copyIndex))].type) {
case 'string': newValue = ""; break;
case 'number': newValue = 0; break;
case 'boolean': newValue = true; break;
case 'null': newValue = null; break;
case 'object': newValue = {}; break;
case 'array': newValue = []; break;
}
}
var newKey;
if (parent.type === 'array') {
newKey = parent.children.length;
} else {
var usedKeys = {};
parent.children.forEach(function(child) { usedKeys[child.key] = true })
var keyRoot = "item";
var keySuffix = 2;
newKey = keyRoot;
while(usedKeys[newKey]) {
newKey = keyRoot+"-"+(keySuffix++);
}
}
var newItem = handleItem(newKey,newValue,parent.depth+1,parent);
parent.treeList.insertChildAt(newItem, index, true);
parent.treeList.expand();
}
function showObjectMenu(button,item) {
var elementPos = button.offset();
var options = [];
if (item.parent) {
options.push({id:"red-ui-editor-type-json-menu-insert-above", icon:"fa fa-toggle-up", label:RED._('jsonEditor.insertAbove'),onselect:function(){
var index = item.parent.children.indexOf(item);
insertNewItem(item.parent,index,index);
}});
options.push({id:"red-ui-editor-type-json-menu-insert-below", icon:"fa fa-toggle-down", label:RED._('jsonEditor.insertBelow'),onselect:function(){
var index = item.parent.children.indexOf(item)+1;
insertNewItem(item.parent,index,index-1);
}});
}
if (item.type === 'array' || item.type === 'object') {
options.push({id:"red-ui-editor-type-json-menu-add-child", icon:"fa fa-plus", label:RED._('jsonEditor.addItem'),onselect:function(){
insertNewItem(item,item.children.length,item.children.length-1);
}});
}
if (item.parent) {
options.push({id:"red-ui-editor-type-json-menu-copy-path", icon:"fa fa-terminal", label:RED._('jsonEditor.copyPath'),onselect:function(){
var i = item;
var path = "";
var newPath;
while(i.parent) {
if (i.parent.type === "array") {
newPath = "["+i.key+"]";
} else {
if (/^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(i.key)) {
newPath = i.key;
} else {
newPath = "[\""+i.key.replace(/"/,"\\\"")+"\"]"
}
}
path = newPath+(path.length>0 && path[0] !== "["?".":"")+path;
i = i.parent;
}
RED.clipboard.copyText(path,item.element,"clipboard.copyMessagePath");
}});
options.push({id:"red-ui-editor-type-json-menu-duplicate", icon:"fa fa-copy", label:RED._("jsonEditor.duplicate"),onselect:function(){
var newKey = item.key;
if (item.parent.type === 'array') {
newKey = parent.children.length;
} else {
var m = /^(.*?)(-(\d+))?$/.exec(newKey);
var usedKeys = {};
item.parent.children.forEach(function(child) { usedKeys[child.key] = true })
var keyRoot = m[1];
var keySuffix = 2;
if (m[3] !== undefined) {
keySuffix = parseInt(m[3]);
}
newKey = keyRoot;
while(usedKeys[newKey]) {
newKey = keyRoot+"-"+(keySuffix++);
}
}
var newItem = handleItem(newKey,convertToObject(item),item.parent.depth+1,item.parent);
var index = item.parent.children.indexOf(item)+1;
item.parent.treeList.insertChildAt(newItem, index, true);
item.parent.treeList.expand();
}});
options.push({id:"red-ui-editor-type-json-menu-delete", icon:"fa fa-times", label:RED._('common.label.delete'),onselect:function(){
item.treeList.remove();
}});
}
if (item.type === 'array' || item.type === 'object') {
options.push(null)
options.push({id:"red-ui-editor-type-json-menu-expand-children",icon:"fa fa-angle-double-down", label:RED._('jsonEditor.expandItems'),onselect:function(){
item.treeList.expand();
item.children.forEach(function(child) {
child.treeList.expand();
})
}});
options.push({id:"red-ui-editor-type-json-menu-collapse-children",icon:"fa fa-angle-double-up", label:RED._('jsonEditor.collapseItems'),onselect:function(){
item.children.forEach(function(child) {
child.treeList.collapse();
})
}});
}
var menuOptionMenu = RED.menu.init({
id:"red-ui-editor-type-json-menu",
options: options
});
menuOptionMenu.css({
position: "absolute"
})
menuOptionMenu.on('mouseleave', function(){ $(this).hide() });
menuOptionMenu.on('mouseup', function() { $(this).hide() });
menuOptionMenu.appendTo("body");
var top = elementPos.top;
var height = menuOptionMenu.height();
var winHeight = $(window).height();
if (top+height > winHeight) {
top -= (top+height)-winHeight + 20;
}
menuOptionMenu.css({
top: top+"px",
left: elementPos.left+"px"
})
menuOptionMenu.show();
}
function parseObject(obj,depth,parent) {
var result = [];
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
result.push(handleItem(prop,obj[prop],depth,parent));
}
}
return result;
}
function parseArray(obj,depth,parent) {
var result = [];
var l = obj.length;
for (var i=0;i<l;i++) {
result.push(handleItem(i,obj[i],depth,parent));
}
return result;
}
function handleItem(key,val,depth,parent) {
var item = {depth:depth, type: typeof val};
var container = $('<span class="red-ui-editor-type-json-editor-label">');
if (key != null) {
item.key = key;
var keyText;
if (typeof key === 'string') {
keyText = '"'+key+'"';
} else {
keyText = key;
}
var keyLabel = $('<span class="red-ui-debug-msg-object-key red-ui-editor-type-json-editor-label-key">').text(keyText).appendTo(container);
keyLabel.addClass('red-ui-debug-msg-type-'+(typeof key));
if (parent && parent.type === "array") {
keyLabel.addClass("red-ui-editor-type-json-editor-label-array-key")
}
keyLabel.on("click", function(evt) {
if (item.parent.type === 'array') {
return;
}
evt.preventDefault();
evt.stopPropagation();
var w = Math.max(150,keyLabel.width());
var keyInput = $('<input type="text" class="red-ui-editor-type-json-editor-key">').css({width:w+"px"}).val(""+item.key).insertAfter(keyLabel).typedInput({types:['str']});
$(document).on("mousedown.nr-ui-json-editor", function(evt) {
var typedInputElement = keyInput.next(".red-ui-typedInput-container")[0];
var target = evt.target;
while (target.nodeName !== 'BODY' && target !== typedInputElement && !$(target).hasClass("red-ui-typedInput-options")) {
target = target.parentElement;
}
if (target.nodeName === 'BODY') {
var newKey = keyInput.typedInput("value");
item.key = newKey;
var keyText;
if (typeof newKey === 'string') {
keyText = '"'+newKey+'"';
} else {
keyText = newKey;
}
keyLabel.text(keyText);
keyInput.remove();
keyLabel.show();
$(document).off("mousedown.nr-ui-json-editor");
$(document).off("keydown.nr-ui-json-editor");
}
});
$(document).on("keydown.nr-ui-json-editor",function(evt) {
if (evt.keyCode === 27) {
// Escape
keyInput.remove();
keyLabel.show();
$(document).off("mousedown.nr-ui-json-editor");
$(document).off("keydown.nr-ui-json-editor");
}
});
keyLabel.hide();
});
$('<span>').text(" : ").appendTo(container);
}
if (Array.isArray(val)) {
item.expanded = depth < 2;
item.type = "array";
item.deferBuild = depth >= 2;
item.children = parseArray(val,depth+1,item);
} else if (val !== null && item.type === "object") {
item.expanded = depth < 2;
item.children = parseObject(val,depth+1,item);
item.deferBuild = depth >= 2;
} else {
item.value = val;
if (val === null) {
item.type = 'null'
}
}
var valType;
var valValue = "";
var valClass;
switch(item.type) {
case 'string': valType = 'str'; valValue = '"'+item.value+'"'; valClass = "red-ui-debug-msg-type-string"; break;
case 'number': valType = 'num'; valValue = item.value; valClass = "red-ui-debug-msg-type-number";break;
case 'boolean': valType = 'bool'; valValue = item.value; valClass = "red-ui-debug-msg-type-other";break;
case 'null': valType = item.type; valValue = item.type; valClass = "red-ui-debug-msg-type-null";break;
case 'object':
valType = item.type;
valValue = item.type;//+"{"+item.children.length+"}";
valClass = "red-ui-debug-msg-type-meta";
break;
case 'array':
valType = item.type;
valValue = item.type+"["+item.children.length+"]";
valClass = "red-ui-debug-msg-type-meta";
break;
}
//
var orphanedChildren;
var valueLabel = $('<span class="red-ui-editor-type-json-editor-label-value">').addClass(valClass).text(valValue).appendTo(container);
valueLabel.on("click", function(evt) {
evt.preventDefault();
evt.stopPropagation();
if (valType === 'str') {
valValue = valValue.substring(1,valValue.length-1);
} else if (valType === 'array') {
valValue = "";
} else if (valType === 'object') {
valValue = "";
}
var w = Math.max(150,valueLabel.width());
var val = $('<input type="text" class="red-ui-editor-type-json-editor-value">').css({width:w+"px"}).val(""+valValue).insertAfter(valueLabel).typedInput({
types:[
'str','num','bool',
{value:"null",label:"null",hasValue:false},
{value:"array",label:"array",hasValue:false},
{value:"object",label:"object",hasValue:false}
],
default: valType
});
$(document).on("mousedown.nr-ui-json-editor", function(evt) {
var typedInputElement = val.next(".red-ui-typedInput-container")[0];
var target = evt.target;
while (target.nodeName !== 'BODY' && target !== typedInputElement && !$(target).hasClass("red-ui-typedInput-options")) {
target = target.parentElement;
}
if (target.nodeName === 'BODY') {
valType = val.typedInput("type");
valValue = val.typedInput("value");
if (valType === 'num') {
valValue = valValue.trim();
if (isNaN(valValue)) {
valType = 'str';
} else if (valValue === "") {
valValue = 0;
}
}
item.value = valValue;
var valClass;
switch(valType) {
case 'str': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "string"; valClass = "red-ui-debug-msg-type-string"; valValue = '"'+valValue+'"'; break;
case 'num': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "number"; valClass = "red-ui-debug-msg-type-number"; break;
case 'bool': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "boolean"; valClass = "red-ui-debug-msg-type-other"; item.value = (valValue === "true"); break;
case 'null': item.children && (orphanedChildren = item.children); item.treeList.makeLeaf(true); item.type = "null"; valClass = "red-ui-debug-msg-type-null"; item.value = valValue = "null"; break;
case 'object':
item.treeList.makeParent(orphanedChildren);
item.type = "object";
valClass = "red-ui-debug-msg-type-meta";
item.value = valValue = "object";
item.children.forEach(function(child,i) {
if (child.hasOwnProperty('_key')) {
child.key = child._key;
delete child._key;
var keyText;
var keyLabel = child.element.find(".red-ui-editor-type-json-editor-label-key");
keyLabel.removeClass("red-ui-editor-type-json-editor-label-array-key");
if (typeof child.key === 'string') {
keyText = '"'+child.key+'"';
keyLabel.addClass('red-ui-debug-msg-type-string');
keyLabel.removeClass('red-ui-debug-msg-type-number');
} else {
keyText = child.key;
keyLabel.removeClass('red-ui-debug-msg-type-string');
keyLabel.addClass('red-ui-debug-msg-type-number');
}
keyLabel.text(keyText);
}
})
break;
case 'array':
item.treeList.makeParent(orphanedChildren);
item.type = "array";
valClass = "red-ui-debug-msg-type-meta";
item.value = valValue = "array["+(item.children.length)+"]";
item.children.forEach(function(child,i) {
child._key = child.key;
child.key = i;
child.element.find(".red-ui-editor-type-json-editor-label-key")
.addClass("red-ui-editor-type-json-editor-label-array-key")
.text(""+child.key)
.removeClass('red-ui-debug-msg-type-string')
.addClass('red-ui-debug-msg-type-number');
})
break;
}
valueLabel.text(valValue).removeClass().addClass("red-ui-editor-type-json-editor-label-value "+valClass);
val.remove();
valueLabel.show();
$(document).off("mousedown.nr-ui-json-editor");
$(document).off("keydown.nr-ui-json-editor");
}
})
$(document).on("keydown.nr-ui-json-editor",function(evt) {
if (evt.keyCode === 27) {
// Escape
val.remove();
valueLabel.show();
if (valType === 'str') {
valValue = '"'+valValue+'"';
}
$(document).off("mousedown.nr-ui-json-editor");
$(document).off("keydown.nr-ui-json-editor");
}
});
valueLabel.hide();
})
item.gutter = $('<span class="red-ui-editor-type-json-editor-item-gutter"></span>');
if (parent) {//red-ui-editor-type-json-editor-item-handle
$('<span class="red-ui-editor-type-json-editor-item-handle"><i class="fa fa-bars"></span>').appendTo(item.gutter);
} else {
$('<span></span>').appendTo(item.gutter);
}
$('<button type="button" class="editor-button editor-button-small"><i class="fa fa-caret-down"></button>').appendTo(item.gutter).on("click", function(evt) {
evt.preventDefault();
evt.stopPropagation();
showObjectMenu($(this), item);
});
item.element = container;
return item;
}
function convertToObject(item) {
var element;
switch (item.type) {
case 'string': element = item.value; break;
case 'number': element = Number(item.value); break;
case 'boolean': element = item.value; break;
case 'null': element = null; break;
case 'object':
element = {};
item.children.forEach(function(child) {
element[child.key] = convertToObject(child);
})
break;
case 'array':
element = item.children.map(function(child) {
return convertToObject(child);
})
break;
}
return element;
}
var definition = {
show: function(options) {
var value = options.value;
var onComplete = options.complete;
var type = "_json"
if ($("script[data-template-name='"+type+"']").length === 0) {
$(template).appendTo("#red-ui-editor-node-configs");
}
RED.view.state(RED.state.EDITING);
var expressionEditor;
var changeTimer;
@ -38,9 +453,11 @@
return false;
}
}
var rootNode;
var trayOptions = {
title: options.title,
width: "inherit",
width: options.width||700,
buttons: [
{
id: "node-dialog-cancel",
@ -57,25 +474,60 @@
if (options.requireValid && !checkValid()) {
return;
}
onComplete(expressionEditor.getValue());
var result;
if (activeTab === "json-ui") {
if (rootNode) {
result = JSON.stringify(convertToObject(rootNode),null,4);
} else {
result = expressionEditor.getValue();
}
} else if (activeTab === "json-raw") {
result = expressionEditor.getValue();
}
onComplete && onComplete(result);
RED.tray.close();
}
}
],
resize: function(dimensions) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var editorRow = $("#dialog-form>div.node-text-editor-row");
var height = $("#dialog-form").height();
for (var i=0;i<rows.size();i++) {
height -= $(rows[i]).outerHeight(true);
}
height -= (parseInt($("#dialog-form").css("marginTop"))+parseInt($("#dialog-form").css("marginBottom")));
$(".node-text-editor").css("height",height+"px");
var height = $(".red-ui-editor-type-json-tab-content").height();
$(".node-text-editor").css("height",(height-45)+"px");
expressionEditor.resize();
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
var trayBody = tray.find('.red-ui-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form',type,'editor');
var container = $("#red-ui-editor-type-json-tab-ui-container").css({"height":"100%"});
var filterDepth = Infinity;
var list = $('<div class="red-ui-debug-msg-payload red-ui-editor-type-json-editor">').appendTo(container).treeList({
rootSortable: false,
sortable: ".red-ui-editor-type-json-editor-item-handle",
}).on("treelistchangeparent", function(event, evt) {
if (evt.old.type === 'array') {
evt.old.element.find(".red-ui-editor-type-json-editor-label-type").text("array["+evt.old.children.length+"]");
}
if (evt.item.parent.type === 'array') {
evt.item.parent.element.find(".red-ui-editor-type-json-editor-label-type").text("array["+evt.item.parent.children.length+"]");
}
}).on("treelistsort", function(event, item) {
item.children.forEach(function(child,i) {
if (item.type === 'array') {
child.key = i;
child.element.find(".red-ui-editor-type-json-editor-label-key")
.text(child.key)
.removeClass('red-ui-debug-msg-type-string')
.addClass('red-ui-debug-msg-type-number');
} else {
child.element.find(".red-ui-editor-type-json-editor-label-key")
.text('"'+child.key+'"')
.removeClass('red-ui-debug-msg-type-number')
.addClass('red-ui-debug-msg-type-string');
}
})
});
expressionEditor = RED.editor.createEditor({
id: 'node-input-json',
value: "",
@ -89,7 +541,7 @@
});
checkValid();
}
$("#node-input-json-reformat").click(function(evt) {
$("#node-input-json-reformat").on("click", function(evt) {
evt.preventDefault();
var v = expressionEditor.getValue()||"";
try {
@ -100,9 +552,56 @@
expressionEditor.getSession().setValue(v||"",-1);
});
dialogForm.i18n();
var finishedBuild = false;
var tabs = RED.tabs.create({
element: $("#red-ui-editor-type-json-tabs"),
onchange:function(tab) {
activeTab = tab.id;
$(".red-ui-editor-type-json-tab-content").hide();
if (finishedBuild) {
if (tab.id === "json-raw") {
if (rootNode) {
var result = JSON.stringify(convertToObject(rootNode),null,4);
expressionEditor.getSession().setValue(result||"",-1);
}
} else if (tab.id === "json-ui") {
var raw = expressionEditor.getValue().trim() ||"{}";
try {
var parsed = JSON.parse(raw);
rootNode = handleItem(null,parsed,0,null);
rootNode.class = "red-ui-editor-type-json-root-node"
list.treeList('data',[rootNode]);
} catch(err) {
rootNode = null;
list.treeList('data',[{
label: "Invalid JSON: "+err.toString()
}]);
}
}
}
tab.content.show();
trayOptions.resize();
}
})
tabs.addTab({
id: 'json-raw',
label: RED._('jsonEditor.rawMode'),
content: $("#red-ui-editor-type-json-tab-raw")
});
tabs.addTab({
id: 'json-ui',
label: RED._('jsonEditor.uiMode'),
content: $("#red-ui-editor-type-json-tab-ui")
});
finishedBuild = true;
},
close: function() {
expressionEditor.destroy();
// expressionEditor.destroy();
if (options.onclose) {
options.onclose();
}
@ -112,6 +611,5 @@
RED.tray.show(trayOptions);
}
}
$(template).appendTo(document.body);
RED.editor.registerTypeEditor("_json", definition);
})();

View File

@ -17,34 +17,34 @@
var toolbarTemplate = '<div style="margin-bottom: 5px">'+
'<span class="button-group">'+
'<button type="button" class="editor-button" data-style="h1" style="font-size:1.1em; font-weight: bold">h1</button>'+
'<button type="button" class="editor-button" data-style="h2" style="font-size:1.0em; font-weight: bold">h2</button>'+
'<button type="button" class="editor-button" data-style="h3" style="font-size:0.9em; font-weight: bold">h3</button>'+
'<button type="button" class="red-ui-button" data-style="h1" style="font-size:1.1em; font-weight: bold">h1</button>'+
'<button type="button" class="red-ui-button" data-style="h2" style="font-size:1.0em; font-weight: bold">h2</button>'+
'<button type="button" class="red-ui-button" data-style="h3" style="font-size:0.9em; font-weight: bold">h3</button>'+
'</span>'+
'<span class="button-group">'+
'<button type="button" class="editor-button" data-style="b"><i class="fa fa-bold"></i></button>'+
'<button type="button" class="editor-button" data-style="i"><i class="fa fa-italic"></i></button>'+
'<button type="button" class="editor-button" data-style="code"><i class="fa fa-code"></i></button>'+
'<button type="button" class="red-ui-button" data-style="b"><i class="fa fa-bold"></i></button>'+
'<button type="button" class="red-ui-button" data-style="i"><i class="fa fa-italic"></i></button>'+
'<button type="button" class="red-ui-button" data-style="code"><i class="fa fa-code"></i></button>'+
'</span>'+
'<span class="button-group">'+
'<button type="button" class="editor-button" data-style="ol"><i class="fa fa-list-ol"></i></button>'+
'<button type="button" class="editor-button" data-style="ul"><i class="fa fa-list-ul"></i></button>'+
'<button type="button" class="editor-button" data-style="bq"><i class="fa fa-quote-left"></i></button>'+
'<button type="button" class="editor-button" data-style="hr"><i class="fa fa-minus"></i></button>'+
'<button type="button" class="editor-button" data-style="link"><i class="fa fa-link"></i></button>'+
'<button type="button" class="red-ui-button" data-style="ol"><i class="fa fa-list-ol"></i></button>'+
'<button type="button" class="red-ui-button" data-style="ul"><i class="fa fa-list-ul"></i></button>'+
'<button type="button" class="red-ui-button" data-style="bq"><i class="fa fa-quote-left"></i></button>'+
'<button type="button" class="red-ui-button" data-style="hr"><i class="fa fa-minus"></i></button>'+
'<button type="button" class="red-ui-button" data-style="link"><i class="fa fa-link"></i></button>'+
'</span>'
'</div>';
var template = '<script type="text/x-red" data-template-name="_markdown">'+
'<div id="node-input-markdown-panels">'+
'<div id="node-input-markdown-panel-editor" class="red-ui-panel">'+
'<div id="red-ui-editor-type-markdown-panels">'+
'<div id="red-ui-editor-type-markdown-panel-editor" class="red-ui-panel">'+
'<div style="height: 100%; margin: auto; max-width: 1000px;">'+
'<div id="node-input-markdown-toolbar"></div>'+
'<div class="node-text-editor" style="height: 100%" id="node-input-markdown"></div>'+
'<div id="red-ui-editor-type-markdown-toolbar"></div>'+
'<div class="node-text-editor" style="height: 100%" id="red-ui-editor-type-markdown"></div>'+
'</div>'+
'</div>'+
'<div class="red-ui-panel">'+
'<div class="node-input-markdown-panel-preview node-help"></div>'+
'<div class="red-ui-editor-type-markdown-panel-preview red-ui-help"></div>'+
'</div>'+
'</script>';
@ -56,6 +56,11 @@
var value = options.value;
var onComplete = options.complete;
var type = "_markdown"
if ($("script[data-template-name='"+type+"']").length === 0) {
$(template).appendTo("#red-ui-editor-node-configs");
}
RED.view.state(RED.state.EDITING);
var expressionEditor;
@ -88,11 +93,11 @@
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
trayBody.addClass("node-input-markdown-editor")
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
var trayBody = tray.find('.red-ui-tray-body');
trayBody.addClass("red-ui-editor-type-markdown-editor")
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form',type,'editor');
expressionEditor = RED.editor.createEditor({
id: 'node-input-markdown',
id: 'red-ui-editor-type-markdown',
value: value,
mode:"ace/mode/markdown",
expandable: false
@ -101,20 +106,20 @@
expressionEditor.getSession().on("change", function() {
clearTimeout(changeTimer);
changeTimer = setTimeout(function() {
var currentScrollTop = $(".node-input-markdown-panel-preview").scrollTop();
$(".node-input-markdown-panel-preview").html(marked(expressionEditor.getValue()));
$(".node-input-markdown-panel-preview").scrollTop(currentScrollTop);
var currentScrollTop = $(".red-ui-editor-type-markdown-panel-preview").scrollTop();
$(".red-ui-editor-type-markdown-panel-preview").html(marked(expressionEditor.getValue()));
$(".red-ui-editor-type-markdown-panel-preview").scrollTop(currentScrollTop);
},200);
})
if (options.header) {
options.header.appendTo(tray.find('#node-input-markdown-title'));
options.header.appendTo(tray.find('#red-ui-editor-type-markdown-title'));
}
if (value) {
$(".node-input-markdown-panel-preview").html(marked(expressionEditor.getValue()));
$(".red-ui-editor-type-markdown-panel-preview").html(marked(expressionEditor.getValue()));
}
panels = RED.panels.create({
id:"node-input-markdown-panels",
id:"red-ui-editor-type-markdown-panels",
dir: "horizontal",
resize: function(p1Width,p2Width) {
expressionEditor.resize();
@ -123,10 +128,10 @@
panels.ratio(1);
$('<span class="button-group" style="float:right">'+
'<button type="button" id="node-btn-markdown-preview" class="editor-button toggle single"><i class="fa fa-eye"></i></button>'+
'<button type="button" id="node-btn-markdown-preview" class="red-ui-button toggle single"><i class="fa fa-eye"></i></button>'+
'</span>').appendTo(expressionEditor.toolbar);
$("#node-btn-markdown-preview").click(function(e) {
$("#node-btn-markdown-preview").on("click", function(e) {
e.preventDefault();
if ($(this).hasClass("selected")) {
$(this).removeClass("selected");
@ -172,7 +177,7 @@
var toolbar = $(toolbarTemplate).appendTo(container);
toolbar.find('button[data-style]').each(function(el) {
var style = styleActions[$(this).data('style')];
$(this).click(function(e) {
$(this).on("click", function(e) {
e.preventDefault();
var current = editor.getSelectedText();
var range = editor.selection.getRange();
@ -207,6 +212,5 @@
return toolbar;
}
}
$(template).appendTo(document.body);
RED.editor.registerTypeEditor("_markdown", definition);
})();

View File

@ -0,0 +1,90 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* 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.
**/
(function() {
var template = '<script type="text/x-red" data-template-name="_text"><div class="form-row node-text-editor-row"><div style="height: 200px;min-height: 150px;" class="node-text-editor" id="node-input-text"></div></div></script>';
var definition = {
show: function(options) {
var value = options.value;
var onComplete = options.complete;
var type = "_text"
if ($("script[data-template-name='"+type+"']").length === 0) {
$(template).appendTo("#red-ui-editor-node-configs");
}
RED.view.state(RED.state.EDITING);
var expressionEditor;
var changeTimer;
var trayOptions = {
title: options.title,
width: options.width||"inherit",
buttons: [
{
id: "node-dialog-cancel",
text: RED._("common.label.cancel"),
click: function() {
RED.tray.close();
}
},
{
id: "node-dialog-ok",
text: RED._("common.label.done"),
class: "primary",
click: function() {
onComplete(expressionEditor.getValue(),expressionEditor.getCursorPosition());
RED.tray.close();
}
}
],
resize: function(dimensions) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var editorRow = $("#dialog-form>div.node-text-editor-row");
var height = $("#dialog-form").height();
// for (var i=0;i<rows.size();i++) {
// height -= $(rows[i]).outerHeight(true);
// }
// height -= (parseInt($("#dialog-form").css("marginTop"))+parseInt($("#dialog-form").css("marginBottom")));
$(".node-text-editor").css("height",height+"px");
expressionEditor.resize();
},
open: function(tray) {
var trayBody = tray.find('.red-ui-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form',type,'editor');
expressionEditor = RED.editor.createEditor({
id: 'node-input-text',
value: "",
mode:"ace/mode/"+(options.mode||"text")
});
expressionEditor.getSession().setValue(value||"",-1);
if (options.cursor) {
expressionEditor.gotoLine(options.cursor.row+1,options.cursor.column,false);
}
},
close: function() {
expressionEditor.destroy();
if (options.onclose) {
options.onclose();
}
},
show: function() {}
}
RED.tray.show(trayOptions);
}
}
RED.editor.registerTypeEditor("_text", definition);
})();

View File

@ -15,7 +15,7 @@
**/
RED.eventLog = (function() {
var template = '<script type="text/x-red" data-template-name="_eventLog"><div class="form-row node-text-editor-row"><div style="height: 100%;min-height: 150px;" class="node-text-editor" id="event-log-editor"></div></div></script>';
var template = '<script type="text/x-red" data-template-name="_eventLog"><div class="form-row node-text-editor-row"><div style="height: 100%;min-height: 150px;" class="node-text-editor" id="red-ui-event-log-editor"></div></div></script>';
var eventLogEditor;
var backlog = [];
@ -36,7 +36,7 @@ RED.eventLog = (function() {
}
return {
init: function() {
$(template).appendTo(document.body);
$(template).appendTo("#red-ui-editor-node-configs");
RED.actions.add("core:show-event-log",RED.eventLog.show);
},
show: function() {
@ -70,10 +70,10 @@ RED.eventLog = (function() {
eventLogEditor.resize();
},
open: function(tray) {
var trayBody = tray.find('.editor-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.editor-tray-body'),'dialog-form',type,'editor');
var trayBody = tray.find('.red-ui-tray-body');
var dialogForm = RED.editor.buildEditForm(tray.find('.red-ui-tray-body'),'dialog-form',type,'editor');
eventLogEditor = RED.editor.createEditor({
id: 'event-log-editor',
id: 'red-ui-event-log-editor',
value: backlog.join("\n"),
lineNumbers: false,
readOnly: true,

View File

@ -19,7 +19,7 @@ RED.keyboard = (function() {
var handlers = {};
var partialState;
RED.h = handlers;
var keyMap = {
"left":37,
"up":38,
@ -94,10 +94,14 @@ RED.h = handlers;
}
}
for (var action in userKeymap) {
if (userKeymap.hasOwnProperty(action)) {
if (userKeymap.hasOwnProperty(action) && userKeymap[action]) {
var obj = userKeymap[action];
if (obj.hasOwnProperty('key')) {
addHandler(obj.scope, obj.key, action, true);
var scope = obj.scope;
if (scope === "workspace") {
scope = "red-ui-workspace";
}
addHandler(scope, obj.key, action, true);
}
}
}
@ -109,7 +113,7 @@ RED.h = handlers;
get: getSettingsPane,
focus: function() {
setTimeout(function() {
$("#user-settings-tab-keyboard-filter").focus();
$("#red-ui-settings-tab-keyboard-filter").trigger("focus");
},200);
}
})
@ -391,19 +395,22 @@ RED.h = handlers;
$(this).toggleClass("input-error",!valid);
})
var scopeSelect = $('<select><option value="*" data-i18n="keyboard.global"></option><option value="workspace" data-i18n="keyboard.workspace"></option></select>').appendTo(scope);
var scopeSelect = $('<select><option value="*" data-i18n="keyboard.global"></option><option value="red-ui-workspace" data-i18n="keyboard.workspace"></option></select>').appendTo(scope);
scopeSelect.i18n();
if (object.scope === "workspace") {
object.scope = "red-ui-workspace";
}
scopeSelect.val(object.scope||'*');
var div = $('<div class="keyboard-shortcut-edit button-group-vertical"></div>').appendTo(scope);
var okButton = $('<button class="editor-button editor-button-small"><i class="fa fa-check"></i></button>').appendTo(div);
var revertButton = $('<button class="editor-button editor-button-small"><i class="fa fa-reply"></i></button>').appendTo(div);
var okButton = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-check"></i></button>').appendTo(div);
var revertButton = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-reply"></i></button>').appendTo(div);
okButton.click(function(e) {
okButton.on("click", function(e) {
e.stopPropagation();
endEditShortcut();
});
revertButton.click(function(e) {
revertButton.on("click", function(e) {
e.stopPropagation();
RED.keyboard.revertToDefault(object.id);
container.empty();
@ -426,7 +433,7 @@ RED.h = handlers;
buildShortcutRow(container,obj);
})
keyInput.focus();
keyInput.trigger("focus");
}
}
@ -510,14 +517,14 @@ RED.h = handlers;
var scope = $('<div class="keyboard-shortcut-entry-scope">').appendTo(item);
$("<span>").text(object.scope === '*'?'global':object.scope||"").appendTo(scope);
container.click(editShortcut);
container.on("click", editShortcut);
}
function getSettingsPane() {
var pane = $('<div id="user-settings-tab-keyboard"></div>');
var pane = $('<div id="red-ui-settings-tab-keyboard"></div>');
$('<div class="keyboard-shortcut-entry keyboard-shortcut-list-header">'+
'<div class="keyboard-shortcut-entry-key keyboard-shortcut-entry-text"><input id="user-settings-tab-keyboard-filter" type="text" data-i18n="[placeholder]keyboard.filterActions"></div>'+
'<div class="keyboard-shortcut-entry-key keyboard-shortcut-entry-text"><input id="red-ui-settings-tab-keyboard-filter" type="text" data-i18n="[placeholder]keyboard.filterActions"></div>'+
'<div class="keyboard-shortcut-entry-key" data-i18n="keyboard.shortcut"></div>'+
'<div class="keyboard-shortcut-entry-scope" data-i18n="keyboard.scope"></div>'+
'</div>').appendTo(pane);

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@ RED.notifications = (function() {
var myNotification = RED.notify("This is the message to display",{
modal: true,
fixed: true,
type: 'warning',
type: 'warning', // 'compact', 'success', 'warning', 'error'
buttons: [
{
text: "cancel",
@ -62,7 +62,7 @@ RED.notifications = (function() {
}
if (options.modal) {
$("#full-shade").show();
$("#red-ui-full-shade").show();
}
if (currentNotifications.length > 4) {
@ -77,14 +77,14 @@ RED.notifications = (function() {
}
}
var n = document.createElement("div");
n.id="red-notification-"+c;
n.className = "notification";
n.id="red-ui-notification-"+c;
n.className = "red-ui-notification";
n.fixed = fixed;
if (type) {
n.className = "notification notification-"+type;
n.className = "red-ui-notification red-ui-notification-"+type;
}
if (options.width) {
var parentWidth = $("#notifications").width();
var parentWidth = $("#red-ui-notifications").width();
if (options.width > parentWidth) {
var margin = -(options.width-parentWidth)/2;
$(n).css({
@ -103,9 +103,9 @@ RED.notifications = (function() {
$(n).append(msg);
}
if (options.buttons) {
var buttonSet = $('<div style="margin-top: 20px;" class="ui-dialog-buttonset"></div>').appendTo(n)
var buttonSet = $('<div class="ui-dialog-buttonset"></div>').appendTo(n)
options.buttons.forEach(function(buttonDef) {
var b = $('<button>').html(buttonDef.text).click(buttonDef.click).appendTo(buttonSet);
var b = $('<button>').html(buttonDef.text).on("click", buttonDef.click).appendTo(buttonSet);
if (buttonDef.id) {
b.attr('id',buttonDef.id);
}
@ -116,7 +116,7 @@ RED.notifications = (function() {
}
$("#notifications").append(n);
$("#red-ui-notifications").append(n);
if (!RED.notifications.hide) {
$(n).slideDown(300);
}
@ -142,7 +142,7 @@ RED.notifications = (function() {
nn.parentNode.removeChild(nn);
}
if (options.modal) {
$("#full-shade").hide();
$("#red-ui-full-shade").hide();
}
};
})();
@ -192,7 +192,7 @@ RED.notifications = (function() {
if (options.buttons) {
var buttonSet = $('<div style="margin-top: 20px;" class="ui-dialog-buttonset"></div>').appendTo(nn)
options.buttons.forEach(function(buttonDef) {
var b = $('<button>').text(buttonDef.text).click(buttonDef.click).appendTo(buttonSet);
var b = $('<button>').text(buttonDef.text).on("click", buttonDef.click).appendTo(buttonSet);
if (buttonDef.id) {
b.attr('id',buttonDef.id);
}
@ -211,9 +211,9 @@ RED.notifications = (function() {
if (nn.hidden) {
nn.showNotification();
} else if (!options || !options.silent){
$(nn).addClass("notification-shake-horizontal");
$(nn).addClass("red-ui-notification-shake-horizontal");
setTimeout(function() {
$(nn).removeClass("notification-shake-horizontal");
$(nn).removeClass("red-ui-notification-shake-horizontal");
},300);
}
@ -221,7 +221,7 @@ RED.notifications = (function() {
})();
if (!fixed) {
$(n).click((function() {
$(n).on("click", (function() {
var nn = n;
return function() {
nn.close();
@ -263,14 +263,14 @@ RED.notifications = (function() {
return {
init: function() {
notificationButtonWrapper = $('<li>'+
'<a id="btn-notifications" class="button" href="#">'+
'<i class="fa fa-warning"></i>'+
'</a>'+
'</li>').prependTo(".header-toolbar").hide();
$('#btn-notifications').click(function() {
showPersistent();
})
$('<div id="red-ui-notifications"></div>').appendTo("#red-ui-editor");
notificationButtonWrapper = $('<li></li>').prependTo(".red-ui-header-toolbar").hide();
$('<a class="button" href="#"><i class="fa fa-warning"></i></a>')
.appendTo(notificationButtonWrapper)
.on("click", function() {
showPersistent();
})
},
notify: notify
}

View File

@ -235,12 +235,7 @@ RED.palette.editor = (function() {
if (def && def.color) {
swatch.css({background:RED.utils.getNodeColor(t,def)});
swatch.css({border: "1px solid "+getContrastingBorder(swatch.css('backgroundColor'))})
} else {
swatch.css({background:"#eee",border:"1px dashed #999"})
}
} else {
swatch.css({background:"#eee",border:"1px dashed #999"})
}
}
nodeEntries[module].setUseCount[setName] = inUseCount;
@ -257,7 +252,7 @@ RED.palette.editor = (function() {
setElements.enableButton.text(RED._('palette.editor.enable'));
}
}
setElements.setRow.toggleClass("palette-module-set-disabled",!set.enabled);
setElements.setRow.toggleClass("red-ui-palette-module-set-disabled",!set.enabled);
}
}
@ -350,7 +345,7 @@ RED.palette.editor = (function() {
catalogueLoadErrors = true;
}
if (catalogueCount > 1) {
$(".palette-module-shade-status").html(RED._('palette.editor.loading')+"<br>"+catalogueLoadStatus.length+"/"+catalogueCount);
$(".red-ui-palette-module-shade-status").html(RED._('palette.editor.loading')+"<br>"+catalogueLoadStatus.length+"/"+catalogueCount);
}
if (catalogueLoadStatus.length === catalogueCount) {
if (catalogueLoadErrors) {
@ -358,7 +353,7 @@ RED.palette.editor = (function() {
}
var delta = 250-(Date.now() - catalogueLoadStart);
setTimeout(function() {
$("#palette-module-install-shade").hide();
$("#red-ui-palette-module-install-shade").hide();
},Math.max(delta,0));
}
@ -370,15 +365,15 @@ RED.palette.editor = (function() {
loadedIndex = {};
packageList.editableList('empty');
$(".palette-module-shade-status").text(RED._('palette.editor.loading'));
$(".red-ui-palette-module-shade-status").text(RED._('palette.editor.loading'));
var catalogues = RED.settings.theme('palette.catalogues')||['https://catalogue.nodered.org/catalogue.json'];
catalogueLoadStatus = [];
catalogueLoadErrors = false;
catalogueCount = catalogues.length;
if (catalogues.length > 1) {
$(".palette-module-shade-status").html(RED._('palette.editor.loading')+"<br>0/"+catalogues.length);
$(".red-ui-palette-module-shade-status").html(RED._('palette.editor.loading')+"<br>0/"+catalogues.length);
}
$("#palette-module-install-shade").show();
$("#red-ui-palette-module-install-shade").show();
catalogueLoadStart = Date.now();
var handled = 0;
catalogues.forEach(function(catalog,index) {
@ -451,7 +446,7 @@ RED.palette.editor = (function() {
focus: function() {
editorTabs.resize();
setTimeout(function() {
filterInput.focus();
filterInput.trigger("focus");
},200);
}
})
@ -542,15 +537,15 @@ RED.palette.editor = (function() {
function createSettingsPane() {
settingsPane = $('<div id="user-settings-tab-palette"></div>');
var content = $('<div id="palette-editor">'+
'<ul id="palette-editor-tabs"></ul>'+
settingsPane = $('<div id="red-ui-settings-tab-palette"></div>');
var content = $('<div id="red-ui-palette-editor">'+
'<ul id="red-ui-palette-editor-tabs"></ul>'+
'</div>').appendTo(settingsPane);
editorTabs = RED.tabs.create({
element: settingsPane.find('#palette-editor-tabs'),
element: settingsPane.find('#red-ui-palette-editor-tabs'),
onchange:function(tab) {
content.find(".palette-editor-tab").hide();
content.find(".red-ui-palette-editor-tab").hide();
tab.content.show();
if (filterInput) {
filterInput.searchBox('value',"");
@ -560,11 +555,11 @@ RED.palette.editor = (function() {
}
if (tab.id === 'install') {
if (searchInput) {
searchInput.focus();
searchInput.trigger("focus");
}
} else {
if (filterInput) {
filterInput.focus();
filterInput.trigger("focus");
}
}
},
@ -572,7 +567,7 @@ RED.palette.editor = (function() {
});
var modulesTab = $('<div>',{class:"palette-editor-tab"}).appendTo(content);
var modulesTab = $('<div>',{class:"red-ui-palette-editor-tab"}).appendTo(content);
editorTabs.addTab({
id: 'nodes',
@ -580,7 +575,7 @@ RED.palette.editor = (function() {
content: modulesTab
})
var filterDiv = $('<div>',{class:"palette-search"}).appendTo(modulesTab);
var filterDiv = $('<div>',{class:"red-ui-palette-search"}).appendTo(modulesTab);
filterInput = $('<input type="text" data-i18n="[placeholder]palette.filter"></input>')
.appendTo(filterDiv)
.searchBox({
@ -591,7 +586,7 @@ RED.palette.editor = (function() {
});
nodeList = $('<ol>',{id:"palette-module-list", style:"position: absolute;top: 35px;bottom: 0;left: 0;right: 0px;"}).appendTo(modulesTab).editableList({
nodeList = $('<ol>',{id:"red-ui-palette-module-list", style:"position: absolute;top: 35px;bottom: 0;left: 0;right: 0px;"}).appendTo(modulesTab).editableList({
addButton: false,
scrollOnAdd: false,
sort: function(A,B) {
@ -607,22 +602,22 @@ RED.palette.editor = (function() {
addItem: function(container,i,object) {
var entry = object.info;
if (entry) {
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
var titleRow = $('<div class="palette-module-meta palette-module-name"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
var headerRow = $('<div>',{class:"red-ui-palette-module-header"}).appendTo(container);
var titleRow = $('<div class="red-ui-palette-module-meta red-ui-palette-module-name"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
$('<span>').text(entry.name).appendTo(titleRow);
var metaRow = $('<div class="palette-module-meta palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
var metaRow = $('<div class="red-ui-palette-module-meta red-ui-palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
var versionSpan = $('<span>').text(entry.version).appendTo(metaRow);
var errorRow = $('<div class="palette-module-meta palette-module-errors"><i class="fa fa-warning"></i></div>').hide().appendTo(headerRow);
var errorList = $('<ul class="palette-module-error-list"></ul>').appendTo(errorRow);
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
var setButton = $('<a href="#" class="editor-button editor-button-small palette-module-set-button"><i class="fa fa-angle-right palette-module-node-chevron"></i> </a>').appendTo(buttonRow);
var errorRow = $('<div class="red-ui-palette-module-meta red-ui-palette-module-errors"><i class="fa fa-warning"></i></div>').hide().appendTo(headerRow);
var errorList = $('<ul class="red-ui-palette-module-error-list"></ul>').appendTo(errorRow);
var buttonRow = $('<div>',{class:"red-ui-palette-module-meta"}).appendTo(headerRow);
var setButton = $('<a href="#" class="red-ui-button red-ui-button-small red-ui-palette-module-set-button"><i class="fa fa-angle-right red-ui-palette-module-node-chevron"></i> </a>').appendTo(buttonRow);
var setCount = $('<span>').appendTo(setButton);
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
var buttonGroup = $('<div>',{class:"red-ui-palette-module-button-group"}).appendTo(buttonRow);
var updateButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.update')).appendTo(buttonGroup);
var updateButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').text(RED._('palette.editor.update')).appendTo(buttonGroup);
updateButton.attr('id','up_'+Math.floor(Math.random()*1000000000));
updateButton.click(function(evt) {
updateButton.on("click", function(evt) {
evt.preventDefault();
if ($(this).hasClass('disabled')) {
return;
@ -631,19 +626,19 @@ RED.palette.editor = (function() {
})
var removeButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.remove')).appendTo(buttonGroup);
var removeButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').text(RED._('palette.editor.remove')).appendTo(buttonGroup);
removeButton.attr('id','up_'+Math.floor(Math.random()*1000000000));
removeButton.click(function(evt) {
removeButton.on("click", function(evt) {
evt.preventDefault();
remove(entry,container,function(err){});
})
if (!entry.local) {
removeButton.hide();
}
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.disableall')).appendTo(buttonGroup);
var enableButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').text(RED._('palette.editor.disableall')).appendTo(buttonGroup);
var contentRow = $('<div>',{class:"palette-module-content"}).appendTo(container);
var shade = $('<div class="palette-module-shade hide"><img src="red/images/spin.svg" class="palette-spinner"/></div>').appendTo(container);
var contentRow = $('<div>',{class:"red-ui-palette-module-content"}).appendTo(container);
var shade = $('<div class="red-ui-palette-module-shade hide"><img src="red/images/spin.svg" class="red-ui-palette-spinner"/></div>').appendTo(container);
object.elements = {
updateButton: updateButton,
@ -657,7 +652,7 @@ RED.palette.editor = (function() {
versionSpan: versionSpan,
sets: {}
}
setButton.click(function(evt) {
setButton.on("click", function(evt) {
evt.preventDefault();
if (container.hasClass('expanded')) {
container.removeClass('expanded');
@ -674,16 +669,16 @@ RED.palette.editor = (function() {
});
setList.forEach(function(setName) {
var set = entry.sets[setName];
var setRow = $('<div>',{class:"palette-module-set"}).appendTo(contentRow);
var buttonGroup = $('<div>',{class:"palette-module-set-button-group"}).appendTo(setRow);
var setRow = $('<div>',{class:"red-ui-palette-module-set"}).appendTo(contentRow);
var buttonGroup = $('<div>',{class:"red-ui-palette-module-set-button-group"}).appendTo(setRow);
var typeSwatches = {};
set.types.forEach(function(t) {
var typeDiv = $('<div>',{class:"palette-module-type"}).appendTo(setRow);
typeSwatches[t] = $('<span>',{class:"palette-module-type-swatch"}).appendTo(typeDiv);
$('<span>',{class:"palette-module-type-node"}).text(t).appendTo(typeDiv);
var typeDiv = $('<div>',{class:"red-ui-palette-module-type"}).appendTo(setRow);
typeSwatches[t] = $('<span>',{class:"red-ui-palette-module-type-swatch"}).appendTo(typeDiv);
$('<span>',{class:"red-ui-palette-module-type-node"}).text(t).appendTo(typeDiv);
})
var enableButton = $('<a href="#" class="editor-button editor-button-small"></a>').appendTo(buttonGroup);
enableButton.click(function(evt) {
var enableButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').appendTo(buttonGroup);
enableButton.on("click", function(evt) {
evt.preventDefault();
if (object.setUseCount[setName] === 0) {
var currentSet = RED.nodes.registry.getNodeSet(set.id);
@ -705,7 +700,7 @@ RED.palette.editor = (function() {
swatches: typeSwatches
};
});
enableButton.click(function(evt) {
enableButton.on("click", function(evt) {
evt.preventDefault();
if (object.totalUseCount === 0) {
changeNodeState(entry.name,(container.hasClass('disabled')),shade,function(xhr){
@ -726,7 +721,7 @@ RED.palette.editor = (function() {
var installTab = $('<div>',{class:"palette-editor-tab hide"}).appendTo(content);
var installTab = $('<div>',{class:"red-ui-palette-editor-tab hide"}).appendTo(content);
editorTabs.addTab({
id: 'install',
@ -734,9 +729,9 @@ RED.palette.editor = (function() {
content: installTab
})
var toolBar = $('<div>',{class:"palette-editor-toolbar"}).appendTo(installTab);
var toolBar = $('<div>',{class:"red-ui-palette-editor-toolbar"}).appendTo(installTab);
var searchDiv = $('<div>',{class:"palette-search"}).appendTo(installTab);
var searchDiv = $('<div>',{class:"red-ui-palette-search"}).appendTo(installTab);
searchInput = $('<input type="text" data-i18n="[placeholder]palette.search"></input>')
.appendTo(searchDiv)
.searchBox({
@ -761,9 +756,9 @@ RED.palette.editor = (function() {
$('<span>').text(RED._("palette.editor.sort")+' ').appendTo(toolBar);
var sortGroup = $('<span class="button-group"></span>').appendTo(toolBar);
var sortRelevance = $('<a href="#" class="palette-editor-install-sort-option sidebar-header-button-toggle selected"><i class="fa fa-sort-amount-desc"></i></a>').appendTo(sortGroup);
var sortAZ = $('<a href="#" class="palette-editor-install-sort-option sidebar-header-button-toggle" data-i18n="palette.editor.sortAZ"></a>').appendTo(sortGroup);
var sortRecent = $('<a href="#" class="palette-editor-install-sort-option sidebar-header-button-toggle" data-i18n="palette.editor.sortRecent"></a>').appendTo(sortGroup);
var sortRelevance = $('<a href="#" class="red-ui-palette-editor-install-sort-option red-ui-sidebar-header-button-toggle selected"><i class="fa fa-sort-amount-desc"></i></a>').appendTo(sortGroup);
var sortAZ = $('<a href="#" class="red-ui-palette-editor-install-sort-option red-ui-sidebar-header-button-toggle" data-i18n="palette.editor.sortAZ"></a>').appendTo(sortGroup);
var sortRecent = $('<a href="#" class="red-ui-palette-editor-install-sort-option red-ui-sidebar-header-button-toggle" data-i18n="palette.editor.sortRecent"></a>').appendTo(sortGroup);
var sortOpts = [
@ -772,12 +767,12 @@ RED.palette.editor = (function() {
{button: sortRecent, func: sortModulesRecent}
]
sortOpts.forEach(function(opt) {
opt.button.click(function(e) {
opt.button.on("click", function(e) {
e.preventDefault();
if ($(this).hasClass("selected")) {
return;
}
$(".palette-editor-install-sort-option").removeClass("selected");
$(".red-ui-palette-editor-install-sort-option").removeClass("selected");
$(this).addClass("selected");
activeSort = opt.func;
refreshFilteredItems();
@ -785,8 +780,8 @@ RED.palette.editor = (function() {
});
var refreshSpan = $('<span>').appendTo(toolBar);
var refreshButton = $('<a href="#" class="sidebar-header-button"><i class="fa fa-refresh"></i></a>').appendTo(refreshSpan);
refreshButton.click(function(e) {
var refreshButton = $('<a href="#" class="red-ui-sidebar-header-button"><i class="fa fa-refresh"></i></a>').appendTo(refreshSpan);
refreshButton.on("click", function(e) {
e.preventDefault();
loadedList = [];
loadedIndex = {};
@ -802,10 +797,10 @@ RED.palette.editor = (function() {
return
}
if (object.more) {
container.addClass('palette-module-more');
var moreRow = $('<div>',{class:"palette-module-header palette-module"}).appendTo(container);
container.addClass('red-ui-palette-module-more');
var moreRow = $('<div>',{class:"red-ui-palette-module-header palette-module"}).appendTo(container);
var moreLink = $('<a href="#"></a>').text(RED._('palette.editor.more',{count:object.more})).appendTo(moreRow);
moreLink.click(function(e) {
moreLink.on("click", function(e) {
e.preventDefault();
packageList.editableList('removeItem',object);
for (var i=object.start;i<Math.min(object.start+10,object.start+object.more);i++) {
@ -819,15 +814,15 @@ RED.palette.editor = (function() {
}
if (object.info) {
var entry = object.info;
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(container);
var titleRow = $('<div class="palette-module-meta"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
$('<span>',{class:"palette-module-name"}).text(entry.name||entry.id).appendTo(titleRow);
$('<a target="_blank" class="palette-module-link"><i class="fa fa-external-link"></i></a>').attr('href',entry.url).appendTo(titleRow);
var descRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
$('<div>',{class:"palette-module-description"}).text(entry.description).appendTo(descRow);
var metaRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
$('<span class="palette-module-version"><i class="fa fa-tag"></i> '+entry.version+'</span>').appendTo(metaRow);
$('<span class="palette-module-updated"><i class="fa fa-calendar"></i> '+formatUpdatedAt(entry.updated_at)+'</span>').appendTo(metaRow);
var headerRow = $('<div>',{class:"red-ui-palette-module-header"}).appendTo(container);
var titleRow = $('<div class="red-ui-palette-module-meta red-ui-palette-module-name"><i class="fa fa-cube"></i></div>').appendTo(headerRow);
$('<span>').text(entry.name||entry.id).appendTo(titleRow);
$('<a target="_blank" class="red-ui-palette-module-link"><i class="fa fa-external-link"></i></a>').attr('href',entry.url).appendTo(titleRow);
var descRow = $('<div class="red-ui-palette-module-meta"></div>').appendTo(headerRow);
$('<div>',{class:"red-ui-palette-module-description"}).text(entry.description).appendTo(descRow);
var metaRow = $('<div class="red-ui-palette-module-meta"></div>').appendTo(headerRow);
$('<span class="red-ui-palette-module-version"><i class="fa fa-tag"></i> '+entry.version+'</span>').appendTo(metaRow);
$('<span class="red-ui-palette-module-updated"><i class="fa fa-calendar"></i> '+formatUpdatedAt(entry.updated_at)+'</span>').appendTo(metaRow);
var duplicateType = false;
if (entry.types && entry.types.length > 0) {
@ -839,13 +834,13 @@ RED.palette.editor = (function() {
break;
}
}
// $('<div>',{class:"palette-module-meta"}).text(entry.types.join(",")).appendTo(headerRow);
// $('<div>',{class:"red-ui-palette-module-meta"}).text(entry.types.join(",")).appendTo(headerRow);
}
var buttonRow = $('<div>',{class:"palette-module-meta"}).appendTo(headerRow);
var buttonGroup = $('<div>',{class:"palette-module-button-group"}).appendTo(buttonRow);
var installButton = $('<a href="#" class="editor-button editor-button-small"></a>').text(RED._('palette.editor.install')).appendTo(buttonGroup);
installButton.click(function(e) {
var buttonRow = $('<div>',{class:"red-ui-palette-module-meta"}).appendTo(headerRow);
var buttonGroup = $('<div>',{class:"red-ui-palette-module-button-group"}).appendTo(buttonRow);
var installButton = $('<a href="#" class="red-ui-button red-ui-button-small"></a>').text(RED._('palette.editor.install')).appendTo(buttonGroup);
installButton.on("click", function(e) {
e.preventDefault();
if (!$(this).hasClass('disabled')) {
install(entry,container,function(xhr) {});
@ -875,7 +870,7 @@ RED.palette.editor = (function() {
}
});
$('<div id="palette-module-install-shade" class="palette-module-shade hide"><div class="palette-module-shade-status"></div><img src="red/images/spin.svg" class="palette-spinner"/></div>').appendTo(installTab);
$('<div id="red-ui-palette-module-install-shade" class="red-ui-palette-module-shade hide"><div class="red-ui-palette-module-shade-status"></div><img src="red/images/spin.svg" class="red-ui-palette-spinner"/></div>').appendTo(installTab);
}
function update(entry,version,container,done) {
if (RED.settings.theme('palette.editable') === false) {
@ -894,11 +889,11 @@ RED.palette.editor = (function() {
},
{
text: RED._("palette.editor.confirm.button.update"),
class: "primary palette-module-install-confirm-button-update",
class: "primary red-ui-palette-module-install-confirm-button-update",
click: function() {
var spinner = RED.utils.addSpinnerOverlay(container, true);
var buttonRow = $('<div style="position: relative;bottom: calc(50% + 17px); padding-right: 10px;text-align: right;"></div>').appendTo(spinner);
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
$('<button class="red-ui-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).on("click", function(evt) {
evt.preventDefault();
RED.actions.invoke("core:show-event-log");
});
@ -953,11 +948,11 @@ RED.palette.editor = (function() {
},
{
text: RED._("palette.editor.confirm.button.remove"),
class: "primary palette-module-install-confirm-button-remove",
class: "primary red-ui-palette-module-install-confirm-button-remove",
click: function() {
var spinner = RED.utils.addSpinnerOverlay(container, true);
var buttonRow = $('<div style="position: relative;bottom: calc(50% + 17px); padding-right: 10px;text-align: right;"></div>').appendTo(spinner);
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
$('<button class="red-ui-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).on("click", function(evt) {
evt.preventDefault();
RED.actions.invoke("core:show-event-log");
});
@ -1009,7 +1004,7 @@ RED.palette.editor = (function() {
if (entry.url) {
buttons.push({
text: RED._("palette.editor.confirm.button.review"),
class: "primary palette-module-install-confirm-button-install",
class: "primary red-ui-palette-module-install-confirm-button-install",
click: function() {
var url = entry.url||"";
window.open(url);
@ -1018,12 +1013,12 @@ RED.palette.editor = (function() {
}
buttons.push({
text: RED._("palette.editor.confirm.button.install"),
class: "primary palette-module-install-confirm-button-install",
class: "primary red-ui-palette-module-install-confirm-button-install",
click: function() {
var spinner = RED.utils.addSpinnerOverlay(container, true);
var buttonRow = $('<div style="position: relative;bottom: calc(50% + 17px); padding-right: 10px;text-align: right;"></div>').appendTo(spinner);
$('<button class="editor-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).click(function(evt) {
$('<button class="red-ui-button"></button>').text(RED._("eventLog.view")).appendTo(buttonRow).on("click", function(evt) {
evt.preventDefault();
RED.actions.invoke("core:show-event-log");
});

View File

@ -23,43 +23,43 @@ RED.palette = (function() {
var sidebarControls;
function createCategory(originalCategory,rootCategory,category,ns) {
if ($("#palette-base-category-"+rootCategory).length === 0) {
if ($("#red-ui-palette-base-category-"+rootCategory).length === 0) {
createCategoryContainer(originalCategory,rootCategory, ns+":palette.label."+rootCategory);
}
$("#palette-container-"+rootCategory).show();
if ($("#palette-"+category).length === 0) {
$("#palette-base-category-"+rootCategory).append('<div id="palette-'+category+'"></div>');
$("#red-ui-palette-container-"+rootCategory).show();
if ($("#red-ui-palette-"+category).length === 0) {
$("#red-ui-palette-base-category-"+rootCategory).append('<div id="red-ui-palette-'+category+'"></div>');
}
}
function createCategoryContainer(originalCategory,category, labelId) {
var label = RED._(labelId, {defaultValue:category});
label = (label || category).replace(/_/g, " ");
var catDiv = $('<div id="palette-container-'+category+'" class="palette-category palette-close hide">'+
'<div id="palette-header-'+category+'" class="palette-header"><i class="expanded fa fa-angle-down"></i><span>'+label+'</span></div>'+
'<div class="palette-content" id="palette-base-category-'+category+'">'+
'<div id="palette-'+category+'-input"></div>'+
'<div id="palette-'+category+'-output"></div>'+
'<div id="palette-'+category+'-function"></div>'+
var catDiv = $('<div id="red-ui-palette-container-'+category+'" class="red-ui-palette-category hide">'+
'<div id="red-ui-palette-header-'+category+'" class="red-ui-palette-header"><i class="expanded fa fa-angle-down"></i><span>'+label+'</span></div>'+
'<div class="red-ui-palette-content" id="red-ui-palette-base-category-'+category+'">'+
'<div id="red-ui-palette-'+category+'-input"></div>'+
'<div id="red-ui-palette-'+category+'-output"></div>'+
'<div id="red-ui-palette-'+category+'-function"></div>'+
'</div>'+
'</div>').appendTo("#palette-container");
'</div>').appendTo("#red-ui-palette-container");
catDiv.data('category',originalCategory);
catDiv.data('label',label);
categoryContainers[category] = {
container: catDiv,
close: function() {
catDiv.removeClass("palette-open");
catDiv.addClass("palette-closed");
$("#palette-base-category-"+category).slideUp();
$("#palette-header-"+category+" i").removeClass("expanded");
catDiv.removeClass("red-ui-palette-open");
catDiv.addClass("red-ui-palette-closed");
$("#red-ui-palette-base-category-"+category).slideUp();
$("#red-ui-palette-header-"+category+" i").removeClass("expanded");
},
open: function() {
catDiv.addClass("palette-open");
catDiv.removeClass("palette-closed");
$("#palette-base-category-"+category).slideDown();
$("#palette-header-"+category+" i").addClass("expanded");
catDiv.addClass("red-ui-palette-open");
catDiv.removeClass("red-ui-palette-closed");
$("#red-ui-palette-base-category-"+category).slideDown();
$("#red-ui-palette-header-"+category+" i").addClass("expanded");
},
toggle: function() {
if (catDiv.hasClass("palette-open")) {
if (catDiv.hasClass("red-ui-palette-open")) {
categoryContainers[category].close();
} else {
categoryContainers[category].open();
@ -67,7 +67,7 @@ RED.palette = (function() {
}
};
$("#palette-header-"+category).on('click', function(e) {
$("#red-ui-palette-header-"+category).on('click', function(e) {
categoryContainers[category].toggle();
});
}
@ -85,17 +85,17 @@ RED.palette = (function() {
var displayLines = [];
var currentLine = words[0];
var currentLineWidth = RED.view.calculateTextWidth(currentLine, "palette_label", 0);
var currentLineWidth = RED.view.calculateTextWidth(currentLine, "red-ui-palette-label", 0);
for (var i=1;i<words.length;i++) {
var newWidth = RED.view.calculateTextWidth(currentLine+" "+words[i], "palette_label", 0);
var newWidth = RED.view.calculateTextWidth(currentLine+" "+words[i], "red-ui-palette-label", 0);
if (newWidth < nodeWidth) {
currentLine += " "+words[i];
currentLineWidth = newWidth;
} else {
displayLines.push(currentLine);
currentLine = words[i];
currentLineWidth = RED.view.calculateTextWidth(currentLine, "palette_label", 0);
currentLineWidth = RED.view.calculateTextWidth(currentLine, "red-ui-palette-label", 0);
}
}
displayLines.push(currentLine);
@ -104,10 +104,10 @@ RED.palette = (function() {
var multiLineNodeHeight = 8+(lineHeight*displayLines.length);
el.css({height:multiLineNodeHeight+"px"});
var labelElement = el.find(".palette_label");
var labelElement = el.find(".red-ui-palette-label");
labelElement.html(lines).attr('dir', RED.text.bidi.resolveBaseTextDir(lines));
el.find(".palette_port").css({top:(multiLineNodeHeight/2-5)+"px"});
el.find(".red-ui-palette-port").css({top:(multiLineNodeHeight/2-5)+"px"});
var popOverContent;
try {
@ -145,17 +145,16 @@ RED.palette = (function() {
function setIcon(element,sf) {
var icon_url = RED.utils.getNodeIcon(sf._def);
var iconContainer = element.find(".palette_icon_container");
var iconContainer = element.find(".red-ui-palette-icon-container");
RED.utils.createIconElement(icon_url, iconContainer, true);
}
function escapeNodeType(nt) {
return nt.replace(/[ .:]/g,"_");
function getPaletteNode(type) {
return $(".red-ui-palette-node[data-palette-type='"+type+"']");
}
function addNodeType(nt,def) {
var nodeTypeId = escapeNodeType(nt);
if ($("#palette_node_"+nodeTypeId).length) {
if (getPaletteNode(nt).length) {
return;
}
if (exclusion.indexOf(def.category)===-1) {
@ -164,9 +163,7 @@ RED.palette = (function() {
var category = def.category.replace(/ /g,"_");
var rootCategory = category.split("-")[0];
var d = document.createElement("div");
d.id = "palette_node_"+nodeTypeId;
d.type = nt;
var d = $('<div>',{class:"red-ui-palette-node"}).attr("data-palette-type",nt).data('category',rootCategory);
var label = /^(.*?)([ -]in|[ -]out)?$/.exec(nt)[1];
if (typeof def.paletteLabel !== "undefined") {
@ -178,51 +175,49 @@ RED.palette = (function() {
}
$('<div/>', {
class: "palette_label"
+ (((!def.align && def.inputs !== 0 && def.outputs === 0) || "right" === def.align) ? " palette_label_right" : "")
class: "red-ui-palette-label"
+ (((!def.align && def.inputs !== 0 && def.outputs === 0) || "right" === def.align) ? " red-ui-palette-label-right" : "")
}).appendTo(d);
d.className="palette_node";
if (def.icon) {
var icon_url = RED.utils.getNodeIcon(def);
var iconContainer = $('<div/>', {
class: "palette_icon_container"
+ (((!def.align && def.inputs !== 0 && def.outputs === 0) || "right" === def.align) ? " palette_icon_container_right" : "")
class: "red-ui-palette-icon-container"
+ (((!def.align && def.inputs !== 0 && def.outputs === 0) || "right" === def.align) ? " red-ui-palette-icon-container-right" : "")
}).appendTo(d);
RED.utils.createIconElement(icon_url, iconContainer, true);
}
d.style.backgroundColor = RED.utils.getNodeColor(nt,def);
d.css("backgroundColor", RED.utils.getNodeColor(nt,def));
if (def.outputs > 0) {
var portOut = document.createElement("div");
portOut.className = "palette_port palette_port_output";
d.appendChild(portOut);
portOut.className = "red-ui-palette-port red-ui-palette-port-output";
d.append(portOut);
}
if (def.inputs > 0) {
var portIn = document.createElement("div");
portIn.className = "palette_port palette_port_input";
d.appendChild(portIn);
portIn.className = "red-ui-palette-port red-ui-palette-port-input";
d.append(portIn);
}
createCategory(def.category,rootCategory,category,(coreCategories.indexOf(rootCategory) !== -1)?"node-red":def.set.id);
$("#palette-"+category).append(d);
$("#red-ui-palette-"+category).append(d);
$(d).data('category',rootCategory);
d.onmousedown = function(e) { e.preventDefault(); };
d.on("mousedown", function(e) { e.preventDefault();});
var popover = RED.popover.create({
target:$(d),
target:d,
trigger: "hover",
width: "300px",
content: "hi",
delay: { show: 750, hide: 50 }
});
$(d).data('popover',popover);
d.data('popover',popover);
// $(d).popover({
// title:d.type,
@ -232,18 +227,21 @@ RED.palette = (function() {
// html: true,
// container:'body'
// });
$(d).click(function() {
d.on("click", function() {
RED.view.focus();
var helpText;
if (nt.indexOf("subflow:") === 0) {
helpText = marked(RED.nodes.subflow(nt.substring(8)).info||"")||('<span class="node-info-none">'+RED._("sidebar.info.none")+'</span>');
helpText = marked(RED.nodes.subflow(nt.substring(8)).info||"")||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
} else {
helpText = $("script[data-help-name='"+d.type+"']").html()||('<span class="node-info-none">'+RED._("sidebar.info.none")+'</span>');
helpText = $("script[data-help-name='"+d.attr("data-palette-type")+"']").html()||('<span class="red-ui-help-info-none">'+RED._("sidebar.info.none")+'</span>');
}
// Don't look too closely. RED.sidebar.info.set will set the 'Description'
// section of the sidebar. Pass in the title of the Help section so it looks
// right.
RED.sidebar.info.set(helpText,RED._("sidebar.info.nodeHelp"));
});
var chart = $("#chart");
var chartSVG = $("#chart>svg").get(0);
var chart = $("#red-ui-workspace-chart");
var chartSVG = $("#red-ui-workspace-chart>svg").get(0);
var activeSpliceLink;
var mouseX;
var mouseY;
@ -252,16 +250,16 @@ RED.palette = (function() {
var paletteTop;
$(d).draggable({
helper: 'clone',
appendTo: 'body',
appendTo: '#red-ui-editor',
revert: 'invalid',
revertDuration: 300,
containment:'#main-container',
revertDuration: 200,
containment:'#red-ui-main-container',
start: function() {
paletteWidth = $("#palette").width();
paletteTop = $("#palette").parent().position().top + $("#palette-container").position().top;
paletteWidth = $("#red-ui-palette").width();
paletteTop = $("#red-ui-palette").parent().position().top + $("#red-ui-palette-container").position().top;
RED.view.focus();
},
stop: function() { d3.select('.link_splice').classed('link_splice',false); if (spliceTimer) { clearTimeout(spliceTimer); spliceTimer = null;}},
stop: function() { d3.select('.red-ui-flow-link-splice').classed('red-ui-flow-link-splice',false); if (spliceTimer) { clearTimeout(spliceTimer); spliceTimer = null;}},
drag: function(e,ui) {
ui.originalPosition.left = $('#' + e.target.id).offset().left;
@ -292,7 +290,7 @@ RED.palette = (function() {
for (var i=0;i<nodes.length;i++) {
var node = d3.select(nodes[i]);
if (node.classed('link_background') && !node.classed('link_link')) {
if (node.classed('red-ui-flow-link-background') && !node.classed('red-ui-flow-link-link')) {
var length = nodes[i].getTotalLength();
for (var j=0;j<length;j+=10) {
var p = nodes[i].getPointAtLength(j);
@ -305,12 +303,12 @@ RED.palette = (function() {
}
}
if (activeSpliceLink && activeSpliceLink !== bestLink) {
d3.select(activeSpliceLink.parentNode).classed('link_splice',false);
d3.select(activeSpliceLink.parentNode).classed('red-ui-flow-link-splice',false);
}
if (bestLink) {
d3.select(bestLink.parentNode).classed('link_splice',true)
d3.select(bestLink.parentNode).classed('red-ui-flow-link-splice',true)
} else {
d3.select('.link_splice').classed('link_splice',false);
d3.select('.red-ui-flow-link-splice').classed('red-ui-flow-link-splice',false);
}
if (activeSpliceLink !== bestLink) {
if (bestLink) {
@ -329,16 +327,16 @@ RED.palette = (function() {
var nodeInfo = null;
if (nt.indexOf("subflow:") === 0) {
$(d).dblclick(function(e) {
d.on("dblclick", function(e) {
RED.workspaces.show(nt.substring(8));
e.preventDefault();
});
nodeInfo = marked(def.info||"");
}
setLabel(nt,$(d),label,nodeInfo);
setLabel(nt,d,label,nodeInfo);
var categoryNode = $("#palette-container-"+rootCategory);
if (categoryNode.find(".palette_node").length === 1) {
var categoryNode = $("#red-ui-palette-container-"+rootCategory);
if (categoryNode.find(".red-ui-palette-node").length === 1) {
categoryContainers[rootCategory].open();
}
@ -346,24 +344,22 @@ RED.palette = (function() {
}
function removeNodeType(nt) {
var nodeTypeId = escapeNodeType(nt);
var paletteNode = $("#palette_node_"+nodeTypeId);
var categoryNode = paletteNode.closest(".palette-category");
var paletteNode = getPaletteNode(nt);
var categoryNode = paletteNode.closest(".red-ui-palette-category");
paletteNode.remove();
if (categoryNode.find(".palette_node").length === 0) {
if (categoryNode.find(".red-ui-palette-node").length === 0) {
if (categoryNode.find("i").hasClass("expanded")) {
categoryNode.find(".palette-content").slideToggle();
categoryNode.find(".red-ui-palette-content").slideToggle();
categoryNode.find("i").toggleClass("expanded");
}
}
}
function hideNodeType(nt) {
var nodeTypeId = escapeNodeType(nt);
var paletteNode = $("#palette_node_"+nodeTypeId);
var paletteNode = getPaletteNode(nt);
paletteNode.hide();
var categoryNode = paletteNode.closest(".palette-category");
var cl = categoryNode.find(".palette_node");
var categoryNode = paletteNode.closest(".red-ui-palette-category");
var cl = categoryNode.find(".red-ui-palette-node");
var c = 0;
for (var i = 0; i < cl.length; i++) {
if ($(cl[i]).css('display') === 'none') { c += 1; }
@ -372,33 +368,31 @@ RED.palette = (function() {
}
function showNodeType(nt) {
var nodeTypeId = escapeNodeType(nt);
var paletteNode = $("#palette_node_"+nodeTypeId);
var categoryNode = paletteNode.closest(".palette-category");
var paletteNode = getPaletteNode(nt);
var categoryNode = paletteNode.closest(".red-ui-palette-category");
categoryNode.show();
paletteNode.show();
}
function refreshNodeTypes() {
RED.nodes.eachSubflow(function(sf) {
var paletteNode = $("#palette_node_subflow_"+sf.id.replace(".","_"));
var portInput = paletteNode.find(".palette_port_input");
var portOutput = paletteNode.find(".palette_port_output");
var paletteNode = getPaletteNode('subflow:'+sf.id);
var portInput = paletteNode.find(".red-ui-palette-port-input");
var portOutput = paletteNode.find(".red-ui-palette-port-output");
var paletteLabel = paletteNode.find(".palette_label");
paletteLabel.attr("class","palette_label"
+ (((!sf._def.align && sf.in.length !== 0 && sf.out.length === 0) || "right" === sf._def.align) ? " palette_label_right" : "")
var paletteLabel = paletteNode.find(".red-ui-palette-label");
paletteLabel.attr("class","red-ui-palette-label"
+ (((!sf._def.align && sf.in.length !== 0 && sf.out.length === 0) || "right" === sf._def.align) ? " red-ui-palette-label-right" : "")
);
var paletteIconContainer = paletteNode.find(".palette_icon_container");
paletteIconContainer.attr("class","palette_icon_container"
+ (((!sf._def.align && sf.in.length !== 0 && sf.out.length === 0) || "right" === sf._def.align) ? " palette_icon_container_right" : "")
var paletteIconContainer = paletteNode.find(".red-ui-palette-icon-container");
paletteIconContainer.attr("class","red-ui-palette-icon-container"
+ (((!sf._def.align && sf.in.length !== 0 && sf.out.length === 0) || "right" === sf._def.align) ? " red-ui-palette-icon-container-right" : "")
);
if (portInput.length === 0 && sf.in.length > 0) {
var portIn = document.createElement("div");
portIn.className = "palette_port palette_port_input";
portIn.className = "red-ui-palette-port red-ui-palette-port-input";
paletteNode.append(portIn);
} else if (portInput.length !== 0 && sf.in.length === 0) {
portInput.remove();
@ -406,7 +400,7 @@ RED.palette = (function() {
if (portOutput.length === 0 && sf.out.length > 0) {
var portOut = document.createElement("div");
portOut.className = "palette_port palette_port_output";
portOut.className = "red-ui-palette-port red-ui-palette-port-output";
paletteNode.append(portOut);
} else if (portOutput.length !== 0 && sf.out.length === 0) {
portOutput.remove();
@ -420,32 +414,32 @@ RED.palette = (function() {
var category = newCategory.replace(/ /g,"_");
createCategory(newCategory,category,category,"node-red");
var currentCategoryNode = paletteNode.closest(".palette-category");
var newCategoryNode = $("#palette-"+category);
var currentCategoryNode = paletteNode.closest(".red-ui-palette-category");
var newCategoryNode = $("#red-ui-palette-"+category);
newCategoryNode.append(paletteNode);
if (newCategoryNode.find(".palette_node").length === 1) {
if (newCategoryNode.find(".red-ui-palette-node").length === 1) {
categoryContainers[category].open();
}
paletteNode.data('category',newCategory);
if (currentCategoryNode.find(".palette_node").length === 0) {
if (currentCategoryNode.find(".red-ui-palette-node").length === 0) {
if (currentCategoryNode.find("i").hasClass("expanded")) {
currentCategoryNode.find(".palette-content").slideToggle();
currentCategoryNode.find(".red-ui-palette-content").slideToggle();
currentCategoryNode.find("i").toggleClass("expanded");
}
}
}
paletteNode.css("backgroundColor", sf.color);
});
}
function filterChange(val) {
var re = new RegExp(val.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'),'i');
$("#palette-container .palette_node").each(function(i,el) {
var currentLabel = $(el).find(".palette_label").text();
if (val === "" || re.test(el.id) || re.test(currentLabel)) {
$("#red-ui-palette-container .red-ui-palette-node").each(function(i,el) {
var currentLabel = $(el).find(".red-ui-palette-label").text();
var type = $(el).attr("data-palette-type");
if (val === "" || re.test(type) || re.test(currentLabel)) {
$(this).show();
} else {
$(this).hide();
@ -455,11 +449,13 @@ RED.palette = (function() {
for (var category in categoryContainers) {
if (categoryContainers.hasOwnProperty(category)) {
if (categoryContainers[category].container
.find(".palette_node")
.find(".red-ui-palette-node")
.filter(function() { return $(this).css('display') !== 'none'}).length === 0) {
categoryContainers[category].close();
categoryContainers[category].container.slideUp();
} else {
categoryContainers[category].open();
categoryContainers[category].container.show();
}
}
}
@ -467,6 +463,13 @@ RED.palette = (function() {
function init() {
$('<img src="red/images/spin.svg" class="red-ui-palette-spinner hide"/>').appendTo("#red-ui-palette");
$('<div id="red-ui-palette-search" class="red-ui-palette-search hide"><input type="text" data-i18n="[placeholder]palette.filter"></input></div>').appendTo("#red-ui-palette");
$('<div id="red-ui-palette-container" class="red-ui-palette-scroll hide"></div>').appendTo("#red-ui-palette");
$('<div class="red-ui-component-footer"></div>').appendTo("#red-ui-palette");
$('<div id="red-ui-palette-shade" class="hide"></div>').appendTo("#red-ui-palette");
RED.events.on('registry:node-type-added', function(nodeType) {
var def = RED.nodes.getType(nodeType);
addNodeType(nodeType,def);
@ -507,31 +510,30 @@ RED.palette = (function() {
}
});
$("#palette > .palette-spinner").show();
$("#red-ui-palette > .red-ui-palette-spinner").show();
$("#palette-search input").searchBox({
$("#red-ui-palette-search input").searchBox({
delay: 100,
change: function() {
filterChange($(this).val());
}
})
sidebarControls = $('<div class="sidebar-control-left"><i class="fa fa-chevron-left"</div>').appendTo($("#palette"));
sidebarControls = $('<div class="red-ui-sidebar-control-left"><i class="fa fa-chevron-left"></i></div>').appendTo($("#red-ui-palette"));
RED.popover.tooltip(sidebarControls,RED._("keyboard.togglePalette"),"core:toggle-palette");
sidebarControls.click(function() {
sidebarControls.on("click", function() {
RED.menu.toggleSelected("menu-item-palette");
})
$("#palette").on("mouseenter", function() {
$("#red-ui-palette").on("mouseenter", function() {
sidebarControls.toggle("slide", { direction: "left" }, 200);
})
$("#palette").on("mouseleave", function() {
$("#red-ui-palette").on("mouseleave", function() {
sidebarControls.stop(false,true);
sidebarControls.hide();
})
var categoryList = coreCategories;
if (RED.settings.paletteCategories) {
categoryList = RED.settings.paletteCategories;
@ -545,7 +547,10 @@ RED.palette = (function() {
createCategoryContainer(category, category, "palette.label."+category);
});
$("#palette-collapse-all").on("click", function(e) {
var paletteFooterButtons = $('<span class="button-group"></span>').appendTo("#red-ui-palette .red-ui-component-footer");
var paletteCollapseAll = $('<button type="button" class="red-ui-footer-button"><i class="fa fa-angle-double-up"></i></button>').appendTo(paletteFooterButtons);
paletteCollapseAll.on("click", function(e) {
e.preventDefault();
for (var cat in categoryContainers) {
if (categoryContainers.hasOwnProperty(cat)) {
@ -553,9 +558,10 @@ RED.palette = (function() {
}
}
});
RED.popover.tooltip($("#palette-collapse-all"),RED._('palette.actions.collapse-all'));
RED.popover.tooltip(paletteCollapseAll,RED._('palette.actions.collapse-all'));
$("#palette-expand-all").on("click", function(e) {
var paletteExpandAll = $('<button type="button" class="red-ui-footer-button"><i class="fa fa-angle-double-down"></i></button>').appendTo(paletteFooterButtons);
paletteExpandAll.on("click", function(e) {
e.preventDefault();
for (var cat in categoryContainers) {
if (categoryContainers.hasOwnProperty(cat)) {
@ -563,7 +569,7 @@ RED.palette = (function() {
}
}
});
RED.popover.tooltip($("#palette-expand-all"),RED._('palette.actions.expand-all'));
RED.popover.tooltip(paletteExpandAll,RED._('palette.actions.expand-all'));
RED.actions.add("core:toggle-palette", function(state) {
if (state === undefined) {
@ -575,20 +581,19 @@ RED.palette = (function() {
}
function togglePalette(state) {
if (!state) {
$("#main-container").addClass("palette-closed");
$("#red-ui-main-container").addClass("red-ui-palette-closed");
sidebarControls.hide();
sidebarControls.find("i").addClass("fa-chevron-right").removeClass("fa-chevron-left");
} else {
$("#main-container").removeClass("palette-closed");
$("#red-ui-main-container").removeClass("red-ui-palette-closed");
sidebarControls.find("i").removeClass("fa-chevron-right").addClass("fa-chevron-left");
}
setTimeout(function() { $(window).resize(); } ,200);
setTimeout(function() { $(window).trigger("resize"); } ,200);
}
function getCategories() {
var categories = [];
$("#palette-container .palette-category").each(function(i,d) {
$("#red-ui-palette-container .red-ui-palette-category").each(function(i,d) {
categories.push({id:$(d).data('category'),label:$(d).data('label')});
})
return categories;

View File

@ -46,7 +46,6 @@ RED.projects.settings = (function() {
}
settingsVisible = true;
var tabContainer;
var trayOptions = {
title: RED._("sidebar.project.projectSettings.title"),
@ -66,9 +65,9 @@ RED.projects.settings = (function() {
open: function(tray) {
var project = RED.projects.getActiveProject();
var trayBody = tray.find('.editor-tray-body');
var trayBody = tray.find('.red-ui-tray-body');
var settingsContent = $('<div></div>').appendTo(trayBody);
var tabContainer = $('<div></div>',{id:"user-settings-tabs-container"}).appendTo(settingsContent);
var tabContainer = $('<div></div>',{class:"red-ui-settings-tabs-container"}).appendTo(settingsContent);
$('<ul></ul>',{id:"user-settings-tabs"}).appendTo(tabContainer);
var settingsTabs = RED.tabs.create({
@ -76,7 +75,7 @@ RED.projects.settings = (function() {
vertical: true,
onchange: function(tab) {
setTimeout(function() {
$("#user-settings-tabs-content").children().hide();
tabContents.children().hide();
$("#" + tab.id).show();
if (tab.pane.focus) {
tab.pane.focus();
@ -84,19 +83,19 @@ RED.projects.settings = (function() {
},50);
}
});
var tabContents = $('<div></div>',{id:"user-settings-tabs-content"}).appendTo(settingsContent);
var tabContents = $('<div></div>',{class:"red-ui-settings-tabs-content"}).appendTo(settingsContent);
panes.forEach(function(pane) {
settingsTabs.addTab({
id: "project-settings-tab-"+pane.id,
id: "red-ui-project-settings-tab-"+pane.id,
label: pane.title,
pane: pane
});
pane.get(project).hide().appendTo(tabContents);
});
settingsContent.i18n();
settingsTabs.activateTab("project-settings-tab-"+(initialTab||'main'))
$("#sidebar-shade").show();
settingsTabs.activateTab("red-ui-project-settings-tab-"+(initialTab||'main'))
$("#red-ui-sidebar-shade").show();
},
close: function() {
settingsVisible = false;
@ -105,7 +104,7 @@ RED.projects.settings = (function() {
pane.close();
}
});
$("#sidebar-shade").hide();
$("#red-ui-sidebar-shade").hide();
},
show: function() {}
@ -161,10 +160,10 @@ RED.projects.settings = (function() {
if (activeProject.description) {
desc = marked(activeProject.description);
} else {
desc = '<span class="node-info-none">'+'No description available'+'</span>';
desc = '<span class="red-ui-help-info-none">'+'No description available'+'</span>';
}
var description = addTargetToExternalLinks($('<span class="bidiAware" dir=\"'+RED.text.bidi.resolveBaseTextDir(desc)+'">'+desc+'</span>')).appendTo(container);
description.find(".bidiAware").contents().filter(function() { return this.nodeType === 3 && this.textContent.trim() !== "" }).wrap( "<span></span>" );
var description = addTargetToExternalLinks($('<span class="red-ui-text-bidi-aware" dir=\"'+RED.text.bidi.resolveBaseTextDir(desc)+'">'+desc+'</span>')).appendTo(container);
description.find(".red-ui-text-bidi-aware").contents().filter(function() { return this.nodeType === 3 && this.textContent.trim() !== "" }).wrap( "<span></span>" );
}
function editSummary(activeProject, summary, container) {
@ -173,16 +172,16 @@ RED.projects.settings = (function() {
container.empty();
var bg = $('<span class="button-row" style="position: relative; float: right; margin-right:0;"></span>').appendTo(container);
var input = $('<input type="text" style="width: calc(100% - 150px); margin-right: 10px;">').val(summary||"").appendTo(container);
$('<button class="editor-button">' + RED._("common.label.cancel") + '</button>')
$('<button class="red-ui-button">' + RED._("common.label.cancel") + '</button>')
.appendTo(bg)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
updateProjectSummary(activeProject.summary, container);
editButton.show();
});
$('<button class="editor-button">' + RED._("common.label.save") + '</button>')
$('<button class="red-ui-button">' + RED._("common.label.save") + '</button>')
.appendTo(bg)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
var v = input.val();
updateProjectSummary(v, container);
@ -223,36 +222,36 @@ RED.projects.settings = (function() {
if (summary) {
container.text(summary).removeClass('node-info-node');
} else {
container.text(RED._("sidebar.project.projectSettings.noSummaryAvailable")).addClass('node-info-none');
container.text(RED._("sidebar.project.projectSettings.noSummaryAvailable")).addClass('red-ui-help-info-none');
}
}
function createMainPane(activeProject) {
var pane = $('<div id="project-settings-tab-main" class="project-settings-tab-pane node-help"></div>');
var pane = $('<div id="red-ui-project-settings-tab-main" class="red-ui-project-settings-tab-pane red-ui-help"></div>');
$('<h1>').text(activeProject.name).appendTo(pane);
var summary = $('<div style="position: relative">').appendTo(pane);
var summaryContent = $('<div></div>',{style:"color: #999"}).appendTo(summary);
var summaryContent = $('<div></div>').appendTo(summary);
updateProjectSummary(activeProject.summary, summaryContent);
if (RED.user.hasPermission("projects.write")) {
$('<button class="editor-button editor-button-small" style="float: right;">' + RED._('sidebar.project.editDescription') + '</button>')
$('<button class="red-ui-button red-ui-button-small" style="float: right;">' + RED._('sidebar.project.editDescription') + '</button>')
.prependTo(summary)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
editSummary(activeProject, activeProject.summary, summaryContent);
});
}
$('<hr>').appendTo(pane);
var description = $('<div class="node-help" style="position: relative"></div>').appendTo(pane);
var description = $('<div class="red-ui-help" style="position: relative"></div>').appendTo(pane);
var descriptionContent = $('<div>',{style:"min-height: 200px"}).appendTo(description);
updateProjectDescription(activeProject, descriptionContent);
if (RED.user.hasPermission("projects.write")) {
$('<button class="editor-button editor-button-small" style="float: right;">' + RED._('sidebar.project.editReadme') + '</button>')
$('<button class="red-ui-button red-ui-button-small" style="float: right;">' + RED._('sidebar.project.editReadme') + '</button>')
.prependTo(description)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
editDescription(activeProject, descriptionContent);
});
@ -323,7 +322,7 @@ RED.projects.settings = (function() {
function saveDependencies(depsList,container,dependencies,complete) {
var activeProject = RED.projects.getActiveProject();
var spinner = utils.addSpinnerOverlay(container).addClass('projects-dialog-spinner-contain');
var spinner = utils.addSpinnerOverlay(container).addClass('red-ui-component-spinner-contain');
var done = function(err,res) {
spinner.remove();
if (err) {
@ -379,11 +378,11 @@ RED.projects.settings = (function() {
}
function createDependenciesPane(activeProject) {
var pane = $('<div id="project-settings-tab-deps" class="project-settings-tab-pane node-help"></div>');
var pane = $('<div id="red-ui-project-settings-tab-deps" class="red-ui-project-settings-tab-pane red-ui-help"></div>');
if (RED.user.hasPermission("projects.write")) {
$('<button class="editor-button editor-button-small" style="margin-top:10px;float: right;">' + RED._("sidebar.project.projectSettings.edit") + '</button>')
$('<button class="red-ui-button red-ui-button-small" style="margin-top:10px;float: right;">' + RED._("sidebar.project.projectSettings.edit") + '</button>')
.appendTo(pane)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
editDependencies(activeProject,null,pane,depsList)
});
@ -393,17 +392,17 @@ RED.projects.settings = (function() {
addButton: false,
addItem: function(row,index,entry) {
// console.log(entry);
var headerRow = $('<div>',{class:"palette-module-header"}).appendTo(row);
var headerRow = $('<div>',{class:"red-ui-palette-module-header"}).appendTo(row);
if (entry.label) {
if (entry.index === 0) {
headerRow.addClass("red-ui-search-empty")
} else {
row.parent().addClass("palette-module-section");
row.parent().addClass("red-ui-palette-module-section");
}
headerRow.text(entry.label);
// if (RED.user.hasPermission("projects.write")) {
// if (entry.index === 1) {
// var addButton = $('<button class="editor-button editor-button-small palette-module-button">add to project</button>').appendTo(headerRow).click(function(evt) {
// var addButton = $('<button class="red-ui-button red-ui-button-small red-ui-palette-module-button">add to project</button>').appendTo(headerRow).on("click", function(evt) {
// evt.preventDefault();
// var deps = $.extend(true, {}, activeProject.dependencies);
// for (var m in modulesInUse) {
@ -414,7 +413,7 @@ RED.projects.settings = (function() {
// editDependencies(activeProject,JSON.stringify(deps,"",4),pane,depsList);
// });
// } else if (entry.index === 3) {
// var removeButton = $('<button class="editor-button editor-button-small palette-module-button">remove from project</button>').appendTo(headerRow).click(function(evt) {
// var removeButton = $('<button class="red-ui-button red-ui-button-small red-ui-palette-module-button">remove from project</button>').appendTo(headerRow).on("click", function(evt) {
// evt.preventDefault();
// var deps = $.extend(true, {}, activeProject.dependencies);
// for (var m in activeProject.dependencies) {
@ -427,17 +426,17 @@ RED.projects.settings = (function() {
// }
// }
} else {
headerRow.addClass("palette-module-header");
headerRow.addClass("red-ui-palette-module-header");
if (!entry.installed) {
headerRow.addClass("palette-module-not-installed");
headerRow.addClass("red-ui-palette-module-not-installed");
} else if (entry.count === 0) {
headerRow.addClass("palette-module-unused");
headerRow.addClass("red-ui-palette-module-unused");
} else if (!entry.known) {
headerRow.addClass("palette-module-unknown");
headerRow.addClass("red-ui-palette-module-unknown");
}
entry.element = headerRow;
var titleRow = $('<div class="palette-module-meta palette-module-name"></div>').appendTo(headerRow);
var titleRow = $('<div class="red-ui-palette-module-meta red-ui-palette-module-name"></div>').appendTo(headerRow);
var iconClass = "fa-cube";
if (!entry.installed) {
iconClass = "fa-warning";
@ -445,14 +444,14 @@ RED.projects.settings = (function() {
var icon = $('<i class="fa '+iconClass+'"></i>').appendTo(titleRow);
entry.icon = icon;
$('<span>').text(entry.id).appendTo(titleRow);
var metaRow = $('<div class="palette-module-meta palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
var metaRow = $('<div class="red-ui-palette-module-meta red-ui-palette-module-version"><i class="fa fa-tag"></i></div>').appendTo(headerRow);
var versionSpan = $('<span>').text(entry.version).appendTo(metaRow);
metaRow = $('<div class="palette-module-meta"></div>').appendTo(headerRow);
var buttons = $('<div class="palette-module-button-group"></div>').appendTo(metaRow);
metaRow = $('<div class="red-ui-palette-module-meta"></div>').appendTo(headerRow);
var buttons = $('<div class="red-ui-palette-module-button-group"></div>').appendTo(metaRow);
if (RED.user.hasPermission("projects.write")) {
if (!entry.installed && RED.settings.theme('palette.editable') !== false) {
$('<a href="#" class="editor-button editor-button-small">' + RED._("sidebar.project.projectSettings.install") + '</a>').appendTo(buttons)
.click(function(evt) {
$('<a href="#" class="red-ui-button red-ui-button-small">' + RED._("sidebar.project.projectSettings.install") + '</a>').appendTo(buttons)
.on("click", function(evt) {
evt.preventDefault();
RED.palette.editor.install(entry,row,function(err) {
if (!err) {
@ -472,8 +471,8 @@ RED.projects.settings = (function() {
});
})
} else if (entry.known && entry.count === 0) {
$('<a href="#" class="editor-button editor-button-small">' + RED._("sidebar.project.projectSettings.removeFromProject") + '</a>').appendTo(buttons)
.click(function(evt) {
$('<a href="#" class="red-ui-button red-ui-button-small">' + RED._("sidebar.project.projectSettings.removeFromProject") + '</a>').appendTo(buttons)
.on("click", function(evt) {
evt.preventDefault();
var deps = $.extend(true, {}, activeProject.dependencies);
delete deps[entry.id];
@ -488,15 +487,15 @@ RED.projects.settings = (function() {
});
});
} else if (!entry.known) {
$('<a href="#" class="editor-button editor-button-small">' + RED._("sidebar.project.projectSettings.addToProject") + '</a>').appendTo(buttons)
.click(function(evt) {
$('<a href="#" class="red-ui-button red-ui-button-small">' + RED._("sidebar.project.projectSettings.addToProject") + '</a>').appendTo(buttons)
.on("click", function(evt) {
evt.preventDefault();
var deps = $.extend(true, {}, activeProject.dependencies);
deps[entry.id] = modulesInUse[entry.id].version;
saveDependencies(depsList,row,deps,function(err) {
if (!err) {
buttons.remove();
headerRow.removeClass("palette-module-unknown");
headerRow.removeClass("red-ui-palette-module-unknown");
} else {
console.log(err);
}
@ -531,7 +530,7 @@ RED.projects.settings = (function() {
var dialogBody;
var filesList;
var selected;
var container = $('<div class="project-file-listing-container"></div>',{style:"position: relative; min-height: 175px; height: 175px;"}).hide().appendTo(row);
var container = $('<div class="red-ui-projects-file-listing-container"></div>',{style:"position: relative; min-height: 175px; height: 175px;"}).hide().appendTo(row);
var spinner = utils.addSpinnerOverlay(container);
$.getJSON("projects/"+activeProject.name+"/files",function(result) {
var fileNames = Object.keys(result);
@ -579,13 +578,13 @@ RED.projects.settings = (function() {
function createFileSubList(container, files, current, selectFilter, onselect, style) {
style = style || "";
var list = $('<ol>',{class:"projects-dialog-file-list", style:style}).appendTo(container).editableList({
var list = $('<ol>',{class:"red-ui-projects-dialog-file-list", style:style}).appendTo(container).editableList({
addButton: false,
scrollOnAdd: false,
addItem: function(row,index,entry) {
var header = $('<div></div>',{class:"projects-dialog-file-list-entry"}).appendTo(row);
var header = $('<div></div>',{class:"red-ui-projects-dialog-file-list-entry"}).appendTo(row);
if (entry.children) {
$('<span class="projects-dialog-file-list-entry-folder"><i class="fa fa-angle-right"></i> <i class="fa fa-folder-o"></i></span>').appendTo(header);
$('<span class="red-ui-projects-dialog-file-list-entry-folder"><i class="fa fa-angle-right"></i> <i class="fa fa-folder-o"></i></span>').appendTo(header);
if (entry.children.length > 0) {
var children = $('<div></div>',{style:"padding-left: 20px;"}).appendTo(row);
if (current.indexOf(entry.path+"/") === 0) {
@ -595,7 +594,7 @@ RED.projects.settings = (function() {
}
createFileSubList(children,entry.children,current,selectFilter,onselect);
header.addClass("selectable");
header.click(function(e) {
header.on("click", function(e) {
if ($(this).hasClass("expanded")) {
$(this).removeClass("expanded");
children.slideUp(200);
@ -616,20 +615,20 @@ RED.projects.settings = (function() {
fileIcon = "fa-book";
} else if (/^\.git/i.test(entry.name)) {
fileIcon = "fa-code-fork";
header.addClass("projects-dialog-file-list-entry-file-type-git");
header.addClass("red-ui-projects-dialog-file-list-entry-file-type-git");
}
$('<span class="projects-dialog-file-list-entry-file"> <i class="fa '+fileIcon+'"></i></span>').appendTo(header);
$('<span class="red-ui-projects-dialog-file-list-entry-file"> <i class="fa '+fileIcon+'"></i></span>').appendTo(header);
if (selectFilter(entry)) {
header.addClass("selectable");
if (entry.path === current) {
header.addClass("selected");
}
header.click(function(e) {
$(".projects-dialog-file-list-entry.selected").removeClass("selected");
header.on("click", function(e) {
$(".red-ui-projects-dialog-file-list-entry.selected").removeClass("selected");
$(this).addClass("selected");
onselect(entry.path,true);
})
header.dblclick(function(e) {
header.on("dblclick", function(e) {
e.preventDefault();
onselect(entry.path,true);
})
@ -637,7 +636,7 @@ RED.projects.settings = (function() {
header.addClass("unselectable");
}
}
$('<span class="projects-dialog-file-list-entry-name" style=""></span>').text(entry.name).appendTo(header);
$('<span class="red-ui-projects-dialog-file-list-entry-name" style=""></span>').text(entry.name).appendTo(header);
}
});
if (!style) {
@ -654,9 +653,9 @@ RED.projects.settings = (function() {
//
// var flowFileInput = $('<input id="" type="text" style="width: calc(100% - 300px);">').val(flowFile).insertAfter(flowFileLabel);
//
// var flowFileInputSearch = $('<button class="editor-button" style="margin-left: 10px"><i class="fa fa-folder-open-o"></i></button>')
// var flowFileInputSearch = $('<button class="red-ui-button" style="margin-left: 10px"><i class="fa fa-folder-open-o"></i></button>')
// .insertAfter(flowFileInput)
// .click(function(e) {
// .on("click", function(e) {
// showProjectFileListing(activeProject,'Select flow file',flowFileInput.val(),function(result) {
// flowFileInput.val(result);
// checkFiles();
@ -671,9 +670,9 @@ RED.projects.settings = (function() {
// flowFileLabel.hide();
//
// var bg = $('<span class="button-group" style="position: relative; float: right; margin-right:0;"></span>').prependTo(container);
// $('<button class="editor-button">Cancel</button>')
// $('<button class="red-ui-button">Cancel</button>')
// .appendTo(bg)
// .click(function(evt) {
// .on("click", function(evt) {
// evt.preventDefault();
//
// flowFileLabel.show();
@ -682,9 +681,9 @@ RED.projects.settings = (function() {
// bg.remove();
// editButton.show();
// });
// var saveButton = $('<button class="editor-button">Save</button>')
// var saveButton = $('<button class="red-ui-button">Save</button>')
// .appendTo(bg)
// .click(function(evt) {
// .on("click", function(evt) {
// evt.preventDefault();
// var newFlowFile = flowFileInput.val();
// var newCredsFile = credentialsFileInput.val();
@ -729,18 +728,18 @@ RED.projects.settings = (function() {
function createFilesSection(activeProject,pane) {
var title = $('<h3></h3>').text(RED._("sidebar.project.projectSettings.files")).appendTo(pane);
var filesContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
var filesContainer = $('<div class="red-ui-settings-section"></div>').appendTo(pane);
if (RED.user.hasPermission("projects.write")) {
var editFilesButton = $('<button type="button" id="project-settings-tab-settings-file-edit" class="editor-button editor-button-small" style="float: right;">' + RED._('sidebar.project.projectSettings.edit') + '</button>')
var editFilesButton = $('<button type="button" id="red-ui-project-settings-tab-settings-file-edit" class="red-ui-button red-ui-button-small" style="float: right;">' + RED._('sidebar.project.projectSettings.edit') + '</button>')
.appendTo(title)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
formButtons.show();
editFilesButton.hide();
// packageFileLabelText.hide();
if (!activeProject.files.package) {
packageFileSubLabel.find(".projects-edit-form-sublabel-text").text(RED._("sidebar.project.projectSettings.packageCreate"));
packageFileSubLabel.find(".red-ui-projects-edit-form-sublabel-text").text(RED._("sidebar.project.projectSettings.packageCreate"));
packageFileSubLabel.show();
}
@ -754,7 +753,7 @@ RED.projects.settings = (function() {
// credentialStateLabel.parent().hide();
credentialStateLabel.addClass("uneditable-input");
$(".user-settings-row-credentials").show();
$(".red-ui-settings-row-credentials").show();
credentialStateLabel.css('height','auto');
credentialFormRows.hide();
credentialSecretButtons.show();
@ -763,19 +762,19 @@ RED.projects.settings = (function() {
var row;
// Flow files
row = $('<div class="user-settings-row"></div>').appendTo(filesContainer);
row = $('<div class="red-ui-settings-row"></div>').appendTo(filesContainer);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.package")).appendTo(row);
var packageFileLabel = $('<div class="uneditable-input" style="padding:0">').appendTo(row);
var packageFileLabelText = $('<span style="display:inline-block; padding: 6px">').text(activeProject.files.package||"package.json").appendTo(packageFileLabel);
var packageFileInput = $('<input type="hidden">').val(activeProject.files.package||"package.json").appendTo(packageFileLabel);
var packageFileInputSearch = $('<button type="button" class="editor-button toggle single" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; width: 36px; height: 34px; position: absolute; top: -1px; right: -1px;"><i class="fa fa-folder-open-o"></i></button>')
var packageFileInputSearch = $('<button type="button" class="red-ui-button toggle single" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; width: 36px; height: 34px; position: absolute; top: -1px; right: -1px;"><i class="fa fa-folder-open-o"></i></button>')
.hide()
.appendTo(packageFileLabel)
.click(function(e) {
.on("click", function(e) {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
packageFileLabel.find('.project-file-listing-container').slideUp(200,function() {
packageFileLabel.find('.red-ui-projects-file-listing-container').slideUp(200,function() {
$(this).remove();
packageFileLabel.css('height','');
});
@ -796,7 +795,7 @@ RED.projects.settings = (function() {
packageFileSubLabel.hide();
}
if (close) {
$(packageFileInputSearch).click();
$(packageFileInputSearch).trigger("click");
}
checkFiles();
});
@ -808,9 +807,9 @@ RED.projects.settings = (function() {
}
})
RED.popover.tooltip(packageFileInputSearch,RED._("sidebar.project.projectSettings.selectFile"));
var packageFileSubLabel = $('<label style="margin-left: 110px" class="projects-edit-form-sublabel"><small><span class="form-warning"><i class="fa fa-warning"></i> <span class="projects-edit-form-sublabel-text"></span></small></label>').appendTo(row).hide();
var packageFileSubLabel = $('<label style="margin-left: 110px" class="red-ui-projects-edit-form-sublabel"><small><span class="form-warning"><i class="fa fa-warning"></i> <span class="red-ui-projects-edit-form-sublabel-text"></span></small></label>').appendTo(row).hide();
if (!activeProject.files.package) {
packageFileSubLabel.find(".projects-edit-form-sublabel-text").text(RED._("sidebar.project.projectSettings.fileNotExist"));
packageFileSubLabel.find(".red-ui-projects-edit-form-sublabel-text").text(RED._("sidebar.project.projectSettings.fileNotExist"));
packageFileSubLabel.show();
}
@ -819,7 +818,7 @@ RED.projects.settings = (function() {
var projectRoot = projectPackage.substring(0,projectPackage.length - 12);
// Flow files
row = $('<div class="user-settings-row"></div>').appendTo(filesContainer);
row = $('<div class="red-ui-settings-row"></div>').appendTo(filesContainer);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.flow")).appendTo(row);
var flowFileLabel = $('<div class="uneditable-input" style="padding:0">').appendTo(row);
var flowFileLabelPrefixText = $('<span style="display:inline-block; padding: 6px 0 6px 6px">').text(projectRoot).appendTo(flowFileLabel);
@ -838,13 +837,13 @@ RED.projects.settings = (function() {
});
}
var flowFileInput = $('<input type="text" style="padding-left:1px; margin-top: -2px; margin-bottom: 0;border: none;">').val(flowFileName).hide().appendTo(flowFileLabel);
var flowFileInputSearch = $('<button type="button" class="editor-button toggle single" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; width: 36px; height: 34px; position: absolute; top: -1px; right: -1px;"><i class="fa fa-folder-open-o"></i></button>')
var flowFileInputSearch = $('<button type="button" class="red-ui-button toggle single" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; width: 36px; height: 34px; position: absolute; top: -1px; right: -1px;"><i class="fa fa-folder-open-o"></i></button>')
.hide()
.appendTo(flowFileLabel)
.click(function(e) {
.on("click", function(e) {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
flowFileLabel.find('.project-file-listing-container').slideUp(200,function() {
flowFileLabel.find('.red-ui-projects-file-listing-container').slideUp(200,function() {
$(this).remove();
flowFileLabel.css('height','');
});
@ -865,7 +864,7 @@ RED.projects.settings = (function() {
}
if (isDblClick) {
$(flowFileInputSearch).click();
$(flowFileInputSearch).trigger("click");
}
checkFiles();
}
@ -879,7 +878,7 @@ RED.projects.settings = (function() {
})
RED.popover.tooltip(flowFileInputSearch,RED._("sidebar.project.projectSettings.selectFile"));
row = $('<div class="user-settings-row"></div>').appendTo(filesContainer);
row = $('<div class="red-ui-settings-row"></div>').appendTo(filesContainer);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.credentials")).appendTo(row);
var credFileName = "flows_cred.json";
@ -942,7 +941,7 @@ RED.projects.settings = (function() {
// }
row = $('<div class="user-settings-row"></div>').appendTo(filesContainer);
row = $('<div class="red-ui-settings-row"></div>').appendTo(filesContainer);
$('<label></label>').appendTo(row);
var credentialStateLabel = $('<span><i class="user-settings-credentials-state-icon fa"></i> <span class="user-settings-credentials-state"></span></span>').appendTo(row);
@ -950,9 +949,9 @@ RED.projects.settings = (function() {
credentialStateLabel.css('color','#666');
credentialSecretButtons.css('vertical-align','top');
var credentialSecretResetButton = $('<button type="button" class="editor-button" style="vertical-align: top; width: 36px; margin-bottom: 10px"><i class="fa fa-trash-o"></i></button>')
var credentialSecretResetButton = $('<button type="button" class="red-ui-button" style="vertical-align: top; width: 36px; margin-bottom: 10px"><i class="fa fa-trash-o"></i></button>')
.appendTo(credentialSecretButtons)
.click(function(e) {
.on("click", function(e) {
e.preventDefault();
if (!$(this).hasClass('selected')) {
credentialSecretNewInput.val("");
@ -974,9 +973,9 @@ RED.projects.settings = (function() {
});
RED.popover.tooltip(credentialSecretResetButton,RED._("sidebar.project.projectSettings.resetTheEncryptionKey"));
var credentialSecretEditButton = $('<button type="button" class="editor-button" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; vertical-align: top; width: 36px; margin-bottom: 10px"><i class="fa fa-pencil"></i></button>')
var credentialSecretEditButton = $('<button type="button" class="red-ui-button" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; vertical-align: top; width: 36px; margin-bottom: 10px"><i class="fa fa-pencil"></i></button>')
.appendTo(credentialSecretButtons)
.click(function(e) {
.on("click", function(e) {
e.preventDefault();
if (!$(this).hasClass('selected')) {
credentialSecretExistingInput.val("");
@ -1006,7 +1005,7 @@ RED.projects.settings = (function() {
RED.popover.tooltip(credentialSecretEditButton,RED._("sidebar.project.projectSettings.changeTheEncryptionKey"));
row = $('<div class="user-settings-row user-settings-row-credentials"></div>').hide().appendTo(filesContainer);
row = $('<div class="red-ui-settings-row red-ui-settings-row-credentials"></div>').hide().appendTo(filesContainer);
@ -1016,7 +1015,7 @@ RED.projects.settings = (function() {
var credentialChangeLabel = $('<div style="margin: 20px 0 10px 5px;">' + RED._("sidebar.project.projectSettings.changeTheEncryptionKey") + '</div>').hide().appendTo(credentialFormRows);
var credentialResetLabel = $('<div style="margin: 20px 0 10px 5px;">' + RED._("sidebar.project.projectSettings.resetTheEncryptionKey") + '</div>').hide().appendTo(credentialFormRows);
var credentialSecretExistingRow = $('<div class="user-settings-row user-settings-row-credentials"></div>').appendTo(credentialFormRows);
var credentialSecretExistingRow = $('<div class="red-ui-settings-row red-ui-settings-row-credentials"></div>').appendTo(credentialFormRows);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.currentKey")).appendTo(credentialSecretExistingRow);
var credentialSecretExistingInput = $('<input type="password">').appendTo(credentialSecretExistingRow)
.on("change keyup paste",function() {
@ -1027,7 +1026,7 @@ RED.projects.settings = (function() {
checkFiles();
});
var credentialSecretNewRow = $('<div class="user-settings-row user-settings-row-credentials"></div>').appendTo(credentialFormRows);
var credentialSecretNewRow = $('<div class="red-ui-settings-row red-ui-settings-row-credentials"></div>').appendTo(credentialFormRows);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.newKey")).appendTo(credentialSecretNewRow);
@ -1051,11 +1050,11 @@ RED.projects.settings = (function() {
credentialStateLabel.css('height','');
flowFileInputSearch.removeClass('selected');
flowFileLabel.find('.project-file-listing-container').remove();
flowFileLabel.find('.red-ui-projects-file-listing-container').remove();
flowFileLabel.css('height','');
flowFileLabel.css('color','');
$(".user-settings-row-credentials").hide();
$(".red-ui-settings-row-credentials").hide();
credentialFormRows.hide();
credentialSecretButtons.hide();
credentialSecretResetButton.removeClass("selected");
@ -1065,9 +1064,9 @@ RED.projects.settings = (function() {
}
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin-right:0;"></span>').hide().appendTo(filesContainer);
$('<button type="button" class="editor-button">' + RED._("common.label.cancel") + '</button>')
$('<button type="button" class="red-ui-button">' + RED._("common.label.cancel") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
var projectPackage = activeProject.files.package||"package.json";
var projectRoot = projectPackage.substring(0,projectPackage.length - 12);
@ -1075,7 +1074,7 @@ RED.projects.settings = (function() {
credFileLabelPrefixText.text(projectRoot);
packageFileLabelText.text(activeProject.files.package||"package.json");
if (!activeProject.files.package) {
packageFileSubLabel.find(".projects-edit-form-sublabel-text").text(RED._("sidebar.project.projectSettings.fileNotExist"));
packageFileSubLabel.find(".red-ui-projects-edit-form-sublabel-text").text(RED._("sidebar.project.projectSettings.fileNotExist"));
packageFileSubLabel.show();
} else {
packageFileSubLabel.hide();
@ -1084,9 +1083,9 @@ RED.projects.settings = (function() {
credFileLabelText.text(credFileName);
hideEditForm();
});
var saveButton = $('<button type="button" class="editor-button">' + RED._("common.label.save") + '</button>')
var saveButton = $('<button type="button" class="red-ui-button">' + RED._("common.label.save") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
var spinner = utils.addSpinnerOverlay(filesContainer);
var done = function(err) {
@ -1179,10 +1178,10 @@ RED.projects.settings = (function() {
}
function createLocalBranchListSection(activeProject,pane) {
var localBranchContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
var localBranchContainer = $('<div class="red-ui-settings-section"></div>').appendTo(pane);
$('<h4></h4>').text(RED._("sidebar.project.projectSettings.branches")).appendTo(localBranchContainer);
var row = $('<div class="user-settings-row projects-dialog-list"></div>').appendTo(localBranchContainer);
var row = $('<div class="red-ui-settings-row red-ui-projects-dialog-list"></div>').appendTo(localBranchContainer);
var branchList = $('<ol>').appendTo(row).editableList({
@ -1190,7 +1189,7 @@ RED.projects.settings = (function() {
addButton: false,
scrollOnAdd: false,
addItem: function(row,index,entry) {
var container = $('<div class="projects-dialog-list-entry">').appendTo(row);
var container = $('<div class="red-ui-projects-dialog-list-entry">').appendTo(row);
if (entry.empty) {
container.addClass('red-ui-search-empty');
container.text(RED._("sidebar.project.projectSettings.noBranches"));
@ -1220,11 +1219,11 @@ RED.projects.settings = (function() {
if (!entry.current) {
var tools = $('<span class="entry-tools">').appendTo(container);
$('<button class="editor-button editor-button-small"><i class="fa fa-trash"></i></button>')
$('<button class="red-ui-button red-ui-button-small"><i class="fa fa-trash"></i></button>')
.appendTo(tools)
.click(function(e) {
.on("click", function(e) {
e.preventDefault();
var spinner = utils.addSpinnerOverlay(row).addClass('projects-dialog-spinner-contain');
var spinner = utils.addSpinnerOverlay(row).addClass('red-ui-component-spinner-contain');
var notification = RED.notify(RED._("sidebar.project.projectSettings.deleteConfirm", { name: entry.name }), {
type: "warning",
modal: true,
@ -1317,20 +1316,20 @@ RED.projects.settings = (function() {
createLocalBranchListSection(activeProject,pane);
var repoContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
var repoContainer = $('<div class="red-ui-settings-section"></div>').appendTo(pane);
var title = $('<h4></h4>').text(RED._("sidebar.project.projectSettings.gitRemotes")).appendTo(repoContainer);
var editRepoButton = $('<button class="editor-button editor-button-small" style="float: right; margin-right: 10px;">' + RED._("sidebar.project.projectSettings.addRemote") + '</button>')
var editRepoButton = $('<button class="red-ui-button red-ui-button-small" style="float: right; margin-right: 10px;">' + RED._("sidebar.project.projectSettings.addRemote") + '</button>')
.appendTo(title)
.click(function(evt) {
.on("click", function(evt) {
editRepoButton.attr('disabled',true);
addRemoteDialog.slideDown(200, function() {
addRemoteDialog[0].scrollIntoView();
if (isEmpty) {
remoteNameInput.val('origin');
remoteURLInput.focus();
remoteURLInput.trigger("focus");
} else {
remoteNameInput.focus();
remoteNameInput.trigger("focus");
}
validateForm();
});
@ -1339,16 +1338,16 @@ RED.projects.settings = (function() {
var emptyItem = { empty: true };
var isEmpty = true;
var row = $('<div class="user-settings-row"></div>').appendTo(repoContainer);
var addRemoteDialog = $('<div class="projects-dialog-list-dialog"></div>').hide().appendTo(row);
row = $('<div class="user-settings-row projects-dialog-list"></div>').appendTo(repoContainer);
var row = $('<div class="red-ui-settings-row"></div>').appendTo(repoContainer);
var addRemoteDialog = $('<div class="red-ui-projects-dialog-list-dialog"></div>').hide().appendTo(row);
row = $('<div class="red-ui-settings-row red-ui-projects-dialog-list"></div>').appendTo(repoContainer);
var remotesList = $('<ol>').appendTo(row);
remotesList.editableList({
addButton: false,
height: 'auto',
addItem: function(row,index,entry) {
var container = $('<div class="projects-dialog-list-entry">').appendTo(row);
var container = $('<div class="red-ui-projects-dialog-list-entry">').appendTo(row);
if (entry.empty) {
container.addClass('red-ui-search-empty');
container.text(RED._("sidebar.project.projectSettings.noRemotes"));
@ -1365,11 +1364,11 @@ RED.projects.settings = (function() {
}
var tools = $('<span class="entry-tools">').appendTo(container);
$('<button class="editor-button editor-button-small"><i class="fa fa-trash"></i></button>')
$('<button class="red-ui-button red-ui-button-small"><i class="fa fa-trash"></i></button>')
.appendTo(tools)
.click(function(e) {
.on("click", function(e) {
e.preventDefault();
var spinner = utils.addSpinnerOverlay(row).addClass('projects-dialog-spinner-contain');
var spinner = utils.addSpinnerOverlay(row).addClass('red-ui-component-spinner-contain');
var notification = RED.notify(RED._("sidebar.project.projectSettings.deleteRemoteConfrim", { name: entry.name }), {
type: "warning",
modal: true,
@ -1462,22 +1461,22 @@ RED.projects.settings = (function() {
var remoteNameInputChanged = false;
var remoteURLInputChanged = false;
$('<div class="projects-dialog-list-dialog-header">').text(RED._('sidebar.project.projectSettings.addRemote2')).appendTo(addRemoteDialog);
$('<div class="red-ui-projects-dialog-list-dialog-header">').text(RED._('sidebar.project.projectSettings.addRemote2')).appendTo(addRemoteDialog);
row = $('<div class="user-settings-row"></div>').appendTo(addRemoteDialog);
row = $('<div class="red-ui-settings-row"></div>').appendTo(addRemoteDialog);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.remoteName")).appendTo(row);
var remoteNameInput = $('<input type="text">').appendTo(row).on("change keyup paste",function() {
remoteNameInputChanged = true;
validateForm();
});
$('<label class="projects-edit-form-sublabel"><small>' + RED._("sidebar.project.projectSettings.nameRule") + '</small></label>').appendTo(row).find("small");
row = $('<div class="user-settings-row"></div>').appendTo(addRemoteDialog);
$('<label class="red-ui-projects-edit-form-sublabel"><small>' + RED._("sidebar.project.projectSettings.nameRule") + '</small></label>').appendTo(row).find("small");
row = $('<div class="red-ui-settings-row"></div>').appendTo(addRemoteDialog);
$('<label for=""></label>').text(RED._("sidebar.project.projectSettings.url")).appendTo(row);
var remoteURLInput = $('<input type="text">').appendTo(row).on("change keyup paste",function() {
remoteURLInputChanged = true;
validateForm()
});
var remoteURLLabel = $('<label class="projects-edit-form-sublabel"><small>' + RED._("sidebar.project.projectSettings.urlRule") +'</small></label>').appendTo(row).find("small");
var remoteURLLabel = $('<label class="red-ui-projects-edit-form-sublabel"><small>' + RED._("sidebar.project.projectSettings.urlRule") +'</small></label>').appendTo(row).find("small");
var hideEditForm = function() {
editRepoButton.attr('disabled',false);
@ -1491,17 +1490,17 @@ RED.projects.settings = (function() {
}
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin: 10px;"></span>')
.appendTo(addRemoteDialog);
$('<button class="editor-button">' + RED._("common.label.cancel") + '</button>')
$('<button class="red-ui-button">' + RED._("common.label.cancel") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
hideEditForm();
});
var saveButton = $('<button class="editor-button">' + RED._("sidebar.project.projectSettings.addRemote2") + '</button>')
var saveButton = $('<button class="red-ui-button">' + RED._("sidebar.project.projectSettings.addRemote2") + '</button>')
.appendTo(formButtons)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
var spinner = utils.addSpinnerOverlay(addRemoteDialog).addClass('projects-dialog-spinner-contain');
var spinner = utils.addSpinnerOverlay(addRemoteDialog).addClass('red-ui-component-spinner-contain');
var payload = {
name: remoteNameInput.val(),
@ -1577,7 +1576,7 @@ RED.projects.settings = (function() {
function createSettingsPane(activeProject) {
var pane = $('<div id="project-settings-tab-settings" class="project-settings-tab-pane node-help"></div>');
var pane = $('<div id="red-ui-project-settings-tab-settings" class="red-ui-project-settings-tab-pane red-ui-help"></div>');
createFilesSection(activeProject,pane);
// createLocalRepositorySection(activeProject,pane);
createRemoteRepositorySection(activeProject,pane);

View File

@ -26,15 +26,15 @@ RED.projects.userSettings = (function() {
var title = $('<h3></h3>').text(RED._("editor:sidebar.project.userSettings.committerDetail")).appendTo(pane);
var gitconfigContainer = $('<div class="user-settings-section"></div>').appendTo(pane);
$('<div style="color:#aaa;"></div>').appendTo(gitconfigContainer).text(RED._("editor:sidebar.project.userSettings.committerTip"));
var gitconfigContainer = $('<div class="red-ui-settings-section"></div>').appendTo(pane);
$('<div class="red-ui-settings-section-description"></div>').appendTo(gitconfigContainer).text(RED._("editor:sidebar.project.userSettings.committerTip"));
var row = $('<div class="user-settings-row"></div>').appendTo(gitconfigContainer);
var row = $('<div class="red-ui-settings-row"></div>').appendTo(gitconfigContainer);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.userName")).appendTo(row);
gitUsernameInput = $('<input type="text">').appendTo(row);
gitUsernameInput.val(currentGitSettings.user.name||"");
row = $('<div class="user-settings-row"></div>').appendTo(gitconfigContainer);
row = $('<div class="red-ui-settings-row"></div>').appendTo(gitconfigContainer);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.email")).appendTo(row);
gitEmailInput = $('<input type="text">').appendTo(row);
gitEmailInput.val(currentGitSettings.user.email||"");
@ -42,20 +42,20 @@ RED.projects.userSettings = (function() {
function createSSHKeySection(pane) {
var container = $('<div class="user-settings-section"></div>').appendTo(pane);
var container = $('<div class="red-ui-settings-section"></div>').appendTo(pane);
var popover;
var title = $('<h3></h3>').text(RED._("editor:sidebar.project.userSettings.sshKeys")).appendTo(container);
var subtitle = $('<div style="color:#aaa;"></div>').appendTo(container).text(RED._("editor:sidebar.project.userSettings.sshKeysTip"));
var subtitle = $('<div class="red-ui-settings-section-description"></div>').appendTo(container).text(RED._("editor:sidebar.project.userSettings.sshKeysTip"));
var addKeyButton = $('<button id="user-settings-gitconfig-add-key" class="editor-button editor-button-small" style="float: right; margin-right: 10px;">'+RED._("editor:sidebar.project.userSettings.add")+'</button>')
var addKeyButton = $('<button id="user-settings-gitconfig-add-key" class="red-ui-button red-ui-button-small" style="float: right; margin-right: 10px;">'+RED._("editor:sidebar.project.userSettings.add")+'</button>')
.appendTo(subtitle)
.click(function(evt) {
.on("click", function(evt) {
addKeyButton.attr('disabled',true);
saveButton.attr('disabled',true);
// bg.children().removeClass("selected");
// addLocalButton.click();
// addLocalButton.trigger("click");
addKeyDialog.slideDown(200);
keyNameInput.focus();
keyNameInput.trigger("focus");
});
var validateForm = function() {
@ -89,18 +89,18 @@ RED.projects.userSettings = (function() {
}
};
var row = $('<div class="user-settings-row"></div>').appendTo(container);
var addKeyDialog = $('<div class="projects-dialog-list-dialog"></div>').hide().appendTo(row);
$('<div class="projects-dialog-list-dialog-header">').text(RED._("editor:sidebar.project.userSettings.addSshKey")).appendTo(addKeyDialog);
var row = $('<div class="red-ui-settings-row"></div>').appendTo(container);
var addKeyDialog = $('<div class="red-ui-projects-dialog-list-dialog"></div>').hide().appendTo(row);
$('<div class="red-ui-projects-dialog-list-dialog-header">').text(RED._("editor:sidebar.project.userSettings.addSshKey")).appendTo(addKeyDialog);
var addKeyDialogBody = $('<div>').appendTo(addKeyDialog);
row = $('<div class="user-settings-row"></div>').appendTo(addKeyDialogBody);
$('<div style="color:#aaa;"></div>').appendTo(row).text(RED._("editor:sidebar.project.userSettings.addSshKeyTip"));
row = $('<div class="red-ui-settings-row"></div>').appendTo(addKeyDialogBody);
$('<div class="red-ui-settings-section-description"></div>').appendTo(row).text(RED._("editor:sidebar.project.userSettings.addSshKeyTip"));
// var bg = $('<div></div>',{class:"button-group", style:"text-align: center"}).appendTo(row);
// var addLocalButton = $('<button class="editor-button toggle selected">use local key</button>').appendTo(bg);
// var uploadButton = $('<button class="editor-button toggle">upload key</button>').appendTo(bg);
// var generateButton = $('<button class="editor-button toggle">generate key</button>').appendTo(bg);
// bg.children().click(function(e) {
// var addLocalButton = $('<button class="red-ui-button toggle selected">use local key</button>').appendTo(bg);
// var uploadButton = $('<button class="red-ui-button toggle">upload key</button>').appendTo(bg);
// var generateButton = $('<button class="red-ui-button toggle">generate key</button>').appendTo(bg);
// bg.children().on("click", function(e) {
// e.preventDefault();
// if ($(this).hasClass("selected")) {
// return;
@ -124,40 +124,40 @@ RED.projects.userSettings = (function() {
// })
row = $('<div class="user-settings-row"></div>').appendTo(addKeyDialogBody);
row = $('<div class="red-ui-settings-row"></div>').appendTo(addKeyDialogBody);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.name")).appendTo(row);
var keyNameInputChanged = false;
var keyNameInput = $('<input type="text">').appendTo(row).on("change keyup paste",function() {
keyNameInputChanged = true;
validateForm();
});
$('<label class="projects-edit-form-sublabel"><small>'+RED._("editor:sidebar.project.userSettings.nameRule")+'</small></label>').appendTo(row).find("small");
$('<label class="red-ui-projects-edit-form-sublabel"><small>'+RED._("editor:sidebar.project.userSettings.nameRule")+'</small></label>').appendTo(row).find("small");
var generateKeyPane = $('<div>').appendTo(addKeyDialogBody);
row = $('<div class="user-settings-row"></div>').appendTo(generateKeyPane);
row = $('<div class="red-ui-settings-row"></div>').appendTo(generateKeyPane);
$('<label for=""></label>').text(RED._("editor:sidebar.project.userSettings.passphrase")).appendTo(row);
var passphraseInput = $('<input type="password">').appendTo(row).on("change keyup paste",validateForm);
var passphraseInputSubLabel = $('<label class="projects-edit-form-sublabel"><small>'+RED._("editor:sidebar.project.userSettings.optional")+'</small></label>').appendTo(row).find("small");
var passphraseInputSubLabel = $('<label class="red-ui-projects-edit-form-sublabel"><small>'+RED._("editor:sidebar.project.userSettings.optional")+'</small></label>').appendTo(row).find("small");
// var addLocalKeyPane = $('<div>').hide().appendTo(addKeyDialogBody);
// row = $('<div class="user-settings-row"></div>').appendTo(addLocalKeyPane);
// row = $('<div class="red-ui-settings-row"></div>').appendTo(addLocalKeyPane);
// $('<label for=""></label>').text('Public key').appendTo(row);
// var localPublicKeyPathInput = $('<input type="text">').appendTo(row).on("change keyup paste",validateForm);
// $('<label class="projects-edit-form-sublabel"><small>Public key file path, for example: ~/.ssh/id_rsa.pub</small></label>').appendTo(row).find("small");
// row = $('<div class="user-settings-row"></div>').appendTo(addLocalKeyPane);
// $('<label class="red-ui-projects-edit-form-sublabel"><small>Public key file path, for example: ~/.ssh/id_rsa.pub</small></label>').appendTo(row).find("small");
// row = $('<div class="red-ui-settings-row"></div>').appendTo(addLocalKeyPane);
// $('<label for=""></label>').text('Private key').appendTo(row);
// var localPrivateKeyPathInput = $('<input type="text">').appendTo(row).on("change keyup paste",validateForm);
// $('<label class="projects-edit-form-sublabel"><small>Private key file path, for example: ~/.ssh/id_rsa</small></label>').appendTo(row).find("small");
// $('<label class="red-ui-projects-edit-form-sublabel"><small>Private key file path, for example: ~/.ssh/id_rsa</small></label>').appendTo(row).find("small");
//
// var uploadKeyPane = $('<div>').hide().appendTo(addKeyDialogBody);
// row = $('<div class="user-settings-row"></div>').appendTo(uploadKeyPane);
// row = $('<div class="red-ui-settings-row"></div>').appendTo(uploadKeyPane);
// $('<label for=""></label>').text('Public key').appendTo(row);
// var publicKeyInput = $('<textarea>').appendTo(row).on("change keyup paste",validateForm);
// $('<label class="projects-edit-form-sublabel"><small>Paste in public key contents, for example: ~/.ssh/id_rsa.pub</small></label>').appendTo(row).find("small");
// row = $('<div class="user-settings-row"></div>').appendTo(uploadKeyPane);
// $('<label class="red-ui-projects-edit-form-sublabel"><small>Paste in public key contents, for example: ~/.ssh/id_rsa.pub</small></label>').appendTo(row).find("small");
// row = $('<div class="red-ui-settings-row"></div>').appendTo(uploadKeyPane);
// $('<label for=""></label>').text('Private key').appendTo(row);
// var privateKeyInput = $('<textarea>').appendTo(row).on("change keyup paste",validateForm);
// $('<label class="projects-edit-form-sublabel"><small>Paste in private key contents, for example: ~/.ssh/id_rsa</small></label>').appendTo(row).find("small");
// $('<label class="red-ui-projects-edit-form-sublabel"><small>Paste in private key contents, for example: ~/.ssh/id_rsa</small></label>').appendTo(row).find("small");
@ -179,17 +179,17 @@ RED.projects.userSettings = (function() {
}
}
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin: 10px;"></span>').appendTo(addKeyDialog);
$('<button class="editor-button">'+RED._("editor:sidebar.project.userSettings.cancel")+'</button>')
$('<button class="red-ui-button">'+RED._("editor:sidebar.project.userSettings.cancel")+'</button>')
.appendTo(formButtons)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
hideEditForm();
});
var saveButton = $('<button class="editor-button">'+RED._("editor:sidebar.project.userSettings.generate")+'</button>')
var saveButton = $('<button class="red-ui-button">'+RED._("editor:sidebar.project.userSettings.generate")+'</button>')
.appendTo(formButtons)
.click(function(evt) {
.on("click", function(evt) {
evt.preventDefault();
var spinner = utils.addSpinnerOverlay(addKeyDialog).addClass('projects-dialog-spinner-contain');
var spinner = utils.addSpinnerOverlay(addKeyDialog).addClass('red-ui-component-spinner-contain');
var payload = {
name: keyNameInput.val()
};
@ -239,12 +239,12 @@ RED.projects.userSettings = (function() {
},payload);
});
row = $('<div class="user-settings-row projects-dialog-list"></div>').appendTo(container);
row = $('<div class="red-ui-settings-row red-ui-projects-dialog-list"></div>').appendTo(container);
var emptyItem = { empty: true };
var expandKey = function(container,entry) {
var row = $('<div class="projects-dialog-ssh-public-key">',{style:"position:relative"}).appendTo(container);
var row = $('<div class="red-ui-projects-dialog-ssh-public-key">',{style:"position:relative"}).appendTo(container);
var keyBox = $('<pre>',{style:"min-height: 80px"}).appendTo(row);
var spinner = utils.addSpinnerOverlay(keyBox).addClass('projects-dialog-spinner-contain');
var spinner = utils.addSpinnerOverlay(keyBox).addClass('red-ui-component-spinner-contain');
var options = {
url: 'settings/user/keys/'+entry.name,
type: "GET",
@ -264,9 +264,9 @@ RED.projects.userSettings = (function() {
utils.sendRequest(options);
var formButtons = $('<span class="button-row" style="position: relative; float: right; margin: 10px;"></span>').appendTo(row);
$('<button class="editor-button editor-button-small">'+RED._("editor:sidebar.project.userSettings.copyPublicKey")+'</button>')
$('<button class="red-ui-button red-ui-button-small">'+RED._("editor:sidebar.project.userSettings.copyPublicKey")+'</button>')
.appendTo(formButtons)
.click(function(evt) {
.on("click", function(evt) {
try {
evt.stopPropagation();
evt.preventDefault();
@ -281,23 +281,23 @@ RED.projects.userSettings = (function() {
return row;
}
var keyList = $('<ol class="projects-dialog-ssh-key-list">').appendTo(row).editableList({
var keyList = $('<ol class="red-ui-projects-dialog-ssh-key-list">').appendTo(row).editableList({
height: 'auto',
addButton: false,
scrollOnAdd: false,
addItem: function(row,index,entry) {
var container = $('<div class="projects-dialog-list-entry">').appendTo(row);
var container = $('<div class="red-ui-projects-dialog-list-entry">').appendTo(row);
if (entry.empty) {
container.addClass('red-ui-search-empty');
container.text(RED._("editor:sidebar.project.userSettings.noSshKeys"));
return;
}
var topRow = $('<div class="projects-dialog-ssh-key-header">').appendTo(container);
var topRow = $('<div class="red-ui-projects-dialog-ssh-key-header">').appendTo(container);
$('<span class="entry-icon"><i class="fa fa-key"></i></span>').appendTo(topRow);
$('<span class="entry-name">').text(entry.name).appendTo(topRow);
var tools = $('<span class="button-row entry-tools">').appendTo(topRow);
var expandedRow;
topRow.click(function(e) {
topRow.on("click", function(e) {
if (expandedRow) {
expandedRow.slideUp(200,function() {
expandedRow.remove();
@ -308,11 +308,11 @@ RED.projects.userSettings = (function() {
}
})
if (!entry.system) {
$('<button class="editor-button editor-button-small"><i class="fa fa-trash"></i></button>')
$('<button class="red-ui-button red-ui-button-small"><i class="fa fa-trash"></i></button>')
.appendTo(tools)
.click(function(e) {
.on("click", function(e) {
e.stopPropagation();
var spinner = utils.addSpinnerOverlay(row).addClass('projects-dialog-spinner-contain');
var spinner = utils.addSpinnerOverlay(row).addClass('red-ui-component-spinner-contain');
var notification = RED.notify(RED._("editor:sidebar.project.userSettings.deleteConfirm", {name:entry.name}), {
type: 'warning',
modal: true,
@ -389,7 +389,7 @@ RED.projects.userSettings = (function() {
}
function createSettingsPane(activeProject) {
var pane = $('<div id="user-settings-tab-gitconfig" class="project-settings-tab-pane node-help"></div>');
var pane = $('<div id="red-ui-settings-tab-gitconfig" class="project-settings-tab-pane red-ui-help"></div>');
createGitUserSection(pane);
createSSHKeySection(pane);
return pane;

Some files were not shown because too many files have changed in this diff Show More