fixes in attr detail positioning

This commit is contained in:
zadam 2020-09-02 16:06:35 +02:00
parent 0745d9ec0b
commit e8114fcc4f

View File

@ -224,6 +224,7 @@ export default class AttributeDetailWidget extends TabAwareWidget {
this.$widget = $(TPL); this.$widget = $(TPL);
utils.bindElShortcut(this.$widget, 'ctrl+return', () => this.saveAndClose()); utils.bindElShortcut(this.$widget, 'ctrl+return', () => this.saveAndClose());
utils.bindElShortcut(this.$widget, 'escape', () => alert("H!"));
this.contentSized(); this.contentSized();
@ -452,42 +453,42 @@ export default class AttributeDetailWidget extends TabAwareWidget {
this.toggleInt(true); this.toggleInt(true);
const offset = this.parent.$widget.offset(); const offset = this.parent.$widget.offset();
const detPosition = this.getDetailPosition(x, offset);
const left = x - offset.left - this.$widget.outerWidth() / 2; this.$widget
.css("left", detPosition.left)
if (left < 0) { .css("right", detPosition.right)
this.$widget .css("top", y - offset.top + 70)
.css("left", "10px") .css("max-height",
.css("right", ""); this.$widget.outerHeight() + y > $(window).height() - 50
} ? $(window).height() - y - 50
else { : 10000);
const right = left + this.$widget.outerWidth();
if (right > $(window).width() - 10) {
this.$widget
.css("left", "")
.css("right", "10px");
}
else {
this.$widget
.css("left", left)
.css("right", "");
}
}
this.$widget.css("top", y - offset.top + 70);
// so that the detail window always fits
this.$widget.css("max-height",
this.$widget.outerHeight() + y > $(window).height() - 50
? $(window).height() - y - 50
: 10000);
if (focus === 'name') { if (focus === 'name') {
this.$inputName.focus().select(); this.$inputName
.trigger('focus')
.trigger('select');
} }
} }
getDetailPosition(x, offset) {
let left = x - offset.left - this.$widget.outerWidth() / 2;
let right = "";
if (left < 0) {
left = 10;
} else {
const rightEdge = left + this.$widget.outerWidth();
if (rightEdge > this.parent.$widget.outerWidth() - 10) {
left = "";
right = 10;
}
}
return {left, right};
}
async updateRelatedNotes() { async updateRelatedNotes() {
let {results, count} = await server.post('search-related', this.attribute); let {results, count} = await server.post('search-related', this.attribute);