Using a class varilable instead of temp files for keeping track of docs.

:meth:`IpythonDirective.setup` method was using a temporary file, such
as :file:`/tmp/seen_docRANDOM`, for storing visited source document
filenames. For a document that is not visited (name not in the temporary
file), it restarts counting line numbers.  Temporary file names are
selected randomly and they were not deleted from the disk upon
completion of a build. Since :meth:`.setup` picks a temp file
arbitrarily to visited status of a file is determined incorrectly.
Using a class variable resolves this problem.

Changed the directive setup function to use a class files for keeping
track of documents.
Fixed a problem with evaluating indented lines in pure python code.

:meth:`EmbeddedSphinxShell.process_pure_python` could not process
block of code with indentation correctly. For example, the following

.. ipython:: python

   for i in range(10):
       if i < 5:
           continue
       else:
           pass

would result in two IPython lines:

In [19]: for i in range(10):
   ....:      if i < 5:
   ....:          continue
   ....:

In [20]: else:
   ....:          pass
   ....:

This would raise various types of error, indentation/snytax, etc.

To resolve this problem, added a simple check for indentation
in the next line which normally start a new IPython line.
Merge branch 'master' of https://github.com/abakan/ipython
Reverted an unintended change in matplotlib backend.
workaround spurious CodeMirror scrollbars

always draw scrollbar margin, so that inappropriate scrollbars never overlap the last line.
To compensate for the extra space, the margin between the scrollbar and the last line is shrunk significantly.
Failing test for gh-3246
Use new input transformation API in %paste

Closes gh-3246
Refactor paste magics and ipdoctest
Inject requirejs in notebook and start using it.
Use different threshold for (auto)scroll in output

Allow, in particular to switch to scolling for longer input (or disable
it) by still keeping the possibility to manually toggle the output to
scroll.
normalize unicode notebook filenames

used in comparison check for notebook name change.

Unless the filenames are normalized,
unchanged names may result in false positives for a name change
(e.g. OS X uses NFD on the filesystem,
so u'\xfc' roundtripped to the filesystem will be u'u\u0308'),
which can result in the first save of a notebook after open performing the following actions:

1. save the recently opened notebook
2. `old_name != new_name`, so name change detected
3. delete old_name (which is actually new_name), which ultimately deletes the just-saved notebook

In master, this has a symptom of the first checkpoint failing because the first save actually deleted the file, and you can't checkpoint a notebook that doesn't exist.

closes #3360
improve js documentation
add is_typing utility

simple, liberal check for whether a keypress is probably typing or not.
setting the notebook dirty flag is now an event

set_dirty.Notebook
rename scroll_threshold, add minimum_ prefix
base default cookie name on request host+port

instead of random.

The random cookie name meant that every time you restarted the notebook it would get a new key in the cookie for the same host, resulting in an ever-growing cookie full of obsolete data.
make cookie_secret configurable

allows config to specify logins that survive across server instances (default behavior unchanged).

Depends on PR #3372
trigger dirty on CM change
remove unused is_typing js util
disable CodeMirror drag/drop on Safari

workaround for marijnh/CodeMirror#332

closes #3375