301 lines
10 KiB
JavaScript
301 lines
10 KiB
JavaScript
// 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: '<div class="swal2-toast-cus">' + html + '</div>'
|
||
})
|
||
}
|
||
var mctmp = '0';
|
||
function msgconfirm(html, btn, icon = 'question') {
|
||
if (mctmp == '0') {
|
||
Swal.fire({
|
||
html: html,
|
||
icon: icon,
|
||
showCancelButton: true,
|
||
confirmButtonText: '<i class="mdi mdi-check"></i> 確定',
|
||
cancelButtonText: '<i class="mdi mdi-close"></i> 取消'
|
||
}).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("<HTML><head><link href=\"../../module/js/css/adminroot.css\" rel=\"stylesheet\" type=\"text/css\">");
|
||
printdetail.document.write("<script type =\"text/javascript\">");
|
||
printdetail.document.write("function mouseover(obj,color_word){obj.style.backgroundColor = color_word;}");
|
||
printdetail.document.write("function mouseout(obj,color_word){obj.style.backgroundColor = color_word;}");
|
||
printdetail.document.write("<\/script>");
|
||
printdetail.document.write("</head>");
|
||
printdetail.document.write("<BODY onload=\"window.print();\"><div style=\"width:720px\">");
|
||
printdetail.document.write(Item.outerHTML);
|
||
printdetail.document.write("</div></BODY></HTML>");
|
||
printdetail.document.close();
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
function PrintTagRWD(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("<HTML><head>\n");
|
||
printdetail.document.write('<link href="../../App_Script/bootstrap3/css/bootstrap.css" rel="stylesheet" />\n');
|
||
printdetail.document.write('<link href="../../App_Script/bootstrap_datepicker/css/datepicker.css" rel="stylesheet" />\n');
|
||
printdetail.document.write('<link href="../../admin/skin/css/style.css" rel="stylesheet" media="screen" />\n');
|
||
printdetail.document.write('<link href="../../admin/skin/css/print.css" rel="stylesheet" media="print" />\n');
|
||
printdetail.document.write('<!--[if lt IE 9]>\n');
|
||
printdetail.document.write('<link href="../../admin/skin/css/ie8-and-down.css" rel="stylesheet" type="text/css" />\n');
|
||
printdetail.document.write('<![endif]-->\n');
|
||
|
||
printdetail.document.write("<style type=\"text/css\">.hidden-print{display:none;}</style>");
|
||
printdetail.document.write("</head>");
|
||
printdetail.document.write("<BODY onload=\"window.print();\">");
|
||
printdetail.document.write(Item.outerHTML);
|
||
printdetail.document.write("</BODY></HTML>");
|
||
printdetail.document.close();
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
//---------------------------------checkbox全選用---------------------------------------------------
|
||
function Check(parentChk, ChildId) {
|
||
var oElements = document.getElementsByTagName("INPUT");
|
||
var bIsChecked = parentChk.checked;
|
||
|
||
for (i = 0; i < oElements.length; i++) {
|
||
if (IsCheckBox(oElements[i]) &&
|
||
IsMatch(oElements[i].id, ChildId)) {
|
||
oElements[i].checked = bIsChecked;
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
function IsMatch(id, ChildId) {
|
||
var sPattern = '^ctl00_ContentPlaceHolder1_Repeater1.*' + ChildId + '$';
|
||
var oRegExp = new RegExp(sPattern);
|
||
if (oRegExp.exec(id))
|
||
return true;
|
||
else
|
||
return false;
|
||
}
|
||
|
||
function IsCheckBox(chk) {
|
||
if (chk.type == 'checkbox') return true;
|
||
else return false;
|
||
}
|
||
|
||
function checkListAll(chk) {
|
||
$('.listCheck input').each(function () {
|
||
this.checked = chk;
|
||
});
|
||
}
|
||
|
||
function checkAll2(chk, num) {
|
||
$('#root_' + num).show();
|
||
$('#root_' + num + ' input:checkbox').each(function () {
|
||
this.checked = chk;
|
||
});
|
||
}
|
||
|
||
|
||
|
||
// Vuetify
|
||
let vuetify_options = {
|
||
theme: { disable: true },
|
||
lang: {
|
||
locales: {
|
||
zhHant: {
|
||
badge: '徽章',
|
||
close: '關閉',
|
||
dataIterator: {
|
||
noResultsText: '沒有符合條件的結果',
|
||
loadingText: '讀取中...',
|
||
},
|
||
dataTable: {
|
||
itemsPerPageText: '每頁列數:',
|
||
ariaLabel: {
|
||
sortDescending: ':降序排列。',
|
||
sortAscending: ':升序排列。',
|
||
sortNone: '無排序方式。點擊以升序排列。',
|
||
activateNone: '點擊以移除排序方式。',
|
||
activateDescending: '點擊以降序排列。',
|
||
activateAscending: '點擊以移除排序方式。',
|
||
},
|
||
sortBy: '排序方式',
|
||
},
|
||
dataFooter: {
|
||
itemsPerPageText: '每頁項目:',
|
||
itemsPerPageAll: '全部',
|
||
nextPage: '下一頁',
|
||
prevPage: '上一頁',
|
||
firstPage: '第一頁',
|
||
lastPage: '最後頁',
|
||
pageText: '{2} 項中的 {0}~{1} 項',
|
||
},
|
||
datePicker: {
|
||
itemsSelected: '已選擇 {0}',
|
||
nextMonthAriaLabel: '下個月',
|
||
nextYearAriaLabel: '明年',
|
||
prevMonthAriaLabel: '上個月',
|
||
prevYearAriaLabel: '去年',
|
||
},
|
||
noDataText: '沒有資料',
|
||
carousel: {
|
||
prev: '上一張',
|
||
next: '下一張',
|
||
ariaLabel: {
|
||
delimiter: '輪播圖 {0} / {1}',
|
||
},
|
||
},
|
||
calendar: {
|
||
moreEvents: '還有其他 {0} 項',
|
||
},
|
||
fileInput: {
|
||
counter: '{0} 個檔案',
|
||
counterSize: '{0} 個檔案(共 {1})',
|
||
},
|
||
timePicker: {
|
||
am: 'AM',
|
||
pm: 'PM',
|
||
},
|
||
pagination: {
|
||
ariaLabel: {
|
||
wrapper: '分頁導覽',
|
||
next: '下一頁',
|
||
previous: '上一頁',
|
||
page: '到頁面 {0}',
|
||
currentPage: '當前頁 {0}',
|
||
},
|
||
},
|
||
rating: {
|
||
ariaLabel: {
|
||
icon: '評分 {0} / {1}',
|
||
},
|
||
},
|
||
}
|
||
},
|
||
current: 'zhHant',
|
||
},
|
||
//theme: { disable: false},
|
||
};
|