<commit_before>import $ from 'dom7';
import Utils from '../../utils/utils';
import Popover from './popover-class';
import ModalMethods from '../../utils/modal-methods';

export default {
  name: 'popover',
  params: {
    popover: {
      backdrop: true,
      backdropEl: undefined,
      closeByBackdropClick: true,
      closeByOutsideClick: true,
      closeOnEscape: false,
    },
  },
  static: {
    Popover,
  },
  create() {
    const app = this;
    app.popover = Utils.extend(
      ModalMethods({
        app,
        constructor: Popover,
        defaultSelector: '.popover.modal-in',
      }),
      {
        open(popoverEl, targetEl, animate) {
          let $popoverEl = $(popoverEl);
          if ($popoverEl.length > 1) {
            // check if same popover in other page
            const $targetPage = $(targetEl).parents('.page');
            if ($targetPage.length) {
              $popoverEl.each((index, el) => {
                const $el = $(el);
                if ($el.parents($targetPage)[0] === $targetPage[0]) {
                  $popoverEl = $el;
                }
              });
            }
          }
          if ($popoverEl.length > 1) {
            $popoverEl = $popoverEl.eq($popoverEl.length - 1);
          }
          let popover = $popoverEl[0].f7Modal;
          if (!popover) popover = new Popover(app, { el: $popoverEl, targetEl });
          return popover.open(targetEl, animate);
        },
      }
    );
  },
  clicks: {
    '.popover-open': function openPopover($clickedEl, data = {}) {
      const app = this;
      app.popover.open(data.popover, $clickedEl, data.animate);
    },
    '.popover-close': function closePopover($clickedEl, data = {}) {
      const app = this;
      app.popover.close(data.popover, data.animate, $clickedEl);
    },
  },
};<commit_msg>Core: Popover - fix data- attrs read<commit_after>import $ from 'dom7';
import Utils from '../../utils/utils';
import Popover from './popover-class';
import ModalMethods from '../../utils/modal-methods';

export default {
  name: 'popover',
  params: {
    popover: {
      backdrop: true,
      backdropEl: undefined,
      closeByBackdropClick: true,
      closeByOutsideClick: true,
      closeOnEscape: false,
    },
  },
  static: {
    Popover,
  },
  create() {
    const app = this;
    app.popover = Utils.extend(
      ModalMethods({
        app,
        constructor: Popover,
        defaultSelector: '.popover.modal-in',
      }),
      {
        open(popoverEl, targetEl, animate) {
          let $popoverEl = $(popoverEl);
          if ($popoverEl.length > 1) {
            // check if same popover in other page
            const $targetPage = $(targetEl).parents('.page');
            if ($targetPage.length) {
              $popoverEl.each((index, el) => {
                const $el = $(el);
                if ($el.parents($targetPage)[0] === $targetPage[0]) {
                  $popoverEl = $el;
                }
              });
            }
          }
          if ($popoverEl.length > 1) {
            $popoverEl = $popoverEl.eq($popoverEl.length - 1);
          }
          let popover = $popoverEl[0].f7Modal;
          const data = $popoverEl.dataset();
          if (!popover) {
            popover = new Popover(app, Object.assign(
              {
                el: $popoverEl,
                targetEl,
              },
              data
            ));
          }
          return popover.open(targetEl, animate);
        },
      }
    );
  },
  clicks: {
    '.popover-open': function openPopover($clickedEl, data = {}) {
      const app = this;
      app.popover.open(data.popover, $clickedEl, data.animate);
    },
    '.popover-close': function closePopover($clickedEl, data = {}) {
      const app = this;
      app.popover.close(data.popover, data.animate, $clickedEl);
    },
  },
};
{'fraction_non_alphanumeric': 0.14537902388369678, 'fraction_numerical': 0.004153686396677051, 'mean_word_length': 1.7482168330955778, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '5922222', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1181, 'n_words': 244}