<commit_before><template>
    <!--
      Container for possible title and content.
     -->
    <div v-show="false" class="d-none" aria-hidden="true">
        <div ref="title"><slot name="title"></slot></div>
        <div ref="content"><slot></slot></div>
    </div>
</template>

<script>
    import PopOver from '../classes/popover';
    import { isArray } from '../utils/array';
    import { assign } from '../utils/object';
    import observeDom from '../utils/observe-dom';

    export default {
        data() {
            return {
                popOver: null
            }
        },
        props: {
            targetId: {
                // ID of element to place popover on
                // Must be in DOM
                type: String,
                default: null,
                required: true
            },
            title: {
                type: String,
                default: ''
            },
            content: {
                type: String,
                default: ''
            },
            triggers: {
                type: [String, Array],
                default: 'click'
            },
            placement: {
                type: String,
                default: 'right'
            },
            delay: {
                type: Number,
                default: 0
            },
            offset: {
                type: [Number, String],
                default: 0
            },
            noFade: {
                type: Boolean,
                default: false
            }
        },
        mounted() {
            if (this.targetId) {
                let target = this.targetId;
                this.$nextTick(() => {
                    target = document.getElementById(/^#/.test(target) ? target.slice(1) : target);
                    if (target && !this.popOver) {
                        // We pass the title & content as part of the config
                        this.popOver = new PopOver(target, this.getConfig(), this.$root);
                        // Listen to close signals from others
                        this.$on('close', this.onClose);
                        // Observe content Child changes so we can notify popper of possible size change
                        observeDom(this.$refs.content, this.updatePosition.bind(this), {
                            subtree: true,
                            childList: true,
                            attributes: true,
                            attributeFilter: ['class', 'style']
                        });
                    }
                });
            }
        },
        updated() {
            // If content changes, etc
            if (this.popOver) {
                this.popOver.updateConfig(this.getConfig());
            }
        },
        destroyed() {
            if (this.popOver) {
                // Destroy the popover
                this.popOver.destroy();
                this.popOver = null;
                // Bring our stuff back if necessary
                this.bringItBack();
            }
            this.$off('close', this.onClose);
        },
        computed: {
            baseConfig() {
                return {
                    title: this.title.trim() || '',
                    content: this.content.trim() || '',
                    placement: this.placement || 'top',
                    delay: parseInt(this.delay, 10) || 0,
                    // offset can be a css distance string. if no units provided then pixels are assumed
                    offset: this.offset || 0,
                    animation: Boolean(this.noFade),
                    triggers: isArray(this.triggers) ? this.triggers.join(' ') : this.triggers
                };
            }
        },
        methods: {
            onClose(callback) {
                if (this.popOver) {
                    this.popOver.hide(callback);
                } else if (typeof callback === 'function') {
                    callback();
                }
            },
            updatePosition() {
                if (this.popOver) {
                    // Instruct popper to reposition popover if necessary
                    this.popOver.update();<commit_msg>fic(popover): Popover component wasn't respecting triggers prop<commit_after><template>
    <!--
      Container for possible title and content.
     -->
    <div v-show="false" class="d-none" aria-hidden="true">
        <div ref="title"><slot name="title"></slot></div>
        <div ref="content"><slot></slot></div>
    </div>
</template>

<script>
    import PopOver from '../classes/popover';
    import { isArray } from '../utils/array';
    import { assign } from '../utils/object';
    import observeDom from '../utils/observe-dom';

    export default {
        data() {
            return {
                popOver: null
            }
        },
        props: {
            targetId: {
                // ID of element to place popover on
                // Must be in DOM
                type: String,
                default: null,
                required: true
            },
            title: {
                type: String,
                default: ''
            },
            content: {
                type: String,
                default: ''
            },
            triggers: {
                type: [String, Array],
                default: 'click'
            },
            placement: {
                type: String,
                default: 'right'
            },
            delay: {
                type: Number,
                default: 0
            },
            offset: {
                type: [Number, String],
                default: 0
            },
            noFade: {
                type: Boolean,
                default: false
            }
        },
        mounted() {
            if (this.targetId) {
                let target = this.targetId;
                this.$nextTick(() => {
                    target = document.getElementById(/^#/.test(target) ? target.slice(1) : target);
                    if (target && !this.popOver) {
                        // We pass the title & content as part of the config
                        this.popOver = new PopOver(target, this.getConfig(), this.$root);
                        // Listen to close signals from others
                        this.$on('close', this.onClose);
                        // Observe content Child changes so we can notify popper of possible size change
                        observeDom(this.$refs.content, this.updatePosition.bind(this), {
                            subtree: true,
                            childList: true,
                            attributes: true,
                            attributeFilter: ['class', 'style']
                        });
                    }
                });
            }
        },
        updated() {
            // If content changes, etc
            if (this.popOver) {
                this.popOver.updateConfig(this.getConfig());
            }
        },
        destroyed() {
            if (this.popOver) {
                // Destroy the popover
                this.popOver.destroy();
                this.popOver = null;
                // Bring our stuff back if necessary
                this.bringItBack();
            }
            this.$off('close', this.onClose);
        },
        computed: {
            baseConfig() {
                return {
                    title: this.title.trim() || '',
                    content: this.content.trim() || '',
                    placement: this.placement || 'top',
                    delay: parseInt(this.delay, 10) || 0,
                    // offset can be a css distance string. if no units provided then pixels are assumed
                    offset: this.offset || 0,
                    animation: Boolean(this.noFade),
                    trigger: isArray(this.triggers) ? this.triggers.join(' ') : this.triggers
                };
            }
        },
        methods: {
            onClose(callback) {
                if (this.popOver) {
                    this.popOver.hide(callback);
                } else if (typeof callback === 'function') {
                    callback();
                }
            },
            updatePosition() {
                if (this.popOver) {
                    // Instruct popper to reposition popover if necessary
                    this.popOver.update();
{'fraction_non_alphanumeric': 0.10959876908509883, 'fraction_numerical': 0.0016570008285004142, 'mean_word_length': 0.9981082998344762, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, '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': '1522231', 'n_tokens_mistral': 2037, 'n_tokens_neox': 1908, 'n_words': 489}