Files
web-at-transit-mock/ui/partials/busDetail.html
T
Bkk1234 750b4a2ea8 mock: three search tabs - stop code, place name, near me
- busStop.html: added the third tab (data-mode=near) and its own panel with
  the location button, hint and result area; removed the near button from the
  toolbar and deleted the old on-screen numpad markup
- busStop.search.js: MODE_NEAR in setMode, disables the other panels, hides
  the stop list while ranked results are shown, skips filtering in that mode,
  and removed the dead initNumpad code
- security gate: the tab is revealed only when isSecureContext and
  navigator.geolocation exist; otherwise it stays hidden and the mode is
  refused
- map.js: re-enable the button after a successful lookup
- i18n: stops.modeNear / nearCta / nearHint
- bump SW version to 2026.09.27.98

Verified on localhost:8090 - three tabs, near mode shows a map with 8 ranked
stops, button re-enables and works again, switching back restores the list;
with isSecureContext forced false the tab is hidden and unselectable.
2026-10-24 00:11:56 +07:00

215 lines
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<style>
/* ============================================================
busDetail (#/routes, #/routes/:id) — หน้ารายละเอียดสายรถ
รถประจำสาย + ติดต่อผู้ประกอบการ รวมอยู่ในการ์ดเดียว (ขึ้นก่อน)
============================================================ */
.mu-page { padding: 20px 0 48px; }
/* --- header --- */
.mu-breadcrumb { color: #6f7b95; font-size: .88rem; margin: 0 0 12px; }
.mu-breadcrumb a { color: #7a4cc0; text-decoration: none; font-weight: 600; }
.mu-page-title {
display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
margin: 0 0 16px; font-size: 1.6rem; color: #1f2a44; font-weight: 800; line-height: 1.25;
}
.mu-route-chip {
display: inline-flex; align-items: center; justify-content: center;
min-width: 54px; height: 54px; padding: 0 16px; border-radius: 14px;
background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff;
font-weight: 800; font-size: 1.35rem; flex: none;
box-shadow: 0 6px 14px rgba(122, 76, 192, .25);
}
/* สีพื้นหลังของเลขสาย เปลี่ยนตามหมวดเส้นทาง (route_groups.json)
น้ำเงิน = เข้ากรุงเทพฯ · ม่วง = ระหว่างจังหวัด · ชมพู = ภายในจังหวัด · เทา = หมวดอื่น/ไม่ระบุ */
.mu-route-chip.grp-bangkok { background: linear-gradient(135deg, #1a53a8, #3f82d8); box-shadow: 0 6px 14px rgba(31, 95, 191, .25); }
.mu-route-chip.grp-interprovincial { background: linear-gradient(135deg, #7a4cc0, #b07ce0); box-shadow: 0 6px 14px rgba(122, 76, 192, .25); }
.mu-route-chip.grp-in_province { background: linear-gradient(135deg, #c02c7d, #e86aae); box-shadow: 0 6px 14px rgba(214, 56, 143, .25); }
.mu-route-chip.grp-municipal { background: linear-gradient(135deg, #5b6560, #8b948f); box-shadow: 0 6px 14px rgba(107, 114, 104, .25); }
.mu-toolbar {
display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
background: #fff; border: 1px solid #e7e2f6; border-radius: 14px;
padding: 12px; margin-bottom: 22px;
box-shadow: 0 8px 20px rgba(63, 43, 94, .06);
}
.mu-toolbar select {
flex: 1; min-width: 180px; min-height: 46px;
border: 1px solid #dfe6f1; background: linear-gradient(180deg, #fff, #f8fbff);
border-radius: 10px; padding: 0 12px; font-family: inherit; font-size: .95rem; color: #1f2a44;
}
/* --- รถประจำสาย + ติดต่อ (การ์ดเดียว ขึ้นก่อน) --- */
.mu-vehicle-card {
background: #fff;
border: 1px solid #e7e2f6;
border-radius: 18px;
overflow: hidden;
box-shadow: 0 4px 14px rgba(20, 40, 90, .06);
display: grid;
grid-template-columns: 1.3fr 1fr;
margin-bottom: 26px;
}
/* ไม่มีรูปรถใน .image/routes/<รหัส>/ → การ์ดไม่เว้นช่องว่าง */
#route-vehicle-card.no-photo { grid-template-columns: 1fr; }
#route-vehicle-card.no-photo > .meta { grid-column: 1 / -1; }
.mu-vehicle-card > img {
grid-column: 1; width: 100%; height: 100%; min-height: 240px;
object-fit: cover; display: block;
}
.mu-vehicle-card > .meta {
grid-column: 2; padding: 24px;
display: flex; flex-direction: column; justify-content: center; gap: 8px;
}
.mu-vehicle-card .meta .label {
margin: 0; font-size: .78rem; font-weight: 700; color: #7a4cc0;
text-transform: uppercase; letter-spacing: .05em;
}
.mu-vehicle-card .meta h2 { margin: 0; font-size: 1.25rem; color: #1f2a44; }
.mu-vehicle-card .meta p { margin: 0; color: #6f7b95; font-size: .95rem; line-height: 1.6; }
/* ติดต่อผู้ประกอบการ — อยู่ใน footer ของการ์ด */
.mu-vehicle-contact {
grid-column: 1 / -1;
display: flex; flex-wrap: wrap; gap: 10px;
padding: 14px 18px;
border-top: 1px solid #f0ecf8;
background: #faf9ff;
}
.mu-contact-item {
flex: 1; min-width: 220px;
display: flex; align-items: center; gap: 12px;
padding: 12px 14px;
border-radius: 12px;
background: #fff; border: 1px solid #eee;
text-decoration: none; color: inherit;
transition: transform .15s ease, box-shadow .15s ease;
}
a.mu-contact-item:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20,40,90,.08); }
.mu-contact-item .ic-wrap {
width: 42px; height: 42px; flex: none;
display: flex; align-items: center; justify-content: center;
border-radius: 12px;
background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff;
}
.mu-contact-item .ic-wrap.tone-green { background: linear-gradient(135deg, #1f8765, #51c39c); }
.mu-contact-item .ic-wrap.tone-sky { background: linear-gradient(135deg, #1877f2, #4a9bf8); }
.mu-contact-item .ic-wrap.tone-purple { background: linear-gradient(135deg, #7a4cc0, #a583e0); }
.mu-contact-item .mu-link-go { flex: 0 0 auto; display: flex; align-items: center; color: #7a4cc0; opacity: .8; }
.mu-contact-item:hover .mu-link-go { opacity: 1; transform: translateX(2px); }
.mu-contact-item .ic-wrap svg { width: 22px; height: 22px; }
.mu-contact-item .txt { flex: 1; min-width: 0; }
.mu-contact-item .txt strong { display: block; color: #1f2a44; font-size: .98rem; margin-bottom: 2px; }
.mu-contact-item .txt span { display: block; color: #6f7b95; font-size: .86rem; }
.mu-qr-img {
width: 72px; height: 72px; flex: none; display: block;
object-fit: contain; background: #fff;
border-radius: 10px; padding: 4px; border: 1px solid #eee;
}
/* ปุ่มครอบ QR — กดเพื่อขยาย (ไม่ให้หน้าตาเปลี่ยน) */
.mu-qr-btn { flex: none; padding: 0; border: 0; background: none; cursor: zoom-in;
border-radius: 10px; line-height: 0; }
.mu-qr-btn:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 2px; }
.mu-qr-btn:hover .mu-qr-img { border-color: #c9b6ec; }
/* --- ขยาย QR ลอยกลางจอ --- */
.mu-qr-modal { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; }
.mu-qr-modal::backdrop { background: rgba(20, 28, 48, .55); }
.mu-qr-modal-card {
position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px;
padding: 22px 22px 18px; border-radius: 14px; background: #fff; border: 1px solid #e7e2f6;
max-width: min(92vw, 360px);
}
.mu-qr-modal-card strong { color: #1f2a44; font-size: 1.02rem; text-align: center; }
.mu-qr-big { width: min(72vw, 260px); height: auto; border-radius: 10px; background: #fff; }
.mu-qr-close {
position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; padding: 0;
display: flex; align-items: center; justify-content: center;
border: 0; border-radius: 10px; background: #f4f1fb; color: #5b4a80; cursor: pointer;
}
.mu-qr-close:hover { background: #e9e2f8; }
.mu-qr-close svg { width: 18px; height: 18px; }
.mu-qr-modal-card .mu-btn { display: inline-flex; align-items: center; gap: 6px; }
.mu-qr-modal-card .mu-btn .ic { width: 16px; height: 16px; }
/* กดรูป QR = เปิดลิงก์ (ทั้งใบ กดได้) */
.mu-qr-link { display: block; line-height: 0; border-radius: 10px; }
.mu-qr-link:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 3px; }
.mu-qr-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.mu-copy-link.is-done { border-color: #1f8765; color: #1f8765; }
/* --- แผนที่ --- */
.mu-map-card {
background: #fff;
border: 1px solid #e7e2f6;
border-radius: 16px;
padding: 16px;
box-shadow: 0 4px 14px rgba(20, 40, 90, .06);
}
/* (ตัดกฎ .mu-map-card svg เดิมออก — แผนที่ SVG นิ่งถูกแทนด้วย Leaflet
และกฎนี้ทำให้ SVG ของ Leaflet ยุบเป็น 0x0 จนเส้นทางไม่แสดง) */
.mu-summary-grid { gap: 14px; }
@media (max-width: 640px) {
.mu-page-title { font-size: 1.4rem; }
.mu-summary-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
.mu-vehicle-card { grid-template-columns: 1fr; }
.mu-vehicle-card > img { grid-column: 1; min-height: 200px; }
.mu-vehicle-card > .meta { grid-column: 1; padding: 18px; }
.mu-vehicle-contact { grid-column: 1; flex-direction: column; }
.mu-contact-item { min-width: 0; }
}
</style>
<main class="mu-page">
<div class="mu-container">
<p class="mu-breadcrumb"><a href="#/" data-i18n="nav.home">หน้าแรก</a>/ <span data-i18n="nav.routes">รายละเอียดสายรถ</span></p>
<h1 class="mu-page-title"><span class="mu-route-chip" id="route-chip"></span> <span id="route-title"></span></h1>
<!-- ตัวเลือกสายรถ: เติมจาก resource/data/routes.json (busDetail.init.js) -->
<form class="mu-toolbar" onsubmit="return false">
<select aria-label="เลือกสายรถ" data-i18n-attr="aria-label:route.selectRoute" id="route-select"></select>
</form>
<!-- ============ รถประจำสาย + ติดต่อผู้ประกอบการ (การ์ดเดียว) ============ -->
<!-- รูปรถ/คำอธิบาย/QR/เบอร์โทร: เติมจาก resource/data/captions/caption<รหัสสาย>.json + routes.json -->
<section class="mu-vehicle-card" aria-label="รถประจำสายและติดต่อผู้ประกอบการ" data-i18n-attr="aria-label:aria.vehicleSection" id="route-vehicle-card">
<img id="route-vehicle-img" alt="" loading="lazy" decoding="async" hidden>
<div class="meta">
<p class="label" data-i18n="route.vehicle">รถประจำสาย</p>
<h2 id="route-vehicle-title" hidden></h2>
<p id="route-vehicle-desc" hidden></p>
</div>
<div class="mu-vehicle-contact" id="route-contact"></div>
</section>
<!-- ============ สรุปเส้นทาง ============ -->
<section class="mu-summary" aria-label="สรุปเส้นทาง" data-i18n-attr="aria-label:aria.routeSummary">
<div class="mu-container">
<div class="mu-summary-grid">
<div class="mu-stat tag-purple"><h3 id="stat-stops">–</h3><p data-i18n="route.kpiStops">จุดจอดหลัก</p></div>
<div class="mu-stat tag-sky"><h3 id="stat-provinces">–</h3><p data-i18n="route.kpiProvince">จังหวัดที่ผ่าน</p></div>
<div class="mu-stat tag-mint"><h3 id="stat-trips">–</h3><p data-i18n="route.kpiTrips">รอบต่อวัน</p></div>
<div class="mu-stat tag-pink"><h3 id="stat-next">–</h3><p data-i18n="route.kpiNext">รอบถัดไป</p></div>
</div>
</div>
</section>
<!-- ============ แผนที่เส้นทาง (Leaflet + GeoJSON จาก QGIS) ============ -->
<section class="mu-zone" aria-label="แผนที่เส้นทาง" data-i18n-attr="aria-label:aria.routeMap">
<div class="mu-zone-head">
<span class="mu-zone-tag tag-sky" data-i18n="route.mapTitle">เส้นทางเดินรถ</span>
<p class="mu-zone-desc" data-i18n="route.mapDesc">เส้นทางจริงจากข้อมูล GIS · ป้ายหยุดรถตามเส้นทาง</p>
</div>
<div class="mu-map-card">
<div class="at-map" id="route-map" role="region" aria-label="แผนที่เส้นทางเดินรถ" data-i18n-attr="aria-label:aria.routeGeom"></div>
<p class="at-map-caption" id="route-map-caption"></p>
<div class="at-km-wrap" hidden>
<h3><span data-i18n="map.alongRoute">จุดจอดตามเส้นทาง (กม. จากต้นทาง)</span></h3>
<ul id="route-map-list"></ul>
</div>
</div>
</section>
</div>
</main>
<script src="./partials/busDetail.init.js"></script>