123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- UE.plugins["appendbase"] = function() {
- let me = this;
- me.commands["appendbase"] = {
- execCommand: function(cmd,text) {
- let range = me.selection.getRange();
-
- let startNode = range.startContainer;
- let endNode = range.endContainer;
- let startA = UE.dom.domUtils.findParentByTagName(startNode, "a", true);
- let endA = UE.dom.domUtils.findParentByTagName(endNode, "a", true);
- if(!startA || startA.getAttribute("class").indexOf("input") == -1){
- return false;
- }
- if(!endA || endA.getAttribute("class").indexOf("input") == -1){
- return false;
- }
-
- if(startA == endA){
- let dataType = startA.getAttribute("dataType");
-
- if(dataType == "02"){
-
-
- let value = startA.innerHTML;
- let newValue = value.substring(0, range.startOffset) + text + value.substring(range.endOffset, value.length);
- startA.innerHTML = newValue;
- } else if(dataType == "03"){
- let textarea = $(startA).find("textarea");
- textarea.insertAtCaret(text);
- }
- }
- }
- }
- };
- UE.plugins["amendment"] = function() {
- let me = this;
-
- function getValue(ele){
- let value = "";
- if(ele){
- if(ele.nodeName == "TEXTAREA"){
- value = ele.textContent;
- } else if(ele.nodeName == "INPUT"){
- value = ele.value;
- } else {
- value = ele.textContent;
- }
- }
- return value;
- }
- function beforeInputEvent(e){
-
-
- let ele = e.target;
-
-
- if(ele){
-
- let inputA = emrRemark.getParentA(ele);
- if(inputA){
- let value = getValue(ele);
- emrRemark.setData(inputA,value);
- }
- }
- }
-
- function inputEvent(e){
-
- let ele = e.target;
-
-
- if(ele){
- let inputA = emrRemark.getParentA(ele);
- if(inputA){
- emrRemark.showAllRemark();
- }
- }
- }
- me.commands["amendment"] = {
- execCommand: function(cmd,ui) {
- me.options.amendment = !me.options.amendment;
-
- if(ui.target){
- if(me.options.amendment){
- me.document.addEventListener("beforeinput", beforeInputEvent),
- me.document.addEventListener("input", inputEvent);
- ui.target.classList.add("edui-active");
- } else {
- me.document.removeEventListener("beforeinput", beforeInputEvent),
- me.document.removeEventListener("input", inputEvent);
- ui.target.classList.remove("edui-active");
- }
- emrRemark.showAllRemark();
- }
- }
- }
- };
- UE.plugins["annotations"] = function() {
- let me = this;
- me.commands["annotations"] = {
- execCommand: function(cmd,ui) {
- me.options.annotations = !me.options.annotations;
-
- if(ui.target){
- if(me.options.annotations){
- ui.target.classList.add("edui-active");
- me.document.addEventListener("input", emrRemark.annotationsInput);
- } else {
- ui.target.classList.remove("edui-active");
- me.document.removeEventListener("input", emrRemark.annotationsInput);
- }
- emrRemark.showAllRemark();
- }
- }
- }
- };
- UE.plugins["addannotations"] = function() {
- let me = this;
- function createSpan(){
- let span = me.document.createElement("label");
- span.classList.add("note");
- span.setAttribute("note","true");
- span.setAttribute("data-original","");
- span.setAttribute("data-create-time", util.formatDate(new Date()));
- span.setAttribute("data-creator", me.options.userName);
-
- return span;
- }
- function setAndShowRemark(){
- if(!me.options.annotations){
- me.options.annotations = !me.options.annotations;
- me.document.addEventListener("input", emrRemark.annotationsInput);
-
- let toolbar = document.querySelector(".edui-for-annotations");
- if(toolbar && toolbar.firstChild){
- toolbar.firstChild.classList.add("edui-active");
- }
- }
- emrRemark.showAllRemark();
- }
- me.commands["addannotations"] = {
- execCommand: function(cmd,ui) {
-
- let range = me.selection.getRange().adjustmentBoundary();
-
-
- let startA = emrRemark.getParentA(range.startContainer);
- let endA = emrRemark.getParentA(range.endContainer);
-
-
-
- if(startA && endA && startA == endA && startA.getAttribute("datatype") == "tooth"){
- let tooth = startA.querySelector(".tooth-all");
- tooth.innerHTML = '<label class="note" note="true" data-create-time="'+util.formatDate(new Date())
- +'" data-creator="'+me.options.userName+'" data-original="">'+tooth.innerHTML+'</label>';
- setAndShowRemark();
- return false;
- }
-
-
- if(startA && endA && startA == endA && startA.getAttribute("datatype") == "imgUpload"){
- let note = me.document.createElement("label");
- note.className = "note";
- note.style.position="absolute";
-
- note.setAttribute("remove","true");
- note.setAttribute("note","true");
- note.setAttribute("data-create-time", util.formatDate(new Date()));
- note.setAttribute("data-creator", me.options.userName);
- note.setAttribute("data-original", "");
- let cupload = startA.querySelector(".Cupload")
- cupload.prepend(note);
-
- setAndShowRemark();
-
-
- return false;
- }
-
-
- if(range.endOffset == range.startOffset){
- range.insertNode(createSpan());
- setAndShowRemark();
- return;
- }
-
-
-
-
- let rangeNode = null;
- range.traversal(function(node){
- let content = node.textContent;
- if(content && content.trim() && !rangeNode){
- rangeNode = node;
- return false;
- }
- });
- range.setStart(rangeNode,0);
-
-
- range.applyInlineStyle("label",{
- "class":"note",
- "note":"true",
- "data-original":"",
- "data-create-time": util.formatDate(new Date()),
- "data-creator": me.options.userName
- }, null, true);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- me.selection.clearRange();
-
- setAndShowRemark();
- }
- }
- };
-
- UE.plugins["sign"] = function() {
- let me = this;
- me.commands["sign"] = {
- execCommand: function(cmd) {
- sign(me);
- }
- }
- };
|