##// END OF EJS Templates
fix js/Python WidgetManager symmetry...
MinRK -
Show More
@@ -6,10 +6,10 b''
6 6 //----------------------------------------------------------------------------
7 7
8 8 //============================================================================
9 // Cell
9 // Widget and WidgetManager bases
10 10 //============================================================================
11 11 /**
12 * An extendable module that provide base functionnality to create cell for notebook.
12 * Base Widget classes
13 13 * @module IPython
14 14 * @namespace IPython
15 15 * @submodule widget
@@ -35,7 +35,7 b' var IPython = (function (IPython) {'
35 35 var msg_types = ['widget_create', 'widget_destroy', 'widget_update'];
36 36 for (var i = 0; i < msg_types.length; i++) {
37 37 var msg_type = msg_types[i];
38 kernel.register_iopub_handler(msg_type, $.proxy(this['handle_' + msg_type], this));
38 kernel.register_iopub_handler(msg_type, $.proxy(this[msg_type], this));
39 39 }
40 40 };
41 41
@@ -44,10 +44,8 b' var IPython = (function (IPython) {'
44 44 this.widget_types[widget_type] = constructor;
45 45 };
46 46
47 WidgetManager.prototype.handle_widget_create = function (msg) {
47 WidgetManager.prototype.widget_create = function (msg) {
48 48 var content = msg.content;
49 console.log("handle create", content);
50 console.log(this.widget_types);
51 49 var constructor = this.widget_types[content.widget_type];
52 50 if (constructor === undefined) {
53 51 console.log("No such widget type registered: ", content.widget_type);
@@ -58,9 +56,8 b' var IPython = (function (IPython) {'
58 56 this.widgets[content.widget_id] = widget;
59 57 };
60 58
61 WidgetManager.prototype.handle_widget_destroy = function (msg) {
59 WidgetManager.prototype.widget_destroy = function (msg) {
62 60 var content = msg.content;
63 console.log("handle destroy", content);
64 61 var widget = this.widgets[content.widget_id];
65 62 if (widget === undefined) {
66 63 return;
@@ -69,9 +66,8 b' var IPython = (function (IPython) {'
69 66 widget.handle_destroy(content.data);
70 67 };
71 68
72 WidgetManager.prototype.handle_widget_update = function (msg) {
69 WidgetManager.prototype.widget_update = function (msg) {
73 70 var content = msg.content;
74 console.log("handle update", content);
75 71 var widget = this.widgets[content.widget_id];
76 72 if (widget === undefined) {
77 73 return;
@@ -84,27 +80,22 b' var IPython = (function (IPython) {'
84 80 //-----------------------------------------------------------------------
85 81
86 82 var Widget = function (kernel, content) {
87 console.log('widget!', this, kernel, content);
88 83 this.kernel = kernel;
84 if (!content) return;
89 85 this.widget_id = content.widget_id;
90 86 this.handle_create(content.data);
91 87 };
92 88
93 89 Widget.prototype.handle_create = function (data) {
94 // base class init does nothing
95 console.log("handle_create", this, data);
96 90 };
97 91
98 92 Widget.prototype.handle_update = function (data) {
99 console.log("handle_update", this, data);
100 93 };
101 94
102 95 Widget.prototype.handle_destroy = function (data) {
103 console.log("handle_destroy", this, data);
104 96 };
105 97
106 98 Widget.prototype.update = function (data) {
107 console.log("update", this, data);
108 99 var content = {
109 100 widget_id : this.widget_id,
110 101 data : data,
@@ -114,7 +105,6 b' var IPython = (function (IPython) {'
114 105
115 106
116 107 Widget.prototype.destroy = function (data) {
117 console.log("destroy", this, data);
118 108 var content = {
119 109 widget_id : this.widget_id,
120 110 data : data,
General Comments 0
You need to be logged in to leave comments. Login now