<commit_before><link rel="import" href="/resources/polymer/polymer/polymer.html">
<link rel="import" href="/resources/components/tg-tooltip.html">
<!--
Provides tooltip support for component that uses this behaviour. In order to set tooltip for specific element in the component, one should
mark element with tooltip-text attribute.
-->
<script>
    (function () {
        var toolTipElement = document.createElement("tg-tooltip");
        /**
         * Returns the element in hierarchy that has tooltip-id attribute set otherwise returns null.
         */
        var extractActiveElement = function (currentElement, thisElement) {
            if (currentElement && currentElement !== thisElement.parentElement) {
                if (currentElement.hasAttribute("tooltip-text")) {
                    return currentElement;
                } else {
                    return extractActiveElement(currentElement.parentElement, thisElement);
                }
            }
            return null;
        };
        //Adds tooltip element to document's body so that it only one for all tooltips.
        Polymer.dom(document.body).appendChild(toolTipElement);
        Polymer.dom.flush();

        Polymer.TgBehaviors = Polymer.TgBehaviors || {};
        Polymer.TgBehaviors.TgTooltipBehavior = {
            properties: {
                triggerManual: {
                    type: String,
                    value: false,
                    observer: "_triggerManualChanged"
                },

                /**
                 * Saved mouse positions.
                 */
                _mousePosX: Number,
                _mousePosY: Number,
                /**
                 * The handle for tooltip timer can be used to cancel tooltip timer. (Tooltip timer - the timer for tooltip to be shown).
                 */
                _tooltipTimer: {
                    type: Number
                },
                /**
                 * Element under mouse pointer, for which tooltip should be shown. Also this element should be marked with tooltip-id attribute.
                 */
                _activeComponent: {
                    type: Object
                }
            },

            ready: function () {
                this._handleMouseMove = this._handleMouseMove.bind(this);
                this._handleTooltipAtMousePos = this._handleTooltipAtMousePos.bind(this);
                this._hideTooltip = this._hideTooltip.bind(this);
                //Register mouse listeners for mouse events     
                this.addEventListener('mousemove', this._handleMouseMove);
            },

            /**
             * Displayes the tooltip with specified text at current mouse position.
             */
            showTooltip: function (tooltipText) {
                Polymer.dom(toolTipElement).innerHTML = tooltipText;
                toolTipElement.showAt(this._mousePosX, this._mousePosY);
            },

            /**
             * Hides the tooltip.
             */
            hideTooltip: function () {
                if (toolTipElement._showing) {
                    toolTipElement.hide();
                }
            },
<commit_msg>#729 Fixed problem with automatic and manual tooltip trigger those work simultaneously.<commit_after><link rel="import" href="/resources/polymer/polymer/polymer.html">
<link rel="import" href="/resources/components/tg-tooltip.html">
<!--
Provides tooltip support for component that uses this behaviour. In order to set tooltip for specific element in the component, one should
mark element with tooltip-text attribute.
-->
<script>
    (function () {
        var toolTipElement = document.createElement("tg-tooltip");
        /**
         * Returns the element in hierarchy that has tooltip-id attribute set otherwise returns null.
         */
        var extractActiveElement = function (currentElement, thisElement) {
            if (currentElement && currentElement !== thisElement.parentElement) {
                if (currentElement.hasAttribute("tooltip-text")) {
                    return currentElement;
                } else {
                    return extractActiveElement(currentElement.parentElement, thisElement);
                }
            }
            return null;
        };
        //Adds tooltip element to document's body so that it only one for all tooltips.
        Polymer.dom(document.body).appendChild(toolTipElement);
        Polymer.dom.flush();

        Polymer.TgBehaviors = Polymer.TgBehaviors || {};
        Polymer.TgBehaviors.TgTooltipBehavior = {
            properties: {
                triggerManual: {
                    type: String,
                    observer: "_triggerManualChanged"
                },

                /**
                 * Saved mouse positions.
                 */
                _mousePosX: Number,
                _mousePosY: Number,
                /**
                 * The handle for tooltip timer can be used to cancel tooltip timer. (Tooltip timer - the timer for tooltip to be shown).
                 */
                _tooltipTimer: {
                    type: Number
                },
                /**
                 * Element under mouse pointer, for which tooltip should be shown. Also this element should be marked with tooltip-id attribute.
                 */
                _activeComponent: {
                    type: Object
                }
            },

            ready: function () {
                this._handleMouseMove = this._handleMouseMove.bind(this);
                this._handleTooltipAtMousePos = this._handleTooltipAtMousePos.bind(this);
                this._hideTooltip = this._hideTooltip.bind(this);
                //Register mouse listeners for mouse events     
                this.addEventListener('mousemove', this._handleMouseMove);
                //Set the default values for properties.
                this.triggerManual = false;
            },

            /**
             * Displayes the tooltip with specified text at current mouse position.
             */
            showTooltip: function (tooltipText) {
                Polymer.dom(toolTipElement).innerHTML = tooltipText;
                toolTipElement.showAt(this._mousePosX, this._mousePosY);
            },

            /**
             * Hides the tooltip.
             */
            hideTooltip: function () {
                if (toolTipElement._showing) {
                    toolTipElement.hide();
                }
            },

{'fraction_non_alphanumeric': 0.08314158613284246, 'fraction_numerical': 0.0004601932811780948, 'mean_word_length': 1.525174283501162, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2566700', 'n_tokens_mistral': 1516, 'n_tokens_neox': 1437, 'n_words': 399}