diff --git a/app/views/media_objects/_thumbnail.html.erb b/app/views/media_objects/_thumbnail.html.erb index e071081bf1..41e6cf7999 100644 --- a/app/views/media_objects/_thumbnail.html.erb +++ b/app/views/media_objects/_thumbnail.html.erb @@ -50,6 +50,59 @@ Unless required by applicable law or agreed to in writing, software distributed let offset = '' let timeCheck = setInterval(enableCreateThumbnail, 500); + function handleCreateThumbnailModalShow() { + let currentPlayer = document.getElementById('iiif-media-player'); + let $imgPolaroid = document.getElementById('img-polaroid'); + offset = currentPlayer.player.currentTime(); + + canvasIndex = parseInt(currentPlayer.dataset.canvasindex); + const sectionId = sectionIds[canvasIndex]; + baseUrl = '/master_files/' + sectionId; + + if ($imgPolaroid) { + let src = baseUrl + '/poster?offset=' + offset + '&preview=true'; + + // Display a preview of thumbnail to user + $imgPolaroid.setAttribute('src', src); + $($imgPolaroid).fadeIn('slow'); + } + }; + + function handleUpdateThumbnail() { + let currentPlayer = document.getElementById('iiif-media-player'); + canvasIndex = parseInt(currentPlayer.dataset.canvasindex); + const sectionId = sectionIds[canvasIndex]; + baseUrl = '/master_files/' + sectionId; + offset = currentPlayer.player.currentTime(); + + const modalBody = document.getElementsByClassName('modal-body')[0]; + // Put in a loading spinner and disable buttons to prevent double clicks + modalBody.classList.add('spinner'); + $('#thumbnailModal') + .find('button') + .attr({ disabled: true }); + + $.ajax({ + url: baseUrl + '/still', + type: 'POST', + data: { + offset: offset + } + }) + .done(response => { + $('#thumbnailModal').modal('hide'); + }) + .fail(error => { + console.log(error); + }) + .always(() => { + modalBody.classList.remove('spinner'); + $('#thumbnailModal') + .find('button') + .attr({ disabled: false }); + }); + }; + function enableCreateThumbnail() { let player = document.getElementById('iiif-media-player'); @@ -85,53 +138,9 @@ Unless required by applicable law or agreed to in writing, software distributed } }); } - - $('#thumbnailModal').on('show.bs.modal', function(e) { - let currentPlayer = document.getElementById('iiif-media-player'); - let $imgPolaroid = document.getElementById('img-polaroid'); - offset = currentPlayer.player.currentTime(); - - canvasIndex = parseInt(currentPlayer.dataset.canvasindex); - const sectionId = sectionIds[canvasIndex]; - baseUrl = '/master_files/' + sectionId; - - if ($imgPolaroid) { - let src = baseUrl + '/poster?offset=' + offset + '&preview=true'; - - // Display a preview of thumbnail to user - $imgPolaroid.setAttribute('src', src); - $($imgPolaroid).fadeIn('slow'); - } - }); - - $('#create-thumbnail-submit-button').on('click', function(e) { - const modalBody = document.getElementsByClassName('modal-body')[0]; - // Put in a loading spinner and disable buttons to prevent double clicks - modalBody.classList.add('spinner'); - $('#thumbnailModal') - .find('button') - .attr({ disabled: true }); - - $.ajax({ - url: baseUrl + '/still', - type: 'POST', - data: { - offset: offset - } - }) - .done(response => { - $('#thumbnailModal').modal('hide'); - }) - .fail(error => { - console.log(error); - }) - .always(() => { - modalBody.classList.remove('spinner'); - $('#thumbnailModal') - .find('button') - .attr({ disabled: false }); - }); - }); + + document.getElementById('create-thumbnail-btn').addEventListener('click', handleCreateThumbnailModalShow); + document.getElementById('create-thumbnail-submit-button').addEventListener('click', handleUpdateThumbnail); }; }); diff --git a/config/application.rb b/config/application.rb index 9f78a4087f..562c2af5ae 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,7 +8,7 @@ Bundler.require(*Rails.groups) module Avalon - VERSION = '7.7.1' + VERSION = '7.7.2' class Application < Rails::Application require 'avalon/configuration' diff --git a/package.json b/package.json index f2a9cc741c..09b1ea8f57 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "@babel/plugin-proposal-object-rest-spread": "^7.20.7", "@babel/preset-react": "^7.0.0", "@babel/runtime": "7", - "@samvera/ramp": "^3.1.0", + "@samvera/ramp": "https://github.com/samvera-labs/ramp.git#v3.1.3", "babel-plugin-macros": "^3.1.0", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "buffer": "^6.0.3", diff --git a/yarn.lock b/yarn.lock index 7516286e5b..35e82e9dc3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1440,10 +1440,9 @@ estree-walker "^2.0.2" picomatch "^2.3.1" -"@samvera/ramp@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@samvera/ramp/-/ramp-3.1.0.tgz#6254646f34b9a434ff6e6046f1e013130d036e28" - integrity sha512-B5UiU0DDxi7Ub+DfbKC7j80zjMCmkuLnmDJNUqnftjO1L2gocdMOuUfYZ30pAh9SO9HbMCEtAFtLUHPlizPz3A== +"@samvera/ramp@https://github.com/samvera-labs/ramp.git#v3.1.3": + version "3.1.3" + resolved "https://github.com/samvera-labs/ramp.git#6c233c2cd668856b6bce1ce63076455a9e58b0f2" dependencies: "@rollup/plugin-json" "^6.0.1" "@silvermine/videojs-quality-selector" "^1.2.4"