From d51341301ddf2d92b565c2ba094774c20593bea9 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Thu, 29 Mar 2012 15:56:21 -0700 Subject: [PATCH] Changed some css properties for proper sizing of elements. --- static/js/CodeMirror/mitx_markdown.js | 56 ++++++++++++++++----------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/static/js/CodeMirror/mitx_markdown.js b/static/js/CodeMirror/mitx_markdown.js index 9674d52264..6c0cb9dc26 100644 --- a/static/js/CodeMirror/mitx_markdown.js +++ b/static/js/CodeMirror/mitx_markdown.js @@ -1,8 +1,13 @@ +var schematic_height = 153; +var schematic_width = 400; + $(function(){ $(document).ready(function() { $("a[rel*=leanModal]").leanModal(); - $("body").append('
'); + $("body").append('
'+ + '' + + '
'); //This is the editor that pops up as a modal var editorCircuit = $("#schematic_editor").get(0); @@ -43,6 +48,7 @@ $(function(){ }); }); + CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) { var htmlMode = CodeMirror.getMode(cmCfg, { name: 'xml', htmlMode: true }); @@ -66,30 +72,34 @@ CodeMirror.defineMode("mitx_markdown", function(cmCfg, modeCfg) { .replace(/"/g, """) .replace(/'/g, "'"); } - - var circuit_formatter = { - creator: function(text) { - var circuit_value = text.match(circuitRE)[1] + + var circuit_formatter = { + creator: function(text) { + var circuit_value = text.match(circuitRE)[1] - circuit_value = escapeHtml(circuit_value); + circuit_value = escapeHtml(circuit_value); - var html = "" + - ""; - - return html; - }, - size: function(text) { - return {width: 150, height:152}; - }, - callback: function(node, line) { - update_schematics(); - var schmInput = node.firstChild; - schmInput.codeMirrorLine = line; - schmInput.schematic.always_draw_grid = true; - schmInput.schematic.redraw_background(); - $(node).leanModal(); - } - }; + var html = "
" + + "
"; + + return html; + }, + size: function(text) { + return {width: schematic_width, height:schematic_height}; + }, + callback: function(node, line) { + update_schematics(); + var schmInput = node.firstChild.firstChild; + schmInput.codeMirrorLine = line; + if (schmInput.schematic) { //This is undefined if there was an error making the schematic + schmInput.schematic.canvas.style.display = "block"; //Otherwise, it gets line height and is a weird size + schmInput.schematic.always_draw_grid = true; + schmInput.schematic.redraw_background(); + } + $(node.firstChild).leanModal(); + } + }; + var hrRE = /^[*-=_]/ , ulRE = /^[*-+]\s+/