diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.js index d018d500c..126485f72 100644 --- a/src/public/app/widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_detail.js @@ -224,6 +224,7 @@ export default class AttributeDetailWidget extends TabAwareWidget { this.$widget = $(TPL); utils.bindElShortcut(this.$widget, 'ctrl+return', () => this.saveAndClose()); + utils.bindElShortcut(this.$widget, 'escape', () => alert("H!")); this.contentSized(); @@ -452,42 +453,42 @@ export default class AttributeDetailWidget extends TabAwareWidget { this.toggleInt(true); const offset = this.parent.$widget.offset(); + const detPosition = this.getDetailPosition(x, offset); - const left = x - offset.left - this.$widget.outerWidth() / 2; - - if (left < 0) { - this.$widget - .css("left", "10px") - .css("right", ""); - } - else { - 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); + this.$widget + .css("left", detPosition.left) + .css("right", detPosition.right) + .css("top", y - offset.top + 70) + .css("max-height", + this.$widget.outerHeight() + y > $(window).height() - 50 + ? $(window).height() - y - 50 + : 10000); 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() { let {results, count} = await server.post('search-related', this.attribute);