mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 02:48:19 -07:00
Merge pull request #1114 from redSpoutnik/fix-subtitlesync-textfield
Fix SubtitleSync-TextField behavior
This commit is contained in:
commit
41ba09a316
@ -32,8 +32,12 @@ define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html',
|
||||
this.textContent = offset + 's';
|
||||
};
|
||||
|
||||
subtitleSyncTextField.addEventListener('keypress', function(event) {
|
||||
subtitleSyncTextField.addEventListener('click', function () {
|
||||
// keep focus to prevent fade with osd
|
||||
this.hasFocus = true;
|
||||
});
|
||||
|
||||
subtitleSyncTextField.addEventListener('keydown', function(event) {
|
||||
if (event.key === 'Enter') {
|
||||
// if input key is enter search for float pattern
|
||||
var inputOffset = /[-+]?\d+\.?\d*/g.exec(this.textContent);
|
||||
@ -55,7 +59,7 @@ define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html',
|
||||
this.hasFocus = false;
|
||||
event.preventDefault();
|
||||
} else {
|
||||
// keep focus to prevent fade with bottom layout
|
||||
// keep focus to prevent fade with osd
|
||||
this.hasFocus = true;
|
||||
if (event.key.match(/[+-\d.s]/) === null) {
|
||||
event.preventDefault();
|
||||
@ -63,6 +67,13 @@ define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html',
|
||||
}
|
||||
});
|
||||
|
||||
subtitleSyncTextField.blur = function() {
|
||||
// prevent textfield to blur while element has focus
|
||||
if (!this.hasFocus && this.prototype) {
|
||||
this.prototype.blur();
|
||||
}
|
||||
};
|
||||
|
||||
subtitleSyncSlider.updateOffset = function(percent) {
|
||||
// default value is 0s = 50%
|
||||
this.value = percent === undefined ? 50 : percent;
|
||||
@ -140,12 +151,10 @@ define(['playbackManager', 'layoutManager', 'text!./subtitlesync.template.html',
|
||||
/* eslint-disable no-fallthrough */
|
||||
switch (action) {
|
||||
case undefined:
|
||||
// if showing subtitle sync is enabled
|
||||
if (playbackManager.isShowingSubtitleOffsetEnabled(player) &&
|
||||
// if there is an external subtitle stream enabled
|
||||
playbackManager.canHandleOffsetOnCurrentSubtitle(player)) {
|
||||
// if no subtitle offset is defined
|
||||
if (!playbackManager.getPlayerSubtitleOffset(player)) {
|
||||
// if showing subtitle sync is enabled and if there is an external subtitle stream enabled
|
||||
if (playbackManager.isShowingSubtitleOffsetEnabled(player) && playbackManager.canHandleOffsetOnCurrentSubtitle(player)) {
|
||||
// if no subtitle offset is defined or element has focus (offset being defined)
|
||||
if (!(playbackManager.getPlayerSubtitleOffset(player) || subtitleSyncTextField.hasFocus)) {
|
||||
// set default offset to '0' = 50%
|
||||
subtitleSyncSlider.value = '50';
|
||||
subtitleSyncTextField.textContent = '0s';
|
||||
|
Loading…
Reference in New Issue
Block a user