// Copyright (c) IPython Development Team. // Distributed under the terms of the Modified BSD License. define([ "widgets/js/widget", "jqueryui", "bootstrap", ], function(widget, $){ var ContainerView = widget.DOMWidgetView.extend({ render: function(){ // Called when view is rendered. this.$el.addClass('widget-container') .addClass('vbox'); 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.pop_child_view(model).remove(); }, 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); // Trigger the displayed event once this view is displayed. this.after_displayed(function() { view.trigger('displayed'); }); }, 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); }, }); var PopupView = widget.DOMWidgetView.extend({ render: function(){ // Called when view is rendered. var that = this; this.$el.on("remove", function(){ that.$backdrop.remove(); }); this.$backdrop = $('
') .appendTo($('#notebook-container')) .addClass('modal-dialog') .css('position', 'absolute') .css('left', '0px') .css('top', '0px'); this.$window = $('
') .appendTo(this.$backdrop) .addClass('modal-content widget-modal') .mousedown(function(){ that.bring_to_front(); }); // Set the elements array since the this.$window element is not child // of this.$el and the parent widget manager or other widgets may // need to know about all of the top-level widgets. The IPython // widget manager uses this to register the elements with the // keyboard manager. this.additional_elements = [this.$window]; this.$title_bar = $('
') .addClass('popover-title') .appendTo(this.$window) .mousedown(function(){ that.bring_to_front(); }); this.$close = $('