##// END OF EJS Templates
pep 8 and js...
Matthias BUSSONNIER -
Show More
@@ -1,123 +1,123
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-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 // Pager
9 // Pager
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 var utils = IPython.utils;
14 var utils = IPython.utils;
15
15
16 var Pager = function (pager_selector, pager_splitter_selector) {
16 var Pager = function (pager_selector, pager_splitter_selector) {
17 this.pager_element = $(pager_selector);
17 this.pager_element = $(pager_selector);
18 var that = this;
18 var that = this;
19 this.percentage_height = 0.40;
19 this.percentage_height = 0.40;
20 this.pager_splitter_element = $(pager_splitter_selector)
20 this.pager_splitter_element = $(pager_splitter_selector)
21 .draggable({
21 .draggable({
22 containment: 'window',
22 containment: 'window',
23 axis:'y',
23 axis:'y',
24 helper: null ,
24 helper: null ,
25 drag: function(event,ui){
25 drag: function(event, ui) {
26 // recalculate the amount of space the pager should take
26 // recalculate the amount of space the pager should take
27 var pheight =($(body).height()-event.clientY-4);
27 var pheight = ($(body).height()-event.clientY-4);
28 var downprct = pheight/IPython.layout_manager.app_height();
28 var downprct = pheight/IPython.layout_manager.app_height();
29 downprct = Math.min(0.9,downprct);
29 downprct = Math.min(0.9, downprct);
30 if(downprct < 0.1) {
30 if (downprct < 0.1) {
31 that.percentage_height = 0.1;
31 that.percentage_height = 0.1;
32 that.collapse({'duration':0});
32 that.collapse({'duration':0});
33 } else if(downprct > 0.2) {
33 } else if (downprct > 0.2) {
34 that.percentage_height = downprct;
34 that.percentage_height = downprct;
35 that.expand({'duration':0});
35 that.expand({'duration':0});
36 }
36 }
37 IPython.layout_manager.do_resize();
37 IPython.layout_manager.do_resize();
38 }
38 }
39 });
39 });
40 this.expanded = false;
40 this.expanded = false;
41 this.style();
41 this.style();
42 this.bind_events();
42 this.bind_events();
43 };
43 };
44
44
45 Pager.prototype.style = function () {
45 Pager.prototype.style = function () {
46 this.pager_splitter_element.addClass('border-box-sizing ui-widget ui-state-default');
46 this.pager_splitter_element.addClass('border-box-sizing ui-widget ui-state-default');
47 this.pager_element.addClass('border-box-sizing ui-widget');
47 this.pager_element.addClass('border-box-sizing ui-widget');
48 this.pager_splitter_element.attr('title', 'Click to Show/Hide pager area, drag to Resize');
48 this.pager_splitter_element.attr('title', 'Click to Show/Hide pager area, drag to Resize');
49 };
49 };
50
50
51
51
52 Pager.prototype.bind_events = function () {
52 Pager.prototype.bind_events = function () {
53 var that = this;
53 var that = this;
54
54
55 this.pager_element.bind('collapse_pager', function (event,extrap) {
55 this.pager_element.bind('collapse_pager', function (event, extrap) {
56 time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
56 time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
57 that.pager_element.hide(time);
57 that.pager_element.hide(time);
58 });
58 });
59
59
60 this.pager_element.bind('expand_pager', function (event,extrap) {
60 this.pager_element.bind('expand_pager', function (event, extrap) {
61 time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
61 time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast';
62 that.pager_element.show(time);
62 that.pager_element.show(time);
63 });
63 });
64
64
65 this.pager_splitter_element.hover(
65 this.pager_splitter_element.hover(
66 function () {
66 function () {
67 that.pager_splitter_element.addClass('ui-state-hover');
67 that.pager_splitter_element.addClass('ui-state-hover');
68 },
68 },
69 function () {
69 function () {
70 that.pager_splitter_element.removeClass('ui-state-hover');
70 that.pager_splitter_element.removeClass('ui-state-hover');
71 }
71 }
72 );
72 );
73
73
74 this.pager_splitter_element.click(function () {
74 this.pager_splitter_element.click(function () {
75 that.toggle();
75 that.toggle();
76 });
76 });
77
77
78 };
78 };
79
79
80
80
81 Pager.prototype.collapse = function (extrap) {
81 Pager.prototype.collapse = function (extrap) {
82 if (this.expanded === true) {
82 if (this.expanded === true) {
83 this.expanded = false;
83 this.expanded = false;
84 this.pager_element.add($('div#notebook')).trigger('collapse_pager',extrap);
84 this.pager_element.add($('div#notebook')).trigger('collapse_pager', extrap);
85 };
85 };
86 };
86 };
87
87
88
88
89 Pager.prototype.expand = function (extrap) {
89 Pager.prototype.expand = function (extrap) {
90 if (this.expanded !== true) {
90 if (this.expanded !== true) {
91 this.expanded = true;
91 this.expanded = true;
92 this.pager_element.add($('div#notebook')).trigger('expand_pager',extrap);
92 this.pager_element.add($('div#notebook')).trigger('expand_pager', extrap);
93 };
93 };
94 };
94 };
95
95
96
96
97 Pager.prototype.toggle = function () {
97 Pager.prototype.toggle = function () {
98 if (this.expanded === true) {
98 if (this.expanded === true) {
99 this.collapse();
99 this.collapse();
100 } else {
100 } else {
101 this.expand();
101 this.expand();
102 };
102 };
103 };
103 };
104
104
105
105
106 Pager.prototype.clear = function (text) {
106 Pager.prototype.clear = function (text) {
107 this.pager_element.empty();
107 this.pager_element.empty();
108 };
108 };
109
109
110
110
111 Pager.prototype.append_text = function (text) {
111 Pager.prototype.append_text = function (text) {
112 var toinsert = $("<div/>").addClass("output_area output_stream");
112 var toinsert = $("<div/>").addClass("output_area output_stream");
113 toinsert.append($('<pre/>').html(utils.fixConsole(text)));
113 toinsert.append($('<pre/>').html(utils.fixConsole(text)));
114 this.pager_element.append(toinsert);
114 this.pager_element.append(toinsert);
115 };
115 };
116
116
117
117
118 IPython.Pager = Pager;
118 IPython.Pager = Pager;
119
119
120 return IPython;
120 return IPython;
121
121
122 }(IPython));
122 }(IPython));
123
123
General Comments 0
You need to be logged in to leave comments. Login now