// navigation and breadcrumb window.addEventListener('DOMContentLoaded', event => { // Toggle the side navigation const sidebarToggle = document.body.querySelector('#sidebarToggle'); if (sidebarToggle) { // Uncomment Below to persist sidebar toggle between refreshes //if (localStorage.getItem('sb|sidebar-toggle') === 'true') { // document.body.classList.toggle('sb-sidenav-toggled'); //} sidebarToggle.addEventListener('click', event => { event.preventDefault(); document.body.classList.toggle('sb-sidenav-toggled'); localStorage.setItem('sb|sidebar-toggle', document.body.classList.contains('sb-sidenav-toggled')); }); } }); $(document).ready(function () { // navigation and breadcrumb //$(".leaf-node").parents("tr").find("img").hide(); var breadcrumb_last = $(".breadcrumb li").last().text().trim(); var item = $("#sideNav_1 a.nav-link").filter((i, t) => { //console.log($(t).text().trim(), breadcrumb_last, $(t).text().trim() == breadcrumb_last); return $(t).text().trim() == breadcrumb_last; }); var panel = item.parents(".collapse").eq(0); item.addClass("active"); panel.toggle(); panel.prev().addClass("active"); $("a[data-bs-target='#offcanvasRight']").click(function (e) { let t = $(this).attr("href"); console.log("right:", this, t); $("#offcanvasRight .offcanvas-body>div").hide(); $(t).show(); $("#offcanvasRightLabel").text($(t).data("title")); }); let show_search = !!$("#offcanvasRight .offcanvas-body #search_panel").length; $("#search_btn").toggle(show_search); // search-control $("[data-search-control]").each((i, t) => { console.log("[data-search-control]", i, t, $(t).children("button").eq(0), $(t).children("[type=hidden]").val(), $(t).children(".search-text").attr("placeholder"), $(t).children(".search-text").val(), ); }); }); // Sweet Alert function msgbox(html, icon = '', url = '') { Swal.fire({ icon: icon, html: html, confirmButtonText: '關閉', onClose: () => { if (url != '') { window.location = url; } } }); } function msgtop(html, icon = 'success') { const Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 3000, heightAuto: false, timerProgressBar: true, onOpen: (toast) => { toast.addEventListener('mouseenter', Swal.stopTimer) toast.addEventListener('mouseleave', Swal.resumeTimer) } }) Toast.fire({ icon: icon, html: '
' + html + '
' }) } var mctmp = '0'; function msgconfirm(html, btn, icon = 'question') { if (mctmp == '0') { Swal.fire({ html: html, icon: icon, showCancelButton: true, confirmButtonText: ' 確定', cancelButtonText: ' 取消' }).then((result) => { if (result.value) { mctmp = '1'; if ($(btn)[0].hasAttribute('href')) { var href = $(btn).attr('href'); window.location.href = href; } else { $(btn).click(); } } }) mctmp = '0'; return false; } else { mctmp = '0'; return true; } } function clearObjProps(obj) { for (const prop of Object.getOwnPropertyNames(obj)) { obj[prop] = null; } } //---------------------------------列印--------------------------------------------------- function PrintTagData(id) { if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) { window.print(); } else { var Item = document.getElementById(id); var printdetail = window.open("", "TextareaDetail"); printdetail.document.open(); printdetail.document.write(""); printdetail.document.write("