Skip to content

Commit f6c760b

Browse files
SQL query SQL code preview as a popup on hover
1 parent 70edfa2 commit f6c760b

File tree

7 files changed

+84
-4
lines changed

7 files changed

+84
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "CacheUMLExplorer",
3-
"version": "1.3.0",
3+
"version": "1.4.1",
44
"description": "An UML Class explorer for InterSystems Caché",
55
"directories": {
66
"test": "test"

web/css/hoverMessage.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.hoverMessage {
2+
3+
box-sizing: border-box;
4+
white-space: pre-line;
5+
background: rgba(255, 255, 255, 0.9);
6+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
7+
border: 1px solid dimgray;
8+
padding: .3em;
9+
10+
}
11+
12+
.hoverContainer {
13+
14+
position: fixed;
15+
box-sizing: border-box;
16+
left: 0;
17+
top: 0;
18+
padding: 20px;
19+
20+
}

web/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<link rel="stylesheet" href="css/joint.min.css"/>
1313
<link rel="stylesheet" href="css/methodCodeView.css"/>
1414
<link rel="stylesheet" href="css/settingsView.css"/>
15+
<link rel="stylesheet" href="css/hoverMessage.css"/>
1516
<!-- endbuild -->
1617
<!-- build:js -->
1718
<script type="text/javascript" src="jsLib/joint.js"></script>
@@ -25,6 +26,7 @@
2526
<script type="text/javascript" src="js/ClassTree.js"></script>
2627
<script type="text/javascript" src="js/Source.js"></script>
2728
<script type="text/javascript" src="js/UI.js"></script>
29+
<script type="text/javascript" src="js/HoverMessage.js"></script>
2830
<!-- endbuild -->
2931
<link id="favicon" rel="shortcut icon" href="#"/>
3032
</head>

web/js/ClassView.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
498498
keyWordsArray.push(n);
499499
arr.push({
500500
text: n,
501-
icons: self.getPropertyIcons(qrs[n])
501+
icons: self.getPropertyIcons(qrs[n]),
502+
hover: qrs[n]["SqlQuery"]
502503
});
503504
}
504505
return arr;
@@ -610,7 +611,7 @@ ClassView.prototype.confirmRender = function (data) {
610611
uml = joint.shapes.uml, relFrom, relTo,
611612
classes = {}, connector;
612613

613-
console.log(data);
614+
console.log(data); // todo
614615
this.filterInherits(data);
615616

616617
// Reset view and zoom again because it may cause visual damage to icons.
@@ -700,6 +701,8 @@ ClassView.prototype.confirmRender = function (data) {
700701
q.options.height/2 - Math.min(q.options.height/2 - 100, bb.height/2)
701702
);
702703

704+
this.onRendered();
705+
703706
};
704707

705708
ClassView.prototype.loadClass = function (className) {
@@ -947,4 +950,18 @@ ClassView.prototype.init = function () {
947950
return w;
948951
})();
949952

953+
};
954+
955+
ClassView.prototype.onRendered = function () {
956+
957+
[].slice.call(document.querySelectorAll(".line-hoverable")).forEach(function (el) {
958+
var hm = new HoverMessage(el.getAttribute("hovertext"));
959+
el.addEventListener("mouseover", function (e) {
960+
hm.attach(e.pageX || e.clientX, e.pageY || e.clientY);
961+
});
962+
//el.addEventListener("mouseout", function () {
963+
// hm.detach();
964+
//});
965+
});
966+
950967
};

web/js/HoverMessage.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
var HoverMessage = function (text) {
2+
3+
var self = this;
4+
5+
this.element = document.createElement("div");
6+
this.element.className = "hoverMessage";
7+
this.element.textContent = text;
8+
this.container = document.createElement("div");
9+
this.container.className = "hoverContainer";
10+
this.container.appendChild(this.element);
11+
12+
this.container.addEventListener("mouseout", function (event) {
13+
var e = event.toElement || event.relatedTarget;
14+
if (e.parentNode == this || e == this) return;
15+
self.detach();
16+
});
17+
18+
};
19+
20+
HoverMessage.prototype.attach = function (screenX, screenY) {
21+
22+
var e = this.container,
23+
w = Math.min(400, window.innerWidth/2);
24+
document.body.appendChild(e);
25+
e.style.width = (w = Math.min(e.offsetWidth, window.innerWidth/2)) + "px";
26+
e.style.top = (screenY - e.offsetHeight + 15) + "px";
27+
e.style.left = Math.min(window.innerWidth - w - 10, screenX - w/2) + "px";
28+
29+
};
30+
31+
HoverMessage.prototype.detach = function () {
32+
33+
if (!this.element.parentNode) return;
34+
35+
this.container.parentNode.removeChild(this.container);
36+
37+
};

web/js/Source.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var Source = function (cacheUMLExplorer) {
22

33
this.URL = window.location.protocol + "//" + window.location.hostname + ":" +
4-
57773/*build.replace:window.location.port*/ + "/UMLExplorer";
4+
57776/*build.replace:window.location.port*/ + "/UMLExplorer";
55

66
this.cue = cacheUMLExplorer;
77

web/jsLib/joint.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17232,6 +17232,10 @@ if ( typeof window === "object" && typeof window.document === "object" ) {
1723217232
tspan.node.addEventListener("click", lines[i]["clickHandler"]);
1723317233
tspan.addClass('line-clickable');
1723417234
}
17235+
if (typeof lines[i]["hover"] === "string") {
17236+
tspan.addClass('line-hoverable');
17237+
tspan.node.setAttribute("hovertext", lines[i]["hover"]);
17238+
}
1723517239

1723617240
// Make sure the textContent is never empty. If it is, add an additional
1723717241
// space (an invisible character) so that following lines are correctly

0 commit comments

Comments
 (0)