Ticket #13529: EMRWidgets.js

File EMRWidgets.js, 23.7 KB (added by Ankur, 9 years ago)
Line 
1alert(111)
2timerID = null;
3normalCode = String.fromCharCode(173);
4
5lookupButn = null;
6currentDataArray = null;
7currentArrayName = null;
8currentAppendMode = null;
9edtLookupOpenFlag= false;
10popupFrame = null;
11
12function setData(append, ahref, direc, txtVal,elementVal){
13
14    span = lookupButn.parentNode;
15    if(span.parentNode.className=="hideInView") span.parentNode.className="";
16    if(append==1 && lookupButn.accessKey!="set") { lookupButn.accessKey="set"; append = 0; }
17
18    if(!txtVal) txt = ahref.innerText;
19    else txt = txtVal;
20    txt = new String(txt);
21    txtPos = "beforeEnd";
22    if(direc=='L') txtPos = "afterBegin"
23    prevtxt = span.getAdjacentText(txtPos);
24    fulltxt = span.innerText;
25
26    if(txt=="[blank]")
27    {
28        span.replaceAdjacentText(txtPos, "");
29        closePopup();
30        return false;
31    }
32    if(append==1 && (fulltxt.indexOf(txt+",")==0 || fulltxt.indexOf(", "+txt+",")>0 || (fulltxt.indexOf(", "+txt)>0 && fulltxt.lastIndexOf(", "+txt)==fulltxt.length-txt.length-2)|| fulltxt.indexOf("- "+txt+",")>0|| (fulltxt.indexOf("- "+txt)>0 && fulltxt.lastIndexOf("- "+txt)==fulltxt.length-txt.length-2)||(txt.lastIndexOf("-")==txt.length-1&&(fulltxt.indexOf(txt)==0||fulltxt.indexOf(', '+txt)!=-1)))){
33    //if(append==1 && (fulltxt.indexOf(txt+",")==0 || fulltxt.indexOf(", "+txt+",")>0 || (fulltxt.indexOf(", "+txt)>0 && fulltxt.lastIndexOf(", "+txt)==fulltxt.length-txt.length-2)|| fulltxt.indexOf("- "+txt+",")>0|| (fulltxt.indexOf("- "+txt)>0 && fulltxt.lastIndexOf("- "+txt)==fulltxt.length-txt.length-2)||(txt.lastIndexOf("-")==txt.length-1&&(fulltxt.indexOf(txt)==0||fulltxt.indexOf(', '+txt)!=-1)))){
34    //if(append==1 && (fulltxt.indexOf(txt+",")==0 || fulltxt.indexOf(", "+txt+",")>0 || (fulltxt.indexOf(", "+txt)>0 && fulltxt.lastIndexOf(", "+txt)==fulltxt.length-txt.length-2))){
35        ahref.style.color= 'blue';
36        if(ahref.nextSibling.tagName=="A") ahref.nextSibling.style.color= 'blue';
37        return false;
38    }
39    if(append==1 && prevtxt.indexOf("___")==-1 && prevtxt.indexOf(normalCode)==-1 && prevtxt!=""){
40      trimPrevtxt=trim(prevtxt);
41      if(trimPrevtxt.lastIndexOf("-")==(trimPrevtxt.length-1))txt =  prevtxt + " " + txt;
42      else if(trimPrevtxt.indexOf(".")==(trimPrevtxt.length-1))txt =  trimPrevtxt.substring(0,trimPrevtxt.length-1) + ", " + txt;
43      else txt =  prevtxt + ", " + txt;
44    }
45
46tRange = editorFrm.contentWindow.document.body.createTextRange();
47tRange.moveToElementText(span);
48tRange.moveStart("character");
49tRange.pasteHTML(txt);
50
51
52//    if(prevtxt=="" && txtPos=="beforeEnd")
53//        lookupButn.replaceAdjacentText("afterEnd", txt);
54//    else  span.replaceAdjacentText(txtPos, txt);
55
56    ahref.style.color= 'blue';
57    if(ahref.nextSibling.tagName=="A") ahref.nextSibling.style.color= 'blue';
58
59    if(elementVal)
60    {
61        if(elementVal=="null") span.title='';
62        else{
63                if(append==1)elementVal=parseFloat(elementVal)+parseFloat(span.title);
64                span.title=elementVal;
65                valSpanObj=editorFrm.contentWindow.document.getElementById("v"+span.id);
66                if(valSpanObj)valSpanObj.innerHTML=elementVal;
67            }
68    }
69
70    if(append==0) closePopup();
71    return false;
72
73}
74
75function remData(ahref)
76{
77        span = lookupButn.parentNode;
78        hrefTxt = ahref.innerText;
79        fulltxt = span.innerText;
80
81        var commaSpaceTxtIndex=-1;
82        var hrefTxtIndex=-1;
83        var indexOfDenies=fulltxt.indexOf("Denies -");
84        var indexOfComplains=fulltxt.indexOf("Complains of -");
85       
86        if(fulltxt==hrefTxt)txt='';
87        else if(hrefTxt=="Denies -"&&indexOfDenies!=-1){
88                if(indexOfDenies!=-1){
89                        commaIndexBeforeDenies=fulltxt.lastIndexOf(',',indexOfDenies);
90                        if(indexOfDenies!=0) txt=fulltxt.substring(0,commaIndexBeforeDenies);
91                        else if(indexOfComplains!=-1) txt=fulltxt.substring(indexOfComplains);
92                        else txt="";
93                }
94        }else if(hrefTxt=="Complains of -"&&indexOfComplains!=-1){
95                if(indexOfComplains!=-1){
96                        commaIndexBeforeComplains=fulltxt.lastIndexOf(',',indexOfComplains);
97                        if(indexOfComplains!=0) txt=fulltxt.substring(0,commaIndexBeforeComplains);
98                        else if(indexOfDenies!=-1) txt=fulltxt.substring(indexOfDenies);
99                        else txt="";
100                }
101        }else if( (commaSpaceTxtIndex=fulltxt.indexOf(", "+hrefTxt)) !=-1 ){
102                        commaAfterTxtIndex=fulltxt.indexOf(',',commaSpaceTxtIndex+1);
103                        if(commaAfterTxtIndex!=-1) txt=fulltxt.substring(0,commaSpaceTxtIndex+1)+fulltxt.substring(commaAfterTxtIndex+1);
104                        else txt=fulltxt.substring(0,commaSpaceTxtIndex);
105        }else if( (commaSpaceTxtIndex=fulltxt.indexOf(hrefTxt+",")) !=-1 ){
106                        //txt=fulltxt.substring((hrefTxt+", ").length);
107                        txt=fulltxt.substring(0,commaSpaceTxtIndex)+fulltxt.substring(commaSpaceTxtIndex+(hrefTxt+", ").length);
108        }else if((hrefTxtIndex=fulltxt.indexOf(hrefTxt))!=-1){
109                        if(hrefTxtIndex!=0)txt=fulltxt.substring(0,hrefTxtIndex);
110                        else    txt=fulltxt.substring(hrefTxt.length);
111        }else txt=fulltxt;
112
113        tRange = editorFrm.contentWindow.document.body.createTextRange();
114        tRange.moveToElementText(span);
115        tRange.moveStart("character");
116        tRange.pasteHTML(txt);
117        ahref.style.color= 'brown';
118        return false;
119}
120
121
122function clearData(span){
123        tRange = editorFrm.contentWindow.document.body.createTextRange();
124        tRange.moveToElementText(span);
125        tRange.moveStart("character");
126        tRange.pasteHTML('');
127        hrefArr=popupLyr.getElementsByTagName('a');
128        for(i=0; i<hrefArr.length; i++){
129                hrefArr[i].style.color= 'brown';
130        }
131        return false;
132}
133
134function openListEditor(){
135        if(currentDataArray==null || currentArrayName==null) return false;
136        edtLookupOpenFlag=true;
137        currentDataArray = currentDataArray;
138        document.editLookupForm.newVal.value="";
139        for(i=0; i<currentDataArray.length; i++){
140                newOpt = document.createElement('option');
141                newOpt.value = currentDataArray[i];
142                newOpt.text = currentDataArray[i].replace(/~/g,"   ");
143                document.editLookupForm.currList.add(newOpt);
144        }
145        editLookupLyr.style.top = popupLyr.style.top;
146        editLookupLyr.style.left = popupLyr.style.left;
147
148        popupFrame.style.top  = editLookupLyr.style.top;
149        popupFrame.style.left = editLookupLyr.style.left;
150        popupFrame.style.width  = editLookupLyr.style.width;
151        popupFrame.style.height = editLookupLyr.style.height;
152        popupFrame.style.display = "block";
153        popupFrame.style.visibility  = "visible";
154
155        editLookupLyr.style.display = "block";
156        editLookupLyr.style.visibility = "visible";
157
158        closePopup();
159        return false;
160}
161function closeListEditor(save){
162        optLen = document.editLookupForm.currList.options.length;
163        if(save==1){
164                currentDataArray.length = optLen;
165                dataArrayStr = currentArrayName + " = [";
166                for(i=0; i<optLen; i++){
167                        currentDataArray[i] = document.editLookupForm.currList.options[i].value;
168                        dataArrayStr += ("\""+currentDataArray[i].replace(/"/g,"\\\"")+"\"");
169                        if(i!=optLen-1) dataArrayStr += ",";
170                        //else dataArrayStr += "];";
171                }
172                dataArrayStr += "];";
173               
174                newInputFld = document.createElement('INPUT');
175                //newInputFld.type  = "hidden";
176                newInputFld.type  = "text";
177                newInputFld.name  = "editedArray";
178                newInputFld.value = dataArrayStr;
179                //document.reportEditForm.appendChild(newInputFld);
180                document.forms[0].appendChild(newInputFld);
181                lookupEdit=true;
182        }
183        editLookupLyr.style.visibility = "hidden";
184        editLookupLyr.style.display = "none";
185
186        document.editLookupForm.newVal.value="";
187        for(i=0; i<optLen; i++) document.editLookupForm.currList.remove(0);
188        if(currentArrayName==null) popLayer(currentDataArray,lookupButn, currentAppendMode);
189        else popLayer(currentArrayName,lookupButn, currentAppendMode);
190        edtLookupOpenFlag=false;
191        return false;
192}
193function addNewListVal(){
194        newvalue = document.editLookupForm.newVal.value;
195
196        var countCarat=0;
197        for (var i=0;i<newvalue.length;i++)
198        {
199                if(newvalue.charAt(i)=='^')
200                {
201                        countCarat++;
202                        if(i==0)
203                        {
204                                alert("First character can't be '^' ");
205                                return false;
206                        }
207                        if(countCarat>1)
208                        {
209                                alert("Only one '^' is allowed");
210                                return false;
211                        }
212                }
213        }
214        if(newvalue=="") return false;
215        newOpt = document.createElement('option');
216        newOpt.value = newvalue;
217        newOpt.text = newvalue.replace(/~/g,"   ");
218        insPos = document.editLookupForm.currList.selectedIndex;
219        if(insPos==-1) document.editLookupForm.currList.add(newOpt);
220        else document.editLookupForm.currList.add(newOpt, insPos+1)
221        return false;
222}
223
224function moveListValUp(){
225        selIdx = document.editLookupForm.currList.selectedIndex;
226        if(selIdx<1) return false;
227        document.editLookupForm.currList.options[selIdx].swapNode(document.editLookupForm.currList.options[selIdx-1]);
228        return false;
229}
230function moveListValDown(){
231        selIdx = document.editLookupForm.currList.selectedIndex;
232        if(selIdx==-1 || selIdx==document.editLookupForm.currList.options.length-1) return false;
233        document.editLookupForm.currList.options[selIdx].swapNode(document.editLookupForm.currList.options[selIdx+1]);
234        return false;
235}
236function indentListValRgt(){
237        selIdx = document.editLookupForm.currList.selectedIndex;
238        if(selIdx!=-1) {
239                optVal = document.editLookupForm.currList.options[selIdx].value;
240                optVal = "~"+optVal;
241                document.editLookupForm.currList.options[selIdx].value = optVal;
242                document.editLookupForm.currList.options[selIdx].text  = optVal.replace(/~/g,"   ");
243        }
244        return false;
245}
246function indentListValLft(){
247        selIdx = document.editLookupForm.currList.selectedIndex;
248        if(selIdx!=-1) {
249                optVal = document.editLookupForm.currList.options[selIdx].value;
250                if(optVal.indexOf("~")==0)
251                {
252                        optVal = optVal.substr(1);
253                        document.editLookupForm.currList.options[selIdx].value = optVal;
254                        document.editLookupForm.currList.options[selIdx].text  = optVal.replace(/~/g,"   ");
255                }
256        }
257        return false;
258}
259function deleteListVal(){
260        selIdx = document.editLookupForm.currList.selectedIndex;
261        if(selIdx!=-1) {
262                if(confirm("Delete the selected value?")){
263                        document.editLookupForm.currList.remove(selIdx);}
264        }
265        return false;
266}
267
268function holdPopup(){
269        if(timerID != null) clearTimeout(timerID);
270        timerID=null;
271}
272function closePopup(){
273        popupLyr.style.visibility="hidden";
274        popupLyr.style.display="none";
275        popupFrame.style.visibility  = "hidden";
276        popupFrame.style.display = "none";
277
278        timerID = null;
279        //lookupButn = null;
280        //currentDataArray = null;
281        return false;
282}
283function waitPopup(){
284        if(!edtLookupOpenFlag){
285                timerID = setTimeout("closePopup()",1200);
286        }
287}
288
289function popLayerRight(dataReference, bttn){
290        if(!editingReport) return false;
291        return popLayer(dataReference, bttn, -1, 'R');
292}
293function popLayerLeft(dataReference, bttn){
294        if(!editingReport) return false;
295        return popLayer(dataReference, bttn, -1, 'L');
296}
297
298function popLayer(dataReference, bttn, singular, direc){
299        alert("Line 298 !!!!!!!!!!!!!!!!!!!!!!!!!");
300        if(!editingReport) return false;
301        if(timerID!=null) clearTimeout(timerID);
302        if(!direc) direc = 'R';
303        if(!singular) singular = -1;
304        append  = 1;
305        if(singular==1) append  = 0;
306        currentAppendMode = append;
307
308        dataArr = null;
309        currentArrayName = null;
310        if(typeof(dataReference)=="string"){
311                dataArr = eval(dataReference);
312                currentArrayName = dataReference;
313        }else { dataArr = dataReference;}
314        currentDataArray = dataArr;
315        lookupButn = bttn;
316
317        imgleft=rteleft; imgtop=rtetop;
318       
319        lyrContent = "<div nowrap>";
320        pad = 0; txt="";
321
322        //lyrContent += ("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a style='text-decoration:none;font-weight:normal;'  href=# onclick='return closePopup()'>[close]</a>");
323
324        valFlag=false;
325        if(dataArr.length>0&&dataArr[0].indexOf("^")!=-1)valFlag=true;
326
327        for(vi=0; vi<dataArr.length; vi++){
328           pad = dataArr[vi].lastIndexOf("~");
329           if(pad==-1){txt=dataArr[vi]; pad=0;}
330           else{
331                txt=dataArr[vi].substring(pad+1);
332                pad = (pad+1)*15;
333           }
334
335           splt=0; txtNeg = ""; txtPos = "";
336           if((splt=txt.indexOf("|"))!=-1) {
337                  txtNeg = txt.substring(0, splt);
338                  txtPos = txt.substring(splt+1);
339                  //lyrContent += ("<a class=simple style='color:#006A77;margin-left:"+pad+"px' href=# onclick=\"return setData("+append+",this,'"+direc+"','"+txtNeg+txtPos+"')\" oncontextmenu=\"return setData(0,this,'"+direc+"','"+txtNeg+txtPos+"')\">"+txtNeg+"</a>");
340                  lyrContent += ("<a class=simple style='color:#006A77;margin-left:"+pad+"px' href=# onclick=\"return setData("+append+",this,'"+direc+"','"+txtNeg+txtPos+"')\" oncontextmenu=\"return remData(this)\">"+txtNeg+"</a>");
341                  //lyrContent += ("<a class=simple style='margin-left:6px' href=# onclick=\"return setData("+append+",this,'"+direc+"')\" oncontextmenu=\"return setData(0,this,'"+direc+"')\">"+txtPos+"</a><br>");
342                  lyrContent += ("<a class=simple style='margin-left:6px' href=# onclick=\"return setData("+append+",this,'"+direc+"')\" oncontextmenu=\"return remData(this)\">"+txtPos+"</a><br>");
343           }else if((splt=txt.indexOf("^"))!=-1){
344                  txtElement = txt.substring(0, splt);
345
346                  elementVal = txt.substring(splt+1);
347                  //lyrContent += ("<a class=simple style='color:#006A77;margin-left:"+pad+"px' href=# onclick=\"return setData("+append+",this,'"+direc+"','"+txtElement+"','"+elementVal+"')\" oncontextmenu=\"return setData(0,this,'"+direc+"','"+txtElement+"','"+elementVal+"')\">"+txtElement+"</a><br>");
348                  lyrContent += ("<a class=simple style='color:#006A77;margin-left:"+pad+"px' href=# onclick=\"return setData("+append+",this,'"+direc+"','"+txtElement+"','"+elementVal+"')\" oncontextmenu=\"return remData(this)\">"+txtElement+"</a><br>");
349
350                }else{ //lyrContent += ("<a class=simple style='margin-left:"+pad+"px' href=# onclick=\"return setData("+append+",this,'"+direc+"')\" oncontextmenu=\"return setData(0,this,'"+direc+"')\">"+txt+"</a><br>");
351                        lyrContent += ("<a class=simple style='margin-left:"+pad+"px' href=# onclick=\"return setData("+append+",this,'"+direc+"')\" oncontextmenu=\"return remData(this)\">"+txt+"</a><br>");
352                }
353        }
354       
355        lyrContent += ("<span style='border-top:1px dotted #C0C0C0;margin-top:2px;text-align:right;width:100%;'>");
356       
357        if(!valFlag&&currentArrayName!=null&&typeof(hideLookupEdit)=='undefined') lyrContent += ("<a style='text-decoration:none;font-weight:normal;' href=# onclick='return openListEditor()'>[new]</a>");
358        lyrContent += ("&nbsp;&nbsp;<a style='text-decoration:none;font-weight:normal;'  href=# onclick='return clearData(lookupButn.parentNode)'>[clr]</a>&nbsp;&nbsp;<a style='text-decoration:none;font-weight:normal;'  href=# onclick='return closePopup()'>[close]</a>&nbsp;</span></div>");
359       
360        popupLyr.contentEditable = true;
361        popupLyr.innerHTML = lyrContent;
362        popupLyr.contentEditable = false;
363
364        obj = bttn;
365        while (obj.offsetParent){
366                imgleft += obj.offsetLeft;
367                imgtop += obj.offsetTop;
368                obj = obj.offsetParent;
369        }
370       
371        poptop = imgtop + 12 - editorFrm.contentWindow.document.body.scrollTop;
372        popupLyr.style.top = poptop;
373       
374        if(direc=='R')
375                popupLyr.style.left = imgleft + 1 - editorFrm.contentWindow.document.body.scrollLeft;
376        else
377                popupLyr.style.left = imgleft +15 - popupLyr.style.pixelWidth - editorFrm.contentWindow.document.body.scrollLeft;
378
379        if(dataArr.length<15)popheight = (dataArr.length+1)*17+10;
380        else popheight = (17)*17+10;
381        popupLyr.style.height = popheight
382        //popupLyr.style.width = 200;
383 
384        popchop = popheight - ( document.body.clientHeight + document.body.scrollTop - poptop);
385        if(popchop > 3){
386                window.scrollBy(0,popchop);
387        }
388
389        if(popupFrame==null) popupFrame = document.all["popupFrm"];
390        popupFrame.style.top  = popupLyr.style.top;
391        popupFrame.style.left = popupLyr.style.left;
392        popupFrame.style.width  = popupLyr.style.width;
393        popupFrame.style.height = popupLyr.style.height;
394        popupFrame.style.display = "block";
395        popupFrame.style.visibility  = "visible";
396
397        popupLyr.style.display = "block";
398        popupLyr.style.visibility = "visible";
399
400        spanTxt = lookupButn.parentNode.innerText;
401        hrefArr=popupLyr.getElementsByTagName('a');
402
403        for(i=0; i<hrefArr.length; i++){
404                //      alert(hrefArr[i].innerText.length-1);
405                //      alert(hrefArr[i].innerText.charAt(hrefArr[i].innerText.length-1))
406
407                if((spanTxt==hrefArr[i].innerText)||(spanTxt.indexOf(hrefArr[i].innerText+', ')!=-1)||(spanTxt.indexOf(', '+hrefArr[i].innerText)!=-1)||(spanTxt.indexOf(hrefArr[i].innerText)!=-1&&(hrefArr[i].innerText.charAt(hrefArr[i].innerText.length-1)=='-'))){
408                        hrefArr[i].style.color= 'blue';
409                }else hrefArr[i].style.color= 'brown';
410        }
411
412        timerID = setTimeout("closePopup()",1200);
413}
414
415function tickBoxOLD(cboxImg){
416        if(!editingReport) return;
417        if(cboxImg.src.indexOf("Off")!=-1) cboxImg.src = "/vis/cboxOn.gif";
418        else cboxImg.src = "/vis/cboxOff.gif";
419}
420function tickBox(cboxImg,elementVal){
421        if(!editingReport) return;
422       
423        span=cboxImg.parentNode;
424        if(span&&span.tagName=="SPAN")isParentSpan=true;
425        else isParentSpan=false;
426       
427        if(cboxImg.src.indexOf("Off")!=-1) {
428                cboxImg.src = "/vis/cboxOn.gif";
429                if(cboxImg.parentElement!=null){
430                  if(cboxImg.parentElement.accessKey=="showIfTicked") cboxImg.parentElement.className="";
431                  else if(cboxImg.parentElement.tagName=="TD" && cboxImg.parentElement.parentElement.accessKey=="showIfTicked") cboxImg.parentElement.parentElement.className="";
432                 if(isParentSpan&&elementVal)span.title=elementVal;
433                }
434        }else{
435                cboxImg.src = "/vis/cboxOff.gif";
436                if(cboxImg.parentElement!=null){
437                  if(cboxImg.parentElement.accessKey=="showIfTicked") cboxImg.parentElement.className="hideInView";
438                  else if(cboxImg.parentElement.tagName=="TD" && cboxImg.parentElement.parentElement.accessKey=="showIfTicked") cboxImg.parentElement.parentElement.className="hideInView";
439                  if(isParentSpan&&elementVal)span.title="";
440                }
441        }
442}
443function radioBox(rboxImg,elementVal){
444        if(!editingReport) return;
445        radioImgs = editorFrm.contentWindow.document.all[rboxImg.name];
446        span=rboxImg.parentNode;
447
448        if(span&&span.tagName=="SPAN")isParentSpan=true;
449        else isParentSpan=false;
450
451        if(radioImgs.tagName=="IMG")
452        {
453                if(radioImgs.src.indexOf("Off")!=-1){
454                        radioImgs.src = "/vis/cboxOn.gif";
455                        if(elementVal){
456                                radioImgs.title=elementVal;
457                                if(isParentSpan)span.title=elementVal;
458                        }
459
460                }else if(radioImgs.src.indexOf("On")!=-1){
461                        radioImgs.src = "/vis/cboxOff.gif";
462                        if(elementVal)radioImgs.title="";
463                        if(isParentSpan)span.title="";
464                }
465
466
467        }
468        for(i=0; i<radioImgs.length; i++){
469                if(radioImgs[i].uniqueID==rboxImg.uniqueID && radioImgs[i].src.indexOf("Off")!=-1){
470                        radioImgs[i].src = "/vis/cboxOn.gif";
471                        if(elementVal)radioImgs[0].title=elementVal;
472                        else if(elementVal==0)radioImgs[0].title=elementVal;
473                        if(isParentSpan)span.title=elementVal;
474
475                        if(radioImgs[i].parentElement!=null)
476                        {
477                          if(radioImgs[i].parentElement.accessKey=="showIfTicked") radioImgs[i].parentElement.className="";
478                          //else if(radioImgs[i].parentElement.tagName=="TD" && radioImgs[i].parentElement.parentElement.accessKey=="showIfTicked") radioImgs[i].parentElement.parentElement.className="";
479                        }
480
481
482                }
483                else if(radioImgs[i].uniqueID!=rboxImg.uniqueID && radioImgs[i].src.indexOf("On")!=-1){
484                        radioImgs[i].src = "/vis/cboxOff.gif";
485                        //if(elementVal)radioImgs[0].title="";
486                        //if(isParentSpan)span.title="";
487
488                        if(radioImgs[i].parentElement!=null)
489                        {
490                          if(radioImgs[i].parentElement.accessKey=="showIfTicked") radioImgs[i].parentElement.className="hideInView";
491                          //else if(radioImgs[i].parentElement.tagName=="TD" && radioImgs[i].parentElement.parentElement.accessKey=="showIfTicked") radioImgs[i].parentElement.parentElement.className="hideInView";
492                        }
493                }
494        }
495}
496
497imgTimerID = null;
498imgToolVisible = false;
499function holdImgPopup(){
500        if(imgTimerID != null) clearTimeout(imgTimerID);
501        imgTimerID=null;
502}
503function closeImgPopup(){
504        imgToolFrm.style.visibility="hidden";
505        imgToolFrm.style.display="none";
506        imgToolVisible = false;
507        imgTimerID = null;
508        return false;
509}
510function waitImgPopup(){
511        imgTimerID = setTimeout("closeImgPopup()",500);
512}
513function popImgLayer(imgObj){
514        if(imgToolVisible){
515                holdImgPopup();
516                return;
517        }
518        imgleft=rteleft; imgtop=rtetop;
519        obj = imgObj;
520        while (obj.offsetParent){
521                        imgleft += obj.offsetLeft;
522                        imgtop  += obj.offsetTop;
523                        obj = obj.offsetParent;
524        }
525        imgToolFrm.style.top = imgtop - editorFrm.contentWindow.document.body.scrollTop;
526        imgToolFrm.style.left = imgleft + imgObj.offsetWidth - editorFrm.contentWindow.document.body.scrollLeft;
527        //x=0;
528        for(k=0; k < document.applets.length; k++){
529                if(imgToolFrm.document.applets[k].code=="ControlPanel.class" || imgToolFrm.document.applets[k].code=="FontPanel.class"){
530                        imgToolFrm.document.applets[k].setInstance(imgObj.title);
531                        //x++;
532        }} //alert("applets updated :"+x);
533        imgToolFrm.style.display = "block";
534        imgToolFrm.style.visibility = "visible";
535        imgToolVisible = true;
536        imgTimerID = null; //setTimeout("closeImgPopup()",2000);
537}
538
539function addTableCol(tableid, maxcols){
540  rteEditor = document.getElementById('idRecordText').contentWindow;
541  tableref  = rteEditor.document.getElementById(tableid);
542  if(tableref==null) return;
543  if(maxcols && tableref.rows(0).cells.length >= maxcols){
544        alert("Maximum column limit for table reached.");
545        return;
546  }
547  for (i=0; i<tableref.rows.length; i++){
548    trow = tableref.rows(i);
549    lasttd = trow.cells(trow.cells.length-1);
550    newtd = lasttd.cloneNode(true);
551    trow.appendChild(newtd);
552  }
553}
554
555
556function trim( inputStr ){
557        strObj = new String (inputStr);
558        return strObj.replace(/^\s*|\s*$/g,"");
559}
560
561
562
563var stopHighlight=false;
564var activeCalSpan = null;
565var imgCals = null;
566var timerNumPadID=null;
567
568function popTest(obj){
569        timerNumPadID=null;             
570        imgCals=obj;
571        if(obj.parentNode.tagName=="SPAN")activeCalSpan=obj.parentNode;
572        //stopHighlight=false;
573        numpad=document.getElementById("numpad");
574        topPos=rtetop; leftPos=rteleft;
575
576        while (obj.offsetParent){
577                leftPos += obj.offsetLeft;
578                topPos  += obj.offsetTop;
579                obj = obj.offsetParent;
580        }
581        numpad.style.left =leftPos - editorFrm.contentWindow.document.body.scrollLeft;
582        numpad.style.top =topPos -95 - editorFrm.contentWindow.document.body.scrollTop;
583        numpad.style.display = "block";
584        numpad.style.visibility = "visible";
585
586//      timerNumPadID=setTimeout("closeNumpad()",2000);
587
588}
589
590function popNumPad(obj){
591        timerNumPadID=null;             
592        imgCals=obj;
593        if(obj.parentNode.tagName=="SPAN")activeCalSpan=obj.parentNode;
594        //stopHighlight=false;
595        numpad=document.getElementById("numpad");
596        topPos=rtetop; leftPos=rteleft;
597
598        while (obj.offsetParent){
599                leftPos += obj.offsetLeft;
600                topPos  += obj.offsetTop;
601                obj = obj.offsetParent;
602        }
603        numpad.style.left =leftPos - editorFrm.contentWindow.document.body.scrollLeft;
604        numpad.style.top =topPos -95 - editorFrm.contentWindow.document.body.scrollTop;
605        numpad.style.display = "block";
606        numpad.style.visibility = "visible";
607
608//      timerNumPadID=setTimeout("closeNumpad()",2000);
609}
610
611
612function closeNumpad(){
613        activeCalSpan = null;
614        timerNumPadID = null;
615       
616        numpad=document.getElementById("numpad");       
617        numpad.style.visibility = "hidden";
618        numpad.style.display = "none";
619        //stopHighlight = true;
620        return false;
621}
622//onmouse over
623function holdPopNumPad(){
624        if(timerNumPadID != null) clearTimeout(timerNumPadID);
625        timerNumPadID=null;
626       
627}
628
629//onmouseout
630function waitPopNumPad(){
631        if(stopHighlight!=null&&!stopHighlight){
632                timerNumPadID = setTimeout("closeNumpad()",1000);
633        }
634}
635
636function npad(n){
637        timerNumPadID = null;
638        stopHighlight=false;
639        if(n=="c"){
640                numpad=document.getElementById("numpad");
641                numpad.style.visibility = "hidden";
642                numpad.style.display = "none";
643                return false;
644        }
645        if(n=="DQT") n='"';
646       
647        editorFrm.contentWindow.focus();
648       
649        txtRngSel = editorFrm.contentWindow.document.selection.createRange();
650       
651        txtRngSpn = editorFrm.contentWindow.document.body.createTextRange();
652        txtRngSpn.moveToElementText(activeCalSpan);
653       
654        if(txtRngSpn.inRange(txtRngSel)) txtRng = txtRngSel; 
655        else txtRng = txtRngSpn;
656       
657        txtRng.collapse(false);
658       
659        if(n=="BKS"){
660       
661                if(trim(activeCalSpan.innerText)!="")
662                {
663                        txtRng.moveStart("character",-1);
664                        txtRng.text="";
665                }
666        }else {
667                txtRng.text = n; 
668        }
669        return false;
670}
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy