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