##// END OF EJS Templates
Attempt 1, HBox and VBox implementation.
Jonathan Frederic -
Show More
@@ -169,7 +169,7 b' define(["static/components/underscore/underscore-min.js",'
169 169
170 170 // Add the view's element to cell's widget div.
171 171 widget_area
172 .append($("<div />").append(widget_view.$el))
172 .append(widget_view.$el)
173 173 .parent().show(); // Show the widget_area (parent of widget_subarea)
174 174
175 175 // Update the view based on the model contents.
@@ -204,6 +204,7 b' define(["static/components/underscore/underscore-min.js",'
204 204
205 205 // Handle when a widget is updated via the python side.
206 206 WidgetManager.prototype.handle_update = function (comm, state) {
207 this.updating = true;
207 208 for (var key in state) {
208 209 if (state.hasOwnProperty(key)) {
209 210 if (key=="_css"){
@@ -214,6 +215,7 b' define(["static/components/underscore/underscore-min.js",'
214 215 }
215 216 }
216 217 comm.model.save();
218 this.updating = false;
217 219 }
218 220
219 221 // Handle when a widget is closed.
@@ -233,21 +235,25 b' define(["static/components/underscore/underscore-min.js",'
233 235
234 236 // Send widget state to python backend.
235 237 WidgetManager.prototype.send_sync = function (method, model) {
236
237 // Create a callback for the output if the widget has an output area associate with it.
238 var callbacks = {};
239 var comm = model.comm;
240 var outputarea = this._get_comm_outputarea(comm);
241 if (outputarea != null) {
242 callbacks = {
243 iopub : {
244 output : $.proxy(outputarea.handle_output, outputarea),
245 clear_output : $.proxy(outputarea.handle_clear_output, outputarea)}
246 };
247 };
248 238 var model_json = model.toJSON();
249 var data = {sync_method: method, sync_data: model_json};
250 comm.send(data, callbacks);
239
240 // Only send updated state if the state hasn't been changed during an update.
241 if (!this.updating) {
242 // Create a callback for the output if the widget has an output area associate with it.
243 var callbacks = {};
244 var comm = model.comm;
245 var outputarea = this._get_comm_outputarea(comm);
246 if (outputarea != null) {
247 callbacks = {
248 iopub : {
249 output : $.proxy(outputarea.handle_output, outputarea),
250 clear_output : $.proxy(outputarea.handle_clear_output, outputarea)}
251 };
252 };
253 var data = {sync_method: method, sync_data: model_json};
254 comm.send(data, callbacks);
255 }
256
251 257 return model_json;
252 258 }
253 259
@@ -10,6 +10,7 b' require(["notebook/js/widget"], function(){'
10 10 render : function(){
11 11 this.$el
12 12 .html('')
13 .addClass('widget_item')
13 14 .addClass(this.model.comm.comm_id);
14 15
15 16 var $label = $('<label />')
@@ -19,6 +20,7 b' require(["notebook/js/widget"], function(){'
19 20 .attr('type', 'checkbox')
20 21 .appendTo($label);
21 22 this.$checkbox_label = $('<div />')
23 .addClass('widget_item')
22 24 .appendTo($label);
23 25
24 26 this.update(); // Set defaults.
@@ -5,14 +5,23 b' require(["notebook/js/widget"], function(){'
5 5 var ContainerView = IPython.WidgetView.extend({
6 6
7 7 render : function(){
8 this.$el.html('');
9 this.$container = $('<div />')
10 .addClass('container')
8 this.$el = $('<div />')
11 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 27 IPython.notebook.widget_manager.register_widget_view('ContainerView', ContainerView);
@@ -10,14 +10,14 b' require(["notebook/js/widget"], function(){'
10 10 .html('')
11 11 .addClass(this.model.comm.comm_id);
12 12 this.$slider = $('<div />')
13 .slider({})
14 .addClass('slider');
13 .slider({})
14 .addClass('slider');
15 15
16 16 // Put the slider in a container
17 17 this.$slider_container = $('<div />')
18 .css('padding-top', '4px')
19 .css('padding-bottom', '4px')
20 .append(this.$slider);
18 .css('padding-top', '4px')
19 .css('padding-bottom', '4px')
20 .append(this.$slider);
21 21 this.$el.append(this.$slider_container);
22 22
23 23 // Set defaults.
@@ -54,6 +54,7 b' require(["notebook/js/widget"], function(){'
54 54 render : function(){
55 55 this.$el
56 56 .html('')
57 .addClass('widget_item')
57 58 .addClass(this.model.comm.comm_id);
58 59 this.$textbox = $('<input type="text" />')
59 60 .addClass('input')
@@ -6,17 +6,18 b' require(["notebook/js/widget"], function(){'
6 6
7 7 // Called when view is rendered.
8 8 render : function(){
9 this.$el.html('');
9 this.$el
10 .html('')
10 11 this.$slider = $('<div />')
11 .slider({})
12 .addClass('slider');
12 .slider({})
13 .addClass('slider');
13 14
14 15 // Put the slider in a container
15 16 this.$slider_container = $('<div />')
16 .css('padding-top', '4px')
17 .css('padding-bottom', '4px')
18 .addClass(this.model.comm.comm_id)
19 .append(this.$slider);
17 .css('padding-top', '4px')
18 .css('padding-bottom', '4px')
19 .addClass(this.model.comm.comm_id)
20 .append(this.$slider);
20 21 this.$el.append(this.$slider_container);
21 22
22 23 // Set defaults.
@@ -52,6 +53,7 b' require(["notebook/js/widget"], function(){'
52 53 render : function(){
53 54 this.$el
54 55 .html('')
56 .addClass('widget_item')
55 57 .addClass(this.model.comm.comm_id);
56 58 this.$textbox = $('<input type="text" />')
57 59 .addClass('input')
@@ -9,8 +9,10 b' require(["notebook/js/widget"], function(){'
9 9
10 10 this.$el
11 11 .html('')
12 .addClass('widget_item')
12 13 .addClass(this.model.comm.comm_id);
13 14 this.$buttongroup = $('<div />')
15 .addClass('widget_item')
14 16 .addClass('btn-group')
15 17 .appendTo(this.$el);
16 18 this.$droplabel = $('<button />')
@@ -43,6 +45,7 b' require(["notebook/js/widget"], function(){'
43 45 .html(items[index])
44 46 .on('click', function(e){
45 47 that.model.set('value', $(e.target).html(), this );
48 that.model.apply(that);
46 49 })
47 50
48 51 this.$droplist.append($('<li />').append(item_button))
@@ -71,6 +74,7 b' require(["notebook/js/widget"], function(){'
71 74 render : function(){
72 75 this.$el
73 76 .html('')
77 .addClass('widget_item')
74 78 .addClass(this.model.comm.comm_id);
75 79 this.update();
76 80 },
@@ -136,8 +140,10 b' require(["notebook/js/widget"], function(){'
136 140 render : function(){
137 141 this.$el
138 142 .html('')
143 .addClass('widget_item')
139 144 .addClass(this.model.comm.comm_id);
140 145 this.$buttongroup = $('<div />')
146 .addClass('widget_item')
141 147 .addClass('btn-group')
142 148 .attr('data-toggle', 'buttons-radio')
143 149 .appendTo(this.$el);
@@ -6,18 +6,16 b' require(["notebook/js/widget"], function(){'
6 6
7 7 // Called when view is rendered.
8 8 render : function(){
9 this.$el
10 .html('');
11 this.$label = $('<div />')
12 .addClass(this.model.comm.comm_id)
13 .appendTo(this.$el);
9 this.$el = $('<div />')
10 .addClass('widget_item')
11 .addClass(this.model.comm.comm_id);
14 12 this.update(); // Set defaults.
15 13 },
16 14
17 15 // Handles: Backend -> Frontend Sync
18 16 // Frontent -> Frontend Sync
19 17 update : function(){
20 this.$label.html(this.model.get('value'));
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 28 render : function(){
31 29 this.$el
32 30 .html('')
31 .addClass('widget_item')
33 32 .addClass(this.model.comm.comm_id);
34 33 this.$textbox = $('<textarea />')
35 34 .attr('rows', 5)
@@ -66,6 +65,7 b' require(["notebook/js/widget"], function(){'
66 65 render : function(){
67 66 this.$el
68 67 .html('')
68 .addClass('widget_item')
69 69 .addClass(this.model.comm.comm_id);
70 70 this.$textbox = $('<input type="text" />')
71 71 .addClass('input')
@@ -1,8 +1,21 b''
1
1 2 div.widget_area {
2 3 page-break-inside: avoid;
4 .vbox();
5 }
6
7 div.widget_hbox {
3 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 19 /* This class is for the widget subarea inside the widget_area and after
7 20 the prompt div. */
8 21 div.widget_subarea {
@@ -152,3 +152,18 b' div.text_cell_input{color:#000000;border:1px solid #cfcfcf;border-radius:4px;bac'
152 152 div.text_cell_render{outline:none;resize:none;width:inherit;border-style:none;padding:5px;color:#000000;}
153 153 a.anchor-link:link{text-decoration:none;padding:0px 20px;visibility:hidden;}
154 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 1 from base import Widget
2 from IPython.utils.traitlets import Unicode
2 from IPython.utils.traitlets import Unicode, Bool
3 3
4 4 class ContainerWidget(Widget):
5 5 target_name = Unicode('container_widget')
6 6 default_view_name = Unicode('ContainerView')
7 No newline at end of file
7 _keys = ['vbox', 'hbox']
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