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

  .directive('mwListColumnConfigurator', function () {
    return {
      require: '^mwListableBb',
      scope: true,
      templateUrl: 'uikit/mw-list/directives/templates/mw_list_column_configurator.html',
      link: function (scope, el, attrs, mwListCtrl) {
        var dropDownMenu = el.find('.dropdown-menu'),
          dropDownToggle = el.find('.btn-group');

        var hide = function () {
          if (dropDownToggle.hasClass('open')) {
            dropDownMenu.dropdown('toggle');
          }
          angular.element(window).off('scroll', hide);
          angular.element(window).off('resize', hide);
        };

        scope.colums = mwListCtrl.getColumns();

        scope.getColTitle = function (column) {
          if (column && column.scope) {
            var title = column.scope.getTitle() || '';
            if (title.length > 0) {
              return title;
            } else {
              return false;
            }
          }
        };

        dropDownToggle.on('show.bs.dropdown', function () {
          dropDownMenu.css({
            position: 'fixed',
            top: el.offset().top + el.innerHeight() + 5,
            left: (el.offset().left + el.innerWidth()) - dropDownMenu.innerWidth()
          });
          angular.element(window).on('scroll', hide);
          angular.element(window).on('resize', hide);
        });
      }
    };
  });<commit_msg>Trigger digest cycle on dropdown open and update event listeners<commit_after>angular.module('mwUI.List')

  .directive('mwListColumnConfigurator', function ($timeout) {
    return {
      require: '^mwListableBb',
      scope: true,
      templateUrl: 'uikit/mw-list/directives/templates/mw_list_column_configurator.html',
      link: function (scope, el, attrs, mwListCtrl) {
        var dropDownMenu = el.find('.dropdown-menu'),
          dropDownToggle = el.find('.btn-group'),
          hideDropDownEvents = 'scroll touchmove mousewheel resize';

        scope.colums = mwListCtrl.getColumns();

        var hide = function () {
          if (dropDownToggle.hasClass('open')) {
            dropDownMenu.dropdown('toggle');
          }
        };

        scope.getColTitle = function (column) {
          if (column && column.scope) {
            var title = column.scope.getTitle() || '';
            if (title.length > 0) {
              return title;
            } else {
              return false;
            }
          }
        };

        dropDownToggle.on('show.bs.dropdown', function () {
          dropDownMenu.css({
            position: 'fixed',
            top: el.offset().top + el.innerHeight() + 5,
            left: 'initial',
            right: '30px'
          });

          // We need to trigger a digest cycle otherwise it can happen that the dropdown list is not up to date
          $timeout(function(){
            angular.element(window).on(hideDropDownEvents, hide);
          });
        });

        dropDownToggle.on('hide.bs.dropdown', function () {
          angular.element(window).off(hideDropDownEvents, hide);
        });
      }
    };
  });
{'fraction_non_alphanumeric': 0.13682864450127877, 'fraction_numerical': 0.0019181585677749361, 'mean_word_length': 1.9188432835820894, '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': '5212782', 'n_tokens_mistral': 887, 'n_tokens_neox': 858, 'n_words': 168}