##// END OF EJS Templates
Done with major changes,...
Jonathan Frederic -
Show More
@@ -9,11 +9,13 define([
9 9 //--------------------------------------------------------------------
10 10 // WidgetManager class
11 11 //--------------------------------------------------------------------
12 var WidgetManager = function (comm_manager) {
12 var WidgetManager = function (comm_manager, keyboard_manager, notebook) {
13 13 // Public constructor
14 14 WidgetManager._managers.push(this);
15 15
16 16 // Attach a comm manager to the
17 this.keyboard_manager = keyboard_manager;
18 this.notebook = notebook;
17 19 this.comm_manager = comm_manager;
18 20 this._models = {}; /* Dictionary of model ids and model instances */
19 21
@@ -76,11 +78,13 define([
76 78 // Have the IPython keyboard manager disable its event
77 79 // handling so the widget can capture keyboard input.
78 80 // Note, this is only done on the outer most widgets.
79 IPython.keyboard_manager.register_events(view.$el);
81 if (this.keyboard_manager) {
82 this.keyboard_manager.register_events(view.$el);
80 83
81 84 if (view.additional_elements) {
82 85 for (var i = 0; i < view.additional_elements.length; i++) {
83 IPython.keyboard_manager.register_events(view.additional_elements[i]);
86 this.keyboard_manager.register_events(view.additional_elements[i]);
87 }
84 88 }
85 89 }
86 90 };
@@ -111,8 +115,8 define([
111 115 WidgetManager.prototype.get_msg_cell = function (msg_id) {
112 116 var cell = null;
113 117 // First, check to see if the msg was triggered by cell execution.
114 if (IPython.notebook) {
115 cell = IPython.notebook.get_msg_cell(msg_id);
118 if (this.notebook) {
119 cell = this.notebook.get_msg_cell(msg_id);
116 120 }
117 121 if (cell !== null) {
118 122 return cell;
@@ -189,8 +193,5 define([
189 193 this._models[model_id] = widget_model;
190 194 };
191 195
192 // For backwards compatability.
193 IPython.WidgetManager = WidgetManager;
194
195 196 return WidgetManager;
196 197 });
@@ -208,20 +208,20 function(WidgetManager, _, Backbone){
208 208
209 209 _pack_models: function(value) {
210 210 // Replace models with model ids recursively.
211 var that = this;
212 var packed;
211 213 if (value instanceof Backbone.Model) {
212 214 return value.id;
213 215
214 216 } else if ($.isArray(value)) {
215 var packed = [];
216 var that = this;
217 packed = [];
217 218 _.each(value, function(sub_value, key) {
218 219 packed.push(that._pack_models(sub_value));
219 220 });
220 221 return packed;
221 222
222 223 } else if (value instanceof Object) {
223 var packed = {};
224 var that = this;
224 packed = {};
225 225 _.each(value, function(sub_value, key) {
226 226 packed[key] = that._pack_models(sub_value);
227 227 });
@@ -3,7 +3,8
3 3
4 4 define([
5 5 "widgets/js/widget",
6 ], function(widget){
6 "base/js/utils",
7 ], function(widget, utils){
7 8
8 9 var DropdownView = widget.DOMWidgetView.extend({
9 10 render : function(){
@@ -226,7 +227,7 define([
226 227 if (item.trim().length == 0) {
227 228 item_html = "&nbsp;";
228 229 } else {
229 item_html = IPython.utils.escape_html(item);
230 item_html = utils.escape_html(item);
230 231 }
231 232 var item_query = '[data-value="' + item + '"]';
232 233 var $item_element = that.$buttongroup.find(item_query);
@@ -3,12 +3,13
3 3
4 4 define([
5 5 "widgets/js/widget",
6 ], function(widget){
6 "base/js/utils",
7 ], function(widget, utils){
7 8
8 9 var AccordionView = widget.DOMWidgetView.extend({
9 10 render: function(){
10 11 // Called when view is rendered.
11 var guid = 'panel-group' + IPython.utils.uuid();
12 var guid = 'panel-group' + utils.uuid();
12 13 this.$el
13 14 .attr('id', guid)
14 15 .addClass('panel-group');
@@ -88,7 +89,7 define([
88 89 // Called when a child is added to children list.
89 90 var view = this.create_child_view(model);
90 91 var index = this.containers.length;
91 var uuid = IPython.utils.uuid();
92 var uuid = utils.uuid();
92 93 var accordion_group = $('<div />')
93 94 .addClass('panel panel-default')
94 95 .appendTo(this.$el);
@@ -141,7 +142,7 define([
141 142
142 143 render: function(){
143 144 // Called when view is rendered.
144 var uuid = 'tabs'+IPython.utils.uuid();
145 var uuid = 'tabs'+utils.uuid();
145 146 var that = this;
146 147 this.$tabs = $('<div />', {id: uuid})
147 148 .addClass('nav')
@@ -189,7 +190,7 define([
189 190 // Called when a child is added to children list.
190 191 var view = this.create_child_view(model);
191 192 var index = this.containers.length;
192 var uuid = IPython.utils.uuid();
193 var uuid = utils.uuid();
193 194
194 195 var that = this;
195 196 var tab = $('<li />')
General Comments 0
You need to be logged in to leave comments. Login now