mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
Fixes that allow last commit to work.
This commit is contained in:
parent
837ef44256
commit
f241242b7f
@ -58,7 +58,7 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
for (var cell_index in this.views) {
|
for (var cell_index in this.views) {
|
||||||
var view = this.views[cell_index];
|
var view = this.views[cell_index];
|
||||||
if (view !== caller) {
|
if (view !== caller) {
|
||||||
view.refresh();
|
view.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -121,7 +121,7 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
|
|
||||||
var data = {sync_method: method, sync_data: send_json};
|
var data = {sync_method: method, sync_data: send_json};
|
||||||
var output_area = this._get_view_output_area(this.last_modified_view);
|
var output_area = this._get_view_output_area(this.last_modified_view);
|
||||||
var callbacks = this._make_callbacks();
|
var callbacks = this._make_callbacks(output_area);
|
||||||
this.comm.send(data, callbacks);
|
this.comm.send(data, callbacks);
|
||||||
this.pending_msgs++;
|
this.pending_msgs++;
|
||||||
}
|
}
|
||||||
@ -134,7 +134,7 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
|
|
||||||
|
|
||||||
// Handle incomming comm msg.
|
// Handle incomming comm msg.
|
||||||
handle_comm_msg: function (comm, msg) {
|
handle_comm_msg: function (msg) {
|
||||||
var method = msg.content.data.method;
|
var method = msg.content.data.method;
|
||||||
switch (method){
|
switch (method){
|
||||||
case 'display':
|
case 'display':
|
||||||
@ -150,7 +150,7 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
this.handle_update(msg.content.data.state);
|
this.handle_update(msg.content.data.state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
// Handle when a widget is updated via the python side.
|
// Handle when a widget is updated via the python side.
|
||||||
@ -171,7 +171,7 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
} finally {
|
} finally {
|
||||||
this.updating = false;
|
this.updating = false;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
// Handle when a widget is closed.
|
// Handle when a widget is closed.
|
||||||
@ -180,11 +180,11 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
var view = this.views[cell_index];
|
var view = this.views[cell_index];
|
||||||
view.remove();
|
view.remove();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
// Create view that represents the model.
|
// Create view that represents the model.
|
||||||
display_view = function (view_name, parent_comm_id, cell_index) {
|
display_view: function (view_name, parent_comm_id, cell_index) {
|
||||||
var view = new this.widget_view_types[view_name]({model: this});
|
var view = new this.widget_view_types[view_name]({model: this});
|
||||||
view.render();
|
view.render();
|
||||||
this.views[cell_index] = view;
|
this.views[cell_index] = view;
|
||||||
@ -205,19 +205,18 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var display_child = null;
|
var displayed = false;
|
||||||
if (parent_comm_id != undefined) {
|
if (parent_comm_id != undefined) {
|
||||||
var parent_comm = this.comm_manager.comms[parent_comm_id];
|
var parent_comm = this.comm_manager.comms[parent_comm_id];
|
||||||
var parent_model = parent_comm.model;
|
var parent_model = parent_comm.model;
|
||||||
var parent_view = parent_model.views[cell_id];
|
var parent_view = parent_model.views[cell_index];
|
||||||
if (parent_view.display_child != undefined) {
|
if (parent_view.display_child != undefined) {
|
||||||
display_child = parent_view.display_child;
|
parent_view.display_child(view.$el);
|
||||||
|
displayed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display_child != null) {
|
if (!displayed) {
|
||||||
display_child(view.$el);
|
|
||||||
} else {
|
|
||||||
// No parent view is defined or exists. Add the view's
|
// No parent view is defined or exists. Add the view's
|
||||||
// element to cell's widget div.
|
// element to cell's widget div.
|
||||||
var cell = IPython.notebook.get_cell(cell_index);
|
var cell = IPython.notebook.get_cell(cell_index);
|
||||||
@ -228,8 +227,8 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update the view based on the model contents.
|
// Update the view based on the model contents.
|
||||||
view.refresh();
|
view.update();
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
// Build a callback dict.
|
// Build a callback dict.
|
||||||
@ -254,14 +253,14 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
// Get the cell output area corresponding to the view.
|
// Get the cell output area corresponding to the view.
|
||||||
_get_view_output_area: function (view) {
|
_get_view_output_area: function (view) {
|
||||||
return this._get_cell_output_area(view.cell_index);
|
return this._get_cell_output_area(view.cell_index);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
// Get the cell output area corresponding to the cell id.
|
// Get the cell output area corresponding to the cell id.
|
||||||
_get_cell_output_area: function (cell_id) {
|
_get_cell_output_area: function (cell_id) {
|
||||||
var cell = IPython.notebook.get_cell(cell_id)
|
var cell = IPython.notebook.get_cell(cell_id)
|
||||||
return cell.output_area;
|
return cell.output_area;
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -271,12 +270,10 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
var WidgetView = Backbone.View.extend({
|
var WidgetView = Backbone.View.extend({
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.model.on('change',this.refresh,this);
|
this.model.on('change',this.update,this);
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
var results = Backbone.Model.prototype.update.call(this);
|
|
||||||
|
|
||||||
if (this.model.css != undefined) {
|
if (this.model.css != undefined) {
|
||||||
for (var selector in this.model.css) {
|
for (var selector in this.model.css) {
|
||||||
if (this.model.css.hasOwnProperty(selector)) {
|
if (this.model.css.hasOwnProperty(selector)) {
|
||||||
@ -300,7 +297,6 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results;
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -338,7 +334,7 @@ define(["../../components/underscore/underscore-min.js",
|
|||||||
|
|
||||||
WidgetManager.prototype.handle_com_open = function (comm, msg) {
|
WidgetManager.prototype.handle_com_open = function (comm, msg) {
|
||||||
var widget_type_name = msg.content.target_name;
|
var widget_type_name = msg.content.target_name;
|
||||||
var widget_model = new this.widget_model_types[widget_type_name](this.comm_manager, comm, view_types);
|
var widget_model = new this.widget_model_types[widget_type_name](this.comm_manager, comm, this.widget_view_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
this.$checkbox.prop('checked', this.model.get('value'));
|
this.$checkbox.prop('checked', this.model.get('value'));
|
||||||
this.$checkbox_label.html(this.model.get('description'));
|
this.$checkbox_label.html(this.model.get('description'));
|
||||||
}
|
}
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {"change input" : "handleChanged"},
|
events: {"change input" : "handleChanged"},
|
||||||
@ -72,6 +73,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
}
|
}
|
||||||
this.$button.html(this.model.get('description'));
|
this.$button.html(this.model.get('description'));
|
||||||
}
|
}
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {"click button" : "handleClick"},
|
events: {"click button" : "handleClick"},
|
||||||
|
@ -23,6 +23,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
// Frontent -> Frontend Sync
|
// Frontent -> Frontend Sync
|
||||||
update : function(){
|
update : function(){
|
||||||
this.$el.html(this.model.get('description'));
|
this.$el.html(this.model.get('description'));
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -22,6 +22,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
this.$el.removeClass(flex_properties[index]);
|
this.$el.removeClass(flex_properties[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
display_child : function($element) {
|
display_child : function($element) {
|
||||||
|
@ -60,6 +60,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
this.$dropbutton.removeAttr('disabled');
|
this.$dropbutton.removeAttr('disabled');
|
||||||
this.$droplist.removeAttr('disabled');
|
this.$droplist.removeAttr('disabled');
|
||||||
}
|
}
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -97,7 +98,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
.prependTo($label)
|
.prependTo($label)
|
||||||
.on('click', function(e){
|
.on('click', function(e){
|
||||||
that.model.set('value', $(e.target).val(), this);
|
that.model.set('value', $(e.target).val(), this);
|
||||||
that.model.update_other_views();
|
that.model.update_other_views(that);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +124,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
$(obj).parent().remove();
|
$(obj).parent().remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -161,7 +163,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
.appendTo(this.$buttongroup)
|
.appendTo(this.$buttongroup)
|
||||||
.on('click', function(e){
|
.on('click', function(e){
|
||||||
that.model.set('value', $(e.target).html(), this);
|
that.model.set('value', $(e.target).html(), this);
|
||||||
that.model.update_other_views();
|
that.model.update_other_views(that);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +189,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
$(obj).remove();
|
$(obj).remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -14,6 +14,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
// Frontent -> Frontend Sync
|
// Frontent -> Frontend Sync
|
||||||
update : function(){
|
update : function(){
|
||||||
this.$el.html(this.model.get('value'));
|
this.$el.html(this.model.get('value'));
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -38,6 +39,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
if (!this.user_invoked_update) {
|
if (!this.user_invoked_update) {
|
||||||
this.$textbox.val(this.model.get('value'));
|
this.$textbox.val(this.model.get('value'));
|
||||||
}
|
}
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {"keyup textarea" : "handleChanging",
|
events: {"keyup textarea" : "handleChanging",
|
||||||
@ -73,6 +75,7 @@ require(["../static/notebook/js/widget"], function(){
|
|||||||
if (!this.user_invoked_update) {
|
if (!this.user_invoked_update) {
|
||||||
this.$textbox.val(this.model.get('value'));
|
this.$textbox.val(this.model.get('value'));
|
||||||
}
|
}
|
||||||
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {"keyup input" : "handleChanging",
|
events: {"keyup input" : "handleChanging",
|
||||||
|
Loading…
Reference in New Issue
Block a user