2019-03-22 16:27:50 +08:00
|
|
|
/* eslint no-underscore-dangle: ["error", { "allowAfterThis": true }]*/
|
|
|
|
/* eslint no-use-before-define: ["error", { "functions": false }]*/
|
2019-04-26 21:21:01 +08:00
|
|
|
/* eslint-disable no-underscore-dangle */
|
2020-12-22 22:25:30 +08:00
|
|
|
/* global PdfPreview */
|
2019-04-02 22:38:53 +08:00
|
|
|
var FilePreviewModal = (function() {
|
2019-03-22 16:27:50 +08:00
|
|
|
'use strict';
|
|
|
|
|
2020-10-22 19:41:17 +08:00
|
|
|
function initPreviewModal() {
|
2020-10-19 21:23:34 +08:00
|
|
|
$(document).on('click', '.file-preview-link', function(e) {
|
2020-10-22 19:41:17 +08:00
|
|
|
var params = {};
|
|
|
|
var galleryViewId = $(this).data('gallery-view-id');
|
2019-03-22 16:27:50 +08:00
|
|
|
e.preventDefault();
|
2020-10-22 19:41:17 +08:00
|
|
|
e.stopPropagation();
|
2020-11-26 22:35:06 +08:00
|
|
|
if ($(this).closest('.attachments').data('preview')) params.preview = true;
|
2020-10-22 19:41:17 +08:00
|
|
|
params.gallery = $(`.file-preview-link[data-gallery-view-id=${galleryViewId}]`)
|
2020-10-27 00:16:31 +08:00
|
|
|
.toArray().sort((a, b) => $(a).closest('.asset').css('order') - $(b).closest('.asset').css('order'))
|
2020-10-22 19:41:17 +08:00
|
|
|
.map(i => i.dataset.id);
|
|
|
|
$.get($(this).data('preview-url'), params, function(result) {
|
2020-10-19 21:23:34 +08:00
|
|
|
$('#filePreviewModal .modal-content').html(result.html);
|
|
|
|
$('#filePreviewModal').modal('show');
|
2020-11-26 22:35:06 +08:00
|
|
|
$('.modal-backdrop').last().css('z-index', $('#filePreviewModal').css('z-index') - 1);
|
2020-12-22 22:25:30 +08:00
|
|
|
PdfPreview.initCanvas();
|
2020-10-22 19:41:17 +08:00
|
|
|
});
|
|
|
|
});
|
2019-04-27 18:46:45 +08:00
|
|
|
|
2020-10-22 19:41:17 +08:00
|
|
|
$(document).on('click', '#filePreviewModal .gallery-switcher', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
$.get($(this).attr('href'), { gallery: $(this).data('gallery-elements') }, function(result) {
|
|
|
|
$('#filePreviewModal .modal-content').html(result.html);
|
2021-01-04 20:40:05 +08:00
|
|
|
PdfPreview.initCanvas();
|
2019-07-02 19:15:57 +08:00
|
|
|
});
|
2020-10-22 19:41:17 +08:00
|
|
|
});
|
2019-04-27 18:46:45 +08:00
|
|
|
}
|
|
|
|
|
2019-04-02 22:38:53 +08:00
|
|
|
return Object.freeze({
|
2020-10-19 21:23:34 +08:00
|
|
|
init: initPreviewModal
|
2019-04-02 22:38:53 +08:00
|
|
|
});
|
2020-10-19 21:23:34 +08:00
|
|
|
}());
|
|
|
|
|
|
|
|
FilePreviewModal.init();
|