mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
quick review pass on javascript
This commit is contained in:
parent
001e06103b
commit
dd2f4a25aa
@ -21,7 +21,7 @@ function(WidgetManager, Underscore, Backbone){
|
||||
|
||||
var WidgetModel = Backbone.Model.extend({
|
||||
constructor: function (widget_manager, model_id, comm) {
|
||||
// Construcctor
|
||||
// Constructor
|
||||
//
|
||||
// Creates a WidgetModel instance.
|
||||
//
|
||||
@ -111,7 +111,7 @@ function(WidgetManager, Underscore, Backbone){
|
||||
if (this.msg_buffer !== null &&
|
||||
this.msg_throttle === this.pending_msgs) {
|
||||
var data = {method: 'backbone', sync_method: 'update', sync_data: this.msg_buffer};
|
||||
this.comm.send(data, callbacks);
|
||||
this.comm.send(data, callbacks);
|
||||
this.msg_buffer = null;
|
||||
} else {
|
||||
--this.pending_msgs;
|
||||
@ -131,7 +131,7 @@ function(WidgetManager, Underscore, Backbone){
|
||||
var that = this;
|
||||
callbacks.iopub.status = function (msg) {
|
||||
that._handle_status(msg, callbacks);
|
||||
}
|
||||
};
|
||||
return callbacks;
|
||||
},
|
||||
|
||||
@ -141,7 +141,7 @@ function(WidgetManager, Underscore, Backbone){
|
||||
// Make sure a comm exists.
|
||||
var error = options.error || function() {
|
||||
console.error('Backbone sync error:', arguments);
|
||||
}
|
||||
};
|
||||
if (this.comm === undefined) {
|
||||
error();
|
||||
return false;
|
||||
@ -233,7 +233,7 @@ function(WidgetManager, Underscore, Backbone){
|
||||
return unpacked;
|
||||
} else {
|
||||
var model = this.widget_manager.get_model(value);
|
||||
if (model !== null) {
|
||||
if (model) {
|
||||
return model;
|
||||
} else {
|
||||
return value;
|
||||
@ -279,7 +279,7 @@ function(WidgetManager, Underscore, Backbone){
|
||||
var view = this.child_views[child_model.id];
|
||||
if (view !== undefined) {
|
||||
delete this.child_views[child_model.id];
|
||||
view.remove();
|
||||
view.remove();
|
||||
}
|
||||
},
|
||||
|
||||
@ -373,7 +373,7 @@ function(WidgetManager, Underscore, Backbone){
|
||||
// to render
|
||||
var e = this.$el;
|
||||
var visible = this.model.get('visible');
|
||||
setTimeout(function() {e.toggle(visible)},0);
|
||||
setTimeout(function() {e.toggle(visible);},0);
|
||||
|
||||
var css = this.model.get('_css');
|
||||
if (css === undefined) {return;}
|
||||
@ -387,17 +387,16 @@ function(WidgetManager, Underscore, Backbone){
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
_get_selector_element: function (selector) {
|
||||
// Get the elements via the css selector.
|
||||
// Get the elements via the css selector.
|
||||
|
||||
// If the selector is blank, apply the style to the $el_to_style
|
||||
// element. If the $el_to_style element is not defined, use apply
|
||||
// the style to the view's element.
|
||||
var elements;
|
||||
if (selector === undefined || selector === null || selector === '') {
|
||||
if (!selector) {
|
||||
if (this.$el_to_style === undefined) {
|
||||
elements = this.$el;
|
||||
} else {
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
|
||||
var ButtonView = IPython.DOMWidgetView.extend({
|
||||
var ButtonView = IPython.DOMWidgetView.extend({
|
||||
render : function(){
|
||||
// Called when view is rendered.
|
||||
this.setElement($("<button />")
|
||||
|
@ -16,22 +16,21 @@
|
||||
|
||||
define(["notebook/js/widgets/widget"], function(WidgetManager) {
|
||||
|
||||
var ContainerView = IPython.DOMWidgetView.extend({
|
||||
var ContainerView = IPython.DOMWidgetView.extend({
|
||||
render: function(){
|
||||
// Called when view is rendered.
|
||||
this.$el
|
||||
.addClass('widget-container');
|
||||
this.$el.addClass('widget-container');
|
||||
this.children={};
|
||||
this.update_children([], this.model.get('_children'));
|
||||
this.model.on('change:_children', function(model, value, options) {
|
||||
this.update_children(model.previous('_children'), value);
|
||||
}, this);
|
||||
this.update()
|
||||
this.update();
|
||||
},
|
||||
|
||||
update_children: function(old_list, new_list) {
|
||||
// Called when the children list changes.
|
||||
this.do_diff(old_list,
|
||||
this.do_diff(old_list,
|
||||
new_list,
|
||||
$.proxy(this.remove_child_model, this),
|
||||
$.proxy(this.add_child_model, this));
|
||||
@ -57,17 +56,16 @@ define(["notebook/js/widgets/widget"], function(WidgetManager) {
|
||||
return ContainerView.__super__.update.apply(this);
|
||||
},
|
||||
});
|
||||
|
||||
WidgetManager.register_widget_view('ContainerView', ContainerView);
|
||||
|
||||
|
||||
var PopupView = IPython.DOMWidgetView.extend({
|
||||
|
||||
var PopupView = IPython.DOMWidgetView.extend({
|
||||
render: function(){
|
||||
// Called when view is rendered.
|
||||
var that = this;
|
||||
this.children={};
|
||||
|
||||
this.$el
|
||||
.on("remove", function(){
|
||||
this.$el.on("remove", function(){
|
||||
that.$window.remove();
|
||||
});
|
||||
this.$window = $('<div />')
|
||||
|
@ -32,7 +32,7 @@ define(["notebook/js/widgets/widget",
|
||||
WidgetManager.register_widget_view('FloatSliderView', FloatSliderView);
|
||||
|
||||
|
||||
var FloatTextView = IntTextView.extend({
|
||||
var FloatTextView = IntTextView.extend({
|
||||
_parse_value: function(value) {
|
||||
// Parse the value stored in a string.
|
||||
return parseFloat(value);
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
|
||||
var IntSliderView = IPython.DOMWidgetView.extend({
|
||||
var IntSliderView = IPython.DOMWidgetView.extend({
|
||||
render : function(){
|
||||
// Called when view is rendered.
|
||||
this.$el
|
||||
@ -32,7 +32,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
// Put the slider in a container
|
||||
this.$slider_container = $('<div />')
|
||||
.addClass('widget-hslider')
|
||||
.append(this.$slider);
|
||||
.append(this.$slider);
|
||||
this.$el_to_style = this.$slider_container; // Set default element to style
|
||||
this.$el.append(this.$slider_container);
|
||||
|
||||
@ -218,7 +218,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
}
|
||||
},
|
||||
|
||||
handleChanged: function(e) {
|
||||
handleChanged: function(e) {
|
||||
// Applies validated input.
|
||||
if (this.model.get('value') != e.target.value) {
|
||||
e.target.value = this.model.get('value');
|
||||
@ -233,7 +233,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
WidgetManager.register_widget_view('IntTextView', IntTextView);
|
||||
|
||||
|
||||
var ProgressView = IPython.DOMWidgetView.extend({
|
||||
var ProgressView = IPython.DOMWidgetView.extend({
|
||||
render : function(){
|
||||
// Called when view is rendered.
|
||||
this.$el
|
||||
|
@ -18,7 +18,7 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){
|
||||
|
||||
var DropdownView = IPython.DOMWidgetView.extend({
|
||||
render : function(){
|
||||
// Called when view is rendered.
|
||||
// Called when view is rendered.
|
||||
this.$el
|
||||
.addClass('widget-hbox-single');
|
||||
this.$label = $('<div />')
|
||||
|
Loading…
Reference in New Issue
Block a user