Skip to content

Commit 596cb85

Browse files
committed
Demo: More display options
- Demo: Added option to compact rows, locking their heights to the minimum required to show links. - Demo: Added option slider for setting the link slot interval on the fly. - Config: Moved all user options directly into the Config object for easy access/modification. - Main: Separated `.init()` and `.draw()` -- The visualisation can now be redrawn (to account for new display options) without unduly affecting Word/Link handle positions, etc. - Build: Added verbose flag to demo CSS watch task
1 parent 5ee0c32 commit 596cb85

File tree

19 files changed

+310
-671
lines changed

19 files changed

+310
-671
lines changed

demo/demo.min.css

Lines changed: 41 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/demo.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/demo.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/index.html

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ <h5 class="modal-title" id="options-title">Options</h5>
176176
</div>
177177

178178
<div class="modal-body">
179-
<div class="p-3">
179+
<div class="px-3">
180180
Show the following category of top links:
181181
<select id="tag-option-top-links" class="custom-select mb-3">
182182
<!-- Options will be added at run time in `demo.js` based on the categories available in the
@@ -202,7 +202,7 @@ <h5 class="modal-title" id="options-title">Options</h5>
202202
</label>
203203
</div>
204204

205-
<div class="custom-control custom-checkbox mt-3">
205+
<div class="custom-control custom-checkbox">
206206
<input type="checkbox" class="custom-control-input" id="tag-option-top-main-label">
207207
<label class="custom-control-label" for="tag-option-top-main-label">
208208
Show main label on top links
@@ -227,6 +227,28 @@ <h5 class="modal-title" id="options-title">Options</h5>
227227
Show argument labels on bottom links
228228
</label>
229229
</div>
230+
231+
<div class="custom-control custom-checkbox mt-3">
232+
<input type="checkbox" class="custom-control-input" id="tag-option-compact">
233+
<label class="custom-control-label" for="tag-option-compact">
234+
Lock rows to the minimum height needed to fit links
235+
</label>
236+
</div>
237+
238+
<div class="form-group mt-3">
239+
<div>Link slot interval</div>
240+
<div class="form-row">
241+
<div class="d-flex">
242+
<div class="col-auto">
243+
<input id="tag-option-link-slot" type="text"
244+
title="Link slot interval">
245+
</div>
246+
<div class="col">
247+
<span id="tag-option-link-slot-value"></span>
248+
</div>
249+
</div>
250+
</div>
251+
</div>
230252
</div>
231253

232254
</div>

demo/src/demo.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ const tplTaxonomy = require("./taxonomy.hbs");
3333
const Handlebars = require("hbsfy/runtime");
3434
Handlebars.registerPartial("taxonomySubtree", tplTaxonomy);
3535

36+
// Sliders for setting display options on the fly
37+
require("bootstrap-slider");
38+
3639
// The colour picker script itself is included in the main HTML, because it
3740
// doesn't play nice with Browserify. Here we expose the jquery globals it
3841
// needs.
@@ -202,6 +205,17 @@ $(async () => {
202205

203206
refreshLinkCategories();
204207

208+
const $optionCompact = $("#tag-option-compact");
209+
$optionCompact
210+
.prop("checked", uiTag.getOption("compactRows"))
211+
.on("change", () => {
212+
uiTag.setOption(
213+
"compactRows",
214+
$optionCompact[0].checked
215+
);
216+
uiTag.draw();
217+
});
218+
205219
const $optionTopLinksOnMove = $("#tag-option-top-links-on-move");
206220
$optionTopLinksOnMove
207221
.prop("checked", uiTag.getOption("showTopLinksOnMove"))
@@ -211,7 +225,6 @@ $(async () => {
211225
$optionTopLinksOnMove[0].checked
212226
);
213227
});
214-
215228
const $optionBottomLinksOnMove = $("#tag-option-bottom-links-on-move");
216229
$optionBottomLinksOnMove
217230
.prop("checked", uiTag.getOption("showBottomLinksOnMove"))
@@ -247,6 +260,33 @@ $(async () => {
247260
uiTag.setBottomArgLabelVisibility($optionBottomArgLabels[0].checked);
248261
});
249262

263+
// We can change various drawing options on the fly.
264+
// This example uses a slider to change the intervals for overlapping links.
265+
const $optionLinkSlot = $("#tag-option-link-slot");
266+
const $optionLinkSlotValue = $("#tag-option-link-slot-value");
267+
$optionLinkSlot.slider({
268+
min: 10,
269+
max: 200,
270+
step: 10,
271+
value: uiTag.getOption("linkSlotInterval"),
272+
tooltip: "hide"
273+
});
274+
$optionLinkSlotValue.text($optionLinkSlot.val());
275+
$optionLinkSlot.on("slide", (event) => {
276+
$optionLinkSlotValue.text(event.value);
277+
uiTag.setOption("linkSlotInterval", event.value);
278+
uiTag.draw();
279+
});
280+
// For direct click events, we need to target the slider directly, rather
281+
// than our initial text input
282+
$optionLinkSlot.siblings(".slider").on("click", () => {
283+
const newValue = $optionLinkSlot.slider("getValue");
284+
$optionLinkSlotValue.text(newValue);
285+
uiTag.setOption("linkSlotInterval", newValue);
286+
uiTag.draw();
287+
});
288+
289+
250290
// --------------------------------------------------------------------------
251291

252292
// The `.exportSvg()` function can be used to save the current

demo/src/demo.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
@import "../../node_modules/bootstrap/scss/bootstrap";
66
// Import Prismjs styles
77
@import "../../node_modules/prismjs/themes/prism";
8+
// Import Bootstrap-slider styles
9+
@import "../../node_modules/bootstrap-slider/dist/css/bootstrap-slider";
810
// Core TAG styles
911
@import "../../dist/tag/css/tag";
1012

@@ -62,6 +64,16 @@
6264
width: 100px;
6365
}
6466

67+
// Styles for the bootstrap-slider plugin
68+
.slider.slider-horizontal {
69+
width: 300px;
70+
}
71+
72+
.slider-selection {
73+
background: #337ab7;
74+
opacity: 0.75;
75+
}
76+
6577
// Fonts used in the visualisation
6678
// The actual loading of the font happens at the start of `demo.js` via the Web Font Loader
6779
svg, svg text {

dist/tag/css/tag.css

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tag/css/tag.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tag/css/tag.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/tag/css/tag.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)