From 4261569215ee203e34ec4dcc9f1dccb7776c5467 Mon Sep 17 00:00:00 2001
From: Julia Hansbrough <julia@edx.org>
Date: Thu, 24 Oct 2013 21:00:06 +0000
Subject: [PATCH] Fixing accessibility bug where users could not tab through on
 wiki

LMS-1307
---
 CHANGELOG.rst                         |  2 ++
 lms/djangoapps/course_wiki/editors.py |  1 +
 lms/static/js/wiki/CodeMirror.init.js |  1 +
 lms/static/js/wiki/accessible.js      | 10 ++++++++++
 4 files changed, 14 insertions(+)
 create mode 100644 lms/static/js/wiki/accessible.js

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 980a277c38d..cea6d7d79f0 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -11,6 +11,8 @@ Studio: Change course overview page, checklists, assets, and course staff manage
 page URLs to a RESTful interface. Also removed "\listing", which duplicated
 "\index".
 
+LMS: Fixed accessibility bug where users could not tab through wiki (LMS-1307)
+
 Blades: When start time and end time are specified for a video, a visual range
 will be shown on the time slider to highlight the place in the video that will
 be played.
diff --git a/lms/djangoapps/course_wiki/editors.py b/lms/djangoapps/course_wiki/editors.py
index 2ca8260bfe5..e823bfdafa6 100644
--- a/lms/djangoapps/course_wiki/editors.py
+++ b/lms/djangoapps/course_wiki/editors.py
@@ -58,6 +58,7 @@ class CodeMirror(BaseEditor):
         js = ("js/vendor/CodeMirror/codemirror.js",
               "js/vendor/CodeMirror/xml.js",
               "js/vendor/CodeMirror/mitx_markdown.js",
+              "js/wiki/accessible.js",
               "js/wiki/CodeMirror.init.js",
               "js/wiki/cheatsheet.js",
               )
diff --git a/lms/static/js/wiki/CodeMirror.init.js b/lms/static/js/wiki/CodeMirror.init.js
index 60a4917fc2f..2ef21aa4be9 100644
--- a/lms/static/js/wiki/CodeMirror.init.js
+++ b/lms/static/js/wiki/CodeMirror.init.js
@@ -5,6 +5,7 @@ $(document).ready(function() {
     matchBrackets: true,
     theme: "default",
     lineWrapping: true,
+    keyMap: "accessible"
   });
       
   //Store the inital contents so we can compare for unsaved changes
diff --git a/lms/static/js/wiki/accessible.js b/lms/static/js/wiki/accessible.js
new file mode 100644
index 00000000000..c7750b2973a
--- /dev/null
+++ b/lms/static/js/wiki/accessible.js
@@ -0,0 +1,10 @@
+/* By default, CodeMirror turns tabs into indents, which makes it difficult for keyboard-only
+   users to "tab through" elements on a page.  Including this file and setting keyMap to 
+   "accessible" removes the "tab" from CodeMirror's default KeyMap to remedy this problem */
+
+var keyMap = CodeMirror.keyMap.accessible = {
+  "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
+  "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
+  "Delete": "delCharRight", "Backspace": "delCharLeft", "Shift-Tab": "indentAuto",
+  "Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
+};
-- 
GitLab