浏览代码

合并新代码,修改选取内容问题

lujianhong 4 年之前
父节点
当前提交
8ec8fec91d
共有 3 个文件被更改,包括 49 次插入66 次删除
  1. 16 4
      EBook.Web/Common/mtm_temp.js
  2. 3 8
      EBook.Web/Common/tasklib_book.css
  3. 30 54
      EBook.Web/Common/tasklib_book.js

+ 16 - 4
EBook.Web/Common/mtm_temp.js

@@ -93,7 +93,10 @@ function bindEvent(ele, opt) {
                             e.stopPropagation();
                             //plugin.call(code);
                             //alert($(this).attr("hitCode"));
-                            test($(this).attr("hitCode"));
+                            var sHCode = $(this).attr("shcode");
+                            if (sHCode != 1) {
+                                test($(this).attr("hitCode"));
+                            }
                         }
                     });
                 }
@@ -103,7 +106,10 @@ function bindEvent(ele, opt) {
                         e.stopPropagation();
                         //plugin.call(code);
                         //alert($(this).attr("hitCode"));
-                        test($(this).attr("hitCode"));
+                        var sHCode = $(this).attr("shcode");
+                        if (sHCode != 1) {
+                            test($(this).attr("hitCode"));
+                        }
                     }
                 });
                 break;
@@ -113,14 +119,20 @@ function bindEvent(ele, opt) {
                         e.stopPropagation();
                         //plugin.call(code);
                         //alert($(this).attr("hitCode"));
-                        test($(this).attr("hitCode"));
+                        var sHCode = $(this).attr("shcode");
+                        if (sHCode != 1) {
+                            test($(this).attr("hitCode"));
+                        }
                     }
                 }).prev().filter('.sentImagcs').unbind().bind({
                     'click': function (e) {
                         e.stopPropagation();
                         //plugin.call(code);
                         //alert($(this).attr("hitCode"));
-                        test($(this).next().attr("hitCode"));
+                        var sHCode = $(this).attr("shcode");
+                        if (sHCode != 1) {
+                            test($(this).next().attr("hitCode"));
+                        }
                     }
                 });
                 break;

+ 3 - 8
EBook.Web/Common/tasklib_book.css

@@ -71,14 +71,9 @@ p .answer-body:first-child{
     height: auto;
 }
 .underlineContent{
-    display:inline-block;
-}
-.underlineContentShow{
-    display:none;
-}
-.underlineContentShow[data-status='1']{
-    display:inline-block;
-    border-bottom:1px solid rgb(151, 151, 151);
+    user-select:none;
+    display:inline;
+    line-height: 35px;
 }
 .TableContainer{
     width: 100px;

+ 30 - 54
EBook.Web/Common/tasklib_book.js

@@ -26,6 +26,7 @@ var styleWPSContrl = {
     phraseFlag: true,
     sentenceFlag: true
 }
+
 // 表格处理Start
 var pressTableFlag = false;
 var GetPadVal = function () {
@@ -127,13 +128,13 @@ var AdjustTableFunc = function () {
                         RuleFlag = false;
                 }
                     ArrMaxLen.push(0);
-            }
+                }
                 if (ArrMaxLen[tdIndex] < tdWidthVal) {
                     TotalMaxLen += tdWidthVal - ArrMaxLen[tdIndex];
                     ArrMaxLen[tdIndex] = tdWidthVal;
-            }
+                }
+            });
         });
-    });
         // 判断表格是否只有一行
         if ($(item).find("tr").length == 1 && $(item).find("tr").eq(0).find("td").length == 1) {
             $(item).find("tr").eq(0).find("td").eq(0).css("width", (ScreenWidth - 4 - GetPadVal()) + "px");
@@ -145,8 +146,8 @@ var AdjustTableFunc = function () {
                 AddPx = AddPx > 2 ? AddPx - 2 : AddPx;
                 for (var i = 0; i < ArrMaxLen.length; i++) {
                     ArrMaxLen[i] += AddPx;
+                }
             }
-        }
             var OneFlag = false;
             for (var i = 0; i < ArrMaxLen.length; i++) {
                 if (ArrMaxLen[i] != undefined && $(item).find("tr").eq(0).find("td").length > 1 && RuleFlag) {
@@ -161,18 +162,18 @@ var AdjustTableFunc = function () {
                 }
                     $.each($(item).find("tr").eq(0).find("td"), function (tdIndex, tdItem) {
                         $(tdItem).css("width", NotRuleWidth + "px");
-                });
+                    });
                 }
                 else if (ArrMaxLen[i] != undefined && $(item).find("tr").eq(0).find("td").length == 1) {
                     OneFlag = true;
                     TableWidth += ArrMaxLen[i];
+                }
             }
-        }
             if (OneFlag) {
                 $(item).find("tr").eq(0).find("td").eq(0).css("width", TableWidth + "px");
-        }
+            }
             $(item).css("width", TableWidth + "px");
-    }
+        }
         // 替换HTML
         var ChildHtmlStr = $(item).prop("outerHTML");
         var HtmlStr = "<div class='TableContainer TContain_" + Index + "'></div>";
@@ -181,7 +182,7 @@ var AdjustTableFunc = function () {
         var JqStr = ".TContain_" + Index;
         $(JqStr).append(ChildHtmlStr);
         Index += 1;
-});
+    });
     $(document.body).css("width", ScreenWidth + "px");
     var BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width()) - GetPadVal());  // 界面宽度
     var Index = 0;
@@ -198,12 +199,12 @@ var AdjustTableFunc = function () {
             var HiddenWidth = BodyWidth - (TableWidth - BodyWidth) * HiddenRate;  // 现滚动条大小
             var CSHtmlStr = "<div class='CSBar' style='width: " + HiddenWidth + "px;'></div>";
             $(JqStr).next().append(CSHtmlStr);
-    }
+        }
         Index += 1;
-});
+    });
     $.each($(".container-table"), function (index, item) {
         $(item).css("width", BodyWidth + "px");
-});
+    });
     // 滚动条事件
     $(".TableContainer").on("touchstart", function () {
         pressTableFlag = true;
@@ -216,13 +217,13 @@ var AdjustTableFunc = function () {
         var NextClsName = $(this).next().attr("class");
         if (NextClsName == "PSBar") {
             $(this).next().find(".CSBar").css("left", SLeftWdith + "px");
-    }
-});
+        }
+    });
     window.addEventListener("scroll", function (event) {
         var ClsName = event.target.className;
         if (ClsName == undefined) {
             return;
-    }
+        }
         ClsName = ClsName.replace("TableContainer ", ".");
         var TableWidth = isNaN(parseFloat($(ClsName).find("table").width())) ? 0 : parseFloat($(ClsName).find("table").width());  // 表格宽度
         BodyWidth = isNaN(parseFloat($(document).width())) ? 0 : (parseFloat($(document).width() - GetPadVal()));  // 界面宽度
@@ -232,7 +233,7 @@ var AdjustTableFunc = function () {
         var NextClsName = $(ClsName).next().attr("class");
         if (NextClsName == "PSBar") {
             $(ClsName).next().find(".CSBar").css("left", SLeftWdith + "px");
-    }
+        }
     }, true);
     $("#pContrainId").remove();
 };
@@ -253,6 +254,7 @@ var isGCFunc = function (NodeHandle) {
     }
     return isFlag;
 };
+
 // 处理高亮
 var dealGLShowFunc = function (NodeHandle) {
     if (styleWPSContrl.wordFlag) {
@@ -281,40 +283,23 @@ var dealGLShowFunc = function (NodeHandle) {
         $(NodeHandle).find(".sentenceStyle").css("border-bottom", "2px solid #fff");
     }
 };
+
 // 处理显示或隐藏答案
 var dealAnswerFunc = function (NodeHandle, OCFlag) {
-    var FontSizeValue = $(NodeHandle).css("font-size");
-    var underlineContentText = $(NodeHandle).text();  // 获取文本内容
-    var widthValue = $(NodeHandle).css("width");
-    var newClsName = $(NodeHandle).next().attr("class");
-    if (newClsName != "underlineContentShow") {
-        var addHtml = "";
-        if (hasChineseWorld(underlineContentText)) {
-            addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";font-size:" + FontSizeValue + ";line-height:" + FontSizeValue + ";height:" + FontSizeValue + ";' data-status='0'>&emsp;</span>";
-        }
-        else {
-            addHtml = "<span class='underlineContentShow' style='width:" + widthValue + ";font-size:" + FontSizeValue + ";line-height:" + FontSizeValue + ";height:" + FontSizeValue + ";' data-status='0'>&nbsp;</span>";
-        }
-        if (OCFlag) {
-            $(NodeHandle).css("display", "inline-block").after(addHtml);
-            // 处理高亮
-            dealGLShowFunc(NodeHandle);
-        }
-        else {
-            $(NodeHandle).css("display", "none").after(addHtml);
-            $(NodeHandle).next().attr("data-status", "1");
-        }
+    if (OCFlag) {
+        $(NodeHandle).css("color", "#92D050").css("border-bottom", "1px solid #979797").css("background-color", "transparent").attr("shcode","0");
+        $(NodeHandle).children().css("color", "#92D050").css("border-bottom", "1px solid #979797").css("background-color", "transparent").attr("shcode", "0");
+        // 处理高亮
+        dealGLShowFunc(NodeHandle);
     }
     else {
-        if (OCFlag) {
-            $(NodeHandle).css("display", "inline-block").next().attr("data-status", "0");
-            // 处理高亮
-            dealGLShowFunc(NodeHandle);
-        }
-        else {
-            $(NodeHandle).css("display", "none").next().attr("data-status", "1");
-        }
+        $(NodeHandle).css("color", "#fff").css("border-bottom", "1px solid #979797").css("background-color", "#fff").attr("shcode", "1");
+        $(NodeHandle).children().css("color", "#fff").css("border-bottom", "1px solid #979797").css("background-color", "#fff").attr("shcode", "1");
+        $(NodeHandle).find(".wordStyle").css("color", "#fff").css("border-bottom", "1px solid #979797").css("background-color", "#fff").attr("shcode", "1");
+        $(NodeHandle).find(".sentenceStyle").css("color", "#fff").css("border-bottom", "1px solid #979797").css("background-color", "#fff").attr("shcode", "1");
+        $(NodeHandle).find(".phraseStyle").css("color", "#fff").css("border-bottom", "1px solid #979797").css("background-color", "#fff").attr("shcode", "1");
     }
+    var underlineContentText = $(NodeHandle).text();  // 获取文本内容
     if (underlineContentText.indexOf("√") > -1) {
         if (OCFlag) {
             $(NodeHandle).parent().find(".checkbox").find("input").prop('checked', true);
@@ -646,15 +631,6 @@ function getPressFlag() {
 function resetPressFlag() {
     pressTableFlag = false;
 }
-// 判断是否存在中文(true表示存在)
-var hasChineseWorld = function (dataStr) {
-    if (escape(dataStr).indexOf("%u") < 0) {
-        return false;
-    }
-    else {
-        return true;
-    }
-};
 //学生端 处理作答区域
 var answerData = new Array();
 function handleAnswerRange() {