Skip to content

Commit 7ee66c5

Browse files
committed
WIP: bootstrap tour, fixed scrollto issue with jquery.scrollTo and svg highlighting issue
1 parent f6dcd07 commit 7ee66c5

File tree

5 files changed

+125
-9
lines changed

5 files changed

+125
-9
lines changed

visualise/static/js/visualise/tour.js

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
function startTour(force_start){
2+
var upcoming_step = null; // hack to know upcoming step in onShow
3+
function next(t) {
4+
// console.log("next, cur: " + t.getCurrentStep());
5+
upcoming_step = t.getCurrentStep() + 1;
6+
}
7+
function prev(t) {
8+
// console.log("prev, cur: " + t.getCurrentStep());
9+
upcoming_step = t.getCurrentStep() - 1;
10+
}
11+
212
function autoScrollSideBar(t) {
3-
// to be called onShow, hence the currentstep + 1 below
4-
var element = t.getStep(t.getCurrentStep() + 1).element;
13+
// sadly not set at this point
14+
// var element_offset = $("#sidebar-container .tour-step-backdrop").offset().top;
15+
16+
// to be called onShow, hence upcoming_step hack
17+
var us = upcoming_step !== null ? upcoming_step : t.getCurrentStep();
18+
var element = t.getStep(us).element;
519
if (!element) {
620
console.warn("autoScrollSideBar called, but can't get element");
721
return;
822
}
9-
var element_offset = $(element).offset().top;
10-
$("#sidebar-container").animate({scrollTop: element_offset}, 200);
23+
// var element_offset = $(element).offset().top;
24+
$("#sidebar-container").scrollTo(element, 200, {offset:-50});
1125
}
1226

1327
function fixupSVGHighlighting(t) {
@@ -17,10 +31,20 @@ function startTour(force_start){
1731
console.warn("fixupSVGHighlighting called, but can't get element");
1832
return;
1933
}
20-
console.log('dim:');
21-
console.log($(element).width());
22-
console.log($(element).height());
23-
$(".tour-step-background").width($(element).width()).height($(element).height());
34+
35+
// need to fix highlight area as it doesn't properly get dimensions
36+
var r = $(element)[0].getBoundingClientRect();
37+
// var p = tour.getOptions();
38+
// console.log($(element).width());
39+
// console.log($(element).height());
40+
$(".tour-step-background").width(r.width + 10).height(r.height + 10);
41+
42+
// also raise the svg element above the backdrop
43+
$("#canvas").children("svg").attr("class", "tour-step-backdrop");
44+
}
45+
46+
function fixupSVGHighlightingRemove(t) {
47+
$("#canvas").children("svg").removeAttr("class");
2448
}
2549

2650
var tour = new Tour({
@@ -29,6 +53,8 @@ function startTour(force_start){
2953
// autoscroll: true, // doesn't seem to work
3054
orphan: true,
3155
debug: true,
56+
onNext: next,
57+
onPrev: prev,
3258
steps: [
3359
{
3460
content: "Welcome to the result visualisation of our <a href='https://w3id.org/associations/#gp_learner'>graph pattern learner</a>.<br>As the interface is quite powerful, this tour will briefly explain its components."
@@ -63,10 +89,47 @@ function startTour(force_start){
6389
placement: 'left',
6490
content: "You can also execute the SPARQL query for the current pattern pre-filled with the individual source node."
6591
},
92+
{
93+
element: '#sidebar-SPARQL-panel',
94+
onShow: autoScrollSideBar,
95+
placement: 'left',
96+
content: "Here you can find the SPARQL SELECT query for the selected pattern that was learned and can execute it."
97+
},
98+
{
99+
element: '#graph svg>g',
100+
onShown: fixupSVGHighlighting,
101+
onHide: fixupSVGHighlightingRemove,
102+
content: "Instead of reading the ugly text version on the right, here you see a graphical representation of the pattern."
103+
},
66104
{
67105
element: '#graph svg>g',
68106
onShown: fixupSVGHighlighting,
69-
content: "This is a tooltip."
107+
onHide: fixupSVGHighlightingRemove,
108+
content: "The ?source and ?target are special variables that were filled with the ground truth pairs on listed on the right during training."
109+
},
110+
{
111+
element: '#sidebar-select-panel',
112+
onShow: autoScrollSideBar,
113+
placement: 'left',
114+
backdrop: false,
115+
reflex: true,
116+
content: "Select another pattern and see how everything else is updated..."
117+
},
118+
{
119+
element: '#matrix-nav',
120+
onShow: autoScrollSideBar,
121+
placement: 'bottom',
122+
backdrop: false,
123+
reflex: true,
124+
onNext: function (t) {$("#matrix-nav > a").click(); next(t);},
125+
content: "After we've now seen how you can quickly explore the learned graph patterns, let's switch to the matrix tab."
126+
},
127+
{
128+
element: '#main-content',
129+
// onShow: autoScrollSideBar,
130+
//placement: 'bottom',
131+
onPrev: function (t) {$("#graph-nav > a").click(); prev(t);},
132+
content: "The matrix tab gives an overview about how the patterns cover the ground truth pairs. Each block represents one ground truth pair. Just hover over them to see how the currently selected graph pattern covers each of them."
70133
},
71134
{
72135
element: document.querySelectorAll('#step2')[0],
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* ========================================================================
2+
* bootstrap-tour - v0.10.2
3+
* http://bootstraptour.com
4+
* ========================================================================
5+
* Copyright 2012-2015 Ulrich Sossou
6+
*
7+
* ========================================================================
8+
* Licensed under the MIT License (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* https://opensource.org/licenses/MIT
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
* ========================================================================
20+
*/
21+
22+
.tour-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1100;background-color:#000;opacity:.8;filter:alpha(opacity=80)}.tour-step-backdrop{position:relative;z-index:1101;}.tour-step-backdrop>td{position:relative;z-index:1101}.tour-step-background{position:absolute!important;z-index:1100;background:inherit;border-radius:6px}.popover[class*=tour-]{z-index:1102}.popover[class*=tour-] .popover-navigation{padding:9px 14px}.popover[class*=tour-] .popover-navigation [data-role=end]{float:right}.popover[class*=tour-] .popover-navigation [data-role=prev],.popover[class*=tour-] .popover-navigation [data-role=next],.popover[class*=tour-] .popover-navigation [data-role=end]{cursor:pointer}.popover[class*=tour-] .popover-navigation [data-role=prev].disabled,.popover[class*=tour-] .popover-navigation [data-role=next].disabled,.popover[class*=tour-] .popover-navigation [data-role=end].disabled{cursor:default}.popover[class*=tour-].orphan{position:fixed;margin-top:0}.popover[class*=tour-].orphan .arrow{display:none}

0 commit comments

Comments
 (0)