User 870ab5b546
28-10-2014 15:46:33
Hi, I'm unable to load a different toolbars style into Marvin4JS. Here is our code for loading Marvin4JS, which works fine:
var bld = new String.builder(). // Javascript analog of a StringBuilder
append('<iframe id="').append(appletName).
append('" class="sketcher-frame" ' +
'src="\/nosession\/marvin4JS\/editorws.html" ' +
'style="min-width:').
append(panelWidth).append('px; min-height:').append(panelHeight).
append('px; overflow:hidden; border:1px solid darkgray;" \/><\/iframe>');
var iframe = bld.toString();
setInnerHTML(appletName + 'Cell', iframe);
$(document).ready(function handleDocumentReady(e) {
getMarvinPromise('#' + appletName).done(function (sketcherInstance) {
marvinSketcherInstance = sketcherInstance;
marvinSketcherInstance.setDisplaySettings({
'carbonLabelVisible': getCVisibilityM4JS(qFlags),
'implicitHydrogen': getHVisibilityM4JS(qFlags),
'valenceErrorVisible': getValenceErrorVisibleM4JS(qFlags),
'atomIndicesVisible': false,
'lonePairsVisible': getLonePairsVisibleM4JS(qFlags),
/* 'chiralitySupport': getRSLabelsVisibleM4JS(qFlags), */
'atomMapsVisible': getAtomMappingM4JS(qFlags),
'chiralFlagVisible': true,
'cpkColoring': true
});
marvinSketcherInstance.importStructure(null, mol);
}).fail(function () {
alert('Cannot retrieve sketcher instance from iframe.');
});
});
append('" class="sketcher-frame" ' +
'src="\/nosession\/marvin4JS\/editorws.html" ' +
'data-toolbars="reporting" ' +
'style="min-width:').
I then tried adding the following two lines before the importStructure() line, in the function (sketcherInstance) bloc:
marvinSketcherInstance.attr('data-toolbars', 'reporting');
marvinSketcherInstance[0].contentWindow.location.reload(true);
But I got a Javascript error, "undefined is not a function", referring to the first new line above. I then tried changing marvinSketcherInstance to $('#' + appletName) in these two lines, and the sketcher then reloaded repeatedly, but always with the standard toolbars. Any advice?
Also, you have an example of how to add a custom button to a toolbar, but you don't show how to add one of your preexisting buttons to a toolbar. I would like to add the rectangle/ellipse button in the reporting toolbar to the education toolbar. (Actually, I would prefer to have just the rectangle.) Any advice on this task as well?