Skip to content

Commit cb17466

Browse files
committed
Adjust and restore sign and transcript windows for fullscreen
Ensures that sign and transcript remain visible and movable. fixes #714
1 parent 3b5ef73 commit cb17466

2 files changed

Lines changed: 57 additions & 3 deletions

File tree

scripts/buildplayer.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,36 @@
197197
}
198198
};
199199

200+
/**
201+
* Reposition draggable windows when switched into fullscreen.
202+
*
203+
* @param {string} which 'transcript' or 'sign'.
204+
*/
205+
AblePlayer.prototype.rePositionDraggableWindow = function (which) {
206+
207+
let preferences, $window;
208+
preferences = this.getPref();
209+
$window = ( which === 'transcript' ) ? this.$transcriptArea : this.$signWindow;
210+
if ( which === 'transcript' ) {
211+
if (typeof preferences.transcript !== 'undefined') {
212+
this.prevTranscriptPosition = preferences.transcript;
213+
}
214+
$window.css({
215+
'top': 0,
216+
'left': 0
217+
});
218+
} else {
219+
if (typeof preferences.sign !== 'undefined') {
220+
this.prevSignPosition = preferences.sign;
221+
}
222+
$window.css({
223+
'top': 0,
224+
'right': 0,
225+
'left': 'auto'
226+
});
227+
}
228+
}
229+
200230
AblePlayer.prototype.positionDraggableWindow = function (which, width) {
201231

202232
// which is either 'transcript' or 'sign'
@@ -208,10 +238,18 @@
208238
if (typeof preferences.transcript !== 'undefined') {
209239
preferencePos = preferences.transcript;
210240
}
241+
if ( this.prevTranscriptPosition ) {
242+
preferencePos = this.prevTranscriptPosition;
243+
this.prevTranscriptPosition = false;
244+
}
211245
} else if (which === 'sign') {
212246
if (typeof preferences.sign !== 'undefined') {
213247
preferencePos = preferences.sign;
214248
}
249+
if ( this.prevSignPosition ) {
250+
preferencePos = this.prevSignPosition;
251+
this.prevSignPosition = false;
252+
}
215253
}
216254
if (typeof preferencePos !== 'undefined' && !($.isEmptyObject(preferencePos))) {
217255
// position window using stored values from preferences
@@ -236,7 +274,8 @@
236274
});
237275
}
238276
// If draggable window is off screen to the left.
239-
if ( leftPosition < 0 ) {
277+
if ( leftPosition < 0 && ! this.restoringAfterFullscreen ) {
278+
console.log( leftPosition );
240279
$window.css({
241280
'left': preferencePos['left'] - leftPosition
242281
});

scripts/control.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,14 @@
12121212
x: window.pageXOffset || 0,
12131213
y: window.pageYOffset || 0
12141214
}
1215+
if (this.prefTranscript === 1) {
1216+
// transcript is on. Go ahead and reposition it
1217+
this.rePositionDraggableWindow("transcript");
1218+
}
1219+
if (this.prefSign === 1) {
1220+
// sign is on. Go ahead and reposition it
1221+
this.rePositionDraggableWindow("sign");
1222+
}
12151223
this.scrollPosition = scroll;
12161224
// Initialize fullscreen
12171225
if (el.requestFullscreen) {
@@ -1230,6 +1238,14 @@
12301238
} else if (document.webkitCancelFullscreen) {
12311239
document.webkitCancelFullscreen();
12321240
}
1241+
if (this.prefTranscript === 1) {
1242+
// transcript is on. Go ahead and reposition it
1243+
this.positionDraggableWindow("transcript");
1244+
}
1245+
if (this.prefSign === 1) {
1246+
// sign is on. Go ahead and reposition it
1247+
this.positionDraggableWindow("sign");
1248+
}
12331249
this.fullscreen = false;
12341250
}
12351251
} else {
@@ -1535,7 +1551,7 @@
15351551
'height': newHeight
15361552
});
15371553
} else {
1538-
// No constraints. Let CSS handle the positioning.
1554+
// No constraints. Let CSS handle the positioning.
15391555
this.$media.removeAttr('width height');
15401556
this.$ableWrapper.removeAttr( 'style' );
15411557
}
@@ -1564,7 +1580,6 @@
15641580
'font-size': captionSize
15651581
});
15661582
}
1567-
15681583
this.refreshControls();
15691584
};
15701585

0 commit comments

Comments
 (0)