asia-home-b-en/assets/javascripts/app.js

935 lines
32 KiB
JavaScript
Raw Normal View History

2021-08-30 10:09:12 +00:00
;(function($, win, undefined) {
// ECMAScript 5 嚴格模式
'use strict';
2022-08-21 09:54:49 +00:00
$.fn.extend({
replaceTagName: function(new_tagname){
if(!this.length)
return {};
var outerHTML = this.prop('outerHTML');
var new_tagname = new_tagname.toLowerCase();
var new_html = '<' + new_tagname + outerHTML.slice(3, -3) + new_tagname + '>';
this.replaceWith(new_html);
}
});
2023-02-06 15:44:11 +00:00
function fix_first_element(force_fix) {
if(!force_fix && window.already_fix_first_element){
return;
}
window.already_fix_first_element = false;
2022-12-15 07:37:24 +00:00
if (!window.has_topest_banner) {
$('.downIcon').css('display','none');
var first_element = $('.header-banner');
2023-02-06 15:44:11 +00:00
var parent_element = $()
2022-12-15 07:37:24 +00:00
if(first_element.length == 0){
first_element = $('.layout-content .layout-content-inner').eq(0);
}else{
if(first_element.html() == ''){
first_element = $('.layout-content .layout-content-inner').eq(0);
}
}
if(first_element.length != 0){
first_element.css("margin-top", "");
2023-02-06 15:44:11 +00:00
var ele_offset = first_element[0].getBoundingClientRect().top + document.documentElement.scrollTop;
2022-12-15 07:37:24 +00:00
if(first_element.parents('.kenjohn.navFixed').length == 0)
ele_offset -= window.top_barrier_height;
if(ele_offset < 0){
first_element.css("margin-top", -ele_offset + "px");
}else{
first_element.css("margin-top", "");
}
}
}else{
$("#onesection").css("margin", "0");
$('.layout-content-inner .row, .layout-content-inner .row > [class*="col-"]').css("padding", "0");
}
2023-02-06 15:44:11 +00:00
window.already_fix_first_element = true;
2022-12-15 07:37:24 +00:00
}
2021-08-30 10:09:12 +00:00
function initdata1 () {
2022-08-24 11:14:22 +00:00
window.temp_scrollY = window.pageYOffset;
window.temp_scrollX = window.pageXOffset;
if(window.temp_scrollY == undefined){
window.temp_scrollY = document.documentElement.scrollTop;
window.temp_scrollX = document.documentElement.scrollLeft;
}
2021-08-30 10:09:12 +00:00
// if (location.href.search('editmode') == -1 && document.getElementsByClassName('asideright').length != 0) {
2022-12-07 07:01:53 +00:00
if ( $('.header-banner').length != 0 ) {
2021-08-30 10:09:12 +00:00
$('.layout-header').css('height', '');
2021-08-31 07:25:53 +00:00
var scrollTop = $(window).scrollTop();
2022-12-09 09:31:42 +00:00
if (!window.has_topest_banner){
2022-12-15 07:37:24 +00:00
$('.kenjohn').removeClass('navRel').addClass('navFixed'); /* 正常選單固定效果 */
2022-12-09 09:31:42 +00:00
}else if (scrollTop>5) { /* 要滑動到選單的距離 */
2022-01-03 15:09:02 +00:00
if (parseInt($('.layout-content').css('margin-top'))==0 && $('.layout-content.topcontent').length != 0 && $('.layout-content.topcontent').offset().top<400){
2021-11-14 03:23:33 +00:00
$('.layout-content').css('margin-top',$('.kenjohn').height()-$('#orbit-bar').height());
2021-08-31 10:01:12 +00:00
}
2021-08-30 10:09:12 +00:00
$('.kenjohn').addClass('navFixed').removeClass('navRel'); /* 幫選單加上固定效果 */
} else {
2022-12-09 09:31:42 +00:00
$('.kenjohn').removeClass('navRel').removeClass('navFixed'); /* 移除選單固定效果 */
2021-08-31 10:01:12 +00:00
$('.layout-content').css('margin-top','');
2021-08-30 10:09:12 +00:00
}
}
2022-08-24 11:14:22 +00:00
var navFixed = $('.kenjohn.navFixed');
window.top_barrier_height = (navFixed.length ? navFixed.height() : 0) + $('#orbit-bar').height();
2023-02-06 15:44:11 +00:00
fix_first_element();
2021-08-30 10:09:12 +00:00
}
// 初始函數: 把所有的程式碼都包在init裡面方便在之後的jQuery ready 函數裡一次呼叫
function init() {
// 快取一些常用的變數
2022-08-24 11:14:22 +00:00
var navFixed = $('.kenjohn.navFixed');
window.top_barrier_height = (navFixed.length ? navFixed.height() : 0) + $('#orbit-bar').height();
2021-08-30 10:09:12 +00:00
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();
$('.top').fadeIn();
} else {
$('.go-back-top').fadeOut();
$('.top').fadeOut();
}
});
// 捲動效果
$('.go-back-top').on('click', function() {
$('body, html').animate({
scrollTop: 0
}, speed || 300);
return false;
});
$('.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()
.removeClass(function(index, css) {
return (css.match(/(^|\s)col-\S+/g) || []).join(' ');
})
.addClass(columnCls);
}
});
}
},
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();
2022-10-20 04:12:53 +00:00
if($('body').hasClass('noscroll')){
$('.mobile-menu').removeClass('active');
window.setTimeout(function(){
$('body').removeClass('noscroll');
$('body').css('top', '');
window.scroll(window.temp_scrollX, ($('body').data('org-scrollY') || 0));
},400);
}else{
$('body').data('org-scrollY', window.temp_scrollY);
$('body').css('top', '-' + window.temp_scrollY.toString() + 'px');
$('body').addClass('noscroll');
$('.mobile-menu').addClass('active');
}
2021-08-30 10:09:12 +00:00
$('.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-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;
}
// 在所有的頁面(包含首頁)執行下面這幾個函數
2022-12-09 08:46:52 +00:00
window.has_topest_banner = ($('[data-pp="300"] .w-ad-banner').length != 0);
2021-08-30 10:09:12 +00:00
initdata1();
orbit.sitemenuDropdown();
orbit.goBackTop('top', 800);
orbit.plugins.bullEye();
orbit.setColumn('.left-column', '.right-column');
// 自適應網頁使用當網頁載入時如果視窗寬度小於769就執行orbit.nav.setDropdown函數
2022-10-12 01:11:40 +00:00
if ($(window).outerWidth() >200) {
2021-08-30 10:09:12 +00:00
// orbit.nav.setDropdown();
orbit.MobileMenu();
2022-10-12 01:11:40 +00:00
$('.dropdowns').append($('.modules-menus'));
$('.mobile-menu').append($('.modules-menus'));
$('.header-buttom').appendTo($('.modules-menus'));
2021-08-30 10:09:12 +00:00
$('.outdropdowns').before($('.header-nav'));
orbit.ClickMenuHandler();
}else{
2022-01-21 09:56:51 +00:00
$('.outdropdowns').before($('.header-nav'));
2022-10-12 01:11:40 +00:00
$('.navbar-header').after($('.modules-menus'));
2021-08-30 10:09:12 +00:00
}
// 自適應網頁使用當使用者改變瀏覽器寬度時呼叫orbit.nav.setDropdown函數
$(window).resize(function() {
2022-08-24 11:14:22 +00:00
var navFixed = $('.kenjohn.navFixed');
window.top_barrier_height = (navFixed.length ? navFixed.height() : 0) + $('#orbit-bar').height();
2023-02-06 15:44:11 +00:00
fix_first_element(true);
2022-10-12 01:11:40 +00:00
if ($(window).outerWidth() >200) {
2021-08-30 10:09:12 +00:00
if (resizeTimer) clearTimeout(resizeTimer);
$('.outdropdowns').before($('.header-nav'));
resizeTimer = setTimeout(function() {
2022-10-12 01:11:40 +00:00
if ( $('.modules-menus i').length == 0 ) {
2021-08-30 10:09:12 +00:00
orbit.MobileMenu();
}
2022-10-12 01:11:40 +00:00
if( $('.mobile-menu .modules-menus').length == 0 ) {
$('.mobile-menu').append($('.modules-menus'));
2021-08-30 10:09:12 +00:00
$('.navbar-toggle').bind(orbit.ClickMenuHandler());
}
},500 )} else {
resizeTimer = setTimeout(function(){
2022-10-12 01:11:40 +00:00
if( $('.mobile-menu .modules-menus').length > 0 ) {
$('.navbar-header').after($('.modules-menus'));
2021-08-30 10:09:12 +00:00
}
orbit.removeDropdown();
}, 500);
2022-01-21 09:56:51 +00:00
$('.outdropdowns').before($('.header-nav'));
2022-10-12 01:11:40 +00:00
$('.navbar-header').after($('.modules-menus'));
2021-08-30 10:09:12 +00:00
}
});
// if($(window).width()<769){
2022-10-12 01:11:40 +00:00
// $('.header-buttom').appendTo($('.modules-menus'));
2021-08-30 10:09:12 +00:00
// }else{
// $('.header-buttom').appendTo($('.dropdowns'));
// }
2022-01-12 01:33:36 +00:00
$(document).on('touchstart','a',function(e){
e.stopPropagation();
$(this).trigger('focus');
});
2021-08-30 10:09:12 +00:00
//背景widget設定
if ( location.href.search('editmode=on') != -1 ) {
$('.background').css('z-index','0');
$('.downIcon').css('position','relative')
$('.jp-jplayer').css('position','relative')
$('.layout-footer').css('position','relative')
$('.layout-header').css('height','auto')
} else {
$('.background').css('z-index','-1');
};
//header banner setting
if ( location.href.search('editmode=on') != -1 ) {
$('.header-banner').css('z-index','2');
$('.header-banner').css('margin-top','8em');
} else {
$('.header-banner').css({
'width': '100%',
'position': 'relative',
'top': '0',
'z-index': '0',
});
};
//公告頁籤
function annc_widget_nav() {
$('.tab_nav').nextAll().addClass('tab_content');
$('.tab_content').css("display","none");
$('.tab_content').eq(0).css('display', 'block');
var num = $('.tab_nav li').length;
$('.tab_content').eq(num).css('display', 'block');
$('.tab_content').eq(num).nextAll().css('display', 'block');
$('.tab_nav li').off('click').on('click',function() {
$('.tab_nav li').removeClass('active');
$(this).addClass('active');
var fa = $(this).index();
$('.tab_content').attr('style','');
$('.tab_content').css("display","none");
$('.tab_content').eq(fa).css('display','block');
var num = $('.tab_nav li').length;
$('.tab_content').eq(num).css('display', 'block');
$('.tab_content').eq(num).nextAll().css('display', 'block');
});
var url = window.location.search;
if (url == "?editmode=on") {
$('.tab_content').css({'position': 'relative','display':'block'});
}
}
annc_widget_nav();
//切換語言停留在同一頁
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('')
});
}
function transdate(){
var n=document.getElementsByClassName('w-event_news__postdate').length;
var i;
var xx = new Array(n);
if(n != 0){
for(i=0;i<n;i++){
var yy;
xx[i] = document.getElementsByClassName('w-event_news__postdate')[i].innerHTML;
JSON.stringify(xx[i]);
if(xx[i]==undefined){
return;
}else{
JSON.stringify(yy);
yy = xx[i].split('-');
//console.log(xx[i]);
switch (yy[1]) {
case '01':
yy[1]='JAN';
break;
case '02':
yy[1]='FEB';
break;
case '03':
yy[1]='MAR';
break;
case '04':
yy[1]='APR';
break;
case '05':
yy[1]='MAY';
break;
case '06':
yy[1]='JUN';
break;
case '07':
yy[1]='JUL';
break;
case '08':
yy[1]='AUG';
break;
case '09':
yy[1]='SEP';
break;
case '10':
yy[1]='OCT';
break;
case '11':
yy[1]='NOV';
break;
case '12':
yy[1]='DEC';
break;
default:
console.log(yy[1]);
break;
}
document.getElementsByClassName('w-event_news__postdate')[i].innerHTML=("<div class='month'>"+yy[1]+"</div><div class='day'>"+yy[2]+"</div>");
};
};
};
};
// 當文件物件模型(DOM)載入後執行init函數
$(document).ready(function() {
2022-08-24 11:14:22 +00:00
window.temp_scrollY = window.pageYOffset;
window.temp_scrollX = window.pageXOffset;
if(window.temp_scrollY == undefined){
window.temp_scrollY = document.documentElement.scrollTop;
window.temp_scrollX = document.documentElement.scrollLeft;
}
$(document).on('focusin','*',function(event){
// event.stopPropagation();
2022-08-24 11:50:27 +00:00
if(window.focus_timeout_id){
window.clearTimeout(window.focus_timeout_id);
2022-08-24 11:14:22 +00:00
}
2022-08-24 11:50:27 +00:00
var _this = $(document.activeElement);//$(this);
2022-10-20 04:12:53 +00:00
if($('body').css('position') != 'fixed' && !_this.hasClass('close-screen-btn') && !_this.hasClass('navbar-toggle')){
2022-10-31 16:24:48 +00:00
var ele_offset = _this[0].getBoundingClientRect().top;
2022-11-01 05:23:48 +00:00
if(_this.parents('.kenjohn.navFixed').length == 0)
2022-10-31 16:24:48 +00:00
ele_offset -= window.top_barrier_height;
2022-08-24 11:50:27 +00:00
if(ele_offset < 0){
window.scroll(window.temp_scrollX, window.temp_scrollY + ele_offset);
window.temp_scrollY = Math.max(window.temp_scrollY + ele_offset, 0);
}
window.focus_timeout_id = window.setTimeout(function(){
2022-10-20 04:12:53 +00:00
var ele_offset = _this[0].getBoundingClientRect().top - window.top_barrier_height;
2022-08-24 11:50:27 +00:00
if(ele_offset < 0){
window.scroll(window.temp_scrollX, window.temp_scrollY + ele_offset);
window.temp_scrollY = Math.max(window.temp_scrollY + ele_offset, 0);
}
}, 800);
if ($('header>.kenjohn').attr('class') == "kenjohn" && _this.is('a.orbit-bar-logo')){
$('header>.kenjohn').addClass('navRel');
$('#gotocenter').focus();
}
2022-01-22 10:25:51 +00:00
}
2022-01-22 10:34:26 +00:00
});
2021-11-14 03:33:54 +00:00
$('.group').each(function(){
if ($(this).text().trim()==''){
$(this).css('padding',0);
}
});
2021-08-30 10:09:12 +00:00
//RWD 自動縮放headerbannner
function headerH() {
2021-09-16 03:43:37 +00:00
if ($(window).outerWidth() < 769) {
2021-08-30 10:09:12 +00:00
const navH = $('.layout-header .navbar-header').outerHeight();
}
}
headerH();
$(window).resize(function() {
headerH();
})
$(window).scroll(function() {
initdata1();
});
// $(window).scroll(function() {
// var windowBottom = $(window).scrollTop() + $(window).innerHeight();
// $('.oneword').each(function() {
// var mid = $(this).offset().top + $(this).height()/2;
// if( mid < windowBottom && mid > $(window).scrollTop()){
// $(this).addClass('animationtop')
// } else {
// $(this).removeClass('animationtop')
// }
// })
// })
init();
// $('.sitemenu-item a').click(function(e) {
// e.preventDefault();
//
// var $this = $(this);
//
// if ($this.next().next().hasClass('show')) {
// $this.next().next().removeClass('show');
// $this.next().next().slideUp(350);
// } else {
// $this.parent().parent().find('li.level-2').removeClass('show');
// $this.parent().parent().find('li.level-2').slideUp(350);
// $this.next().next().toggleClass('show');
// $this.next().next().slideToggle(350);
// }
// });
2021-09-14 05:08:17 +00:00
$('.sitemenu-item span.fa').click(function(){
var $ul = $(this).parent("li").children("ul");
if($ul.find('li').length != 0){
$ul.slideToggle('100');
if($(this).hasClass('fa-caret-down')){
$(this).removeClass('fa-caret-down').addClass('fa-caret-up');
}else{
$(this).removeClass('fa-caret-up').addClass('fa-caret-down');
}
}
2021-08-30 10:09:12 +00:00
});
});
// // //選單
// $(document).ready(function() {
//
// //drop down menu
// $(".dropdown-toggle").hover(function() {
2022-10-12 01:11:40 +00:00
// $('.modules-menus-level-1').addClass('display-on');
2021-08-30 10:09:12 +00:00
// });
// $(".dropdown-toggle").mouseleave(function() {
2022-10-12 01:11:40 +00:00
// $('.modules-menus-level-1').removeClass('display-on');
2021-08-30 10:09:12 +00:00
// });
//
// });
// $(document).ready(function() {
//
// "use strict";
//
// $(".navbar-collapse > ul > li").hover(function(e) {
// if ($(window).width() > 943) {
// $(this).children("ul").stop(true, false).fadeToggle(150);
// e.preventDefault();
// }
// });
// });// //選單
$(document).ready(function() {
2021-09-22 15:09:30 +00:00
$('li.active > span.fa-caret-down').addClass('fa-caret-up').removeClass('fa-caret-down');
window.has_hover = false;
if($(window).outerWidth(true) >= 768){
window.has_hover = true;
}
$('.sitemenu-item.level-1').hover(function(){
2021-09-22 15:22:47 +00:00
if(window.has_hover && !$(this).hasClass("active")){
2021-09-22 15:09:30 +00:00
$(this).find(".sitemenu-dropdown-toggle").addClass("fa-caret-up").removeClass('fa-caret-down');
}
},function(){
2021-09-22 15:22:47 +00:00
if(window.has_hover && !$(this).hasClass("active")){
2021-09-22 15:09:30 +00:00
$(this).find(".sitemenu-dropdown-toggle").addClass("fa-caret-down").removeClass('fa-caret-up');
}
})
2021-09-10 12:03:22 +00:00
var title_wrapper = $("<div class=\"title-wraper col-sm-12\"></div>")
2022-08-21 09:54:49 +00:00
$('h4.page-module-title').replaceTagName('h3');
2022-08-24 11:14:22 +00:00
$('h3.i-annc__entry-title').replaceTagName('h4');
2021-09-15 13:05:19 +00:00
title_wrapper.append($('.view_count.pull-right,.page-module-title,#main-content .index-title,.i-member-status-title:eq(0),#main-content > * > [class*="-title"]'));
2021-09-10 12:03:22 +00:00
$('.row.pagerow').prepend(title_wrapper);
try {
2021-08-30 10:09:12 +00:00
transdate()
} catch (e) {
};
"use strict";
$(".menu > ul > li").hover(function(e) {
if ($(window).width() > 943) {
$(this).children("ul").stop(true, false).fadeToggle(150);
e.preventDefault();
}
});
2022-10-12 01:11:40 +00:00
//$('.modules-menus-level-1').css('left','-'+$('.outdropdowns .dropdowns').offset().left+'px');
2021-08-30 10:09:12 +00:00
$(".downIcon").click(function() {
2021-09-02 07:21:58 +00:00
var move_to_target=function (stop) {
2021-09-02 05:42:28 +00:00
var theTop;
2021-09-02 07:21:58 +00:00
if (stop){
$(".kenjohn").addClass('navFixed');
2022-01-03 15:09:02 +00:00
if ($('.layout-content.topcontent').length != 0 && $('.layout-content.topcontent').offset().top<400){
2021-11-14 03:33:54 +00:00
$('.layout-content').css('margin-top',$('.kenjohn').height()-$('#orbit-bar').height());
}
2021-09-02 07:21:58 +00:00
if (parseInt($('.layout-content').css('margin-top')==0)){
2022-01-07 12:11:07 +00:00
theTop = $('.layout-content-inner.container').offset().top-$(".kenjohn").position().top+5;
2021-09-02 07:21:58 +00:00
}else{
2022-01-07 12:11:07 +00:00
theTop = $('.layout-content-inner.container').offset().top-$(".kenjohn").position().top-$(".kenjohn").height()+5;
2021-09-02 07:21:58 +00:00
}
2021-09-02 05:42:28 +00:00
}else{
2022-01-07 12:11:07 +00:00
theTop = 5;
2021-09-02 05:42:28 +00:00
}
2022-08-21 09:54:49 +00:00
// console.log(theTop);
2021-09-02 05:28:12 +00:00
$("html, body").animate({
2022-01-07 12:11:07 +00:00
scrollTop: theTop }, {duration: 400,easing: "swing",complete: function(){
2022-08-21 09:54:49 +00:00
// console.log('finish');
2021-09-02 07:21:58 +00:00
if(!stop){
2022-01-07 12:11:07 +00:00
move_to_target(true);
2021-09-02 07:21:58 +00:00
}
}});
2021-09-02 07:12:09 +00:00
}
2021-09-02 07:21:58 +00:00
move_to_target(false);
2021-08-30 10:09:12 +00:00
return false;
});
});
2021-12-08 02:26:00 +00:00
var calc_menu_flag = false;
2021-12-07 06:21:20 +00:00
function calc_menu_pos(){
2021-09-16 03:43:37 +00:00
if ($(window).outerWidth() < 769){
2021-12-08 02:26:00 +00:00
calc_menu_flag = false;
2022-10-12 01:11:40 +00:00
$('.outdropdowns .modules-menus-level-1').css('right','')
$('.outdropdowns .modules-menus-level-1').css('width','')
2021-12-07 06:21:20 +00:00
}else{
2022-08-24 11:14:22 +00:00
try{
var width = $('header #main-nav').outerWidth();
var right = $(window).width() - $('header #main-nav').offset().left - width;
if (width>50){
calc_menu_flag = true;
2022-10-12 01:11:40 +00:00
$('.outdropdowns .modules-menus-level-1').css('right',right);
$('.outdropdowns .modules-menus-level-1').css('width',width);
2022-08-24 11:14:22 +00:00
}
}catch(e){};
2021-08-30 10:09:12 +00:00
}
2021-12-07 06:21:20 +00:00
}
2021-12-07 06:51:55 +00:00
$(window).resize(function() {
2021-12-07 06:21:20 +00:00
2022-10-12 01:11:40 +00:00
//$('.modules-menus-level-1').css('calc_menu_flagleft','-'+$('.outdropdowns .dropdowns').offset().left+'px');
2021-12-07 06:21:20 +00:00
calc_menu_pos();
2022-01-07 12:11:07 +00:00
2021-12-08 02:29:16 +00:00
window.has_hover = false;
2021-09-22 15:09:30 +00:00
if($(window).outerWidth(true) >= 768){
window.has_hover = true;
}
2021-08-30 10:09:12 +00:00
});
2022-01-24 01:35:52 +00:00
$(document).ready(function(){
$('header #main-nav>li').hover(function(){
if (!calc_menu_flag){
calc_menu_pos();
}
});
$('header #main-nav>li>a').on('focus',function(){
if (!calc_menu_flag){
calc_menu_pos();
}
});
2021-12-08 02:26:00 +00:00
});
2021-08-30 10:09:12 +00:00
$(window).load(function(){
2022-01-24 01:37:14 +00:00
calc_menu_pos();
2021-08-30 10:09:12 +00:00
$("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));