<commit_before>angular.module('ngRibbon', ['ngRibbon.menu', 'ngRibbon.utils'])
    .directive('ngRibbon', function () {
        function ContextualGroup(parent, title, color) {
            this.parent = parent;
            this.title = title;
            this.color = 'color-' + color;
            this.tabs = [];

            this.initialize();
        }

        Object.defineProperties(ContextualGroup.prototype, {
            initialize: {
                value: function () {
                    var context = this.parent.ribbonContext;
                    if (context.hasOwnProperty(this.title)) {
                        return;
                    }

                    var _this = this;
                    Object.defineProperty(context, this.title, {
                        get: function () {
                            return _this.visible;
                        },
                        set: function (value) {
                            _this.visible = value;
                            _this.onVisibleChanged();
                        }
                    });
                }
            },
            hasActive: {
                get: function () {
                    return this.tabs.filter(function (tab) {
                        return tab.active;
                    }).length > 0;
                }
            },
            onVisibleChanged: {
                value: function () {
                    if (this.visible && !this.parent.collapsed) {
                        this.parent.activate(this.tabs[0]);
                    } else if (this.hasActive) {
                        this.parent.activate();
                    }
                }
            }
        });

        function RibbonController(scope, document, contextualColors) {
            this.scope = scope;
            this.document = document;
            this.contextualColors = contextualColors;
            this.tabs = [];
            this.contextualGroups = [];
            this._collapsed = false;
        }

        Object.defineProperties(RibbonController.prototype, {
            hasBackstage: {
                get: function () {
                    return !!this.backstage;
                }
            },
            collapsed: {
                get: function () {
                    return this._collapsed && !this.activeTab;
                }
            },
            toggleCollapse: {
                value: function () {
                    this._collapsed = !this._collapsed;
                    if (this._collapsed) {
                        this.clearActiveTab();
                    }
                }
            },
            activate: {
                value: function (tab, e) {
                    if (this.activeTab) {
                        if (this.activeTab === tab) {
                            if (this._collapsed) {
                                this.clearActiveTab();
                            }
                            return;
                        }
                        this.clearActiveTab();
                    }

                    if (!tab) {
                        tab = this.tabs[0];
                    }

                    this.activeTab = tab;
                    this.activeTab.active = true;<commit_msg>Comments for handling double-click event intelligently<commit_after>angular.module('ngRibbon', ['ngRibbon.menu', 'ngRibbon.utils'])
    .directive('ngRibbon', function () {
        function ContextualGroup(parent, title, color) {
            this.parent = parent;
            this.title = title;
            this.color = 'color-' + color;
            this.tabs = [];

            this.initialize();
        }

        Object.defineProperties(ContextualGroup.prototype, {
            initialize: {
                value: function () {
                    var context = this.parent.ribbonContext;
                    if (context.hasOwnProperty(this.title)) {
                        return;
                    }

                    var _this = this;
                    Object.defineProperty(context, this.title, {
                        get: function () {
                            return _this.visible;
                        },
                        set: function (value) {
                            _this.visible = value;
                            _this.onVisibleChanged();
                        }
                    });
                }
            },
            hasActive: {
                get: function () {
                    return this.tabs.filter(function (tab) {
                        return tab.active;
                    }).length > 0;
                }
            },
            onVisibleChanged: {
                value: function () {
                    if (this.visible && !this.parent.collapsed) {
                        this.parent.activate(this.tabs[0]);
                    } else if (this.hasActive) {
                        this.parent.activate();
                    }
                }
            }
        });

        function RibbonController(scope, document, contextualColors) {
            this.scope = scope;
            this.document = document;
            this.contextualColors = contextualColors;
            this.tabs = [];
            this.contextualGroups = [];
            this._collapsed = false;
        }

        Object.defineProperties(RibbonController.prototype, {
            hasBackstage: {
                get: function () {
                    return !!this.backstage;
                }
            },
            collapsed: {
                get: function () {
                    return this._collapsed && !this.activeTab;
                }
            },
            toggleCollapse: {
                value: function () {
                    this._collapsed = !this._collapsed;
                    if (this._collapsed) {
                        this.clearActiveTab();
                    }
                }
            },
            activate: {
                //http://stackoverflow.com/questions/5497073/how-to-differentiate-single-click-event-and-double-click-event
                //http://stackoverflow.com/questions/20444409/handling-ng-click-and-ng-dblclick-on-the-same-element-with-angularjs
                value: function (tab, e) {
                    if (this.activeTab) {
                        if (this.activeTab === tab) {
                            if (this._collapsed) {
                                this.clearActiveTab();
                            }
                            return;
                        }
                        this.clearActiveTab();
                    }

                    if (!tab) {
                        tab = this.tabs[0];
                    }

                    this.activeTab = tab;
                    this.activeTab.active = true;
{'fraction_non_alphanumeric': 0.095536756126021, 'fraction_numerical': 0.0030630105017502916, 'mean_word_length': 0.8822399121603074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7350869', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1479, 'n_words': 248}