2023-08-07 16:45:52 +08:00
|
|
|
/* global notTurbolinksPreview */
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function initializeHandsonTable(el) {
|
|
|
|
var input = el.siblings('input.hot-table-contents');
|
|
|
|
var inputObj = JSON.parse(input.attr('value'));
|
|
|
|
var metadataJson = el.siblings('input.hot-table-metadata');
|
|
|
|
var data = inputObj.data;
|
|
|
|
var metadata;
|
|
|
|
|
|
|
|
metadata = JSON.parse(metadataJson.val() || '{}');
|
|
|
|
el.handsontable({
|
|
|
|
disableVisualSelection: true,
|
|
|
|
rowHeaders: true,
|
|
|
|
colHeaders: true,
|
|
|
|
editor: false,
|
|
|
|
copyPaste: false,
|
|
|
|
formulas: true,
|
|
|
|
data: data,
|
|
|
|
cell: metadata.cells || []
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initAttachments() {
|
|
|
|
$(document).on('click', '.shareable-file-preview-link, .shareable-gallery-switcher', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('.modal-file-preview.in').modal('hide');
|
|
|
|
$($(`.modal-file-preview[data-object-id=${$(this).data('id')}]`)).modal('show');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-10-10 20:22:48 +08:00
|
|
|
function initResultComments() {
|
|
|
|
$(document).on('click', '.shareable-link-open-comments-sidebar', function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('.comments-sidebar').removeClass('open');
|
|
|
|
|
|
|
|
$($(this).data('objectTarget')).addClass('open');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-08-07 16:45:52 +08:00
|
|
|
function initResultsExpandCollapse() {
|
|
|
|
$(document).on('click', '#results-collapse-btn', function() {
|
2023-10-18 16:15:43 +08:00
|
|
|
$('.result-container .collapse').collapse('hide');
|
2023-08-07 16:45:52 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('click', '#results-expand-btn', function() {
|
2023-10-18 16:15:43 +08:00
|
|
|
$('.result-container .collapse').collapse('show');
|
2023-08-07 16:45:52 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initMyModuleResultsShow() {
|
|
|
|
initAttachments();
|
|
|
|
initResultsExpandCollapse();
|
2023-10-10 20:22:48 +08:00
|
|
|
initResultComments();
|
2023-08-07 16:45:52 +08:00
|
|
|
|
|
|
|
$('.hot-table-container').each(function() {
|
|
|
|
initializeHandsonTable($(this));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (notTurbolinksPreview()) {
|
|
|
|
initMyModuleResultsShow();
|
|
|
|
}
|
|
|
|
}());
|