Files
edx-platform/common/static/js/capa/schematicinput.js
Syed Ali Abbas Zaidi 8480dbc228 chore: apply amnesty on existing not fixable issues (#32215)
* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue

* fix: all autofixable eslint issues

* fix: all react related fixable issues

* fix: autofixable eslint issues

* chore: remove all template literals

* fix: remaining autofixable issues

* chore: apply amnesty on all existing issues

* fix: failing xss-lint issues

* refactor: apply amnesty on remaining issues

* refactor: apply amnesty on new issues

* fix: remove file level suppressions

* refactor: apply amnesty on new issues
2023-08-07 19:13:19 +05:00

50 lines
2.1 KiB
JavaScript

$(function() {
// TODO: someone should fix all of this...
// $("a[rel*=leanModal]").leanModal(); //TODO: Make this work with the new modal library. Try and integrate this with the "slices"
/* eslint-disable no-multi-str */
// xss-lint: disable=javascript-jquery-append
$('body').append('\
<div id="circuit_editor_modal" class="modal hide fade"> \
<div class="modal-body"> \
<input class="schematic" height="300" width="500" id="schematic_editor" name="schematic" type="hidden" value=""/> \
</div> \
<div class="modal-footer"> \
<button type="button" id="circuit_save_btn" class="btn btn-primary" data-dismiss="modal"> \
Save circuit \
</button> \
</div> \
</div>');
// This is the editor that pops up as a modal
var editorCircuit = $('#schematic_editor').get(0);
// This is the circuit that they last clicked. The one being edited.
var editingCircuit = null;
// Notice we use live, because new circuits can be inserted
$('.schematic_open').live('click', function() {
// Find the new editingCircuit. Transfer its contents to the editorCircuit
editingCircuit = $(this).children('input.schematic').get(0);
editingCircuit.schematic.update_value();
var circuit_so_far = $(editingCircuit).val();
var n = editorCircuit.schematic.components.length;
for (var i = 0; i < n; i++) { editorCircuit.schematic.components[n - 1 - i].remove(); }
editorCircuit.schematic.load_schematic(circuit_so_far, '');
editorCircuit.schematic.zoomall();
});
$('#circuit_save_btn').click(function() {
// Take the circuit from the editor and put it back into editingCircuit
editorCircuit.schematic.update_value();
var saving_circuit = $(editorCircuit).val();
var n = editingCircuit.schematic.components.length;
for (var i = 0; i < n; i++) { editingCircuit.schematic.components[n - 1 - i].remove(); }
editingCircuit.schematic.load_schematic(saving_circuit, '');
editingCircuit.schematic.zoomall();
});
});