exam_detail_img.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. $(function () {
  2. $("img").lazyload();
  3. const globaldata = {
  4. active: null,
  5. maxlength: null,
  6. };
  7. // 判断试题是否存在;
  8. // let bool = $(".my-nav>ul>li:first-child"), slock = true;
  9. // if (!bool.data("open")) {
  10. // bool.css({ "cursor": "not-allowed" });
  11. // slock = false;
  12. // }
  13. // 实现跳转
  14. let my_nav = $(".my-nav"), top = my_nav.offset().top;
  15. $(".my-nav").click(function (e) {
  16. if (e.target.className == "my-nav") return false;
  17. let active = Array.prototype.slice.call($(this).find("li")).indexOf(e.target), id = null;
  18. // if (active == globaldata.active) return false;
  19. // globaldata.active = active;
  20. // 模板之间跳转逻辑
  21. if (e.target == $(this).find("li.active")[0]) return false;
  22. switch (active) {
  23. case 0:
  24. // if (!slock) break;
  25. id = lxd.parseUrl(window.location.href).pathname.match(/(?<=\/h_exam\/d_).*?(?=.html)/);
  26. window.open(`/h_exam/s_${id}.html`);
  27. break;
  28. case 1:
  29. id = lxd.parseUrl(window.location.href).pathname.match(/(?<=\/h_exam\/s_).*?(?=.html)/);
  30. window.open(`/h_exam/d_${id}.html`);
  31. break;
  32. default:
  33. break;
  34. }
  35. // 模板内部跳转逻辑
  36. // $(this).find(".active").removeClass("active");
  37. // $(e.target).addClass("active");
  38. // // 获取跳转锚点到顶部的距离
  39. // let title = $("#title").offset().top;
  40. // let edi_answer = $("#edi-answer").offset().top;
  41. // let interactive = $("#interactive").offset().top;
  42. // let lis = $(this).find("li");
  43. // let i = Array.prototype.slice.call(lis).indexOf($(e.target)[0]);
  44. // // 储存锚点
  45. // let maos = [title, edi_answer, interactive];
  46. // $(window).scrollTop(maos[i]);
  47. })
  48. $(window).scroll(
  49. function () {
  50. let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
  51. if (scrolltop >= top) { my_nav.addClass("fixed"); } else {
  52. my_nav.removeClass("fixed")
  53. }
  54. }
  55. )
  56. // 查看更多
  57. $("[data-click='open']").click(function () {
  58. let bool = $(this).data("open");
  59. if (!bool) {
  60. $("#toast").show();
  61. // $(this).data("open", true).children("span").text("收起阅读全部").parent().children("i").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up").parent().parent().parent().addClass("edi-body-height");
  62. } else {
  63. $(this).data("open", false).children("span").text("展开阅读全部").parent().children("i").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down").parent().parent().parent().removeClass("edi-body-height");
  64. }
  65. })
  66. // // 不能实现的事件
  67. // function warm () {
  68. // alert("请在大联考App内登录后操作")
  69. // }
  70. // // $(".edi-open>span[data-click='open']").click(warm)
  71. // $(".edi-user").click(warm)
  72. // $(".choose").click(warm)
  73. // 默认 时间
  74. // $(".pull-right>span").click(function () {
  75. // $(this).addClass('active').siblings("span").removeClass("active");
  76. // })
  77. })