Show More
@@ -0,0 +1,56 b'' | |||||
|
1 | ||||
|
2 | //============================================================================ | |||
|
3 | // Layout | |||
|
4 | //============================================================================ | |||
|
5 | ||||
|
6 | var IPython = (function (IPython) { | |||
|
7 | ||||
|
8 | var LayoutManager = function () { | |||
|
9 | this.bind_events(); | |||
|
10 | }; | |||
|
11 | ||||
|
12 | ||||
|
13 | LayoutManager.prototype.bind_events = function () { | |||
|
14 | $(window).resize($.proxy(this.do_resize,this)); | |||
|
15 | }; | |||
|
16 | ||||
|
17 | ||||
|
18 | LayoutManager.prototype.do_resize = function () { | |||
|
19 | var win = $(window); | |||
|
20 | var w = win.width(); | |||
|
21 | var h = win.height(); | |||
|
22 | var header_height = $('div#header').outerHeight(true); | |||
|
23 | var app_height = h - header_height - 2; // content height | |||
|
24 | ||||
|
25 | $('div#notebook_app').height(app_height + 2); // content+padding+border height | |||
|
26 | ||||
|
27 | $('div#left_panel').height(app_height); | |||
|
28 | ||||
|
29 | $('div#left_panel_splitter').height(app_height); | |||
|
30 | ||||
|
31 | var left_panel_width = $('div#left_panel').outerWidth(); | |||
|
32 | var left_panel_splitter_width = $('div#left_panel_splitter').outerWidth(); | |||
|
33 | $('div#notebook_panel').height(app_height); | |||
|
34 | if (IPython.left_panel.expanded) { | |||
|
35 | $('div#notebook_panel').css({marginLeft : left_panel_width+left_panel_splitter_width}); | |||
|
36 | } else { | |||
|
37 | $('div#notebook_panel').css({marginLeft : left_panel_splitter_width}); | |||
|
38 | } | |||
|
39 | ||||
|
40 | ||||
|
41 | var pager_height = IPython.pager.percentage_height*app_height; | |||
|
42 | var pager_splitter_height = $('div#pager_splitter').outerHeight(true); | |||
|
43 | $('div#pager').height(pager_height); | |||
|
44 | if (IPython.pager.expanded) { | |||
|
45 | $('div#notebook').height(app_height-pager_height-pager_splitter_height); | |||
|
46 | } else { | |||
|
47 | $('div#notebook').height(app_height-pager_splitter_height); | |||
|
48 | } | |||
|
49 | console.log('resize: ', app_height); | |||
|
50 | }; | |||
|
51 | ||||
|
52 | IPython.LayoutManager = LayoutManager | |||
|
53 | ||||
|
54 | return IPython; | |||
|
55 | ||||
|
56 | }(IPython)); |
@@ -0,0 +1,87 b'' | |||||
|
1 | ||||
|
2 | //============================================================================ | |||
|
3 | // LeftPanel | |||
|
4 | //============================================================================ | |||
|
5 | ||||
|
6 | ||||
|
7 | var IPython = (function (IPython) { | |||
|
8 | ||||
|
9 | var utils = IPython.utils; | |||
|
10 | ||||
|
11 | var LeftPanel = function (left_panel_selector, left_panel_splitter_selector) { | |||
|
12 | this.left_panel_element = $(left_panel_selector); | |||
|
13 | this.left_panel_splitter_element = $(left_panel_splitter_selector); | |||
|
14 | this.expanded = true; | |||
|
15 | this.width = 250; | |||
|
16 | this.style(); | |||
|
17 | this.bind_events(); | |||
|
18 | }; | |||
|
19 | ||||
|
20 | ||||
|
21 | LeftPanel.prototype.style = function () { | |||
|
22 | this.left_panel_splitter_element.addClass('border-box-sizing ui-widget ui-state-default'); | |||
|
23 | this.left_panel_element.addClass('border-box-sizing ui-widget'); | |||
|
24 | this.left_panel_element.width(this.width); | |||
|
25 | this.left_panel_splitter_element.css({left : this.width}); | |||
|
26 | }; | |||
|
27 | ||||
|
28 | ||||
|
29 | LeftPanel.prototype.bind_events = function () { | |||
|
30 | var that = this; | |||
|
31 | ||||
|
32 | this.left_panel_element.bind('collapse_left_panel', function () { | |||
|
33 | that.left_panel_element.hide('fast'); | |||
|
34 | that.left_panel_splitter_element.animate({left : 0}, 'fast'); | |||
|
35 | }); | |||
|
36 | ||||
|
37 | this.left_panel_element.bind('expand_left_panel', function () { | |||
|
38 | that.left_panel_element.show('fast'); | |||
|
39 | that.left_panel_splitter_element.animate({left : that.width}, 'fast'); | |||
|
40 | }); | |||
|
41 | ||||
|
42 | this.left_panel_splitter_element.hover( | |||
|
43 | function () { | |||
|
44 | that.left_panel_splitter_element.addClass('ui-state-hover'); | |||
|
45 | }, | |||
|
46 | function () { | |||
|
47 | that.left_panel_splitter_element.removeClass('ui-state-hover'); | |||
|
48 | } | |||
|
49 | ); | |||
|
50 | ||||
|
51 | this.left_panel_splitter_element.click(function () { | |||
|
52 | that.toggle(); | |||
|
53 | }); | |||
|
54 | ||||
|
55 | }; | |||
|
56 | ||||
|
57 | ||||
|
58 | LeftPanel.prototype.collapse = function () { | |||
|
59 | if (this.expanded === true) { | |||
|
60 | this.left_panel_element.add($('div#notebook')).trigger('collapse_left_panel'); | |||
|
61 | this.expanded = false; | |||
|
62 | }; | |||
|
63 | }; | |||
|
64 | ||||
|
65 | ||||
|
66 | LeftPanel.prototype.expand = function () { | |||
|
67 | if (this.expanded !== true) { | |||
|
68 | this.left_panel_element.add($('div#notebook')).trigger('expand_left_panel'); | |||
|
69 | this.expanded = true; | |||
|
70 | }; | |||
|
71 | }; | |||
|
72 | ||||
|
73 | ||||
|
74 | LeftPanel.prototype.toggle = function () { | |||
|
75 | if (this.expanded === true) { | |||
|
76 | this.collapse(); | |||
|
77 | } else { | |||
|
78 | this.expand(); | |||
|
79 | }; | |||
|
80 | }; | |||
|
81 | ||||
|
82 | IPython.LeftPanel = LeftPanel; | |||
|
83 | ||||
|
84 | return IPython; | |||
|
85 | ||||
|
86 | }(IPython)); | |||
|
87 |
@@ -111,8 +111,6 b' div#notebook_app {' | |||||
111 | } |
|
111 | } | |
112 |
|
112 | |||
113 | div#left_panel { |
|
113 | div#left_panel { | |
114 | width: 200px; |
|
|||
115 | min-height: 300px; |
|
|||
116 | overflow-y: auto; |
|
114 | overflow-y: auto; | |
117 | top: 0px; |
|
115 | top: 0px; | |
118 | left: 0px; |
|
116 | left: 0px; | |
@@ -131,7 +129,8 b' div#left_panel_splitter {' | |||||
131 | } |
|
129 | } | |
132 |
|
130 | |||
133 | div#notebook_panel { |
|
131 | div#notebook_panel { | |
134 | margin: 0px 0px 0px 209px; |
|
132 | /* The L margin will be set in the Javascript code*/ | |
|
133 | margin: 0px 0px 0px 0px; | |||
135 | padding: 0px; |
|
134 | padding: 0px; | |
136 | } |
|
135 | } | |
137 |
|
136 | |||
@@ -150,7 +149,6 b' div#pager_splitter {' | |||||
150 | } |
|
149 | } | |
151 |
|
150 | |||
152 | div#pager { |
|
151 | div#pager { | |
153 | height: 200px; |
|
|||
154 | overflow: auto; |
|
152 | overflow: auto; | |
155 | } |
|
153 | } | |
156 |
|
154 |
@@ -25,6 +25,7 b' var IPython = (function (IPython) {' | |||||
25 |
|
25 | |||
26 |
|
26 | |||
27 | Notebook.prototype.style = function () { |
|
27 | Notebook.prototype.style = function () { | |
|
28 | $('div#notebook').addClass('border-box-sizing'); | |||
28 | }; |
|
29 | }; | |
29 |
|
30 | |||
30 |
|
31 | |||
@@ -96,6 +97,20 b' var IPython = (function (IPython) {' | |||||
96 | var new_height = app_height - pager_height - splitter_height; |
|
97 | var new_height = app_height - pager_height - splitter_height; | |
97 | that.element.animate({height : new_height + 'px'}, 'fast'); |
|
98 | that.element.animate({height : new_height + 'px'}, 'fast'); | |
98 | }); |
|
99 | }); | |
|
100 | ||||
|
101 | this.element.bind('collapse_left_panel', function () { | |||
|
102 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); | |||
|
103 | var new_margin = splitter_width; | |||
|
104 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); | |||
|
105 | }); | |||
|
106 | ||||
|
107 | this.element.bind('expand_left_panel', function () { | |||
|
108 | var splitter_width = $('div#left_panel_splitter').outerWidth(true); | |||
|
109 | var left_panel_width = IPython.left_panel.width; | |||
|
110 | var new_margin = splitter_width + left_panel_width; | |||
|
111 | console.log('expand', splitter_width, left_panel_width, new_margin); | |||
|
112 | $('div#notebook_panel').animate({marginLeft : new_margin + 'px'}, 'fast'); | |||
|
113 | }); | |||
99 | }; |
|
114 | }; | |
100 |
|
115 | |||
101 |
|
116 |
@@ -6,26 +6,6 b'' | |||||
6 |
|
6 | |||
7 | $(document).ready(function () { |
|
7 | $(document).ready(function () { | |
8 |
|
8 | |||
9 |
|
||||
10 | $('div#notebook_app').addClass('border-box-sizing ui-widget ui-widget-content'); |
|
|||
11 | $('div#left_panel').addClass('border-box-sizing ui-widget'); |
|
|||
12 | $('div#left_panel_splitter').addClass('border-box-sizing ui-widget ui-state-default'); |
|
|||
13 | $('div#notebook_panel').addClass('border-box-sizing ui-widget'); |
|
|||
14 | $('div#notebook').addClass('border-box-sizing'); |
|
|||
15 |
|
||||
16 | $('div#left_panel_splitter').click(function () { |
|
|||
17 | $('div#left_panel').toggle('fast'); |
|
|||
18 | }); |
|
|||
19 |
|
||||
20 | $('div#left_panel_splitter').hover( |
|
|||
21 | function () { |
|
|||
22 | $('div#left_panel_splitter').addClass('ui-state-hover'); |
|
|||
23 | }, |
|
|||
24 | function () { |
|
|||
25 | $('div#left_panel_splitter').removeClass('ui-state-hover'); |
|
|||
26 | } |
|
|||
27 | ); |
|
|||
28 |
|
||||
29 | MathJax.Hub.Config({ |
|
9 | MathJax.Hub.Config({ | |
30 | tex2jax: { |
|
10 | tex2jax: { | |
31 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], |
|
11 | inlineMath: [ ['$','$'], ["\\(","\\)"] ], | |
@@ -37,34 +17,17 b' $(document).ready(function () {' | |||||
37 | } |
|
17 | } | |
38 | }); |
|
18 | }); | |
39 |
|
19 | |||
40 | var do_resize = function () { |
|
20 | $('div#notebook_app').addClass('border-box-sizing ui-widget ui-widget-content'); | |
41 | var win = $(window); |
|
21 | $('div#notebook_panel').addClass('border-box-sizing ui-widget'); | |
42 | var w = win.width(); |
|
|||
43 | var h = win.height(); |
|
|||
44 | var header_height = $('div#header').outerHeight(true); |
|
|||
45 | var app_height = h - header_height - 2; // content height |
|
|||
46 | var pager_height = $('div#pager').outerHeight(true); |
|
|||
47 | var pager_splitter_height = $('div#pager_splitter').outerHeight(true); |
|
|||
48 | $('div#notebook_app').height(app_height + 2); // content+padding+border height |
|
|||
49 | $('div#left_panel').height(app_height); |
|
|||
50 | $('div#left_panel_splitter').height(app_height); |
|
|||
51 | $('div#notebook_panel').height(app_height); |
|
|||
52 | if (IPython.pager.expanded) { |
|
|||
53 | $('div#notebook').height(app_height-pager_height-pager_splitter_height); |
|
|||
54 | } else { |
|
|||
55 | $('div#notebook').height(app_height-pager_splitter_height); |
|
|||
56 | } |
|
|||
57 | console.log('resize: ', app_height); |
|
|||
58 | }; |
|
|||
59 |
|
||||
60 | $(window).resize(do_resize); |
|
|||
61 |
|
||||
62 | IPython.notebook = new IPython.Notebook('div#notebook'); |
|
|||
63 | IPython.notebook.insert_code_cell_after(); |
|
|||
64 |
|
22 | |||
|
23 | IPython.layout_manager = new IPython.LayoutManager(); | |||
65 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); |
|
24 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); | |
|
25 | IPython.left_panel = new IPython.LeftPanel('div#left_panel', 'div#left_panel_splitter'); | |||
|
26 | IPython.notebook = new IPython.Notebook('div#notebook'); | |||
66 |
|
27 | |||
67 | do_resize(); |
|
28 | IPython.notebook.insert_code_cell_after(); | |
|
29 | IPython.layout_manager.do_resize(); | |||
|
30 | IPython.pager.collapse(); | |||
68 |
|
31 | |||
69 | // $("#menu_tabs").tabs(); |
|
32 | // $("#menu_tabs").tabs(); | |
70 |
|
33 |
@@ -7,17 +7,18 b' var IPython = (function (IPython) {' | |||||
7 |
|
7 | |||
8 | var utils = IPython.utils; |
|
8 | var utils = IPython.utils; | |
9 |
|
9 | |||
10 |
var Pager = function (pager_selector, pager_ |
|
10 | var Pager = function (pager_selector, pager_splitter_selector) { | |
11 | this.pager_element = $(pager_selector); |
|
11 | this.pager_element = $(pager_selector); | |
12 |
this.pager_ |
|
12 | this.pager_splitter_element = $(pager_splitter_selector); | |
13 | this.expanded = true; |
|
13 | this.expanded = true; | |
|
14 | this.percentage_height = 0.30; | |||
14 | this.style(); |
|
15 | this.style(); | |
15 | this.bind_events(); |
|
16 | this.bind_events(); | |
16 | }; |
|
17 | }; | |
17 |
|
18 | |||
18 |
|
19 | |||
19 | Pager.prototype.style = function () { |
|
20 | Pager.prototype.style = function () { | |
20 |
this.pager_ |
|
21 | this.pager_splitter_element.addClass('border-box-sizing ui-widget ui-state-default'); | |
21 | this.pager_element.addClass('border-box-sizing ui-widget'); |
|
22 | this.pager_element.addClass('border-box-sizing ui-widget'); | |
22 | }; |
|
23 | }; | |
23 |
|
24 | |||
@@ -33,18 +34,19 b' var IPython = (function (IPython) {' | |||||
33 | that.pager_element.show('fast'); |
|
34 | that.pager_element.show('fast'); | |
34 | }); |
|
35 | }); | |
35 |
|
36 | |||
36 |
this.pager_ |
|
37 | this.pager_splitter_element.hover( | |
37 | function () { |
|
38 | function () { | |
38 |
that.pager_ |
|
39 | that.pager_splitter_element.addClass('ui-state-hover'); | |
39 | }, |
|
40 | }, | |
40 | function () { |
|
41 | function () { | |
41 |
that.pager_ |
|
42 | that.pager_splitter_element.removeClass('ui-state-hover'); | |
42 | } |
|
43 | } | |
43 | ); |
|
44 | ); | |
44 |
|
45 | |||
45 |
this.pager_ |
|
46 | this.pager_splitter_element.click(function () { | |
46 | that.toggle(); |
|
47 | that.toggle(); | |
47 | }); |
|
48 | }); | |
|
49 | ||||
48 | }; |
|
50 | }; | |
49 |
|
51 | |||
50 |
|
52 |
@@ -54,7 +54,9 b'' | |||||
54 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> |
|
54 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> | |
55 | <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script> |
|
55 | <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script> | |
56 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> |
|
56 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> | |
|
57 | <script src="static/js/layout.js" type="text/javascript" charset="utf-8"></script> | |||
57 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> |
|
58 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> | |
|
59 | <script src="static/js/leftpanel.js" type="text/javascript" charset="utf-8"></script> | |||
58 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> |
|
60 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> | |
59 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> |
|
61 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> | |
60 | <script src="static/codemirror2/lib/codemirror.js"></script> |
|
62 | <script src="static/codemirror2/lib/codemirror.js"></script> |
General Comments 0
You need to be logged in to leave comments.
Login now