<commit_before>define([
  'summernote/base/core/func',
  'summernote/base/core/list',
  'summernote/base/core/dom'
], function (func, list, dom) {
  var AirPopover = function (context) {
    var self = this;
    var ui = $.summernote.ui;

    var $note = context.layoutInfo.note;
    var $editingArea = context.layoutInfo.editingArea;
    var options = context.options;

    var AIR_MODE_POPOVER_X_OFFSET = 20;

    this.events = {
      'summernote.keyup summernote.mouseup summernote.scroll': function () {
        self.update();
      },
      'summernote.change': function () {
        self.hide();
      },
      'summernote.focusout': function (we, e) {
        if (!e.relatedTarget || !dom.ancestor(e.relatedTarget, func.eq($editingArea[0]))) {
          self.hide();
        }
      }
    };

    this.initialize = function () {
      if (!options.airMode || list.isEmpty(options.popover.air)) {
        return;
      }

      this.$popover = ui.popover({
        className: 'note-air-popover'
      }).render().appendTo('body');
      var $content = this.$popover.find('.popover-content');

      context.invoke('buttons.build', $content, options.popover.air);
      dom.attachEvents($note, this.events);
    };

    this.destroy = function () {
      if (!options.airMode || list.isEmpty(options.popover.air)) {
        return;
      }

      this.$popover.remove();
      dom.detachEvents($note, this.events);
    };

    this.update = function () {
      var styleInfo = context.invoke('editor.currentStyle');
      if (styleInfo.range && !styleInfo.range.isCollapsed()) {
        var rect = list.last(styleInfo.range.getClientRects());
        if (rect) {
          var bnd = func.rect2bnd(rect);
          this.$popover.css({
            display: 'block',
            left: Math.max(bnd.left + bnd.width / 2, 0) - AIR_MODE_POPOVER_X_OFFSET,
            top: bnd.top + bnd.height
          });
        }
      } else {
        this.hide();
      }
    };

    this.hide = function () {
      this.$popover.hide();
    };
  };

  return AirPopover;
});<commit_msg>Prevent script error on airpopover.<commit_after>define([
  'summernote/base/core/func',
  'summernote/base/core/list',
  'summernote/base/core/dom'
], function (func, list, dom) {
  var AirPopover = function (context) {
    var self = this;
    var ui = $.summernote.ui;

    var $note = context.layoutInfo.note;
    var $editingArea = context.layoutInfo.editingArea;
    var options = context.options;

    var AIR_MODE_POPOVER_X_OFFSET = 20;

    this.events = {
      'summernote.keyup summernote.mouseup summernote.scroll': function () {
        self.update();
      },
      'summernote.change': function () {
        self.hide();
      },
      'summernote.focusout': function (we, e) {
        if (!e.relatedTarget || !dom.ancestor(e.relatedTarget, func.eq($editingArea[0]))) {
          self.hide();
        }
      }
    };

    this.initialize = function () {
      if (!options.airMode || list.isEmpty(options.popover.air)) {
        return;
      }

      this.$popover = ui.popover({
        className: 'note-air-popover'
      }).render().appendTo('body');
      var $content = this.$popover.find('.popover-content');

      context.invoke('buttons.build', $content, options.popover.air);
      dom.attachEvents($note, this.events);
    };

    this.destroy = function () {
      if (!options.airMode || list.isEmpty(options.popover.air)) {
        return;
      }

      this.$popover.remove();
      dom.detachEvents($note, this.events);
    };

    this.update = function () {
      var styleInfo = context.invoke('editor.currentStyle');
      if (styleInfo.range && !styleInfo.range.isCollapsed()) {
        var rect = list.last(styleInfo.range.getClientRects());
        if (rect) {
          var bnd = func.rect2bnd(rect);
          this.$popover.css({
            display: 'block',
            left: Math.max(bnd.left + bnd.width / 2, 0) - AIR_MODE_POPOVER_X_OFFSET,
            top: bnd.top + bnd.height
          });
        }
      } else {
        this.hide();
      }
    };

    this.hide = function () {
      if (!options.airMode || list.isEmpty(options.popover.air)) {
        return;
      }
      this.$popover.hide();
    };
  };

  return AirPopover;
});
{'fraction_non_alphanumeric': 0.1563892145369285, 'fraction_numerical': 0.002813599062133646, 'mean_word_length': 2.2391799544419135, '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': '6063411', 'n_tokens_mistral': 1402, 'n_tokens_neox': 1361, 'n_words': 230}