mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-13 13:17:50 +08:00
jslint /widgets
This commit is contained in:
parent
f1986755ec
commit
4e3b2b3e94
@ -54,7 +54,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
this.$checkbox.prop('disabled', disabled);
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.html(description);
|
||||
@ -98,7 +98,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
this.$button.prop('disabled', disabled);
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$button.html(' '); // Preserve button height
|
||||
} else {
|
||||
this.$button.html(description);
|
||||
|
@ -36,7 +36,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
var description = this.model.get('description');
|
||||
description = description.replace(/ /g, ' ', 'm');
|
||||
description = description.replace(/\n/g, '<br>\n', 'm');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$el.html(' '); // Preserve button height
|
||||
} else {
|
||||
this.$el.html(description);
|
||||
|
@ -87,7 +87,7 @@ define(["notebook/js/widget"], function(widget_manager) {
|
||||
.appendTo(this.$window)
|
||||
.mousedown(function(){
|
||||
that.bring_to_front();
|
||||
});;
|
||||
});
|
||||
this.$close = $('<button />')
|
||||
.addClass('close icon-remove')
|
||||
.css('margin-left', '5px')
|
||||
@ -156,7 +156,7 @@ define(["notebook/js/widget"], function(widget_manager) {
|
||||
this.$window.resizable();
|
||||
this.$window.on('resize', function(){
|
||||
that.$body.outerHeight(that.$window.innerHeight() - that.$title_bar.outerHeight());
|
||||
})
|
||||
});
|
||||
|
||||
this.$el_to_style = this.$body;
|
||||
this._shown_once = false;
|
||||
@ -173,7 +173,7 @@ define(["notebook/js/widget"], function(widget_manager) {
|
||||
|
||||
this.$window.show();
|
||||
if (this.popped_out) {
|
||||
this.$window.css("positon", "absolute")
|
||||
this.$window.css("positon", "absolute");
|
||||
this.$window.css("top", "0px");
|
||||
this.$window.css("left", Math.max(0, (($('body').outerWidth() - this.$window.outerWidth()) / 2) +
|
||||
$(window).scrollLeft()) + "px");
|
||||
@ -192,7 +192,7 @@ define(["notebook/js/widget"], function(widget_manager) {
|
||||
max_zindex = Math.max(max_zindex, 2000);
|
||||
|
||||
$widget_modals.each(function (index, el){
|
||||
$el = $(el)
|
||||
$el = $(el);
|
||||
if (max_zindex == parseInt($el.css('z-index'))) {
|
||||
$el.css('z-index', max_zindex - 1);
|
||||
}
|
||||
@ -206,7 +206,7 @@ define(["notebook/js/widget"], function(widget_manager) {
|
||||
var description = this.model.get('description');
|
||||
description = description.replace(/ /g, ' ', 'm');
|
||||
description = description.replace(/\n/g, '<br>\n', 'm');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$title.html(' '); // Preserve title height
|
||||
} else {
|
||||
this.$title.html(description);
|
||||
@ -215,7 +215,7 @@ define(["notebook/js/widget"], function(widget_manager) {
|
||||
var button_text = this.model.get('button_text');
|
||||
button_text = button_text.replace(/ /g, ' ', 'm');
|
||||
button_text = button_text.replace(/\n/g, '<br>\n', 'm');
|
||||
if (button_text.length == 0) {
|
||||
if (button_text.length === 0) {
|
||||
this.$show_button.html(' '); // Preserve button height
|
||||
} else {
|
||||
this.$show_button.html(button_text);
|
||||
|
@ -33,8 +33,8 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
var titles = this.model.get('_titles');
|
||||
for (var page_index in titles) {
|
||||
|
||||
var accordian = this.containers[page_index]
|
||||
if (accordian != undefined) {
|
||||
var accordian = this.containers[page_index];
|
||||
if (accordian !== undefined) {
|
||||
accordian
|
||||
.find('.accordion-heading')
|
||||
.find('.accordion-toggle')
|
||||
@ -95,7 +95,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
// open by default even though they don't have the `in` class
|
||||
// attached to them. For some reason a delay is required.
|
||||
// TODO: Better fix.
|
||||
setTimeout(function(){that.update()}, 500);
|
||||
setTimeout(function(){ that.update(); }, 500);
|
||||
},
|
||||
});
|
||||
|
||||
@ -121,8 +121,8 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
// Set tab titles
|
||||
var titles = this.model.get('_titles');
|
||||
for (var page_index in titles) {
|
||||
var tab_text = this.containers[page_index]
|
||||
if (tab_text != undefined) {
|
||||
var tab_text = this.containers[page_index];
|
||||
if (tab_text !== undefined) {
|
||||
tab_text.html(titles[page_index]);
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
.append(view.$el)
|
||||
.appendTo(this.$tab_contents);
|
||||
|
||||
if (index==0) {
|
||||
if (index === 0) {
|
||||
tab_text.tab('show');
|
||||
}
|
||||
this.update();
|
||||
|
@ -62,7 +62,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
var selected_item_text = this.model.get('value');
|
||||
selected_item_text = selected_item_text.replace(/ /g, ' ');
|
||||
selected_item_text = selected_item_text.replace(/\n/g, '<br>\n');
|
||||
if (selected_item_text.length == 0) {
|
||||
if (selected_item_text.length === 0) {
|
||||
this.$droplabel.html(' ');
|
||||
} else {
|
||||
this.$droplabel.html(selected_item_text);
|
||||
@ -74,12 +74,8 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
var that = this;
|
||||
var item_button = $('<a href="#"/>')
|
||||
.html(items[index])
|
||||
.on('click', function(e){
|
||||
that.model.set('value', $(e.target).html(), this);
|
||||
that.model.update_other_views(that);
|
||||
})
|
||||
|
||||
this.$droplist.append($('<li />').append(item_button))
|
||||
.on('click', this.handle_click);
|
||||
this.$droplist.append($('<li />').append(item_button));
|
||||
}
|
||||
|
||||
if (this.model.get('disabled')) {
|
||||
@ -95,7 +91,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
}
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.html(description);
|
||||
@ -103,6 +99,12 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
}
|
||||
return IPython.WidgetView.prototype.update.call(this);
|
||||
},
|
||||
|
||||
// Handle when a value is clicked.
|
||||
handle_click: function (e) {
|
||||
this.model.set('value', $(e.target).html(), this);
|
||||
this.model.update_other_views(this);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -136,22 +138,18 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
var disabled = this.model.get('disabled');
|
||||
for (var index in items) {
|
||||
var item_query = ' :input[value="' + items[index] + '"]';
|
||||
if (this.$el.find(item_query).length == 0) {
|
||||
if (this.$el.find(item_query).length === 0) {
|
||||
var $label = $('<label />')
|
||||
.addClass('radio')
|
||||
.html(items[index])
|
||||
.appendTo(this.$container);
|
||||
|
||||
var that = this;
|
||||
$('<input />')
|
||||
.attr('type', 'radio')
|
||||
.addClass(this.model)
|
||||
.val(items[index])
|
||||
.prependTo($label)
|
||||
.on('click', function(e){
|
||||
that.model.set('value', $(e.target).val(), this);
|
||||
that.model.update_other_views(that);
|
||||
});
|
||||
.on('click', this.handle_click);
|
||||
}
|
||||
|
||||
var $item_element = this.$container.find(item_query);
|
||||
@ -180,7 +178,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
});
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.html(description);
|
||||
@ -188,7 +186,12 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
}
|
||||
return IPython.WidgetView.prototype.update.call(this);
|
||||
},
|
||||
|
||||
|
||||
// Handle when a value is clicked.
|
||||
handle_click: function (e) {
|
||||
this.model.set('value', $(e.target).val(), this);
|
||||
this.model.update_other_views(this);
|
||||
},
|
||||
});
|
||||
|
||||
widget_manager.register_widget_view('RadioButtonsView', RadioButtonsView);
|
||||
@ -222,18 +225,13 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
var disabled = this.model.get('disabled');
|
||||
for (var index in items) {
|
||||
var item_query = ' :contains("' + items[index] + '")';
|
||||
if (this.$buttongroup.find(item_query).length == 0) {
|
||||
|
||||
var that = this;
|
||||
if (this.$buttongroup.find(item_query).length === 0) {
|
||||
$('<button />')
|
||||
.attr('type', 'button')
|
||||
.addClass('btn')
|
||||
.html(items[index])
|
||||
.appendTo(this.$buttongroup)
|
||||
.on('click', function(e){
|
||||
that.model.set('value', $(e.target).html(), this);
|
||||
that.model.update_other_views(that);
|
||||
});
|
||||
.on('click', this.handle_click);
|
||||
}
|
||||
|
||||
var $item_element = this.$buttongroup.find(item_query);
|
||||
@ -262,7 +260,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
});
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.html(description);
|
||||
@ -270,6 +268,12 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
}
|
||||
return IPython.WidgetView.prototype.update.call(this);
|
||||
},
|
||||
|
||||
// Handle when a value is clicked.
|
||||
handle_click: function (e) {
|
||||
this.model.set('value', $(e.target).html(), this);
|
||||
this.model.update_other_views(this);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
@ -302,17 +306,12 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
var items = this.model.get('values');
|
||||
for (var index in items) {
|
||||
var item_query = ' :contains("' + items[index] + '")';
|
||||
if (this.$listbox.find(item_query).length == 0) {
|
||||
|
||||
var that = this;
|
||||
if (this.$listbox.find(item_query).length === 0) {
|
||||
$('<option />')
|
||||
.html(items[index])
|
||||
.attr('value', items[index])
|
||||
.appendTo(this.$listbox)
|
||||
.on('click', function(e){
|
||||
that.model.set('value', $(e.target).html(), this);
|
||||
that.model.update_other_views(that);
|
||||
});
|
||||
.on('click', this.handle_click);
|
||||
}
|
||||
}
|
||||
|
||||
@ -340,7 +339,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
});
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.html(description);
|
||||
@ -348,6 +347,12 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
}
|
||||
return IPython.WidgetView.prototype.update.call(this);
|
||||
},
|
||||
|
||||
// Handle when a value is clicked.
|
||||
handle_click: function (e) {
|
||||
this.model.set('value', $(e.target).html(), this);
|
||||
this.model.update_other_views(this);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
@ -102,7 +102,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
this.$textbox.prop('disabled', disabled);
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.html(description);
|
||||
@ -156,7 +156,7 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
this.$textbox.prop('disabled', disabled);
|
||||
|
||||
var description = this.model.get('description');
|
||||
if (description.length == 0) {
|
||||
if (description.length === 0) {
|
||||
this.$label.hide();
|
||||
} else {
|
||||
this.$label.html(description);
|
||||
|
Loading…
Reference in New Issue
Block a user