scinote-web/app/assets/javascripts/my_modules/image_preview.js

24 lines
804 B
JavaScript
Raw Normal View History

2016-12-20 00:36:18 +08:00
function initPreviewModal() {
$('.image-preview-link').off();
$('.image-preview-link').click(function(e) {
e.preventDefault();
var name = $(this).find('p').text();
var url = $(this).find('img').data('large-url');
var downloadUrl = $(this).attr('href');
var description = $(this).data('description');
openPreviewModal(name, url, downloadUrl, description);
});
}
2016-12-20 00:36:18 +08:00
function openPreviewModal(name, url, downloadUrl, description) {
var modal = $('#imagePreviewModal');
modal.find('.image-name').text(name);
var link = modal.find('.image-download-link');
link.attr('href', downloadUrl);
var image = modal.find('.modal-body img');
image.attr('src', url);
image.attr('alt', name);
modal.find('.modal-footer .image-description').text(description);
modal.modal();
}