Show More
@@ -60,28 +60,34 b' define([' | |||
|
60 | 60 | WidgetManager._save_callback = null; |
|
61 | 61 | |
|
62 | 62 | WidgetManager.register_widget_model = function (model_name, model_type) { |
|
63 | // Registers a widget model by name. | |
|
63 | /** | |
|
64 | * Registers a widget model by name. | |
|
65 | */ | |
|
64 | 66 | WidgetManager._model_types[model_name] = model_type; |
|
65 | 67 | }; |
|
66 | 68 | |
|
67 | 69 | WidgetManager.register_widget_view = function (view_name, view_type) { |
|
68 | // Registers a widget view by name. | |
|
70 | /** | |
|
71 | * Registers a widget view by name. | |
|
72 | */ | |
|
69 | 73 | WidgetManager._view_types[view_name] = view_type; |
|
70 | 74 | }; |
|
71 | 75 | |
|
72 | 76 | WidgetManager.set_state_callbacks = function (load_callback, save_callback, options) { |
|
73 | // Registers callbacks for widget state persistence. | |
|
74 | // | |
|
75 | // Parameters | |
|
76 | // ---------- | |
|
77 | // load_callback: function() | |
|
78 | // function that is called when the widget manager state should be | |
|
79 | // loaded. This function should return a promise for the widget | |
|
80 | // manager state. An empty state is an empty dictionary `{}`. | |
|
81 | // save_callback: function(state as dictionary) | |
|
82 | // function that is called when the notebook is saved or autosaved. | |
|
83 | // The current state of the widget manager is passed in as the first | |
|
84 | // argument. | |
|
77 | /** | |
|
78 | * Registers callbacks for widget state persistence. | |
|
79 | * | |
|
80 | * Parameters | |
|
81 | * ---------- | |
|
82 | * load_callback: function() | |
|
83 | * function that is called when the widget manager state should be | |
|
84 | * loaded. This function should return a promise for the widget | |
|
85 | * manager state. An empty state is an empty dictionary `{}`. | |
|
86 | * save_callback: function(state as dictionary) | |
|
87 | * function that is called when the notebook is saved or autosaved. | |
|
88 | * The current state of the widget manager is passed in as the first | |
|
89 | * argument. | |
|
90 | */ | |
|
85 | 91 | WidgetManager._load_callback = load_callback; |
|
86 | 92 | WidgetManager._save_callback = save_callback; |
|
87 | 93 | WidgetManager._get_state_options = options; |
@@ -313,23 +319,25 b' define([' | |||
|
313 | 319 | }; |
|
314 | 320 | |
|
315 | 321 | WidgetManager.prototype.get_state = function(options) { |
|
316 | // Asynchronously get the state of the widget manager. | |
|
317 | // | |
|
318 | // This includes all of the widget models and the cells that they are | |
|
319 | // displayed in. | |
|
320 | // | |
|
321 | // Parameters | |
|
322 | // ---------- | |
|
323 | // options: dictionary | |
|
324 | // Dictionary of options with the following contents: | |
|
325 | // only_displayed: (optional) boolean=false | |
|
326 | // Only return models with one or more displayed views. | |
|
327 | // not_live: (optional) boolean=false | |
|
328 | // Include models that have comms with severed connections. | |
|
329 | // | |
|
330 |
|
|
|
331 | // ------- | |
|
332 | // Promise for a state dictionary | |
|
322 | /** | |
|
323 | * Asynchronously get the state of the widget manager. | |
|
324 | * | |
|
325 | * This includes all of the widget models and the cells that they are | |
|
326 | * displayed in. | |
|
327 | * | |
|
328 | * Parameters | |
|
329 | * ---------- | |
|
330 | * options: dictionary | |
|
331 | * Dictionary of options with the following contents: | |
|
332 | * only_displayed: (optional) boolean=false | |
|
333 | * Only return models with one or more displayed views. | |
|
334 | * not_live: (optional) boolean=false | |
|
335 | * Include models that have comms with severed connections. | |
|
336 | * | |
|
337 | * Returns | |
|
338 | * ------- | |
|
339 | * Promise for a state dictionary | |
|
340 | */ | |
|
333 | 341 | var that = this; |
|
334 | 342 | return utils.resolve_promises_dict(this._models).then(function(models) { |
|
335 | 343 | var state = {}; |
@@ -366,11 +374,13 b' define([' | |||
|
366 | 374 | }; |
|
367 | 375 | |
|
368 | 376 | WidgetManager.prototype.set_state = function(state) { |
|
369 | // Set the notebook's state. | |
|
370 | // | |
|
371 | // Reconstructs all of the widget models and attempts to redisplay the | |
|
372 | // widgets in the appropriate cells by cell index. | |
|
373 | ||
|
377 | /** | |
|
378 | * Set the notebook's state. | |
|
379 | * | |
|
380 | * Reconstructs all of the widget models and attempts to redisplay the | |
|
381 | * widgets in the appropriate cells by cell index. | |
|
382 | */ | |
|
383 | ||
|
374 | 384 | // Get the kernel when it's available. |
|
375 | 385 | var that = this; |
|
376 | 386 | return this._get_connected_kernel().then(function(kernel) { |
@@ -423,7 +433,9 b' define([' | |||
|
423 | 433 | }; |
|
424 | 434 | |
|
425 | 435 | WidgetManager.prototype._get_connected_kernel = function() { |
|
426 | // Gets a promise for a connected kernel. | |
|
436 | /** | |
|
437 | * Gets a promise for a connected kernel | |
|
438 | */ | |
|
427 | 439 | var that = this; |
|
428 | 440 | return new Promise(function(resolve, reject) { |
|
429 | 441 | if (that.comm_manager && |
General Comments 0
You need to be logged in to leave comments.
Login now