Skip to content

Commit e0215ef

Browse files
committed
Refactor to help creation of a different HTML structure to place the player in mobile
1 parent 413110f commit e0215ef

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ <h2>Musicians' Helper - Repeater</h2>
114114

115115
<!-- Video Player Column -->
116116
<div class="col-md-6 col-sm-12 text-center">
117-
<div id="player-wrapper" class="sticky-top">
117+
<div class="sticky">
118118
<div id="player" style="display:none"></div>
119119
</div>
120120
</div>

scripts.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function onYouTubeIframeAPIReady() {
3333
playerHeight = 180;
3434
}
3535

36-
player = new YT.Player('player', {
36+
player = new YT.Player(getPlayerId(), {
3737
height: playerHeight.toString(),
3838
width: playerWidth.toString(),
3939
events: {
@@ -117,7 +117,7 @@ function reset() {
117117
player.stopVideo();
118118
$('#duration').val('');
119119
$('#start').val('');
120-
$('#player').hide();
120+
getJQueryPlayer().hide();
121121
}
122122

123123
function processFile(file_contents) {
@@ -182,7 +182,7 @@ $('#video-url').change( function () {
182182
reset();
183183
$this.addClass('is-invalid');
184184
} else {
185-
$('#player').show();
185+
getJQueryPlayer().show();
186186
$this.removeClass('is-invalid');
187187
player.loadVideoById(video_id);
188188
videoChanged = true;
@@ -290,6 +290,14 @@ function handleFile() {
290290
reader.readAsText(fileList[0]);
291291
}
292292

293+
function getPlayerId() {
294+
return 'player';
295+
}
296+
297+
function getJQueryPlayer() {
298+
return $('#' + getPlayerId());
299+
}
300+
293301
$(document).ready(function () {
294302
bsCustomFileInput.init()
295303

styles.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,11 @@
107107
font-size: 2rem;
108108
}
109109
}
110+
111+
@media (min-width: 768px) {
112+
.sticky {
113+
position: sticky;
114+
top: 0;
115+
z-index: 1030;
116+
}
117+
}

0 commit comments

Comments
 (0)