From f67bc6d080c4089e3e49e02c50f548fca9b053ad Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 8 Apr 2015 13:38:37 +0200 Subject: Add campus pictures --- images/campus-auditorium.png | Bin 0 -> 183948 bytes images/campus-bike-repair-shop.png | Bin 0 -> 97936 bytes images/campus-bus-stops.png | Bin 0 -> 323931 bytes images/campus-supermarket.png | Bin 0 -> 219358 bytes images/campus-zwarte-doos.png | Bin 0 -> 116172 bytes js/campus.js | 23 +++++++++++++++++++++++ style/campus.less | 13 +++++++++++++ 7 files changed, 36 insertions(+) create mode 100644 images/campus-auditorium.png create mode 100644 images/campus-bike-repair-shop.png create mode 100644 images/campus-bus-stops.png create mode 100644 images/campus-supermarket.png create mode 100644 images/campus-zwarte-doos.png diff --git a/images/campus-auditorium.png b/images/campus-auditorium.png new file mode 100644 index 0000000..a1d28c0 Binary files /dev/null and b/images/campus-auditorium.png differ diff --git a/images/campus-bike-repair-shop.png b/images/campus-bike-repair-shop.png new file mode 100644 index 0000000..d027a93 Binary files /dev/null and b/images/campus-bike-repair-shop.png differ diff --git a/images/campus-bus-stops.png b/images/campus-bus-stops.png new file mode 100644 index 0000000..ee00fb4 Binary files /dev/null and b/images/campus-bus-stops.png differ diff --git a/images/campus-supermarket.png b/images/campus-supermarket.png new file mode 100644 index 0000000..3575254 Binary files /dev/null and b/images/campus-supermarket.png differ diff --git a/images/campus-zwarte-doos.png b/images/campus-zwarte-doos.png new file mode 100644 index 0000000..2dd503e Binary files /dev/null and b/images/campus-zwarte-doos.png differ diff --git a/js/campus.js b/js/campus.js index 8d6846b..55e0efe 100644 --- a/js/campus.js +++ b/js/campus.js @@ -46,6 +46,27 @@ define(['campus-coords', 'd3'], function(coords, d3) { }); } + function try_add_image(building, element) { + var image_url = 'images/campus-' + building.id + '.png'; + var img = new Image(); + img.src = image_url; + img.className = 'description-picture'; + img.addEventListener('load', function() { + var clear = document.createElement('div'); + clear.style.clear = 'both'; + + if (img.width > 500) { + img.classList.add('large'); + element.appendChild(img); + element.appendChild(clear); + } else { + img.classList.add('small'); + element.insertBefore(img, element.firstChild); + element.insertBefore(clear, element.firstChild); + } + }); + } + return function() { var svg = d3.select('#campus-map').append('svg'); initSvg(svg); @@ -67,6 +88,8 @@ define(['campus-coords', 'd3'], function(coords, d3) { back_to_top.textContent = 'Back to top'; links_block.appendChild(back_to_top); citems.appendChild(links_block); + + try_add_image(building, text_block); }); }; }); diff --git a/style/campus.less b/style/campus.less index a330595..02d9126 100644 --- a/style/campus.less +++ b/style/campus.less @@ -17,4 +17,17 @@ body[data-page="campus"] #campus-map { } } } + +body[data-page="campus"] { + img.description-picture { + float: right; + margin-left: 1em; + + &.small { + } + + &.large { + } + } +} /* vim: set sw=4 et ts=4: */ -- cgit v1.2.1