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.

92 lines
4.3 KiB

2 years ago
  1. $(function () {
  2. 'use strict';
  3. var sLang = $('[http-equiv="content-language"]').attr('content') || 'zh-TW',
  4. /*
  5. * 目的 抓去經典案例
  6. */
  7. fnGetClassicCase = function () {
  8. return fnGetWebSiteSetting(function (saRes) {
  9. var sHtmlTab = $('#temp_classiccasetab').render(saRes),
  10. sHtmlDiv = $('#temp_classiccasediv').render(saRes),
  11. sCurId = '';
  12. if (saRes.length > 0) {
  13. $('#tabsNav').html(sHtmlTab);
  14. $('.tab_contentr').html(sHtmlDiv);
  15. $(".rectThumb").imgLiquid({ fill: true });
  16. var _showTab = getUrlParam('T') || 0;
  17. $('#tabsNav li').css('width', (navigator.userAgent.match(/mobile/i) ? 105 : 100) / saRes.length + '%');
  18. if (_showTab === 0) {
  19. $('#tabsNav li:first').addClass('active');
  20. $('.tab_content').hide().eq(0).show();
  21. }
  22. else {
  23. $('#tabsNav li[data-id="' + _showTab + '"]').addClass('active');
  24. $('.tab_content').hide();
  25. $('#tab' + _showTab).show();
  26. }
  27. // 當 li 頁籤被點擊時...
  28. // 若要改成滑鼠移到 li 頁籤就切換時, 把 click 改成 mouseover
  29. $('#tabsNav li').click(function () {
  30. // 找出 li 中的超連結 href(#id)
  31. var $this = $(this),
  32. _clickTab = $this.find('a').attr('href');
  33. // 把目前點擊到的 li 頁籤加上 .active
  34. // 並把兄弟元素中有 .active 的都移除 class
  35. $this.addClass('active').siblings('.active').removeClass('active');
  36. // 淡入相對應的內容並隱藏兄弟元素
  37. $(_clickTab).stop(false, true).fadeIn(0).siblings().hide();
  38. return false;
  39. });
  40. $(".iframe").click(function () {
  41. sCurId = $(this).attr('data-id');
  42. }).fancybox({
  43. type: 'iframe',
  44. iframe: {
  45. css: {
  46. width: '1024px',
  47. height: '660px'
  48. }
  49. },
  50. afterShow: function (instance, current) {
  51. var oInfo = [],
  52. sParentId = $('#tabsNav li.active').attr('data-id');
  53. oInfo = $.grep(saRes, function (item) {
  54. return item.Guid === sParentId;
  55. })[0];
  56. $.each(oInfo.Infos, function (index, item) {
  57. if (item.Guid === sCurId) {
  58. var elIframe = current.$content.find('iframe').contents();
  59. elIframe.find('#imgCoverId').attr('src', gServerUrl + '/' + item.CoverPath.replace(/\\/g, "\/"));
  60. elIframe.find('#parentTitle').html(oInfo.Title);
  61. elIframe.find('#detailTitle').html(item.Title);
  62. elIframe.find('.detailText').html(item.Content);
  63. elIframe.find(".caseThumb").imgLiquid({ fill: true });
  64. return false;
  65. }
  66. });
  67. }
  68. });
  69. }
  70. }, 'ClassicCase', sLang, null, true);
  71. },
  72. init = function () {
  73. var myHelpers = {
  74. setTitle: function (val, val2) {
  75. return navigator.userAgent.match(/mobile/i) ? val2 || val : val;
  76. },
  77. setFilePath: function (val) {
  78. val = val || '';
  79. return gServerUrl + '/' + val.replace(/\\/g, "\/");
  80. }
  81. };
  82. $.views.helpers(myHelpers);
  83. fnGetClassicCase();
  84. };
  85. init();
  86. });