##// END OF EJS Templates
Refactoring pager into its own class.
Brian E. Granger -
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 18 this.notebook_load_re = /%notebook load/
19 19 this.notebook_save_re = /%notebook save/
20 20 this.notebook_filename_re = /(\w)+.ipynb/
21 this.style();
21 22 this.bind_events();
22 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 32 Notebook.prototype.bind_events = function () {
27 33 var that = this;
28 34 $(document).keydown(function (event) {
@@ -390,18 +396,16 var IPython = (function (IPython) {
390 396
391 397 Notebook.prototype.handle_payload = function (payload) {
392 398 var l = payload.length;
393 var element = $('div#pager');
394 399 if (l > 0) {
395 element.show();
400 IPython.pager.clear();
401 IPython.pager.expand();
396 402 };
397 403 for (var i=0; i<l; i++) {
398 var toinsert = $("<div/>").addClass("output_area output_stream monospace-font");
399 toinsert.append($("<pre/>").addClass("monospace-font").
400 html(utils.fixConsole(payload[i].text)));
401 element.append(toinsert);
404 IPython.pager.append_text(payload[i].text);
402 405 };
403 406 };
404 407
408
405 409 Notebook.prototype.handle_iopub_reply = function (e) {
406 410 reply = $.parseJSON(e.data);
407 411 var content = reply.content;
@@ -9,26 +9,8 $(document).ready(function () {
9 9 $('div#wrapper').addClass('vbox border-box-sizing')
10 10 $('div#notebook_app').addClass('hbox box-flex1 border-box-sizing')
11 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 12 $('div#left_panel_splitter').addClass('border-box-sizing ui-widget ui-widget-header')
16 $('div#pager').addClass('border-box-sizing')
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();
13 $('div#notebook_panel').addClass('vbox box-flex1 border-box-sizing ui-widget ui-widget-content')
32 14
33 15 $('div#left_panel_splitter').click(function () {
34 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 44 IPython.notebook = new IPython.Notebook('div#notebook');
58 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 $("#help_toolbar").buttonset();
51 // $("#help_toolbar").buttonset();
63 52
64 $("#kernel_toolbar").buttonset();
65 $("#interrupt_kernel").click(function () {IPython.notebook.kernel.interrupt();});
66 $("#restart_kernel").click(function () {IPython.notebook.kernel.restart();});
67 $("#kernel_status").addClass("status_idle");
53 // $("#kernel_toolbar").buttonset();
54 // $("#interrupt_kernel").click(function () {IPython.notebook.kernel.interrupt();});
55 // $("#restart_kernel").click(function () {IPython.notebook.kernel.restart();});
56 // $("#kernel_status").addClass("status_idle");
68 57
69 $("#move_cell").buttonset();
70 $("#move_up").button("option", "icons", {primary:"ui-icon-arrowthick-1-n"});
71 $("#move_up").button("option", "text", false);
72 $("#move_up").click(function () {IPython.notebook.move_cell_up();});
73 $("#move_down").button("option", "icons", {primary:"ui-icon-arrowthick-1-s"});
74 $("#move_down").button("option", "text", false);
75 $("#move_down").click(function () {IPython.notebook.move_cell_down();});
58 // $("#move_cell").buttonset();
59 // $("#move_up").button("option", "icons", {primary:"ui-icon-arrowthick-1-n"});
60 // $("#move_up").button("option", "text", false);
61 // $("#move_up").click(function () {IPython.notebook.move_cell_up();});
62 // $("#move_down").button("option", "icons", {primary:"ui-icon-arrowthick-1-s"});
63 // $("#move_down").button("option", "text", false);
64 // $("#move_down").click(function () {IPython.notebook.move_cell_down();});
76 65
77 $("#insert_delete").buttonset();
78 $("#insert_cell_before").click(function () {IPython.notebook.insert_code_cell_before();});
79 $("#insert_cell_after").click(function () {IPython.notebook.insert_code_cell_after();});
80 $("#delete_cell").button("option", "icons", {primary:"ui-icon-closethick"});
81 $("#delete_cell").button("option", "text", false);
82 $("#delete_cell").click(function () {IPython.notebook.delete_cell();});
66 // $("#insert_delete").buttonset();
67 // $("#insert_cell_before").click(function () {IPython.notebook.insert_code_cell_before();});
68 // $("#insert_cell_after").click(function () {IPython.notebook.insert_code_cell_after();});
69 // $("#delete_cell").button("option", "icons", {primary:"ui-icon-closethick"});
70 // $("#delete_cell").button("option", "text", false);
71 // $("#delete_cell").click(function () {IPython.notebook.delete_cell();});
83 72
84 $("#cell_type").buttonset();
85 $("#to_code").click(function () {IPython.notebook.text_to_code();});
86 $("#to_text").click(function () {IPython.notebook.code_to_text();});
73 // $("#cell_type").buttonset();
74 // $("#to_code").click(function () {IPython.notebook.text_to_code();});
75 // $("#to_text").click(function () {IPython.notebook.code_to_text();});
87 76
88 $("#sort").buttonset();
89 $("#sort_cells").click(function () {IPython.notebook.sort_cells();});
77 // $("#sort").buttonset();
78 // $("#sort_cells").click(function () {IPython.notebook.sort_cells();});
90 79
91 $("#toggle").buttonset();
92 $("#collapse").click(function () {IPython.notebook.collapse();});
93 $("#expand").click(function () {IPython.notebook.expand();});
80 // $("#toggle").buttonset();
81 // $("#collapse").click(function () {IPython.notebook.collapse();});
82 // $("#expand").click(function () {IPython.notebook.expand();});
94 83
95 84 });
96 85
@@ -58,6 +58,7
58 58 <script src="static/js/codecell.js" type="text/javascript" charset="utf-8"></script>
59 59 <script src="static/js/textcell.js" type="text/javascript" charset="utf-8"></script>
60 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 62 <script src="static/js/notebook.js" type="text/javascript" charset="utf-8"></script>
62 63 <script src="static/js/notebook_main.js" type="text/javascript" charset="utf-8"></script>
63 64 <script src="static/codemirror2/lib/codemirror.js"></script>
General Comments 0
You need to be logged in to leave comments. Login now