VirtualBox

Changeset 83440 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Mar 26, 2020 2:20:22 PM (5 years ago)
Author:
vboxsync
Message:

TestManager/vcstooltip: Don't specify a URL fragment because most browsers will scroll the main viewport/window. Firefox doesn't, but now I couldn't find a good way of changing the fragment without the iframe jumping around. Sigh. This stuff drives me nuts, always something that doens't work the way you want.

Location:
trunk/src/VBox/ValidationKit/testmanager/htdocs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/htdocs/css/common.css

    r83410 r83440  
    11511151    border:     0px none;
    11521152    width:      100%;
    1153     overflow:   auto;
     1153    //overflow:   auto;
     1154    overflow:   hidden;
    11541155}
    11551156
  • trunk/src/VBox/ValidationKit/testmanager/htdocs/css/tooltip.css

    r82968 r83440  
    115115
    116116/* This helps highlighting the revision we're showing the tooltip for. */
    117 .tmvcstimeline :target, .tmvcstimeline :target + dd {
     117.tmvcstimeline-highlight, .tmvcstimeline :target, .tmvcstimeline :target + dd {
    118118    background-color: #d8e8ff;
    119119    padding-top:    0.2em;
  • trunk/src/VBox/ValidationKit/testmanager/htdocs/js/common.js

    r83360 r83440  
    3232var g_ksParamRedirectTo = 'RedirectTo';
    3333
     34
     35/**
     36 * Detects the firefox browser.
     37 */
     38function isBrowserFirefox()
     39{
     40    return typeof InstallTrigger !== 'undefined';
     41}
     42
     43/**
     44 * Detects the google chrome browser.
     45 * @note Might be confused with edge chromium
     46 */
     47function isBrowserChrome()
     48{
     49    var oChrome = window.chrome;
     50    if (!oChrome)
     51        return false;
     52    return !!oChrome.runtime || !oChrome.webstore;
     53}
     54
     55/**
     56 * Detects the chromium-based edge browser.
     57 */
     58function isBrowserEdgeChromium()
     59{
     60    if (!isBrowserChrome())
     61        return false;
     62    return navigation.userAgent.indexOf('Edg') >= 0
     63}
     64
     65/**
     66 * Detects the safari browser (v3+).
     67 */
     68function isBrowserSafari()
     69{
     70    /* Check if window.HTMLElement is a function named 'HTMLElementConstructor()'?
     71       Should work for older safari versions. */
     72    var sStr = window.HTMLElement.toString();
     73    if (/constructor/i.test(sStr))
     74        return true;
     75
     76    /* Check the class name of window.safari.pushNotification.  This works for current. */
     77    var oSafari = window['safari'];
     78    if (oSafari)
     79    {
     80        if (typeof oSafari !== 'undefined')
     81        {
     82            var oPushNotify = oSafari.pushNotification;
     83            if (oPushNotify)
     84            {
     85                sStr = oPushNotify.toString();
     86                if (/\[object Safari.*Notification\]/.test(sStr))
     87                    return true;
     88            }
     89        }
     90    }
     91    return false;
     92}
    3493
    3594/**
     
    691750function tooltipRepositionOnLoad()
    692751{
     752    //console.log('tooltipRepositionOnLoad');
    693753    if (g_oCurrentTooltip)
    694754    {
     
    784844    }
    785845
     846    oTooltip.oElm.style.position = 'absolute';
    786847    oTooltip.oElm.style.display  = 'block';
    787     oTooltip.oElm.style.position = 'absolute';
    788848    oRect = oRelTo.getBoundingClientRect();
    789849    oTooltip.oRelToRect = oRect;
     
    832892
    833893/**
     894 * Highlights the desired revision.
     895 *
     896 * This is a WORKAROUND for browser where we cannot use the URL fragment to
     897 * do this.
     898 */
     899function svnHistoryTooltipHighligh(oTooltip)
     900{
     901    var iRevision = oTooltip.iRevision;
     902    if (false && isBrowserFirefox())
     903    {
     904        var sDesiredHash = '#r' + iRevision;
     905        var sCurrentHash = oTooltip.oIFrame.contentWindow.location.hash;
     906        //console.log('before: location.hash=' + sCurrentHash + ' src=' + oTooltip.oIFrame.src);
     907        if (sCurrentHash != sDesiredHash)
     908        {
     909            oTooltip.oIFrame.contentWindow.location.hash = sDesiredHash;
     910            oTooltip.oIFrame.contentWindow.location.reload();
     911            //console.log('after:  location.hash=' + oTooltip.oIFrame.contentWindow.location.hash + ' src='+oTooltip.oIFrame.src);
     912        }
     913        return true;
     914    }
     915
     916    /* Clear old selection - not needed as we appear to be reloading the page each time... */
     917    var aoElements = oTooltip.oIFrame.contentDocument.getElementsByTagName('dt');
     918    var i;
     919    for (i = 0; i < aoElements.length; i++)
     920        aoElements[i].className = '';
     921    aoElements = oTooltip.oIFrame.contentDocument.getElementsByTagName('dd');
     922    for (i = 0; i < aoElements.length; i++)
     923        aoElements[i].className = '';
     924
     925    /* New selection: */
     926    var oDt = oTooltip.oIFrame.contentDocument.getElementById('r' + iRevision);
     927    oDt.className = 'tmvcstimeline-highlight';
     928    oDt.nextElementSibling.className = 'tmvcstimeline-highlight';
     929
     930    return true;
     931}
     932
     933/**
    834934 * iframe.onload hook that repositions and resizes the tooltip.
    835935 *
     
    848948    {
    849949        var oSubElement = g_oCurrentTooltip.oIFrame;
     950        svnHistoryTooltipHighligh(g_oCurrentTooltip); /* do early as it increases the element padding */
     951
    850952        var cxSpace  = Math.max(oSubElement.offsetLeft * 2, 0); /* simplified */
    851953        var cySpace  = Math.max(oSubElement.offsetTop  * 2, 0); /* simplified */
     
    9641066            oTooltip.oElm.style.position = 'absolute';
    9651067            oTooltip.oElm.style.zIndex = 6001;
    966             oTooltip.xPos    = 0;
    967             oTooltip.yPos    = 0;
    968             oTooltip.cxMax   = 0;
    969             oTooltip.cyMax   = 0;
    970             oTooltip.cyMaxUp = 0;
    971             oTooltip.xScroll = 0;
    972             oTooltip.yScroll = 0;
     1068            oTooltip.xPos      = 0;
     1069            oTooltip.yPos      = 0;
     1070            oTooltip.cxMax     = 0;
     1071            oTooltip.cyMax     = 0;
     1072            oTooltip.cyMaxUp   = 0;
     1073            oTooltip.xScroll   = 0;
     1074            oTooltip.yScroll   = 0;
     1075            oTooltip.iRevision = iRevision;   /**< For  :target/highlighting */
    9731076
    9741077            oSubElement = document.createElement('iframe');
    9751078            oSubElement.setAttribute('id', sKey + '_iframe');
    9761079            oSubElement.setAttribute('style', 'position: relative;"');
    977             oSubElement.onload       = function() {svnHistoryTooltipOnLoad(); setTimeout(svnHistoryTooltipOnLoad,0);};
    9781080            oSubElement.onmouseenter = tooltipElementOnMouseEnter;
    9791081            oSubElement.onmouseout   = tooltipElementOnMouseOut;
     
    9831085
    9841086            document.body.appendChild(oTooltip.oElm);
     1087
     1088            oSubElement.onload = function() { tooltipReallyShow(oTooltip, oParent); svnHistoryTooltipOnLoad();  };
     1089
     1090            var sUrl = sUrlPrefix + 'index.py?Action=VcsHistoryTooltip&repo=' + sRepository
     1091                     + '&rev=' + svnHistoryTooltipCalcLastRevision(iRevision)
     1092                     + '&cEntries=' + g_cTooltipSvnRevisions;
     1093            if (false && isBrowserFirefox()) /* The other browsers will scroll the main window when jumping to the revision. */
     1094                sUrl = sUrl + '#r' + iRevision;
     1095            oSubElement.setAttribute('src', sUrl);
     1096
    9851097        }
    9861098        else
    9871099        {
    988             oSubElement = oTooltip.oIFrame;
    989         }
    990 
    991         oSubElement.setAttribute('src', sUrlPrefix + 'index.py?Action=VcsHistoryTooltip&repo=' + sRepository
    992                                  + '&rev=' + svnHistoryTooltipCalcLastRevision(iRevision)
    993                                  + '&cEntries=' + g_cTooltipSvnRevisions
    994                                  + '#r' + iRevision);
    995         tooltipReallyShow(oTooltip, oParent);
    996         /* Resize and repositioning hacks. */
    997         svnHistoryTooltipOnLoad();
    998         setTimeout(svnHistoryTooltipOnLoad, 0);
     1100            /* Show the existing one with different :target/highlighting */
     1101            oTooltip.iRevision = iRevision;
     1102            if (false && isBrowserFirefox()) /* The other browsers will scroll the main window when jumping to the revision. */
     1103                svnHistoryTooltipHighligh(oTooltip);
     1104            tooltipReallyShow(oTooltip, oParent);
     1105            svnHistoryTooltipOnLoad();
     1106        }
    9991107    }
    10001108
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette