From a3a317eaf1fe6e2d0e32bef005eaf34c0fb2c9d7 Mon Sep 17 00:00:00 2001 From: Brenden Tuck Date: Mon, 1 Apr 2019 16:22:53 -0400 Subject: [PATCH] Add the ability to create more input windows --- .../webclient/js/plugins/goldenlayout.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/evennia/web/webclient/static/webclient/js/plugins/goldenlayout.js b/evennia/web/webclient/static/webclient/js/plugins/goldenlayout.js index 2b1962922b..75a137ac0f 100644 --- a/evennia/web/webclient/static/webclient/js/plugins/goldenlayout.js +++ b/evennia/web/webclient/static/webclient/js/plugins/goldenlayout.js @@ -56,6 +56,12 @@ plugin_handler.add('goldenlayout', (function () { }, }; + var newInputConfig = { + title: 'input', + type: 'component', + componentName: 'input', + id: 'inputComponent', + }; // helper function: filter vals out of array function filter (vals, array) { @@ -340,6 +346,23 @@ plugin_handler.add('goldenlayout', (function () { } + // + // + var onInputCreate = function (tab) { + //HTML for the typeDropdown + let splitControl = $('+'); + + // track adding a new tab + splitControl.click( tab, function (evnt) { + evnt.data.header.parent.addChild( newInputConfig ); + }); + + // Add the typeDropdown to the header + tab.element.append( splitControl ); + + tab.header.parent.on( 'activeContentItemChanged', onActiveTabChange ); + } + // // var scrollAll = function () { @@ -511,6 +534,7 @@ plugin_handler.add('goldenlayout', (function () { $( $(evnt.target).siblings('.inputfield')[0] ).trigger(e); }); + container.on('tab', onInputCreate); }); myLayout.registerComponent( 'evennia', function (container, componentState) {