exam_detail_img.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. $(function () {
  2. $("img").lazyload();
  3. const globaldata = {
  4. active: null,
  5. maxlength: null,
  6. };
  7. // 实现跳转
  8. let my_nav = $(".my-nav"), top = my_nav.offset().top;
  9. $(".my-nav").click(function (e) {
  10. if (e.target.className == "my-nav") return false;
  11. let active = Array.prototype.slice.call($(this).find("li")).indexOf(e.target);
  12. if (active == globaldata.active) return false;
  13. globaldata.active = active;
  14. $(this).find(".active").removeClass("active");
  15. $(e.target).addClass("active");
  16. // 获取跳转锚点到顶部的距离
  17. let title = $("#title").offset().top;
  18. let edi_answer = $("#edi-answer").offset().top;
  19. let interactive = $("#interactive").offset().top;
  20. let lis = $(this).find("li");
  21. let i = Array.prototype.slice.call(lis).indexOf($(e.target)[0]);
  22. // 储存锚点
  23. let maos = [title, edi_answer, interactive];
  24. $(window).scrollTop(maos[i]);
  25. })
  26. $(window).scroll(
  27. function () {
  28. let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
  29. if (scrolltop >= top) { my_nav.addClass("fixed"); } else {
  30. my_nav.removeClass("fixed")
  31. }
  32. }
  33. )
  34. // 查看更多
  35. $("[data-click='open']").click(function () {
  36. let bool = $(this).data("open");
  37. if (!bool) {
  38. $("#toast").show();
  39. // $(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");
  40. } else {
  41. $(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");
  42. }
  43. })
  44. // // 不能实现的事件
  45. // function warm () {
  46. // alert("请在大联考App内登录后操作")
  47. // }
  48. // // $(".edi-open>span[data-click='open']").click(warm)
  49. // $(".edi-user").click(warm)
  50. // $(".choose").click(warm)
  51. // 默认 时间
  52. // $(".pull-right>span").click(function () {
  53. // $(this).addClass('active').siblings("span").removeClass("active");
  54. // })
  55. })