1249 lines
44 KiB
JavaScript
1249 lines
44 KiB
JavaScript
;(function($, win, undefined) {
|
||
// ECMAScript 5 嚴格模式
|
||
'use strict';
|
||
//header fixed在上方
|
||
function initdata1() {
|
||
if ( $('.homebanner').length != 0) {
|
||
$('.layout-header').css('height', '');
|
||
var scrollTop = $(window).scrollTop();
|
||
var scrollBottom = $('html').height() - $(window).height() - $('.layout-header').height();
|
||
if (scrollTop>5 && scrollBottom>0) { /* 要滑動到選單的距離 */
|
||
if (parseInt($('.index-layout-content').css('margin-top'))==0){
|
||
}
|
||
$('.layout-header').addClass('navFixed'); /* 幫選單加上固定效果 */
|
||
} else {
|
||
if ($('.homebanner').html().trim() == "") {
|
||
$('.layout-header').removeClass('navFixed');
|
||
}else{
|
||
$('.layout-header').removeClass('navFixed'); /* 移除選單固定效果 */
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
$.fn.replace_bootstrap_col_class = function(colcls){
|
||
$(this).removeClass(function(index, css) {
|
||
return (css.match(/(^|\s)col-\S+/g) || []).join(' ');
|
||
})
|
||
.addClass(colcls);
|
||
}
|
||
// 初始函數: 把所有的程式碼都包在init裡面,方便在之後的jQuery ready 函數裡一次呼叫
|
||
function init() {
|
||
// 快取一些常用的變數
|
||
var doc = document;
|
||
var lang = doc.documentElement.lang;
|
||
var pageModule = doc.body.getAttribute('data-module');
|
||
var resizeTimer = -1;
|
||
|
||
// 把所有的函數都包在orbit這個物件裡並按模組做簡單的分類
|
||
var orbit = {
|
||
|
||
// 工具函數,裡面包含可以重覆使用的函數
|
||
utils: {
|
||
// 字數限制函數, 因為系統預設沒有,所以使用JS來做
|
||
// els = 元素, maxLen = 限制長度
|
||
truncateText: function(els, maxLen) {
|
||
var els = doc.querySelectorAll(els);
|
||
var newTitle = '';
|
||
var i = -1;
|
||
var elsLen = els.length;
|
||
|
||
for (i = 0; i < elsLen; i++) {
|
||
if (els[i].firstChild !== null) {
|
||
if (els[i].firstChild.length > maxLen) {
|
||
newTitle = els[i].firstChild.textContent;
|
||
els[i].textContent = newTitle.substring(0, maxLen) + '...';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
|
||
// 外掛,所有的外掛都可以放到這個物件裡
|
||
plugins: {
|
||
// 自適應圖片裁切,Ray的外掛
|
||
bullEye: function() {
|
||
$('.bullseye').bullseye({
|
||
fadeEffect: false
|
||
});
|
||
}
|
||
},
|
||
|
||
// nav: {
|
||
// 自適應使用的下拉選單
|
||
// setDropdown: function() {
|
||
// var $caret1 = $('<i class="dropdown-toggle-icon level-1 fa fa-chevron-down"></i>');
|
||
// var $caret2 = $('<i class="dropdown-toggle-icon level-2 fa fa-chevron-down"></i>');
|
||
// var $li = null;
|
||
// var $this = null;
|
||
// var cls = 'active';
|
||
// var iconDown = 'fa-chevron-down';
|
||
// var iconUp = 'fa-chevron-up';
|
||
|
||
// // 如果有第二層選單,新增對應的類別到parent元素上
|
||
// $('.nav-level-1')
|
||
// .parent('li')
|
||
// .addClass('has-dropdown level-1');
|
||
|
||
// // 檢查是否已經有dropdown-toggle-icon這個元素,才不會在resize事件中重覆新增
|
||
// if ($('.has-dropdown.level-1 > .dropdown-toggle-icon').length < 1) {
|
||
// $caret1.appendTo('.has-dropdown.level-1');
|
||
|
||
// // 如果有第三層選單,新增對應的類別到parent元素上
|
||
// $('.nav-level-2')
|
||
// .parent('li')
|
||
// .addClass('has-dropdown level-2');
|
||
// $caret2.appendTo('.has-dropdown.level-2');
|
||
// }
|
||
|
||
// // 綁定事件到第二、三層下拉選單的按鈕上
|
||
// $('.dropdown-toggle-icon.level-1, .dropdown-toggle-icon.level-2').on('vclick', function(e) {
|
||
// e.preventDefault();
|
||
// $this = $(this);
|
||
// $li = $this.parent('li');
|
||
|
||
// // 拿掉所有選項除了目前點選的選項的 active class 並把icon換成預設的
|
||
// $li
|
||
// .siblings('li')
|
||
// .removeClass(cls)
|
||
// .find('.' + iconUp)
|
||
// .removeClass(iconUp)
|
||
// .addClass(iconDown);
|
||
|
||
|
||
// // 換掉目前選項的icon
|
||
// $li
|
||
// .find('> i')
|
||
// .removeClass(iconDown)
|
||
// .addClass(iconUp);
|
||
|
||
// // 折疊已打開的選項
|
||
// if ( $li.hasClass(cls) ){
|
||
// $li.removeClass(cls);
|
||
// $this.removeClass(iconUp).addClass(iconDown);
|
||
// }
|
||
// else{
|
||
// $li.addClass(cls)
|
||
// $this.removeClass(iconDown).addClass(iconUp);
|
||
// }
|
||
// });
|
||
// },
|
||
|
||
// 移除行動版下拉選單
|
||
// removeDropdown: function() {
|
||
// var $nav = $('#main-nav');
|
||
|
||
// $nav
|
||
// .find('.dropdown-toggle-icon')
|
||
// .remove();
|
||
// $nav
|
||
// .find('.active')
|
||
// .removeClass('active');
|
||
// }
|
||
// },
|
||
|
||
member: {
|
||
// 欄位相同高度,小心這個函數沒有計算到圖片高度,所以可能要搭配 jQuery load函數使用,或是之後使用更好的方式例如 CSS3 flexbox
|
||
equalHeight: function(el) {
|
||
var bigbrother = -1;
|
||
var $el = $(el);
|
||
$el.each(function(i) {
|
||
bigbrother = bigbrother > $el.eq(i).height() ? bigbrother : $el.eq(i).height();
|
||
});
|
||
|
||
$el.height(bigbrother);
|
||
},
|
||
|
||
// 把沒有完成資料的表格列藏起來, 因為後台不管有沒有資料都會輸出項目,所以需要在前台藏起來…
|
||
removeEmptyRow: function() {
|
||
// index 頁面項目
|
||
$('.i-member-profile-item .i-member-value').each(function() {
|
||
if ($(this).text().trim() === '' || $(this).text().trim() === ':') {
|
||
$(this).parent().addClass('hide');
|
||
}
|
||
});
|
||
|
||
// show 頁面項目
|
||
$('.show-member .member-data th, .show-member .member-data td').each(function() {
|
||
if ($(this).text().trim() === '') {
|
||
$(this).parent('tr').addClass('hide');
|
||
}
|
||
});
|
||
},
|
||
},
|
||
|
||
archives: {
|
||
// 把沒有文字內容的標題藏起來,因為就算是標題裡沒有文字系統仍然會輸出,這樣會造成一些多餘的CSS margins, paddings,或許之後也可以使用 CSS3 :empty selector 處理
|
||
// el = 要移除的元素
|
||
removeEmptyTitle: function(el) {
|
||
var $el = $(el);
|
||
var $els = $el.children();
|
||
|
||
$.each($els, function(i, val) {
|
||
if ($els.eq(i).text().trim() === '') {
|
||
$els.eq(i).addClass('hide');
|
||
}
|
||
});
|
||
|
||
$.each($el, function(i, val) {
|
||
if ($el.eq(i).children('.hide').length >= 2) {
|
||
$el.eq(i).addClass('hide');
|
||
}
|
||
});
|
||
},
|
||
|
||
// bootstarp panel 功能擴充,因為原本的功能不支援多個panel
|
||
extendPanel: function() {
|
||
var len = $('.i-archive .panel-title').length;
|
||
var i = -1;
|
||
if (len > 0) {
|
||
// 新增數字到要對應的panel按鈕id及href上面
|
||
for (i = 0; i < len; i++) {
|
||
$('.panel-title:eq(' + i + ') .collapsed').attr('href', '#collapse' + i);
|
||
$('.panel-collapse:eq(' + i + ')').attr('id', 'collapse' + i);
|
||
}
|
||
}
|
||
}
|
||
},
|
||
|
||
adBanner: {
|
||
// 讓AD banner 的圖片可以點選,因為系統預設輸出的圖片是沒有連結的
|
||
// els = 要可以點選的元素(需要配合有data-link這個參數及data-targe才能使用)
|
||
addLinkOnADBanner: function(els) {
|
||
$.each(els, function() {
|
||
if ($(this).data('link') !== '' && !$(this).hasClass('youtube')) {
|
||
$(this).on('click', function() {
|
||
var target = $(this).data('target');
|
||
var link = $(this).data('link');
|
||
|
||
// 設定頁面打開的方式,記得要加上data-target在HTML裡面
|
||
if (target === '_blank') {
|
||
window.open(link, target);
|
||
} else {
|
||
window.location.href = link;
|
||
}
|
||
}).addClass('cursor'); // cursor類別樣式定義在CSS裡面
|
||
}
|
||
});
|
||
},
|
||
|
||
},
|
||
|
||
|
||
|
||
// 移除行動版下拉選單
|
||
removeDropdown: function() {
|
||
var $nav = $('#main-nav');
|
||
|
||
$nav
|
||
.find('.menu-drop')
|
||
.remove();
|
||
$nav
|
||
.find('.opened')
|
||
.removeClass('opened');
|
||
},
|
||
// 網站次選單設定,如果次選單有第三層就新增下拉選單的圖示及加上bootstrap class
|
||
// els = 選單元素
|
||
sitemenuDropdown: function(els) {
|
||
var els = doc.querySelectorAll('.sitemenu-list.level-2');
|
||
var len = els.length;
|
||
var i = -1;
|
||
var caret = null;
|
||
|
||
for (i = 0; i < len; i++) {
|
||
if (els[i].children.length) {
|
||
caret = doc.createElement('span');
|
||
caret.className = 'sitemenu-dropdown-toggle fa fa-caret-down';
|
||
caret.setAttribute('data-toggle', 'dropdown');
|
||
|
||
els[i].parentNode.insertBefore(caret, els[i]);
|
||
els[i].className += ' dropdown-menu';
|
||
}
|
||
}
|
||
},
|
||
|
||
// 回到頁面最頂端,動態產生DOM
|
||
// txt = 按鈕的文字, speed = 捲動時的速度
|
||
goBackTop: function(txt, speed) {
|
||
var top = document.createElement('div');
|
||
top.className = 'go-back-top no-print';
|
||
top.textContent = txt || 'top';
|
||
doc.body.appendChild(top);
|
||
|
||
// 判斷是否顯示按鈕
|
||
$(window).scroll(function() {
|
||
if ($(this).scrollTop() !== 0) {
|
||
$('.go-back-top').fadeIn();
|
||
} else {
|
||
$('.go-back-top').fadeOut();
|
||
}
|
||
});
|
||
|
||
// 捲動效果
|
||
$('.go-back-top').on('click', function() {
|
||
$('body, html').animate({
|
||
scrollTop: 0
|
||
}, speed || 300);
|
||
return false;
|
||
});
|
||
},
|
||
|
||
// Multi-column layout, passing ID or class string as parameters and a
|
||
// Bootstrap col class for full width, eg: col-md-12
|
||
setColumn: function(leftCol, rightCol, columnCls) {
|
||
var $leftCol = $(leftCol);
|
||
var $rightCol = $(rightCol);
|
||
var columnCls = columnCls || 'col-sm-12';
|
||
|
||
if ($leftCol.length || $rightCol.length) {
|
||
$.each([$leftCol, $rightCol], function() {
|
||
if ($(this).is(':empty')) {
|
||
$(this)
|
||
.addClass('empty-column')
|
||
.siblings()
|
||
.replace_bootstrap_col_class(columnCls);
|
||
}
|
||
});
|
||
}
|
||
},
|
||
setThreeColumn: function(leftCol, centerCol, rightCol, mediumCls, fullCls) { //mediumCls and fullCls will apply to centerCol
|
||
var $leftCol = $(leftCol);
|
||
var $centerCol = $(centerCol);
|
||
var $rightCol = $(rightCol);
|
||
var mediumCls = mediumCls || 'col-sm-9';
|
||
var mediumCls_complement = mediumCls.replace(/(^|\s+)col-[^-]+-([\d]+)/g,function(match, p1, p2){
|
||
return match.replace(p2, 12 - Number(p2));
|
||
});
|
||
var fullCls = fullCls || 'col-sm-12';
|
||
var asides_cols = [$leftCol, $rightCol];
|
||
var asides_count = [$leftCol.not(':empty').length, $rightCol.not(':empty').length];
|
||
var complemented_aside, empty_aside;
|
||
if(asides_count[0] == 0 && asides_count[1] == 0){
|
||
$centerCol.replace_bootstrap_col_class(fullCls);
|
||
$.each(asides_cols, function() {
|
||
$(this).addClass('empty-column').replace_bootstrap_col_class('');
|
||
});
|
||
}else{
|
||
asides_cols.forEach(function(col , i){
|
||
if(asides_count[i] == 0){
|
||
empty_aside = col;
|
||
}else{
|
||
complemented_aside = col;
|
||
}
|
||
})
|
||
if(empty_aside){
|
||
empty_aside.addClass('empty-column').replace_bootstrap_col_class('');
|
||
complemented_aside.replace_bootstrap_col_class(mediumCls_complement);
|
||
$centerCol.replace_bootstrap_col_class(mediumCls);
|
||
}
|
||
}
|
||
},
|
||
|
||
MobileMenu: function() {
|
||
var $menu = $('[data-menu-level="0"]');
|
||
|
||
$menu.find('ul[data-menu-level="1"]').parent().addClass('mobile-menu1');
|
||
$menu.find('ul[data-menu-level="2"]').parent().addClass('mobile-menu2');
|
||
|
||
var $caret1 = $('<span class="menu-drop"><i class="dropdown-toggle-icon level-1 fa fa-chevron-down"></i></span>');
|
||
var $caret2 = $('<span class="menu-drop"><i class="dropdown-toggle-icon level-2 fa fa-chevron-down"></i></span>');
|
||
|
||
// 如果有第二層選單,新增對應的類別到parent元素上
|
||
$('.nav-level-1')
|
||
.parent('li')
|
||
.addClass('has-dropdown level-1');
|
||
|
||
// 檢查是否已經有dropdown-toggle-icon這個元素,才不會在resize事件中重覆新增
|
||
if ($('.has-dropdown.level-1 .menu-drop').length < 1) {
|
||
$('.mobile-menu1').append($caret1);
|
||
|
||
|
||
// 如果有第三層選單,新增對應的類別到parent元素上
|
||
$('.nav-level-2')
|
||
.parent('li')
|
||
.addClass('has-dropdown level-2');
|
||
$caret2.appendTo('.has-dropdown.level-2');
|
||
}
|
||
},
|
||
|
||
ClickMenuHandler: function() {
|
||
$('.navbar-toggle').click(function(e){
|
||
e.preventDefault();
|
||
$('.mobile-menu').each(function() {
|
||
var $mobileMenu = $(this);
|
||
|
||
// 移动 .navbar-toggle 到 .modules-menu 后面
|
||
$mobileMenu.find('.modules-menu').after($mobileMenu.find('.navbar-toggle'));
|
||
});
|
||
$('.mobile-menu').toggleClass('active');
|
||
$('body').toggleClass('noscroll');
|
||
|
||
$('.mobile-menu .navbar-toggle').removeClass('collapsed');
|
||
// $menu.slideToggle();
|
||
$('.mobile-menu1 > ul').slideUp(500);
|
||
$('.mobile-menu1 > .menu-drop').removeClass('opened');
|
||
$('.mobile-menu2 > ul').slideUp(500);
|
||
$('.mobile-menu2 > .menu-drop').removeClass('opened');
|
||
// 如果 .mobile-menu 有 .active 类且 Tab 键聚焦,聚焦到 .modules-menu
|
||
if ($('.mobile-menu').hasClass('active')) {
|
||
setTimeout(function() {
|
||
$('.modules-menu').find('input, button, select, textarea, a').first().focus();
|
||
}, 100);
|
||
}
|
||
});
|
||
|
||
$('.mobile-menu1 > .menu-drop').click(function(){
|
||
var $that = $(this);
|
||
var opencheck1 = $that.hasClass('opened');
|
||
if ( opencheck1 == 0 ) {
|
||
$('.mobile-menu1 > ul').not($that.siblings('ul')).slideUp(500);
|
||
$('.mobile-menu1 > .menu-drop').not($that).removeClass('opened');
|
||
$('.mobile-menu2 > ul').slideUp(500);
|
||
$('.mobile-menu2 > .menu-drop').removeClass('opened');
|
||
$that.siblings('ul').slideDown(500);
|
||
$that.addClass('opened');
|
||
|
||
} else if (opencheck1 == 1) {
|
||
$that.siblings('ul').slideUp(500);
|
||
$('.mobile-menu2 > ul').slideUp(500);
|
||
$('.mobile-menu2 > .menu-drop').removeClass('opened');
|
||
$that.removeClass('opened');
|
||
|
||
}
|
||
})
|
||
|
||
$('.mobile-menu2 > .menu-drop').click(function(){
|
||
var $that = $(this);
|
||
var opencheck2 = $that.hasClass('opened');
|
||
if ( opencheck2 == 0 ) {
|
||
$('.mobile-menu2 > ul').not($that.siblings('ul')).slideUp(500);
|
||
$('.mobile-menu2 > .menu-drop').not($that).removeClass('opened');
|
||
$that.siblings('ul').slideDown(500);
|
||
$that.addClass('opened');
|
||
} else if (opencheck2 == 1) {
|
||
$that.siblings('ul').slideUp(500);
|
||
$that.removeClass('opened');
|
||
}
|
||
})
|
||
}
|
||
};
|
||
|
||
// 把orbit物件加到window物件裡面並改名為ORBITFRONT來減少名稱衝突的機會
|
||
win.ORBITFRONT = orbit;
|
||
|
||
// 在switch裡測試頁面模組後執行對應的函數
|
||
switch (pageModule) {
|
||
case 'home':
|
||
break;
|
||
case 'member':
|
||
orbit.member.removeEmptyRow();
|
||
$('.index-member-3 .member-data-title-email').empty();
|
||
break;
|
||
case 'archive':
|
||
orbit.archives.removeEmptyTitle('.i-archive__category-item');
|
||
orbit.archives.extendPanel();
|
||
break;
|
||
case 'gallery':
|
||
orbit.utils.truncateText('.show-description', 15);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
// 在所有的頁面(包含首頁)執行下面這幾個函數
|
||
initdata1()
|
||
orbit.sitemenuDropdown();
|
||
orbit.goBackTop('top', 800);
|
||
orbit.plugins.bullEye();
|
||
orbit.setThreeColumn('.left-column','.center-column', '.right-column');
|
||
|
||
// 自適應網頁使用,當網頁載入時,如果視窗寬度小於769,就執行orbit.nav.setDropdown函數
|
||
if ($(window).width() < 769) {
|
||
// orbit.nav.setDropdown();
|
||
orbit.MobileMenu();
|
||
$('.mobile-menu').append($('.modules-menu'));
|
||
orbit.ClickMenuHandler();
|
||
}
|
||
|
||
// 自適應網頁使用,當使用者改變瀏覽器寬度時呼叫orbit.nav.setDropdown函數
|
||
$(window).resize(function() {
|
||
if ($(window).width() < 769) {
|
||
if (resizeTimer) clearTimeout(resizeTimer);
|
||
resizeTimer = setTimeout(function() {
|
||
if ( $('.modules-menu i').length == 0 ) {
|
||
orbit.MobileMenu();
|
||
}
|
||
if( $('.mobile-menu .modules-menu').length == 0 ) {
|
||
$('.mobile-menu').append($('.modules-menu'));
|
||
$('.navbar-toggle').bind(orbit.ClickMenuHandler());
|
||
}
|
||
},500 )} else {
|
||
resizeTimer = setTimeout(function(){
|
||
if( $('.mobile-menu .modules-menu').length > 0 ) {
|
||
$('.layout-header .container').append($('.modules-menu'));
|
||
}
|
||
orbit.removeDropdown();
|
||
}, 500);
|
||
}
|
||
});
|
||
function forFreeGo() {
|
||
$('.w-ba-banner__caption li button').each(function (index) {
|
||
const $slide = $('.w-ba-banner__slide').eq(index);
|
||
const title = $slide.attr('data-cycle-title')?.trim();
|
||
|
||
if (title) {
|
||
const fullText = title + '的pager';
|
||
$(this).attr('aria-label', fullText);
|
||
$(this).attr('title', fullText);
|
||
}
|
||
});
|
||
// 當 focus 到 menu link 時,顯示對應 ul
|
||
$('.sitemenu-item > a').on('focus', function () {
|
||
$(this).siblings('ul').addClass('show');
|
||
});
|
||
|
||
// 當 focus 離開最後一個子選單 link 時,移除 .show
|
||
$('.sitemenu-item').each(function () {
|
||
const $submenuLinks = $(this).find('ul a');
|
||
|
||
if ($submenuLinks.length > 0) {
|
||
$submenuLinks.last().on('blur', function () {
|
||
// 當最後一個子項 blur 時關閉 ul
|
||
$(this).closest('ul').removeClass('show');
|
||
});
|
||
} else {
|
||
// 若沒有子項,當主選單項 blur 也隱藏
|
||
$(this).find('> a').on('blur', function () {
|
||
$(this).siblings('ul').removeClass('show');
|
||
});
|
||
}
|
||
});
|
||
if (document.documentElement.lang === 'zh_tw') {
|
||
document.documentElement.lang = 'zh-Hant';
|
||
}
|
||
//tab鍵按下
|
||
$(document).on('keydown', function(e) {
|
||
if (e.key === "Tab" || e.keyCode === 9) {
|
||
$('.header-nav, .dropdowns').css('display', 'block');
|
||
}
|
||
});
|
||
|
||
//li被hover
|
||
function handleHover() {
|
||
if ($(window).width() > 769) {
|
||
$('li').off('mouseenter mouseleave').hover(
|
||
function() {
|
||
$(this).children('ul').addClass('show');
|
||
},
|
||
function() {
|
||
$(this).children('ul').removeClass('show');
|
||
}
|
||
);
|
||
} else {
|
||
$('li').off('mouseenter mouseleave'); // 移除 hover 事件
|
||
}
|
||
}
|
||
|
||
// 先執行一次
|
||
handleHover();
|
||
|
||
// 監聽視窗大小變化
|
||
$(window).on('resize', function() {
|
||
handleHover();
|
||
});
|
||
//刪除空的h1
|
||
$('h1').each(function() {
|
||
if ($(this).text().trim() === '') {
|
||
$(this).remove();
|
||
}
|
||
});
|
||
//refresh_btn加上aria-label
|
||
$('#refresh_btn').each(function() {
|
||
var $this = $(this);
|
||
|
||
// 如果 button 尚未有 aria-label,則新增
|
||
if (!$this.attr('aria-label')) {
|
||
$this.attr('aria-label', '重新整理');
|
||
}
|
||
});
|
||
//無障礙會員表格刪除沒有顯示的th
|
||
$('.i-member-tr-head').each(function() {
|
||
if ($(this).css('display') === 'none') {
|
||
$(this).remove();
|
||
}
|
||
});
|
||
//無障礙公告a是空的
|
||
$('.w-annc__subtitle').each(function () {
|
||
var $this = $(this);
|
||
var $link = $this.find('a');
|
||
|
||
// 檢查 a 是否存在,且去除空白後是否為空字串
|
||
if ($link.length && $link.text().trim() === '') {
|
||
$this.remove(); // 移除外層 .w-annc__subtitle
|
||
}
|
||
});
|
||
//無障礙單位轉換
|
||
$("[style*='font-size']").each(function() {
|
||
var fontSize = $(this).css("font-size");
|
||
if (fontSize.includes("px")) {
|
||
var pxValue = parseFloat(fontSize); // 取得數值
|
||
var emValue = pxValue / 16; // 假設 1em = 16px
|
||
$(this).css("font-size", emValue + "em");
|
||
}
|
||
});
|
||
$("[style*='font-size']").each(function() {
|
||
var fontSize = $(this).css("font-size");
|
||
if (fontSize.includes("pt")) {
|
||
var ptValue = parseFloat(fontSize); // 取得數值
|
||
var emValue = ptValue / 12; // 1em = 12pt(一般轉換標準)
|
||
$(this).css("font-size", emValue + "em");
|
||
}
|
||
});
|
||
//表格scope
|
||
$("table").each(function() {
|
||
$(this).find("tr").each(function(rowIndex) {
|
||
$(this).find("th").each(function(colIndex) {
|
||
if (rowIndex === 0) {
|
||
// 第一列的 th,適用於該欄
|
||
$(this).attr("scope", "col");
|
||
} else if (colIndex === 0) {
|
||
// 其他列的第一個 th,適用於該行
|
||
$(this).attr("scope", "row");
|
||
}
|
||
});
|
||
});
|
||
});
|
||
$(".banner-pager button").addClass('banner-pagerbtn');
|
||
$(".banner-pager button").attr("type","button");
|
||
$(".banner-pager button").append('<span style="display: none;">下一張</span>');
|
||
$("button").attr("role", "button");
|
||
$("select").attr("title","選擇類別");
|
||
$(".jarallax-video-audio").attr("role", "button");
|
||
$('button').each(function() {
|
||
var $this = $(this);
|
||
if (!$this.attr('title') || $this.attr('title').trim() === '') {
|
||
$this.attr('title', '按鈕');
|
||
}
|
||
});
|
||
$('img').each(function() {
|
||
var $this = $(this);
|
||
if (!$this.attr('alt') || $this.attr('alt').trim() === '') {
|
||
$this.attr('alt', '這是一張圖片');
|
||
}
|
||
});
|
||
$('img').each(function() {
|
||
var $this = $(this);
|
||
|
||
// 檢查 img 的 alt 屬性是否為 "裝飾圖片"
|
||
if ($this.attr('alt') === "裝飾圖片" || $this.attr('title') === "裝飾圖片") {
|
||
// 設定 alt 為空字串
|
||
$this.attr('alt', '');
|
||
|
||
// 移除 title 屬性
|
||
$this.removeAttr('title');
|
||
}
|
||
});
|
||
|
||
$(".w-annc__img-wrap a").each(function () {
|
||
var $this = $(this);
|
||
// 確保 <a> 內沒有文字節點 (避免重複添加)
|
||
if ($this.text().trim() === "") {
|
||
$this.append('<span class="sr-only">公告圖片</span>');
|
||
}
|
||
});
|
||
$(".widget-link__widget-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">公告標題</span>');
|
||
}
|
||
});
|
||
$(".sitemenu-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">次選單</span>');
|
||
}
|
||
});
|
||
$(".annc-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">內頁公告標題</span>');
|
||
}
|
||
});
|
||
$(".event-annc-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">內頁活動公告標題</span>');
|
||
}
|
||
});
|
||
$(".show-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">內頁活動公告標題</span>');
|
||
}
|
||
});
|
||
$(".w-annc__widget-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">公告標題</span>');
|
||
}
|
||
});
|
||
$(".widget-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">網路資源標題</span>');
|
||
}
|
||
});
|
||
$(".widget-title").each(function () {
|
||
if ($(this).text().trim() === "") {
|
||
$(this).append('<span class="sr-only">網路資源標題</span>');
|
||
}
|
||
});
|
||
$('input').each(function() {
|
||
var $this = $(this);
|
||
if (!$this.attr('title') || $this.attr('title').trim() === '') {
|
||
$this.attr('title', '網內搜尋');
|
||
}
|
||
});
|
||
$('.rucaptcha-image').each(function() {
|
||
var $button = $(this).next('button'); // 取得緊接在 .rucaptcha-image 之後的 button
|
||
if ($button.length && !$button.attr('aria-label')) {
|
||
$button.attr('aria-label', '播放驗證碼語音');
|
||
}
|
||
});
|
||
//有連結目的之所有a標籤加上aria-label和title
|
||
$('a').each(function () {
|
||
var $a = $(this);
|
||
var href = $a.attr('href');
|
||
if (!href) return;
|
||
|
||
var hasSrOnly = $a.find('.sr-only').length > 0;
|
||
|
||
// 若有 .sr-only,移除 aria-label 和 title 避免重複朗讀
|
||
if (hasSrOnly) {
|
||
$a.removeAttr('aria-label');
|
||
$a.removeAttr('title');
|
||
return; // 有 .sr-only 就不做其他處理
|
||
}
|
||
|
||
// ----- aria-label 邏輯 -----
|
||
if (!$a.attr('aria-label')) {
|
||
let ariaLabel = '';
|
||
|
||
// 加入開啟方式
|
||
if ($a.attr('target') === '_blank') {
|
||
ariaLabel += '在新視窗開啟 ';
|
||
} else if ($a.attr('target') === '_self') {
|
||
ariaLabel += '在本視窗開啟 ';
|
||
}
|
||
|
||
// 如果包含圖片且有圖片 title
|
||
if ($a.find('img').length) {
|
||
const imgTitle = $a.find('img').attr('title');
|
||
if (imgTitle) ariaLabel = imgTitle;
|
||
} else {
|
||
const text = $a.text().trim();
|
||
if (text) {
|
||
ariaLabel += text;
|
||
} else if ($a.children('span').length === 1) {
|
||
ariaLabel += $a.children('span').text().trim();
|
||
}
|
||
}
|
||
|
||
if (ariaLabel) {
|
||
$a.attr('aria-label', ariaLabel);
|
||
}
|
||
}
|
||
|
||
// ----- title 邏輯 -----
|
||
if (!$a.attr('title')) {
|
||
let titleStr = '';
|
||
|
||
if ($a.attr('target') === '_blank') {
|
||
titleStr += '在新視窗開啟 ';
|
||
} else if ($a.attr('target') === '_self') {
|
||
titleStr += '在本視窗開啟 ';
|
||
}
|
||
|
||
if ($a.find('img').length) {
|
||
titleStr = '這是一張照片';
|
||
} else {
|
||
const text = $a.text().trim();
|
||
if (text) {
|
||
titleStr += text;
|
||
} else if ($a.children('span').length === 1) {
|
||
titleStr += $a.children('span').text().trim();
|
||
}
|
||
}
|
||
|
||
if (titleStr) {
|
||
$a.attr('title', titleStr);
|
||
}
|
||
}
|
||
});
|
||
|
||
|
||
|
||
|
||
// 刪除banner-slide的空連結和空連結目標
|
||
for(var i=0;i<$('.w-ba-banner__slide a').length;i++){
|
||
if($('.w-ba-banner__slide a').eq(i).attr('href')=="")
|
||
$('.w-ba-banner__slide a').eq(i).removeAttr('href');
|
||
if($('.w-ba-banner__slide a').eq(i).attr('target') == "")
|
||
$('.w-ba-banner__slide a').eq(i).removeAttr('target');
|
||
};
|
||
// 幫無標題之iframe加上title
|
||
for(var i=0;i<$('iframe').length;i++)
|
||
if($('iframe').eq(i).attr('title')=="" || $('iframe').eq(i).attr('title')== undefined ){
|
||
if($('iframe').eq(i).attr('src').search('facebook') != -1 )
|
||
$('iframe').eq(i).attr('title','facebook');
|
||
else if($('iframe').eq(i).attr('src').search('google') != -1 )
|
||
$('iframe').eq(i).attr('title','google');
|
||
else if($('iframe').eq(i).attr('src').search('youtube') != -1 )
|
||
$('iframe').eq(i).attr('title','youtube');
|
||
else if($('iframe').eq(i).attr('src').search('twitframe') != -1 )
|
||
$('iframe').eq(i).attr('title','twitter');
|
||
else
|
||
$('iframe').eq(i).attr('title','unknown');
|
||
};
|
||
//button是空的就加上內容
|
||
$('button').each(function() {
|
||
var $this = $(this);
|
||
var titleText = $this.attr('title') || '';
|
||
|
||
// 檢查 button 是否是空的(沒有可見文字或子元素)
|
||
if ($this.text().trim() === '' && !$this.children().length && titleText) {
|
||
// 新增隱藏的 span,內容為 title
|
||
$this.append('<span class="sr-only">' + titleText + '</span>');
|
||
}
|
||
});
|
||
// 刪除空的檔案室
|
||
var archievelen = $('dd a.i-archive-files-item').length;
|
||
for(i=archievelen-1;i>=0;i--)
|
||
if($('dd a.i-archive-files-item').eq(i).html().trim()=="")
|
||
$('dd a.i-archive-files-item').eq(i).parent('dd').remove();
|
||
// 刪除具有空連結欄位的橫列
|
||
for(var i = 0;i < $('*[data-list] tr td a').length ; i++)
|
||
if($('*[data-list] tr td a').eq(i).html().trim()=="")
|
||
$('*[data-list] tr td a').eq(i).parent('td').parent('tr').remove();
|
||
// tab按鍵選到menu,會顯示下層的menu(為了符合無障礙)
|
||
$('.nav-level-0>li>a').focus(function(e) {
|
||
e.stopPropagation();
|
||
$(this).parent().focus();
|
||
if ($(this).parent().find('.nav-level-1').hasClass('show')) {
|
||
} else {
|
||
$('.nav-level-1').removeClass('show');
|
||
$(this).parent().find('.nav-level-1').addClass('show');
|
||
}
|
||
});
|
||
$('.nav-level-1>li>a').focus(function(e) {
|
||
e.stopPropagation();
|
||
if ($(this).parent().find('.nav-level-2').hasClass('show')) {
|
||
}else{
|
||
$('.nav-level-2').removeClass('show');
|
||
$(this).parent().find('.nav-level-2').addClass('show');
|
||
}
|
||
});
|
||
$('show').parent('li').focus();
|
||
}
|
||
forFreeGo();
|
||
|
||
//背景widget設定
|
||
if ( location.href.search('editmode=on') != -1 ) {
|
||
$('.background').css({'z-index': '0', 'position': 'relative'});
|
||
} else {
|
||
$('.background').css('z-index','-1');
|
||
};
|
||
|
||
//header banner setting
|
||
if ( location.href.search('editmode=on') != -1 ) {
|
||
$('.header-banner').css('z-index','2');
|
||
} else {
|
||
$('.header-banner').css({
|
||
'position': 'absolute',
|
||
'top': '0',
|
||
'z-index': '-2',
|
||
});
|
||
};
|
||
|
||
var url = window.location.search;
|
||
if (url == "?editmode=on") {
|
||
$('.tab_content').css({'position': 'relative','display':'block'});
|
||
}
|
||
|
||
//切換語言停留在同一頁
|
||
if(window.location.pathname!="/")
|
||
$("#en").attr("href",window.location.pathname.replace("zh_tw","en"))
|
||
|
||
//檔案室 下載檔案 hover 彈出備註訊息
|
||
$('[data-toggle="tooltip"]').tooltip()
|
||
|
||
//下載檔案格式dot pdf分色
|
||
$(".i-archive .label.label-primary").each(function() {
|
||
var downloadType = $(this).text();
|
||
$(this).addClass(downloadType);
|
||
})
|
||
|
||
//檔案室模組 Widget 手風琴
|
||
function extendPanelWidget() {
|
||
var len = $('.panel-title').length;
|
||
var i = -1;
|
||
if (len > 0) {
|
||
// 新增數字到要對應的panel按鈕id及href上面
|
||
for (i = 0; i < len; i++) {
|
||
$('.panel-title:eq(' + i + ') .collapsed').attr('href', '#collapse' + i);
|
||
$('.panel-collapse:eq(' + i + ')').attr('id', 'collapse' + i);
|
||
}
|
||
}
|
||
}
|
||
extendPanelWidget();
|
||
// member show tab scroll
|
||
$('.nav-pills').scrollingTabs({
|
||
scrollToTabEdge: true,
|
||
enableSwiping: true,
|
||
leftArrowContent: [
|
||
'<div class="scrtabs-tab-scroll-arrow custom-scroll-arrow"><i class="fa fa-caret-left" aria-hidden="true"></i>',
|
||
'</div>'
|
||
].join(''),
|
||
rightArrowContent: [
|
||
'<div class="scrtabs-tab-scroll-arrow custom-scroll-arrow"><i class="fa fa-caret-right" aria-hidden="true"></i>',
|
||
'</div>'
|
||
].join('')
|
||
});
|
||
}
|
||
$(document).ready(function () {
|
||
// 移除 onload 屬性
|
||
$('.rucaptcha-image').removeAttr('onload');
|
||
|
||
// 檢查是否已插入過
|
||
if (!$('#captcha_audio').length) {
|
||
const audioButton = $(`
|
||
<button
|
||
title="播放驗證碼語音"
|
||
type="button"
|
||
onclick="document.getElementById('captcha_audio').play();"
|
||
class="fas fa-volume-up"
|
||
aria-label="播放驗證碼語音"
|
||
role="button"
|
||
style="font-size: 1.5em; color: #333; cursor: pointer; border: 2px solid #333; padding: 0.2em;">
|
||
<span class="sr-only">播放驗證碼語音</span>
|
||
</button>
|
||
`);
|
||
|
||
const audio = $('<audio id="captcha_audio" src="/rucaptcha/?format=wav&locale=zh_tw"></audio>');
|
||
|
||
$('.rucaptcha-image').after(audioButton, audio);
|
||
}
|
||
});
|
||
|
||
$(document).ready(function () {
|
||
$('.searchbtn2').click(function (event) {
|
||
event.preventDefault(); // 防止預設行為
|
||
$(".searchbox").slideToggle(300, function () {
|
||
updateAriaExpanded();
|
||
});
|
||
$(this).closest('.ken-click').toggleClass('ken-click2');
|
||
});
|
||
|
||
let triggeredByFocus = false; //預留變數,用來處理「focus 觸發 click」的情況(目前未使用)
|
||
|
||
function updateAriaExpanded() {
|
||
const isVisible = $(".searchbox").is(":visible");
|
||
$(".searchbtn2").attr("aria-expanded", isVisible ? "true" : "false");
|
||
}
|
||
|
||
// 預設 aria-expanded 為 false
|
||
$(".searchbtn2").attr("aria-expanded", "false");
|
||
});
|
||
|
||
|
||
|
||
|
||
// 當文件物件模型(DOM)載入後,執行init函數
|
||
$(document).ready(function(){
|
||
|
||
|
||
$('#search'). attr('title', '另開新視窗');
|
||
$('button.fas.fa-volume-up').attr('aria-label', '播放驗證碼語音');
|
||
|
||
$('.i-annc__page-title').after($('.sitemenu-wrap2'));
|
||
$('.i-archive-title').after($('.sitemenu-wrap2'));
|
||
$('.page-module-title').after($('.sitemenu-wrap2'));
|
||
if ($(window).width() < 769) {
|
||
$('.modules-menu-level-0').after($('.header-nav'));
|
||
}else{
|
||
$('.orbit-bar-menu').after($('.header-nav'));
|
||
};
|
||
// $(".navbar-brand").append("<p >Institute of Transportation, MOTC</p>");
|
||
/////////////fatfooter開關/////////////
|
||
/*-----------------------------------*/
|
||
$('.btn-fatfooter').click(function(e) {
|
||
$(this).parent('.container').find('nav>ul>li>ul').stop(true, true).slideToggle(function() {
|
||
if ($(this).is(':visible')) {
|
||
$('.btn-fatfooter').html("收合");
|
||
$('.btn-fatfooter').attr('name', '收合選單/CLOSE');
|
||
$('.btn-fatfooter').attr('aria-pressed', 'true');
|
||
} else {
|
||
$('.btn-fatfooter').html("展開");
|
||
$('.btn-fatfooter').attr('name', '展開選單/OPEN');
|
||
$('.btn-fatfooter').attr('aria-pressed', 'false');
|
||
}
|
||
});
|
||
$(this).stop(true, true).toggleClass('close');
|
||
});
|
||
$('.w-annc__widget-title>span>.nav_tabs_filter').before($('.kenItem'));
|
||
//RWD 自動縮放headerbannner
|
||
function headerH() {
|
||
if ($(window).width() < 769) {
|
||
var navH = $('.layout-header .navbar-header').outerHeight();
|
||
$('.orbit-bar-menu').css('height', navH );
|
||
}
|
||
}
|
||
headerH();
|
||
$(window).resize(function() {
|
||
headerH();
|
||
if ($(window).width() < 769) {
|
||
$('.modules-menu-level-0').after($('.header-nav'));
|
||
}else{
|
||
$('.orbit-bar-menu').after($('.header-nav'));
|
||
};
|
||
})
|
||
$(window).scroll(function() {
|
||
initdata1();
|
||
});
|
||
|
||
init();
|
||
});
|
||
$(document).ready(function () {
|
||
let isArranged = false; // 追蹤是否已經排列過
|
||
|
||
function arrangeInCircle(containerSelector, radius) {
|
||
const $items = $(containerSelector + ' > .sitemenu-item');
|
||
const total = $items.length;
|
||
|
||
$items.each(function (index) {
|
||
const angle = (2 * Math.PI / total) * index;
|
||
const x = radius * Math.cos(angle);
|
||
const y = radius * Math.sin(angle);
|
||
$(this).css({
|
||
position: 'absolute',
|
||
left: '50%',
|
||
top: '50%',
|
||
transform: `translate(-50%, -50%) translate(${x}px, ${y}px)`
|
||
});
|
||
});
|
||
}
|
||
|
||
function clearTransforms(containerSelector) {
|
||
$(containerSelector + ' > .sitemenu-item').removeAttr('style');
|
||
}
|
||
|
||
function handleResize() {
|
||
const containerSelector = '.sitemenu-horizontal-ken .sitemenu-list.level-1';
|
||
if (window.innerWidth > 767) {
|
||
if (!isArranged) {
|
||
arrangeInCircle(containerSelector, 220);
|
||
isArranged = true;
|
||
}
|
||
} else {
|
||
if (isArranged) {
|
||
clearTransforms(containerSelector);
|
||
isArranged = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 初次執行
|
||
handleResize();
|
||
|
||
// 監聽視窗縮放
|
||
$(window).on('resize', function () {
|
||
handleResize();
|
||
});
|
||
});
|
||
//orbitbar無障礙
|
||
$(document).ready(function() {
|
||
const isEnglish = document.documentElement.lang === 'en';
|
||
|
||
if (isEnglish) {
|
||
$('.navbar-toggle').attr({
|
||
title: 'menu',
|
||
'aria-label': 'menu'
|
||
});
|
||
$('label[for="open-orbit-nav"]').attr({
|
||
title: 'Site search and language menu',
|
||
'aria-label': 'Site search and language menu'
|
||
});
|
||
$('.mobile-button').attr({
|
||
title: 'Language menu',
|
||
'aria-label': 'Language menu'
|
||
});
|
||
} else {
|
||
$('label[for="open-orbit-nav"]').attr({
|
||
title: '全站収尋及語言切換選單',
|
||
'aria-label': '全站収尋及語言切換選單'
|
||
});
|
||
$('.mobile-button').attr({
|
||
title: '語言切換選單',
|
||
'aria-label': '語言切換選單'
|
||
});
|
||
}
|
||
|
||
|
||
$('label[for="open-orbit-login"]').removeAttr('tabindex');
|
||
$('#orbit-bar').find('li').each(function() {
|
||
var $li = $(this);
|
||
|
||
// 如果 <li> 中没有 <a> 元素,则为 <li> 设置 tabindex="0"
|
||
if ($li.children('a').length === 0) {
|
||
$li.attr('tabindex', '0');
|
||
} else {
|
||
// 如果 <li> 中有 <a> 元素,则确保 <a> 有 tabindex="0"
|
||
$li.find('a').attr('tabindex', '0');
|
||
|
||
// 确保 <li> 不影响焦点管理,移除 <li> 的 tabindex
|
||
$li.removeAttr('tabindex');
|
||
|
||
// 如果 <li> 被聚焦,自动跳转到 <a> 元素
|
||
$li.on('focus', function() {
|
||
$(this).find('a').focus();
|
||
});
|
||
}
|
||
});
|
||
$('label[for="open-orbit-nav"]').attr('tabindex', '0');
|
||
// 当屏幕宽度小于 768px 时,将 .orbit-bar-search-sign-language 移动到 <label for="open-orbit-nav"> 后面
|
||
function moveSearchSignLanguage() {
|
||
if ($(window).width() < 767) {
|
||
$('.orbit-bar-search-sign-language').insertAfter('label[for="open-orbit-nav"]');
|
||
} else {
|
||
// 屏幕宽度大于等于 768px 时,恢复原位置
|
||
$('.orbit-bar-search-sign-language').appendTo('.orbit-bar-inner');
|
||
}
|
||
}
|
||
|
||
moveSearchSignLanguage();
|
||
$(window).resize(function() {
|
||
moveSearchSignLanguage();
|
||
});
|
||
// 当 <label for="open-orbit-nav"> 被选中时,显示 .orbit-bar-search-sign-language
|
||
$('label[for="open-orbit-nav"]').on('focus', function() {
|
||
$('.orbit-bar-search-sign-language').addClass('show');
|
||
})
|
||
$('#languagebutton').on('focus', function() {
|
||
$('#language-li ul').addClass('show');
|
||
});
|
||
|
||
// 监听 #language 元素被 Tab 键选中时
|
||
$('#language-li-ul li').on('focus', function() {
|
||
// 给 #language 内部的 ul 元素添加 show 类
|
||
$(this).find('ul').addClass('show');
|
||
});
|
||
$('#language-li-ul li ul > li:last-child>a').on('blur', function() {
|
||
$('#language-li-ul li ul').removeClass('show');
|
||
});
|
||
$('.orbit-bar-title a').on('focus', function() {
|
||
$('#language-li-ul li ul').removeClass('show');
|
||
});
|
||
|
||
|
||
$('#language-li').on('focus', function() {
|
||
// 给 #language 内部的 ul 元素添加 show 类
|
||
$(this).find('ul').addClass('show');
|
||
});
|
||
$('#language-li ul > li:last-child>a').on('blur', function() {
|
||
$('#language-li ul').removeClass('show');
|
||
$('.orbit-bar-search-sign-language').removeClass('show');
|
||
});
|
||
$('label[for="open-orbit-login"]').on('blur', function() {
|
||
$('.orbit-bar-search-sign-language').removeClass('show');
|
||
});
|
||
$('#gotocenter').on('focus', function() {
|
||
// 当 #gotocenter 被选中时,移除 .orbit-bar-search-sign-language 上的 show 类
|
||
$('.orbit-bar-search-sign-language').removeClass('show');
|
||
});
|
||
$('label[for="open-orbit-nav"]').on('click', function() {
|
||
// 切換 .orbit-bar-search-sign-language 的 .show 類別
|
||
$('.orbit-bar-search-sign-language').removeClass('show');
|
||
});
|
||
|
||
});
|
||
$(document).ready(function () {
|
||
$('.controlplay a[role="radio"]').on('click', function () {
|
||
// 取消所有的 aria-checked 並還原文字
|
||
$('.controlplay a[role="radio"]').attr('aria-checked', 'false');
|
||
$('.controlplay a[role="radio"] span').each(function () {
|
||
var text = $(this).text().replace('(已選取)', '');
|
||
$(this).text(text);
|
||
});
|
||
|
||
// 設定目前被點擊的按鈕為已選取
|
||
$(this).attr('aria-checked', 'true');
|
||
var selectedText = $(this).text().trim();
|
||
$(this).find('span').text(selectedText + '(已選取)');
|
||
});
|
||
});
|
||
//隱藏Hashtags
|
||
$(document).ready(function () {
|
||
$('.universal-table-show .table-title').each(function () {
|
||
var $titleTd = $(this);
|
||
var titleText = $titleTd.text().trim();
|
||
var $nextTd = $titleTd.next('td');
|
||
|
||
if (titleText === 'Hashtags' && $nextTd.length > 0 && $nextTd.text().trim() === '') {
|
||
$titleTd.closest('tr').hide();
|
||
}
|
||
});
|
||
});
|
||
$(document).ready(function () {
|
||
$('.universal-table-index .theadsearch tr th').each(function (index) {
|
||
const $th = $(this);
|
||
const title = $th.find('.universal-th-text').text().trim();
|
||
|
||
// 找到 Hashtags 欄
|
||
if (title === 'Hashtags') {
|
||
let allEmpty = true;
|
||
|
||
// 走訪 tbody 的每一列檢查對應欄位是否都為空
|
||
$('.universal-table-index tbody tr').each(function () {
|
||
const $td = $(this).find('td').eq(index);
|
||
if ($td.text().trim() !== '') {
|
||
allEmpty = false;
|
||
return false; // 提前跳出 each
|
||
}
|
||
});
|
||
|
||
if (allEmpty) {
|
||
// 隱藏 thead 裡對應的 th
|
||
$th.hide();
|
||
|
||
// 隱藏 tbody 所有對應的 td 欄位
|
||
$('.universal-table-index tbody tr').each(function () {
|
||
$(this).find('td').eq(index).hide();
|
||
});
|
||
}
|
||
}
|
||
});
|
||
});
|
||
$(document).ready(function () {
|
||
const $tableShow = $('.universal-table-show');
|
||
if ($tableShow.length > 0) {
|
||
const firstText = $tableShow.find('tr:first .table-txt:first').text().trim();
|
||
if (firstText) {
|
||
const $li = $('<li>').text(firstText);
|
||
$('.breadcrumb').append($li);
|
||
}
|
||
}
|
||
});
|
||
$(window).load(function(){
|
||
$('.orbit-bar-menu').after($('.header-nav'));
|
||
if ($(window).width() < 769) {
|
||
$('.modules-menu-level-0').after($('.header-nav'));
|
||
}else{
|
||
$('.orbit-bar-menu').after($('.header-nav'));
|
||
};
|
||
$('.w-annc__widget-title>span>.nav_tabs_filter').before($('.kenItem'));
|
||
$("iframe[src*='google']").attr('title','googleOauth');
|
||
});
|
||
|
||
// 執行 member等高計算,目前改用flexbox故mark掉 by ika 20160105
|
||
// $(window).load(function() {
|
||
// if ($('.index-member-3').length && $(window).width() > 992) {
|
||
// ORBITFRONT.member.equalHeight('.i-member-item-inner');
|
||
// }
|
||
// });
|
||
|
||
}(jQuery, window));
|