##// END OF EJS Templates
Removed max height from widget modal body
Jonathan Frederic -
Show More
@@ -1,186 +1,187 b''
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2013 The IPython Development Team
2 // Copyright (C) 2013 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 // ContainerWidget
9 // ContainerWidget
10 //============================================================================
10 //============================================================================
11
11
12 /**
12 /**
13 * @module IPython
13 * @module IPython
14 * @namespace IPython
14 * @namespace IPython
15 **/
15 **/
16
16
17 define(["notebook/js/widget"], function(widget_manager) {
17 define(["notebook/js/widget"], function(widget_manager) {
18 var ContainerModel = IPython.WidgetModel.extend({});
18 var ContainerModel = IPython.WidgetModel.extend({});
19 widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel);
19 widget_manager.register_widget_model('ContainerWidgetModel', ContainerModel);
20
20
21 var ContainerView = IPython.WidgetView.extend({
21 var ContainerView = IPython.WidgetView.extend({
22
22
23 render: function(){
23 render: function(){
24 this.$el
24 this.$el
25 .addClass('widget-container');
25 .addClass('widget-container');
26 },
26 },
27
27
28 update: function(){
28 update: function(){
29
29
30 // Apply flexible box model properties by adding and removing
30 // Apply flexible box model properties by adding and removing
31 // corrosponding CSS classes.
31 // corrosponding CSS classes.
32 // Defined in IPython/html/static/base/less/flexbox.less
32 // Defined in IPython/html/static/base/less/flexbox.less
33 this.set_flex_property('vbox', this.model.get('_vbox'));
33 this.set_flex_property('vbox', this.model.get('_vbox'));
34 this.set_flex_property('hbox', this.model.get('_hbox'));
34 this.set_flex_property('hbox', this.model.get('_hbox'));
35 this.set_flex_property('start', this.model.get('_pack_start'));
35 this.set_flex_property('start', this.model.get('_pack_start'));
36 this.set_flex_property('center', this.model.get('_pack_center'));
36 this.set_flex_property('center', this.model.get('_pack_center'));
37 this.set_flex_property('end', this.model.get('_pack_end'));
37 this.set_flex_property('end', this.model.get('_pack_end'));
38 this.set_flex_property('align-start', this.model.get('_align_start'));
38 this.set_flex_property('align-start', this.model.get('_align_start'));
39 this.set_flex_property('align-center', this.model.get('_align_center'));
39 this.set_flex_property('align-center', this.model.get('_align_center'));
40 this.set_flex_property('align-end', this.model.get('_align_end'));
40 this.set_flex_property('align-end', this.model.get('_align_end'));
41 this.set_flex_property('box-flex0', this.model.get('_flex0'));
41 this.set_flex_property('box-flex0', this.model.get('_flex0'));
42 this.set_flex_property('box-flex1', this.model.get('_flex1'));
42 this.set_flex_property('box-flex1', this.model.get('_flex1'));
43 this.set_flex_property('box-flex2', this.model.get('_flex2'));
43 this.set_flex_property('box-flex2', this.model.get('_flex2'));
44
44
45 return IPython.WidgetView.prototype.update.call(this);
45 return IPython.WidgetView.prototype.update.call(this);
46 },
46 },
47
47
48 set_flex_property: function(property_name, enabled) {
48 set_flex_property: function(property_name, enabled) {
49 if (enabled) {
49 if (enabled) {
50 this.$el.addClass(property_name);
50 this.$el.addClass(property_name);
51 } else {
51 } else {
52 this.$el.removeClass(property_name);
52 this.$el.removeClass(property_name);
53 }
53 }
54 },
54 },
55
55
56 display_child: function(view) {
56 display_child: function(view) {
57 this.$el.append(view.$el);
57 this.$el.append(view.$el);
58 },
58 },
59 });
59 });
60
60
61 widget_manager.register_widget_view('ContainerView', ContainerView);
61 widget_manager.register_widget_view('ContainerView', ContainerView);
62
62
63
63
64 var ModalView = IPython.WidgetView.extend({
64 var ModalView = IPython.WidgetView.extend({
65
65
66 render: function(){
66 render: function(){
67 var that = this;
67 var that = this;
68 this.$el
68 this.$el
69 .html('')
69 .html('')
70 .on("remove", function(){
70 .on("remove", function(){
71 that.$window.remove();
71 that.$window.remove();
72 });
72 });
73 this.$window = $('<div />')
73 this.$window = $('<div />')
74 .addClass('modal widget-modal')
74 .addClass('modal widget-modal')
75 .appendTo($('#notebook-container'));
75 .appendTo($('#notebook-container'));
76 this.$title_bar = $('<div />')
76 this.$title_bar = $('<div />')
77 .addClass('popover-title')
77 .addClass('popover-title')
78 .appendTo(this.$window);
78 .appendTo(this.$window);
79 var that = this;
79 var that = this;
80 $('<button />')
80 $('<button />')
81 .addClass('close')
81 .addClass('close')
82 .html('&times;')
82 .html('&times;')
83 .appendTo(this.$title_bar)
83 .appendTo(this.$title_bar)
84 .click(function(){
84 .click(function(){
85 that.hide();
85 that.hide();
86 event.stopPropagation();
86 event.stopPropagation();
87 });
87 });
88 this.$title = $('<div />')
88 this.$title = $('<div />')
89 .addClass('widget-modal-title')
89 .addClass('widget-modal-title')
90 .html('&nbsp;')
90 .html('&nbsp;')
91 .appendTo(this.$title_bar);
91 .appendTo(this.$title_bar);
92 this.$body = $('<div />')
92 this.$body = $('<div />')
93 .addClass('modal-body')
93 .addClass('modal-body')
94 .addClass('widget-modal-body')
94 .addClass('widget-container')
95 .addClass('widget-container')
95 .appendTo(this.$window);
96 .appendTo(this.$window);
96
97
97 this.$show_button = $('<button />')
98 this.$show_button = $('<button />')
98 .html('&nbsp;')
99 .html('&nbsp;')
99 .addClass('btn btn-info widget-modal-show')
100 .addClass('btn btn-info widget-modal-show')
100 .appendTo(this.$el)
101 .appendTo(this.$el)
101 .click(function(){
102 .click(function(){
102 that.show();
103 that.show();
103 });
104 });
104
105
105 this.$window.draggable({handle: '.popover-title', snap: '#notebook, .modal', snapMode: 'both'});
106 this.$window.draggable({handle: '.popover-title', snap: '#notebook, .modal', snapMode: 'both'});
106 this.$window.resizable();
107 this.$window.resizable();
107 this.$window.on('resize', function(){
108 this.$window.on('resize', function(){
108 that.$body.outerHeight(that.$window.innerHeight() - that.$title_bar.outerHeight());
109 that.$body.outerHeight(that.$window.innerHeight() - that.$title_bar.outerHeight());
109 })
110 })
110
111
111 this._shown_once = false;
112 this._shown_once = false;
112 },
113 },
113
114
114 hide: function() {
115 hide: function() {
115 this.$window.hide();
116 this.$window.hide();
116 this.$show_button.removeClass('btn-info');
117 this.$show_button.removeClass('btn-info');
117 },
118 },
118
119
119 show: function() {
120 show: function() {
120 this.$window.show();
121 this.$window.show();
121 this.$show_button.addClass('btn-info');
122 this.$show_button.addClass('btn-info');
122 var position = this.$show_button.offset();
123 var position = this.$show_button.offset();
123 this.$window.css('left', position.left + this.$show_button.outerWidth());
124 this.$window.css('left', position.left + this.$show_button.outerWidth());
124 this.$window.css('top', position.top);
125 this.$window.css('top', position.top);
125 },
126 },
126
127
127 update: function(){
128 update: function(){
128
129
129 // Apply flexible box model properties by adding and removing
130 // Apply flexible box model properties by adding and removing
130 // corrosponding CSS classes.
131 // corrosponding CSS classes.
131 // Defined in IPython/html/static/base/less/flexbox.less
132 // Defined in IPython/html/static/base/less/flexbox.less
132 this.set_flex_property('vbox', this.model.get('_vbox'));
133 this.set_flex_property('vbox', this.model.get('_vbox'));
133 this.set_flex_property('hbox', this.model.get('_hbox'));
134 this.set_flex_property('hbox', this.model.get('_hbox'));
134 this.set_flex_property('start', this.model.get('_pack_start'));
135 this.set_flex_property('start', this.model.get('_pack_start'));
135 this.set_flex_property('center', this.model.get('_pack_center'));
136 this.set_flex_property('center', this.model.get('_pack_center'));
136 this.set_flex_property('end', this.model.get('_pack_end'));
137 this.set_flex_property('end', this.model.get('_pack_end'));
137 this.set_flex_property('align-start', this.model.get('_align_start'));
138 this.set_flex_property('align-start', this.model.get('_align_start'));
138 this.set_flex_property('align-center', this.model.get('_align_center'));
139 this.set_flex_property('align-center', this.model.get('_align_center'));
139 this.set_flex_property('align-end', this.model.get('_align_end'));
140 this.set_flex_property('align-end', this.model.get('_align_end'));
140 this.set_flex_property('box-flex0', this.model.get('_flex0'));
141 this.set_flex_property('box-flex0', this.model.get('_flex0'));
141 this.set_flex_property('box-flex1', this.model.get('_flex1'));
142 this.set_flex_property('box-flex1', this.model.get('_flex1'));
142 this.set_flex_property('box-flex2', this.model.get('_flex2'));
143 this.set_flex_property('box-flex2', this.model.get('_flex2'));
143
144
144 var description = this.model.get('description');
145 var description = this.model.get('description');
145 description = description.replace(/ /g, '&nbsp;', 'm');
146 description = description.replace(/ /g, '&nbsp;', 'm');
146 description = description.replace(/\n/g, '<br>\n', 'm');
147 description = description.replace(/\n/g, '<br>\n', 'm');
147 if (description.length == 0) {
148 if (description.length == 0) {
148 this.$title.html('&nbsp;'); // Preserve title height
149 this.$title.html('&nbsp;'); // Preserve title height
149 } else {
150 } else {
150 this.$title.html(description);
151 this.$title.html(description);
151 }
152 }
152
153
153 var button_text = this.model.get('button_text');
154 var button_text = this.model.get('button_text');
154 button_text = button_text.replace(/ /g, '&nbsp;', 'm');
155 button_text = button_text.replace(/ /g, '&nbsp;', 'm');
155 button_text = button_text.replace(/\n/g, '<br>\n', 'm');
156 button_text = button_text.replace(/\n/g, '<br>\n', 'm');
156 if (button_text.length == 0) {
157 if (button_text.length == 0) {
157 this.$show_button.html('&nbsp;'); // Preserve button height
158 this.$show_button.html('&nbsp;'); // Preserve button height
158 } else {
159 } else {
159 this.$show_button.html(button_text);
160 this.$show_button.html(button_text);
160 }
161 }
161
162
162 if (!this._shown_once) {
163 if (!this._shown_once) {
163 this._shown_once = true;
164 this._shown_once = true;
164 this.show();
165 this.show();
165 }
166 }
166
167
167 return IPython.WidgetView.prototype.update.call(this);
168 return IPython.WidgetView.prototype.update.call(this);
168 },
169 },
169
170
170 set_flex_property: function(property_name, enabled) {
171 set_flex_property: function(property_name, enabled) {
171 if (enabled) {
172 if (enabled) {
172 this.$body.addClass(property_name);
173 this.$body.addClass(property_name);
173 } else {
174 } else {
174 this.$body.removeClass(property_name);
175 this.$body.removeClass(property_name);
175 }
176 }
176 },
177 },
177
178
178 display_child: function(view) {
179 display_child: function(view) {
179 this.$body.append(view.$el);
180 this.$body.append(view.$el);
180 },
181 },
181
182
182
183
183 });
184 });
184
185
185 widget_manager.register_widget_view('ModalView', ModalView);
186 widget_manager.register_widget_view('ModalView', ModalView);
186 });
187 });
@@ -1,228 +1,233 b''
1
1
2 /*
2 /*
3 LESS file that styles IPython notebook widgets and the area they sit in.
3 LESS file that styles IPython notebook widgets and the area they sit in.
4
4
5 The widget area typically looks something like this:
5 The widget area typically looks something like this:
6 +------------------------------------------+
6 +------------------------------------------+
7 | widget-area |
7 | widget-area |
8 | +--------+---------------------------+ |
8 | +--------+---------------------------+ |
9 | | prompt | widget-subarea | |
9 | | prompt | widget-subarea | |
10 | | | +--------+ +--------+ | |
10 | | | +--------+ +--------+ | |
11 | | | | widget | | widget | | |
11 | | | | widget | | widget | | |
12 | | | +--------+ +--------+ | |
12 | | | +--------+ +--------+ | |
13 | +--------+---------------------------+ |
13 | +--------+---------------------------+ |
14 +------------------------------------------+
14 +------------------------------------------+
15 */
15 */
16
16
17 .widget-area {
17 .widget-area {
18 page-break-inside: avoid;
18 page-break-inside: avoid;
19 .hbox();
19 .hbox();
20
20
21 .widget-subarea {
21 .widget-subarea {
22 padding: 0.44em 0.4em 0.4em 1px;
22 padding: 0.44em 0.4em 0.4em 1px;
23 margin-left: 6px;
23 margin-left: 6px;
24 .border-box-sizing();
24 .border-box-sizing();
25 .vbox();
25 .vbox();
26 .box-flex2();
26 .box-flex2();
27
27
28 /* Horizontal Label */
28 /* Horizontal Label */
29 .widget-hlabel {
29 .widget-hlabel {
30 min-width: 10ex;
30 min-width: 10ex;
31 padding-right: 8px;
31 padding-right: 8px;
32 padding-top: 3px;
32 padding-top: 3px;
33 text-align: right;
33 text-align: right;
34 vertical-align: text-top;
34 vertical-align: text-top;
35 }
35 }
36
36
37 /* Vertical Label */
37 /* Vertical Label */
38 .widget-vlabel {
38 .widget-vlabel {
39 padding-bottom: 5px;
39 padding-bottom: 5px;
40 text-align: center;
40 text-align: center;
41 vertical-align: text-bottom;
41 vertical-align: text-bottom;
42 }
42 }
43
43
44
44
45 /* Slider Track */
45 /* Slider Track */
46 .slide-track {
46 .slide-track {
47 border: 1px solid #CCCCCC;
47 border: 1px solid #CCCCCC;
48 background: #FFFFFF;
48 background: #FFFFFF;
49 .corner-all(); /* Round the corners of the slide track */
49 .corner-all(); /* Round the corners of the slide track */
50 }
50 }
51
51
52 /* Horizontal jQuery Slider
52 /* Horizontal jQuery Slider
53
53
54 Both the horizontal and vertical versions of the slider are characterized
54 Both the horizontal and vertical versions of the slider are characterized
55 by a styled div that contains an invisible jQuery slide div which
55 by a styled div that contains an invisible jQuery slide div which
56 contains a visible slider handle div. This is requred so we can control
56 contains a visible slider handle div. This is requred so we can control
57 how the slider is drawn and 'fix' the issue where the slide handle
57 how the slider is drawn and 'fix' the issue where the slide handle
58 doesn't stop at the end of the slide.
58 doesn't stop at the end of the slide.
59
59
60 Both horizontal and vertical sliders have this div nesting:
60 Both horizontal and vertical sliders have this div nesting:
61 +------------------------------------------+
61 +------------------------------------------+
62 | widget-(h/v)slider |
62 | widget-(h/v)slider |
63 | +--------+---------------------------+ |
63 | +--------+---------------------------+ |
64 | | ui-slider | |
64 | | ui-slider | |
65 | | +------------------+ | |
65 | | +------------------+ | |
66 | | | ui-slider-handle | | |
66 | | | ui-slider-handle | | |
67 | | +------------------+ | |
67 | | +------------------+ | |
68 | +--------+---------------------------+ |
68 | +--------+---------------------------+ |
69 +------------------------------------------+
69 +------------------------------------------+
70 */
70 */
71 .widget-hslider {
71 .widget-hslider {
72
72
73 /* Fix the padding of the slide track so the ui-slider is sized
73 /* Fix the padding of the slide track so the ui-slider is sized
74 correctly. */
74 correctly. */
75 padding-left: 8px;
75 padding-left: 8px;
76 padding-right: 5px;
76 padding-right: 5px;
77 overflow: visible;
77 overflow: visible;
78
78
79 /* Default size of the slider */
79 /* Default size of the slider */
80 width: 348px;
80 width: 348px;
81 height: 5px;
81 height: 5px;
82 max-height: 5px;
82 max-height: 5px;
83 margin-top: 11px;
83 margin-top: 11px;
84
84
85 /* Style the slider track */
85 /* Style the slider track */
86 .slide-track();
86 .slide-track();
87
87
88 /* Make the div a flex box (makes FF behave correctly). */
88 /* Make the div a flex box (makes FF behave correctly). */
89 .hbox();
89 .hbox();
90
90
91 /* Inner, invisible slide div */
91 /* Inner, invisible slide div */
92 .ui-slider {
92 .ui-slider {
93 border: 0px !important;
93 border: 0px !important;
94 background: none !important;
94 background: none !important;
95
95
96 .hbox();
96 .hbox();
97 .box-flex1();
97 .box-flex1();
98
98
99 .ui-slider-handle {
99 .ui-slider-handle {
100 width: 14px !important;
100 width: 14px !important;
101 height: 28px !important;
101 height: 28px !important;
102
102
103 margin-top: -8px !important;
103 margin-top: -8px !important;
104 }
104 }
105 }
105 }
106 }
106 }
107
107
108 /* Vertical jQuery Slider */
108 /* Vertical jQuery Slider */
109 .widget-vslider {
109 .widget-vslider {
110
110
111 /* Fix the padding of the slide track so the ui-slider is sized
111 /* Fix the padding of the slide track so the ui-slider is sized
112 correctly. */
112 correctly. */
113 padding-bottom: 8px;
113 padding-bottom: 8px;
114 overflow: visible;
114 overflow: visible;
115
115
116 /* Default size of the slider */
116 /* Default size of the slider */
117 width: 5px;
117 width: 5px;
118 max-width: 5px;
118 max-width: 5px;
119 height: 250px;
119 height: 250px;
120 margin-left: 12px;
120 margin-left: 12px;
121
121
122 /* Style the slider track */
122 /* Style the slider track */
123 .slide-track();
123 .slide-track();
124
124
125 /* Make the div a flex box (makes FF behave correctly). */
125 /* Make the div a flex box (makes FF behave correctly). */
126 .vbox();
126 .vbox();
127
127
128 /* Inner, invisible slide div */
128 /* Inner, invisible slide div */
129 .ui-slider {
129 .ui-slider {
130 border: 0px !important;
130 border: 0px !important;
131 background: none !important;
131 background: none !important;
132 margin-left: -4px;
132 margin-left: -4px;
133 margin-top: 5px;
133 margin-top: 5px;
134
134
135 .vbox();
135 .vbox();
136 .box-flex1();
136 .box-flex1();
137
137
138 .ui-slider-handle {
138 .ui-slider-handle {
139 width: 28px !important;
139 width: 28px !important;
140 height: 14px !important;
140 height: 14px !important;
141 margin-left: -9px;
141 margin-left: -9px;
142 }
142 }
143 }
143 }
144 }
144 }
145
145
146 /* String Textbox - used for TextBoxView and TextAreaView */
146 /* String Textbox - used for TextBoxView and TextAreaView */
147 .widget-text {
147 .widget-text {
148 width: 350px;
148 width: 350px;
149 margin-bottom: 0px;
149 margin-bottom: 0px;
150 }
150 }
151
151
152 /* Listbox */
152 /* Listbox */
153 .widget-listbox {
153 .widget-listbox {
154 width: 364px;
154 width: 364px;
155 margin-bottom: 0px;
155 margin-bottom: 0px;
156 }
156 }
157
157
158 /* Single Line Textbox - used for IntTextView and FloatTextView */
158 /* Single Line Textbox - used for IntTextView and FloatTextView */
159 .widget-numeric-text {
159 .widget-numeric-text {
160 width: 150px;
160 width: 150px;
161 }
161 }
162
162
163 /* Progress Bar */
163 /* Progress Bar */
164 .widget-progress {
164 .widget-progress {
165 width: 363px;
165 width: 363px;
166
166
167 /* Disable progress bar animation */
167 /* Disable progress bar animation */
168 .bar {
168 .bar {
169 -webkit-transition: none;
169 -webkit-transition: none;
170 -moz-transition: none;
170 -moz-transition: none;
171 -ms-transition: none;
171 -ms-transition: none;
172 -o-transition: none;
172 -o-transition: none;
173 transition: none;
173 transition: none;
174 }
174 }
175 }
175 }
176
176
177 /* ComboBox Main Button */
177 /* ComboBox Main Button */
178 .widget-combo-btn {
178 .widget-combo-btn {
179 min-width: 138px; /* + 26px drop arrow btn = 164px */
179 min-width: 138px; /* + 26px drop arrow btn = 164px */
180 }
180 }
181
181
182 /* The following section sets the style for the invisible div that
182 /* The following section sets the style for the invisible div that
183 hold widgets and their accompanying labels.
183 hold widgets and their accompanying labels.
184
184
185 Looks like this:
185 Looks like this:
186 +-----------------------------+
186 +-----------------------------+
187 | widget-box (or similar) |
187 | widget-box (or similar) |
188 | +-------+---------------+ |
188 | +-------+---------------+ |
189 | | Label | Actual Widget | |
189 | | Label | Actual Widget | |
190 | +-------+---------------+ |
190 | +-------+---------------+ |
191 +-----------------------------+
191 +-----------------------------+
192 */
192 */
193 .widget-box {
193 .widget-box {
194 .start();
194 .start();
195 .widget-container();
195 .widget-container();
196 margin: 5px;
196 margin: 5px;
197 }
197 }
198 .widget-hbox { /* Horizontal widgets */
198 .widget-hbox { /* Horizontal widgets */
199 .widget-box();
199 .widget-box();
200 .hbox();
200 .hbox();
201 }
201 }
202 .widget-hbox-single { /* Single line horizontal widgets */
202 .widget-hbox-single { /* Single line horizontal widgets */
203 .widget-hbox();
203 .widget-hbox();
204 height: 30px;
204 height: 30px;
205 }
205 }
206 .widget-vbox-single { /* For vertical slides */
206 .widget-vbox-single { /* For vertical slides */
207 .widget-box();
207 .widget-box();
208 .vbox();
208 .vbox();
209 width: 30px;
209 width: 30px;
210 }
210 }
211 }
211 }
212 }
212 }
213
213
214 /* THE CLASSES BELOW CAN APPEAR ANYWHERE IN THE DOM */
214 /* THE CLASSES BELOW CAN APPEAR ANYWHERE IN THE DOM */
215
215
216 /* ContainerWidget - ModalView */
216 /* ContainerWidget - ModalView */
217 .widget-modal {
217 .widget-modal {
218 overflow: hidden;
218 overflow: hidden;
219 position: absolute !important;
219 position: absolute !important;
220 top: 0px;
220 top: 0px;
221 left: 0px;
221 left: 0px;
222 margin-left: 0px !important;
222 margin-left: 0px !important;
223 }
223 }
224
224
225 /* ContainerWidget - ModalView Body */
226 .widget-modal-body {
227 max-height: none !important;
228 }
229
225 /* ContainerWidget */
230 /* ContainerWidget */
226 .widget-container {
231 .widget-container {
227 .border-box-sizing();
232 .border-box-sizing();
228 } No newline at end of file
233 }
General Comments 0
You need to be logged in to leave comments. Login now