Add focus/blur to API, don't stopPropagation DOM focus/blur

Before, we'd listen to focus/blur on the MathQuill root span and
trigger it on the textarea, but in some browsers this bubbles, so to
avoid infinite looping, we'd stopPropagation() in the textarea handler.

In ways I don't fully understand, this made detecting focus/blur from
outside MathQuill (via the jQuery focusin/out events) unreliable,
in particular, if you clicked on the math and then left and then clicked
again, there would be a focusin event the first time, but successive
clicks trigger no focusin events even though the textbox is visibly
blurring and focusing.

The solution I settled on is to have an API call to set focus or blur,
and never interfere with actual HTML DOM focus/blur events. This is what
CodeMirror 2 and ACE (Cloud9) both do, as of
https://github.com/marijnh/CodeMirror/blob/8ba416d5cac2de28a6da9bbc966b8b8761850358/lib/codemirror.js
and
https://github.com/ajaxorg/ace/blob/51b15d35889148f3bd21060bba5cbb32670e36ff/lib/ace/editor.js

Note this means the initializing blur() has to be called on the textarea
now.
Stop triggering spurious focusin events on click

Only focus textarea if it became unfocused (which it only should in IE<9
where preventing default in mousedown fails to prevent focus from
transferring to the mousedown target (which when it's anything in a
MathQuill span, we'd like to prevent)).

New contract on textarea.focused: set in focus/blur event handlers on
the textarea, elsewhere it'll be correct when checked.
Systematize show/hide/blur

We're now specifying a contract for Cursor::writeLatex() and
RootBlock::renderLatex():
- will call cursor.show() # so no need to do so before calling them, but
                          # it's also harmless to do so
- will call cursor.parent.focus()
- won't call cursor.hide() or .parent.blur()
  # so when RootTextBlock::renderLatex() calls
  # RootMathBlock::renderLatex(), don't have to re-show() afterwards

So now it's up to the API calls to check the editable was blurred before
the call, and if so, call cursor.hide().parent.blur().
Merge branch 'api.focus-blur' into refactor.controller
Split createRoot into many functions

createRoot was >300 lines with little cohesion. In preparation for
\editable not stopPropagation-ing mouse events, for which we want
\editable to run much but not all of the same code, split createRoot
into many functions and have the original calls to createRoot call each
of them (so \editable can just call the ones it wants and not call some
of them).

To keep the diff readable, as much as possible I didn't touch the actual
createRoot code, but rather put lots of ends of functions and beginnings
of new functions in between code blocks.
Notes:
- Most variables that were shared in the grab-bag of createRoot's scope
  are either passed to createRoot() (like container, root, textbox, and
  editable), or can be read from slots of root (cursor from .cursor,
  textareaSpan from .textarea), or can just be returned from a function
  to be passed to another.
    + The exception is the textareaManager, which is closed over in a
      function created in setupTextarea() before it's initialized later
      on in hookUpTextarea(), which in turn uses the textarea created by
      setupTextarea(), a circular dependency that only worked because
      their contents were in the same scope. The main thing I don't want
      \editable to run that I'm trying to split out of createRoot() is
      mouseEvents(), which is in between setupTextarea() and
      hookUpTextarea(), so I can't keep them the same function. The
      smallest change I could think of that would work was for
      hookUpTextarea() to return the textareaManager it creates, and for
      setupTextarea() to directly call hookUpTextarea() and close over
      the returned textareaManager. This does reorder execution of the
      hookUpTextarea() code before mouseEvents(), but that ordering was
      incidental anyway.
- There was an early return, `if (!editable) { ... return; }`, in the
  middle of what became hookUpTextarea(), that obviously doesn't work
  now that hookUpTextarea() is its own function, so the caller of all
  the new sub-functions of createRoot has to manually return early at
  the same place.
Fix .id/.jQ/mqBlockId asymmetrical for root block

e23f3de1a8bd1a6420e498aa9fa7b29397ad338c "Separate out root block DOM
node from container DOM" on #195 perf.latex-render did this weird thing
where the container's 'mathquill-block-id' attribute is the .id of the
RootMathBlock, but the RootMathBlock's .jQ is the
span.mathquill-root-block inside the container, so as to not have to
change publicapi.js.

Turns out that fixing that (so the RootMathBlock's .jQ is the
span.mathquill-root-block, whose 'mathquill-block-id' attribute is the
.id of RootMathBlock) and changing the public API to work with the new
structure actually dramatically simplifies publicapi.js, because after
filtering for .mathquill-root-block I can be reasonably sure we have
actual MathQuill-made HTML elements.
Replace `textarea.focused` with `root.blurred`

`textarea` is a jQuery object, shouldn't put flag on there, whereas
`root` is a long-lived RootMathBlock.

Grepping for `.focused`, literally every condition on it negated it, so
use `.blurred` instead. (The name is also shorter.) The downside is the
initial value has to be set to true (rather than defaulting to the falsy
`undefined`), which it already was for editables because of the initial
blur on the textarea (in `focusBlurEvents()`), but wasn't for static
math.
Don't stopPropagation() mouse events

...instead, use closest root block.

Completely replace the old RootMathCommand-descended, jQadd-overriding
\editable. Instead, LatexCmds.editable::finalizeTree sets up its block
to be like RootMathBlock after .mathquill('editable').

The main reason for the big createRoot() refactor, 46a97ee "Split
createRoot into many functions", is that the mousedown handlers attached
to the root of the static math and to the root of the inner editable
stepped on each other's toes. Until now we did stopPropagation, but
that's bad (it breaks e.g. the Desmos graphing calculator), the right
thing is for mousedown to be a delegated event, with the handler only
attached to the ultimate root of the MathQuill tree (the root of the
static math), which then uses the closest ancestor that's a root block
to determine editability, attaches the mousemove handler to it, focuses
its textarea, and seeks its cursor.

Note that it's important to attach the mousemove event handler to the
closest ancestor root block, lest the target node not descend from the
cursor's root, breaking Cursor::seek. (The mousemove handler attached
to the document ignores the target node.)
Rename \editable to \MathQuillMathField

Use a MathQuill namespaced name so as to avoid the remote possibility of
colliding with other LaTeX command names.

Recommend --word-diff-regex='\w+|.' to view diff.
Test that public API works for \MathQuillMathField
Fix paste in inner editable math fields

For editables the paste handler is attached to the container so as to
listen for middle-click paste, but for static math the only reason for
the cut and paste handlers is that Ctrl-X and Ctrl-V don't do anything
for static text so when static math is selected, even though a textarea
is actually selected, we want to pretend they don't do anything. So
there's no reason to listen for cut or paste events from anywhere beside
the textarea, and in fact preventing default on any paste event from
anywhere inside the static math blocks paste in inner editable math
fields.
Merge branch 'feature.MathQuillMathField' into refactor.controller
Move mouseEvents() out into its own mouse.js

Continue to kill rootelements.js, slowly.
Inline hookUpTextarea() into setupTextarea()

They belong together anyway, it was just bad organization that
mouseEvents() was between them.
Inline rootCSSClasses() into publicapi.js

Don't worry, rootelements.js, it'll be over soon.
Include focusBlurEvents() inside setupTextarea()

Another immaterial slight re-ordering.
Rename root.textarea => root.textareaSpan

root.textarea wasn't a textarea, how dumb was that

Recommend --word-diff-regex='\w+' to view diff.
Comment on why we throttle setTextareaSelection() #doTodo
Fix potential Ctrl-C "copy" race condition

No matter editable or noneditable, we always want to synchronously set
the textarea selection on a `copy` event.

https://github.com/mathquill/mathquill/commit/404d619#commitcomment-5208259
Slightly rearrange setupTextarea()

Move root.selectionChanged closer to manageTextarea(), because
root.selectionChanged closes over the textareaManager created by
manageTextarea.