mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-21 04:10:17 +08:00
Fixed some spacing in widget.js
This commit is contained in:
parent
5678617d8f
commit
8120778e5a
@ -23,14 +23,14 @@
|
|||||||
// elsewhere.
|
// elsewhere.
|
||||||
define(["components/underscore/underscore-min",
|
define(["components/underscore/underscore-min",
|
||||||
"components/backbone/backbone-min",
|
"components/backbone/backbone-min",
|
||||||
], function(underscore, backbone){
|
], function (underscore, backbone) {
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// WidgetModel class
|
// WidgetModel class
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
var WidgetModel = Backbone.Model.extend({
|
var WidgetModel = Backbone.Model.extend({
|
||||||
constructor: function(comm_manager, comm, widget_manager) {
|
constructor: function (comm_manager, comm, widget_manager) {
|
||||||
this.comm_manager = comm_manager;
|
this.comm_manager = comm_manager;
|
||||||
this.widget_manager = widget_manager;
|
this.widget_manager = widget_manager;
|
||||||
this.pending_msgs = 0;
|
this.pending_msgs = 0;
|
||||||
@ -51,7 +51,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
update_other_views: function(caller) {
|
update_other_views: function (caller) {
|
||||||
this.last_modified_view = caller;
|
this.last_modified_view = caller;
|
||||||
this.save(this.changedAttributes(), {patch: true});
|
this.save(this.changedAttributes(), {patch: true});
|
||||||
|
|
||||||
@ -64,7 +64,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
send: function(content, cell) {
|
send: function (content, cell) {
|
||||||
|
|
||||||
// Used the last modified view as the sender of the message. This
|
// Used the last modified view as the sender of the message. This
|
||||||
// will insure that any python code triggered by the sent message
|
// will insure that any python code triggered by the sent message
|
||||||
@ -131,7 +131,7 @@
|
|||||||
// Handle incomming comm msg.
|
// Handle incomming comm msg.
|
||||||
_handle_comm_msg: function (msg) {
|
_handle_comm_msg: function (msg) {
|
||||||
var method = msg.content.data.method;
|
var method = msg.content.data.method;
|
||||||
switch (method){
|
switch (method) {
|
||||||
case 'display':
|
case 'display':
|
||||||
|
|
||||||
// Try to get the cell.
|
// Try to get the cell.
|
||||||
@ -171,7 +171,7 @@
|
|||||||
try {
|
try {
|
||||||
for (var key in state) {
|
for (var key in state) {
|
||||||
if (state.hasOwnProperty(key)) {
|
if (state.hasOwnProperty(key)) {
|
||||||
if (key == "_css"){
|
if (key == "_css") {
|
||||||
|
|
||||||
// Set the css value of the model as an attribute
|
// Set the css value of the model as an attribute
|
||||||
// instead of a backbone trait because we are only
|
// instead of a backbone trait because we are only
|
||||||
@ -244,7 +244,7 @@
|
|||||||
// normal. If this is a patch operation, just send the
|
// normal. If this is a patch operation, just send the
|
||||||
// changes.
|
// changes.
|
||||||
var send_json = model_json;
|
var send_json = model_json;
|
||||||
if (method=='patch') {
|
if (method =='patch') {
|
||||||
send_json = {};
|
send_json = {};
|
||||||
for (attr in options.attrs) {
|
for (attr in options.attrs) {
|
||||||
send_json[attr] = options.attrs[attr];
|
send_json[attr] = options.attrs[attr];
|
||||||
@ -270,7 +270,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
_handle_view_displayed: function(view) {
|
_handle_view_displayed: function (view) {
|
||||||
if (this._view_displayed_callback) {
|
if (this._view_displayed_callback) {
|
||||||
try {
|
try {
|
||||||
this._view_displayed_callback(view);
|
this._view_displayed_callback(view);
|
||||||
@ -361,7 +361,7 @@
|
|||||||
|
|
||||||
// Handle when the view element is remove from the page.
|
// Handle when the view element is remove from the page.
|
||||||
var that = this;
|
var that = this;
|
||||||
view.$el.on("remove", function(){
|
view.$el.on("remove", function () {
|
||||||
var index = that.views.indexOf(view);
|
var index = that.views.indexOf(view);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
that.views.splice(index, 1);
|
that.views.splice(index, 1);
|
||||||
@ -407,14 +407,14 @@
|
|||||||
output : handle_output,
|
output : handle_output,
|
||||||
clear_output : handle_clear_output,
|
clear_output : handle_clear_output,
|
||||||
|
|
||||||
status : function(msg){
|
status : function (msg) {
|
||||||
that._handle_status(cell, msg);
|
that._handle_status(cell, msg);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Special function only registered by widget messages.
|
// Special function only registered by widget messages.
|
||||||
// Allows us to get the cell for a message so we know
|
// Allows us to get the cell for a message so we know
|
||||||
// where to add widgets if the code requires it.
|
// where to add widgets if the code requires it.
|
||||||
get_cell : function() {
|
get_cell : function () {
|
||||||
return cell;
|
return cell;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -460,19 +460,19 @@
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
var WidgetView = Backbone.View.extend({
|
var WidgetView = Backbone.View.extend({
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function () {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
this.model.on('sync',this.update,this);
|
this.model.on('sync',this.update,this);
|
||||||
},
|
},
|
||||||
|
|
||||||
add_class: function(selector, class_list){
|
add_class: function (selector, class_list) {
|
||||||
var elements = this._get_selector_element(selector);
|
var elements = this._get_selector_element(selector);
|
||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
elements.addClass(class_list);
|
elements.addClass(class_list);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
remove_class: function(selector, class_list){
|
remove_class: function (selector, class_list) {
|
||||||
var elements = this._get_selector_element(selector);
|
var elements = this._get_selector_element(selector);
|
||||||
if (elements.length > 0) {
|
if (elements.length > 0) {
|
||||||
elements.removeClass(class_list);
|
elements.removeClass(class_list);
|
||||||
@ -480,11 +480,11 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
send: function(content) {
|
send: function (content) {
|
||||||
this.model.send(content, this.cell);
|
this.model.send(content, this.cell);
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function () {
|
||||||
if (this.model.get('visible') !== undefined) {
|
if (this.model.get('visible') !== undefined) {
|
||||||
if (this.visible != this.model.get('visible')) {
|
if (this.visible != this.model.get('visible')) {
|
||||||
this.visible = this.model.get('visible');
|
this.visible = this.model.get('visible');
|
||||||
@ -515,7 +515,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_get_selector_element: function(selector) {
|
_get_selector_element: function (selector) {
|
||||||
// Get the elements via the css selector. If the selector is
|
// Get the elements via the css selector. If the selector is
|
||||||
// blank, apply the style to the $el_to_style element. If
|
// blank, apply the style to the $el_to_style element. If
|
||||||
// the $el_to_style element is not defined, use apply the
|
// the $el_to_style element is not defined, use apply the
|
||||||
@ -536,13 +536,13 @@
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// WidgetManager class
|
// WidgetManager class
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
var WidgetManager = function(){
|
var WidgetManager = function () {
|
||||||
this.comm_manager = null;
|
this.comm_manager = null;
|
||||||
this.widget_model_types = {};
|
this.widget_model_types = {};
|
||||||
this.widget_view_types = {};
|
this.widget_view_types = {};
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
Backbone.sync = function(method, model, options, error) {
|
Backbone.sync = function (method, model, options, error) {
|
||||||
var result = model._handle_sync(method, options);
|
var result = model._handle_sync(method, options);
|
||||||
if (options.success) {
|
if (options.success) {
|
||||||
options.success(result);
|
options.success(result);
|
||||||
|
Loading…
Reference in New Issue
Block a user