Show More
@@ -169,7 +169,7 b' define(["static/components/underscore/underscore-min.js",' | |||||
169 |
|
169 | |||
170 | // Add the view's element to cell's widget div. |
|
170 | // Add the view's element to cell's widget div. | |
171 | widget_area |
|
171 | widget_area | |
172 |
|
|
172 | .append(widget_view.$el) | |
173 | .parent().show(); // Show the widget_area (parent of widget_subarea) |
|
173 | .parent().show(); // Show the widget_area (parent of widget_subarea) | |
174 |
|
174 | |||
175 | // Update the view based on the model contents. |
|
175 | // Update the view based on the model contents. | |
@@ -204,6 +204,7 b' define(["static/components/underscore/underscore-min.js",' | |||||
204 |
|
204 | |||
205 | // Handle when a widget is updated via the python side. |
|
205 | // Handle when a widget is updated via the python side. | |
206 | WidgetManager.prototype.handle_update = function (comm, state) { |
|
206 | WidgetManager.prototype.handle_update = function (comm, state) { | |
|
207 | this.updating = true; | |||
207 | for (var key in state) { |
|
208 | for (var key in state) { | |
208 | if (state.hasOwnProperty(key)) { |
|
209 | if (state.hasOwnProperty(key)) { | |
209 | if (key=="_css"){ |
|
210 | if (key=="_css"){ | |
@@ -214,6 +215,7 b' define(["static/components/underscore/underscore-min.js",' | |||||
214 | } |
|
215 | } | |
215 | } |
|
216 | } | |
216 | comm.model.save(); |
|
217 | comm.model.save(); | |
|
218 | this.updating = false; | |||
217 | } |
|
219 | } | |
218 |
|
220 | |||
219 | // Handle when a widget is closed. |
|
221 | // Handle when a widget is closed. | |
@@ -233,7 +235,10 b' define(["static/components/underscore/underscore-min.js",' | |||||
233 |
|
235 | |||
234 | // Send widget state to python backend. |
|
236 | // Send widget state to python backend. | |
235 | WidgetManager.prototype.send_sync = function (method, model) { |
|
237 | WidgetManager.prototype.send_sync = function (method, model) { | |
|
238 | var model_json = model.toJSON(); | |||
236 |
|
239 | |||
|
240 | // Only send updated state if the state hasn't been changed during an update. | |||
|
241 | if (!this.updating) { | |||
237 | // Create a callback for the output if the widget has an output area associate with it. |
|
242 | // Create a callback for the output if the widget has an output area associate with it. | |
238 | var callbacks = {}; |
|
243 | var callbacks = {}; | |
239 | var comm = model.comm; |
|
244 | var comm = model.comm; | |
@@ -245,9 +250,10 b' define(["static/components/underscore/underscore-min.js",' | |||||
245 | clear_output : $.proxy(outputarea.handle_clear_output, outputarea)} |
|
250 | clear_output : $.proxy(outputarea.handle_clear_output, outputarea)} | |
246 | }; |
|
251 | }; | |
247 | }; |
|
252 | }; | |
248 | var model_json = model.toJSON(); |
|
|||
249 | var data = {sync_method: method, sync_data: model_json}; |
|
253 | var data = {sync_method: method, sync_data: model_json}; | |
250 | comm.send(data, callbacks); |
|
254 | comm.send(data, callbacks); | |
|
255 | } | |||
|
256 | ||||
251 | return model_json; |
|
257 | return model_json; | |
252 | } |
|
258 | } | |
253 |
|
259 |
@@ -10,6 +10,7 b' require(["notebook/js/widget"], function(){' | |||||
10 | render : function(){ |
|
10 | render : function(){ | |
11 | this.$el |
|
11 | this.$el | |
12 | .html('') |
|
12 | .html('') | |
|
13 | .addClass('widget_item') | |||
13 | .addClass(this.model.comm.comm_id); |
|
14 | .addClass(this.model.comm.comm_id); | |
14 |
|
15 | |||
15 | var $label = $('<label />') |
|
16 | var $label = $('<label />') | |
@@ -19,6 +20,7 b' require(["notebook/js/widget"], function(){' | |||||
19 | .attr('type', 'checkbox') |
|
20 | .attr('type', 'checkbox') | |
20 | .appendTo($label); |
|
21 | .appendTo($label); | |
21 | this.$checkbox_label = $('<div />') |
|
22 | this.$checkbox_label = $('<div />') | |
|
23 | .addClass('widget_item') | |||
22 | .appendTo($label); |
|
24 | .appendTo($label); | |
23 |
|
25 | |||
24 | this.update(); // Set defaults. |
|
26 | this.update(); // Set defaults. |
@@ -5,14 +5,23 b' require(["notebook/js/widget"], function(){' | |||||
5 | var ContainerView = IPython.WidgetView.extend({ |
|
5 | var ContainerView = IPython.WidgetView.extend({ | |
6 |
|
6 | |||
7 | render : function(){ |
|
7 | render : function(){ | |
8 |
this.$el |
|
8 | this.$el = $('<div />') | |
9 | this.$container = $('<div />') |
|
|||
10 | .addClass('container') |
|
|||
11 | .addClass(this.model.comm.comm_id); |
|
9 | .addClass(this.model.comm.comm_id); | |
12 | this.$el.append(this.$container); |
|
|||
13 | }, |
|
10 | }, | |
14 |
|
11 | |||
15 |
update : function(){ |
|
12 | update : function(){ | |
|
13 | if (this.model.get('vbox')) { | |||
|
14 | this.$el.addClass('vbox'); | |||
|
15 | } else { | |||
|
16 | this.$el.removeClass('vbox'); | |||
|
17 | } | |||
|
18 | ||||
|
19 | if (this.model.get('hbox')) { | |||
|
20 | this.$el.addClass('hbox'); | |||
|
21 | } else { | |||
|
22 | this.$el.removeClass('hbox'); | |||
|
23 | } | |||
|
24 | }, | |||
16 | }); |
|
25 | }); | |
17 |
|
26 | |||
18 | IPython.notebook.widget_manager.register_widget_view('ContainerView', ContainerView); |
|
27 | IPython.notebook.widget_manager.register_widget_view('ContainerView', ContainerView); |
@@ -54,6 +54,7 b' require(["notebook/js/widget"], function(){' | |||||
54 | render : function(){ |
|
54 | render : function(){ | |
55 | this.$el |
|
55 | this.$el | |
56 | .html('') |
|
56 | .html('') | |
|
57 | .addClass('widget_item') | |||
57 | .addClass(this.model.comm.comm_id); |
|
58 | .addClass(this.model.comm.comm_id); | |
58 | this.$textbox = $('<input type="text" />') |
|
59 | this.$textbox = $('<input type="text" />') | |
59 | .addClass('input') |
|
60 | .addClass('input') |
@@ -6,7 +6,8 b' require(["notebook/js/widget"], function(){' | |||||
6 |
|
6 | |||
7 | // Called when view is rendered. |
|
7 | // Called when view is rendered. | |
8 | render : function(){ |
|
8 | render : function(){ | |
9 |
this.$el |
|
9 | this.$el | |
|
10 | .html('') | |||
10 | this.$slider = $('<div />') |
|
11 | this.$slider = $('<div />') | |
11 |
|
|
12 | .slider({}) | |
12 |
|
|
13 | .addClass('slider'); | |
@@ -52,6 +53,7 b' require(["notebook/js/widget"], function(){' | |||||
52 | render : function(){ |
|
53 | render : function(){ | |
53 | this.$el |
|
54 | this.$el | |
54 | .html('') |
|
55 | .html('') | |
|
56 | .addClass('widget_item') | |||
55 | .addClass(this.model.comm.comm_id); |
|
57 | .addClass(this.model.comm.comm_id); | |
56 | this.$textbox = $('<input type="text" />') |
|
58 | this.$textbox = $('<input type="text" />') | |
57 | .addClass('input') |
|
59 | .addClass('input') |
@@ -9,8 +9,10 b' require(["notebook/js/widget"], function(){' | |||||
9 |
|
9 | |||
10 | this.$el |
|
10 | this.$el | |
11 | .html('') |
|
11 | .html('') | |
|
12 | .addClass('widget_item') | |||
12 | .addClass(this.model.comm.comm_id); |
|
13 | .addClass(this.model.comm.comm_id); | |
13 | this.$buttongroup = $('<div />') |
|
14 | this.$buttongroup = $('<div />') | |
|
15 | .addClass('widget_item') | |||
14 | .addClass('btn-group') |
|
16 | .addClass('btn-group') | |
15 | .appendTo(this.$el); |
|
17 | .appendTo(this.$el); | |
16 | this.$droplabel = $('<button />') |
|
18 | this.$droplabel = $('<button />') | |
@@ -43,6 +45,7 b' require(["notebook/js/widget"], function(){' | |||||
43 | .html(items[index]) |
|
45 | .html(items[index]) | |
44 | .on('click', function(e){ |
|
46 | .on('click', function(e){ | |
45 | that.model.set('value', $(e.target).html(), this ); |
|
47 | that.model.set('value', $(e.target).html(), this ); | |
|
48 | that.model.apply(that); | |||
46 | }) |
|
49 | }) | |
47 |
|
50 | |||
48 | this.$droplist.append($('<li />').append(item_button)) |
|
51 | this.$droplist.append($('<li />').append(item_button)) | |
@@ -71,6 +74,7 b' require(["notebook/js/widget"], function(){' | |||||
71 | render : function(){ |
|
74 | render : function(){ | |
72 | this.$el |
|
75 | this.$el | |
73 | .html('') |
|
76 | .html('') | |
|
77 | .addClass('widget_item') | |||
74 | .addClass(this.model.comm.comm_id); |
|
78 | .addClass(this.model.comm.comm_id); | |
75 | this.update(); |
|
79 | this.update(); | |
76 | }, |
|
80 | }, | |
@@ -136,8 +140,10 b' require(["notebook/js/widget"], function(){' | |||||
136 | render : function(){ |
|
140 | render : function(){ | |
137 | this.$el |
|
141 | this.$el | |
138 | .html('') |
|
142 | .html('') | |
|
143 | .addClass('widget_item') | |||
139 | .addClass(this.model.comm.comm_id); |
|
144 | .addClass(this.model.comm.comm_id); | |
140 | this.$buttongroup = $('<div />') |
|
145 | this.$buttongroup = $('<div />') | |
|
146 | .addClass('widget_item') | |||
141 | .addClass('btn-group') |
|
147 | .addClass('btn-group') | |
142 | .attr('data-toggle', 'buttons-radio') |
|
148 | .attr('data-toggle', 'buttons-radio') | |
143 | .appendTo(this.$el); |
|
149 | .appendTo(this.$el); |
@@ -6,18 +6,16 b' require(["notebook/js/widget"], function(){' | |||||
6 |
|
6 | |||
7 | // Called when view is rendered. |
|
7 | // Called when view is rendered. | |
8 | render : function(){ |
|
8 | render : function(){ | |
9 | this.$el |
|
9 | this.$el = $('<div />') | |
10 |
. |
|
10 | .addClass('widget_item') | |
11 | this.$label = $('<div />') |
|
11 | .addClass(this.model.comm.comm_id); | |
12 | .addClass(this.model.comm.comm_id) |
|
|||
13 | .appendTo(this.$el); |
|
|||
14 | this.update(); // Set defaults. |
|
12 | this.update(); // Set defaults. | |
15 | }, |
|
13 | }, | |
16 |
|
14 | |||
17 | // Handles: Backend -> Frontend Sync |
|
15 | // Handles: Backend -> Frontend Sync | |
18 | // Frontent -> Frontend Sync |
|
16 | // Frontent -> Frontend Sync | |
19 | update : function(){ |
|
17 | update : function(){ | |
20 |
this.$ |
|
18 | this.$el.html(this.model.get('value')); | |
21 | }, |
|
19 | }, | |
22 |
|
20 | |||
23 | }); |
|
21 | }); | |
@@ -30,6 +28,7 b' require(["notebook/js/widget"], function(){' | |||||
30 | render : function(){ |
|
28 | render : function(){ | |
31 | this.$el |
|
29 | this.$el | |
32 | .html('') |
|
30 | .html('') | |
|
31 | .addClass('widget_item') | |||
33 | .addClass(this.model.comm.comm_id); |
|
32 | .addClass(this.model.comm.comm_id); | |
34 | this.$textbox = $('<textarea />') |
|
33 | this.$textbox = $('<textarea />') | |
35 | .attr('rows', 5) |
|
34 | .attr('rows', 5) | |
@@ -66,6 +65,7 b' require(["notebook/js/widget"], function(){' | |||||
66 | render : function(){ |
|
65 | render : function(){ | |
67 | this.$el |
|
66 | this.$el | |
68 | .html('') |
|
67 | .html('') | |
|
68 | .addClass('widget_item') | |||
69 | .addClass(this.model.comm.comm_id); |
|
69 | .addClass(this.model.comm.comm_id); | |
70 | this.$textbox = $('<input type="text" />') |
|
70 | this.$textbox = $('<input type="text" />') | |
71 | .addClass('input') |
|
71 | .addClass('input') |
@@ -1,8 +1,21 b'' | |||||
|
1 | ||||
1 | div.widget_area { |
|
2 | div.widget_area { | |
2 | page-break-inside: avoid; |
|
3 | page-break-inside: avoid; | |
|
4 | .vbox(); | |||
|
5 | } | |||
|
6 | ||||
|
7 | div.widget_hbox { | |||
3 | .hbox(); |
|
8 | .hbox(); | |
4 | } |
|
9 | } | |
5 |
|
10 | |||
|
11 | div.widget_vbox { | |||
|
12 | .vbox(); | |||
|
13 | } | |||
|
14 | ||||
|
15 | div.widget_item { | |||
|
16 | display: inline-block; | |||
|
17 | } | |||
|
18 | ||||
6 | /* This class is for the widget subarea inside the widget_area and after |
|
19 | /* This class is for the widget subarea inside the widget_area and after | |
7 | the prompt div. */ |
|
20 | the prompt div. */ | |
8 | div.widget_subarea { |
|
21 | div.widget_subarea { |
@@ -152,3 +152,18 b' div.text_cell_input{color:#000000;border:1px solid #cfcfcf;border-radius:4px;bac' | |||||
152 | div.text_cell_render{outline:none;resize:none;width:inherit;border-style:none;padding:5px;color:#000000;} |
|
152 | div.text_cell_render{outline:none;resize:none;width:inherit;border-style:none;padding:5px;color:#000000;} | |
153 | a.anchor-link:link{text-decoration:none;padding:0px 20px;visibility:hidden;} |
|
153 | a.anchor-link:link{text-decoration:none;padding:0px 20px;visibility:hidden;} | |
154 | h1:hover .anchor-link,h2:hover .anchor-link,h3:hover .anchor-link,h4:hover .anchor-link,h5:hover .anchor-link,h6:hover .anchor-link{visibility:visible;} |
|
154 | h1:hover .anchor-link,h2:hover .anchor-link,h3:hover .anchor-link,h4:hover .anchor-link,h5:hover .anchor-link,h6:hover .anchor-link{visibility:visible;} | |
|
155 | .toolbar{padding:0px 10px;margin-top:-5px;}.toolbar select,.toolbar label{width:auto;height:26px;vertical-align:middle;margin-right:2px;margin-bottom:0px;display:inline;font-size:92%;margin-left:0.3em;margin-right:0.3em;padding:0px;padding-top:3px;} | |||
|
156 | .toolbar .btn{padding:2px 8px;} | |||
|
157 | .toolbar .btn-group{margin-top:0px;} | |||
|
158 | .toolbar-inner{border:none !important;-webkit-box-shadow:none !important;-moz-box-shadow:none !important;box-shadow:none !important;} | |||
|
159 | #maintoolbar{margin-bottom:0px;} | |||
|
160 | @-moz-keyframes fadeOut{from{opacity:1;} to{opacity:0;}}@-webkit-keyframes fadeOut{from{opacity:1;} to{opacity:0;}}@-moz-keyframes fadeIn{from{opacity:0;} to{opacity:1;}}@-webkit-keyframes fadeIn{from{opacity:0;} to{opacity:1;}}.bigtooltip{overflow:auto;height:200px;-webkit-transition-property:height;-webkit-transition-duration:500ms;-moz-transition-property:height;-moz-transition-duration:500ms;transition-property:height;transition-duration:500ms;} | |||
|
161 | .smalltooltip{-webkit-transition-property:height;-webkit-transition-duration:500ms;-moz-transition-property:height;-moz-transition-duration:500ms;transition-property:height;transition-duration:500ms;text-overflow:ellipsis;overflow:hidden;height:80px;} | |||
|
162 | .tooltipbuttons{position:absolute;padding-right:15px;top:0px;right:0px;} | |||
|
163 | .tooltiptext{padding-right:30px;} | |||
|
164 | .ipython_tooltip{max-width:700px;-webkit-animation:fadeOut 400ms;-moz-animation:fadeOut 400ms;animation:fadeOut 400ms;-webkit-animation:fadeIn 400ms;-moz-animation:fadeIn 400ms;animation:fadeIn 400ms;vertical-align:middle;background-color:#f7f7f7;overflow:visible;border:#ababab 1px solid;outline:none;padding:3px;margin:0px;padding-left:7px;font-family:monospace;min-height:50px;-moz-box-shadow:0px 6px 10px -1px #adadad;-webkit-box-shadow:0px 6px 10px -1px #adadad;box-shadow:0px 6px 10px -1px #adadad;border-radius:4px;position:absolute;z-index:2;}.ipython_tooltip a{float:right;} | |||
|
165 | .ipython_tooltip .tooltiptext pre{border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;font-size:100%;background-color:#f7f7f7;} | |||
|
166 | .pretooltiparrow{left:0px;margin:0px;top:-16px;width:40px;height:16px;overflow:hidden;position:absolute;} | |||
|
167 | .pretooltiparrow:before{background-color:#f7f7f7;border:1px #ababab solid;z-index:11;content:"";position:absolute;left:15px;top:10px;width:25px;height:25px;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);} | |||
|
168 | div.widget_area{page-break-inside:avoid;display:-webkit-box;-webkit-box-orient:horizontal;-webkit-box-align:stretch;display:-moz-box;-moz-box-orient:horizontal;-moz-box-align:stretch;display:box;box-orient:horizontal;box-align:stretch;} | |||
|
169 | div.widget_subarea{padding:0.44em 0.4em 0.4em 1px;margin-left:6px;-webkit-box-flex:1;-moz-box-flex:1;box-flex:1;} |
@@ -1,7 +1,10 b'' | |||||
1 | from base import Widget |
|
1 | from base import Widget | |
2 | from IPython.utils.traitlets import Unicode |
|
2 | from IPython.utils.traitlets import Unicode, Bool | |
3 |
|
3 | |||
4 | class ContainerWidget(Widget): |
|
4 | class ContainerWidget(Widget): | |
5 | target_name = Unicode('container_widget') |
|
5 | target_name = Unicode('container_widget') | |
6 | default_view_name = Unicode('ContainerView') |
|
6 | default_view_name = Unicode('ContainerView') | |
|
7 | _keys = ['vbox', 'hbox'] | |||
7 |
|
8 | |||
|
9 | hbox = Bool(True) | |||
|
10 | vbox = Bool(False) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now