popup_note.js 979 B

1234567891011121314151617181920212223242526272829
  1. function popup_init() {
  2. $("code:not([class])").each(function () {
  3. if ($(this).attr("init") != "1") {
  4. if ($(this).text().length == 0) {
  5. return;
  6. }
  7. const noteText = $(this).html();
  8. $(this).html("");
  9. if ($(this).offset().left < $(document.body).width() / 2) {
  10. $(this).append('<div class="popup_contence" style="left: -15px;">' + marked(noteText) + "</div>");
  11. $(".popup_contence:after").css("left", "0");
  12. } else {
  13. $(this).append('<div class="popup_contence" style="right: -15px;">' + marked(noteText) + "</div>");
  14. $(".popup_contence:after").css("right", "0");
  15. }
  16. $(this).attr("init", "1");
  17. }
  18. });
  19. $("code").mouseenter(function (event) {
  20. let mouse_x=event.clientX - 20
  21. let mouse_y=event.clientY
  22. $(this).children(".popup_contence").first().css("left",mouse_x+"px")
  23. $(this).children(".popup_contence").first().css("top",mouse_y+"px")
  24. if ($(this).children(".popup_contence").first().html().length > 0) {
  25. return;
  26. }
  27. });
  28. }