From c7feee5b67b62093e2525d3c63df38a8b507a3fa Mon Sep 17 00:00:00 2001 From: cahrens Date: Tue, 8 Jan 2013 15:39:45 -0500 Subject: [PATCH] Delete speed-editor.js and cruft from unit.html. --- cms/static/js/speed-editor.js | 438 ---------------------------------- cms/templates/unit.html | 94 -------- 2 files changed, 532 deletions(-) delete mode 100644 cms/static/js/speed-editor.js 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, '

$1

'); - xml = xml.replace(/\n^\=\=+$/gm, ''); - - // group multiple choice answers - xml = xml.replace(/(^\s*\(.?\).*?$\n*)+/gm, function(match, p) { - var groupString = '\n'; - groupString += ' \n'; - var options = match.split('\n'); - for(var i = 0; i < options.length; i++) { - if(options[i].length > 0) { - var value = options[i].split(/^\s*\(.?\)\s*/)[1]; - var correct = /^\s*\(x\)/i.test(options[i]); - groupString += ' ' + value + '\n'; - } - } - groupString += ' \n'; - groupString += '\n\n'; - return groupString; - }); - - // group check answers - xml = xml.replace(/(^\s*\[.?\].*?$\n*)+/gm, function(match, p) { - var groupString = '\n'; - groupString += ' \n'; - var options = match.split('\n'); - for(var i = 0; i < options.length; i++) { - if(options[i].length > 0) { - var value = options[i].split(/^\s*\[.?\]\s*/)[1]; - var correct = /^\s*\[x\]/i.test(options[i]); - groupString += ' ' + value + '\n'; - } - } - groupString += ' \n'; - groupString += '\n\n'; - return groupString; - }); - - // replace videos - xml = xml.replace(/\{\{video\s(.*?)\}\}/g, '