mtm_temp.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*高亮文本标注*/
  2. function Fill(data) {
  3. var highlightArr = [];
  4. clearHighlight();
  5. $.each(data, function (i, item) {
  6. if (typeof (item.HightCode) != 'undefined' && item.HightCode != null && item.HightCode != "") {
  7. var highlightItem = $('span[id=' + item.HightCode + ']').eq(0);
  8. if (highlightItem.length > 0) {
  9. var hitCode = highlightItem.attr('hitCode');
  10. if (hitCode) {
  11. highlightItem.attr('hitCode', hitCode + "|" + item.SourceCode);
  12. }
  13. else {
  14. highlightItem.attr('hitCode', item.SourceCode);
  15. }
  16. highlightArr.push(highlightItem);
  17. }
  18. }
  19. else if (typeof (item.SourceCode) == 'undefined' || item.SourceCode == null || item.SourceCode != "") {
  20. var highlightItem = $('span[kcode*=' + item.SourceCode + ']:first');
  21. if (highlightItem.length > 0) {
  22. var hitCode = highlightItem.attr('hitCode');
  23. if (hitCode) {
  24. highlightItem.attr('hitCode', hitCode + "|" + item.SourceCode);
  25. }
  26. else {
  27. highlightItem.attr('hitCode', item.SourceCode);
  28. }
  29. highlightArr.push(highlightItem);
  30. }
  31. }
  32. $.each(highlightArr, function (i, item) {
  33. if (item.attr('flag') == 'word') {
  34. styleWPSContrl.wordFlag = true;
  35. bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "wordStyle").addClass('wordStyle'), true);
  36. }
  37. else if (item.attr('flag') == 'phrase') {
  38. styleWPSContrl.phraseFlag = true;
  39. if (item != null && item.attr('separate') != null) {
  40. $("span[separate=" + item.attr('separate') + "]").attr('iskeyklg', 'true').attr("hitstyle", "phraseStyle").addClass('phraseStyle');
  41. bindEvent(item, true);
  42. }
  43. else {
  44. bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "phraseStyle").addClass('phraseStyle'), true);
  45. if ($(item).parent().attr('iskeyklg') == 'true' && $(item).parent().attr('flag') == 'phrase') $(item).addClass('border1')
  46. }
  47. }
  48. else if (item.attr('flag') == 'sentence') {
  49. if (item.attr('iskeyklg') == 'true') return;
  50. styleWPSContrl.sentenceFlag = true;
  51. bindEvent(item.attr('iskeyklg', 'true').attr("hitstyle", "sentenceStyle").addClass('sentenceStyle')
  52. .before('<img src="file:///android_asset/js/sentenceIco.png" class="sentImagcs">'), true);
  53. }
  54. });
  55. });
  56. // 绑定横线内处理
  57. if (typeof (addFillAssist) == "function") {
  58. addFillAssist();
  59. }
  60. }
  61. function clearHighlight() {
  62. $('span.klg-selected').removeClass('klg-selected');
  63. $('span[iskeyklg="true"]').each(function (i, item) {
  64. $(item).removeAttr('hitCode');
  65. $(item).attr('iskeyklg', 'false');
  66. if ($(item).attr('flag') == 'word') {
  67. $(item).removeClass('wordStyle').unbind();
  68. }
  69. else if ($(item).attr('flag') == 'phrase') {
  70. $(item).removeClass().unbind();
  71. }
  72. else if ($(item).attr('flag') == 'sentence') {
  73. $(item).removeClass('sentenceStyle').unbind();
  74. $(item).prev().filter('img.sentImagcs').remove();
  75. }
  76. })
  77. }
  78. function bindEvent(ele, opt) {
  79. if (opt) {
  80. var className = '';
  81. if (ele.hasClass('phraseStyle'))
  82. className = 'phraseStyle';
  83. else if (ele.hasClass('wordStyle'))
  84. className = 'wordStyle';
  85. else if (ele.hasClass('sentenceStyle'))
  86. className = 'sentenceStyle';
  87. switch (className) {
  88. case 'phraseStyle':
  89. if (ele.attr('separate') != null) {
  90. $("span[separate=" + ele.attr('separate') + "]").unbind().bind({
  91. 'click': function (e) {
  92. e.stopPropagation();
  93. //plugin.call(code);
  94. //alert($(this).attr("hitCode"));
  95. var sHCode = $(this).attr("shcode");
  96. if (sHCode == 1) {
  97. test($(this).attr("hitCode"));
  98. }
  99. }
  100. });
  101. }
  102. case 'wordStyle':
  103. ele.unbind().bind({
  104. 'click': function (e) {
  105. e.stopPropagation();
  106. //plugin.call(code);
  107. //alert($(this).attr("hitCode"));
  108. var sHCode = $(this).attr("shcode");
  109. if (sHCode == 1) {
  110. test($(this).attr("hitCode"));
  111. }
  112. }
  113. });
  114. break;
  115. case 'sentenceStyle':
  116. ele.unbind().bind({
  117. 'click': function (e) {
  118. e.stopPropagation();
  119. //plugin.call(code);
  120. //alert($(this).attr("hitCode"));
  121. var sHCode = $(this).attr("shcode");
  122. if (sHCode == 1) {
  123. test($(this).attr("hitCode"));
  124. }
  125. }
  126. }).prev().filter('.sentImagcs').unbind().bind({
  127. 'click': function (e) {
  128. e.stopPropagation();
  129. //plugin.call(code);
  130. //alert($(this).attr("hitCode"));
  131. var sHCode = $(this).attr("shcode");
  132. if (sHCode == 1) {
  133. test($(this).next().attr("hitCode"));
  134. }
  135. }
  136. });
  137. break;
  138. }
  139. }
  140. else {
  141. ele.unbind();
  142. }
  143. }
  144. function test(code) {
  145. //alert(code);
  146. cancelBubble();
  147. plugin.call(code);
  148. }