1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- $(function () {
- $("img").lazyload();
- const globaldata = {
- active: null,
- maxlength: null,
- };
- // 判断试题是否存在;
- // let bool = $(".my-nav>ul>li:first-child"), slock = true;
- // if (!bool.data("open")) {
- // bool.css({ "cursor": "not-allowed" });
- // slock = false;
- // }
- // 实现跳转
- let my_nav = $(".my-nav"), top = my_nav.offset().top;
- $(".my-nav").click(function (e) {
- if (e.target.className == "my-nav") return false;
- let active = Array.prototype.slice.call($(this).find("li")).indexOf(e.target), id = null;
- // if (active == globaldata.active) return false;
- // globaldata.active = active;
- // 模板之间跳转逻辑
- if (e.target == $(this).find("li.active")[0]) return false;
- switch (active) {
- case 0:
- // if (!slock) break;
- id = lxd.parseUrl(window.location.href).pathname.match(/(?<=\/h_exam\/d_).*?(?=.html)/);
- window.open(`/h_exam/s_${id}.html`);
- break;
- case 1:
- id = lxd.parseUrl(window.location.href).pathname.match(/(?<=\/h_exam\/s_).*?(?=.html)/);
- window.open(`/h_exam/d_${id}.html`);
- break;
- default:
- break;
- }
- // 模板内部跳转逻辑
- // $(this).find(".active").removeClass("active");
- // $(e.target).addClass("active");
- // // 获取跳转锚点到顶部的距离
- // let title = $("#title").offset().top;
- // let edi_answer = $("#edi-answer").offset().top;
- // let interactive = $("#interactive").offset().top;
- // let lis = $(this).find("li");
- // let i = Array.prototype.slice.call(lis).indexOf($(e.target)[0]);
- // // 储存锚点
- // let maos = [title, edi_answer, interactive];
- // $(window).scrollTop(maos[i]);
- })
- $(window).scroll(
- function () {
- let scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
- if (scrolltop >= top) { my_nav.addClass("fixed"); } else {
- my_nav.removeClass("fixed")
- }
- }
- )
- // 查看更多
- $("[data-click='open']").click(function () {
- let bool = $(this).data("open");
- if (!bool) {
- $("#toast").show();
- // $(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");
- } else {
- $(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");
- }
- })
- // // 不能实现的事件
- // function warm () {
- // alert("请在大联考App内登录后操作")
- // }
- // // $(".edi-open>span[data-click='open']").click(warm)
- // $(".edi-user").click(warm)
- // $(".choose").click(warm)
- // 默认 时间
- // $(".pull-right>span").click(function () {
- // $(this).addClass('active').siblings("span").removeClass("active");
- // })
- })
|