diff --git a/cms/static/js/speed-editor.js b/cms/static/js/speed-editor.js deleted file mode 100644 index eec4341b6a..0000000000 --- a/cms/static/js/speed-editor.js +++ /dev/null @@ -1,438 +0,0 @@ -var $body; -var $preview; -var $tooltip; -var $cheatsheet; -var $currentEditor; -var simpleEditor; -var xmlEditor; -var currentEditor; -var controlDown; -var commandDown; - - -(function() { - $body.on('click', '.editor-bar a', onEditorButton); - $body.on('click', '.cheatsheet-toggle', toggleCheatsheet); -// NOTE: we are showing metadata in the standard way, not in an "Advanced" section below. - $body.on('click', '.problem-settings-button', toggleProblemSettings); -// NOTE: not doing keybindings at this time. - $(document).bind('keyup', onKeyboard); -})(); - -function initProblemEditors($editor, $prev) { - $currentEditor = $editor; - simpleEditor = CodeMirror.fromTextArea($editor.find('.edit-box')[0], { - lineWrapping: true, -// NOTE: keybindings have been left out at this point. Needs further work. - extraKeys: { - 'Ctrl-N': newUnit, - 'Ctrl-H': makeHeader, - 'Ctrl-V': makeVideo, - 'Ctrl-M': makeMultipleChoice, - 'Ctrl-C': makeCheckboxes, - 'Ctrl-S': makeStringInput, - 'Shift-Ctrl-3': makeNumberInput, - 'Shift-Ctrl-S': makeSelect - }, - mode: null, - onChange: onSimpleEditorUpdate - }); - - xmlEditor = CodeMirror.fromTextArea($editor.find('.xml-box')[0], { - lineWrapping: true, - mode: 'xml', - lineNumbers: true - }); - - currentEditor = simpleEditor; - -// NOTE: I left out setting the background color. Does not appear necessary. - $(simpleEditor.getWrapperElement()).css('background', '#fff'); - $(xmlEditor.getWrapperElement()).css({ - 'background': '#fff' - }).hide(); - -// NOTE: I left this out, doesn't seem to be necessary. - $(simpleEditor.getWrapperElement()).bind('click', setFocus); -// NOTE: we are not supporting preview at this time. - $preview = $prev.find('.problem'); -} - -function toggleProblemSettings(e) { - e.preventDefault(); - - $(this).toggleClass('is-open'); - - if($(this).hasClass('is-open')) { - $(this).find('.button-label').html('Hide Advanced Settings'); - $('.problem-settings').slideDown(150); - } else { - $(this).find('.button-label').html('Show Advanced Settings'); - $('.problem-settings').slideUp(150); - } -} - -function toggleCheatsheet(e) { - e.preventDefault(); - - if(!$currentEditor.find('.simple-editor-cheatsheet')[0]) { - $cheatsheet = $($('#simple-editor-cheatsheet').html()); - $currentEditor.append($cheatsheet); - } - - setTimeout(function() { - $cheatsheet.toggleClass('shown'); - }, 10); -} - -function setFocus(e) { - $(simpleEditor).focus(); -} - -function onSimpleEditorUpdate() { - console.log('update'); - updatePreview(); - updateXML(); -} - -function updateXML() { - var val = simpleEditor.getValue(); - var xml = val; - - // replace headers - xml = xml.replace(/(^.*?$)(?=\n\=\=+$)/gm, '