Difference between revisions of "Template:CPU CHINA/common JS"

Line 14: Line 14:
 
     ifon: true, //离开是否会关闭按钮
 
     ifon: true, //离开是否会关闭按钮
 
     // 一级菜单列表
 
     // 一级菜单列表
     classList: [
+
     classList: ["Project", "Parts", "Model", "Human Practices", "Team"],
      "Project",
+
      "Parts",
+
      "WetLab",
+
      "DryLab",
+
      "Human Practises",
+
      "Team",
+
    ],
+
 
     // 二级菜单刘表
 
     // 二级菜单刘表
 
     classList2: [
 
     classList2: [
 
       [
 
       [
 
         {
 
         {
           text: "Background",
+
           text: "Description",
 
           url: "",
 
           url: "",
 
           num: 0,
 
           num: 0,
 
         },
 
         },
 
         {
 
         {
           text: "Description",
+
           text: "Design",
 
           url: "",
 
           url: "",
 
           num: 1,
 
           num: 1,
 
         },
 
         },
 
         {
 
         {
           text: "Design",
+
           text: "Proof of Concept",
 
           url: "",
 
           url: "",
 
           num: 2,
 
           num: 2,
 
         },
 
         },
 
         {
 
         {
           text: "Implemention",
+
           text: "Proposed Implementation",
 
           url: "",
 
           url: "",
 
           num: 3,
 
           num: 3,
Line 50: Line 43:
 
           num: 4,
 
           num: 4,
 
         },
 
         },
      ],
 
      [
 
 
         {
 
         {
           text: "parts Overview",
+
           text: "Lab",
 
           url: "",
 
           url: "",
           num: 0,
+
           num: 5,
 +
        },
 +
        {
 +
          text: "General Safety",
 +
          url: "",
 +
          num: 6,
 
         },
 
         },
 
       ],
 
       ],
 
       [
 
       [
 
         {
 
         {
           text: "Experiments",
+
           text: "Parts Overview",
 
           url: "",
 
           url: "",
 
           num: 0,
 
           num: 0,
 
         },
 
         },
 
         {
 
         {
           text: "Results",
+
           text: "Contributions",
 
           url: "",
 
           url: "",
 
           num: 1,
 
           num: 1,
 
         },
 
         },
 
         {
 
         {
           text: "Safety",
+
           text: "Engineering Success",
 
           url: "",
 
           url: "",
 
           num: 2,
 
           num: 2,
 
         },
 
         },
 
         {
 
         {
           text: "Contribution",
+
           text: "Improvement",
 
           url: "",
 
           url: "",
 
           num: 3,
 
           num: 3,
Line 82: Line 78:
 
       [
 
       [
 
         {
 
         {
           text: "Model",
+
           text: "Summary",
 
           url: "",
 
           url: "",
 
           num: 0,
 
           num: 0,
 
         },
 
         },
 
         {
 
         {
           text: "Mathematical Modeling",
+
           text: "🍄Mathematical Modeling",
 
           url: "",
 
           url: "",
 
           num: 1,
 
           num: 1,
 
         },
 
         },
 
         {
 
         {
           text: "Molecular Modeling",
+
           text: "🌿Molecular Modeling",
 
           url: "",
 
           url: "",
 
           num: 2,
 
           num: 2,
        },
 
        {
 
          text: "Measurment",
 
          url: "",
 
          num: 3,
 
 
         },
 
         },
 
       ],
 
       ],
 
       [
 
       [
 
         {
 
         {
           text: "Integrated Human Practise",
+
           text: "Summary",
 
           url: "",
 
           url: "",
 
           num: 0,
 
           num: 0,
 
         },
 
         },
 
         {
 
         {
           text: "Education and Public Engament",
+
           text: "Integrated Human Practices",
 
           url: "",
 
           url: "",
 
           num: 1,
 
           num: 1,
 
         },
 
         },
 
         {
 
         {
           text: "Plasticase",
+
           text: "Education and Public Engagement",
 
           url: "",
 
           url: "",
 
           num: 2,
 
           num: 2,
        },
 
        {
 
          text: "Meddy:Relight My Star",
 
          url: "",
 
          num: 3,
 
 
         },
 
         },
 
       ],
 
       ],
Line 136: Line 122:
 
         },
 
         },
 
         {
 
         {
           text: "Partnership",
+
           text: "Collaboration",
 
           url: "",
 
           url: "",
 
           num: 2,
 
           num: 2,
 
         },
 
         },
 
         {
 
         {
           text: "Collabration",
+
           text: "Cartnership",
 
           url: "",
 
           url: "",
 
           num: 3,
 
           num: 3,
Line 196: Line 182:
 
     // 鼠标离开菜单
 
     // 鼠标离开菜单
 
     leave() {
 
     leave() {
    //  setTimeout(() => {
+
      setTimeout(() => {
    //    if (this.clickon) {
+
        if (this.clickon) {
    //      this.ifon = true;
+
          this.ifon = true;
    //      if (this.ifon && this.open) {
+
          if (this.ifon && this.open) {
    //        this.close();
+
            this.close();
    //      } else {
+
          } else {
    //        return;
+
            return;
    //      }
+
          }
    //    }
+
        }
    //  }, 3000);
+
      }, 3000);
 
       this.clickon = true;
 
       this.clickon = true;
 
     },
 
     },

Revision as of 12:50, 12 September 2021

// 菜单页 var header = new Vue({

 el: "#header",
 data: {
   menu: "T--CPU_CHINA--face.png", //菜单按钮
   isOpen: false, //背景变化
   classA: false, //一级菜单是否打开
   classB: false, //二级菜单是否打开
   isActive: "", //背景变色
   isActiveA: -1, //一级菜单悬停效果
   isActiveB: -1, //二级菜单悬停效果
   open: false, //菜单是否是打开状态
   clickon: true, //鼠标是否位于菜单上
   ifon: true, //离开是否会关闭按钮
   // 一级菜单列表
   classList: ["Project", "Parts", "Model", "Human Practices", "Team"],
   // 二级菜单刘表
   classList2: [
     [
       {
         text: "Description",
         url: "",
         num: 0,
       },
       {
         text: "Design",
         url: "",
         num: 1,
       },
       {
         text: "Proof of Concept",
         url: "",
         num: 2,
       },
       {
         text: "Proposed Implementation",
         url: "",
         num: 3,
       },
       {
         text: "Art Design",
         url: "",
         num: 4,
       },
       {
         text: "Lab",
         url: "",
         num: 5,
       },
       {
         text: "General Safety",
         url: "",
         num: 6,
       },
     ],
     [
       {
         text: "Parts Overview",
         url: "",
         num: 0,
       },
       {
         text: "Contributions",
         url: "",
         num: 1,
       },
       {
         text: "Engineering Success",
         url: "",
         num: 2,
       },
       {
         text: "Improvement",
         url: "",
         num: 3,
       },
     ],
     [
       {
         text: "Summary",
         url: "",
         num: 0,
       },
       {
         text: "🍄Mathematical Modeling",
         url: "",
         num: 1,
       },
       {
         text: "🌿Molecular Modeling",
         url: "",
         num: 2,
       },
     ],
     [
       {
         text: "Summary",
         url: "",
         num: 0,
       },
       {
         text: "Integrated Human Practices",
         url: "",
         num: 1,
       },
       {
         text: "Education and Public Engagement",
         url: "",
         num: 2,
       },
     ],
     [
       {
         text: "Members",
         url: "https://2021.igem.org/Team:CPU_CHINA/Team/Members",
         num: 0,
       },
       {
         text: "Attributions",
         url: "",
         num: 1,
       },
       {
         text: "Collaboration",
         url: "",
         num: 2,
       },
       {
         text: "Cartnership",
         url: "",
         num: 3,
       },
     ],
   ],
 },
 methods: {
   // 鼠标悬停到菜单按钮上
   mouseover() {
     if (!this.open) {
       this.menu =
         "T--CPU_CHINA--zheng.gif";
       this.isOpen = true;
       this.isActive = "menu";
       setTimeout(() => {
         this.open = true;
         this.classA = true;
         this.menu =
           "T--CPU_CHINA--.png";
       }, 1100);
     }
   },
   // 关闭菜单
   close() {
     if (this.open) {
       this.menu =
         "T--CPU_CHINA--fan.gif";
       this.isActive = "";
       this.open = false;
       this.classB = false;
       this.classA = false;
       this.isActiveA = -1;
       setTimeout(() => {
         this.isOpen = false;
         this.menu =
           "T--CPU_CHINA--face.png";
       }, 1100);
     }
   },
   // 点击菜单按钮
   click() {
     if (this.open) {
       this.close();
     } else {
       this.mouseover();
     }
   },
   // 鼠标移动到菜单上
   on() {
     this.clickon = false;
     this.ifon = false;
   },
   // 鼠标离开菜单
   leave() {
     setTimeout(() => {
       if (this.clickon) {
         this.ifon = true;
         if (this.ifon && this.open) {
           this.close();
         } else {
           return;
         }
       }
     }, 3000);
     this.clickon = true;
   },
   // 鼠标点击空白关闭菜单
   ifclick() {
     if (this.clickon && this.open) {
       this.close();
     } else {
       return;
     }
   },
   // 鼠标点击一级菜单
   classAClick(index) {
     this.isActiveB = -1;
     this.isActiveA = index;
     this.classB = true;
   },
   // 鼠标悬停到二级菜单
   classBOver(num) {
     setTimeout(() => {
       this.isActiveB = num;
     }, 300);
   },
   // 鼠标离开二级菜单
   classBLeave(num) {
     setTimeout(() => {
       this.isActiveB = -1;
     }, 300);
   },
 },

});

// 页面滚动响应 var $navs = $("nav li"), // 导航

 $sections = $(".section"), // 模块
 $window = $(window),
 navLength = $navs.length - 1;

$window.scroll(function () {

 var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
 len = navLength;
 for (; len > -1; len--) {
   var that = $sections.eq(len);
   if (scrollTop >= that.offset().top - 10) {
     $navs.removeClass("current").eq(len).addClass("current");
     break;
   }
 }

});

$navs.on("click", function (e) {

 e.preventDefault();
 $("html, body").animate(
   {
     scrollTop: $($(this).find("a").attr("href")).offset().top,
   },
   400
 );

});