You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.1 KiB

2 years ago
  1. $(function () {
  2. var win = $(window),
  3. sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  4. bEn = sLang === 'en',
  5. pathname = window.location.pathname,
  6. seleLast = pathname.replace("/TG/page/", "").replace(".html", "").replace('_en', ''),
  7. rand_no = Math.floor((Math.random() * 4) + 1),//避免零
  8. menu = $("#headerWrapper h4"),
  9. submenu = $("ul#menu"),
  10. content = $(".article"),
  11. a_logo = $("#headerWrapper>h1>a"),
  12. h1_bg = $("h1.addBG"),
  13. open = function () {
  14. submenu.toggle(200);
  15. content.bind("click", close);
  16. menu.toggleClass("gray");
  17. win.bind("scroll", close);
  18. },
  19. close = function () {
  20. submenu.fadeOut(200);
  21. content.unbind("click");
  22. menu.removeClass("gray");
  23. win.unbind("scroll");
  24. },
  25. /*
  26. * 目的 設置logo
  27. */
  28. fnSetLogo = function (org) {
  29. g_api.ConnectLite(Service.apiappcom, ComFn.GetFileList, {
  30. ParentID: org.WebsiteLgoId
  31. }, function (res) {
  32. if (res.RESULT) {
  33. var saRes = res.DATA.rel;
  34. if (saRes.length > 0 && saRes[0].FilePath) {
  35. a_logo.attr('style', 'background-image: url(' + gServerUrl + '/' + saRes[0].FilePath.replace(/\\/g, "\/") + ');');
  36. }
  37. }
  38. });
  39. };
  40. g_ul.SetLang(sLang);
  41. $("li#" + seleLast).addClass("selected");
  42. $(window).scroll(function () {
  43. if ($(this).scrollTop() > 50) {
  44. $('#toTop').fadeIn(300);
  45. }
  46. else {
  47. $('#toTop').fadeOut(200);
  48. }
  49. });
  50. $("#toTop").click(function () {
  51. $('html, body').animate({
  52. scrollTop: $("body").offset().top
  53. }, 500);
  54. });
  55. menu.bind("click", open);
  56. window.scrollTo(0, 1);
  57. if (h1_bg.length > 0) {
  58. h1_bg.addClass("BG" + rand_no);
  59. }
  60. if (a_logo.length > 0) {
  61. runByOrgInfo(fnSetLogo);
  62. }
  63. });