mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-16 06:06:56 +08:00
66 lines
1.8 KiB
JavaScript
66 lines
1.8 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 initResultComments() {
|
|
$(document).on('click', '.shareable-link-open-comments-sidebar', function(e) {
|
|
e.preventDefault();
|
|
$('.comments-sidebar').removeClass('open');
|
|
|
|
$($(this).data('objectTarget')).addClass('open');
|
|
});
|
|
}
|
|
|
|
function initResultsExpandCollapse() {
|
|
$(document).on('click', '#results-collapse-btn', function() {
|
|
$('.result-container .collapse').collapse('hide');
|
|
});
|
|
|
|
$(document).on('click', '#results-expand-btn', function() {
|
|
$('.result-container .collapse').collapse('show');
|
|
});
|
|
}
|
|
|
|
function initMyModuleResultsShow() {
|
|
initAttachments();
|
|
initResultsExpandCollapse();
|
|
initResultComments();
|
|
|
|
$('.hot-table-container').each(function() {
|
|
initializeHandsonTable($(this));
|
|
});
|
|
}
|
|
|
|
if (notTurbolinksPreview()) {
|
|
initMyModuleResultsShow();
|
|
}
|
|
}());
|