mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-09 21:36:44 +08:00
Fix I18n and double loading
This commit is contained in:
parent
0f80786433
commit
e8e9244d96
3 changed files with 93 additions and 96 deletions
|
@ -315,19 +315,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initAssetViewModeToggle(){
|
|
||||||
$('.attachments-actions').on('click', '.attachments-view-mode', function () {
|
|
||||||
var viewModeBtn = $(this);
|
|
||||||
$.post(viewModeBtn.closest('.dropdown-menu').data('view-mode-url'), {
|
|
||||||
assets_view_mode: viewModeBtn.data('assets-view-mode')
|
|
||||||
}, function(result) {
|
|
||||||
viewModeBtn.closest('.dropdown-menu').find('.attachments-view-mode').removeClass('selected');
|
|
||||||
viewModeBtn.addClass('selected');
|
|
||||||
viewModeBtn.closest('.step').find('.attachments').html(result.html)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function initCallBacks() {
|
function initCallBacks() {
|
||||||
if (typeof(applyCreateWopiFileCallback) === 'function') applyCreateWopiFileCallback();
|
if (typeof(applyCreateWopiFileCallback) === 'function') applyCreateWopiFileCallback();
|
||||||
applyCheckboxCallBack();
|
applyCheckboxCallBack();
|
||||||
|
@ -336,8 +323,6 @@
|
||||||
applyMoveStepCallBack();
|
applyMoveStepCallBack();
|
||||||
initDeleteStep();
|
initDeleteStep();
|
||||||
TinyMCE.highlight();
|
TinyMCE.highlight();
|
||||||
reorderAttachmentsInit();
|
|
||||||
initAssetViewModeToggle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -620,9 +605,84 @@
|
||||||
Comments.init();
|
Comments.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reorder attachments
|
// On init
|
||||||
|
initCallBacks();
|
||||||
|
initHandsOnTable($(document));
|
||||||
|
expandAllSteps();
|
||||||
|
TinyMCE.highlight();
|
||||||
|
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
||||||
|
newStepHandler();
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
$("[data-action='collapse-steps']").click(function () {
|
||||||
|
$('.step .panel-collapse').collapse('hide');
|
||||||
|
});
|
||||||
|
$("[data-action='expand-steps']").click(expandAllSteps);
|
||||||
|
});
|
||||||
|
|
||||||
|
global.initHandsOnTable = initHandsOnTable;
|
||||||
|
})(window);
|
||||||
|
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var StepInlineAttachments = (function() {
|
||||||
|
function elementVisible(element) {
|
||||||
|
var elementRect = element.getBoundingClientRect();
|
||||||
|
var elementHeight = $(element).height()
|
||||||
|
return elementRect.top + (elementHeight / 2) >= 0 &&
|
||||||
|
elementRect.bottom <= (window.innerHeight || document.documentElement.clientHeight) + (elementHeight / 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
function showElement(element) {
|
||||||
|
setTimeout(() => {
|
||||||
|
var iframeUrl = $(element).find('.iframe-placeholder').data('iframe-url');
|
||||||
|
if (elementVisible(element) && iframeUrl) {
|
||||||
|
$(element).find('.iframe-placeholder')
|
||||||
|
.replaceWith(`<iframe class="active-iframe-preview" src="${iframeUrl}"></iframe>`);
|
||||||
|
$(element).addClass('active').attr('data-created-at', new Date().getTime());
|
||||||
|
}
|
||||||
|
},500)
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideElement(element) {
|
||||||
|
var iframeUrl = $(element).find('.active-iframe-preview').attr('src');
|
||||||
|
if (!elementVisible(element) && iframeUrl) {
|
||||||
|
$(element).find('iframe')
|
||||||
|
.replaceWith(`<div class="iframe-placeholder" data-iframe-url="${iframeUrl}"></div>`);
|
||||||
|
$(element).removeClass('active').attr('data-created-at', null)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkForAttachmentsState() {
|
||||||
|
$.each($('.inline-attachment-container'), function(i, element){
|
||||||
|
showElement(element)
|
||||||
|
})
|
||||||
|
if ($('.active-iframe-preview').length > 5){
|
||||||
|
let sortedIframes = $('.inline-attachment-container.active').sort(function(a, b) {
|
||||||
|
return +a.dataset.createdAt - +b.dataset.createdAt;
|
||||||
|
})
|
||||||
|
$.each(sortedIframes, function(i, element){
|
||||||
|
if (hideElement(element)) return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
init: () => {
|
||||||
|
windowScrollEvents['StepInlineAttachments'] = StepInlineAttachments.scrollEvent;
|
||||||
|
},
|
||||||
|
scrollEvent: () => {
|
||||||
|
checkForAttachmentsState()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Reorder attachments
|
||||||
function reorderAttachmentsInit() {
|
function reorderAttachmentsInit() {
|
||||||
$('.attachments-actions').on('click', '.change-order', function(e){
|
$('#steps').on('click', '.attachments-actions .change-order', function(e){
|
||||||
var orderDropdown = $(this).closest('.dropdown-menu');
|
var orderDropdown = $(this).closest('.dropdown-menu');
|
||||||
var assetsContainer = $(`.attachments[data-step-id=${orderDropdown.data('step-id')}]`)
|
var assetsContainer = $(`.attachments[data-step-id=${orderDropdown.data('step-id')}]`)
|
||||||
var order = $(this).data('order');
|
var order = $(this).data('order');
|
||||||
|
@ -636,7 +696,7 @@
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
$('.attachments').on('reorder', function() {
|
$('#steps').on('reorder', '.attachments', function() {
|
||||||
var assets = $(`.attachments[data-step-id=${$(this).data('step-id')}] .asset`);
|
var assets = $(`.attachments[data-step-id=${$(this).data('step-id')}] .asset`);
|
||||||
var order = $(this).data('order');
|
var order = $(this).data('order');
|
||||||
var sortedAssets = assets.sort(function(a, b) {
|
var sortedAssets = assets.sort(function(a, b) {
|
||||||
|
@ -665,84 +725,20 @@
|
||||||
$('.attachments').trigger('reorder');
|
$('.attachments').trigger('reorder');
|
||||||
}
|
}
|
||||||
|
|
||||||
function initInlineAttachment() {
|
function initAssetViewModeToggle(){
|
||||||
$(document).on('scroll', 'body', function(){
|
$('#steps').on('click', '.attachments-actions .attachments-view-mode', function () {
|
||||||
console.log(1)
|
var viewModeBtn = $(this);
|
||||||
|
$.post(viewModeBtn.closest('.dropdown-menu').data('view-mode-url'), {
|
||||||
|
assets_view_mode: viewModeBtn.data('assets-view-mode')
|
||||||
|
}, function(result) {
|
||||||
|
viewModeBtn.closest('.dropdown-menu').find('.attachments-view-mode').removeClass('selected');
|
||||||
|
viewModeBtn.addClass('selected');
|
||||||
|
viewModeBtn.closest('.step').find('.attachments').html(result.html)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// On init
|
StepInlineAttachments.init();
|
||||||
initCallBacks();
|
reorderAttachmentsInit();
|
||||||
initHandsOnTable($(document));
|
initAssetViewModeToggle();
|
||||||
expandAllSteps();
|
|
||||||
TinyMCE.highlight();
|
|
||||||
SmartAnnotation.preventPropagation('.atwho-user-popover');
|
|
||||||
newStepHandler();
|
|
||||||
|
|
||||||
$(function () {
|
|
||||||
$("[data-action='collapse-steps']").click(function () {
|
|
||||||
$('.step .panel-collapse').collapse('hide');
|
|
||||||
});
|
|
||||||
$("[data-action='expand-steps']").click(expandAllSteps);
|
|
||||||
});
|
|
||||||
|
|
||||||
global.initHandsOnTable = initHandsOnTable;
|
|
||||||
})(window);
|
|
||||||
|
|
||||||
|
|
||||||
var StepInlineAttachments = (function() {
|
|
||||||
function elementVisible(element) {
|
|
||||||
var elementRect = element.getBoundingClientRect();
|
|
||||||
var elementHeight = $(element).height()
|
|
||||||
return elementRect.top + (elementHeight / 2) >= 0 &&
|
|
||||||
elementRect.bottom <= (window.innerHeight || document.documentElement.clientHeight) + (elementHeight / 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
function showElement(element) {
|
|
||||||
setTimeout(() => {
|
|
||||||
var iframeUrl = $(element).find('.iframe-placeholder').data('iframe-url');
|
|
||||||
if (elementVisible(element) && iframeUrl) {
|
|
||||||
$(element).find('.iframe-placeholder')
|
|
||||||
.replaceWith(`<iframe class="active-iframe-preview" src="${iframeUrl}"></iframe>`);
|
|
||||||
$(element).addClass('active').attr('data-created-at', new Date().getTime());
|
|
||||||
}
|
|
||||||
},500)
|
|
||||||
}
|
|
||||||
|
|
||||||
function hideElement(element) {
|
|
||||||
var iframeUrl = $(element).find('.active-iframe-preview').attr('src');
|
|
||||||
if (!elementVisible(element) && iframeUrl) {
|
|
||||||
$(element).find('iframe')
|
|
||||||
.replaceWith(`<div class="iframe-placeholder" data-iframe-url="${iframeUrl}"></div>`);
|
|
||||||
$(element).removeClass('active').attr('data-created-at', null)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkForAttachmentsState() {
|
|
||||||
$.each($('.inline-attachment-container'), function(i, element){
|
|
||||||
showElement(element)
|
|
||||||
})
|
|
||||||
if ($('.active-iframe-preview').length > 5){
|
|
||||||
let sortedIframes = $('.inline-attachment-container.active').sort(function(a, b) {
|
|
||||||
return +a.dataset.createdAt - +b.dataset.createdAt;
|
|
||||||
})
|
|
||||||
$.each(sortedIframes, function(i, element){
|
|
||||||
if (hideElement(element)) return false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
init: () => {
|
|
||||||
windowScrollEvents['StepInlineAttachments'] = StepInlineAttachments.scrollEvent;
|
|
||||||
},
|
|
||||||
scrollEvent: () => {
|
|
||||||
checkForAttachmentsState()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
StepInlineAttachments.init();
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<div class="dropdown sci-dropdown">
|
<div class="dropdown sci-dropdown">
|
||||||
<button class="btn btn-light dropdown-toggle" type="button" id="dropdownAttachmentsOptions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
<button class="btn btn-light dropdown-toggle" type="button" id="dropdownAttachmentsOptions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||||
<span>Manage</span>
|
<span><%= t("protocols.steps.attachments.manage") %></span>
|
||||||
<span class="caret pull-right"></span>
|
<span class="caret pull-right"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-right dropdown-attachment-options"
|
<ul class="dropdown-menu dropdown-menu-right dropdown-attachment-options"
|
||||||
|
|
|
@ -1958,6 +1958,7 @@ en:
|
||||||
uncomplete_title: "Restart step"
|
uncomplete_title: "Restart step"
|
||||||
attachments:
|
attachments:
|
||||||
modified_label: "Modified:"
|
modified_label: "Modified:"
|
||||||
|
manage: "Manage"
|
||||||
add: "ADD"
|
add: "ADD"
|
||||||
sort_by: "SORT BY"
|
sort_by: "SORT BY"
|
||||||
attachments_view_mode: "ALL ATTACHMENTS VIEW SIZE"
|
attachments_view_mode: "ALL ATTACHMENTS VIEW SIZE"
|
||||||
|
|
Loading…
Add table
Reference in a new issue