Skip to content

Commit

Permalink
Merge pull request #5781 from avalonmediasystem/v7.7.x
Browse files Browse the repository at this point in the history
V7.7.2
  • Loading branch information
cjcolvar authored Apr 12, 2024
2 parents 442f2b3 + f5d6bd2 commit 7899877
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 53 deletions.
103 changes: 56 additions & 47 deletions app/views/media_objects/_thumbnail.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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);
};
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 7899877

Please sign in to comment.