Browse Source

修改表格兼容和隐藏显示答案

namejr 4 years ago
parent
commit
2a7bfcd3aa
2 changed files with 91 additions and 2 deletions
  1. 7 0
      EBook.Web/Common/tasklib_book.css
  2. 84 2
      EBook.Web/Common/tasklib_book.js

+ 7 - 0
EBook.Web/Common/tasklib_book.css

@@ -2,6 +2,13 @@
 p{word-break: break-word;word-wrap: break-word;clear:both;line-height: 22px;}
 /*作答区域外层*/
 .answer-body {background-color:#eaf6ff;border-radius: 5px;display:inline-block;margin-bottom:-1px;margin-top:8px;}
+.answer-body[answer-showanswer='1']{display:inline;}
+p .answer-body{
+    margin-left:5px;
+}
+p .answer-body:first-child{
+    margin-left:0px;
+}
 .answer-border {border:solid #66b6ff 1px;}
 /*作答音频区域*/
 .answer-audio-range { border-radius: 5px;border:solid #66b6ff 1px;height:20px;background-color:#eaf6ff;display:none;margin-bottom:-6px;}

+ 84 - 2
EBook.Web/Common/tasklib_book.js

@@ -27,11 +27,54 @@ function showHideAnswer(flag) {
         //$(".underlineContent").show();
         $(".underlineContent").css("color", "#92D050");
         $(".yaoshi").attr("src", PicInfo.yaoshiShowImgUrl);
+        $.each($(".underlineContent"), function (index, item) {
+            var underlineContentText = $(this).text();  // 获取文本内容
+            var widthValue = $(item).css("width");
+            var newClsName = $(item).next().attr("class");
+            if (newClsName != "underlineContentShow") {
+                var addHtml = "";
+                if (hasChineseWorld(underlineContentText)) {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                }
+                else {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                }
+                $(item).css("display", "inline-block").after(addHtml);
+            }
+            else {
+                $(item).css("display", "inline-block").next().attr("data-status", "0");
+            }
+            if (underlineContentText.indexOf("√") > -1) {
+                $(this).parent().find(".checkbox").find("input").prop('checked', true);
+            }
+        });
     }
     else {
         //$(".underlineContent").hide();
         $(".underlineContent").css("color", "#ffffff");
         $(".yaoshi").attr("src", PicInfo.yaoshiHideImgUrl);
+        $.each($(".underlineContent,.underlineContent.no-answer"), function (index, item) {
+            var underlineContentText = $(this).text();  // 获取文本内容
+            var widthValue = $(item).css("width");
+            var newClsName = $(item).next().attr("class");
+            if (newClsName != "underlineContentShow") {
+                var addHtml = "";
+                if (hasChineseWorld(underlineContentText)) {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                }
+                else {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                }
+                $(item).css("display", "none").after(addHtml);
+                $(item).next().attr("data-status", "1");
+            }
+            else {
+                $(item).css("display", "none").next().attr("data-status", "1");
+            }
+            if (underlineContentText.indexOf("√") > -1) {
+                $(this).parent().find(".checkbox").find("input").prop('checked', false);
+            }
+        });
     }
 }
 
@@ -46,6 +89,25 @@ function showHideAnswerEx(isShowYX, isShowAS) {
 
     if (isShowAS) {
         $.each($(".underlineContent"), function (index, item) {
+            var underlineContentText = $(this).text();  // 获取文本内容
+            var widthValue = $(item).css("width");
+            var newClsName = $(item).next().attr("class");
+            if (newClsName != "underlineContentShow") {
+                var addHtml = "";
+                if (hasChineseWorld(underlineContentText)) {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                }
+                else {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                }
+                $(item).css("display", "inline-block").after(addHtml);
+            }
+            else {
+                $(item).css("display", "inline-block").next().attr("data-status", "0");
+            }
+            if (underlineContentText.indexOf("√") > -1) {
+                $(this).parent().find(".checkbox").find("input").prop('checked', true);
+            }
             //$(item).html($(item).attr("data-text"));
             if (!$(item).hasClass("no-answer")) {
                 $(item).css("color", "#92D050");
@@ -53,7 +115,6 @@ function showHideAnswerEx(isShowYX, isShowAS) {
             else {
                 $(item).css("color", "#989898");
             }
-
             $(item).find(".wordStyle").css("color", "#db5d00");
             $(item).find(".phraseStyle").css("background-color", "#f2db8b");
         });
@@ -62,6 +123,26 @@ function showHideAnswerEx(isShowYX, isShowAS) {
     }
     else {
         $.each($(".underlineContent,.underlineContent.no-answer"), function (index, item) {
+            var underlineContentText = $(this).text();  // 获取文本内容
+            var widthValue = $(item).css("width");
+            var newClsName = $(item).next().attr("class");
+            if (newClsName != "underlineContentShow") {
+                var addHtml = "";
+                if (hasChineseWorld(underlineContentText)) {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&emsp;</span>";
+                }
+                else {
+                    addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";' data-status='0'>&nbsp;</span>";
+                }
+                $(item).css("display", "none").after(addHtml);
+                $(item).next().attr("data-status", "1");
+            }
+            else {
+                $(item).css("display", "none").next().attr("data-status", "1");
+            }
+            if (underlineContentText.indexOf("√") > -1) {
+                $(this).parent().find(".checkbox").find("input").prop('checked', false);
+            }
             $(item).css("color", "#ffffff");
             $(item).find(".wordStyle").css("color", "#ffffff");
             $(item).find(".phraseStyle").css("background-color", "#ffffff");
@@ -620,7 +701,7 @@ function handleAnswerRange() {
                 break;
             }
         }
-        $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text'></buttom></div>");
+        $(item).prop("outerHTML", "<div class='answer-body' answer-id='" + answerid + "' answer-anstext='" + answerText + "' answer-isky='" + isky + "' answer-showanswer='0'><div class='answer-audio-range'><img src='" + PicInfo.recordPlayImgUrl + "'/><span class='answer-audio-text'>作答音频</span></div><div class='answer-point-range'><img src='" + PicInfo.answerPointImgUrl + "'/><span class='answer-point-text'>答题点</span></div><buttom class='answer-text'></buttom></div>");
         //删除钥匙节点
         var prev = $("img[answer-id='" + answerid + "']");
         if (prev.length > 0) {
@@ -819,6 +900,7 @@ function backupAllAnswer(answerJson, statusType) {
             }
             //已评阅,查看评阅详情
             if (statusType == 2) {
+                $(item).attr("answer-showanswer", "1");  // 修改显示格式
                 //添加音频控制
                 if ((answerList[index].Type == 3 || answerList[index].Type == 4) && answerList[index].AudioUrl != "") {
                     //独立绑定事件