Skip to content

Commit a23b174

Browse files
committed
Fixed the floorplan template and accompanying javascript to make the arrows which point out room location work. This needed some modification to support separate per-floor images, and a fix to make the arrow position setting code work in html5 ('px' must be specified). Also added handling of responsive resizing of the floor-plan images, to make the arrow point right independent of the image scaling.
- Legacy-Id: 11578
1 parent d53da28 commit a23b174

2 files changed

Lines changed: 29 additions & 21 deletions

File tree

ietf/static/ietf/js/room_params.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,15 @@ function roomcoords(nm)
5252
if (nmi[2] > nm0[2]) nm0[2] = nmi[2];
5353
if (nmi[3] > nm0[3]) nm0[3] = nmi[3];
5454
}
55-
return [nm0[0], nm0[1], nm0[2], nm0[3]];
55+
return [nm0[0], nm0[1], nm0[2], nm0[3], nm0[4], nm0[5]];
5656
} else {
5757
return findroom(nm);
5858
}
5959
}
6060

61-
function setarrow(nm, fl)
61+
function setarrow(nm)
6262
// Place an arrow at the center of a given room name (or list of room names separated by "/").
6363
{
64-
for (var i = 0; i < arrowsuffixlist.length; i++) {
65-
removearrow(arrowsuffixlist[i], fl);
66-
}
6764
for (var i = 0; i < arguments.length; i+=2) {
6865
nm = roommap(arguments[i]);
6966
if (verbose) alert("nm=" + nm);
@@ -74,17 +71,26 @@ function setarrow(nm, fl)
7471
if (verbose) alert("roomcoords returned: " + ret);
7572
if (!ret) continue;
7673

77-
var left = ret[0], top = ret[1], right = ret[2], bottom = ret[3], offsetleft = -25, offsettop = -25;
78-
if (verbose) alert("left=" + left + ", top=" + top + ", right=" + right + ", bottom=" + bottom);
74+
var left = ret[0], top = ret[1], right = ret[2], bottom = ret[3], floor=ret[4], width=ret[5], offsetleft = -25, offsettop = -25;
75+
if (verbose) alert("left=" + left + ", top=" + top + ", right=" + right + ", bottom=" + bottom + ", floor=" + floor + ", width=" + width);
7976
//alert("left=" + left + ", top=" + top + ", right=" + right + ", bottom=" + bottom);
80-
var arrowdiv = fl+'-arrowdiv' + (j > 0 ? j : "");
77+
// calculate arrow position
78+
for (var i = 0; i < arrowsuffixlist.length; i++) {
79+
removearrow(arrowsuffixlist[i], floor);
80+
}
81+
arrow_left = (left + (right - left) / 2 );
82+
arrow_top = (top + (bottom - top) / 2 );
83+
// scale the coordinates to match image scaling
84+
var img = document.getElementById(floor+"-image");
85+
scale = img.width / width;
86+
arrow_left = arrow_left * scale;
87+
arrow_top = arrow_top * scale;
88+
var arrowdiv = floor+'-arrowdiv'+j;
8189
//if (verbose) alert("arrowdiv: " + arrowdiv);
8290
var adiv = document.getElementById(arrowdiv);
83-
// if (verbose) alert("looking for 'arrowdiv'+" + j);
8491
if (adiv) {
85-
//if (verbose) alert("adiv found");
86-
adiv.style.left = left + (right - left) / 2 + offsetleft;
87-
adiv.style.top = top + (bottom - top) / 2 + offsettop;
92+
adiv.style.left = arrow_left + offsetleft + "px";
93+
adiv.style.top = arrow_top + offsettop + "px";
8894
adiv.style.visibility = "visible";
8995
}
9096
}

ietf/templates/meeting/floor-plan.html

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
top: 0;
1919
left: 0;
2020
}
21+
.floor-plan img {
22+
padding: 0;
23+
}
2124
.rooms a {
2225
text-decoration: underline;
2326
}
2427
{% endblock %}
2528

26-
{% block bodyAttrs %}data-spy="scroll" data-target="#affix"{% endblock %}
29+
{% block bodyAttrs %}onload="automaticarrow(); checkParams();" data-spy="scroll" data-target="#affix"{% endblock %}
2730

2831
{% block content %}
2932
{% origin %}
@@ -43,17 +46,16 @@
4346
<div class="anchor-target" id="{{floor.name|slugify}}"></div>
4447
<h3>{{ floor.name }}</h3>
4548
<div class="floor-plan">
46-
<img class="col-md-12 col-sm-12 col-xs-12" src="{{ floor.image.url }}" >
49+
<img id="{{floor.name|slugify}}-image" class="col-md-12 col-sm-12 col-xs-12" src="{{ floor.image.url }}" >
4750
<!-- We need as many of these as we can have individual rooms combining into one -->
48-
<div id="{{floor.name|slugify}}-arrowdiv" style="position: absolute; left: 0; top: 67.5px; visibility: hidden;"><img id="arrow" src="{% static 'ietf/images/arrow-ani.gif' %}"></div>
51+
<div id="{{floor.name|slugify}}-arrowdiv0" style="position: absolute; left: 0; top: 67.5px; visibility: hidden;"><img id="arrow" src="{% static 'ietf/images/arrow-ani.gif' %}"></div>
4952
<div id="{{floor.name|slugify}}-arrowdiv1" style="position: absolute; left: 0; top: 67.5px; visibility: hidden;"><img id="arrow" src="{% static 'ietf/images/arrow-ani.gif' %}"></div>
5053
<div id="{{floor.name|slugify}}-arrowdiv2" style="position: absolute; left: 0; top: 67.5px; visibility: hidden;"><img id="arrow" src="{% static 'ietf/images/arrow-ani.gif' %}"></div>
5154
<div id="{{floor.name|slugify}}-arrowdiv3" style="position: absolute; left: 0; top: 67.5px; visibility: hidden;"><img id="arrow" src="{% static 'ietf/images/arrow-ani.gif' %}"></div>
5255
</div>
5356
<div class="rooms">
5457
{% for room in floor.room_set.all %}
55-
{#<a href="javascript: setarrow('{{room.name|slugify}}','{{floor.name|slugify}}')">{{ room.name|nbsp }}</a>#}
56-
{{ room.name|nbsp }}
58+
<a href="javascript: setarrow('{{room.name|slugify}}')">{{ room.name|nbsp }}</a>
5759
{% endfor %}
5860
</div>
5961
<div class="row"></div>
@@ -87,19 +89,19 @@ <h3>{{ floor.name }}</h3>
8789

8890
function findroom(nm)
8991
{
90-
var left = 0, top = 0, right = 0, bottom = 0;
92+
var left = 0, top = 0, right = 0, bottom = 0, floor="", width=0;
9193

9294
if (0) { }
9395
{% for room in meeting.room_set.all %}
94-
else if (nm == '{{room.name|slugify}}') { left = {{room.left}}; top = {{room.top}}; right = {{room.right}}; bottom = {{room.bottom}}; }{% endfor %}
96+
else if (nm == '{{room.name|slugify}}') { left = {{room.left}}; top = {{room.top}}; right = {{room.right}}; bottom = {{room.bottom}}; floor='{{room.floorplan.name|slugify}}'; width={{room.floorplan.image.width}}; }{% endfor %}
9597

9698
{% for room in meeting.room_set.all %}{% if room.functional_display_name %}
97-
else if (nm == '{{room.functional_name|slugify}}') { left = {{room.left}}; top = {{room.top}}; right = {{room.right}}; bottom = {{room.bottom}}; }{% endif %}{% endfor %}
99+
else if (nm == '{{room.functional_name|slugify}}') { left = {{room.left}}; top = {{room.top}}; right = {{room.right}}; bottom = {{room.bottom}}; floor='{{room.floorplan.name|slugify}}'; width={{room.floorplan.image.width}}; }{% endif %}{% endfor %}
98100

99101
else return null;
100102

101103
// alert("nm=" + nm + ",left=" + left + ",top=" + top + ",r=" + right + ",b=" + bottom);
102-
return [left, top, right, bottom];
104+
return [left, top, right, bottom, floor, width];
103105
}
104106
</script>
105107
{% endwith %}

0 commit comments

Comments
 (0)