diff --git a/evennia/web/webclient/static/webclient/css/webclient.css b/evennia/web/webclient/static/webclient/css/webclient.css index 94344386a1..1e9adb283b 100644 --- a/evennia/web/webclient/static/webclient/css/webclient.css +++ b/evennia/web/webclient/static/webclient/css/webclient.css @@ -147,6 +147,19 @@ div {margin:0px;} cursor: pointer; } +.button { + width: fit-content; + padding: 1em; + color: black; + border: 1px solid black; + background-color: darkgray; + margin: 0 auto; +} + +.splitbutton:hover { + cursor: pointer; +} + #optionsbutton { width: 2rem; font-size: 2rem; @@ -256,6 +269,10 @@ div {margin:0px;} overflow-x: hidden; } +.split-sub { + padding: .5rem; +} + .content { border: 1px solid #C0C0C0; box-shadow: inset 0 1px 2px #e4e4e4; diff --git a/evennia/web/webclient/static/webclient/js/splithandler.js b/evennia/web/webclient/static/webclient/js/splithandler.js index 7ba8e45e17..aa6ea4364a 100644 --- a/evennia/web/webclient/static/webclient/js/splithandler.js +++ b/evennia/web/webclient/static/webclient/js/splithandler.js @@ -1,50 +1,50 @@ // Use split.js to create a basic ui var SplitHandler = (function () { - var num_splits = 0; var split_panes = {}; var set_pane_types = function(splitpane, types) { split_panes[splitpane]['types'] = types; } - var dynamic_split = function(splitpane, direction, update_method1, update_method2) { - var first = ++num_splits; - var second = ++num_splits; - var first_div = $( '
' ) - var first_sub = $( '
' ) - var second_div = $( '
' ) - var second_sub = $( '
' ) + var dynamic_split = function(splitpane, direction, pane_name1, pane_name2, update_method1, update_method2, sizes) { + // find the sub-div of the pane we are being asked to split + splitpanesub = splitpane + '-sub'; - // check to see if this pane contains the primary message window. - contents = $('#'+splitpane).contents(); + // create the new div stack to replace the sub-div with. + var first_div = $( '
' ) + var first_sub = $( '
' ) + var second_div = $( '
' ) + var second_sub = $( '
' ) + + // check to see if this sub-pane contains anything + contents = $('#'+splitpanesub).contents(); if( contents ) { - // it does, so move it to the first new div (TODO -- selectable between first/second?) + // it does, so move it to the first new div-sub (TODO -- selectable between first/second?) contents.appendTo(first_sub); } - first_div.append( first_sub ); second_div.append( second_sub ); - // update the split_panes array to remove this split + // update the split_panes array to remove this pane name delete( split_panes[splitpane] ); // now vaporize the current split_N-sub placeholder and create two new panes. - $('#'+splitpane).parent().append(first_div); - $('#'+splitpane).parent().append(second_div); - $('#'+splitpane).remove(); + $('#'+splitpane).append(first_div); + $('#'+splitpane).append(second_div); + $('#'+splitpane+'-sub').remove(); // And split - Split(['#split_'+first,'#split_'+second], { + Split(['#'+pane_name1,'#'+pane_name2], { direction: direction, - sizes: [50,50], + sizes: sizes, gutterSize: 4, minSize: [50,50], }); - // store our new splits for future splits/uses by the main UI. - split_panes['split_'+first +'-sub'] = { 'types': [], 'update_method': update_method1 }; - split_panes['split_'+second+'-sub'] = { 'types': [], 'update_method': update_method2 }; + // store our new split sub-divs for future splits/uses by the main UI. + split_panes[pane_name1] = { 'types': [], 'update_method': update_method1 }; + split_panes[pane_name2] = { 'types': [], 'update_method': update_method2 }; } @@ -63,7 +63,7 @@ var SplitHandler = (function () { minSize: [50,50], }); - split_panes['main-sub'] = {'types': [], 'update_method': 'append'}; + split_panes['main'] = { 'types': [], 'update_method': 'append' }; var input_render = Mustache.render(input_template); $('[data-role-input]').html(input_render); diff --git a/evennia/web/webclient/static/webclient/js/webclient_gui.js b/evennia/web/webclient/static/webclient/js/webclient_gui.js index 4189e026fb..7a7c218921 100644 --- a/evennia/web/webclient/static/webclient/js/webclient_gui.js +++ b/evennia/web/webclient/static/webclient/js/webclient_gui.js @@ -15,6 +15,7 @@ (function () { "use strict" +var num_splits = 0; var options = {}; @@ -167,7 +168,7 @@ function onKeydown (event) { return; } - inputfield.focus(); + //inputfield.focus(); if (code === 13) { // Enter key sends text doSendText(); @@ -245,31 +246,23 @@ function onText(args, kwargs) { known_types.push(msgtype); } - if ( msgtype == 'help' ) { - if (("helppopup" in options) && (options["helppopup"])) { - openPopup("#helpdialog", args[0]); - return; - } - // fall through to the default output - - } else { - // pass this message to each pane that has this msgtype mapped - if( SplitHandler ) { - for ( var key in SplitHandler.split_panes) { - var pane = SplitHandler.split_panes[key]; - // is this message type mapped to this pane? - if ( (pane['types'].length > 0) && pane['types'].includes(msgtype) ) { - // yes, so append/replace this pane's inner div with this message - if ( pane['update_method'] == 'replace' ) { - $('#'+key).html(args[0]) - } else { - $('#'+key).append(args[0]); - var scrollHeight = $('#'+key).parent().prop("scrollHeight"); - $('#'+key).parent().animate({ scrollTop: scrollHeight }, 0); - } - // record sending this message to a pane, no need to update the default div - use_default_pane = false; + // pass this message to each pane that has this msgtype mapped + if( SplitHandler ) { + for ( var key in SplitHandler.split_panes) { + var pane = SplitHandler.split_panes[key]; + // is this message type mapped to this pane? + if ( (pane['types'].length > 0) && pane['types'].includes(msgtype) ) { + // yes, so append/replace this pane's inner div with this message + var text_div = $('#'+key+'-sub'); + if ( pane['update_method'] == 'replace' ) { + text_div.html(args[0]) + } else { + text_div.append(args[0]); + var scrollHeight = text_div.parent().prop("scrollHeight"); + text_div.parent().animate({ scrollTop: scrollHeight }, 0); } + // record sending this message to a pane, no need to update the default div + use_default_pane = false; } } } @@ -441,19 +434,39 @@ function doStartDragDialog(event) { $(document).bind("mouseup", undrag); } - function onSplitDialogClose() { var pane = $("input[name=pane]:checked").attr("value"); var direction = $("input[name=direction]:checked").attr("value"); + var new_pane1 = $("input[name=new_pane1]").val(); + var new_pane2 = $("input[name=new_pane2]").val(); var flow1 = $("input[name=flow1]:checked").attr("value"); var flow2 = $("input[name=flow2]:checked").attr("value"); - SplitHandler.dynamic_split( pane, direction, flow1, flow2 ); + if( new_pane1 == "" ) { + new_pane1 = 'pane_'+num_splits; + num_splits++; + } + + if( new_pane2 == "" ) { + new_pane2 = 'pane_'+num_splits; + num_splits++; + } + + if( document.getElementById(new_pane1) ) { + alert('An element: "' + new_pane1 + '" already exists'); + return; + } + + if( document.getElementById(new_pane2) ) { + alert('An element: "' + new_pane2 + '" already exists'); + return; + } + + SplitHandler.dynamic_split( pane, direction, new_pane1, new_pane2, flow1, flow2, [50,50] ); closePopup("#splitdialog"); } - function onSplitDialog() { var dialog = $("#splitdialogcontent"); dialog.empty(); @@ -467,6 +480,10 @@ function onSplitDialog() { dialog.append(''+ pane +'
'); } + dialog.append("

New Pane Names

"); + dialog.append(''); + dialog.append(''); + dialog.append("

New First Pane Flow

"); dialog.append('append
'); dialog.append('replace
'); diff --git a/evennia/web/webclient/templates/webclient/webclient.html b/evennia/web/webclient/templates/webclient/webclient.html index 2b138cb8bd..b750257048 100644 --- a/evennia/web/webclient/templates/webclient/webclient.html +++ b/evennia/web/webclient/templates/webclient/webclient.html @@ -16,14 +16,12 @@
-
+
- -
-
+