<commit_before>/**
 * Grid class
 * Creats an applicant grid from a display and a set of applicant ids
 * 
 * @param {Display} display
 * @param [] applicantIds
 * @param {jQuery} target
 */
function Grid(display, applicantIds, target, controllerPath){
  this.display = display;
  this.applicantIds = applicantIds;
  this.target = target;
  this.controllerPath = controllerPath;
  this.maxLoad = 100;
  this.lastClick = null;
};

Grid.prototype.init = function(){
  var self = this;
  var columns = this.getColumns();
  
  var data = [];
  $(this.target).empty();
  $(this.target).addClass('applicant_grid');
  $(this.target).append($('<div>').addClass('overlay'));
  var table = $('<table>').addClass('grid');
  if($.browser.mozilla){//Firefox
    table.css('MozUserSelect','none');
  }else if($.browser.msie){//IE
    table.bind('selectstart',function(){return false;});
  }else{//Opera, etc.
    table.mousedown(function(){return false;});
  }
  $(this.target).append(table);
  var grid = table.dataTable( {
    sScrollY: "500",
    sScrollX: "95%",
    sPaginationType: 'full_numbers',
    aaSorting: [[ 1, "asc" ]],
    fnDrawCallback: Grid.processDraw,
    aaData: data,
    aoColumns: columns,
    bJQueryUI: true,
    "sDom": '<"H"Tfrl>t<"F"ip>',
    "oTableTools": {
      "sRowSelect": "multi",
      "fnPreRowSelect": function(e, nodes) {
        if(e){ //e is not defined when we call the fnSelect method directly
          if (e.shiftKey && self.lastClick != null) {
            var lastClickPosition = grid.fnGetPosition(self.lastClick);
            var thisClickPosition = grid.fnGetPosition(nodes[0]);
            if (lastClickPosition >= 0 && thisClickPosition >= 0 && lastClickPosition != thisClickPosition) {
              //use min/max so we can click higher or ower than the first click and still loop corectly
              for (var i=Math.min(thisClickPosition,lastClickPosition); i < Math.max(thisClickPosition,lastClickPosition); i++) {
                this.fnSelect(grid.fnSettings().aoData[i].nTr);
              }
            }
          }
          self.lastClick = nodes[0];
        }
        return true;
      },
      "aButtons": [
        "select_all",<commit_msg>Fix grid shift-click so it works after a sort.<commit_after>/**
 * Grid class
 * Creats an applicant grid from a display and a set of applicant ids
 * 
 * @param {Display} display
 * @param [] applicantIds
 * @param {jQuery} target
 */
function Grid(display, applicantIds, target, controllerPath){
  this.display = display;
  this.applicantIds = applicantIds;
  this.target = target;
  this.controllerPath = controllerPath;
  this.maxLoad = 100;
  this.lastClick = null;
};

Grid.prototype.init = function(){
  var self = this;
  var columns = this.getColumns();
  
  var data = [];
  $(this.target).empty();
  $(this.target).addClass('applicant_grid');
  $(this.target).append($('<div>').addClass('overlay'));
  var table = $('<table>').addClass('grid');
  if($.browser.mozilla){//Firefox
    table.css('MozUserSelect','none');
  }else if($.browser.msie){//IE
    table.bind('selectstart',function(){return false;});
  }else{//Opera, etc.
    table.mousedown(function(){return false;});
  }
  $(this.target).append(table);
  var grid = table.dataTable( {
    sScrollY: "500",
    sScrollX: "95%",
    sPaginationType: 'full_numbers',
    aaSorting: [[ 1, "asc" ]],
    fnDrawCallback: Grid.processDraw,
    aaData: data,
    aoColumns: columns,
    bJQueryUI: true,
    "sDom": '<"H"Tfrl>t<"F"ip>',
    "oTableTools": {
      "sRowSelect": "multi",
      "fnPreRowSelect": function(e, nodes) {
        if(e){ //e is not defined when we call the fnSelect method directly
          if (e.shiftKey && self.lastClick != null) {
            var oSettings = grid.fnSettings();
            var clickPositionOne = grid.fnGetPosition(self.lastClick);
            var clickPositionTwo = grid.fnGetPosition(nodes[0]);
            
            var displayPositionOne = -1;
            var displayPositionTwo = -1;
            for(var i = 0; i < oSettings.aiDisplay.length; i++) {
              if(oSettings.aiDisplay[i] == clickPositionOne) {
                displayPositionOne = i;
              }
              if(oSettings.aiDisplay[i] == clickPositionTwo) {
                displayPositionTwo = i;
              }
            }
            if (displayPositionOne >= 0 && displayPositionTwo >= 0 && displayPositionOne != displayPositionTwo) {
              //use min/max so we can click higher or ower than the first click and still loop corectly
              for (var i=Math.min(displayPositionTwo,displayPositionOne); i < Math.max(displayPositionTwo,displayPositionOne); i++) {
                this.fnSelect(oSettings.aoData[ oSettings.aiDisplay[i] ].nTr);
              }
            }
          }
          self.lastClick = nodes[0];
        }
        return true;
      },
      "aButtons": [
        "select_all",
{'fraction_non_alphanumeric': 0.14643584521384928, 'fraction_numerical': 0.005906313645621181, 'mean_word_length': 2.7232752084912812, 'pattern_counts': {'":': 10, '<': 14, '<?xml version=': 0, '>': 15, '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': '2343673', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1488, 'n_words': 342}