Quellcode durchsuchen

Merge pull request #789 from visuddhinanda/nissaya-channel

:bug: on click多次绑定导致义注反复伸缩
visuddhinanda vor 4 Jahren
Ursprung
Commit
b7c14f3812
2 geänderte Dateien mit 34 neuen und 16 gelöschten Zeilen
  1. 28 13
      public/app/term/note.js
  2. 6 3
      public/app/term/term.css

+ 28 - 13
public/app/term/note.js

@@ -212,7 +212,8 @@ function note_refresh_new(callback = null) {
 						splite_pali_word();
 						splite_pali_word();
 						//处理编辑框消息
 						//处理编辑框消息
 						tran_sent_textarea_event_init();
 						tran_sent_textarea_event_init();
-
+                        //处理鼠标移入显示菜单消息
+                        setSentToolBarEvent();
 						//初始化mermaid
 						//初始化mermaid
 						mermaid.initialize({startOnLoad:true});
 						mermaid.initialize({startOnLoad:true});
 
 
@@ -1008,6 +1009,7 @@ function render_one_sent_tran_a(iterator, diff = false) {
 
 
 	let html = "";
 	let html = "";
 	html += "<div class='sent_tran ";
 	html += "<div class='sent_tran ";
+    html += iterator.channalinfo.type;
 	if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
 	if (typeof iterator.is_pr != "undefined" && iterator.is_pr == true) {
 		html += " pr ";
 		html += " pr ";
 	}
 	}
@@ -1658,8 +1660,8 @@ function set_more_button_display() {
         {
         {
 			$(this).find(".other_tran_num").html(count);
 			$(this).find(".other_tran_num").html(count);
 			$(this).find(".other_tran_num").attr("style", "display:inline-flex;");
 			$(this).find(".other_tran_num").attr("style", "display:inline-flex;");
-			$(this)
-				.click(function () {
+			$(this).off('click')
+				.on('click',function () {
 					const sentid = $(this).attr("sent").split("-");
 					const sentid = $(this).attr("sent").split("-");
 		            const channelType = $(this).attr("channel_type");
 		            const channelType = $(this).attr("channel_type");
 					const book = sentid[0];
 					const book = sentid[0];
@@ -1669,7 +1671,7 @@ function set_more_button_display() {
 					let sentId = $(this).attr("sent");
 					let sentId = $(this).attr("sent");
                     let otherSentDiv = $(this).parent().parent().siblings(".other_tran").first();
                     let otherSentDiv = $(this).parent().parent().siblings(".other_tran").first();
 					if (otherSentDiv.css("display") == "none") {
 					if (otherSentDiv.css("display") == "none") {
-						otherSentDiv.show();
+						otherSentDiv.slideDown();
                         //加号复位
                         //加号复位
 						//$(this).siblings(".more_tran ").css("transform", "unset");
 						//$(this).siblings(".more_tran ").css("transform", "unset");
 						$.get(
 						$.get(
@@ -1711,20 +1713,19 @@ function set_more_button_display() {
 								html += "</div>";
 								html += "</div>";
 								otherSentDiv.html(html);
 								otherSentDiv.html(html);
                                 if(channelType==='commentary'){
                                 if(channelType==='commentary'){
-                                    note_refresh_new(function(){
-                                        otherSentDiv.show();
-                                    });
+                                    note_refresh_new();
                                 }
                                 }
-                                //不知道为什么加上note_refresh_new后div下拉后会收回。所以加了这个弥补。但是视觉效果不好。数据加载后收回,然后再弹出。
-                                otherSentDiv.show();
+
 								//初始化文本编辑框消息处理
 								//初始化文本编辑框消息处理
 								tran_sent_textarea_event_init();
 								tran_sent_textarea_event_init();
 							}
 							}
 						);
 						);
 					} else {
 					} else {
-						otherSentDiv.hide();
+						otherSentDiv.slideUp();
 						$(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
 						$(this).siblings(".more_tran ").css("transform", "rotate(-90deg)");
 					}
 					}
+
+                    return false;    //  阻止事件冒泡
 				});
 				});
 		}else 
 		}else 
         {
         {
@@ -1782,7 +1783,8 @@ function tran_sent_edit_cancel(obj) {
 function tran_sent_save(obj) {
 function tran_sent_save(obj) {
 	let sentDiv = find_sent_tran_div(obj);
 	let sentDiv = find_sent_tran_div(obj);
 	if (sentDiv) {
 	if (sentDiv) {
-		let textarea = $(sentDiv).children().find(".tran_sent_textarea").first();
+		let textarea = $(sentDiv).children('.sent_tran_inner').first().children('.body').first().children('.edit').find(".tran_sent_textarea").first();
+		//let textarea = $(sentDiv).children().find(".tran_sent_textarea").first();
 		let isPr = $(textarea).attr("is_pr");
 		let isPr = $(textarea).attr("is_pr");
 		if (isPr == "true") {
 		if (isPr == "true") {
 			note_pr_save(textarea);
 			note_pr_save(textarea);
@@ -1935,7 +1937,12 @@ function sent_save_callback(data) {
                         case 'nissaya':
                         case 'nissaya':
                             divPreview.html(renderNissayaPreview(result.text));
                             divPreview.html(renderNissayaPreview(result.text));
                             break;
                             break;
-                    
+                        case 'commentary':
+                            divPreview.html(
+                                note_init(result.text, result.channal, result.editor, result.lang)
+                            );
+                            note_refresh_new();
+                        break;
                         default:
                         default:
                             divPreview.html(
                             divPreview.html(
                                 marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
                                 marked(term_std_str_to_tran(result.text, result.channal, result.editor, result.lang))
@@ -1943,7 +1950,6 @@ function sent_save_callback(data) {
                             term_updata_translation();                        
                             term_updata_translation();                        
                             break;
                             break;
                     }
                     }
-
 					popup_init();
 					popup_init();
 				}
 				}
 			}
 			}
@@ -2550,3 +2556,12 @@ function term_parent(paliword) {
 	}
 	}
 	return output;
 	return output;
 }
 }
+
+function setSentToolBarEvent(){
+    $('.sent_tran_inner').off('mouseenter').on('mouseenter',function(){
+        $(this).children('.tool_bar').first().children('.right').show();
+    });
+    $('.sent_tran_inner').off('mouseleave').on('mouseleave',function(){
+        $(this).children('.tool_bar').first().children('.right').hide();
+    })
+}

+ 6 - 3
public/app/term/term.css

@@ -728,15 +728,18 @@ pw {
 	/*margin-right: 20px;*/
 	/*margin-right: 20px;*/
 }
 }
 .commentary .tool_bar > .right{
 .commentary .tool_bar > .right{
-    left: 8em;
+    /*left: 8em;*/
     width: 8em;
     width: 8em;
 }
 }
+.translation>.sent_tran_inner>.tool_bar > .right{
+    right: 2em;
+}
 
 
 .sent_tran_inner:hover .tool_bar > .right {
 .sent_tran_inner:hover .tool_bar > .right {
-	display: block;
+	/*display: block;*/
 }
 }
 .list_with_head:hover .tool_bar > .right {
 .list_with_head:hover .tool_bar > .right {
-	display: block;
+	/*display: block;*/
 }
 }
 .list_with_head {
 .list_with_head {
 	position: relative;
 	position: relative;