/** * The page's geometry: the grip that divides panes from results, the * columns a screen lays its panes out in, the editors over the textareas, * the interface modes, drag and drop. Mixed onto ShExBaseApp; see * ShExBaseApp.js. * * This is doc/ShExBaseApp-layout.js's source (tsconfig.app.json compiles src/app/ into * doc/); edit here and run `npm run build`. */ mixin(ShExBaseApp, { /** * The top edge of the results is a handle. * * The page is a fixed division -- panes above, results below -- and how * much each gets depends on what you are doing: reading a long result, or * writing a long schema. Dragging the edge says which, and the panes * take (or give up) what the results don't (or do). */ prepareResultsGrip() { const grip = $("#resultsGrip"); if (grip.length === 0) return; const least = 48; // px: the tab strip, and enough result to know it is there let dragging = false; const divideAt = (y) => { // innerHeight rather than $(window).height(): the latter reads a // layout, and asks it of a document that may not have one const page = window.innerHeight || 0; const most = page > 2 * least ? page - least : Infinity; const height = Math.min(Math.max(page - y, least), most); $("#results").css("flex", "0 0 " + Math.round(height) + "px"); // a pane that just changed size measures again, editors included this.remeasureScreenPanes(this.currentScreen()); }; grip.on("mousedown", (evt) => { dragging = true; evt.preventDefault(); // or the drag selects the page instead }); $(document).on("mousemove.shexjsGrip", (evt) => { if (dragging) divideAt(evt.clientY); }); $(document).on("mouseup.shexjsGrip", () => { dragging = false; }); }, /** the row of columns a screen's panes lay out in: the toolbar and the * statusbar are the screen's other children, and go under it */ screenColumns(screen) { let row = screen.children(".screenColumns").first(); if (row.length === 0) row = $("
").addClass("screenColumns").prependTo(screen); return row; }, /** * The tab set panes take turns in, made on demand (§4). * * A column can hold one pane at a time as well as several at once: the * schema and the overlay it is read with are the same column of * ShExReduce's screen, a tab each -- which is what the data source's own * documents do in #dataPaneTabs. `tabs:` names the set, `label:` names * the tab, and the panes that share a set share a column in declaration * order. */ paneTabset(pane, screen, columns) { const key = pane.panel === undefined ? "" : pane.panel; if (!columns.has(key)) columns.set(key, $("
").addClass("panel").attr("data-panel", key || null) .appendTo(this.screenColumns(screen))); let set = $("#" + pane.tabs); if (set.length === 0) { set = $("
").attr({ id: pane.tabs, "data-tabset": "" }).appendTo(columns.get(key)); $("