mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-08 07:21:03 +08:00
Fix MarvinJS init for remote/local/disabled cases [SCI-10815]
This commit is contained in:
parent
9f4f697e03
commit
3075df6771
1 changed files with 15 additions and 11 deletions
|
|
@ -237,7 +237,9 @@ var MarvinJsEditorApi = (function() {
|
|||
enabled: function() {
|
||||
return ($('#MarvinJsModal').length > 0);
|
||||
},
|
||||
|
||||
isRemote: function() {
|
||||
return marvinJsMode === 'remote';
|
||||
},
|
||||
open: function(config) {
|
||||
if (!MarvinJsEditor.enabled()) {
|
||||
$('#MarvinJsPromoModal').modal('show');
|
||||
|
|
@ -320,22 +322,24 @@ $(document).on('click', '.gene-sequence-edit-button', function() {
|
|||
});
|
||||
|
||||
function initMarvinJs() {
|
||||
const isRemote = $('#marvinjs-editor')[0].dataset.marvinjsMode === 'remote';
|
||||
MarvinJsEditor = MarvinJsEditorApi();
|
||||
|
||||
if (isRemote && typeof (ChemicalizeMarvinJs) === 'undefined') {
|
||||
// MarvinJS is disabled, nothing to initialize
|
||||
if (!MarvinJsEditor.enabled()) return;
|
||||
|
||||
// wait for remote MarvinJS to initialize
|
||||
if (MarvinJsEditor.isRemote() && typeof (ChemicalizeMarvinJs) === 'undefined') {
|
||||
setTimeout(initMarvinJs, 100);
|
||||
return;
|
||||
}
|
||||
|
||||
MarvinJsEditor = MarvinJsEditorApi();
|
||||
if (MarvinJsEditor.enabled()) {
|
||||
if (isRemote) {
|
||||
ChemicalizeMarvinJs.createEditor('#marvinjs-sketch').then(function(marvin) {
|
||||
marvin.setDisplaySettings({ toolbars: 'reporting' });
|
||||
marvinJsRemoteEditor = marvin;
|
||||
});
|
||||
}
|
||||
if (MarvinJsEditor.isRemote()) {
|
||||
ChemicalizeMarvinJs.createEditor('#marvinjs-sketch').then(function(marvin) {
|
||||
marvin.setDisplaySettings({ toolbars: 'reporting' });
|
||||
marvinJsRemoteEditor = marvin;
|
||||
});
|
||||
}
|
||||
|
||||
MarvinJsEditor.initNewButton('.new-marvinjs-upload-button');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue