##// END OF EJS Templates
Trigger a single event on js app initilized...
Matthias BUSSONNIER -
Show More
@@ -1,123 +1,124 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 "use strict";
12 12
13 13 // for the time beeing, we have to pass marked as a parameter here,
14 14 // as injecting require.js make marked not to put itself in the globals,
15 15 // which make both this file fail at setting marked configuration, and textcell.js
16 16 // which search marked into global.
17 17 require(['components/marked/lib/marked'],
18 18
19 19 function (marked) {
20 20
21 21 window.marked = marked
22 22
23 23 // monkey patch CM to be able to syntax highlight cell magics
24 24 // bug reported upstream,
25 25 // see https://github.com/marijnh/CodeMirror2/issues/670
26 26 if(CodeMirror.getMode(1,'text/plain').indent == undefined ){
27 27 console.log('patching CM for undefined indent');
28 28 CodeMirror.modes.null = function() {
29 29 return {token: function(stream) {stream.skipToEnd();},indent : function(){return 0}}
30 30 }
31 31 }
32 32
33 33 CodeMirror.patchedGetMode = function(config, mode){
34 34 var cmmode = CodeMirror.getMode(config, mode);
35 35 if(cmmode.indent == null)
36 36 {
37 37 console.log('patch mode "' , mode, '" on the fly');
38 38 cmmode.indent = function(){return 0};
39 39 }
40 40 return cmmode;
41 41 }
42 42 // end monkey patching CodeMirror
43 43
44 44 IPython.mathjaxutils.init();
45 45
46 46 IPython.read_only = $('body').data('readOnly') === 'True';
47 47 $('#ipython-main-app').addClass('border-box-sizing');
48 48 $('div#notebook_panel').addClass('border-box-sizing');
49 49
50 50 var baseProjectUrl = $('body').data('baseProjectUrl')
51 51
52 52 IPython.page = new IPython.Page();
53 53 IPython.layout_manager = new IPython.LayoutManager();
54 54 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
55 55 IPython.quick_help = new IPython.QuickHelp();
56 56 IPython.login_widget = new IPython.LoginWidget('span#login_widget',{baseProjectUrl:baseProjectUrl});
57 57 IPython.notebook = new IPython.Notebook('div#notebook',{baseProjectUrl:baseProjectUrl, read_only:IPython.read_only});
58 58 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
59 59 IPython.menubar = new IPython.MenuBar('#menubar',{baseProjectUrl:baseProjectUrl})
60 60 IPython.toolbar = new IPython.MainToolBar('#maintoolbar-container')
61 61 IPython.tooltip = new IPython.Tooltip()
62 62 IPython.notification_area = new IPython.NotificationArea('#notification_area')
63 63 IPython.notification_area.init_notification_widgets();
64 64
65 65 IPython.layout_manager.do_resize();
66 66
67 67 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
68 68 '<span id="test2" style="font-weight: bold;">x</span>'+
69 69 '<span id="test3" style="font-style: italic;">x</span></pre></div>')
70 70 var nh = $('#test1').innerHeight();
71 71 var bh = $('#test2').innerHeight();
72 72 var ih = $('#test3').innerHeight();
73 73 if(nh != bh || nh != ih) {
74 74 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
75 75 }
76 76 $('#fonttest').remove();
77 77
78 78 if(IPython.read_only){
79 79 // hide various elements from read-only view
80 80 $('div#pager').remove();
81 81 $('div#pager_splitter').remove();
82 82
83 83 // set the notebook name field as not modifiable
84 84 $('#notebook_name').attr('disabled','disabled')
85 85 }
86 86
87 87 IPython.page.show();
88 88
89 89 IPython.layout_manager.do_resize();
90 90 var first_load = function () {
91 91 IPython.layout_manager.do_resize();
92 92 var hash = document.location.hash;
93 93 if (hash) {
94 94 document.location.hash = '';
95 95 document.location.hash = hash;
96 96 }
97 97 IPython.notebook.set_autosave_interval(IPython.notebook.minimum_autosave_interval);
98 98 // only do this once
99 99 $([IPython.events]).off('notebook_loaded.Notebook', first_load);
100 100 };
101 101
102 102 $([IPython.events]).on('notebook_loaded.Notebook', first_load);
103 $([IPython.events]).trigger('app_initialized.NotebookApp');
103 104 IPython.notebook.load_notebook($('body').data('notebookId'));
104 105
105 106 if (marked) {
106 107 marked.setOptions({
107 108 gfm : true,
108 109 tables: true,
109 110 langPrefix: "language-",
110 111 highlight: function(code, lang) {
111 112 var highlighted;
112 113 try {
113 114 highlighted = hljs.highlight(lang, code, false);
114 115 } catch(err) {
115 116 highlighted = hljs.highlightAuto(code);
116 117 }
117 118 return highlighted.value;
118 119 }
119 120 })
120 121 }
121 122 }
122 123
123 124 );
General Comments 0
You need to be logged in to leave comments. Login now