|
1 | 1 | // Tour Image Carousel JS |
2 | 2 |
|
| 3 | +$.get("resources/templates/_carouselPrototype.html", function (data) { |
| 4 | + $.carouselPrototype = data; |
| 5 | + |
| 6 | + }); |
3 | 7 | $.get("resources/templates/_loungeCarousel.html", function (data) { |
4 | 8 | $.lounge = data; |
5 | 9 |
|
@@ -39,50 +43,67 @@ $.get("resources/templates/_loungeCarousel.html", function (data) { |
39 | 43 | // Return: None |
40 | 44 | function switchImage(room){ |
41 | 45 | var imageHTML; |
| 46 | + var containerElement = $('#carouselImages'); |
42 | 47 | $('.tourTextActive').hide(); |
43 | 48 | $('.tourTextActive').removeClass('tourTextActive'); |
44 | | - if(room == "lounge"){ |
45 | | - imageHTML = $.lounge; |
46 | 49 |
|
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(); |
50 | 56 |
|
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(); |
54 | 63 |
|
55 | | - } |
56 | | - else if(room == "user"){ |
57 | | - imageHTML = $.user; |
| 64 | + if(room == "lounge"){ |
| 65 | + imageHTML = $.lounge; |
58 | 66 |
|
59 | | - } |
60 | | - else if(room == "conference"){ |
61 | | - imageHTML = $.conference; |
| 67 | + } |
| 68 | + else if(room == "software"){ |
| 69 | + imageHTML = $.software; |
62 | 70 |
|
63 | | - } |
64 | | - else if(room == "server"){ |
65 | | - imageHTML = $.server; |
| 71 | + } |
| 72 | + else if(room == "library"){ |
| 73 | + imageHTML = $.library; |
66 | 74 |
|
67 | | - // Photosphere instead of carousel, hide controls |
68 | | - $('.carousel-control').hide(); |
| 75 | + } |
| 76 | + else if(room == "user"){ |
| 77 | + imageHTML = $.user; |
69 | 78 |
|
70 | | - } |
71 | | - else if(room == "project"){ |
72 | | - imageHTML = $.project; |
| 79 | + } |
| 80 | + else if(room == "conference"){ |
| 81 | + imageHTML = $.conference; |
73 | 82 |
|
74 | | - } |
75 | | - else if(room == "dorm"){ |
76 | | - imageHTML = $.dorm; |
| 83 | + } |
| 84 | + else if(room == "project"){ |
| 85 | + imageHTML = $.project; |
77 | 86 |
|
| 87 | + } |
| 88 | + else if(room == "dorm"){ |
| 89 | + imageHTML = $.dorm; |
| 90 | + |
| 91 | + } |
78 | 92 | } |
| 93 | + |
79 | 94 | $('.csh-active').removeClass('csh-active'); |
80 | 95 | $("#"+room+"Text").show(); |
81 | 96 | $("#"+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 | + } |
83 | 106 | $('#'+room).addClass('csh-active'); |
84 | 107 |
|
85 | 108 |
|
86 | | - |
87 | | - |
88 | 109 | } |
0 commit comments