Skip to content

Commit c40ddb5

Browse files
committed
Provide menu.info function
Use it instead of alert to show camera position as URL
1 parent ce19170 commit c40ddb5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

scripts/JSRoot.geom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ JSROOT.define(['d3', 'three', 'geobase', 'painter', 'base3d'], (d3, THREE, geo,
679679
menu.add("Reset camera position", () => this.focusCamera());
680680

681681
if (!this._geom_viewer)
682-
menu.add("Get camera position", () => alert("Position (as url): &opt=" + this.produceCameraUrl()));
682+
menu.add("Get camera position", () => menu.info("Position (as url)", "&opt=" + this.produceCameraUrl()));
683683

684684
if (!this.ctrl.project)
685685
menu.addchk(this.ctrl.rotate, "Autorotate", () => this.setAutoRotate(!this.ctrl.rotate));

scripts/JSRoot.menu.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,30 @@ JSROOT.define(['d3', 'jquery', 'painter', 'jquery-ui'], (d3, $, jsrp) => {
159159
if (!without_sub) this.add("endsub:");
160160
}
161161

162+
/** @summary Show modal info dialog
163+
* @protected */
164+
info(title, message) {
165+
let dlg_id = this.menuname + "_dialog";
166+
let old_dlg = document.getElementById(dlg_id);
167+
if (old_dlg) old_dlg.parentNode.removeChild(old_dlg);
168+
$(document.body).append(
169+
`<div id="${dlg_id}">
170+
<p tabindex="0">${message}</p>
171+
</div>`);
172+
let dialog = $("#" + dlg_id).dialog({
173+
height: 120,
174+
width: 400,
175+
modal: true,
176+
resizable: true,
177+
title: title,
178+
close: () => dialog.remove()
179+
});
180+
}
181+
162182
/** @summary Input value
163183
* @returns {Promise} with input value
164184
* @protected */
165185
input(title, value, kind) {
166-
167186
let dlg_id = this.menuname + "_dialog";
168187
let old_dlg = document.getElementById(dlg_id);
169188
if (old_dlg) old_dlg.parentNode.removeChild(old_dlg);

0 commit comments

Comments
 (0)