2013-09-05 16:02:48 +02:00
|
|
|
/**
|
2015-02-26 22:29:56 +01:00
|
|
|
* Copyright 2013, 2015 IBM Corp.
|
2013-09-05 16:02:48 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
**/
|
2014-08-08 01:01:35 +02:00
|
|
|
RED.editor = (function() {
|
2013-09-05 16:02:48 +02:00
|
|
|
var editing_node = null;
|
2015-11-06 12:08:07 +01:00
|
|
|
var editing_config_node = null;
|
2015-10-23 23:14:21 +02:00
|
|
|
var subflowEditor;
|
2013-09-05 16:02:48 +02:00
|
|
|
|
2014-05-07 20:19:08 +02:00
|
|
|
function getCredentialsURL(nodeType, nodeID) {
|
|
|
|
var dashedType = nodeType.replace(/\s+/g, '-');
|
|
|
|
return 'credentials/' + dashedType + "/" + nodeID;
|
|
|
|
}
|
2014-05-16 09:34:23 +02:00
|
|
|
|
2014-05-27 17:06:25 +02:00
|
|
|
/**
|
2015-05-07 17:44:55 +02:00
|
|
|
* Validate a node
|
2014-05-27 17:06:25 +02:00
|
|
|
* @param node - the node being validated
|
|
|
|
* @returns {boolean} whether the node is valid. Sets node.dirty if needed
|
|
|
|
*/
|
|
|
|
function validateNode(node) {
|
2015-03-20 00:11:55 +01:00
|
|
|
var oldValue = node.valid;
|
2015-03-20 22:20:04 +01:00
|
|
|
var oldChanged = node.changed;
|
2015-03-20 00:11:55 +01:00
|
|
|
node.valid = true;
|
|
|
|
var subflow;
|
|
|
|
var isValid;
|
2015-03-20 22:20:04 +01:00
|
|
|
var hasChanged;
|
2015-03-20 00:11:55 +01:00
|
|
|
if (node.type.indexOf("subflow:")===0) {
|
|
|
|
subflow = RED.nodes.subflow(node.type.substring(8));
|
|
|
|
isValid = subflow.valid;
|
2015-03-20 22:20:04 +01:00
|
|
|
hasChanged = subflow.changed;
|
2015-03-20 00:11:55 +01:00
|
|
|
if (isValid === undefined) {
|
|
|
|
isValid = validateNode(subflow);
|
2015-03-20 22:20:04 +01:00
|
|
|
hasChanged = subflow.changed;
|
2015-03-20 00:11:55 +01:00
|
|
|
}
|
|
|
|
node.valid = isValid;
|
2015-07-30 12:03:37 +02:00
|
|
|
node.changed = node.changed || hasChanged;
|
2015-03-20 00:11:55 +01:00
|
|
|
} else if (node._def) {
|
2015-03-12 00:37:44 +01:00
|
|
|
node.valid = validateNodeProperties(node, node._def.defaults, node);
|
|
|
|
if (node._def._creds) {
|
|
|
|
node.valid = node.valid && validateNodeProperties(node, node._def.credentials, node._def._creds);
|
|
|
|
}
|
2015-03-20 00:11:55 +01:00
|
|
|
} else if (node.type == "subflow") {
|
|
|
|
var subflowNodes = RED.nodes.filterNodes({z:node.id});
|
|
|
|
for (var i=0;i<subflowNodes.length;i++) {
|
|
|
|
isValid = subflowNodes[i].valid;
|
2015-03-20 22:20:04 +01:00
|
|
|
hasChanged = subflowNodes[i].changed;
|
2015-03-20 00:11:55 +01:00
|
|
|
if (isValid === undefined) {
|
|
|
|
isValid = validateNode(subflowNodes[i]);
|
2015-03-20 22:20:04 +01:00
|
|
|
hasChanged = subflowNodes[i].changed;
|
2015-03-20 00:11:55 +01:00
|
|
|
}
|
|
|
|
node.valid = node.valid && isValid;
|
2015-03-20 22:20:04 +01:00
|
|
|
node.changed = node.changed || hasChanged;
|
2015-03-20 00:11:55 +01:00
|
|
|
}
|
|
|
|
var subflowInstances = RED.nodes.filterNodes({type:"subflow:"+node.id});
|
|
|
|
var modifiedTabs = {};
|
|
|
|
for (i=0;i<subflowInstances.length;i++) {
|
|
|
|
subflowInstances[i].valid = node.valid;
|
2015-07-30 12:03:37 +02:00
|
|
|
subflowInstances[i].changed = subflowInstances[i].changed || node.changed;
|
2015-03-20 00:11:55 +01:00
|
|
|
subflowInstances[i].dirty = true;
|
|
|
|
modifiedTabs[subflowInstances[i].z] = true;
|
|
|
|
}
|
|
|
|
Object.keys(modifiedTabs).forEach(function(id) {
|
|
|
|
var subflow = RED.nodes.subflow(id);
|
|
|
|
if (subflow) {
|
|
|
|
validateNode(subflow);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-03-20 22:20:04 +01:00
|
|
|
if (oldValue !== node.valid || oldChanged !== node.changed) {
|
2015-03-20 00:11:55 +01:00
|
|
|
node.dirty = true;
|
|
|
|
subflow = RED.nodes.subflow(node.z);
|
|
|
|
if (subflow) {
|
|
|
|
validateNode(subflow);
|
2015-03-12 00:37:44 +01:00
|
|
|
}
|
2014-05-27 17:06:25 +02:00
|
|
|
}
|
2015-03-20 00:11:55 +01:00
|
|
|
return node.valid;
|
2014-05-27 17:06:25 +02:00
|
|
|
}
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2014-05-27 17:06:25 +02:00
|
|
|
/**
|
|
|
|
* Validate a node's properties for the given set of property definitions
|
|
|
|
* @param node - the node being validated
|
|
|
|
* @param definition - the node property definitions (either def.defaults or def.creds)
|
|
|
|
* @param properties - the node property values to validate
|
|
|
|
* @returns {boolean} whether the node's properties are valid
|
|
|
|
*/
|
|
|
|
function validateNodeProperties(node, definition, properties) {
|
|
|
|
var isValid = true;
|
|
|
|
for (var prop in definition) {
|
2014-09-22 14:22:23 +02:00
|
|
|
if (definition.hasOwnProperty(prop)) {
|
|
|
|
if (!validateNodeProperty(node, definition, prop, properties[prop])) {
|
|
|
|
isValid = false;
|
|
|
|
}
|
2014-05-27 17:06:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return isValid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Validate a individual node property
|
|
|
|
* @param node - the node being validated
|
|
|
|
* @param definition - the node property definitions (either def.defaults or def.creds)
|
|
|
|
* @param property - the property name being validated
|
|
|
|
* @param value - the property value being validated
|
|
|
|
* @returns {boolean} whether the node proprty is valid
|
|
|
|
*/
|
2014-05-16 09:34:23 +02:00
|
|
|
function validateNodeProperty(node,definition,property,value) {
|
2013-09-05 16:02:48 +02:00
|
|
|
var valid = true;
|
2014-05-16 09:34:23 +02:00
|
|
|
if ("required" in definition[property] && definition[property].required) {
|
2013-09-05 16:02:48 +02:00
|
|
|
valid = value !== "";
|
|
|
|
}
|
2014-05-16 09:34:23 +02:00
|
|
|
if (valid && "validate" in definition[property]) {
|
|
|
|
valid = definition[property].validate.call(node,value);
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2014-05-16 09:34:23 +02:00
|
|
|
if (valid && definition[property].type && RED.nodes.getType(definition[property].type) && !("validate" in definition[property])) {
|
2013-11-17 18:49:32 +01:00
|
|
|
if (!value || value == "_ADD_") {
|
2015-03-09 21:42:23 +01:00
|
|
|
valid = definition[property].hasOwnProperty("required") && !definition[property].required;
|
2013-11-17 18:49:32 +01:00
|
|
|
} else {
|
2013-11-18 22:17:29 +01:00
|
|
|
var v = RED.nodes.node(value).valid;
|
|
|
|
valid = (v==null || v);
|
2013-11-17 18:49:32 +01:00
|
|
|
}
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
return valid;
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2014-05-27 17:06:25 +02:00
|
|
|
/**
|
|
|
|
* Called when the node's properties have changed.
|
|
|
|
* Marks the node as dirty and needing a size check.
|
|
|
|
* Removes any links to non-existant outputs.
|
|
|
|
* @param node - the node that has been updated
|
|
|
|
* @returns {array} the links that were removed due to this update
|
|
|
|
*/
|
2013-09-05 16:02:48 +02:00
|
|
|
function updateNodeProperties(node) {
|
|
|
|
node.resize = true;
|
|
|
|
node.dirty = true;
|
|
|
|
var removedLinks = [];
|
2014-02-25 00:35:11 +01:00
|
|
|
if (node.ports) {
|
|
|
|
if (node.outputs < node.ports.length) {
|
|
|
|
while (node.outputs < node.ports.length) {
|
|
|
|
node.ports.pop();
|
|
|
|
}
|
|
|
|
RED.nodes.eachLink(function(l) {
|
|
|
|
if (l.source === node && l.sourcePort >= node.outputs) {
|
|
|
|
removedLinks.push(l);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (node.outputs > node.ports.length) {
|
|
|
|
while (node.outputs > node.ports.length) {
|
|
|
|
node.ports.push(node.ports.length);
|
|
|
|
}
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2014-02-25 00:35:11 +01:00
|
|
|
}
|
|
|
|
if (node.inputs === 0) {
|
2015-03-16 00:41:16 +01:00
|
|
|
removedLinks.concat(RED.nodes.filterLinks({target:node}));
|
2014-02-25 00:35:11 +01:00
|
|
|
}
|
|
|
|
for (var l=0;l<removedLinks.length;l++) {
|
|
|
|
RED.nodes.removeLink(removedLinks[l]);
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
return removedLinks;
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
function createDialog(){
|
|
|
|
$( "#dialog" ).dialog({
|
|
|
|
modal: true,
|
|
|
|
autoOpen: false,
|
|
|
|
dialogClass: "ui-dialog-no-close",
|
|
|
|
closeOnEscape: false,
|
|
|
|
minWidth: 500,
|
|
|
|
width: 'auto',
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
id: "node-dialog-ok",
|
2015-07-01 00:42:03 +02:00
|
|
|
text: RED._("common.label.ok"),
|
2015-05-26 22:52:23 +02:00
|
|
|
click: function() {
|
|
|
|
if (editing_node) {
|
|
|
|
var changes = {};
|
|
|
|
var changed = false;
|
|
|
|
var wasDirty = RED.nodes.dirty();
|
|
|
|
var d;
|
|
|
|
|
|
|
|
if (editing_node._def.oneditsave) {
|
|
|
|
var oldValues = {};
|
|
|
|
for (d in editing_node._def.defaults) {
|
|
|
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
|
|
if (typeof editing_node[d] === "string" || typeof editing_node[d] === "number") {
|
|
|
|
oldValues[d] = editing_node[d];
|
|
|
|
} else {
|
|
|
|
oldValues[d] = $.extend(true,{},{v:editing_node[d]}).v;
|
|
|
|
}
|
2014-08-08 01:01:35 +02:00
|
|
|
}
|
2013-10-12 22:54:07 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
var rc = editing_node._def.oneditsave.call(editing_node);
|
|
|
|
if (rc === true) {
|
|
|
|
changed = true;
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
for (d in editing_node._def.defaults) {
|
|
|
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
|
|
if (oldValues[d] === null || typeof oldValues[d] === "string" || typeof oldValues[d] === "number") {
|
|
|
|
if (oldValues[d] !== editing_node[d]) {
|
|
|
|
changes[d] = oldValues[d];
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (JSON.stringify(oldValues[d]) !== JSON.stringify(editing_node[d])) {
|
|
|
|
changes[d] = oldValues[d];
|
|
|
|
changed = true;
|
|
|
|
}
|
2014-08-08 01:01:35 +02:00
|
|
|
}
|
2013-10-12 22:54:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
if (editing_node._def.defaults) {
|
|
|
|
for (d in editing_node._def.defaults) {
|
|
|
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
|
|
var input = $("#node-input-"+d);
|
|
|
|
var newValue;
|
|
|
|
if (input.attr('type') === "checkbox") {
|
|
|
|
newValue = input.prop('checked');
|
|
|
|
} else {
|
|
|
|
newValue = input.val();
|
|
|
|
}
|
|
|
|
if (newValue != null) {
|
2015-06-19 21:37:12 +02:00
|
|
|
if (d === "outputs" && (newValue.trim() === "" || isNaN(newValue))) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
if (editing_node[d] != newValue) {
|
|
|
|
if (editing_node._def.defaults[d].type) {
|
|
|
|
if (newValue == "_ADD_") {
|
|
|
|
newValue = "";
|
|
|
|
}
|
|
|
|
// Change to a related config node
|
|
|
|
var configNode = RED.nodes.node(editing_node[d]);
|
|
|
|
if (configNode) {
|
|
|
|
var users = configNode.users;
|
|
|
|
users.splice(users.indexOf(editing_node),1);
|
|
|
|
}
|
|
|
|
configNode = RED.nodes.node(newValue);
|
|
|
|
if (configNode) {
|
|
|
|
configNode.users.push(editing_node);
|
|
|
|
}
|
2014-08-08 01:01:35 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
changes[d] = editing_node[d];
|
|
|
|
editing_node[d] = newValue;
|
|
|
|
changed = true;
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
if (editing_node._def.credentials) {
|
|
|
|
var prefix = 'node-input';
|
|
|
|
var credDefinition = editing_node._def.credentials;
|
|
|
|
var credsChanged = updateNodeCredentials(editing_node,credDefinition,prefix);
|
|
|
|
changed = changed || credsChanged;
|
|
|
|
}
|
2014-05-07 00:42:54 +02:00
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
var removedLinks = updateNodeProperties(editing_node);
|
|
|
|
if (changed) {
|
|
|
|
var wasChanged = editing_node.changed;
|
|
|
|
editing_node.changed = true;
|
|
|
|
RED.nodes.dirty(true);
|
2015-07-30 12:03:37 +02:00
|
|
|
|
|
|
|
var activeSubflow = RED.nodes.subflow(RED.workspaces.active());
|
2015-08-13 23:18:47 +02:00
|
|
|
var subflowInstances = null;
|
2015-07-30 12:03:37 +02:00
|
|
|
if (activeSubflow) {
|
2015-08-13 23:18:47 +02:00
|
|
|
subflowInstances = [];
|
2015-07-30 12:03:37 +02:00
|
|
|
RED.nodes.eachNode(function(n) {
|
|
|
|
if (n.type == "subflow:"+RED.workspaces.active()) {
|
|
|
|
subflowInstances.push({
|
|
|
|
id:n.id,
|
|
|
|
changed:n.changed
|
|
|
|
});
|
|
|
|
n.changed = true;
|
|
|
|
n.dirty = true;
|
|
|
|
updateNodeProperties(n);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
var historyEvent = {
|
|
|
|
t:'edit',
|
|
|
|
node:editing_node,
|
|
|
|
changes:changes,
|
|
|
|
links:removedLinks,
|
|
|
|
dirty:wasDirty,
|
|
|
|
changed:wasChanged
|
|
|
|
};
|
|
|
|
if (subflowInstances) {
|
|
|
|
historyEvent.subflow = {
|
|
|
|
instances:subflowInstances
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RED.history.push(historyEvent);
|
2015-05-26 22:52:23 +02:00
|
|
|
}
|
|
|
|
editing_node.dirty = true;
|
|
|
|
validateNode(editing_node);
|
|
|
|
RED.view.redraw();
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
$( this ).dialog( "close" );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "node-dialog-cancel",
|
2015-07-01 00:42:03 +02:00
|
|
|
text: RED._("common.label.cancel"),
|
2015-05-26 22:52:23 +02:00
|
|
|
click: function() {
|
|
|
|
if (editing_node && editing_node._def) {
|
|
|
|
if (editing_node._def.oneditcancel) {
|
|
|
|
editing_node._def.oneditcancel.call(editing_node);
|
|
|
|
}
|
2015-07-22 23:28:30 +02:00
|
|
|
|
|
|
|
for (var d in editing_node._def.defaults) {
|
|
|
|
if (editing_node._def.defaults.hasOwnProperty(d)) {
|
|
|
|
var def = editing_node._def.defaults[d];
|
|
|
|
if (def.type) {
|
|
|
|
var configTypeDef = RED.nodes.getType(def.type);
|
|
|
|
if (configTypeDef && configTypeDef.exclusive) {
|
|
|
|
var input = $("#node-input-"+d).val()||"";
|
|
|
|
if (input !== "" && !editing_node[d]) {
|
|
|
|
// This node has an exclusive config node that
|
|
|
|
// has just been added. As the user is cancelling
|
|
|
|
// the edit, need to delete the just-added config
|
|
|
|
// node so that it doesn't get orphaned.
|
|
|
|
RED.nodes.remove(input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-08 01:01:35 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
$( this ).dialog( "close" );
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
resize: function(e,ui) {
|
|
|
|
if (editing_node) {
|
|
|
|
$(this).dialog('option',"sizeCache-"+editing_node.type,ui.size);
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
},
|
2015-05-26 22:52:23 +02:00
|
|
|
open: function(e) {
|
|
|
|
var minWidth = $(this).dialog('option','minWidth');
|
|
|
|
if ($(this).outerWidth() < minWidth) {
|
|
|
|
$(this).dialog('option','width',minWidth);
|
|
|
|
} else {
|
|
|
|
$(this).dialog('option','width',$(this).outerWidth());
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
RED.keyboard.disable();
|
|
|
|
if (editing_node) {
|
|
|
|
var size = $(this).dialog('option','sizeCache-'+editing_node.type);
|
|
|
|
if (size) {
|
|
|
|
$(this).dialog('option','width',size.width);
|
|
|
|
$(this).dialog('option','height',size.height);
|
|
|
|
}
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
},
|
|
|
|
close: function(e) {
|
|
|
|
RED.keyboard.enable();
|
2013-09-05 16:02:48 +02:00
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
|
|
|
|
RED.view.state(RED.state.DEFAULT);
|
|
|
|
}
|
|
|
|
$( this ).dialog('option','height','auto');
|
|
|
|
$( this ).dialog('option','width','auto');
|
|
|
|
if (editing_node) {
|
|
|
|
RED.sidebar.info.refresh(editing_node);
|
|
|
|
}
|
2015-09-23 23:49:48 +02:00
|
|
|
RED.workspaces.refresh();
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
var buttons = $( this ).dialog("option","buttons");
|
|
|
|
if (buttons.length == 3) {
|
|
|
|
$( this ).dialog("option","buttons",buttons.splice(1));
|
|
|
|
}
|
|
|
|
editing_node = null;
|
2014-02-25 00:35:11 +01:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
});
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2014-05-07 00:42:54 +02:00
|
|
|
/**
|
|
|
|
* Create a config-node select box for this property
|
|
|
|
* @param node - the node being edited
|
|
|
|
* @param property - the name of the field
|
|
|
|
* @param type - the type of the config-node
|
|
|
|
*/
|
|
|
|
function prepareConfigNodeSelect(node,property,type) {
|
|
|
|
var input = $("#node-input-"+property);
|
|
|
|
var node_def = RED.nodes.getType(type);
|
|
|
|
|
|
|
|
input.replaceWith('<select style="width: 60%;" id="node-input-'+property+'"></select>');
|
|
|
|
updateConfigNodeSelect(property,type,node[property]);
|
|
|
|
var select = $("#node-input-"+property);
|
2015-07-14 00:21:03 +02:00
|
|
|
select.after(' <a id="node-input-lookup-'+property+'" class="editor-button"><i class="fa fa-pencil"></i></a>');
|
2014-05-07 00:42:54 +02:00
|
|
|
$('#node-input-lookup-'+property).click(function(e) {
|
|
|
|
showEditConfigNodeDialog(property,type,select.find(":selected").val());
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
var label = "";
|
|
|
|
var configNode = RED.nodes.node(node[property]);
|
|
|
|
if (configNode && node_def.label) {
|
|
|
|
if (typeof node_def.label == "function") {
|
|
|
|
label = node_def.label.call(configNode);
|
|
|
|
} else {
|
|
|
|
label = node_def.label;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
input.val(label);
|
|
|
|
}
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-05-06 12:08:01 +02:00
|
|
|
/**
|
|
|
|
* Create a config-node button for this property
|
|
|
|
* @param node - the node being edited
|
|
|
|
* @param property - the name of the field
|
|
|
|
* @param type - the type of the config-node
|
|
|
|
*/
|
|
|
|
function prepareConfigNodeButton(node,property,type) {
|
|
|
|
var input = $("#node-input-"+property);
|
|
|
|
input.val(node[property]);
|
|
|
|
input.attr("type","hidden");
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-07-14 00:21:03 +02:00
|
|
|
var button = $("<a>",{id:"node-input-edit-"+property, class:"editor-button"});
|
2015-05-06 12:08:01 +02:00
|
|
|
input.after(button);
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-05-06 12:08:01 +02:00
|
|
|
if (node[property]) {
|
2015-05-22 01:40:27 +02:00
|
|
|
button.text(RED._("editor.configEdit"));
|
2015-05-06 12:08:01 +02:00
|
|
|
} else {
|
2015-05-22 01:40:27 +02:00
|
|
|
button.text(RED._("editor.configAdd"));
|
2015-05-06 12:08:01 +02:00
|
|
|
}
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-05-06 12:08:01 +02:00
|
|
|
button.click(function(e) {
|
|
|
|
showEditConfigNodeDialog(property,type,input.val()||"_ADD_");
|
2015-05-07 17:44:55 +02:00
|
|
|
e.preventDefault();
|
2015-05-06 12:08:01 +02:00
|
|
|
});
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2014-05-07 00:42:54 +02:00
|
|
|
/**
|
|
|
|
* Populate the editor dialog input field for this property
|
|
|
|
* @param node - the node being edited
|
|
|
|
* @param property - the name of the field
|
|
|
|
* @param prefix - the prefix to use in the input element ids (node-input|node-config-input)
|
|
|
|
*/
|
|
|
|
function preparePropertyEditor(node,property,prefix) {
|
|
|
|
var input = $("#"+prefix+"-"+property);
|
|
|
|
if (input.attr('type') === "checkbox") {
|
|
|
|
input.prop('checked',node[property]);
|
|
|
|
} else {
|
|
|
|
var val = node[property];
|
|
|
|
if (val == null) {
|
|
|
|
val = "";
|
|
|
|
}
|
|
|
|
input.val(val);
|
|
|
|
}
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2014-05-07 00:42:54 +02:00
|
|
|
/**
|
|
|
|
* Add an on-change handler to revalidate a node field
|
|
|
|
* @param node - the node being edited
|
2014-05-16 09:34:23 +02:00
|
|
|
* @param definition - the definition of the node
|
2014-05-07 00:42:54 +02:00
|
|
|
* @param property - the name of the field
|
|
|
|
* @param prefix - the prefix to use in the input element ids (node-input|node-config-input)
|
|
|
|
*/
|
2014-05-16 09:34:23 +02:00
|
|
|
function attachPropertyChangeHandler(node,definition,property,prefix) {
|
2014-05-07 00:42:54 +02:00
|
|
|
$("#"+prefix+"-"+property).change(function() {
|
2014-05-16 09:34:23 +02:00
|
|
|
if (!validateNodeProperty(node, definition, property,this.value)) {
|
2014-05-07 00:42:54 +02:00
|
|
|
$(this).addClass("input-error");
|
|
|
|
} else {
|
|
|
|
$(this).removeClass("input-error");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2014-06-24 12:13:19 +02:00
|
|
|
/**
|
|
|
|
* Assign the value to each credential field
|
|
|
|
* @param node
|
|
|
|
* @param credDef
|
|
|
|
* @param credData
|
|
|
|
* @param prefix
|
|
|
|
*/
|
|
|
|
function populateCredentialsInputs(node, credDef, credData, prefix) {
|
2014-08-08 01:01:35 +02:00
|
|
|
var cred;
|
|
|
|
for (cred in credDef) {
|
2014-07-19 01:16:21 +02:00
|
|
|
if (credDef.hasOwnProperty(cred)) {
|
|
|
|
if (credDef[cred].type == 'password') {
|
|
|
|
if (credData[cred]) {
|
|
|
|
$('#' + prefix + '-' + cred).val(credData[cred]);
|
2014-07-20 21:42:41 +02:00
|
|
|
} else if (credData['has_' + cred]) {
|
2014-07-19 01:16:21 +02:00
|
|
|
$('#' + prefix + '-' + cred).val('__PWRD__');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#' + prefix + '-' + cred).val('');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
preparePropertyEditor(credData, cred, prefix);
|
2014-06-24 12:13:19 +02:00
|
|
|
}
|
2014-07-19 01:16:21 +02:00
|
|
|
attachPropertyChangeHandler(node, credDef, cred, prefix);
|
2014-06-24 12:13:19 +02:00
|
|
|
}
|
2014-07-19 01:16:21 +02:00
|
|
|
}
|
2014-08-08 01:01:35 +02:00
|
|
|
for (cred in credDef) {
|
2014-07-19 01:16:21 +02:00
|
|
|
if (credDef.hasOwnProperty(cred)) {
|
2014-06-24 12:13:19 +02:00
|
|
|
$("#" + prefix + "-" + cred).change();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2014-07-19 01:16:21 +02:00
|
|
|
/**
|
|
|
|
* Update the node credentials from the edit form
|
|
|
|
* @param node - the node containing the credentials
|
|
|
|
* @param credDefinition - definition of the credentials
|
|
|
|
* @param prefix - prefix of the input fields
|
|
|
|
* @return {boolean} whether anything has changed
|
|
|
|
*/
|
|
|
|
function updateNodeCredentials(node, credDefinition, prefix) {
|
|
|
|
var changed = false;
|
|
|
|
if(!node.credentials) {
|
2014-07-20 23:00:02 +02:00
|
|
|
node.credentials = {_:{}};
|
2014-07-19 01:16:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (var cred in credDefinition) {
|
|
|
|
if (credDefinition.hasOwnProperty(cred)) {
|
|
|
|
var input = $("#" + prefix + '-' + cred);
|
|
|
|
var value = input.val();
|
|
|
|
if (credDefinition[cred].type == 'password') {
|
2014-08-08 01:01:35 +02:00
|
|
|
node.credentials['has_' + cred] = (value !== "");
|
2014-07-19 01:16:21 +02:00
|
|
|
if (value == '__PWRD__') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
changed = true;
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2014-07-19 01:16:21 +02:00
|
|
|
}
|
2014-08-27 23:06:45 +02:00
|
|
|
node.credentials[cred] = value;
|
2014-07-19 01:16:21 +02:00
|
|
|
if (value != node.credentials._[cred]) {
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return changed;
|
|
|
|
}
|
2014-06-24 12:13:19 +02:00
|
|
|
|
2014-05-07 00:42:54 +02:00
|
|
|
/**
|
|
|
|
* Prepare all of the editor dialog fields
|
|
|
|
* @param node - the node being edited
|
|
|
|
* @param definition - the node definition
|
|
|
|
* @param prefix - the prefix to use in the input element ids (node-input|node-config-input)
|
|
|
|
*/
|
|
|
|
function prepareEditDialog(node,definition,prefix) {
|
|
|
|
for (var d in definition.defaults) {
|
2014-08-08 01:01:35 +02:00
|
|
|
if (definition.defaults.hasOwnProperty(d)) {
|
|
|
|
if (definition.defaults[d].type) {
|
2015-07-08 23:12:52 +02:00
|
|
|
var configTypeDef = RED.nodes.getType(definition.defaults[d].type);
|
2015-09-26 00:17:57 +02:00
|
|
|
if (configTypeDef) {
|
|
|
|
if (configTypeDef.exclusive) {
|
|
|
|
prepareConfigNodeButton(node,d,definition.defaults[d].type);
|
|
|
|
} else {
|
|
|
|
prepareConfigNodeSelect(node,d,definition.defaults[d].type);
|
|
|
|
}
|
2015-05-06 12:08:01 +02:00
|
|
|
} else {
|
2015-09-26 00:17:57 +02:00
|
|
|
console.log("Unknown type:", definition.defaults[d].type);
|
|
|
|
preparePropertyEditor(node,d,prefix);
|
2015-05-06 12:08:01 +02:00
|
|
|
}
|
2014-08-08 01:01:35 +02:00
|
|
|
} else {
|
|
|
|
preparePropertyEditor(node,d,prefix);
|
|
|
|
}
|
|
|
|
attachPropertyChangeHandler(node,definition.defaults,d,prefix);
|
2014-05-07 00:42:54 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-19 01:16:21 +02:00
|
|
|
var completePrepare = function() {
|
|
|
|
if (definition.oneditprepare) {
|
|
|
|
definition.oneditprepare.call(node);
|
|
|
|
}
|
|
|
|
for (var d in definition.defaults) {
|
2014-08-08 01:01:35 +02:00
|
|
|
if (definition.defaults.hasOwnProperty(d)) {
|
|
|
|
$("#"+prefix+"-"+d).change();
|
|
|
|
}
|
2014-07-19 01:16:21 +02:00
|
|
|
}
|
|
|
|
}
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2014-05-07 00:42:54 +02:00
|
|
|
if (definition.credentials) {
|
2014-07-19 01:16:21 +02:00
|
|
|
if (node.credentials) {
|
|
|
|
populateCredentialsInputs(node, definition.credentials, node.credentials, prefix);
|
|
|
|
completePrepare();
|
2014-06-24 12:13:19 +02:00
|
|
|
} else {
|
|
|
|
$.getJSON(getCredentialsURL(node.type, node.id), function (data) {
|
2014-07-19 01:16:21 +02:00
|
|
|
node.credentials = data;
|
|
|
|
node.credentials._ = $.extend(true,{},data);
|
|
|
|
populateCredentialsInputs(node, definition.credentials, node.credentials, prefix);
|
|
|
|
completePrepare();
|
2014-06-24 12:13:19 +02:00
|
|
|
});
|
|
|
|
}
|
2014-07-19 01:16:21 +02:00
|
|
|
} else {
|
|
|
|
completePrepare();
|
2014-05-07 00:42:54 +02:00
|
|
|
}
|
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2014-05-07 00:42:54 +02:00
|
|
|
function showEditDialog(node) {
|
|
|
|
editing_node = node;
|
|
|
|
RED.view.state(RED.state.EDITING);
|
2014-02-25 00:35:11 +01:00
|
|
|
var type = node.type;
|
|
|
|
if (node.type.substring(0,8) == "subflow:") {
|
|
|
|
type = "subflow";
|
|
|
|
var id = editing_node.type.substring(8);
|
|
|
|
var buttons = $( "#dialog" ).dialog("option","buttons");
|
|
|
|
buttons.unshift({
|
|
|
|
class: 'leftButton',
|
2015-07-01 00:42:03 +02:00
|
|
|
text: RED._("subflow.edit"),
|
2014-02-25 00:35:11 +01:00
|
|
|
click: function() {
|
2015-03-13 00:38:37 +01:00
|
|
|
RED.workspaces.show(id);
|
2014-02-25 00:35:11 +01:00
|
|
|
$("#node-dialog-ok").click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$( "#dialog" ).dialog("option","buttons",buttons);
|
|
|
|
}
|
|
|
|
$("#dialog-form").html($("script[data-template-name='"+type+"']").html());
|
2015-05-06 23:14:00 +02:00
|
|
|
var ns;
|
|
|
|
if (node._def.set.module === "node-red") {
|
|
|
|
ns = "node-red";
|
|
|
|
} else {
|
|
|
|
ns = node._def.set.id;
|
|
|
|
}
|
|
|
|
$("#dialog-form").find('[data-i18n]').each(function() {
|
|
|
|
var current = $(this).attr("data-i18n");
|
2015-08-13 14:58:19 +02:00
|
|
|
var keys = current.split(";");
|
|
|
|
for (var i=0;i<keys.length;i++) {
|
|
|
|
var key = keys[i];
|
|
|
|
if (key.indexOf(":") === -1) {
|
|
|
|
var prefix = "";
|
|
|
|
if (key.indexOf("[")===0) {
|
|
|
|
var parts = key.split("]");
|
|
|
|
prefix = parts[0]+"]";
|
|
|
|
key = parts[1];
|
|
|
|
}
|
|
|
|
keys[i] = prefix+ns+":"+key;
|
2015-05-07 15:06:55 +02:00
|
|
|
}
|
2015-05-06 23:14:00 +02:00
|
|
|
}
|
2015-08-13 14:58:19 +02:00
|
|
|
$(this).attr("data-i18n",keys.join(";"));
|
2015-05-06 23:14:00 +02:00
|
|
|
});
|
2014-08-28 21:55:19 +02:00
|
|
|
$('<input type="text" style="display: none;" />').appendTo("#dialog-form");
|
2014-05-07 00:42:54 +02:00
|
|
|
prepareEditDialog(node,node._def,"node-input");
|
2015-05-06 23:14:00 +02:00
|
|
|
$("#dialog").i18n();
|
2014-02-25 00:35:11 +01:00
|
|
|
$( "#dialog" ).dialog("option","title","Edit "+type+" node").dialog( "open" );
|
2014-05-07 00:42:54 +02:00
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
function showEditConfigNodeDialog(name,type,id) {
|
2013-11-17 18:49:32 +01:00
|
|
|
var adding = (id == "_ADD_");
|
2013-09-05 16:02:48 +02:00
|
|
|
var node_def = RED.nodes.getType(type);
|
2015-11-06 12:08:07 +01:00
|
|
|
editing_config_node = RED.nodes.node(id);
|
2015-05-26 22:52:23 +02:00
|
|
|
|
2015-05-28 16:28:35 +02:00
|
|
|
var ns;
|
|
|
|
if (node_def.set.module === "node-red") {
|
|
|
|
ns = "node-red";
|
|
|
|
} else {
|
|
|
|
ns = node_def.set.id;
|
|
|
|
}
|
|
|
|
|
2015-09-23 23:49:48 +02:00
|
|
|
var activeWorkspace = RED.nodes.workspace(RED.workspaces.active());
|
|
|
|
if (!activeWorkspace) {
|
|
|
|
activeWorkspace = RED.nodes.subflow(RED.workspaces.active());
|
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
|
2015-11-06 12:08:07 +01:00
|
|
|
if (editing_config_node == null) {
|
|
|
|
editing_config_node = {
|
2014-05-07 00:42:54 +02:00
|
|
|
id: (1+Math.random()*4294967295).toString(16),
|
|
|
|
_def: node_def,
|
2015-09-23 23:49:48 +02:00
|
|
|
type: type,
|
|
|
|
z: activeWorkspace.id,
|
|
|
|
users: []
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2014-05-09 16:23:33 +02:00
|
|
|
for (var d in node_def.defaults) {
|
|
|
|
if (node_def.defaults[d].value) {
|
2015-11-06 12:08:07 +01:00
|
|
|
editing_config_node[d] = node_def.defaults[d].value;
|
2014-05-09 16:23:33 +02:00
|
|
|
}
|
2015-06-29 17:12:18 +02:00
|
|
|
}
|
2015-11-06 12:08:07 +01:00
|
|
|
editing_config_node["_"] = node_def._;
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2014-05-07 00:42:54 +02:00
|
|
|
|
2015-09-14 17:10:46 +02:00
|
|
|
$("#node-config-dialog-edit-form").html($("script[data-template-name='"+type+"']").html());
|
2015-05-06 23:14:00 +02:00
|
|
|
|
|
|
|
$("#dialog-config-form").find('[data-i18n]').each(function() {
|
|
|
|
var current = $(this).attr("data-i18n");
|
|
|
|
if (current.indexOf(":") === -1) {
|
2015-05-13 10:51:13 +02:00
|
|
|
var prefix = "";
|
|
|
|
if (current.indexOf("[")===0) {
|
|
|
|
var parts = current.split("]");
|
|
|
|
prefix = parts[0]+"]";
|
|
|
|
current = parts[1];
|
|
|
|
}
|
|
|
|
$(this).attr("data-i18n",prefix+ns+":"+current);
|
2015-05-06 23:14:00 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-11-06 12:08:07 +01:00
|
|
|
prepareEditDialog(editing_config_node,node_def,"node-config-input");
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
var buttons = $( "#node-config-dialog" ).dialog("option","buttons");
|
2014-05-07 00:42:54 +02:00
|
|
|
if (adding) {
|
2013-09-05 16:02:48 +02:00
|
|
|
if (buttons.length == 3) {
|
|
|
|
buttons = buttons.splice(1);
|
|
|
|
}
|
|
|
|
buttons[0].text = "Add";
|
2015-09-23 23:49:48 +02:00
|
|
|
$("#node-config-dialog-user-count").find("span").html("").parent().hide();
|
2013-09-05 16:02:48 +02:00
|
|
|
} else {
|
|
|
|
if (buttons.length == 2) {
|
|
|
|
buttons.unshift({
|
|
|
|
class: 'leftButton',
|
2015-05-22 01:40:27 +02:00
|
|
|
text: RED._("editor.configDelete"),
|
2013-09-05 16:02:48 +02:00
|
|
|
click: function() {
|
|
|
|
var configProperty = $(this).dialog('option','node-property');
|
|
|
|
var configId = $(this).dialog('option','node-id');
|
|
|
|
var configType = $(this).dialog('option','node-type');
|
2015-11-06 12:08:07 +01:00
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
var configTypeDef = RED.nodes.getType(configType);
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
if (configTypeDef.ondelete) {
|
2015-11-06 12:08:07 +01:00
|
|
|
configTypeDef.ondelete.call(editing_config_node);
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-02-13 12:20:08 +01:00
|
|
|
if (configTypeDef.oneditdelete) {
|
2015-11-06 12:08:07 +01:00
|
|
|
configTypeDef.oneditdelete.call(editing_config_node);
|
2015-02-13 12:20:08 +01:00
|
|
|
}
|
2015-09-25 22:49:53 +02:00
|
|
|
var historyEvent = {
|
|
|
|
t:'delete',
|
2015-11-06 12:08:07 +01:00
|
|
|
nodes:[editing_config_node],
|
2015-09-25 22:49:53 +02:00
|
|
|
changes: {},
|
|
|
|
dirty: RED.nodes.dirty()
|
|
|
|
}
|
2013-09-05 16:02:48 +02:00
|
|
|
RED.nodes.remove(configId);
|
2015-11-06 12:08:07 +01:00
|
|
|
for (var i=0;i<editing_config_node.users.length;i++) {
|
|
|
|
var user = editing_config_node.users[i];
|
2015-09-25 22:49:53 +02:00
|
|
|
historyEvent.changes[user.id] = {
|
|
|
|
changed: user.changed,
|
|
|
|
valid: user.valid
|
|
|
|
};
|
2013-09-05 16:02:48 +02:00
|
|
|
for (var d in user._def.defaults) {
|
2014-08-08 01:01:35 +02:00
|
|
|
if (user._def.defaults.hasOwnProperty(d) && user[d] == configId) {
|
2015-09-25 22:49:53 +02:00
|
|
|
historyEvent.changes[user.id][d] = configId
|
2013-09-05 16:02:48 +02:00
|
|
|
user[d] = "";
|
2015-09-25 22:49:53 +02:00
|
|
|
user.changed = true;
|
|
|
|
user.dirty = true;
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
validateNode(user);
|
|
|
|
}
|
|
|
|
updateConfigNodeSelect(configProperty,configType,"");
|
2015-03-15 22:54:36 +01:00
|
|
|
RED.nodes.dirty(true);
|
2013-09-05 16:02:48 +02:00
|
|
|
$( this ).dialog( "close" );
|
|
|
|
RED.view.redraw();
|
2015-09-25 22:49:53 +02:00
|
|
|
RED.history.push(historyEvent);
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
buttons[1].text = "Update";
|
2015-11-06 12:08:07 +01:00
|
|
|
$("#node-config-dialog-user-count").find("span").html(RED._("editor.nodesUse", {count:editing_config_node.users.length})).parent().show();
|
2015-09-23 23:49:48 +02:00
|
|
|
}
|
|
|
|
|
2015-11-06 12:08:07 +01:00
|
|
|
if (editing_config_node._def.exclusive) {
|
2015-09-23 23:49:48 +02:00
|
|
|
$("#node-config-dialog-scope").hide();
|
|
|
|
} else {
|
|
|
|
$("#node-config-dialog-scope").show();
|
|
|
|
}
|
|
|
|
$("#node-config-dialog-scope-warning").hide();
|
|
|
|
|
|
|
|
|
|
|
|
var nodeUserFlows = {};
|
2015-11-06 12:08:07 +01:00
|
|
|
editing_config_node.users.forEach(function(n) {
|
2015-09-23 23:49:48 +02:00
|
|
|
nodeUserFlows[n.z] = true;
|
|
|
|
});
|
|
|
|
var flowCount = Object.keys(nodeUserFlows).length;
|
|
|
|
|
|
|
|
var tabSelect = $("#node-config-dialog-scope").empty();
|
|
|
|
tabSelect.off("change");
|
2015-11-06 12:08:07 +01:00
|
|
|
tabSelect.append('<option value=""'+(!editing_config_node.z?" selected":"")+' data-i18n="sidebar.config.global"></option>');
|
2015-11-05 15:22:15 +01:00
|
|
|
tabSelect.append('<option disabled data-i18n="sidebar.config.flows"></option>');
|
2015-09-23 23:49:48 +02:00
|
|
|
RED.nodes.eachWorkspace(function(ws) {
|
|
|
|
var workspaceLabel = ws.label;
|
|
|
|
if (nodeUserFlows[ws.id]) {
|
|
|
|
workspaceLabel = "* "+workspaceLabel;
|
|
|
|
}
|
2015-11-06 12:08:07 +01:00
|
|
|
tabSelect.append('<option value="'+ws.id+'"'+(ws.id==editing_config_node.z?" selected":"")+'>'+workspaceLabel+'</option>');
|
2015-09-23 23:49:48 +02:00
|
|
|
});
|
2015-11-05 15:22:15 +01:00
|
|
|
tabSelect.append('<option disabled data-i18n="sidebar.config.subflows"></option>');
|
2015-09-23 23:49:48 +02:00
|
|
|
RED.nodes.eachSubflow(function(ws) {
|
|
|
|
var workspaceLabel = ws.name;
|
|
|
|
if (nodeUserFlows[ws.id]) {
|
|
|
|
workspaceLabel = "* "+workspaceLabel;
|
|
|
|
}
|
2015-11-06 12:08:07 +01:00
|
|
|
tabSelect.append('<option value="'+ws.id+'"'+(ws.id==editing_config_node.z?" selected":"")+'>'+workspaceLabel+'</option>');
|
2015-09-23 23:49:48 +02:00
|
|
|
});
|
|
|
|
if (flowCount > 0) {
|
|
|
|
tabSelect.on('change',function() {
|
|
|
|
var newScope = $(this).val();
|
|
|
|
if (newScope === '') {
|
|
|
|
// global scope - everyone can use it
|
|
|
|
$("#node-config-dialog-scope-warning").hide();
|
|
|
|
} else if (!nodeUserFlows[newScope] || flowCount > 1) {
|
|
|
|
// a user will loose access to it
|
|
|
|
$("#node-config-dialog-scope-warning").show();
|
|
|
|
} else {
|
|
|
|
$("#node-config-dialog-scope-warning").hide();
|
|
|
|
}
|
|
|
|
});
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-09-23 23:49:48 +02:00
|
|
|
|
|
|
|
//tabSelect.append('<option value="'+activeWorkspace.id+'"'+(activeWorkspace.id==configNode.z?" selected":"")+'>'+workspaceLabel+'</option>');
|
|
|
|
tabSelect.i18n();
|
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
$( "#node-config-dialog" ).dialog("option","buttons",buttons);
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2015-05-06 23:14:00 +02:00
|
|
|
$("#node-config-dialog").i18n();
|
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
$( "#node-config-dialog" )
|
|
|
|
.dialog("option","node-adding",adding)
|
|
|
|
.dialog("option","node-property",name)
|
2015-11-06 12:08:07 +01:00
|
|
|
.dialog("option","node-id",editing_config_node.id)
|
2013-09-05 16:02:48 +02:00
|
|
|
.dialog("option","node-type",type)
|
2015-05-22 01:40:27 +02:00
|
|
|
.dialog("option","title",(adding?RED._("editor.addNewConfig", {type:type}):RED._("editor.editConfig", {type:type})))
|
2013-09-05 16:02:48 +02:00
|
|
|
.dialog( "open" );
|
|
|
|
}
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
function updateConfigNodeSelect(name,type,value) {
|
2015-05-06 12:08:01 +02:00
|
|
|
var button = $("#node-input-edit-"+name);
|
|
|
|
if (button.length) {
|
|
|
|
if (value) {
|
2015-05-22 01:40:27 +02:00
|
|
|
button.text(RED._("editor.configEdit"));
|
2015-05-06 12:08:01 +02:00
|
|
|
} else {
|
2015-05-22 01:40:27 +02:00
|
|
|
button.text(RED._("editor.configAdd"));
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-06 12:08:01 +02:00
|
|
|
$("#node-input-"+name).val(value);
|
|
|
|
} else {
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-05-06 12:08:01 +02:00
|
|
|
var select = $("#node-input-"+name);
|
|
|
|
var node_def = RED.nodes.getType(type);
|
|
|
|
select.children().remove();
|
2015-09-23 23:49:48 +02:00
|
|
|
|
|
|
|
var activeWorkspace = RED.nodes.workspace(RED.workspaces.active());
|
|
|
|
if (!activeWorkspace) {
|
|
|
|
activeWorkspace = RED.nodes.subflow(RED.workspaces.active());
|
|
|
|
}
|
|
|
|
|
|
|
|
var configNodes = [];
|
|
|
|
|
2015-05-06 12:08:01 +02:00
|
|
|
RED.nodes.eachConfig(function(config) {
|
2015-09-23 23:49:48 +02:00
|
|
|
if (config.type == type && (!config.z || config.z === activeWorkspace.id)) {
|
2015-05-06 12:08:01 +02:00
|
|
|
var label = "";
|
|
|
|
if (typeof node_def.label == "function") {
|
|
|
|
label = node_def.label.call(config);
|
|
|
|
} else {
|
|
|
|
label = node_def.label;
|
|
|
|
}
|
2015-09-23 23:49:48 +02:00
|
|
|
configNodes.push({id:config.id,label:label});
|
2015-05-06 12:08:01 +02:00
|
|
|
}
|
|
|
|
});
|
2015-09-23 23:49:48 +02:00
|
|
|
|
|
|
|
configNodes.sort(function(A,B) {
|
|
|
|
if (A.label < B.label) {
|
|
|
|
return -1;
|
|
|
|
} else if (A.label > B.label) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
|
|
|
|
configNodes.forEach(function(cn) {
|
|
|
|
select.append('<option value="'+cn.id+'"'+(value==cn.id?" selected":"")+'>'+cn.label+'</option>');
|
|
|
|
});
|
|
|
|
|
2015-05-22 01:40:27 +02:00
|
|
|
select.append('<option value="_ADD_"'+(value===""?" selected":"")+'>'+RED._("editor.addNewType", {type:type})+'</option>');
|
2015-05-06 12:08:01 +02:00
|
|
|
window.setTimeout(function() { select.change();},50);
|
|
|
|
}
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
|
|
|
|
function createNodeConfigDialog(){
|
|
|
|
$( "#node-config-dialog" ).dialog({
|
|
|
|
modal: true,
|
|
|
|
autoOpen: false,
|
|
|
|
dialogClass: "ui-dialog-no-close",
|
|
|
|
minWidth: 500,
|
|
|
|
width: 'auto',
|
|
|
|
closeOnEscape: false,
|
|
|
|
buttons: [
|
|
|
|
{
|
|
|
|
id: "node-config-dialog-ok",
|
2015-07-01 00:42:03 +02:00
|
|
|
text: RED._("common.label.ok"),
|
2015-05-26 22:52:23 +02:00
|
|
|
click: function() {
|
|
|
|
var configProperty = $(this).dialog('option','node-property');
|
|
|
|
var configId = $(this).dialog('option','node-id');
|
|
|
|
var configType = $(this).dialog('option','node-type');
|
|
|
|
var configAdding = $(this).dialog('option','node-adding');
|
|
|
|
var configTypeDef = RED.nodes.getType(configType);
|
|
|
|
var d;
|
|
|
|
var input;
|
2015-09-23 23:49:48 +02:00
|
|
|
var scope = $("#node-config-dialog-scope").val();
|
2015-11-06 12:08:07 +01:00
|
|
|
for (d in configTypeDef.defaults) {
|
|
|
|
if (configTypeDef.defaults.hasOwnProperty(d)) {
|
|
|
|
input = $("#node-config-input-"+d);
|
|
|
|
if (input.attr('type') === "checkbox") {
|
|
|
|
editing_config_node[d] = input.prop('checked');
|
|
|
|
} else {
|
|
|
|
editing_config_node[d] = input.val();
|
2015-05-26 22:52:23 +02:00
|
|
|
}
|
|
|
|
}
|
2015-11-06 12:08:07 +01:00
|
|
|
}
|
|
|
|
editing_config_node.label = configTypeDef.label;
|
|
|
|
editing_config_node.z = scope;
|
|
|
|
|
|
|
|
if (scope) {
|
|
|
|
editing_config_node.users = editing_config_node.users.filter(function(n) {
|
|
|
|
var keep = true;
|
|
|
|
for (var d in n._def.defaults) {
|
|
|
|
if (n._def.defaults.hasOwnProperty(d)) {
|
|
|
|
if (n._def.defaults[d].type === editing_config_node.type &&
|
|
|
|
n[d] === editing_config_node.id &&
|
|
|
|
n.z !== scope) {
|
|
|
|
keep = false;
|
|
|
|
n[d] = null;
|
|
|
|
n.dirty = true;
|
|
|
|
n.changed = true;
|
|
|
|
validateNode(n);
|
2015-09-23 23:49:48 +02:00
|
|
|
}
|
|
|
|
}
|
2015-11-06 12:08:07 +01:00
|
|
|
}
|
|
|
|
return keep;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (configAdding) {
|
|
|
|
RED.nodes.add(editing_config_node);
|
2015-05-26 22:52:23 +02:00
|
|
|
}
|
2015-11-06 12:08:07 +01:00
|
|
|
|
|
|
|
updateConfigNodeSelect(configProperty,configType,editing_config_node.id);
|
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
if (configTypeDef.credentials) {
|
2015-11-06 12:08:07 +01:00
|
|
|
updateNodeCredentials(editing_config_node,configTypeDef.credentials,"node-config-input");
|
2015-05-26 22:52:23 +02:00
|
|
|
}
|
|
|
|
if (configTypeDef.oneditsave) {
|
2015-11-06 12:08:07 +01:00
|
|
|
configTypeDef.oneditsave.call(editing_config_node);
|
2015-05-26 22:52:23 +02:00
|
|
|
}
|
2015-11-06 12:08:07 +01:00
|
|
|
validateNode(editing_config_node);
|
|
|
|
for (var i=0;i<editing_config_node.users.length;i++) {
|
|
|
|
var user = editing_config_node.users[i];
|
2015-05-26 22:52:23 +02:00
|
|
|
validateNode(user);
|
|
|
|
}
|
|
|
|
|
|
|
|
RED.nodes.dirty(true);
|
2015-09-23 23:49:48 +02:00
|
|
|
RED.view.redraw(true);
|
2015-05-26 22:52:23 +02:00
|
|
|
$(this).dialog("close");
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "node-config-dialog-cancel",
|
2015-07-01 00:42:03 +02:00
|
|
|
text: RED._("common.label.cancel"),
|
2015-05-26 22:52:23 +02:00
|
|
|
click: function() {
|
|
|
|
var configType = $(this).dialog('option','node-type');
|
|
|
|
var configId = $(this).dialog('option','node-id');
|
|
|
|
var configAdding = $(this).dialog('option','node-adding');
|
|
|
|
var configTypeDef = RED.nodes.getType(configType);
|
|
|
|
|
|
|
|
if (configTypeDef.oneditcancel) {
|
|
|
|
// TODO: what to pass as this to call
|
|
|
|
if (configTypeDef.oneditcancel) {
|
|
|
|
var cn = RED.nodes.node(configId);
|
|
|
|
if (cn) {
|
|
|
|
configTypeDef.oneditcancel.call(cn,false);
|
|
|
|
} else {
|
|
|
|
configTypeDef.oneditcancel.call({id:configId},true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$( this ).dialog( "close" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
resize: function(e,ui) {
|
|
|
|
},
|
|
|
|
open: function(e) {
|
|
|
|
var minWidth = $(this).dialog('option','minWidth');
|
|
|
|
if ($(this).outerWidth() < minWidth) {
|
|
|
|
$(this).dialog('option','width',minWidth);
|
|
|
|
}
|
|
|
|
if (RED.view.state() != RED.state.EDITING) {
|
|
|
|
RED.keyboard.disable();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
close: function(e) {
|
|
|
|
$(this).dialog('option','width','auto');
|
|
|
|
$(this).dialog('option','height','auto');
|
2015-09-14 17:10:46 +02:00
|
|
|
$("#node-config-dialog-edit-form").html("");
|
2015-05-26 22:52:23 +02:00
|
|
|
if (RED.view.state() != RED.state.EDITING) {
|
|
|
|
RED.keyboard.enable();
|
|
|
|
}
|
2015-09-23 23:49:48 +02:00
|
|
|
RED.workspaces.refresh();
|
|
|
|
},
|
|
|
|
create: function() {
|
|
|
|
$("#node-config-dialog").parent().find("div.ui-dialog-buttonpane")
|
|
|
|
.prepend('<div id="node-config-dialog-user-count"><i class="fa fa-info-circle"></i> <span></span></div>');
|
|
|
|
|
|
|
|
$("#node-config-dialog").parent().find('.ui-dialog-titlebar').append('<span id="node-config-dialog-scope-container"><span id="node-config-dialog-scope-warning" data-i18n="[title]editor.errors.scopeChange"><i class="fa fa-warning"></i></span><select id="node-config-dialog-scope"></select></span>');
|
|
|
|
$("#node-config-dialog").parent().draggable({
|
|
|
|
cancel: '.ui-dialog-content, .ui-dialog-titlebar-close, #node-config-dialog-scope-container'
|
|
|
|
});
|
2015-05-26 22:52:23 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function createSubflowDialog(){
|
|
|
|
$( "#subflow-dialog" ).dialog({
|
2013-09-05 16:02:48 +02:00
|
|
|
modal: true,
|
|
|
|
autoOpen: false,
|
2015-03-21 00:11:03 +01:00
|
|
|
dialogClass: "ui-dialog-no-close",
|
2015-05-26 22:52:23 +02:00
|
|
|
closeOnEscape: false,
|
2015-03-09 21:41:57 +01:00
|
|
|
minWidth: 500,
|
|
|
|
width: 'auto',
|
2013-09-05 16:02:48 +02:00
|
|
|
buttons: [
|
|
|
|
{
|
2015-05-26 22:52:23 +02:00
|
|
|
id: "subflow-dialog-ok",
|
2015-07-01 00:42:03 +02:00
|
|
|
text: RED._("common.label.ok"),
|
2013-09-05 16:02:48 +02:00
|
|
|
click: function() {
|
2015-05-26 22:52:23 +02:00
|
|
|
if (editing_node) {
|
|
|
|
var i;
|
|
|
|
var changes = {};
|
|
|
|
var changed = false;
|
|
|
|
var wasDirty = RED.nodes.dirty();
|
|
|
|
|
|
|
|
var newName = $("#subflow-input-name").val();
|
|
|
|
|
|
|
|
if (newName != editing_node.name) {
|
|
|
|
changes['name'] = editing_node.name;
|
|
|
|
editing_node.name = newName;
|
|
|
|
changed = true;
|
2015-09-27 21:18:21 +02:00
|
|
|
$("#menu-item-workspace-menu-"+editing_node.id.replace(".","-")).text(newName);
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
|
2015-10-23 23:14:21 +02:00
|
|
|
var newDescription = subflowEditor.getValue();
|
|
|
|
|
|
|
|
if (newDescription != editing_node.info) {
|
|
|
|
changes['info'] = editing_node.info;
|
|
|
|
editing_node.info = newDescription;
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
RED.palette.refresh();
|
|
|
|
|
|
|
|
if (changed) {
|
2015-07-30 12:03:37 +02:00
|
|
|
var subflowInstances = [];
|
2015-05-26 22:52:23 +02:00
|
|
|
RED.nodes.eachNode(function(n) {
|
|
|
|
if (n.type == "subflow:"+editing_node.id) {
|
2015-07-30 12:03:37 +02:00
|
|
|
subflowInstances.push({
|
|
|
|
id:n.id,
|
|
|
|
changed:n.changed
|
|
|
|
})
|
2015-05-26 22:52:23 +02:00
|
|
|
n.changed = true;
|
2015-07-30 12:03:37 +02:00
|
|
|
n.dirty = true;
|
2015-05-26 22:52:23 +02:00
|
|
|
updateNodeProperties(n);
|
2014-09-01 10:11:10 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
});
|
|
|
|
var wasChanged = editing_node.changed;
|
|
|
|
editing_node.changed = true;
|
|
|
|
RED.nodes.dirty(true);
|
|
|
|
var historyEvent = {
|
|
|
|
t:'edit',
|
|
|
|
node:editing_node,
|
|
|
|
changes:changes,
|
|
|
|
dirty:wasDirty,
|
2015-07-30 12:03:37 +02:00
|
|
|
changed:wasChanged,
|
|
|
|
subflow: {
|
|
|
|
instances:subflowInstances
|
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
RED.history.push(historyEvent);
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
editing_node.dirty = true;
|
|
|
|
RED.view.redraw();
|
2015-03-19 11:49:56 +01:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
$( this ).dialog( "close" );
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2015-05-26 22:52:23 +02:00
|
|
|
id: "subflow-dialog-cancel",
|
2015-07-01 00:42:03 +02:00
|
|
|
text: RED._("common.label.cancel"),
|
2013-09-05 16:02:48 +02:00
|
|
|
click: function() {
|
|
|
|
$( this ).dialog( "close" );
|
2015-05-26 22:52:23 +02:00
|
|
|
editing_node = null;
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2015-10-23 23:14:21 +02:00
|
|
|
create: function(e) {
|
|
|
|
$("#subflow-dialog form" ).submit(function(e) { e.preventDefault();});
|
|
|
|
subflowEditor = RED.editor.createEditor({
|
|
|
|
id: 'subflow-input-info-editor',
|
|
|
|
mode: 'ace/mode/markdown',
|
|
|
|
value: ""
|
|
|
|
});
|
|
|
|
},
|
2015-03-09 21:41:57 +01:00
|
|
|
open: function(e) {
|
2015-05-26 22:52:23 +02:00
|
|
|
RED.keyboard.disable();
|
2015-03-09 21:41:57 +01:00
|
|
|
var minWidth = $(this).dialog('option','minWidth');
|
|
|
|
if ($(this).outerWidth() < minWidth) {
|
|
|
|
$(this).dialog('option','width',minWidth);
|
|
|
|
}
|
2013-09-05 16:02:48 +02:00
|
|
|
},
|
|
|
|
close: function(e) {
|
2015-05-26 22:52:23 +02:00
|
|
|
RED.keyboard.enable();
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-05-26 22:52:23 +02:00
|
|
|
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {
|
|
|
|
RED.view.state(RED.state.DEFAULT);
|
2014-02-25 00:35:11 +01:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
RED.sidebar.info.refresh(editing_node);
|
2015-09-23 23:49:48 +02:00
|
|
|
RED.workspaces.refresh();
|
2015-05-26 22:52:23 +02:00
|
|
|
editing_node = null;
|
2015-10-23 23:14:21 +02:00
|
|
|
},
|
|
|
|
resize: function(e) {
|
|
|
|
var rows = $("#subflow-dialog>form>div:not(.node-text-editor-row)");
|
|
|
|
var editorRow = $("#subflow-dialog>form>div.node-text-editor-row");
|
|
|
|
var height = $("#subflow-dialog").height();
|
|
|
|
for (var i=0;i<rows.size();i++) {
|
|
|
|
height -= $(rows[i]).outerHeight(true);
|
|
|
|
}
|
|
|
|
height -= (parseInt($("#subflow-dialog>form").css("marginTop"))+parseInt($("#subflow-dialog>form").css("marginBottom")));
|
|
|
|
$(".node-text-editor").css("height",height+"px");
|
|
|
|
subflowEditor.resize();
|
2014-02-25 00:35:11 +01:00
|
|
|
}
|
2015-05-26 22:52:23 +02:00
|
|
|
});
|
|
|
|
}
|
2015-03-12 18:23:17 +01:00
|
|
|
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2014-02-25 00:35:11 +01:00
|
|
|
function showEditSubflowDialog(subflow) {
|
|
|
|
editing_node = subflow;
|
|
|
|
RED.view.state(RED.state.EDITING);
|
2015-10-23 23:14:21 +02:00
|
|
|
|
2014-02-25 00:35:11 +01:00
|
|
|
$("#subflow-input-name").val(subflow.name);
|
2015-10-23 23:14:21 +02:00
|
|
|
subflowEditor.getSession().setValue(subflow.info,-1);
|
2014-02-25 00:35:11 +01:00
|
|
|
var userCount = 0;
|
|
|
|
var subflowType = "subflow:"+editing_node.id;
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2014-02-25 00:35:11 +01:00
|
|
|
RED.nodes.eachNode(function(n) {
|
|
|
|
if (n.type === subflowType) {
|
|
|
|
userCount++;
|
|
|
|
}
|
|
|
|
});
|
2015-05-26 22:52:23 +02:00
|
|
|
|
2015-07-01 00:42:03 +02:00
|
|
|
$("#subflow-dialog-user-count").html(RED._("subflow.subflowInstances", {count:userCount})).show();
|
|
|
|
$("#subflow-dialog").dialog("option","title",RED._("subflow.editSubflow",{name:subflow.name})).dialog( "open" );
|
2014-02-25 00:35:11 +01:00
|
|
|
}
|
2014-05-07 20:19:08 +02:00
|
|
|
|
2015-05-07 17:44:55 +02:00
|
|
|
|
|
|
|
|
2013-09-05 16:02:48 +02:00
|
|
|
return {
|
2015-05-26 22:52:23 +02:00
|
|
|
init: function(){
|
|
|
|
createDialog();
|
|
|
|
createNodeConfigDialog();
|
|
|
|
createSubflowDialog();
|
|
|
|
},
|
2013-09-05 16:02:48 +02:00
|
|
|
edit: showEditDialog,
|
2014-01-25 23:31:43 +01:00
|
|
|
editConfig: showEditConfigNodeDialog,
|
2014-02-25 00:35:11 +01:00
|
|
|
editSubflow: showEditSubflowDialog,
|
2013-09-05 16:02:48 +02:00
|
|
|
validateNode: validateNode,
|
2015-02-26 22:29:56 +01:00
|
|
|
updateNodeProperties: updateNodeProperties, // TODO: only exposed for edit-undo
|
2015-05-07 17:44:55 +02:00
|
|
|
|
2015-02-26 22:29:56 +01:00
|
|
|
createEditor: function(options) {
|
|
|
|
var editor = ace.edit(options.id);
|
|
|
|
editor.setTheme("ace/theme/tomorrow");
|
2015-05-07 22:12:46 +02:00
|
|
|
var session = editor.getSession();
|
2015-02-26 22:29:56 +01:00
|
|
|
if (options.mode) {
|
2015-05-07 22:12:46 +02:00
|
|
|
session.setMode(options.mode);
|
2015-02-26 22:29:56 +01:00
|
|
|
}
|
|
|
|
if (options.foldStyle) {
|
2015-05-07 22:12:46 +02:00
|
|
|
session.setFoldStyle(options.foldStyle);
|
2015-02-26 22:29:56 +01:00
|
|
|
} else {
|
2015-05-07 22:12:46 +02:00
|
|
|
session.setFoldStyle('markbeginend');
|
2015-02-26 22:29:56 +01:00
|
|
|
}
|
|
|
|
if (options.options) {
|
|
|
|
editor.setOptions(options.options);
|
|
|
|
} else {
|
|
|
|
editor.setOptions({
|
|
|
|
enableBasicAutocompletion:true,
|
|
|
|
enableSnippets:true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
editor.$blockScrolling = Infinity;
|
2015-05-07 22:12:46 +02:00
|
|
|
if (options.value) {
|
|
|
|
session.setValue(options.value,-1);
|
|
|
|
}
|
2015-02-26 22:29:56 +01:00
|
|
|
return editor;
|
|
|
|
}
|
2013-09-05 16:02:48 +02:00
|
|
|
}
|
2014-08-08 01:01:35 +02:00
|
|
|
})();
|