Skip to content

Commit c1a19e0

Browse files
authored
Merge pull request #5806 from avalonmediasystem/staging
Release v7.7.2
2 parents 45088cb + 1d0f26c commit c1a19e0

File tree

5 files changed

+82
-55
lines changed

5 files changed

+82
-55
lines changed

app/views/media_objects/_add_to_playlist.html.erb

+21-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,27 @@ Unless required by applicable law or agreed to in writing, software distributed
202202
function enableAddToPlaylist() {
203203
let player = document.getElementById('iiif-media-player');
204204
let addToPlaylistBtn = document.getElementById('addToPlaylistBtn');
205-
if(addToPlaylistBtn && addToPlaylistBtn.disabled && player?.player.readyState() === 4) {
206-
addToPlaylistBtn.disabled = false;
205+
if(addToPlaylistBtn && addToPlaylistBtn.disabled) {
206+
const USER_AGENT = window.navigator.userAgent;
207+
// Identify both iPad and iPhone devices
208+
const IS_MOBILE = (/Mobi/i).test(USER_AGENT);
209+
const IS_IPHONE = (/iPhone/i).test(USER_AGENT);
210+
const IS_TOUCH_ONLY = navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && !window.matchMedia("(pointer: fine").matches;
211+
// Identify browser is Safari
212+
const IS_SAFARI = (/Safari/i).test(USER_AGENT);
213+
/*
214+
For iOS Safari, player.readyState() never gets to 4 until media playback is
215+
started. Therefore, use player.src() to check whether there's a playable media
216+
loaded into the player instead of player.readyState().
217+
Keep the player.readyState() === 4 check for desktop browsers, because without
218+
that check the add to playlist form populates NaN values for time fields when user
219+
clicks the 'Add to Playlist' button immediately on page load, which does not
220+
happen in mobile context.
221+
*/
222+
if(((IS_TOUCH_ONLY || IS_IPHONE || IS_MOBILE) && IS_SAFARI && player?.player.src() != '')
223+
|| player?.player.readyState() === 4) {
224+
addToPlaylistBtn.disabled = false;
225+
}
207226
}
208227
if(!listenersAdded) {
209228
// Add 'Add new playlist' option to dropdown

app/views/media_objects/_thumbnail.html.erb

+56-47
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,59 @@ Unless required by applicable law or agreed to in writing, software distributed
5050
let offset = ''
5151
let timeCheck = setInterval(enableCreateThumbnail, 500);
5252

53+
function handleCreateThumbnailModalShow() {
54+
let currentPlayer = document.getElementById('iiif-media-player');
55+
let $imgPolaroid = document.getElementById('img-polaroid');
56+
offset = currentPlayer.player.currentTime();
57+
58+
canvasIndex = parseInt(currentPlayer.dataset.canvasindex);
59+
const sectionId = sectionIds[canvasIndex];
60+
baseUrl = '/master_files/' + sectionId;
61+
62+
if ($imgPolaroid) {
63+
let src = baseUrl + '/poster?offset=' + offset + '&preview=true';
64+
65+
// Display a preview of thumbnail to user
66+
$imgPolaroid.setAttribute('src', src);
67+
$($imgPolaroid).fadeIn('slow');
68+
}
69+
};
70+
71+
function handleUpdateThumbnail() {
72+
let currentPlayer = document.getElementById('iiif-media-player');
73+
canvasIndex = parseInt(currentPlayer.dataset.canvasindex);
74+
const sectionId = sectionIds[canvasIndex];
75+
baseUrl = '/master_files/' + sectionId;
76+
offset = currentPlayer.player.currentTime();
77+
78+
const modalBody = document.getElementsByClassName('modal-body')[0];
79+
// Put in a loading spinner and disable buttons to prevent double clicks
80+
modalBody.classList.add('spinner');
81+
$('#thumbnailModal')
82+
.find('button')
83+
.attr({ disabled: true });
84+
85+
$.ajax({
86+
url: baseUrl + '/still',
87+
type: 'POST',
88+
data: {
89+
offset: offset
90+
}
91+
})
92+
.done(response => {
93+
$('#thumbnailModal').modal('hide');
94+
})
95+
.fail(error => {
96+
console.log(error);
97+
})
98+
.always(() => {
99+
modalBody.classList.remove('spinner');
100+
$('#thumbnailModal')
101+
.find('button')
102+
.attr({ disabled: false });
103+
});
104+
};
105+
53106
function enableCreateThumbnail() {
54107
let player = document.getElementById('iiif-media-player');
55108

@@ -85,53 +138,9 @@ Unless required by applicable law or agreed to in writing, software distributed
85138
}
86139
});
87140
}
88-
89-
$('#thumbnailModal').on('show.bs.modal', function(e) {
90-
let currentPlayer = document.getElementById('iiif-media-player');
91-
let $imgPolaroid = document.getElementById('img-polaroid');
92-
offset = currentPlayer.player.currentTime();
93-
94-
canvasIndex = parseInt(currentPlayer.dataset.canvasindex);
95-
const sectionId = sectionIds[canvasIndex];
96-
baseUrl = '/master_files/' + sectionId;
97-
98-
if ($imgPolaroid) {
99-
let src = baseUrl + '/poster?offset=' + offset + '&preview=true';
100-
101-
// Display a preview of thumbnail to user
102-
$imgPolaroid.setAttribute('src', src);
103-
$($imgPolaroid).fadeIn('slow');
104-
}
105-
});
106-
107-
$('#create-thumbnail-submit-button').on('click', function(e) {
108-
const modalBody = document.getElementsByClassName('modal-body')[0];
109-
// Put in a loading spinner and disable buttons to prevent double clicks
110-
modalBody.classList.add('spinner');
111-
$('#thumbnailModal')
112-
.find('button')
113-
.attr({ disabled: true });
114-
115-
$.ajax({
116-
url: baseUrl + '/still',
117-
type: 'POST',
118-
data: {
119-
offset: offset
120-
}
121-
})
122-
.done(response => {
123-
$('#thumbnailModal').modal('hide');
124-
})
125-
.fail(error => {
126-
console.log(error);
127-
})
128-
.always(() => {
129-
modalBody.classList.remove('spinner');
130-
$('#thumbnailModal')
131-
.find('button')
132-
.attr({ disabled: false });
133-
});
134-
});
141+
142+
document.getElementById('create-thumbnail-btn').addEventListener('click', handleCreateThumbnailModalShow);
143+
document.getElementById('create-thumbnail-submit-button').addEventListener('click', handleUpdateThumbnail);
135144
};
136145
});
137146
</script>

config/application.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Bundler.require(*Rails.groups)
99

1010
module Avalon
11-
VERSION = '7.7.1'
11+
VERSION = '7.7.2'
1212

1313
class Application < Rails::Application
1414
require 'avalon/configuration'

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
66
"@babel/preset-react": "^7.0.0",
77
"@babel/runtime": "7",
8-
"@samvera/ramp": "^3.1.0",
8+
"@samvera/ramp": "https://github.com/samvera-labs/ramp.git#v3.1.3",
99
"babel-plugin-macros": "^3.1.0",
1010
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
1111
"buffer": "^6.0.3",

yarn.lock

+3-4
Original file line numberDiff line numberDiff line change
@@ -1440,10 +1440,9 @@
14401440
estree-walker "^2.0.2"
14411441
picomatch "^2.3.1"
14421442

1443-
"@samvera/ramp@^3.1.0":
1444-
version "3.1.0"
1445-
resolved "https://registry.yarnpkg.com/@samvera/ramp/-/ramp-3.1.0.tgz#6254646f34b9a434ff6e6046f1e013130d036e28"
1446-
integrity sha512-B5UiU0DDxi7Ub+DfbKC7j80zjMCmkuLnmDJNUqnftjO1L2gocdMOuUfYZ30pAh9SO9HbMCEtAFtLUHPlizPz3A==
1443+
"@samvera/ramp@https://github.com/samvera-labs/ramp.git#v3.1.3":
1444+
version "3.1.3"
1445+
resolved "https://github.com/samvera-labs/ramp.git#6c233c2cd668856b6bce1ce63076455a9e58b0f2"
14471446
dependencies:
14481447
"@rollup/plugin-json" "^6.0.1"
14491448
"@silvermine/videojs-quality-selector" "^1.2.4"

0 commit comments

Comments
 (0)