Show More
@@ -0,0 +1,70 | |||||
|
1 | ||||
|
2 | //============================================================================ | |||
|
3 | // Pager | |||
|
4 | //============================================================================ | |||
|
5 | ||||
|
6 | var IPython = (function (IPython) { | |||
|
7 | ||||
|
8 | var utils = IPython.utils; | |||
|
9 | ||||
|
10 | var Pager = function (pager_selector, pager_toggle_selector) { | |||
|
11 | this.pager_element = $(pager_selector); | |||
|
12 | this.pager_toggle_element = $(pager_toggle_selector); | |||
|
13 | this.style(); | |||
|
14 | this.bind_events(); | |||
|
15 | this.collapse(); | |||
|
16 | }; | |||
|
17 | ||||
|
18 | ||||
|
19 | Pager.prototype.style = function () { | |||
|
20 | this.pager_toggle_element.addClass('border-box-sizing ui-widget ui-widget-header') | |||
|
21 | this.pager_element.addClass('border-box-sizing') | |||
|
22 | }; | |||
|
23 | ||||
|
24 | ||||
|
25 | Pager.prototype.bind_events = function () { | |||
|
26 | var that = this; | |||
|
27 | this.pager_toggle_element.click(function () { | |||
|
28 | that.pager_element.toggle('fast'); | |||
|
29 | }); | |||
|
30 | ||||
|
31 | this.pager_toggle_element.hover( | |||
|
32 | function () { | |||
|
33 | that.pager_toggle_element.addClass('ui-state-hover'); | |||
|
34 | }, | |||
|
35 | function () { | |||
|
36 | that.pager_toggle_element.removeClass('ui-state-hover'); | |||
|
37 | } | |||
|
38 | ); | |||
|
39 | }; | |||
|
40 | ||||
|
41 | ||||
|
42 | Pager.prototype.collapse = function () { | |||
|
43 | this.pager_element.hide('fast'); | |||
|
44 | }; | |||
|
45 | ||||
|
46 | ||||
|
47 | Pager.prototype.expand = function () { | |||
|
48 | this.pager_element.show('fast'); | |||
|
49 | }; | |||
|
50 | ||||
|
51 | ||||
|
52 | Pager.prototype.clear = function (text) { | |||
|
53 | this.pager_element.empty(); | |||
|
54 | }; | |||
|
55 | ||||
|
56 | ||||
|
57 | Pager.prototype.append_text = function (text) { | |||
|
58 | var toinsert = $("<div/>").addClass("output_area output_stream monospace-font"); | |||
|
59 | toinsert.append($("<pre/>").addClass("monospace-font"). | |||
|
60 | html(utils.fixConsole(text))); | |||
|
61 | this.pager_element.append(toinsert); | |||
|
62 | }; | |||
|
63 | ||||
|
64 | ||||
|
65 | IPython.Pager = Pager; | |||
|
66 | ||||
|
67 | return IPython; | |||
|
68 | ||||
|
69 | }(IPython)); | |||
|
70 |
@@ -18,11 +18,17 var IPython = (function (IPython) { | |||||
18 | this.notebook_load_re = /%notebook load/ |
|
18 | this.notebook_load_re = /%notebook load/ | |
19 | this.notebook_save_re = /%notebook save/ |
|
19 | this.notebook_save_re = /%notebook save/ | |
20 | this.notebook_filename_re = /(\w)+.ipynb/ |
|
20 | this.notebook_filename_re = /(\w)+.ipynb/ | |
|
21 | this.style(); | |||
21 | this.bind_events(); |
|
22 | this.bind_events(); | |
22 | this.start_kernel(); |
|
23 | this.start_kernel(); | |
23 | }; |
|
24 | }; | |
24 |
|
25 | |||
25 |
|
26 | |||
|
27 | Notebook.prototype.style = function () { | |||
|
28 | this.element.addClass('vbox box-flex1 border-box-sizing'); | |||
|
29 | }; | |||
|
30 | ||||
|
31 | ||||
26 | Notebook.prototype.bind_events = function () { |
|
32 | Notebook.prototype.bind_events = function () { | |
27 | var that = this; |
|
33 | var that = this; | |
28 | $(document).keydown(function (event) { |
|
34 | $(document).keydown(function (event) { | |
@@ -390,18 +396,16 var IPython = (function (IPython) { | |||||
390 |
|
396 | |||
391 | Notebook.prototype.handle_payload = function (payload) { |
|
397 | Notebook.prototype.handle_payload = function (payload) { | |
392 | var l = payload.length; |
|
398 | var l = payload.length; | |
393 | var element = $('div#pager'); |
|
|||
394 | if (l > 0) { |
|
399 | if (l > 0) { | |
395 | element.show(); |
|
400 | IPython.pager.clear(); | |
|
401 | IPython.pager.expand(); | |||
396 | }; |
|
402 | }; | |
397 | for (var i=0; i<l; i++) { |
|
403 | for (var i=0; i<l; i++) { | |
398 | var toinsert = $("<div/>").addClass("output_area output_stream monospace-font"); |
|
404 | IPython.pager.append_text(payload[i].text); | |
399 | toinsert.append($("<pre/>").addClass("monospace-font"). |
|
|||
400 | html(utils.fixConsole(payload[i].text))); |
|
|||
401 | element.append(toinsert); |
|
|||
402 | }; |
|
405 | }; | |
403 | }; |
|
406 | }; | |
404 |
|
407 | |||
|
408 | ||||
405 | Notebook.prototype.handle_iopub_reply = function (e) { |
|
409 | Notebook.prototype.handle_iopub_reply = function (e) { | |
406 | reply = $.parseJSON(e.data); |
|
410 | reply = $.parseJSON(e.data); | |
407 | var content = reply.content; |
|
411 | var content = reply.content; |
@@ -9,26 +9,8 $(document).ready(function () { | |||||
9 | $('div#wrapper').addClass('vbox border-box-sizing') |
|
9 | $('div#wrapper').addClass('vbox border-box-sizing') | |
10 | $('div#notebook_app').addClass('hbox box-flex1 border-box-sizing') |
|
10 | $('div#notebook_app').addClass('hbox box-flex1 border-box-sizing') | |
11 | $('div#left_panel').addClass('vbox border-box-sizing ui-widget ui-widget-content') |
|
11 | $('div#left_panel').addClass('vbox border-box-sizing ui-widget ui-widget-content') | |
12 | $('div#pager_splitter').addClass('border-box-sizing ui-widget ui-widget-header') |
|
|||
13 | $('div#notebook_panel').addClass('vbox box-flex1 border-box-sizing ui-widget ui-widget-content') |
|
|||
14 | $('div#notebook').addClass('vbox box-flex1 border-box-sizing') |
|
|||
15 | $('div#left_panel_splitter').addClass('border-box-sizing ui-widget ui-widget-header') |
|
12 | $('div#left_panel_splitter').addClass('border-box-sizing ui-widget ui-widget-header') | |
16 |
$('div# |
|
13 | $('div#notebook_panel').addClass('vbox box-flex1 border-box-sizing ui-widget ui-widget-content') | |
17 |
|
||||
18 | $('div#pager_splitter').click(function () { |
|
|||
19 | $('div#pager').toggle('fast'); |
|
|||
20 | }); |
|
|||
21 |
|
||||
22 | $('div#pager_splitter').hover( |
|
|||
23 | function () { |
|
|||
24 | $('div#pager_splitter').addClass('ui-state-hover'); |
|
|||
25 | }, |
|
|||
26 | function () { |
|
|||
27 | $('div#pager_splitter').removeClass('ui-state-hover'); |
|
|||
28 | } |
|
|||
29 | ); |
|
|||
30 |
|
||||
31 | $('div#pager').hide(); |
|
|||
32 |
|
14 | |||
33 | $('div#left_panel_splitter').click(function () { |
|
15 | $('div#left_panel_splitter').click(function () { | |
34 | $('div#left_panel').toggle('fast'); |
|
16 | $('div#left_panel').toggle('fast'); | |
@@ -54,43 +36,50 $(document).ready(function () { | |||||
54 | } |
|
36 | } | |
55 | }); |
|
37 | }); | |
56 |
|
38 | |||
|
39 | // $('div#notebook').scroll(function (e) { | |||
|
40 | // console.log(e); | |||
|
41 | // e.preventDefault(); | |||
|
42 | // }); | |||
|
43 | ||||
57 | IPython.notebook = new IPython.Notebook('div#notebook'); |
|
44 | IPython.notebook = new IPython.Notebook('div#notebook'); | |
58 | IPython.notebook.insert_code_cell_after(); |
|
45 | IPython.notebook.insert_code_cell_after(); | |
59 |
|
46 | |||
60 | $("#menu_tabs").tabs(); |
|
47 | IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter'); | |
|
48 | ||||
|
49 | // $("#menu_tabs").tabs(); | |||
61 |
|
50 | |||
62 |
|
|
51 | // $("#help_toolbar").buttonset(); | |
63 |
|
52 | |||
64 |
|
|
53 | // $("#kernel_toolbar").buttonset(); | |
65 |
|
|
54 | // $("#interrupt_kernel").click(function () {IPython.notebook.kernel.interrupt();}); | |
66 |
|
|
55 | // $("#restart_kernel").click(function () {IPython.notebook.kernel.restart();}); | |
67 |
|
|
56 | // $("#kernel_status").addClass("status_idle"); | |
68 |
|
57 | |||
69 |
|
|
58 | // $("#move_cell").buttonset(); | |
70 |
|
|
59 | // $("#move_up").button("option", "icons", {primary:"ui-icon-arrowthick-1-n"}); | |
71 |
|
|
60 | // $("#move_up").button("option", "text", false); | |
72 |
|
|
61 | // $("#move_up").click(function () {IPython.notebook.move_cell_up();}); | |
73 |
|
|
62 | // $("#move_down").button("option", "icons", {primary:"ui-icon-arrowthick-1-s"}); | |
74 |
|
|
63 | // $("#move_down").button("option", "text", false); | |
75 |
|
|
64 | // $("#move_down").click(function () {IPython.notebook.move_cell_down();}); | |
76 |
|
65 | |||
77 |
|
|
66 | // $("#insert_delete").buttonset(); | |
78 |
|
|
67 | // $("#insert_cell_before").click(function () {IPython.notebook.insert_code_cell_before();}); | |
79 |
|
|
68 | // $("#insert_cell_after").click(function () {IPython.notebook.insert_code_cell_after();}); | |
80 |
|
|
69 | // $("#delete_cell").button("option", "icons", {primary:"ui-icon-closethick"}); | |
81 |
|
|
70 | // $("#delete_cell").button("option", "text", false); | |
82 |
|
|
71 | // $("#delete_cell").click(function () {IPython.notebook.delete_cell();}); | |
83 |
|
72 | |||
84 |
|
|
73 | // $("#cell_type").buttonset(); | |
85 |
|
|
74 | // $("#to_code").click(function () {IPython.notebook.text_to_code();}); | |
86 |
|
|
75 | // $("#to_text").click(function () {IPython.notebook.code_to_text();}); | |
87 |
|
76 | |||
88 |
|
|
77 | // $("#sort").buttonset(); | |
89 |
|
|
78 | // $("#sort_cells").click(function () {IPython.notebook.sort_cells();}); | |
90 |
|
79 | |||
91 |
|
|
80 | // $("#toggle").buttonset(); | |
92 |
|
|
81 | // $("#collapse").click(function () {IPython.notebook.collapse();}); | |
93 |
|
|
82 | // $("#expand").click(function () {IPython.notebook.expand();}); | |
94 |
|
83 | |||
95 | }); |
|
84 | }); | |
96 |
|
85 |
@@ -58,6 +58,7 | |||||
58 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> |
|
58 | <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script> | |
59 | <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script> |
|
59 | <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script> | |
60 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> |
|
60 | <script src="static/js/kernel.js" type="text/javascript" charset="utf-8"></script> | |
|
61 | <script src="static/js/pager.js" type="text/javascript" charset="utf-8"></script> | |||
61 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> |
|
62 | <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script> | |
62 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> |
|
63 | <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script> | |
63 | <script src="static/codemirror2/lib/codemirror.js"></script> |
|
64 | <script src="static/codemirror2/lib/codemirror.js"></script> |
General Comments 0
You need to be logged in to leave comments.
Login now