-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize.js
135 lines (124 loc) · 5.42 KB
/
resize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//----------------------------------------------------------------------
// Copyright (c) 2012-2015 Raytheon BBN Technologies
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and/or hardware specification (the "Work") to
// deal in the Work without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Work, and to permit persons to whom the Work
// is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Work.
//
// THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS
// IN THE WORK.
//----------------------------------------------------------------------
function stopRecentering() {
if (window.hasOwnProperty('map_resize')) {
// console.log("Firing resize timeout");
clearInterval(window.map_resize.interval);
delete window.map_resize;
}
}
function keepMapCentered() {
if (window.hasOwnProperty('map')) {
if (window.hasOwnProperty('map_resize')) {
clearTimeout(window.map_resize.timeout);
window.map_resize.timeout = setTimeout(stopRecentering, 1000);
} else {
var map = window.map;
window.map_resize = Object();
window.map_resize.center = map.getCenter();
window.map_resize.interval = setInterval(function() {
// console.log("Firing resize interval");
map.panTo(window.map_resize.center);
}, 100);
window.map_resize.timeout = setTimeout(stopRecentering, 1000);
}
}
}
function resizeLayout(evt) {
w = $( window ).width();
h = $( window ).height();
//console.log("w: " + w + "; h: " + h);
w3 = Math.floor(w/3);
h3 = Math.floor(h/3);
var chartExists3 = document.getElementById("chart_div_bottom3");
var chartExists1 = document.getElementById("chart_div_right1");
if (chartExists3) {
if (chartExists1) {
mapw = w3 * 2;
} else {
mapw = w;
}
maph = h3 * 2;
} else {
mapw = w;
maph = h;
}
// Set up an interval to keep the map center steady
keepMapCentered();
$("#map-canvas").css({"position": "fixed",
"top": 0,
"left": 0,
"width": mapw + "px",
"min-width": mapw + "px",
"max-width": mapw + "px",
"height": maph + "px",
"min-height": maph + "px",
"max-height": maph + "px"});
$("#chart_div_right1").css({"position": "fixed",
"top": 0,
"left": mapw,
"width": w3 + "px",
"min-width": w3 + "px",
"max-width": w3 + "px",
"height": h3 + "px",
"min-height": h3 + "px",
"max-height": h3 + "px"});
$("#chart_div_right2").css({"position": "fixed",
"top": h3,
"left": mapw,
"width": w3 + "px",
"min-width": w3 + "px",
"max-width": w3 + "px",
"height": h3 + "px",
"min-height": h3 + "px",
"max-height": h3 + "px"});
$("#chart_div_bottom3").css({"position": "fixed",
"top": maph,
"left": 0,
"width": w3 + "px",
"min-width": w3 + "px",
"max-width": w3 + "px",
"height": h3 + "px",
"min-height": h3 + "px",
"max-height": h3 + "px"});
$("#chart_div_bottom4").css({"position": "fixed",
"top": maph,
"left": w3,
"width": w3 + "px",
"min-width": w3 + "px",
"max-width": w3 + "px",
"height": h3 + "px",
"min-height": h3 + "px",
"max-height": h3 + "px"});
$("#chart_div_bottom5").css({"position": "fixed",
"top": maph,
"left": w3 * 2,
"width": w3 + "px",
"min-width": w3 + "px",
"max-width": w3 + "px",
"height": h3 + "px",
"min-height": h3 + "px",
"max-height": h3 + "px"});
}
$(window).resize(resizeLayout);
$(document).ready(resizeLayout);