Show More
@@ -66,37 +66,37 b'' | |||
|
66 | 66 | WidgetManager.prototype.register_widget_view = function (widget_view_name, widget_view_type) { |
|
67 | 67 | this.widget_view_types[widget_view_name] = widget_view_type; |
|
68 | 68 | }; |
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
69 | WidgetManager.prototype.handle_msg = function(msg, model) { | |
|
70 | var method = msg.content.data.method; | |
|
71 | switch (method) { | |
|
72 | case 'display': | |
|
73 | var cell = this.get_msg_cell(msg.parent_header.msg_id); | |
|
74 | if (cell === null) { | |
|
75 | console.log("Could not determine where the display" + | |
|
76 | " message was from. Widget will not be displayed"); | |
|
77 | } else { | |
|
78 | var view = this.create_view(model, | |
|
79 | msg.content.data.view_name, cell); | |
|
80 | if (view !== undefined | |
|
81 | && cell.widget_subarea !== undefined | |
|
82 | && cell.widget_subarea !== null) { | |
|
83 | 83 | cell.widget_area.show(); |
|
84 | 84 | cell.widget_subarea.append(view.$el); |
|
85 | } | |
|
86 | } | |
|
87 |
|
|
|
88 |
|
|
|
89 | } | |
|
90 | ||
|
91 |
|
|
|
92 |
|
|
|
85 | } | |
|
86 | } | |
|
87 | break; | |
|
88 | } | |
|
89 | } | |
|
90 | ||
|
91 | WidgetManager.prototype.create_view = function(model, view_name, cell) { | |
|
92 | view_name = view_name || model.get('default_view_name'); | |
|
93 | 93 | var ViewType = this.widget_view_types[view_name]; |
|
94 | 94 | if (ViewType !== undefined && ViewType !== null) { |
|
95 | 95 | var view = new ViewType({model: model, widget_manager: this, cell: cell}); |
|
96 | 96 | view.render(); |
|
97 |
|
|
|
98 |
|
|
|
99 | /* | |
|
97 | model.views.push(view); | |
|
98 | model.on('destroy', view.remove, view); | |
|
99 | /* | |
|
100 | 100 | // TODO: handle view deletion. Don't forget to delete child views |
|
101 | 101 | var that = this; |
|
102 | 102 | view.$el.on("remove", function () { |
@@ -108,10 +108,10 b'' | |||
|
108 | 108 | |
|
109 | 109 | // Close the comm if there are no views left. |
|
110 | 110 | if (that.views.length() === 0) { |
|
111 |
|
|
|
111 | //trigger comm close event? | |
|
112 | 112 | } |
|
113 | 113 | |
|
114 |
|
|
|
114 | ||
|
115 | 115 | if (that.comm !== undefined) { |
|
116 | 116 | that.comm.close(); |
|
117 | 117 | delete that.comm.model; // Delete ref so GC will collect widget model. |
@@ -119,20 +119,20 b'' | |||
|
119 | 119 | } |
|
120 | 120 | delete that.widget_id; // Delete id from model so widget manager cleans up. |
|
121 | 121 | }); |
|
122 | */ | |
|
122 | */ | |
|
123 | 123 | return view; |
|
124 | 124 | } |
|
125 | 125 | }, |
|
126 | 126 | |
|
127 | 127 | WidgetManager.prototype.get_msg_cell = function (msg_id) { |
|
128 |
|
|
|
128 | var cell = null; | |
|
129 | 129 | // First, check to see if the msg was triggered by cell execution. |
|
130 | 130 | if (IPython.notebook !== undefined && IPython.notebook !== null) { |
|
131 | 131 | cell = IPython.notebook.get_msg_cell(msg_id); |
|
132 | 132 | } |
|
133 |
|
|
|
134 |
|
|
|
135 |
|
|
|
133 | if (cell !== null) { | |
|
134 | return cell | |
|
135 | } | |
|
136 | 136 | // Second, check to see if a get_cell callback was defined |
|
137 | 137 | // for the message. get_cell callbacks are registered for |
|
138 | 138 | // widget messages, so this block is actually checking to see if the |
@@ -292,7 +292,7 b' function(widget_manager, underscore, backbone){' | |||
|
292 | 292 | elements.removeClass(class_list); |
|
293 | 293 | } |
|
294 | 294 | }, |
|
295 | ||
|
295 | ||
|
296 | 296 | update: function () { |
|
297 | 297 | // the very first update seems to happen before the element is finished rendering |
|
298 | 298 | // so we use setTimeout to give the element time to render |
@@ -119,10 +119,10 b' define(["notebook/js/widgets/base"], function(widget_manager){' | |||
|
119 | 119 | |
|
120 | 120 | var TabView = IPython.WidgetView.extend({ |
|
121 | 121 | |
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
|
125 | }, | |
|
122 | initialize: function() { | |
|
123 | this.containers = []; | |
|
124 | IPython.WidgetView.prototype.initialize.apply(this, arguments); | |
|
125 | }, | |
|
126 | 126 | |
|
127 | 127 | render: function(){ |
|
128 | 128 | var uuid = 'tabs'+IPython.utils.uuid(); |
@@ -134,11 +134,11 b' define(["notebook/js/widgets/base"], function(widget_manager){' | |||
|
134 | 134 | this.$tab_contents = $('<div />', {id: uuid + 'Content'}) |
|
135 | 135 | .addClass('tab-content') |
|
136 | 136 | .appendTo(this.$el); |
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
|
137 | var children = this.model.get('children'); | |
|
138 | for (var i in children) { | |
|
139 | this.add_child_view(this.child_view(children[i])) | |
|
140 | } | |
|
141 | this.update(); | |
|
142 | 142 | }, |
|
143 | 143 | |
|
144 | 144 | update: function() { |
General Comments 0
You need to be logged in to leave comments.
Login now