Mercurial > hg > NetworkVis
comparison d3s_examples/python-neo4jrestclient/static/platin/js/Map/MapPopup.js @ 8:18ef6948d689
new d3s examples
author | Dirk Wintergruen <dwinter@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 01 Oct 2015 17:17:27 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
7:45dad9e38c82 | 8:18ef6948d689 |
---|---|
1 /* | |
2 * MapPopup.js | |
3 * | |
4 * Copyright (c) 2012, Stefan Jänicke. All rights reserved. | |
5 * | |
6 * This library is free software; you can redistribute it and/or | |
7 * modify it under the terms of the GNU Lesser General Public | |
8 * License as published by the Free Software Foundation; either | |
9 * version 3 of the License, or (at your option) any later version. | |
10 * | |
11 * This library is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * Lesser General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU Lesser General Public | |
17 * License along with this library; if not, write to the Free Software | |
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
19 * MA 02110-1301 USA | |
20 */ | |
21 | |
22 /** | |
23 * @class MapPopup | |
24 * map popup implementaion | |
25 * @author Stefan Jänicke (stjaenicke@informatik.uni-leipzig.de) | |
26 * @release 1.0 | |
27 * @release date: 2012-07-27 | |
28 * @version date: 2012-07-27 | |
29 */ | |
30 function MapPopup(parent) { | |
31 | |
32 this.parentDiv = parent.gui.mapWindow; | |
33 | |
34 this.initialize = function(x, y, onclose) { | |
35 | |
36 var popup = this; | |
37 this.x = x; | |
38 this.y = y; | |
39 | |
40 this.popupDiv = document.createElement("div"); | |
41 this.popupDiv.setAttribute('class', 'ddbPopupDiv'); | |
42 this.parentDiv.appendChild(this.popupDiv); | |
43 | |
44 this.cancel = document.createElement("div"); | |
45 this.cancel.setAttribute('class', 'ddbPopupCancel'); | |
46 this.cancel.title = GeoTemConfig.getString('close'); | |
47 this.cancel.onclick = function() { | |
48 if ( typeof onclose != 'undefined') { | |
49 onclose(); | |
50 } | |
51 popup.reset(); | |
52 } | |
53 | |
54 this.input = document.createElement("div"); | |
55 this.input.style.maxWidth = Math.floor(this.parentDiv.offsetWidth * 0.75) + "px"; | |
56 this.input.style.maxHeight = Math.floor(this.parentDiv.offsetHeight * 0.75) + "px"; | |
57 this.input.setAttribute('class', 'ddbPopupInput'); | |
58 | |
59 this.popupDiv.appendChild(this.input); | |
60 this.popupDiv.appendChild(this.cancel); | |
61 | |
62 var peak = document.createElement("div"); | |
63 peak.setAttribute('class', 'popupPeak'); | |
64 this.popupDiv.appendChild(peak); | |
65 var topRight = document.createElement("div"); | |
66 topRight.setAttribute('class', 'popupTopRight'); | |
67 this.popupDiv.appendChild(topRight); | |
68 var bottomRight = document.createElement("div"); | |
69 bottomRight.setAttribute('class', 'popupBottomRight'); | |
70 this.popupDiv.appendChild(bottomRight); | |
71 this.popupRight = document.createElement("div"); | |
72 this.popupRight.setAttribute('class', 'popupRight'); | |
73 this.popupDiv.appendChild(this.popupRight); | |
74 this.popupBottom = document.createElement("div"); | |
75 this.popupBottom.setAttribute('class', 'popupBottom'); | |
76 this.popupDiv.appendChild(this.popupBottom); | |
77 | |
78 } | |
79 | |
80 this.setContent = function(content) { | |
81 $(this.input).empty(); | |
82 this.visible = true; | |
83 $(this.input).append(content); | |
84 this.decorate(); | |
85 } | |
86 | |
87 this.reset = function() { | |
88 $(this.popupDiv).remove(); | |
89 this.visible = false; | |
90 } | |
91 | |
92 this.decorate = function() { | |
93 this.popupRight.style.height = (this.popupDiv.offsetHeight - 14) + "px"; | |
94 this.popupBottom.style.width = (this.popupDiv.offsetWidth - 22) + "px"; | |
95 this.left = this.x + 9; | |
96 this.top = this.y - 10 - this.popupDiv.offsetHeight; | |
97 this.popupDiv.style.left = this.left + "px"; | |
98 this.popupDiv.style.top = this.top + "px"; | |
99 var shiftX = 0, shiftY = 0; | |
100 if (this.popupDiv.offsetTop < parent.gui.headerHeight + 10) { | |
101 shiftY = -1 * (parent.gui.headerHeight + 10 - this.popupDiv.offsetTop); | |
102 } | |
103 if (this.popupDiv.offsetLeft + this.popupDiv.offsetWidth > parent.gui.headerWidth - 10) { | |
104 shiftX = -1 * (parent.gui.headerWidth - 10 - this.popupDiv.offsetLeft - this.popupDiv.offsetWidth); | |
105 } | |
106 parent.shift(shiftX, shiftY); | |
107 } | |
108 | |
109 this.shift = function(x, y) { | |
110 this.left = this.left - this.x + x; | |
111 this.top = this.top - this.y + y; | |
112 this.x = x; | |
113 this.y = y; | |
114 if (this.left + this.popupDiv.offsetWidth > this.parentDiv.offsetWidth) { | |
115 this.popupDiv.style.left = 'auto'; | |
116 this.popupDiv.style.right = (this.parentDiv.offsetWidth - this.left - this.popupDiv.offsetWidth) + "px"; | |
117 } else { | |
118 this.popupDiv.style.right = 'auto'; | |
119 this.popupDiv.style.left = this.left + "px"; | |
120 } | |
121 this.popupDiv.style.top = this.top + "px"; | |
122 } | |
123 } |