mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
Fix MarvinJS loading race condition [SCI-9411]
This commit is contained in:
parent
7285e68f76
commit
947d5e6744
1 changed files with 14 additions and 2 deletions
|
@ -16,6 +16,7 @@ var MarvinJsEditorApi = (function() {
|
|||
var sketchName = marvinJsModal.find('.file-name input');
|
||||
var marvinJsMode = marvinJsContainer.data('marvinjsMode');
|
||||
|
||||
|
||||
// Facade api actions
|
||||
var marvinJsExportImage = (childFuction, options = {}) => {
|
||||
if (marvinJsMode === 'remote') {
|
||||
|
@ -219,6 +220,8 @@ var MarvinJsEditorApi = (function() {
|
|||
var objectType = dataset.objectType;
|
||||
var marvinUrl = dataset.marvinUrl;
|
||||
var container = dataset.sketchContainer;
|
||||
|
||||
|
||||
MarvinJsEditor.open({
|
||||
mode: 'new',
|
||||
objectId: objectId,
|
||||
|
@ -244,6 +247,7 @@ var MarvinJsEditorApi = (function() {
|
|||
setTimeout(() => { MarvinJsEditor.open(config); }, 100);
|
||||
return false;
|
||||
}
|
||||
|
||||
preloadActions(config);
|
||||
$(marvinJsModal).modal('show');
|
||||
$(marvinJsObject)
|
||||
|
@ -314,10 +318,14 @@ $(document).on('click', '.gene-sequence-edit-button', function() {
|
|||
window.showIFrameModal(editButton.data('sequence-edit-url'));
|
||||
});
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
function initMarvinJs() {
|
||||
if (typeof (ChemicalizeMarvinJs) === 'undefined') {
|
||||
setTimeout(initMarvinJs, 100);
|
||||
}
|
||||
|
||||
MarvinJsEditor = MarvinJsEditorApi();
|
||||
if (MarvinJsEditor.enabled()) {
|
||||
if ($('#marvinjs-editor')[0].dataset.marvinjsMode === 'remote' && typeof (ChemicalizeMarvinJs) !== 'undefined') {
|
||||
if ($('#marvinjs-editor')[0].dataset.marvinjsMode === 'remote') {
|
||||
ChemicalizeMarvinJs.createEditor('#marvinjs-sketch').then(function(marvin) {
|
||||
marvin.setDisplaySettings({ toolbars: 'reporting' });
|
||||
marvinJsRemoteEditor = marvin;
|
||||
|
@ -325,4 +333,8 @@ $(document).on('turbolinks:load', function() {
|
|||
}
|
||||
}
|
||||
MarvinJsEditor.initNewButton('.new-marvinjs-upload-button');
|
||||
}
|
||||
|
||||
$(document).on('turbolinks:load', function() {
|
||||
initMarvinJs();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue