Commit 05ea675f by Dave St.Germain

Merge pull request #2959 from edx/dcs/remove-junk-from-codemirror

Removed circuit editor setup code that had always been in codemirror-compressed.js
parents b8ceb5ab 376b0407
......@@ -862,7 +862,7 @@ class MatlabInput(CodeInput):
'queue_len': str(self.queue_len),
'queue_msg': self.queue_msg,
'button_enabled': self.button_enabled(),
'matlab_editor_js': '{static_url}js/vendor/CodeMirror/addons/octave.js'.format(
'matlab_editor_js': '{static_url}js/vendor/CodeMirror/octave.js'.format(
static_url=self.capa_system.STATIC_URL),
}
return extra_context
......@@ -961,6 +961,15 @@ class Schematic(InputTypeBase):
Attribute('label', ''),
]
def _extra_context(self):
"""
"""
context = {
'setup_script': '{static_url}js/capa/schematicinput.js'.format(
static_url=self.capa_system.STATIC_URL),
}
return context
#-----------------------------------------------------------------------------
......
<span>
<input type="hidden" class="schematic" height="${height}" width="${width}" parts="${parts}" analyses="${analyses}" name="input_${id}" id="input_${id}" aria-label="${label}" aria-describedby="answer_${id}" value="" initial_value=""/>
<div id="value_${id}" style="display:none">${value}</div>
<div id="initial_value_${id}" style="display:none">${initial_value}</div>
<div id="submit_value_${id}" style="display:none">${submit_analyses}</div>
<script>
$("#input_${id}").attr("value",$("#value_${id}").text());
$("#input_${id}").attr("initial_value",$("#initial_value_${id}").text());
$("#input_${id}").attr("submit_analyses",$("#submit_value_${id}").text());
</script>
<div class="script_placeholder" data-src="${setup_script}"/>
<input type="hidden"
class="schematic"
height="${height}"
width="${width}"
parts="${parts}"
analyses="${analyses}"
name="input_${id}"
id="input_${id}"
aria-label="${label}"
aria-describedby="answer_${id}"
value="${value|h}"
initial_value="${initial_value|h}"
submit_analyses="${submit_analyses|h}"
/>
<span id="answer_${id}"></span>
% if status == 'unsubmitted':
......@@ -29,5 +33,6 @@
<span class="sr">Status: incomplete</span>
</span>
% endif
</span>
......@@ -453,7 +453,7 @@ class MatlabTest(unittest.TestCase):
'tabsize': int(self.tabsize),
'button_enabled': True,
'queue_len': '3',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/addons/octave.js',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/octave.js',
}
self.assertEqual(context, expected)
......@@ -486,7 +486,7 @@ class MatlabTest(unittest.TestCase):
'tabsize': int(self.tabsize),
'button_enabled': True,
'queue_len': '3',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/addons/octave.js',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/octave.js',
}
self.assertEqual(context, expected)
......@@ -519,7 +519,7 @@ class MatlabTest(unittest.TestCase):
'tabsize': int(self.tabsize),
'button_enabled': False,
'queue_len': '0',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/addons/octave.js',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/octave.js',
}
self.assertEqual(context, expected)
......@@ -551,7 +551,7 @@ class MatlabTest(unittest.TestCase):
'tabsize': int(self.tabsize),
'button_enabled': True,
'queue_len': '1',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/addons/octave.js',
'matlab_editor_js': '/dummy-static/js/vendor/CodeMirror/octave.js',
}
self.assertEqual(context, expected)
......@@ -617,7 +617,7 @@ class MatlabTest(unittest.TestCase):
output = self.the_input.get_html()
self.assertEqual(
etree.tostring(output),
"""<div>{\'status\': \'queued\', \'button_enabled\': True, \'linenumbers\': \'true\', \'rows\': \'10\', \'queue_len\': \'3\', \'mode\': \'\', \'cols\': \'80\', \'value\': \'print "good evening"\', \'status_class\': \'processing\', \'queue_msg\': \'\', \'STATIC_URL\': \'/dummy-static/\', \'msg\': u\'Submitted. As soon as a response is returned, this message will be replaced by that feedback.\', \'matlab_editor_js\': \'/dummy-static/js/vendor/CodeMirror/addons/octave.js\', \'hidden\': \'\', \'status_display\': u\'queued\', \'id\': \'prob_1_2\', \'tabsize\': 4}</div>"""
"""<div>{\'status\': \'queued\', \'button_enabled\': True, \'linenumbers\': \'true\', \'rows\': \'10\', \'queue_len\': \'3\', \'mode\': \'\', \'cols\': \'80\', \'value\': \'print "good evening"\', \'status_class\': \'processing\', \'queue_msg\': \'\', \'STATIC_URL\': \'/dummy-static/\', \'msg\': u\'Submitted. As soon as a response is returned, this message will be replaced by that feedback.\', \'matlab_editor_js\': \'/dummy-static/js/vendor/CodeMirror/octave.js\', \'hidden\': \'\', \'status_display\': u\'queued\', \'id\': \'prob_1_2\', \'tabsize\': 4}</div>"""
)
# test html, that is correct HTML5 html, but is not parsable by XML parser.
......@@ -693,6 +693,7 @@ class SchematicTest(unittest.TestCase):
'width': width,
'height': height,
'parts': parts,
'setup_script': '/dummy-static/js/capa/schematicinput.js',
'analyses': analyses,
'submit_analyses': submit_analyses,
}
......
var schematic_height = 220;
var schematic_width = 400;
var styling_height_delta = 2; //How many pixels are added to the height of the box because of styling (like a shadow)
var styling_width_delta = 2;
$(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"
$("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();
if (editingCircuit.codeMirrorLine) {
editingCircuit.codeMirrorLine.replace(0, null, "circuit-schematic:" + saving_circuit);
}
});
});
var schematic_height = 220;
var schematic_width = 400;
var styling_height_delta = 2; //How many pixels are added to the height of the box because of styling (like a shadow)
var styling_width_delta = 2;
var schematic_editor_height = 300;
var schematic_editor_width = 500;
$(function(){
$(document).ready(function() {
//$("a[rel*=leanModal]").leanModal(); //TODO: Make this work with the new modal library. Try and integrate this with the "slices"
$("body").append('\
<div id="circuit_editor_modal" class="modal hide fade"> \
<div class="modal-body"> \
<input class="schematic" height="' + schematic_editor_height + '" width="' + schematic_editor_width + '" 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();
if (editingCircuit.codeMirrorLine) {
editingCircuit.codeMirrorLine.replace(0, null, "circuit-schematic:" + saving_circuit);
}
});
});
});
CodeMirror.defineMode("edx_markdown", function(cmCfg, modeCfg) {
var htmlFound = CodeMirror.mimeModes.hasOwnProperty("text/html");
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment