mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Add scroll_to_bottom method for TextAreaView (StringWidget).
This commit is contained in:
parent
9019b639d1
commit
d795654251
@ -63,6 +63,14 @@ define(["notebook/js/widget"], function(widget_manager){
|
||||
this.$textbox.val(this.model.get('value'));
|
||||
}
|
||||
|
||||
if (this.last_scroll_to_bottom == undefined) {
|
||||
this.last_scroll_to_bottom = 0;
|
||||
}
|
||||
if (this.last_scroll_to_bottom < this.model.get('scroll_to_bottoms')) {
|
||||
this.last_scroll_to_bottom < this.model.get('scroll_to_bottoms');
|
||||
this.$textbox.scrollTop(this.$textbox[0].scrollHeight);
|
||||
}
|
||||
|
||||
var disabled = this.model.get('disabled');
|
||||
this.$textbox.prop('disabled', disabled);
|
||||
|
||||
|
@ -27,11 +27,12 @@ class StringWidget(Widget):
|
||||
default_view_name = Unicode('TextBoxView')
|
||||
|
||||
# Keys
|
||||
_keys = ['value', 'disabled', 'description', 'submits']
|
||||
_keys = ['value', 'disabled', 'description', 'submits', 'scroll_to_bottoms']
|
||||
value = Unicode(help="String value")
|
||||
disabled = Bool(False, help="Enable or disable user changes")
|
||||
description = Unicode(help="Description of the value this widget represents")
|
||||
submits = Int(0, help="Used to capture and fire submission ")
|
||||
scroll_to_bottoms = Int(0, help="Used to scroll a TextAreaView to the bottom")
|
||||
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
@ -39,6 +40,10 @@ class StringWidget(Widget):
|
||||
self._submission_callbacks = []
|
||||
|
||||
|
||||
def scroll_to_bottom(self):
|
||||
self.scroll_to_bottoms += 1
|
||||
|
||||
|
||||
def on_submit(self, callback, remove=False):
|
||||
"""Register a callback to handle text submission (triggered when the
|
||||
user clicks enter).
|
||||
|
Loading…
Reference in New Issue
Block a user