Files
OrcaSlicer/resources/web/guide/21/index.html
yw4z 133dc1c8e5 Printer selection dialog redesign (#12248)
* init

* remove debug

* update

* cleanup

* update

* animate sidebar and search bar when reduce motion not enabled

* add custom snappy scrolling to fix lags

* cleanup

* update

* scroll to vendor after layout change

* improve snapping on events

* update

* match UI of setup guide
2026-05-11 02:16:13 +03:00

365 lines
12 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="max-age=7200" />
<title>引导_P21</title>
<link rel="stylesheet" type="text/css" href="../../include/global.css" /> <!-- ORCA One for all-->
<link rel="stylesheet" type="text/css" href="../css/common.css" />
<link rel="stylesheet" type="text/css" href="21.css" />
<link rel="stylesheet" type="text/css" href="../css/dark.css" />
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="../js/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../js/json2.js"></script>
<script type="text/javascript" src="../../data/text.js"></script>
<script type="text/javascript" src="../js/globalapi.js"></script>
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="21.js"></script>
</head>
<body onLoad="OnInit()">
<div id="Title">
<div class="trans" tid="t10">Printer Selection</div>
</div>
<div id="SidebarContainer">
<div id="Sidebar" class="thin-scroll">
<div class="title">Vendors</div>
<div class="area" id="SidebarVendors">
<!-- <div class="SidebarItem"></div> -->
</div>
</div>
<div class="back" onclick="document.getElementById('SidebarContainer').setAttribute('open', '0')"></div>
</div>
<div class="SidebarBtn ButtonStyleRegular" onclick="document.getElementById('SidebarContainer').setAttribute('open', '1')">
<div class="icon16"></div>
</div>
<div class="search" hasvalue="0">
<div class="search-icon icon16"></div>
<input type="text" class="searchTerm" placeholder=" " oninput="textInput(this)">
<span class="search-placeholder trans">Search...</span>
</div>
<div class="LayoutSelector">
<div class="TabGroup">
<div class="TabButton" onclick="LayoutMode('compact-list')" ><div class="icon16"></div></div>
<div class="TabButton" onclick="LayoutMode('compact-cover')"><div class="icon16"></div></div>
<div class="TabButton" onclick="LayoutMode('large-cover')" ><div class="icon16"></div></div>
</div>
</div>
<div id="Content" class="thin-scroll">
<!--<div class="OneVendorBlock" Vendor="BBL">
<div class="BlockBanner">
<a>BBL-3DP</a>
<div class="BannerBtns">
<div class="ButtonStyleConfirm ButtonTypeWindow trans" onClick="SelectPrinterAll('BBL')">所有</div>
<div class="ButtonStyleRegular ButtonTypeWindow trans" onClick="SelectPrinterNone('BBL')">无</div>
</div>
</div>
<div class="PrinterArea">
<div class="PrinterBlock">
<div class="PImg">
<img class="ModelThumbnail" src="p2.jpg" />
<div class="ModelCheckBox ModelCheckBoxSelected" model="BBL-3DP-V5NORMAL" onClick="ChooseModel('BBL-3DP-V5NORMAL')"></div>
</div>
<div class="PName">BBL-3DP-V4NORMAL</div>
<div class="pNozzel TextS2"><input id="ZZ" type="checkbox" model="BBL-3DP-V4NORMAL" nozzel="0.4" vendor="BBL" />0.4mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V4NORMAL" nozzel="0.1" vendor="BBL" />0.1mm nozzle</div>
</div>
<div class="PrinterBlock">
<div class="PImg">
<img class="ModelThumbnail" src="p2.jpg" />
<div class="ModelCheckBox"></div>
</div>
<div class="PName">BBL-3DP-V4NORMAL</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.4" vendor="BBL" />0.4mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.2" vendor="BBL" />0.22mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.1" vendor="BBL" />0.1mm nozzle</div>
</div>
<div class="PrinterBlock">
<div class="PImg">
<img class="ModelThumbnail" src="p2.jpg" />
<div class="ModelCheckBox"></div>
</div>
<div class="PName">BBL-3DP-V4NORMAL</div>
<div class="pNozzel TextS2"><input id="ZZ" type="checkbox" model="BBL-3DP-V4NORMAL" nozzel="0.4" vendor="BBL" />0.4mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V4NORMAL" nozzel="0.1" vendor="BBL" />0.11mm nozzle</div>
</div>
<div class="PrinterBlock">
<div class="PImg">
<img class="ModelThumbnail" src="p2.jpg" />
<div class="ModelCheckBox ModelCheckBoxSelected"></div>
</div>
<div class="PName">BBL-3DP-V4NORMAL</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.4" vendor="BBL" />0.4mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.2" vendor="BBL" />0.22mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.1" vendor="BBL" />0.1mm nozzle</div>
</div>
</div>
</div>
<div class="OneVendorBlock" Vendor="BAMBU">
<div class="BlockBanner">
<a>BAMBU-3DP</a>
<div class="BannerBtns">
<div class="SmallBtn_Green trans" onClick="SelectPrinterAll('BAMBU')">所有</div>
<div class="SmallBtn trans" onClick="SelectPrinterNone('BAMBU')">无</div>
</div>
</div>
<div class="PrinterArea">
<div class="PrinterBlock">
<div class="PImg">
<img class="ModelThumbnail" src="p2.jpg" />
<div class="ModelCheckBox ModelCheckBoxSelected"></div>
</div>
<div class="PName TextS1">BBL-3DP-V4NORMAL</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V4NORMAL" nozzel="0.4" vendor="BAMBU" />0.4mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V4NORMAL" nozzel="0.1" vendor="BAMBU" />0.1mm nozzle</div>
</div>
<div class="PrinterBlock">
<div class="PImg">
<img class="ModelThumbnail" src="p2.jpg" />
<div class="ModelCheckBox ModelCheckBoxSelected"></div>
</div>
<div class="PName TextS1">BBL-3DP-V4NORMAL</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.4" vendor="BAMBU" />0.4mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.2" vendor="BAMBU" />0.2mm nozzle</div>
<div class="pNozzel TextS2"><input type="checkbox" model="BBL-3DP-V5NORMAL" nozzel="0.1" vendor="BAMBU" />0.1mm nozzle</div>
</div>
</div>
</div>-->
</div>
<div id="AcceptArea">
<div class="ButtonStyleRegular ButtonTypeChoice trans" id="PreBtn" tid="t8" onclick="window.open('../1/index.html','_self')">Back</div>
<div class="ButtonStyleConfirm ButtonTypeChoice trans" id="AcceptBtn" tid="t9" onclick="GotoFilamentPage()">Next</div>
</div>
<div id="NoticeMask"></div>
<div id="NoticeBody">
<div id="NoticeBar" class="trans" tid="t18">error</div>
<div id="NoticeContent">
<div id="NoticeText" class="trans" tid="t37">At least one printer must be selected.</div>
<div id="NoticeBtns">
<div class="ButtonStyleConfirm ButtonTypeChoice trans" tid="t36" onClick="ShowNotice(0)">ok</div>
</div>
</div>
</div>
</body>
<script>
const SearchBox = document.querySelector('.searchTerm');
document.onkeydown = function (event) {
var e = event || window.event || arguments.callee.caller.arguments[0];
// ORCA focus search bar on key input
// SearchBox not in focus && writable character && non modifier
if (document.activeElement != SearchBox && e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
SearchBox.focus();
}
// Close sidebar
document.getElementById('SidebarContainer').setAttribute('open', '0')
//if (window.event) {
// try { e.keyCode = 0; } catch (e) { }
// e.returnValue = true;
//}
};
let pModel = {};
let ModelNozzleSelected = {};
function textInput(obj) {
FilterModelList(obj.value);
}
const $content = $('#Content');
// SNAPPY SCROLLING WITHOUT LAGS
const SNAP_DELAY = 600;
const SNAP_DURATION = 200;
const SNAP_CORR = 8; // error correction / tolerance
let scrollTimer = null;
let lastScrollTop = 0;
let scrollDir = 'down';
let isSnapping = false;
let snapRafId = null;
let lastSnapTarget = null;
let waitingForUserScroll = false;
function findSnap(cur, dir) {
if (lastSnapTarget !== null && Math.abs(cur - lastSnapTarget) < SNAP_CORR) return null;
const savedScroll = cur;
$content[0].scrollTop = 0; // Temporarily scroll to 0 so getBoundingClientRect can get absolute positions
let bcTop = el=>(el.getBoundingClientRect().top);
const contentTop = bcTop($content[0]);
const bannerH = ($content.find('.BlockBanner')[0] || {}).offsetHeight || 0;
const firstCard = $content.find('.PrinterBlock')[0];
const firstArea = $content.find('.PrinterArea')[0];
const cardGap = (firstCard && firstArea) ? (bcTop(firstCard) - bcTop(firstArea)) : 0;
const candidates = $content.find('.BlockBanner, .PrinterBlock').get();
if (dir === 'up') candidates.reverse();
let result = lastSeen = null;
for (const el of candidates) {
const snapTo = Math.round(
el.classList.contains('BlockBanner')
? (bcTop(el.closest('.OneVendorBlock')) - contentTop)
: Math.max(0, bcTop(el) - contentTop - bannerH - cardGap)
);
if (snapTo != lastSeen){
lastSeen = snapTo;
if (dir === 'down' && snapTo > cur + SNAP_CORR) { result = snapTo; break; }
if (dir === 'up' && snapTo < cur - SNAP_CORR) { result = snapTo; break; }
}
}
$content[0].scrollTop = savedScroll; // Restore scroll position
return result;
}
function smoothScrollTo(target) {
if (snapRafId) {
cancelAnimationFrame(snapRafId);
snapRafId = null;
}
const el = $content[0];
const from = el.scrollTop;
const dist = target - from;
const t0 = performance.now();
const ease = t => t < 0.5 ? 2*t*t : -1 + (4 - 2*t)*t;
function onDone() {
el.scrollTop = target;
lastScrollTop = lastSnapTarget = target;
waitingForUserScroll = true;
clearTimeout(scrollTimer);
scrollTimer = null;
snapRafId = null;
isSnapping = false;
}
if (Math.abs(dist) < 2)
return onDone();
snapRafId = requestAnimationFrame(function step(now) {
const p = Math.min((now - t0) / SNAP_DURATION, 1);
el.scrollTop = from + dist * ease(p);
if (p < 1)
snapRafId = requestAnimationFrame(step);
else
onDone();
});
}
function armSnap() {
waitingForUserScroll = false;
lastSnapTarget = null;
}
$content.on('scroll', function() {
if (isSnapping) return;
if (this.scrollTop > lastScrollTop + 1) scrollDir = 'down';
else if (this.scrollTop < lastScrollTop - 1) scrollDir = 'up';
lastScrollTop = this.scrollTop;
if (waitingForUserScroll) return;
clearTimeout(scrollTimer);
scrollTimer = setTimeout(()=>{
if (isSnapping) return;
const target = findSnap($content[0].scrollTop, scrollDir);
if (target){
isSnapping = true;
smoothScrollTo(target);
}
}, SNAP_DELAY);
});
let touchY = 0;
$content[0].addEventListener('touchstart', e => {
touchY = e.touches[0].clientY;
armSnap();
}, { passive: true });
$content[0].addEventListener('touchmove', e => {
const dy = touchY - e.touches[0].clientY;
if (Math.abs(dy) > 3)
scrollDir = dy > 0 ? 'down' : 'up';
}, { passive: true });
// Re-arm snap system on user scroll
$content[0].addEventListener('wheel', armSnap, { passive: true });
// Re-arm on after scrollbar usage
$content[0].addEventListener('pointerdown', e => {
if (e.target === $content[0])
armSnap();
});
// Re-arm on keyboard scroll or focus changes
document.addEventListener('keydown', e => {
if (document.activeElement != SearchBox){
let scrollKeys = ['ArrowUp','ArrowDown','PageUp','PageDown',' '];
let hasFocus = $content[0].contains(document.activeElement);
if(scrollKeys.includes(e.key) || (hasFocus && e.which == 9))
armSnap();
}
});
// ORCA unfocus search bar while scrolling and its content empty
$content[0].addEventListener("scroll", () => {
if (document.activeElement === SearchBox && SearchBox.value == "")
SearchBox.blur();
});
// LAYOUT SELECTOR
const LayoutSelector = document.querySelector('.LayoutSelector > .TabGroup');
const LayoutBtns = Array.from(LayoutSelector.children);
const LayoutTypes = ["compact-list","compact-cover","large-cover"];
function LayoutMode(value) {
if($content[0].getAttribute("layout") === value)
return;
// find current visible vendor and scroll to it after layout change
let target = null;
for (const el of $content.find('.OneVendorBlock')) {
if (el.getBoundingClientRect().bottom - $content[0].getBoundingClientRect().top >= -1) {
target = el.getAttribute("vendor");
break;
}
}
LayoutBtns.forEach(el => el.classList.remove('selected'));
LayoutBtns[LayoutTypes.indexOf(value)].classList.add('selected');
$content[0].setAttribute("layout", value);
if (target) scrollToVendor(target);
}
LayoutMode("large-cover");
</script>
</html>