<commit_before>angular.module('mwUI.UiComponents')

//TODO rename to mwCollapsible
  .directive('mwCollapsable', function () {
    return {
      transclude: true,
      scope: {
        mwCollapsable: '=',
        title: '@mwTitle'
      },
      templateUrl: 'uikit/mw-ui-components/directives/templates/mw_collapsible.html',
      link: function (scope, el) {
        scope.viewModel = {};
        scope.viewModel.collapsed = false;

        var getHeight = function (el) {
          var totalHeight = 0;

          el.children().filter(':visible').each(function () {
            totalHeight += angular.element(this).outerHeight(true);
          });
          return totalHeight;
        };

        scope.toggle = function () {
          var collapsedBody = el.find('.mw-collapsible-body'),
            maxHeight;

          if (!scope.viewModel.collapsed) {
            maxHeight = getHeight(collapsedBody);
          } else {
            maxHeight = 0;
          }

          collapsedBody.css('max-height', maxHeight);
          scope.viewModel.collapsed = !scope.viewModel.collapsed;
        };

        scope.$watch('mwCollapsable', function () {
          if (scope.mwCollapsable === false) {
            scope.viewModel.collapsed = true;
          } else {
            scope.viewModel.collapsed = false;
          }
        });
      }
    };
  });<commit_msg>Use open and close function<commit_after>angular.module('mwUI.UiComponents')

//TODO rename to mwCollapsible
  .directive('mwCollapsable', function () {
    return {
      transclude: true,
      scope: {
        mwCollapsable: '=',
        title: '@mwTitle'
      },
      templateUrl: 'uikit/mw-ui-components/directives/templates/mw_collapsible.html',
      link: function (scope, el) {
        scope.viewModel = {};
        scope.viewModel.collapsed = false;

        var getHeight = function (el) {
          var totalHeight = 0;

          el.children().filter(':visible').each(function () {
            totalHeight += angular.element(this).outerHeight(true);
          });
          return totalHeight;
        };

        var open = function(){
          var collapsedBody = el.find('.mw-collapsible-body');

          collapsedBody.css('max-height', getHeight(collapsedBody));
          scope.viewModel.collapsed = false;
        };

        var close = function(){
          var collapsedBody = el.find('.mw-collapsible-body');

          collapsedBody.css('max-height', 0);
          scope.viewModel.collapsed = true;
        };

        scope.toggle = function () {
          if (scope.mwCollapsable === false) {
            close();
          } else {
            open();
          }
        };

        scope.$watch('mwCollapsable', function () {
          if (scope.mwCollapsable === false) {
            close();
          } else {
            open();
          }
        });
      }
    };
  });
{'fraction_non_alphanumeric': 0.13497571131158917, 'fraction_numerical': 0.0013879250520471894, 'mean_word_length': 1.7990291262135922, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5622333', 'n_tokens_mistral': 842, 'n_tokens_neox': 804, 'n_words': 137}