##// END OF EJS Templates
Attempt 1, HBox and VBox implementation.
Attempt 1, HBox and VBox implementation.

File last commit:

r14268:ca37a2a5
r14268:ca37a2a5
Show More
string.js
98 lines | 3.2 KiB | application/javascript | JavascriptLexer
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 require(["notebook/js/widget"], function(){
var StringWidgetModel = IPython.WidgetModel.extend({});
IPython.notebook.widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel);
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 var LabelView = IPython.WidgetView.extend({
// Called when view is rendered.
render : function(){
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268 this.$el = $('<div />')
.addClass('widget_item')
.addClass(this.model.comm.comm_id);
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 this.update(); // Set defaults.
},
// Handles: Backend -> Frontend Sync
// Frontent -> Frontend Sync
update : function(){
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268 this.$el.html(this.model.get('value'));
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 },
});
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 IPython.notebook.widget_manager.register_widget_view('LabelView', LabelView);
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 var TextareaView = IPython.WidgetView.extend({
// Called when view is rendered.
render : function(){
this.$el
.html('')
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268 .addClass('widget_item')
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 .addClass(this.model.comm.comm_id);
this.$textbox = $('<textarea />')
.attr('rows', 5)
.appendTo(this.$el);
this.update(); // Set defaults.
},
// Handles: Backend -> Frontend Sync
// Frontent -> Frontend Sync
update : function(){
if (!this.user_invoked_update) {
this.$textbox.val(this.model.get('value'));
}
},
events: {"keyup textarea" : "handleChanging",
"paste textarea" : "handleChanging",
"cut textarea" : "handleChanging"},
// Handles and validates user input.
handleChanging: function(e) {
this.user_invoked_update = true;
this.model.set('value', e.target.value);
this.model.apply(this);
this.user_invoked_update = false;
},
});
IPython.notebook.widget_manager.register_widget_view('TextareaView', TextareaView);
Jonathan Frederic
Moved view code into model files
r14252
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 var TextboxView = IPython.WidgetView.extend({
// Called when view is rendered.
render : function(){
this.$el
.html('')
Jonathan Frederic
Attempt 1, HBox and VBox implementation.
r14268 .addClass('widget_item')
Jonathan Frederic
Lots of updates to widget(s) js...
r14263 .addClass(this.model.comm.comm_id);
this.$textbox = $('<input type="text" />')
.addClass('input')
.appendTo(this.$el);
this.update(); // Set defaults.
},
// Handles: Backend -> Frontend Sync
// Frontent -> Frontend Sync
update : function(){
if (!this.user_invoked_update) {
this.$textbox.val(this.model.get('value'));
}
},
events: {"keyup input" : "handleChanging",
"paste input" : "handleChanging",
"cut input" : "handleChanging"},
// Handles and validates user input.
handleChanging: function(e) {
this.user_invoked_update = true;
this.model.set('value', e.target.value);
this.model.apply(this);
this.user_invoked_update = false;
},
});
IPython.notebook.widget_manager.register_widget_view('TextboxView', TextboxView);
});