Skip to content

Commit b559bbe

Browse files
committed
better editor panel resize
1 parent 6a0e105 commit b559bbe

5 files changed

Lines changed: 43 additions & 46 deletions

File tree

css/iconbar.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
height: 48px;
44
font-family: Arial, Helvetica, sans-serif;
55
margin-top: 5px;
6+
overflow: hidden; /* if the editor is too narrow, it flows to multiple lines */
67
}
78

89
.iconbar a {

css/main.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,15 @@ body {
560560
text-align: center;
561561
min-height: 150px;
562562
min-width: 300px;
563-
max-height: 500px;
564-
max-width: 800px;
563+
max-height: 80%;
564+
max-width: 80%;
565565
}
566566

567567
/*Drgable */
568568

569569
.popup {
570570
position: absolute;
571-
/*resize: both; !*enable this to css resize*! */
572-
overflow: auto;
571+
overflow: hidden;
573572
}
574573

575574
.popup-header {
@@ -581,6 +580,10 @@ body {
581580
color: #fff;
582581
}
583582

583+
.popup-content {
584+
margin-bottom: 6px;
585+
}
586+
584587
/*Resizeable*/
585588

586589
.popup .resizer-right {
@@ -591,25 +594,27 @@ body {
591594
right: 0;
592595
bottom: 0;
593596
cursor: e-resize;
597+
z-index: 100;
594598
}
595599

596600
.popup .resizer-bottom {
597601
width: 100%;
598-
height: 10px;
599-
background: red;
602+
height: 6px;
603+
background: transparent;
600604
position: absolute;
601605
right: 0;
602606
bottom: 0;
603-
cursor: n-resize;
607+
cursor: s-resize;
608+
z-index: 100;
604609
}
605610

606611
.popup .resizer-both {
607-
width: 5px;
608-
height: 5px;
612+
width: 10px;
613+
height: 10px;
609614
background: transparent;
610-
z-index: 10;
615+
z-index: 100;
611616
position: absolute;
612617
right: 0;
613618
bottom: 0;
614-
cursor: nw-resize;
619+
cursor: se-resize;
615620
}

icons/validate.svg

Lines changed: 1 addition & 1 deletion
Loading

src/ui/editor/survey.js

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ class SurveyEditor extends Editor {
244244
`Survey editor: ${this.survey.name}`,
245245
true,
246246
() => this.closeEditor(),
247-
(_newWidth, newHeight) => this.table.setHeight(newHeight - 100),
247+
(_newWidth, _newHeight) => {
248+
this.table.setHeight(this.panel.offsetHeight - 100); // we cannot use newHeight, because it could be a higher value than max-height
249+
},
250+
248251
() => {
249252
this.table.redraw();
250253
}
@@ -290,19 +293,6 @@ class SurveyEditor extends Editor {
290293
},
291294
{ id: 'update-survey', tooltip: 'Update survey', icon: 'icons/update.svg', click: () => this.updateSurvey() },
292295
{ separator: true },
293-
{
294-
id : 'splays-toggle',
295-
tooltip : 'Show / hide splays',
296-
icon : 'icons/splay.svg',
297-
click : () => {
298-
if (this.iconSelected['splays-toggle'] === true) {
299-
this.table.addFilter(showOrphans);
300-
} else if (this.iconSelected['splays-toggle'] === false) {
301-
this.table.addFilter(hideOrphans);
302-
}
303-
}
304-
},
305-
{ separator: true },
306296
{
307297
id : 'xyz-toggle',
308298
tooltip : 'Toggle XYZ',
@@ -366,7 +356,7 @@ class SurveyEditor extends Editor {
366356

367357
});
368358

369-
this.panel.appendChild(U.node`<div id="surveydata"></div>`);
359+
this.panel.appendChild(U.node`<div id="surveydata" class="popup-content"></div>`);
370360

371361
var isFloatNumber = function (_cell, value) {
372362
return U.isFloatStr(value);
@@ -404,18 +394,6 @@ class SurveyEditor extends Editor {
404394
cell.getRow().reformat();
405395
};
406396

407-
function showCenter(data) {
408-
return data.type === 'center';
409-
}
410-
411-
function hideOrphans(data) {
412-
return data.status !== 'orphan';
413-
}
414-
415-
function showOrphans(data) {
416-
return data.status === 'orphan';
417-
}
418-
419397
const columns = [
420398
{
421399
width : 25,
@@ -564,10 +542,10 @@ class SurveyEditor extends Editor {
564542
clipboardPasteAction : 'range',
565543

566544
// pagination
567-
pagination : true,
568-
paginationSize : this.options.tabulator.paginationSize, // From config.js
569-
paginationSizeSelector : [this.options.tabulator.paginationSize, 10, 25, 50, 100], // optional: shows the dropdown to select page size
570-
paginationCounter : 'rows', // optional: shows the current page size
545+
// pagination : true,
546+
// paginationSize : this.options.tabulator.paginationSize, // From config.js
547+
// paginationSizeSelector : [this.options.tabulator.paginationSize, 10, 25, 50, 100], // optional: shows the dropdown to select page size
548+
// paginationCounter : 'rows', // optional: shows the current page size
571549

572550
rowContextMenu : this.baseTableFunctions.getContextMenu(),
573551
rowHeader : {

src/ui/popups.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,22 @@ function makeMovable(panel, headerText, resizable = true, closeFn, doDragFn, sto
6969
pos2 = pos4 - e.clientY;
7070
pos3 = e.clientX;
7171
pos4 = e.clientY;
72-
// set the element's new position:
73-
elmnt.style.top = elmnt.offsetTop - pos2 + 'px';
74-
elmnt.style.left = elmnt.offsetLeft - pos1 + 'px';
72+
73+
// Calculate new position
74+
let newTop = elmnt.offsetTop - pos2;
75+
let newLeft = elmnt.offsetLeft - pos1;
76+
77+
// Clamp to viewport
78+
const minTop = 0;
79+
const minLeft = 0;
80+
const maxTop = window.innerHeight - elmnt.offsetHeight;
81+
const maxLeft = window.innerWidth - elmnt.offsetWidth;
82+
83+
newTop = Math.max(minTop, Math.min(newTop, maxTop));
84+
newLeft = Math.max(minLeft, Math.min(newLeft, maxLeft));
85+
86+
elmnt.style.top = newTop + 'px';
87+
elmnt.style.left = newLeft + 'px';
7588
}
7689

7790
function initDrag(e) {

0 commit comments

Comments
 (0)