<commit_before>define(function (require) { 
  require("jquery");
  var Utils = require("core/Utils");
  var Storage = require("core/Storage");
  var Inherits = require("core/Inherits");
  var SelectDialog = require("core/Control/SelectDialog");
  var Class = require("core/Class");
  var Grid = require("core/Control/Grid");
  
  var TEMPLATE = '' +
'<div class="finder">' +
'  <span name="description"></span><i name="search" class="fa {{FONT_NAME}}" style="display:inline-block;vertical-align:top;"/>' +
'  <div name="list" style="display:inline-block;"></div>' +
'</div>';

  var ITEM_TEMPLATE = '' +
'<div class="item" style="border:solid 1px gray;border-radius:3px;background-color:#f0f0f0;padding:2px 5px 2px 5px;margin:2px 0px;">' +
'  <span style="display:inline-block;font-family:Verdana,Arial,sans-serif;font-size:12px;"></span>' +
'  <i class="fa fa-remove" />' +
'</div>';

  function create_search(self, root, multi_selectable) {
    self._search.on("click", function(event) {
      var items = Object.keys(self._objects).map(function(id) { return self._objects[id]; });
      var dialog = new SelectDialog();
      dialog.init(self._columns, items, multi_selectable)
      .done(function() {
        dialog.title("Select");
        dialog.ok(function (recids) {
          console.log("[OK] clicked. selection=" + recids);
          self._value = recids;
          if (typeof self._ok == "function")
            self._ok(recids);
          self.refresh();
        });
        dialog.size(300, 400);
        
        dialog.open();
      });
    });
  }
  
  function Finder() {
    this._search = null;
    this._description = null;
    this._list = null;
    this._class = null;
    this._columns = null;
    this._objects = null;
    this._fixed = null;
    this._value = null;
    this._editting = false;
    this._ok = null;
    this._converter = null;
  }

  Finder.prototype.init = function(selector, columns, items, description, multi_selectable, converter, font_name) {
    var dfd = new $.Deferred;
    // Set member fields
    var root = $(selector);
    if (0 < root.children()) {
      dfd.resolve();
      return dfd.promise();
    }
    
    // Create form tags
    var html = TEMPLATE.replace(/{{FONT_NAME}}/, !font_name ? "fa-search" : font_name);
    root.empty();
    root.append(html);
    // Seach Icon
    this._search = root.find("div > i[name='search']");
    // Description
    this._description = root.find("div > span[name='description']");
    this._description.text(description);
    // List
    this._list = root.find("div > div[name='list']");
    this._list.on("click", "div.item > i", function(event) {
      var i = $(event.originalEvent.target);
      var record = i.parent();
      record.remove();
      var id = record.attr("id");
      self._value = self._value.filter(function (_id) { return _id != id; });
    });
    // Mouse over/out on icons.
    root.on("mouseover", "i", function(event) {
      var i = $(event.originalEvent.target);
      i.css("cursor", "pointer");
    });
    root.on("mouseout", "i", function(event) {
      var i = $(event.originalEvent.target);
      i.css("cursor", "auto");
    });

    var self = this;
    self._columns = columns;
    self._objects = items;
    self._converter = converter;
    Utils.load_css("/core/Control/Finder.css")
    .then(function() {
      create_search(self, root, multi_selectable);
      self.edit(false);
      dfd.resolve();
    });
    return dfd.promise();
  };

  Finder.prototype.ok = function(callback) {
    this._ok = callback;
  };
  
  Finder.prototype.edit = function(on) {
    this._editting = on;
    if (on) {
      this._search.show();
      this._list.find("div.item > i").css("display", "inline");
    } else {
      this._search.hide();
      this._list.find("div.item > i").css("display", "none")
    }
  };

  Finder.prototype.backuped = function() {
    return this._fixed;
  };

  Finder.prototype.commit = function() {
    this._fixed = this._value;
  };

  Finder.prototype.restore = function() {
    this._value = this._fixed;<commit_msg>Changed the search picture from icon to div-button.<commit_after>define(function (require) { 
  require("jquery");
  var Utils = require("core/Utils");
  var Storage = require("core/Storage");
  var Inherits = require("core/Inherits");
  var SelectDialog = require("core/Control/SelectDialog");
  var Class = require("core/Class");
  var Grid = require("core/Control/Grid");
  var DivButton = require("core/Control/DivButton");
  
  var TEMPLATE = '' +
'<div class="finder">' +
'  <div name="button" style="vertical-align:top;"></div>' +
'  <div name="list" style="display:inline-block;"></div>' +
'</div>';

  var ITEM_TEMPLATE = '' +
'<div class="item" style="border:solid 1px gray;border-radius:3px;background-color:#f0f0f0;padding:2px 5px 2px 5px;margin:2px 0px;">' +
'  <span style="display:inline-block;font-family:Verdana,Arial,sans-serif;font-size:12px;"></span>' +
'  <i class="fa fa-remove" />' +
'</div>';

  function create_search(selector, self, multi_selectable) {
    function search(event) {
      var items = Object.keys(self._objects).map(function(id) { return self._objects[id]; });
      var dialog = new SelectDialog();
      dialog.init(self._columns, items, multi_selectable)
      .done(function() {
        dialog.title("Select");
        dialog.ok(function (recids) {
          console.log("[OK] clicked. selection=" + recids);
          self._value = recids;
          if (typeof self._ok == "function")
            self._ok(recids);
          self.refresh();
        });
        dialog.size(300, 400);
        dialog.open();
      });
    }
    self._search = new DivButton();
    return self._search.init(selector, '<i class="fa fa-search" />', search);
  }
  
  function Finder() {
    this._search = null;
    this._list = null;
    this._class = null;
    this._columns = null;
    this._objects = null;
    this._fixed = null;
    this._value = null;
    this._editting = false;
    this._ok = null;
    this._converter = null;
  }

  Finder.prototype.init = function(selector, columns, items, description, multi_selectable, converter, font_name) {
    var dfd = new $.Deferred;
    // Set member fields
    var root = $(selector);
    if (0 < root.children()) {
      dfd.resolve();
      return dfd.promise();
    }
    
    // Create form tags
    var html = TEMPLATE.replace(/{{FONT_NAME}}/, !font_name ? "fa-search" : font_name);
    root.empty();
    root.append(html);
    // Seach Icon
    this._search = root.find("div > i[name='search']");
    // List
    this._list = root.find("div > div[name='list']");
    this._list.on("click", "div.item > i", function(event) {
      var i = $(event.originalEvent.target);
      var record = i.parent();
      record.remove();
      var id = record.attr("id");
      self._value = self._value.filter(function (_id) { return _id != id; });
    });
    // Mouse over/out on icons.
    root.on("mouseover", "i", function(event) {
      var i = $(event.originalEvent.target);
      i.css("cursor", "pointer");
    });
    root.on("mouseout", "i", function(event) {
      var i = $(event.originalEvent.target);
      i.css("cursor", "auto");
    });

    var self = this;
    self._columns = columns;
    self._objects = items;
    self._converter = converter;
    Utils.load_css("/core/Control/Finder.css")
    .then(function() {
      return create_search(selector + " > div > div[name='button']", self, multi_selectable);
    })
    .then(function() {
      self.edit(false);
      dfd.resolve();
    });
    return dfd.promise();
  };

  Finder.prototype.ok = function(callback) {
    this._ok = callback;
  };
  
  Finder.prototype.edit = function(on) {
    this._editting = on;
    this._search.visible(on);
    this._list.find("div.item > i").css("display", on ? "inline" : "none");
  };

  Finder.prototype.backuped = function() {
    return this._fixed;
  };

  Finder.prototype.commit = function() {
    this._fixed = this._value;
  };

  Finder.prototype.restore = function() {
    this._value = this._fixed;
{'fraction_non_alphanumeric': 0.17572755417956656, 'fraction_numerical': 0.004953560371517028, 'mean_word_length': 2.9337554797856793, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 39, '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': '7045031', 'n_tokens_mistral': 2670, 'n_tokens_neox': 2609, 'n_words': 509}