فهرست منبع

term 气泡功能加入到所有模块

visuddhinanda 5 سال پیش
والد
کامیت
129929c500
6فایلهای تغییر یافته به همراه50 افزوده شده و 72 حذف شده
  1. 2 0
      app/article/index.php
  2. 5 0
      app/pcdl/html_head.php
  3. 3 0
      app/studio/editor.php
  4. 5 0
      app/studio/index_head.php
  5. 0 69
      app/term/term.js
  6. 35 3
      app/term/term_popup.js

+ 2 - 0
app/article/index.php

@@ -6,7 +6,9 @@ require_once "../pcdl/html_head.php";
 <body style="margin: 0;padding: 0;" class="reader_body" >
 	<script src="../term/term.js"></script>
 	<script src="../term/note.js"></script>
+	<script src="../term/term_popup.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
+	
 	<script src="../channal/channal.js"></script>
 	<script src="./article.js"></script>
 

+ 5 - 0
app/pcdl/html_head.php

@@ -46,6 +46,11 @@ else{
 
 	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>
 	<link type="text/css" rel="stylesheet" href="../public/js/jquery-ui-1.12.1/jquery-ui.css"/>	
+
+	<script src="../term/term.js"></script>
+	<script src="../term/note.js"></script>
+	<script src="../term/term_popup.js"></script>
+	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
 	
 	<script >
 	<?php require_once '../public/load_lang_js.php';?>

+ 3 - 0
app/studio/editor.php

@@ -66,6 +66,9 @@ else{$currDevice="computer";}
 
 	<script src="../term/term.js"></script>
 	<script src="../term/note.js"></script>
+	<script src="../term/term_popup.js"></script>
+	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
+
 	<script src="./js/message.js"></script>
 	<script src="../uwbw/update.js"></script>
 	<script src="../usent/usent.js"></script>

+ 5 - 0
app/studio/index_head.php

@@ -29,6 +29,11 @@ require_once '../public/load_lang.php';
 	<script src="../public/js/jquery-ui-1.12.1/jquery-ui.js"></script>
 	<link type="text/css" rel="stylesheet" href="../public/js/jquery-ui-1.12.1/jquery-ui.css"/>	
 
+	<script src="../term/term.js"></script>
+	<script src="../term/note.js"></script>
+	<script src="../term/term_popup.js"></script>
+	<link type="text/css" rel="stylesheet" href="../term/term.css"/>
+
 	<script type="text/javascript">
 	<?php require_once '../public/load_lang_js.php';//加载js语言包?>
 		

+ 0 - 69
app/term/term.js

@@ -132,38 +132,6 @@ function note_lookup(word, showto) {
   );
 }
 
-function note_lookup_guid_json(guid, showto) {
-  $.get(
-    "../term/term.php",
-    {
-      op: "load_id",
-      id: guid,
-      format: "json",
-    },
-    function (data, status) {
-      let html = "";
-      if (status == "success") {
-        try {
-          let result = JSON.parse(data)[0];
-          html = "<div class='term_block'>";
-
-          html += "<h2>" + result.word + "</h2>";
-          html += "<div class='meaning'>" + result.meaning + "</div>";
-          html +=
-            "<div class='term_note' status='1'>" +
-            note_init(result.note) +
-            "</div>";
-          html += "</div>";
-          $("#" + showto).html(html);
-          note_refresh_new();
-        } catch (e) {
-          console.error("note_lookup_guid_json:" + e + " data:" + data);
-        }
-      }
-    }
-  );
-}
-
 function term_load_preview(guid, showto) {
   $.get(
     "../term/term.php",
@@ -888,40 +856,3 @@ function term_get_dict() {
     }
   );
 }
-
-function term_popup_init() {
-  $(".term_link").each(function () {
-    if ($(this).attr("init") != "1") {
-      if ($(this).text().length > 0) {
-        $(this).css("background", "unset");
-      }
-      let gid = $(this).attr("gid");
-      if ($(this).offset().left < $(document.body).width() / 2) {
-        //出现在左侧
-        $(this).append(
-          '<div id="gid_' +
-            gid +
-            '" class="guide_contence" style="left: -5px;"></div>'
-        );
-        $(".guide_contence:after").css("left", "0");
-      } else {
-        //出现在右侧
-        $(this).append(
-          '<div id="gid_' +
-            gid +
-            '" class="guide_contence" style="right: -5px;"></div>'
-        );
-        $(".guide_contence:after").css("right", "0");
-      }
-      $(this).attr("init", "1");
-    }
-  });
-
-  $(".term_link").mouseenter(function () {
-    if ($(this).children(".guide_contence").first().html().length > 0) {
-      return;
-    }
-    let gid = $(this).attr("gid");
-    term_load_preview(gid, "gid_" + gid);
-  });
-}

+ 35 - 3
app/term/term_popup.js

@@ -8,7 +8,7 @@ function term_popup_init() {
       if ($(this).offset().left < $(document.body).width() / 2) {
         //出现在左侧
         $(this).append(
-          '<div id="gid_' +
+          '<div term-popup="' +
             gid +
             '"  class="guide_contence" style="left: -5px;"></div>'
         );
@@ -16,7 +16,7 @@ function term_popup_init() {
       } else {
         //出现在右侧
         $(this).append(
-          '<div id="gid_' +
+          '<div term-popup="' +
             gid +
             '" class="guide_contence" style="right: -5px;"></div>'
         );
@@ -32,6 +32,38 @@ function term_popup_init() {
     }
     let gid = $(this).attr("gid");
     let id = "gid_" + gid;
-    note_lookup_guid_json(gid, id);
+    note_lookup_guid_json(gid);
   });
 }
+
+function note_lookup_guid_json(guid) {
+  $.get(
+    "../term/term.php",
+    {
+      op: "load_id",
+      id: guid,
+      format: "json",
+    },
+    function (data, status) {
+      let html = "";
+      if (status == "success") {
+        try {
+          let result = JSON.parse(data)[0];
+          html = "<div class='term_block'>";
+
+          html += "<h2>" + result.word + "</h2>";
+          html += "<div class='meaning'>" + result.meaning + "</div>";
+          html +=
+            "<div class='term_note' status='1'>" +
+            note_init(result.note) +
+            "</div>";
+          html += "</div>";
+          $("[term-popup='" + guid + "']").html(html);
+          note_refresh_new();
+        } catch (e) {
+          console.error("note_lookup_guid_json:" + e + " data:" + data);
+        }
+      }
+    }
+  );
+}