<commit_before>(function() {
    var $ = require("jquery");
    var jquery_plugin_class = require("../lib/jquery_plugin_class");
    var plugin_name = "DropDownPanel";
    jquery_plugin_class(plugin_name);
    var DropDownPanel = function(e) {
        this.opt = {
            "caption" : null,
            "onOpen" : function() {},
            "onClose" : function() {}
        };
        if($(e).attr("caption")) {
            this.opt.caption = $(e).attr("caption");
        }
        if($(e).hasClass(plugin_name)) {
            this.root = $(e);
            this.heading = this.root.find(".heading");
            this.content = this.root.find(".content");
        } else {
            this.root = $("<div/>").insertBefore($(e));
            if(!$(e).hasClass("close") && !$(e).hasClass("open")) {
                this.root.addClass("close");
            } else if($(e).hasClass("close")) {
                this.root.addClass("close");
            } else if($(e).hasClass("open")) {
                this.root.addClass("open");
            }
            this.heading = $("<div/>").addClass("heading");
            this.content = $("<div/>").addClass("content");
            this.root
                .append(this.heading)
                .append(this.content);
            $(e).appendTo(this.content);
        }
        this.root.addClass(plugin_name);
    };
    window.DropDownPanel = DropDownPanel;

    DropDownPanel.prototype.create = function(opt) {
        if(opt) {
            Object.keys(this.opt).forEach(function(key) {
                if(key in opt) { this.opt[key] = opt[key]; }
            }, this);
        }
        if(!this.root.hasClass("close") && !this.root.hasClass("open")) {
            this.root.addClass("close");
        }
        if(this.root.hasClass("close")) {
            this._close();
        } else {
            this._open();
        }
        if(this.opt.caption) {
            this.heading.html(this.opt.caption);
        }
        var caption = $("<span/>").addClass("caption").html(this.heading.html());
        this.heading.empty().append(caption)
            .append($("<span/>").addClass("button").html("▼")
                .click(function() {
                    if(this.root.hasClass("close")) {
                        this._open();
                    } else {
                        this._close();
                    }
                }.bind(this)));
    };
    DropDownPanel.prototype.open = function() {
        if(!this.root.hasClass("open")) {
            this._open();
        }
    };
    DropDownPanel.prototype.close = function() {
        if(!this.root.hasClass("close")) {
            this._close();
        }
    };
    DropDownPanel.prototype._open = function() {
        this.root.addClass("open");
        this.root.removeClass("close");
        this.opt.onOpen.call(this);
        this.root.find(".content").show(100);
    };
    DropDownPanel.prototype._close = function() {
        this.root.removeClass("open");
        this.root.addClass("close");
        this.opt.onClose.call(this);
        this.root.find(".content").hide(100);
    };
}());
<commit_msg>Trigger jquery events after the ddpanel content is to open or close<commit_after>(function() {
    var $ = require("jquery");
    var jquery_plugin_class = require("../lib/jquery_plugin_class");
    var plugin_name = "DropDownPanel";
    jquery_plugin_class(plugin_name);
    var DropDownPanel = function(e) {
        this.opt = {
            "caption" : null,
        };
        if($(e).attr("caption")) {
            this.opt.caption = $(e).attr("caption");
        }
        if($(e).hasClass(plugin_name)) {
            this.root = $(e);
            this.heading = this.root.find(".heading");
            this.content = this.root.find(".content");
        } else {
            this.root = $("<div/>").insertBefore($(e));
            if(!$(e).hasClass("close") && !$(e).hasClass("open")) {
                this.root.addClass("close");
            } else if($(e).hasClass("close")) {
                this.root.addClass("close");
            } else if($(e).hasClass("open")) {
                this.root.addClass("open");
            }
            this.heading = $("<div/>").addClass("heading");
            this.content = $("<div/>").addClass("content");
            this.root
                .append(this.heading)
                .append(this.content);
            $(e).appendTo(this.content);
        }
        this.root.addClass(plugin_name);
    };
    window.DropDownPanel = DropDownPanel;

    DropDownPanel.prototype.create = function(opt) {
        if(opt) {
            Object.keys(this.opt).forEach(function(key) {
                if(key in opt) { this.opt[key] = opt[key]; }
            }, this);
        }
        if(!this.root.hasClass("close") && !this.root.hasClass("open")) {
            this.root.addClass("close");
        }
        if(this.root.hasClass("close")) {
            this._close();
        } else {
            this._open();
        }
        if(this.opt.caption) {
            this.heading.html(this.opt.caption);
        }
        var caption = $("<span/>").addClass("caption").html(this.heading.html());
        this.heading.empty().append(caption)
            .append($("<span/>").addClass("button").html("▼")
                .click(function() {
                    if(this.root.hasClass("close")) {
                        this._open();
                    } else {
                        this._close();
                    }
                }.bind(this)));
    };
    DropDownPanel.prototype.open = function() {
        if(!this.root.hasClass("open")) {
            this._open();
        }
    };
    DropDownPanel.prototype.close = function() {
        if(!this.root.hasClass("close")) {
            this._close();
        }
    };
    DropDownPanel.prototype.isOpen = function() {
        return this.root.hasClass("open");
    };
    DropDownPanel.prototype._open = function() {
        this.root.addClass("open");
        this.root.removeClass("close");
        this.content.show(100, () => {
            this.content.find("> *").trigger("open");
        });
    };
    DropDownPanel.prototype._close = function() {
        this.root.removeClass("open");
        this.root.addClass("close");
        this.content.hide(100, () => {
            this.content.find("> *").trigger("close");
        });
    };
}());

{'fraction_non_alphanumeric': 0.18275862068965518, 'fraction_numerical': 0.0018808777429467085, 'mean_word_length': 1.7095541401273886, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4514583', 'n_tokens_mistral': 1832, 'n_tokens_neox': 1791, 'n_words': 219}