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