Show More
@@ -1,89 +1,94 b'' | |||
|
1 | 1 | //---------------------------------------------------------------------------- |
|
2 | 2 | // Copyright (C) 2011 The IPython Development Team |
|
3 | 3 | // |
|
4 | 4 | // Distributed under the terms of the BSD License. The full license is in |
|
5 | 5 | // the file COPYING, distributed as part of this software. |
|
6 | 6 | //---------------------------------------------------------------------------- |
|
7 | 7 | |
|
8 | 8 | //============================================================================ |
|
9 | 9 | // On document ready |
|
10 | 10 | //============================================================================ |
|
11 | 11 | |
|
12 | 12 | |
|
13 | 13 | $(document).ready(function () { |
|
14 | 14 | |
|
15 | 15 | // monkey patch CM to be able to syntax highlight cell magics |
|
16 | 16 | // bug reported upstream, |
|
17 | 17 | // see https://github.com/marijnh/CodeMirror2/issues/670 |
|
18 | 18 | if(CodeMirror.getMode(1,'text/plain').indent == undefined ){ |
|
19 | 19 | console.log('patching CM for undefined indent'); |
|
20 | 20 | CodeMirror.modes.null = function() { return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}} |
|
21 | 21 | } |
|
22 | 22 | |
|
23 | 23 | CodeMirror.patchedGetMode = function(config, mode){ |
|
24 | 24 | var cmmode = CodeMirror.getMode(config, mode); |
|
25 | 25 | if(cmmode.indent == null) |
|
26 | 26 | { |
|
27 | 27 | console.log('patch mode "' , mode, '" on the fly'); |
|
28 | 28 | cmmode.indent = function(){return 0}; |
|
29 | 29 | } |
|
30 | 30 | return cmmode; |
|
31 | 31 | } |
|
32 | 32 | // end monkey patching CodeMirror |
|
33 | 33 | |
|
34 | 34 | IPython.mathjaxutils.init(); |
|
35 | 35 | |
|
36 | 36 | IPython.read_only = $('body').data('readOnly') === 'True'; |
|
37 | 37 | $('#ipython-main-app').addClass('border-box-sizing'); |
|
38 | 38 | $('div#notebook_panel').addClass('border-box-sizing'); |
|
39 | 39 | // The header's bottom border is provided by the menu bar so we remove it. |
|
40 | 40 | $('div#header').css('border-bottom-style','none'); |
|
41 | 41 | |
|
42 | 42 | var baseProjectUrl = $('body').data('baseProjectUrl') |
|
43 | 43 | |
|
44 | 44 | IPython.page = new IPython.Page(); |
|
45 | 45 | IPython.markdown_converter = new Markdown.Converter(); |
|
46 | 46 | IPython.layout_manager = new IPython.LayoutManager(); |
|
47 | 47 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); |
|
48 | 48 | IPython.quick_help = new IPython.QuickHelp('span#quick_help_area'); |
|
49 | 49 | IPython.login_widget = new IPython.LoginWidget('span#login_widget',{baseProjectUrl:baseProjectUrl}); |
|
50 | 50 | IPython.notebook = new IPython.Notebook('div#notebook',{baseProjectUrl:baseProjectUrl, read_only:IPython.read_only}); |
|
51 | 51 | IPython.save_widget = new IPython.SaveWidget('span#save_widget'); |
|
52 | 52 | IPython.menubar = new IPython.MenuBar('#menubar',{baseProjectUrl:baseProjectUrl}) |
|
53 | 53 | IPython.toolbar = new IPython.MainToolBar('#maintoolbar') |
|
54 | 54 | IPython.tooltip = new IPython.Tooltip() |
|
55 | 55 | IPython.notification_area = new IPython.NotificationArea('#notification_area') |
|
56 | 56 | IPython.notification_area.init_notification_widgets(); |
|
57 | 57 | |
|
58 | 58 | IPython.layout_manager.do_resize(); |
|
59 | 59 | |
|
60 | 60 | $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+ |
|
61 | 61 | '<span id="test2" style="font-weight: bold;">x</span>'+ |
|
62 | 62 | '<span id="test3" style="font-style: italic;">x</span></pre></div>') |
|
63 | 63 | var nh = $('#test1').innerHeight(); |
|
64 | 64 | var bh = $('#test2').innerHeight(); |
|
65 | 65 | var ih = $('#test3').innerHeight(); |
|
66 | 66 | if(nh != bh || nh != ih) { |
|
67 | 67 | $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>'); |
|
68 | 68 | } |
|
69 | 69 | $('#fonttest').remove(); |
|
70 | 70 | |
|
71 | 71 | if(IPython.read_only){ |
|
72 | 72 | // hide various elements from read-only view |
|
73 | 73 | $('div#pager').remove(); |
|
74 | 74 | $('div#pager_splitter').remove(); |
|
75 | 75 | |
|
76 | 76 | // set the notebook name field as not modifiable |
|
77 | 77 | $('#notebook_name').attr('disabled','disabled') |
|
78 | 78 | } |
|
79 | 79 | |
|
80 | 80 | IPython.page.show(); |
|
81 | 81 | |
|
82 | 82 | IPython.layout_manager.do_resize(); |
|
83 | 83 | $([IPython.events]).on('notebook_loaded.Notebook', function () { |
|
84 | 84 | IPython.layout_manager.do_resize(); |
|
85 | var hash = document.location.hash; | |
|
86 | if (hash) { | |
|
87 | document.location.hash = ''; | |
|
88 | document.location.hash = hash; | |
|
89 | } | |
|
85 | 90 | }); |
|
86 | 91 | IPython.notebook.load_notebook($('body').data('notebookId')); |
|
87 | 92 | |
|
88 | 93 | }); |
|
89 | 94 |
General Comments 0
You need to be logged in to leave comments.
Login now