<commit_before>// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.

define([
    "widgets/js/widget",
    "jqueryui",
    "bootstrap",
], function(widget, $){

    var BoxView = widget.DOMWidgetView.extend({
        initialize: function(){
            // Public constructor
            BoxView.__super__.initialize.apply(this, arguments);
            this.update_children([], this.model.get('children'));
            this.model.on('change:children', function(model, value) {
                this.update_children(model.previous('children'), value);
            }, this);
        },

        render: function(){
            // Called when view is rendered.
            this.$box = this.$el;
            this.$el.addClass('widget-box');
        },
        
        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.$box.append(view.$el);

            // Trigger the displayed event of the child view.
            this.after_displayed(function() {
                view.trigger('displayed');
            });
        },
    });


    var FlexBoxView = BoxView.extend({
        render: function(){
            FlexBoxView.__super__.render.apply(this);
            this.model.on('change:orientation', this.update_orientation, this);
            this.model.on('change:flex', this._flex_changed, this);
            this.model.on('change:pack', this._pack_changed, this);
            this.model.on('change:align', this._align_changed, this);
            this._flex_changed();
            this._pack_changed();
            this._align_changed();
            that.update_orientation();
        },

        update_orientation: function(){
            var orientation = this.model.get("orientation");
            if (orientation == "vertical") {
                this.$el.removeClass("hbox").addClass("vbox");
            } else {
                this.$el.removeClass("vbox").addClass("hbox");
            }
        },

        _flex_changed: function(){
            if (this.model.previous('flex')) {
                this.$el.removeClass('box-flex' + this.model.previous('flex'));
            }
            this.$el.addClass('box-flex' + this.model.get('flex'));
        },

        _pack_changed: function(){
            if (this.model.previous('pack')) {
                this.$el.removeClass(this.model.previous('pack'));
            }
            this.$el.addClass(this.model.get('pack'));
        },

        _align_changed: function(){
            if (this.model.previous('align')) {
                this.$el.removeClass('align-' + this.model.previous('align'));
            }
            this.$el.addClass('align-' + this.model.get('align'));
        },
    });

    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 = $('<div />')
                .appendTo($('#notebook-container'))
                .addClass('modal-dialog')
                .css('position', 'absolute')
                .css('left', '0px')
                .css('top', '0px');
            this.$window = $('<div />')
                .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 = $('<div />')
                .addClass('popover-title')<commit_msg>Make popup inherit from widget box<commit_after>// Copyright (c) IPython Development Team.
// Distributed under the terms of the Modified BSD License.

define([
    "widgets/js/widget",
    "jqueryui",
    "bootstrap",
], function(widget, $){

    var BoxView = widget.DOMWidgetView.extend({
        initialize: function(){
            // Public constructor
            BoxView.__super__.initialize.apply(this, arguments);
            this.update_children([], this.model.get('children'));
            this.model.on('change:children', function(model, value) {
                this.update_children(model.previous('children'), value);
            }, this);
        },

        render: function(){
            // Called when view is rendered.
            this.$box = this.$el;
            this.$el.addClass('widget-box');
        },
        
        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.$box.append(view.$el);

            // Trigger the displayed event of the child view.
            this.after_displayed(function() {
                view.trigger('displayed');
            });
        },
    });


    var FlexBoxView = BoxView.extend({
        render: function(){
            FlexBoxView.__super__.render.apply(this);
            this.model.on('change:orientation', this.update_orientation, this);
            this.model.on('change:flex', this._flex_changed, this);
            this.model.on('change:pack', this._pack_changed, this);
            this.model.on('change:align', this._align_changed, this);
            this._flex_changed();
            this._pack_changed();
            this._align_changed();
            that.update_orientation();
        },

        update_orientation: function(){
            var orientation = this.model.get("orientation");
            if (orientation == "vertical") {
                this.$el.removeClass("hbox").addClass("vbox");
            } else {
                this.$el.removeClass("vbox").addClass("hbox");
            }
        },

        _flex_changed: function(){
            if (this.model.previous('flex')) {
                this.$el.removeClass('box-flex' + this.model.previous('flex'));
            }
            this.$el.addClass('box-flex' + this.model.get('flex'));
        },

        _pack_changed: function(){
            if (this.model.previous('pack')) {
                this.$el.removeClass(this.model.previous('pack'));
            }
            this.$el.addClass(this.model.get('pack'));
        },

        _align_changed: function(){
            if (this.model.previous('align')) {
                this.$el.removeClass('align-' + this.model.previous('align'));
            }
            this.$el.addClass('align-' + this.model.get('align'));
        },
    });

    var PopupView = BoxView.extend({
        render: function(){
            // Called when view is rendered.
            var that = this;
            
            this.$el.on("remove", function(){
                    that.$backdrop.remove();
                });
            this.$backdrop = $('<div />')
                .appendTo($('#notebook-container'))
                .addClass('modal-dialog')
                .css('position', 'absolute')
                .css('left', '0px')
                .css('top', '0px');
            this.$window = $('<div />')
                .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 = $('<div />')
                .addClass('popover-title')
{'fraction_non_alphanumeric': 0.1373819459696903, 'fraction_numerical': 0.0004392708104546453, 'mean_word_length': 1.6888101564806615, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6709675', 'n_tokens_mistral': 2386, 'n_tokens_neox': 2278, 'n_words': 482}