//---------------------------------------------------------------------------- // Copyright (C) 2013 The IPython Development Team // // Distributed under the terms of the BSD License. The full license is in // the file COPYING, distributed as part of this software. //---------------------------------------------------------------------------- //============================================================================ // ContainerWidget //============================================================================ /** * @module IPython * @namespace IPython **/ define(["notebook/js/widgets/widget"], function(WidgetManager) { var ContainerView = IPython.DOMWidgetView.extend({ render: function(){ // Called when view is rendered. this.$el .addClass('widget-container'); this.children={}; this.update_children([], this.model.get('_children')); this.model.on('change:_children', function(model, value, options) { this.update_children(model.previous('_children'), value); }, this); this.update() }, update_children: function(old_list, new_list) { // Called when the children list changes. this.do_diff(old_list, new_list, $.proxy(this.remove_child_model, this), $.proxy(this.add_child_model, this)); }, remove_child_model: function(model) { // Called when a model is removed from the children list. this.child_views[model.id].remove(); this.delete_child_view(model); }, add_child_model: function(model) { // Called when a model is added to the children list. var view = this.create_child_view(model); this.$el.append(view.$el); }, update: function(){ // Update the contents of this view // // Called when the model is changed. The model may have been // changed by another view or by a state update from the back-end. return ContainerView.__super__.update.apply(this); }, }); WidgetManager.register_widget_view('ContainerView', ContainerView); var ModalView = IPython.DOMWidgetView.extend({ render: function(){ // Called when view is rendered. var that = this; this.children={}; this.update_children([], this.model.get('_children')); this.model.on('change:_children', function(model, value, options) { this.update_children(model.previous('_children'), value); }, this); this.$el .on("remove", function(){ that.$window.remove(); }); this.$window = $('
') .addClass('modal widget-modal') .appendTo($('#notebook-container')) .mousedown(function(){ that.bring_to_front(); }); this.$title_bar = $('
') .addClass('popover-title') .appendTo(this.$window) .mousedown(function(){ that.bring_to_front(); }); this.$close = $('