PvXwiki
Advertisement

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
RLQ.push(function () {
    if( window.navigator.userAgent.indexOf('Mozilla') != -1 ) {
        firefoxGwpvxTooltips();
    }
});

/* Workaround for broken hover "overlib" tooltips in Mozilla Firefox */
function firefoxGwpvxTooltips() {
    // Get all elements with mouseover events.
    var a = $('*[onmouseover]');

    // Add fixed position element in top left
    $('body').append('<div id="gwpvxhoverdiv" style="position:absolute; top:-5000px; left:-5000px;"></div>')

    // New global function - Populate and position the tooltip
    window.gwpvxTooltipOpen = function(content) {
        // Populate content
        $('#gwpvxhoverdiv').html(content);

        // Track cursor and move tooltip nearby
        $(document).on('mousemove.gwpvxtooltip', function(e) {
            $('#gwpvxhoverdiv').css('left',e.pageX).css('top',e.pageY);
        });
    }

    // New global function - Reposition the tooltip out of sight
    window.gwpvxTooltipClose = function() {
        // Hide the element and reset content
        $('#gwpvxhoverdiv').css('top','-5000px').css('left','-5000px');

        // Switch off cursor tracking
        $(document).off('mousemove.gwpvxtooltip');
    }

    // Replace the ancient overlib onmouseover/onmouseout events
    $.each(a, function(i,v){
        // Get original expression
        var old_onmouseover = v.attributes.onmouseover.value;

        // Check with a pattern to see if it is a match. If no match, skip.
        var pattern = new RegExp("return overlib\\(div\\(\'(load\\d+)\'\\)\.innerHTML\\)\\;");
        if ( !(old_onmouseover.match(pattern)) ) {
            return;
        }

        // For valid matches, replace the weird "div('id')" notation with "document.getElementById('id')"
        var new_onmouseover = old_onmouseover.replace(pattern, 'gwpvxTooltipOpen(document.getElementById(\'$1\').innerHTML );');
        var new_onmouseout = 'gwpvxTooltipClose()';
        $(v).attr('onmouseover', new_onmouseover);
        $(v).attr('onmouseout', new_onmouseout);

        // Add a class so we can target properly.
        $(v).addClass('gwpvxhover');
    });
}
Advertisement