diff --git a/Gruntfile.js b/Gruntfile.js
index 891469c24..8cc406345 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -116,6 +116,7 @@ module.exports = function(grunt) {
"editor/js/ui/common/popover.js",
"editor/js/ui/common/searchBox.js",
"editor/js/ui/common/tabs.js",
+ "editor/js/ui/common/stack.js",
"editor/js/ui/common/typedInput.js",
"editor/js/ui/actions.js",
"editor/js/ui/deploy.js",
diff --git a/editor/js/ui/common/stack.js b/editor/js/ui/common/stack.js
new file mode 100644
index 000000000..b273b9f22
--- /dev/null
+++ b/editor/js/ui/common/stack.js
@@ -0,0 +1,92 @@
+/**
+ * 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.stack = (function() {
+ function createStack(options) {
+ var container = options.container;
+
+ var entries = [];
+
+ return {
+ add: function(entry) {
+
+ entries.push(entry);
+ var entryContainer = $('
').appendTo(container);
+
+ var header = $('').appendTo(entryContainer);
+ var icon = $('
').appendTo(header);
+ $('
').html(entry.title).appendTo(header);
+ entry.content = $('
').appendTo(entryContainer);
+
+ if (entry.expanded) {
+ icon.addClass("expanded");
+ } else {
+ entry.content.hide();
+ }
+
+ header.click(function() {
+ if (options.singleExpanded) {
+ if (!entry.isExpanded()) {
+ for (var i=0;i
i");
- var body = el.find(".editor-tray-content");
- var result = {
- el:el,
- body:body,
- expand: function() {
- icon.addClass("expanded");
- body.slideDown();
- },
- collapse: function() {
- icon.removeClass("expanded");
- body.slideUp();
- },
- toggle: function() {
- if (icon.hasClass("expanded")) {
- result.collapse();
- return false;
- } else {
- result.expand();
- return true;
- }
- }
- }
- return result;
- }
-
- var nodePropertiesSection = buildThing($('').appendTo(trayBody));
-
- var portLabelsSection = buildThing($('').appendTo(trayBody));
-
- portLabelsSection.el.find(".palette-header").click(function(el) {
- var res = portLabelsSection.toggle();
- if (res) {
- nodePropertiesSection.collapse();
- } else {
- nodePropertiesSection.expand();
- }
+ var stack = RED.stack.create({
+ container: trayBody,
+ singleExpanded: true
});
- nodePropertiesSection.el.find(".palette-header").click(function(el) {
- var res = nodePropertiesSection.toggle();
- if (res) {
- portLabelsSection.collapse();
- } else {
- portLabelsSection.expand();
- }
+ var nodeProperties = stack.add({
+ title: "node properties",
+ expanded: true,
+ });
+ var portLabels = stack.add({
+ title: "port labels"
});
if (editing_node) {
@@ -850,9 +808,9 @@ RED.editor = (function() {
} else {
ns = node._def.set.id;
}
- var dialogForm = buildEditForm(nodePropertiesSection.body,"dialog-form",type,ns);
+ var dialogForm = buildEditForm(nodeProperties.content,"dialog-form",type,ns);
prepareEditDialog(node,node._def,"node-input");
- dialogForm.i18n();
+ trayBody.i18n();
},
close: function() {
if (RED.view.state() != RED.state.IMPORT_DRAGGING) {