带有多个显示事件的qTip2不起作用

问题描述 投票:2回答:1

qTip2仅在我指定多个事件时才单击。[mouseenter]或[focus]单独工作都很好,但是我想确保它在所有事件上都起作用,以防在移动设备上没有mouseenter事件。

$('span#message').qtip({
    content: {
        text: 'some text'
    },
    show: {
        event: 'click mouseenter focus'
    },
    hide: {
        event: 'click mouseleave blur'
    }
});
jquery qtip2
1个回答
0
投票
PROTOTYPE._bindEvents = function(showEvents, hideEvents, showTargets, hideTargets, showCallback, hideCallback) { // Get tasrgets that lye within both var similarTargets = showTargets.filter( hideTargets ).add( hideTargets.filter(showTargets) ), toggleEvents = []; // If hide and show targets are the same... if(similarTargets.length) { // Filter identical show/hide events $.each(hideEvents, function(i, type) { var showIndex = $.inArray(type, showEvents); // Both events are identical, remove from both hide and show events // and append to toggleEvents showIndex > -1 && toggleEvents.push( showEvents.splice( showIndex, 1 )[0] ); }); // Toggle events are special case of identical show/hide events, which happen in sequence if(toggleEvents.length) { // Bind toggle events to the similar targets this._bind(similarTargets, toggleEvents, function(event) { var state = this.rendered ? this.tooltip[0].offsetWidth > 0 : false; (state ? hideCallback : showCallback).call(this, event); }); // Remove the similar targets from the regular show/hide bindings showTargets = showTargets.not(similarTargets); hideTargets = hideTargets.not(similarTargets); } } // Apply show/hide/toggle events this._bind(showTargets, showEvents, showCallback); this._bind(hideTargets, hideEvents, hideCallback); };

收件人:

PROTOTYPE._bindEvents = function(showEvents, hideEvents, showTargets, hideTargets, showCallback, hideCallback) {
    // Get tasrgets that lye within both
    var similarTargets = showTargets.filter( hideTargets ).add( hideTargets.filter(showTargets) ),
        toggleEvents = [];

    // If hide and show targets are the same...
    if(similarTargets.length) {

        // Filter identical show/hide events
        $.each(hideEvents, function(i, type) {
            var showIndex = $.inArray(type, showEvents);

            // Both events are identical, remove from both hide and show events
            // and append to toggleEvents
            showIndex > -1 && toggleEvents.push(type);
        });
        showEvents = showEvents.filter((el) => !toggleEvents.includes(el));
        hideEvents = hideEvents.filter((el) => !toggleEvents.includes(el));

        // Toggle events are special case of identical show/hide events, which happen in sequence
        if(toggleEvents.length) {
            // Bind toggle events to the similar targets
            this._bind(similarTargets, toggleEvents, function(event) {
                var state = this.rendered ? this.tooltip[0].offsetWidth > 0 : false;
                (state ? hideCallback : showCallback).call(this, event);
            });
        }
    }

    // Apply show/hide/toggle events
    this._bind(showTargets, showEvents, showCallback);
    this._bind(hideTargets, hideEvents, hideCallback);
};
© www.soinside.com 2019 - 2024. All rights reserved.