mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-18 15:13:21 +08:00
6f76e86171
* Implement results tab for shareable task link [SCI-8753]
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
/* 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');
|
|
});
|
|
}
|
|
|
|
function initResultsExpandCollapse() {
|
|
$(document).on('click', '#results-collapse-btn', function() {
|
|
$('.result .panel-collapse').collapse('hide');
|
|
});
|
|
|
|
$(document).on('click', '#results-expand-btn', function() {
|
|
$('.result .panel-collapse').collapse('show');
|
|
});
|
|
}
|
|
|
|
function initMyModuleResultsShow() {
|
|
initAttachments();
|
|
initResultsExpandCollapse();
|
|
|
|
$('.hot-table-container').each(function() {
|
|
initializeHandsonTable($(this));
|
|
});
|
|
}
|
|
|
|
if (notTurbolinksPreview()) {
|
|
initMyModuleResultsShow();
|
|
}
|
|
}());
|