Changeset 83451 in vbox
- Timestamp:
- Mar 26, 2020 7:17:38 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/htdocs/js/common.js
r83440 r83451 892 892 893 893 /** 894 * Highlights the desired revision.895 *896 * This is a WORKAROUND for browser where we cannot use the URL fragment to897 * do this.898 */899 function 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 /**934 894 * iframe.onload hook that repositions and resizes the tooltip. 935 895 * … … 947 907 if (g_oCurrentTooltip && g_oCurrentTooltip.oIFrame.contentWindow) 948 908 { 949 var oSubElement = g_oCurrentTooltip.oIFrame; 950 svnHistoryTooltipHighligh(g_oCurrentTooltip); /* do early as it increases the element padding */ 951 952 var cxSpace = Math.max(oSubElement.offsetLeft * 2, 0); /* simplified */ 953 var cySpace = Math.max(oSubElement.offsetTop * 2, 0); /* simplified */ 954 var cxNeeded = oSubElement.contentWindow.document.body.scrollWidth + cxSpace; 955 var cyNeeded = oSubElement.contentWindow.document.body.scrollHeight + cySpace; 909 var oIFrameElement = g_oCurrentTooltip.oIFrame; 910 var cxSpace = Math.max(oIFrameElement.offsetLeft * 2, 0); /* simplified */ 911 var cySpace = Math.max(oIFrameElement.offsetTop * 2, 0); /* simplified */ 912 var cxNeeded = oIFrameElement.contentWindow.document.body.scrollWidth + cxSpace; 913 var cyNeeded = oIFrameElement.contentWindow.document.body.scrollHeight + cySpace; 956 914 var cx = Math.min(cxNeeded, g_oCurrentTooltip.cxMax); 957 915 var cy; 958 916 959 917 g_oCurrentTooltip.oElm.width = cx + 'px'; 960 o SubElement.width = (cx - cxSpace) + 'px';918 oIFrameElement.width = (cx - cxSpace) + 'px'; 961 919 if (cx >= cxNeeded) 962 920 { 963 921 //console.log('svnHistoryTooltipOnLoad: overflowX -> hidden'); 964 o SubElement.style.overflowX = 'hidden';922 oIFrameElement.style.overflowX = 'hidden'; 965 923 } 966 924 else 967 925 { 968 o SubElement.style.overflowX = 'scroll';926 oIFrameElement.style.overflowX = 'scroll'; 969 927 } 970 928 … … 980 938 981 939 g_oCurrentTooltip.oElm.height = cy + 'px'; 982 o SubElement.height = (cy - cySpace) + 'px';940 oIFrameElement.height = (cy - cySpace) + 'px'; 983 941 if (cy >= cyNeeded) 984 942 { 985 943 //console.log('svnHistoryTooltipOnLoad: overflowY -> hidden'); 986 o SubElement.style.overflowY = 'hidden';944 oIFrameElement.style.overflowY = 'hidden'; 987 945 } 988 946 else 989 947 { 990 o SubElement.style.overflowY = 'scroll';948 oIFrameElement.style.overflowY = 'scroll'; 991 949 } 992 950 993 951 //console.log('cyNeeded='+cyNeeded+' cyMax='+g_oCurrentTooltip.cyMax+' cySpace='+cySpace+' cy='+cy); 994 //console.log('o SubElement.offsetTop='+oSubElement.offsetTop);952 //console.log('oIFrameElement.offsetTop='+oIFrameElement.offsetTop); 995 953 //console.log('svnHistoryTooltipOnLoad: cx='+cx+'cxMax='+g_oCurrentTooltip.cxMax+' cxNeeded='+cxNeeded+' cy='+cy+' cyMax='+g_oCurrentTooltip.cyMax); 996 954 … … 1042 1000 function svnHistoryTooltipShowEx(oEvt, sRepository, iRevision, sUrlPrefix) 1043 1001 { 1044 var sKey = svnHistoryTooltipCalcId(sRepository, iRevision); 1045 var oTooltip = g_dTooltips[sKey]; 1046 var oParent = oEvt.currentTarget; 1002 var sKey = svnHistoryTooltipCalcId(sRepository, iRevision); 1003 var oParent = oEvt.currentTarget; 1047 1004 //console.log('svnHistoryTooltipShow ' + sRepository); 1048 1005 1049 1006 function svnHistoryTooltipDelayedShow() 1050 1007 { 1051 var oSubElement;1052 1008 var sSrc; 1053 1009 1054 oTooltip = g_dTooltips[sKey];1010 var oTooltip = g_dTooltips[sKey]; 1055 1011 //console.log('svnHistoryTooltipDelayedShow ' + sRepository + ' ' + oTooltip); 1056 1012 if (!oTooltip) … … 1063 1019 oTooltip.oElm = document.createElement('div'); 1064 1020 oTooltip.oElm.setAttribute('id', sKey); 1065 oTooltip.oElm.setAttribute('class', 'tmvcstooltip'); 1021 oTooltip.oElm.className = 'tmvcstooltip'; 1022 oTooltip.oElm.style.display = 'none'; /* Note! Must stay hidden till loaded, or parent jumps with #rXXXX.*/ 1066 1023 oTooltip.oElm.style.position = 'absolute'; 1067 oTooltip.oElm.style.zIndex = 6001;1024 oTooltip.oElm.style.zIndex = 6001; 1068 1025 oTooltip.xPos = 0; 1069 1026 oTooltip.yPos = 0; … … 1075 1032 oTooltip.iRevision = iRevision; /**< For :target/highlighting */ 1076 1033 1077 oSubElement = document.createElement('iframe');1078 o SubElement.setAttribute('id', sKey + '_iframe');1079 o SubElement.setAttribute('style', 'position: relative;"');1080 o SubElement.onmouseenter= tooltipElementOnMouseEnter;1081 o SubElement.onmouseout= tooltipElementOnMouseOut;1082 oTooltip.oElm.appendChild(o SubElement);1083 oTooltip.oIFrame = o SubElement;1034 var oIFrameElement = document.createElement('iframe'); 1035 oIFrameElement.setAttribute('id', sKey + '_iframe'); 1036 oIFrameElement.style.position = 'relative'; 1037 oIFrameElement.onmouseenter = tooltipElementOnMouseEnter; 1038 oIFrameElement.onmouseout = tooltipElementOnMouseOut; 1039 oTooltip.oElm.appendChild(oIFrameElement); 1040 oTooltip.oIFrame = oIFrameElement; 1084 1041 g_dTooltips[sKey] = oTooltip; 1085 1042 1086 1043 document.body.appendChild(oTooltip.oElm); 1087 1044 1088 oSubElement.onload = function() { tooltipReallyShow(oTooltip, oParent); svnHistoryTooltipOnLoad(); }; 1045 oIFrameElement.onload = function() { /* A slight delay here to give time for #rXXXX scrolling before we show it. */ 1046 setTimeout(function(){tooltipReallyShow(oTooltip, oParent); svnHistoryTooltipOnLoad();}, 64); 1047 }; 1089 1048 1090 1049 var sUrl = sUrlPrefix + 'index.py?Action=VcsHistoryTooltip&repo=' + sRepository 1091 1050 + '&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 1051 + '&cEntries=' + g_cTooltipSvnRevisions 1052 + '#r' + iRevision; 1053 oIFrameElement.src = sUrl; 1097 1054 } 1098 1055 else 1099 1056 { 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(); 1057 /* 1058 * Show the existing one, possibly with different :target/highlighting. 1059 */ 1060 if (oTooltip.iRevision != iRevision) 1061 { 1062 //console.log('Changing revision ' + oTooltip.iRevision + ' -> ' + iRevision); 1063 oTooltip.oIFrame.contentWindow.location.hash = '#r' + iRevision; 1064 if (!isBrowserFirefox()) /* Chrome updates stuff like expected; Firefox OTOH doesn't change anything. */ 1065 { 1066 setTimeout(function() { /* Slight delay to make sure it scrolls before it's shown. */ 1067 tooltipReallyShow(oTooltip, oParent); 1068 svnHistoryTooltipOnLoad(); 1069 }, 64); 1070 } 1071 else 1072 oTooltip.oIFrame.contentWindow.location.reload(); 1073 } 1074 else 1075 { 1076 tooltipReallyShow(oTooltip, oParent); 1077 svnHistoryTooltipOnLoad(); 1078 } 1106 1079 } 1107 1080 } 1108 1081 1109 1082 /* 1110 * Delay the change .1083 * Delay the change (in case the mouse moves on). 1111 1084 */ 1112 1085 tooltipResetShowTimer();
Note:
See TracChangeset
for help on using the changeset viewer.