##// END OF EJS Templates
Add scroll_to_bottom method for TextAreaView (StringWidget).
Jonathan Frederic -
Show More
@@ -63,6 +63,14 b' define(["notebook/js/widget"], function(widget_manager){'
63 63 this.$textbox.val(this.model.get('value'));
64 64 }
65 65
66 if (this.last_scroll_to_bottom == undefined) {
67 this.last_scroll_to_bottom = 0;
68 }
69 if (this.last_scroll_to_bottom < this.model.get('scroll_to_bottoms')) {
70 this.last_scroll_to_bottom < this.model.get('scroll_to_bottoms');
71 this.$textbox.scrollTop(this.$textbox[0].scrollHeight);
72 }
73
66 74 var disabled = this.model.get('disabled');
67 75 this.$textbox.prop('disabled', disabled);
68 76
@@ -27,11 +27,12 b' class StringWidget(Widget):'
27 27 default_view_name = Unicode('TextBoxView')
28 28
29 29 # Keys
30 _keys = ['value', 'disabled', 'description', 'submits']
30 _keys = ['value', 'disabled', 'description', 'submits', 'scroll_to_bottoms']
31 31 value = Unicode(help="String value")
32 32 disabled = Bool(False, help="Enable or disable user changes")
33 33 description = Unicode(help="Description of the value this widget represents")
34 34 submits = Int(0, help="Used to capture and fire submission ")
35 scroll_to_bottoms = Int(0, help="Used to scroll a TextAreaView to the bottom")
35 36
36 37
37 38 def __init__(self, **kwargs):
@@ -39,6 +40,10 b' class StringWidget(Widget):'
39 40 self._submission_callbacks = []
40 41
41 42
43 def scroll_to_bottom(self):
44 self.scroll_to_bottoms += 1
45
46
42 47 def on_submit(self, callback, remove=False):
43 48 """Register a callback to handle text submission (triggered when the
44 49 user clicks enter).
General Comments 0
You need to be logged in to leave comments. Login now