mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-12 11:45:38 +08:00
Lots of updates to widget(s) js
Use require.js (again) Allow IntTextView and FloatTextView to be used without min/max
This commit is contained in:
parent
f7d96da585
commit
40a923c5b6
@ -17,12 +17,19 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
// Only run once on a notebook.
|
||||
if (IPython.notebook.widget_manager == undefined) {
|
||||
// Use require.js 'define' method so that require.js is intelligent enough to
|
||||
// syncronously load everything within this file when it is being 'required'
|
||||
// elsewhere.
|
||||
define(["static/components/underscore/underscore-min.js",
|
||||
"static/components/backbone/backbone-min.js",
|
||||
], function(){
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// Only run once on a notebook.
|
||||
if (IPython.notebook.widget_manager == undefined) {
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// WidgetModel class
|
||||
//-----------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------
|
||||
var WidgetModel = Backbone.Model.extend({
|
||||
apply: function(sender) {
|
||||
this.save();
|
||||
@ -37,9 +44,9 @@ if (IPython.notebook.widget_manager == undefined) {
|
||||
});
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------
|
||||
// WidgetView class
|
||||
//-----------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------
|
||||
var WidgetView = Backbone.View.extend({
|
||||
|
||||
initialize: function() {
|
||||
@ -76,9 +83,9 @@ if (IPython.notebook.widget_manager == undefined) {
|
||||
});
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------
|
||||
// WidgetManager class
|
||||
//-----------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------
|
||||
// Public constructor
|
||||
var WidgetManager = function(comm_manager){
|
||||
this.comm_manager = comm_manager;
|
||||
@ -250,4 +257,5 @@ if (IPython.notebook.widget_manager == undefined) {
|
||||
|
||||
IPython.notebook.widget_manager = new WidgetManager(IPython.notebook.kernel.comm_manager);
|
||||
|
||||
};
|
||||
};
|
||||
});
|
||||
|
@ -1,7 +1,8 @@
|
||||
var ContainerModel = IPython.WidgetModel.extend({});
|
||||
IPython.notebook.widget_manager.register_widget_model('container_widget', ContainerModel);
|
||||
require(["notebook/js/widget"], function(){
|
||||
var ContainerModel = IPython.WidgetModel.extend({});
|
||||
IPython.notebook.widget_manager.register_widget_model('container_widget', ContainerModel);
|
||||
|
||||
var ContainerView = IPython.WidgetView.extend({
|
||||
var ContainerView = IPython.WidgetView.extend({
|
||||
|
||||
render : function(){
|
||||
this.$el.html('');
|
||||
@ -12,6 +13,7 @@ var ContainerView = IPython.WidgetView.extend({
|
||||
},
|
||||
|
||||
update : function(){},
|
||||
});
|
||||
});
|
||||
|
||||
IPython.notebook.widget_manager.register_widget_view('ContainerView', ContainerView);
|
||||
IPython.notebook.widget_manager.register_widget_view('ContainerView', ContainerView);
|
||||
});
|
@ -1,7 +1,8 @@
|
||||
var SelectionWidgetModel = IPython.WidgetModel.extend({});
|
||||
IPython.notebook.widget_manager.register_widget_model('SelectionWidgetModel', SelectionWidgetModel);
|
||||
require(["notebook/js/widget"], function(){
|
||||
var SelectionWidgetModel = IPython.WidgetModel.extend({});
|
||||
IPython.notebook.widget_manager.register_widget_model('SelectionWidgetModel', SelectionWidgetModel);
|
||||
|
||||
var DropdownView = IPython.WidgetView.extend({
|
||||
var DropdownView = IPython.WidgetView.extend({
|
||||
|
||||
// Called when view is rendered.
|
||||
render : function(){
|
||||
@ -60,11 +61,11 @@ var DropdownView = IPython.WidgetView.extend({
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
IPython.notebook.widget_manager.register_widget_view('DropdownView', DropdownView);
|
||||
IPython.notebook.widget_manager.register_widget_view('DropdownView', DropdownView);
|
||||
|
||||
var RadioButtonView = IPython.WidgetView.extend({
|
||||
var RadioButtonsView = IPython.WidgetView.extend({
|
||||
|
||||
// Called when view is rendered.
|
||||
render : function(){
|
||||
@ -124,12 +125,12 @@ var RadioButtonView = IPython.WidgetView.extend({
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
IPython.notebook.widget_manager.register_widget_view('RadioButtonView', RadioButtonView);
|
||||
IPython.notebook.widget_manager.register_widget_view('RadioButtonsView', RadioButtonsView);
|
||||
|
||||
|
||||
var ToggleButtonView = IPython.WidgetView.extend({
|
||||
var ToggleButtonsView = IPython.WidgetView.extend({
|
||||
|
||||
// Called when view is rendered.
|
||||
render : function(){
|
||||
@ -189,6 +190,7 @@ var ToggleButtonView = IPython.WidgetView.extend({
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
IPython.notebook.widget_manager.register_widget_view('ToggleButtonView', ToggleButtonView);
|
||||
IPython.notebook.widget_manager.register_widget_view('ToggleButtonsView', ToggleButtonsView);
|
||||
});
|
||||
|
@ -1,7 +1,30 @@
|
||||
var StringWidgetModel = IPython.WidgetModel.extend({});
|
||||
IPython.notebook.widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel);
|
||||
require(["notebook/js/widget"], function(){
|
||||
var StringWidgetModel = IPython.WidgetModel.extend({});
|
||||
IPython.notebook.widget_manager.register_widget_model('StringWidgetModel', StringWidgetModel);
|
||||
|
||||
var TextareaView = IPython.WidgetView.extend({
|
||||
var LabelView = IPython.WidgetView.extend({
|
||||
|
||||
// Called when view is rendered.
|
||||
render : function(){
|
||||
this.$el
|
||||
.html('');
|
||||
this.$label = $('<div />')
|
||||
.addClass(this.model.comm.comm_id)
|
||||
.appendTo(this.$el);
|
||||
this.update(); // Set defaults.
|
||||
},
|
||||
|
||||
// Handles: Backend -> Frontend Sync
|
||||
// Frontent -> Frontend Sync
|
||||
update : function(){
|
||||
this.$label.html(this.model.get('value'));
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
IPython.notebook.widget_manager.register_widget_view('LabelView', LabelView);
|
||||
|
||||
var TextareaView = IPython.WidgetView.extend({
|
||||
|
||||
// Called when view is rendered.
|
||||
render : function(){
|
||||
@ -33,11 +56,11 @@ var TextareaView = IPython.WidgetView.extend({
|
||||
this.model.apply(this);
|
||||
this.user_invoked_update = false;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
IPython.notebook.widget_manager.register_widget_view('TextareaView', TextareaView);
|
||||
IPython.notebook.widget_manager.register_widget_view('TextareaView', TextareaView);
|
||||
|
||||
var TextboxView = IPython.WidgetView.extend({
|
||||
var TextboxView = IPython.WidgetView.extend({
|
||||
|
||||
// Called when view is rendered.
|
||||
render : function(){
|
||||
@ -69,6 +92,7 @@ var TextboxView = IPython.WidgetView.extend({
|
||||
this.model.apply(this);
|
||||
this.user_invoked_update = false;
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
IPython.notebook.widget_manager.register_widget_view('TextboxView', TextboxView);
|
||||
IPython.notebook.widget_manager.register_widget_view('TextboxView', TextboxView);
|
||||
});
|
||||
|
@ -71,8 +71,6 @@
|
||||
<script src="{{static_url("components/jquery/jquery.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/jquery-ui/ui/minified/jquery-ui.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/bootstrap/bootstrap/js/bootstrap.min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/underscore/underscore-min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("components/backbone/backbone-min.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("base/js/namespace.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("base/js/page.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{static_url("auth/js/loginwidget.js") }}" type="text/javascript" charset="utf-8"></script>
|
||||
|
Loading…
Reference in New Issue
Block a user