<commit_before>angular.module("bmComponents").directive("bmChosen", ["$timeout",
    function ($timeout) {

        return {
            restrict : "A",
            link : function(scope, element, attrs) {
                element.chosen();

                scope.$watch(attrs.bmChosen, function (data) {
                    if (data) element.trigger("chosen:updated");
                });

                scope.$watch(attrs.ngDisabled, function (data) {
                    if (data === false || data === true) element.trigger("chosen:updated");
                });

                scope.$on("switchMode", function() {
                    var classes = element.attr("class").split(/\s+/),
                        spanClass = classes.filter(function (className) {
                            return className.indexOf("span") > -1;
                        })[0];

                    element.before("<p class='" + spanClass + " hidden'></p>");
                    element.next(".chosen-container").css("width", element.prev().css("width"));
                });
            }
        }
    }
]);<commit_msg>Update chosen directive to work with newer AngularJS versions.<commit_after>angular.module("bmComponents").directive("bmChosen", ["$timeout",
    function ($timeout) {

        return {
            restrict : "A",
            link : function(scope, element, attrs) {
                element.chosen();

                scope.$watch(attrs.bmChosen, function (data) {
                    if (data) {
                        $timeout(function () {
                            element.trigger("chosen:updated");
                        });
                    }
                });

                scope.$watch(attrs.ngDisabled, function (data) {
                    if (data === false || data === true) {
                        $timeout(function () {
                            element.trigger("chosen:updated");
                        });
                    }
                });

                scope.$on("switchMode", function() {
                    $timeout(function () {
                        element.next(".chosen-container").css("width", element.parent().width() + "px");
                    });
                });
            }
        }
    }
]);
{'fraction_non_alphanumeric': 0.14600794000882222, 'fraction_numerical': 0.000882223202470225, 'mean_word_length': 1.2411067193675889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '7520049', 'n_tokens_mistral': 551, 'n_tokens_neox': 510, 'n_words': 88}