<commit_before>/*
 * Copyright https://github.com/divio/django-cms
 */

// #############################################################################
// NAMESPACES
/**
 * @module CMS
 */
var CMS = window.CMS || {};

// #############################################################################
// Tooltip
(function ($) {
    'use strict';

    /**
     * The tooltip is the element which shows over plugins
     * and suggests clicking/tapping them to edit.
     *
     * @class Tooltip
     * @namespace CMS
     */
    CMS.Tooltip = new CMS.Class({

        initialize: function initialize() {
            this.body = $('body');
            /**
             * Are we on touch device?
             *
             * @property {Boolean} isTouch
             */
            this.isTouch = false;
            /**
             * Tooltip DOM element
             *
             * @property {jQuery} domElem
             */
            this.domElem = this._pick();

            this._forceTouchOnce = CMS.API.Helpers.once(this._forceTouch);
            this._checkTouch();
        },

        /**
         * Checks for touch event and switches to touch tooltip if detected.
         *
         * @method _checkTouch
         * @private
         */
        _checkTouch: function _checkTouch() {
            this.body.one('touchstart.cms', $.proxy(this._forceTouchOnce, this));
        },

        /**
         * Force tooltip to be "touch".
         *
         * @method _forceTouch
         * @private
         */
        _forceTouch: function _forceTouch() {
            this.isTouch = true;
            this.domElem = this._pick();

            // attach tooltip event for touch devices
            this.domElem.on('touchstart.cms', function () {
                var id = $(this).data('plugin_id');
                var plugin = $('.cms-plugin-' + id);
                // check if it is a normal plugin or a generic
                if (plugin.length) {
                    plugin.trigger('dblclick.cms');
                } else {
                    // generics are added through the content mode via special
                    // template tags some generic element might be
                    // cms-plugin-cms-page-changelist-x
                    var generic = $('.cms-plugin[class*="cms-plugin-cms-"][class*="-' + id + '"]');
                    generic.eq(0).trigger('dblclick.cms');
                }
            });
        },

        /**
         * Manages show/hide calls.
         *
         * @method displayToggle
         * @param {Boolean} isShown
         * @param {Object} e event object
         * @param {String} name current plugin name
         * @param {String} id current plugin id
         */
        displayToggle: function displayToggle(isShown, e, name, id) {
            isShown ? this.show(e, name, id) : this.hide();
        },

        /**
         * Shows tooltip with specific plugin-related parameters.
         *
         * @method show
         * @param {Object} e
         * @param {String} name current plugin name
         * @param {String} id current plugin id
         */
        show: function show(e, name, id) {
            var tooltip = this.domElem;
            var that = this;

            // change css and attributes
            tooltip.css('visibility', 'visible')
                .data('plugin_id', id || null)
                .show()
                .find('span').html(name);

            if (this.isTouch) {
                this.position(e.originalEvent, tooltip);
            } else {
                // attaches move event
                // this sets the correct position for the edit tooltip
                that.position(e.originalEvent, tooltip);
                this.body.on('mousemove.cms', function (e) {
                    that.position(e, tooltip);
                });
            }
        },

        /**
         * Hides tooltip.
         *
         * @method hide
         */
        hide: function hide() {
            // change css
            this.domElem.css('visibility', 'hidden').hide();

            // unbind events
            if (!this.isTouch) {
                this.body.off('mousemove.cms');
            }
        },
<commit_msg>namespace mousemove a bit more, since it's on body<commit_after>/*
 * Copyright https://github.com/divio/django-cms
 */

// #############################################################################
// NAMESPACES
/**
 * @module CMS
 */
var CMS = window.CMS || {};

// #############################################################################
// Tooltip
(function ($) {
    'use strict';

    /**
     * The tooltip is the element which shows over plugins
     * and suggests clicking/tapping them to edit.
     *
     * @class Tooltip
     * @namespace CMS
     */
    CMS.Tooltip = new CMS.Class({

        initialize: function initialize() {
            this.body = $('body');
            /**
             * Are we on touch device?
             *
             * @property {Boolean} isTouch
             */
            this.isTouch = false;
            /**
             * Tooltip DOM element
             *
             * @property {jQuery} domElem
             */
            this.domElem = this._pick();

            this._forceTouchOnce = CMS.API.Helpers.once(this._forceTouch);
            this._checkTouch();
        },

        /**
         * Checks for touch event and switches to touch tooltip if detected.
         *
         * @method _checkTouch
         * @private
         */
        _checkTouch: function _checkTouch() {
            this.body.one('touchstart.cms', $.proxy(this._forceTouchOnce, this));
        },

        /**
         * Force tooltip to be "touch".
         *
         * @method _forceTouch
         * @private
         */
        _forceTouch: function _forceTouch() {
            this.isTouch = true;
            this.domElem = this._pick();

            // attach tooltip event for touch devices
            this.domElem.on('touchstart.cms', function () {
                var id = $(this).data('plugin_id');
                var plugin = $('.cms-plugin-' + id);
                // check if it is a normal plugin or a generic
                if (plugin.length) {
                    plugin.trigger('dblclick.cms');
                } else {
                    // generics are added through the content mode via special
                    // template tags some generic element might be
                    // cms-plugin-cms-page-changelist-x
                    var generic = $('.cms-plugin[class*="cms-plugin-cms-"][class*="-' + id + '"]');
                    generic.eq(0).trigger('dblclick.cms');
                }
            });
        },

        /**
         * Manages show/hide calls.
         *
         * @method displayToggle
         * @param {Boolean} isShown
         * @param {Object} e event object
         * @param {String} name current plugin name
         * @param {String} id current plugin id
         */
        displayToggle: function displayToggle(isShown, e, name, id) {
            isShown ? this.show(e, name, id) : this.hide();
        },

        /**
         * Shows tooltip with specific plugin-related parameters.
         *
         * @method show
         * @param {Object} e
         * @param {String} name current plugin name
         * @param {String} id current plugin id
         */
        show: function show(e, name, id) {
            var tooltip = this.domElem;
            var that = this;

            // change css and attributes
            tooltip.css('visibility', 'visible')
                .data('plugin_id', id || null)
                .show()
                .find('span').html(name);

            if (this.isTouch) {
                this.position(e.originalEvent, tooltip);
            } else {
                // attaches move event
                // this sets the correct position for the edit tooltip
                that.position(e.originalEvent, tooltip);
                this.body.on('mousemove.cms.tooltip', function (e) {
                    that.position(e, tooltip);
                });
            }
        },

        /**
         * Hides tooltip.
         *
         * @method hide
         */
        hide: function hide() {
            // change css
            this.domElem.css('visibility', 'hidden').hide();

            // unbind events
            if (!this.isTouch) {
                this.body.off('mousemove.cms.tooltip');
            }
        },

{'fraction_non_alphanumeric': 0.15179728933411904, 'fraction_numerical': 0.0002357100766057749, 'mean_word_length': 1.360500695410292, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '7575917', 'n_tokens_mistral': 2231, 'n_tokens_neox': 2101, 'n_words': 544}