##// END OF EJS Templates
Added sync=True to all view name attrs
Added sync=True to all view name attrs

File last commit:

r14583:ecbe638b
r14590:bff850b0
Show More
widget_string.js
202 lines | 7.0 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Added standard IPY JS header to widget JS files.
r14366 //----------------------------------------------------------------------------
// Copyright (C) 2013 The IPython Development Team
//
// Distributed under the terms of the BSD License. The full license is in
// the file COPYING, distributed as part of this software.
//----------------------------------------------------------------------------
//============================================================================
// StringWidget
//============================================================================
/**
* @module IPython
* @namespace IPython
**/
Jonathan Frederic
Updated require.js references
r14537 define(["notebook/js/widgets/widget"], function(widget_manager){
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 var StringWidgetModel = IPython.WidgetModel.extend({});
Jonathan Frederic
Changed require.js load calls to allow require.js to pass...
r14374 widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel);
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
s/BaseWidgetView/WidgetView and s/WidgetView/DOMWidgetView
r14564 var HTMLView = IPython.DOMWidgetView.extend({
Jonathan Frederic
Lots of updates to widget(s) js...
r14263
// Called when view is rendered.
render : function(){
this.update(); // Set defaults.
},
update : function(){
Jonathan Frederic
make JS update comment more descriptive (english)
r14568 // Update the contents of this view
//
// Called when the model is changed. The model may have been
// changed by another view or by a state update from the back-end.
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268 this.$el.html(this.model.get('value'));
Jonathan Frederic
Many checks off the todo list, test fixes
r14583 return HTMLView.__super__.update.apply(this);
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 },
});
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
s/LabelView/HTMLView
r14446 widget_manager.register_widget_view('HTMLView', HTMLView);
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
Added LatexView
r14447
Jonathan Frederic
s/BaseWidgetView/WidgetView and s/WidgetView/DOMWidgetView
r14564 var LatexView = IPython.DOMWidgetView.extend({
Jonathan Frederic
Added LatexView
r14447
// Called when view is rendered.
render : function(){
this.update(); // Set defaults.
},
update : function(){
Jonathan Frederic
make JS update comment more descriptive (english)
r14568 // Update the contents of this view
//
// Called when the model is changed. The model may have been
// changed by another view or by a state update from the back-end.
Jonathan Frederic
Added LatexView
r14447 this.$el.html(this.model.get('value'));
Jonathan Frederic
Remove uneccessary lines in String.js
r14448 MathJax.Hub.Queue(["Typeset",MathJax.Hub,this.$el.get(0)]);
Jonathan Frederic
Many checks off the todo list, test fixes
r14583 return LatexView.__super__.update.apply(this);
Jonathan Frederic
Added LatexView
r14447 },
});
widget_manager.register_widget_view('LatexView', LatexView);
Jonathan Frederic
s/BaseWidgetView/WidgetView and s/WidgetView/DOMWidgetView
r14564 var TextAreaView = IPython.DOMWidgetView.extend({
Jonathan Frederic
Lots of updates to widget(s) js...
r14263
// Called when view is rendered.
Jonathan Frederic
Made scroll to bottom use msgs...
r14403 render: function(){
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.$el
Jonathan Frederic
MAJOR CSS FIXES...
r14295 .addClass('widget-hbox')
Jonathan Frederic
LOTS OF WIDGET CHANGES...
r14278 .html('');
Jonathan Frederic
Added labels to basic widgets
r14292 this.$label = $('<div />')
.appendTo(this.$el)
Jonathan Frederic
Fixed vertical widget labels
r14297 .addClass('widget-hlabel')
Jonathan Frederic
Added labels to basic widgets
r14292 .hide();
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.$textbox = $('<textarea />')
.attr('rows', 5)
Jonathan Frederic
MAJOR CSS FIXES...
r14295 .addClass('widget-text')
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 .appendTo(this.$el);
Jonathan Frederic
Set default element to be styled in built-in views
r14314 this.$el_to_style = this.$textbox; // Set default element to style
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.update(); // Set defaults.
Jonathan Frederic
Made scroll to bottom use msgs...
r14403
Jason Grout
Remove the automatic _children_attr and _children_lists_attr....
r14487 this.model.on('msg:custom', $.proxy(this._handle_textarea_msg, this));
Jonathan Frederic
Made scroll to bottom use msgs...
r14403 },
_handle_textarea_msg: function (content){
if (content.method == "scroll_to_bottom") {
this.scroll_to_bottom();
}
},
scroll_to_bottom: function (){
this.$textbox.scrollTop(this.$textbox[0].scrollHeight);
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 },
Jonathan Frederic
Made scroll to bottom use msgs...
r14403
Jonathan Frederic
Lots of updates to widget(s) js...
r14263
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 update: function(options){
Jonathan Frederic
make JS update comment more descriptive (english)
r14568 // Update the contents of this view
//
// Called when the model is changed. The model may have been
// changed by another view or by a state update from the back-end.
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 if (options === undefined || options.updated_view != this) {
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.$textbox.val(this.model.get('value'));
Jonathan Frederic
Added labels to basic widgets
r14292
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 var disabled = this.model.get('disabled');
this.$textbox.prop('disabled', disabled);
Jonathan Frederic
Made TextArea and TextBox views compatable with disabled property
r14302
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 var description = this.model.get('description');
if (description.length === 0) {
this.$label.hide();
} else {
this.$label.html(description);
this.$label.show();
}
Jonathan Frederic
Added labels to basic widgets
r14292 }
Jonathan Frederic
Many checks off the todo list, test fixes
r14583 return TextAreaView.__super__.update.apply(this);
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 },
Jonathan Frederic
Made scroll to bottom use msgs...
r14403 events: {"keyup textarea": "handleChanging",
"paste textarea": "handleChanging",
"cut textarea": "handleChanging"},
Jonathan Frederic
Lots of updates to widget(s) js...
r14263
// Handles and validates user input.
handleChanging: function(e) {
Jonathan Frederic
comment model.set, so we know that it triggers update on other views
r14569
// Calling model.set will trigger all of the other views of the
// model to update.
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 this.model.set('value', e.target.value, {updated_view: this});
Jonathan Frederic
Moved touch logic out of model into view....
r14482 this.touch();
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 },
});
Jonathan Frederic
Changed require.js load calls to allow require.js to pass...
r14374 widget_manager.register_widget_view('TextAreaView', TextAreaView);
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
s/BaseWidgetView/WidgetView and s/WidgetView/DOMWidgetView
r14564 var TextBoxView = IPython.DOMWidgetView.extend({
Jonathan Frederic
Lots of updates to widget(s) js...
r14263
// Called when view is rendered.
Jonathan Frederic
Made scroll to bottom use msgs...
r14403 render: function(){
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.$el
Jonathan Frederic
MAJOR CSS FIXES...
r14295 .addClass('widget-hbox-single')
Jonathan Frederic
LOTS OF WIDGET CHANGES...
r14278 .html('');
Jonathan Frederic
Added labels to basic widgets
r14292 this.$label = $('<div />')
Jonathan Frederic
Fixed vertical widget labels
r14297 .addClass('widget-hlabel')
Jonathan Frederic
Added labels to basic widgets
r14292 .appendTo(this.$el)
.hide();
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.$textbox = $('<input type="text" />')
.addClass('input')
Jonathan Frederic
MAJOR CSS FIXES...
r14295 .addClass('widget-text')
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 .appendTo(this.$el);
Jonathan Frederic
Set default element to be styled in built-in views
r14314 this.$el_to_style = this.$textbox; // Set default element to style
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.update(); // Set defaults.
},
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 update: function(options){
Jonathan Frederic
make JS update comment more descriptive (english)
r14568 // Update the contents of this view
//
// Called when the model is changed. The model may have been
// changed by another view or by a state update from the back-end.
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 if (options === undefined || options.updated_view != this) {
if (this.$textbox.val() != this.model.get('value')) {
this.$textbox.val(this.model.get('value'));
}
var disabled = this.model.get('disabled');
this.$textbox.prop('disabled', disabled);
var description = this.model.get('description');
if (description.length === 0) {
this.$label.hide();
} else {
this.$label.html(description);
this.$label.show();
}
Jonathan Frederic
Added labels to basic widgets
r14292 }
Jonathan Frederic
Many checks off the todo list, test fixes
r14583 return TextBoxView.__super__.update.apply(this);
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 },
Jonathan Frederic
Made scroll to bottom use msgs...
r14403 events: {"keyup input": "handleChanging",
"paste input": "handleChanging",
"cut input": "handleChanging",
"keypress input": "handleKeypress"},
Jonathan Frederic
Lots of updates to widget(s) js...
r14263
// Handles and validates user input.
handleChanging: function(e) {
Jonathan Frederic
comment model.set, so we know that it triggers update on other views
r14569
// Calling model.set will trigger all of the other views of the
// model to update.
Jonathan Frederic
add locks to update everywhere by using options to pass this...
r14570 this.model.set('value', e.target.value, {updated_view: this});
Jonathan Frederic
Moved touch logic out of model into view....
r14482 this.touch();
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 },
Jonathan Frederic
Added TextBox submit event
r14391
// Handles text submition
handleKeypress: function(e) {
if (e.keyCode == 13) { // Return key
Jonathan Frederic
Made scroll to bottom use msgs...
r14403 this.send({event: 'submit'});
Jonathan Frederic
Added TextBox submit event
r14391 }
},
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 });
Jonathan Frederic
Changed require.js load calls to allow require.js to pass...
r14374 widget_manager.register_widget_view('TextBoxView', TextBoxView);
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 });