forked from enviPath/enviPy
79 lines
3.0 KiB
HTML
79 lines
3.0 KiB
HTML
{% load static %}
|
||
<div class="modal fade bs-modal-lg" id="new_compound_modal" tabindex="-1" aria-labelledby="new_compound_modal" aria-modal="true"
|
||
role="dialog">
|
||
<div class="modal-dialog modal-lg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span>
|
||
</button>
|
||
<h4 class="modal-title">Create a new Compound</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form id="new_compound_modal_form" accept-charset="UTF-8" action="{% url 'package compound list' meta.current_package.uuid %}" data-remote="true" method="post">
|
||
{% csrf_token %}
|
||
<label for="compound-name">Name</label>
|
||
<input id="compound-name" class="form-control" name="compound-name" placeholder="Name"/>
|
||
<label for="compound-description">Description</label>
|
||
<input id="compound-description" class="form-control" name="compound-description" placeholder="Description"/>
|
||
<label for="compound-smiles">SMILES</label>
|
||
<input type="text" class="form-control" name="compound-smiles" placeholder="SMILES" id="compound-smiles">
|
||
<p></p>
|
||
<div>
|
||
<iframe id="new_compound_ketcher" src="{% static '/js/ketcher2/ketcher.html' %}" width="100%"
|
||
height="510"></iframe>
|
||
</div>
|
||
<p></p>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-secondary pull-left" data-dismiss="modal">Close
|
||
</button>
|
||
<button type="button" class="btn btn-primary" id="new_compound_modal_form_submit">Submit</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<script>
|
||
|
||
function newCompoundModalketcherToNewCompoundModalTextInput() {
|
||
$('#compound-smiles').val(this.ketcher.getSmiles());
|
||
}
|
||
|
||
$(function() {
|
||
|
||
$('#new_compound_ketcher').on('load', function() {
|
||
const checkKetcherReady = () => {
|
||
win = this.contentWindow
|
||
if (win.ketcher && 'editor' in win.ketcher) {
|
||
win.ketcher.editor.event.change.handlers.push({
|
||
once: false,
|
||
priority: 0,
|
||
f: newCompoundModalketcherToNewCompoundModalTextInput,
|
||
ketcher: win.ketcher
|
||
});
|
||
} else {
|
||
setTimeout(checkKetcherReady, 100);
|
||
}
|
||
};
|
||
|
||
checkKetcherReady();
|
||
})
|
||
|
||
$(function() {
|
||
$('#new_compound_modal_form_submit').on('click', function(e) {
|
||
e.preventDefault();
|
||
$(this).prop("disabled",true);
|
||
|
||
|
||
|
||
// submit form
|
||
$('#new_compound_modal_form').submit();
|
||
});
|
||
});
|
||
|
||
});
|
||
|
||
</script>
|