|
1047 | 1047 | return doc.body || doc.querySelector('body'); |
1048 | 1048 | } |
1049 | 1049 |
|
| 1050 | + function clientX(e) { |
| 1051 | + if (e.type.indexOf('touch') === 0) { |
| 1052 | + return e.changedTouches ? e.changedTouches[0].clientX : 0; |
| 1053 | + } else { |
| 1054 | + return e.clientX; |
| 1055 | + } |
| 1056 | + } |
| 1057 | + |
| 1058 | + function clientY(e) { |
| 1059 | + if (e.type.indexOf('touch') === 0) { |
| 1060 | + return e.changedTouches ? e.changedTouches[0].clientY : 0; |
| 1061 | + } else { |
| 1062 | + return e.clientY; |
| 1063 | + } |
| 1064 | + } |
| 1065 | + |
| 1066 | + function pageX(e) { |
| 1067 | + if (e.type.indexOf('touch') === 0) { |
| 1068 | + return e.changedTouches ? e.changedTouches[0].pageX : 0; |
| 1069 | + } else { |
| 1070 | + return e.pageX; |
| 1071 | + } |
| 1072 | + } |
| 1073 | + |
| 1074 | + function pageY(e) { |
| 1075 | + if (e.type.indexOf('touch') === 0) { |
| 1076 | + return e.changedTouches ? e.changedTouches[0].pageY : 0; |
| 1077 | + } else { |
| 1078 | + return e.pageY; |
| 1079 | + } |
| 1080 | + } |
| 1081 | + |
1050 | 1082 | function getAllElementsByXpath(xpath, contextNode, doc) { |
1051 | 1083 | doc = doc || document; |
1052 | 1084 | contextNode = contextNode || doc; |
|
2519 | 2551 | color: black; |
2520 | 2552 | white-space: normal; |
2521 | 2553 | max-width: 640px; |
| 2554 | + max-width: min(80vw,640px); |
2522 | 2555 | width: max-content; |
2523 | 2556 | line-height: ${35 * this.tipsZoom}px; |
2524 | 2557 | word-break: break-all; |
|
2529 | 2562 | } |
2530 | 2563 | .search-jumper-tips * { |
2531 | 2564 | max-width: 640px; |
| 2565 | + max-width: min(80vw,640px); |
2532 | 2566 | } |
2533 | 2567 | .search-jumper-searchBar>.search-jumper-type { |
2534 | 2568 | padding: 0px; |
|
3480 | 3514 | bar.classList.remove("initShow"); |
3481 | 3515 | }; |
3482 | 3516 | let touchHandler = e => { |
3483 | | - if (this.touched) return; |
| 3517 | + if (this.touched || this.funcKeyCall) return; |
3484 | 3518 | this.touched = true; |
3485 | 3519 | bar.classList.add('disable-pointer'); |
3486 | 3520 | e.stopPropagation(); |
|
9855 | 9889 | } |
9856 | 9890 | } |
9857 | 9891 | } |
| 9892 | + let touchend = false; |
| 9893 | + ele.addEventListener('touchend', e => { |
| 9894 | + if (showTips) { |
| 9895 | + touchend = true; |
| 9896 | + self.waitForShowTips = true; |
| 9897 | + } |
| 9898 | + }, false); |
9858 | 9899 | ele.addEventListener('mouseenter', e => { |
| 9900 | + if (touchend) { |
| 9901 | + touchend = false; |
| 9902 | + return; |
| 9903 | + } |
9859 | 9904 | showTipsHandler(ele); |
9860 | 9905 | }, false); |
9861 | 9906 | ele.addEventListener('mousemove', e => { |
@@ -10375,13 +10420,13 @@ |
10375 | 10420 | let scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft; |
10376 | 10421 | let viewHeight = window.innerHeight || document.documentElement.clientHeight; |
10377 | 10422 | let tileOffset = searchData.prefConfig.tileOffset || 0; |
10378 | | - let clientX = e.pageX - self.bar.clientWidth / 2 - (getComputedStyle(document.documentElement).position !== 'static' ? document.documentElement.offsetLeft : 0); |
| 10423 | + let clientX = pageX(e) - self.bar.clientWidth / 2 - (getComputedStyle(document.documentElement).position !== 'static' ? document.documentElement.offsetLeft : 0); |
10379 | 10424 | if (clientX < 0) clientX = 5; |
10380 | 10425 | else if (clientX + self.bar.clientWidth > viewWidth + scrollLeft) clientX = viewWidth + scrollLeft - self.bar.clientWidth - 20; |
10381 | | - let clientY = e.pageY; |
10382 | | - if (e.clientY > viewHeight / 5) clientY -= (self.bar.clientHeight + 20 + tileOffset); |
| 10426 | + let clientY = pageY(e); |
| 10427 | + if (clientY > viewHeight / 5) clientY -= (self.bar.clientHeight + 20 + tileOffset); |
10383 | 10428 | else clientY += (20 + tileOffset); |
10384 | | - if (e.pageX < viewWidth / 2) { |
| 10429 | + if (pageX(e) < viewWidth / 2) { |
10385 | 10430 | self.bar.style.left = clientX + scrollLeft + "px"; |
10386 | 10431 | self.bar.style.transformOrigin = '0 0'; |
10387 | 10432 | } else { |
|
11945 | 11990 | let hideTimer; |
11946 | 11991 | let touchStart = false; |
11947 | 11992 |
|
11948 | | - let clientX = e => { |
11949 | | - if (e.type.indexOf('mouse') === 0) { |
11950 | | - return e.clientX; |
11951 | | - } else { |
11952 | | - return e.changedTouches[0].clientX; |
11953 | | - } |
11954 | | - }; |
11955 | | - |
11956 | | - let clientY = e => { |
11957 | | - if (e.type.indexOf('mouse') === 0) { |
11958 | | - return e.clientY; |
11959 | | - } else { |
11960 | | - return e.changedTouches[0].clientY; |
11961 | | - } |
11962 | | - }; |
11963 | | - |
11964 | 11993 | let mouseUpHandler = e => { |
11965 | 11994 | clearTimeout(hideTimer); |
11966 | 11995 | searchBar.bar.classList.remove("grabbing"); |
|
12258 | 12287 | searchBar.con.classList.add("targetInput"); |
12259 | 12288 | } else searchBar.con.classList.remove("targetInput"); |
12260 | 12289 | } |
| 12290 | + if (e.type === "touchend") { |
| 12291 | + if (searchData.prefConfig.selectToShow) { |
| 12292 | + setTimeout(() => { |
| 12293 | + if (getSelectStr()) { |
| 12294 | + searchBar.showInPage(true, e); |
| 12295 | + } else searchBar.waitForHide(1); |
| 12296 | + }, 0); |
| 12297 | + } |
| 12298 | + return; |
| 12299 | + } |
12261 | 12300 | waitForMouse = true; |
12262 | 12301 | setTimeout(() => { |
12263 | 12302 | waitForMouse = false; |
|
12402 | 12441 | }; |
12403 | 12442 | document.addEventListener('mousedown', mouseDownHandler); |
12404 | 12443 | document.addEventListener('dblclick', mouseDownHandler); |
| 12444 | + document.addEventListener('touchend', mouseDownHandler); |
12405 | 12445 | document.addEventListener('contextmenu', e => { |
12406 | 12446 | if (shown) e.preventDefault(); |
12407 | 12447 | shown = false; |
|
0 commit comments