Skip to content

Commit 56be60e

Browse files
Fix carousel and implement workaround for show/hide bug
1 parent 803af33 commit 56be60e

File tree

3 files changed

+63
-31
lines changed

3 files changed

+63
-31
lines changed

resources/js/tour.js

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// Tour Image Carousel JS
22

3+
$.get("resources/templates/_carouselPrototype.html", function (data) {
4+
$.carouselPrototype = data;
5+
6+
});
37
$.get("resources/templates/_loungeCarousel.html", function (data) {
48
$.lounge = data;
59

@@ -39,50 +43,67 @@ $.get("resources/templates/_loungeCarousel.html", function (data) {
3943
// Return: None
4044
function switchImage(room){
4145
var imageHTML;
46+
var containerElement = $('#carouselImages');
4247
$('.tourTextActive').hide();
4348
$('.tourTextActive').removeClass('tourTextActive');
44-
if(room == "lounge"){
45-
imageHTML = $.lounge;
4649

47-
}
48-
else if(room == "software"){
49-
imageHTML = $.software;
50+
if(room == "server"){
51+
imageHTML = $.server;
52+
53+
// Show Photosphere container
54+
containerElement = $('#photosphere-container');
55+
containerElement.show();
5056

51-
}
52-
else if(room == "library"){
53-
imageHTML = $.library;
57+
// Photosphere, remove carousel
58+
// Part of the workaround for the carousel bug (see below)
59+
$('.carousel').remove();
60+
} else {
61+
// Hide photosphere container
62+
$('#photosphere-container').hide();
5463

55-
}
56-
else if(room == "user"){
57-
imageHTML = $.user;
64+
if(room == "lounge"){
65+
imageHTML = $.lounge;
5866

59-
}
60-
else if(room == "conference"){
61-
imageHTML = $.conference;
67+
}
68+
else if(room == "software"){
69+
imageHTML = $.software;
6270

63-
}
64-
else if(room == "server"){
65-
imageHTML = $.server;
71+
}
72+
else if(room == "library"){
73+
imageHTML = $.library;
6674

67-
// Photosphere instead of carousel, hide controls
68-
$('.carousel-control').hide();
75+
}
76+
else if(room == "user"){
77+
imageHTML = $.user;
6978

70-
}
71-
else if(room == "project"){
72-
imageHTML = $.project;
79+
}
80+
else if(room == "conference"){
81+
imageHTML = $.conference;
7382

74-
}
75-
else if(room == "dorm"){
76-
imageHTML = $.dorm;
83+
}
84+
else if(room == "project"){
85+
imageHTML = $.project;
7786

87+
}
88+
else if(room == "dorm"){
89+
imageHTML = $.dorm;
90+
91+
}
7892
}
93+
7994
$('.csh-active').removeClass('csh-active');
8095
$("#"+room+"Text").show();
8196
$("#"+room+"Text").addClass("tourTextActive");
82-
$('#carouselImages').html(imageHTML);
97+
98+
// If the carousel doesn't exist in the DOM, add it
99+
// Workaround for this bug: https://github.com/angular-ui/bootstrap/issues/1513
100+
if (room !== 'server' && $('.carousel').length == 0) {
101+
$('.image-container').append($.carouselPrototype.replace('{{images}}', imageHTML));
102+
$('.carousel').carousel();
103+
} else {
104+
containerElement.html(imageHTML);
105+
}
83106
$('#'+room).addClass('csh-active');
84107

85108

86-
87-
88109
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div id="myCarousel" class="carousel slide" data-ride="carousel">
2+
<span id="carouselImages">{{images}}</span>
3+
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
4+
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
5+
<span class="sr-only">Previous</span>
6+
</a>
7+
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
8+
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
9+
<span class="sr-only">Next</span>
10+
</a>
11+
</div>
12+
</div>

tour.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<p>Though the walls are the same as regular dorm rooms, our rooms usually look rather different than the standard RIT room layout.</p>
7171
</span>
7272

73-
73+
<div id="photosphere-container"></div>
7474

7575
<div class="image-container">
7676
<div id="myCarousel" class="carousel slide" data-ride="carousel">
@@ -312,11 +312,10 @@
312312
<span class="sr-only">Next</span>
313313
</a>
314314
</div>
315-
<br>
316315
</div>
317316

318317

319-
318+
<br>
320319
</div>
321320

322321

0 commit comments

Comments
 (0)