var qb_links = new Array(); var qb_zoomFactor = 1; var qb_linkMenuNode; function qb_link(id1,id2,condition){ for(i=qb_links.length-1;i>=0;i--){ var col1s = qb_links[i].field1.id.split('.'); var col2s = qb_links[i].field2.id.split('.'); if (id1.id) { var id1s = id1.id.split('.'); var id2s = id2.id.split('.'); } else { var id1s = id1.split('.'); var id2s = id2.split('.'); } // don't allow a column to be joined to same table twice if (qb_links[i].field1.id == id1 && (id2s[0] == col2s[0])){ var img = html_GetElement("dragimg"); img.style.display="none"; qb_colDrag = false; qb_begDrag = ''; return; } if (qb_links[i].field1.id == id2 && (id1s[0] == col2s[0])){ var img = html_GetElement("dragimg"); img.style.display="none"; qb_colDrag = false; qb_begDrag = ''; return; } if (qb_links[i].field2.id == id1 && (id2s[0] == col1s[0])){ var img = html_GetElement("dragimg"); img.style.display="none"; qb_colDrag = false; qb_begDrag = ''; return; } if (qb_links[i].field2.id == id2 && (id1s[0] == col1s[0])){ var img = html_GetElement("dragimg"); img.style.display="none"; qb_colDrag = false; qb_begDrag = ''; return; } // don't allow multiple joins of same type //if (qb_links[i].field1.id == id1 && qb_links[i].field2.id == id2){ // return; // } // if (qb_links[i].field2.id == id1 && qb_links[i].field1.id == id2){ // return; // } } // // push reference to the array // qb_links.push(this); // // var declarations // this.id = "link"+(new Date()).getTime(); this.id1 = html_GetElement(id1); this.id2 = html_GetElement(id2); this.field1 = this.id1; this.field2 = this.id2; this.linkObj1; this.linkObj2; this.linkObj3; this.col1; // need to get based on id this.col2; // need to get based on id this.condition = condition == null ? "E" : condition; // // Declare methods // this.create = qb_link_create; this.redim = qb_link_redim; this.setTip = qb_link_setTip; this.getTip = qb_link_tip; this.updateTip = qb_link_updateTip; // // Create the link // this.create(); this.setTip(); this.updateTip(); this.redim(); } function qb_link_tip(){ return this.field1.id + ( this.condition == 'L' ? '(+)':'') + "=" + this.field2.id+ ( this.condition == 'R' ? '(+)':''); } function qb_link_updateTip(){ var tip = this.getTip(); this.linkObj2.tip=tip; this.linkObj1.tip=tip; this.linkObj3.tip=tip; } function qb_link_create(){ var tmp; var holder = html_GetElement('qbLinkHolder'); this.linkObj2 = document.createElement("DIV"); this.linkObj2.id = this.id; this.linkObj2.menuId=this.linkObj2.id; this.linkObj2.arrayElement=this; this.linkObj2.vert = 0; this.linkObj2.relLeft = 0; this.linkObj2.style.position = "absolute"; this.linkObj2.style.overflow = "hidden"; this.linkObj2.style.zIndex = 20000; this.linkObj2.innerHTML=" "; tmp = document.createElement("DIV"); tmp.style.position = "absolute"; tmp.style.overflow = "hidden"; tmp.menuId=this.linkObj2.id; tmp.arrayElement=this; tmp.style.left = 2; tmp.style.top = 0; tmp.style.width = 2; tmp.style.height = "100%"; tmp.style.zIndex = 20000; tmp.style.backgroundColor = "#cfdccf"; this.linkObj2.appendChild(tmp); this.linkObj1 = document.createElement("DIV"); this.linkObj1.id = this.linkObj2.id;//+"divh1"; this.linkObj1.menuId=this.linkObj2.id; this.linkObj1.arrayElement=this; this.linkObj1.style.position = "absolute"; this.linkObj1.style.overflow = "hidden"; this.linkObj1.style.zIndex = 20000; this.linkObj1.innerHTML="
"; tmp = document.createElement("DIV"); tmp.style.position = "absolute"; tmp.menuId=this.linkObj2.id; tmp.arrayElement=this; tmp.style.overflow = "hidden"; tmp.style.left = 0; tmp.style.top = 2; tmp.style.width = "100%"; tmp.style.height = 2; tmp.style.zIndex = 20000; this.linkObj1.appendChild(tmp); tmp.style.backgroundColor = "#cfdccf"; this.linkObj1.vert = 1; this.linkObj1.onmousedown="lineMouseDown(event);"; this.linkObj1.onmouseup="lineMouseUp(event);"; this.linkObj3 = document.createElement("DIV"); this.linkObj3.id = this.linkObj2.id;//+"divh2"; this.linkObj3.menuId=this.linkObj3.id; this.linkObj3.arrayElement=this; this.linkObj3.style.position = "absolute"; this.linkObj3.style.overflow = "hidden"; this.linkObj3.style.zIndex = 20000; this.linkObj3.innerHTML=" "; tmp = document.createElement("DIV"); tmp.style.position = "absolute"; tmp.style.overflow = "hidden"; tmp.menuId=this.linkObj2.id; tmp.arrayElement=this; tmp.style.left = 0; tmp.style.top = 2; tmp.style.width = "100%"; tmp.style.height = 2; tmp.style.zIndex = 20000; tmp.style.backgroundColor = "#cfdccf"; this.linkObj3.appendChild(tmp); holder.appendChild(this.linkObj1); holder.appendChild(this.linkObj2); holder.appendChild(this.linkObj3); this.linkObj1.vert = 1; this.linkObj2.vert = 0; this.linkObj3.vert = 1; if (document.all) { this.linkObj1.style.cursor = "hand";//"N-resize"; this.linkObj2.style.cursor = "hand";//"E-resize"; // middle this.linkObj3.style.cursor = "hand";//"N-resize"; } else { this.linkObj1.style.cursor = "pointer";//"N-resize"; this.linkObj2.style.cursor = "pointer";//"E-resize"; // middle this.linkObj3.style.cursor = "pointer";//"N-resize"; } this.linkObj1.className = "links1"; this.linkObj2.className = "links"; this.linkObj3.className = "links1"; sqlQueryRebuild = true; qb_validateLinks(); } function qb_link_onmouseover(evt){ var evt = (evt) ? evt : ((window.event) ? event : null); var target = evt.target ? evt.target : evt.srcElement; //alert('hi'); qb_linkMenuNode=target.menuId; if ( target.tip != null ) toolTip_enable(evt,target,target.tip); } function qb_link_onclick(evt){ var evt = (evt) ? evt : ((window.event) ? event : null); var target = evt.target ? evt.target : evt.srcElement; qb_linkMenuNode=target.menuId; qb_checkOuterLink(); qb_OpenLinkMenu(evt,target,'defaultLinkMenu'); } function qb_link_setTip(){ try { this.linkObj1.attachEvent("onmouseover",qb_link_onmouseover); this.linkObj2.attachEvent("onmouseover",qb_link_onmouseover); this.linkObj3.attachEvent("onmouseover",qb_link_onmouseover); this.linkObj1.attachEvent("onclick",qb_link_onclick); this.linkObj2.attachEvent("onclick",qb_link_onclick); this.linkObj3.attachEvent("onclick",qb_link_onclick); } catch (ex) { // must not be in IE } try { this.linkObj1.setAttribute("onmouseover","qb_link_onmouseover(event)"); this.linkObj2.setAttribute("onmouseover","qb_link_onmouseover(event)"); this.linkObj3.setAttribute("onmouseover","qb_link_onmouseover(event)"); this.linkObj1.setAttribute("onclick","qb_link_onclick(event)"); this.linkObj2.setAttribute("onclick","qb_link_onclick(event)"); this.linkObj3.setAttribute("onclick","qb_link_onclick(event)"); } catch(ex){ // must not be in Mozilla } } function qb_OpenLinkMenu(evt,pThis,pThat){ evt = (evt) ? evt : ((window.event) ? event : null); var evtX = evt.pageX ? evt.pageX : evt.clientX ;; var evtY = evt.pageY ? evt.pageY : evt.clientY ; dhtml_SingeMenuOpen(pThis,pThat,'Set',evtX,evtY); html_GetElement('defaultLinkMenu').style.zIndex = 200001; return; } function qb_link_redim() { var o1 = qb_cascadeUpUntil(this.field1,"TR"); var o2 = qb_cascadeUpUntil(this.field2,"TR"); var o1_holder = qb_cascadeUpUntil(o1,"DIV"); var o2_holder = qb_cascadeUpUntil(o2,"DIV"); if ( o1_holder.style.display == 'none' || ( o1_holder.scrollHeight && o1_holder.scrollHeight > 250) ) { o1 = qb_cascadeUpUntil(o1,"DIV"); o1 = qb_cascadeUpUntil(o1,"DIV"); } if ( o2_holder.style.display == 'none' || ( o2_holder.scrollHeight && o2_holder.scrollHeight > 250) ) { o2 = qb_cascadeUpUntil(o2,"DIV"); o2 = qb_cascadeUpUntil(o2,"DIV"); } var l1=parseInt(findPosX(o1)); var t1=parseInt(findPosY(o1)); var w1=o1.offsetWidth; var h1=o1.offsetHeight; var r1=l1 + w1; var l2=parseInt(findPosX(o2)); var t2=parseInt(findPosY(o2)); var w2=o2.offsetWidth; var h2=o2.offsetHeight; var r2=l2 + w2; this.linkObj1.style.top = t1 + 10; this.linkObj3.style.top = t2 + 10; if(this.linkObj2.relLeft>0){ y1 = this.linkObj2.relLeft; } else { if (r1r1) { this.linkObj1.style.left=r1; this.linkObj1.style.width=y1-r1+1; } else { this.linkObj1.style.left=y1; this.linkObj1.style.width=1; } if (y1r2) { this.linkObj3.style.left=r2; this.linkObj3.style.width=y1-r2+1; } else { this.linkObj3.style.left=y1; this.linkObj3.style.width=1; } var pt1 = parseInt(this.linkObj1.style.top); var pt2 = parseInt(this.linkObj3.style.top); this.linkObj2.style.top=((pt1-pt2)<0)?pt1+2:pt2+2; return false; } // // End of Object // function qb_outer(w){ var l_link =document.getElementById(qb_linkMenuNode); l_link.arrayElement.condition=w; l_link.arrayElement.updateTip(); qb_validateLinks(); html_HideElement('defaultLinkMenu'); qb_genSql(); } function qb_delLink(l){ var tmp = l.arrayElement; var col1j = html_GetElement(tmp.field1.id+'_jbox'); var col2j = html_GetElement(tmp.field2.id+'_jbox'); if (col1j) { col1j.style.backgroundColor= ""; col1j.innerHTML = '  '; } if (col2j){ col2j.innerHTML = '  '; col2j.style.backgroundColor= ""; } tmp.field1.style.backgroundColor= ""; tmp.field2.style.backgroundColor= ""; tmp.linkObj1.parentNode.removeChild(tmp.linkObj1); tmp.linkObj2.parentNode.removeChild(tmp.linkObj2); tmp.linkObj3.parentNode.removeChild(tmp.linkObj3); qb_links = qb_delArrElement(qb_links,l); qb_validateLinks(); html_HideElement(g_Single_Menu); return } function qb_delLinkClick(){ var l_link =document.getElementById(qb_linkMenuNode); qb_delLink(l_link); qb_validateLinks(); qb_validateLinks(); app_AppMenuMultiClose(); qb_genSql(); } function qb_validateLinks(){ var i; for(i=qb_links.length-1;i>=0;i--){ var col1j = html_GetElement(qb_links[i].field1.id+'_jbox'); var col2j = html_GetElement(qb_links[i].field2.id+'_jbox'); if (col1j) col1j.innerHTML = ' '; if (col2j) col2j.innerHTML = ' '; } for(i=qb_links.length-1;i>=0;i--){ if (qb_links[i]) { var col1 = html_GetElement(qb_links[i].field1.id); var col1j = html_GetElement(qb_links[i].field1.id+'_jbox'); var col2 = html_GetElement(qb_links[i].field2.id); var col2j = html_GetElement(qb_links[i].field2.id+'_jbox'); if(qb_links[i] && ( ! col1 || ! col2 ) ) { qb_delLink(qb_links[i].linkObj2); } else { col1.style.backgroundColor= "#DDDDDD"; col2.style.backgroundColor= "#DDDDDD"; if (qb_links[i].condition == 'L') { col1j.innerHTML = col1j.innerHTML+'+'; col2j.innerHTML = col2j.innerHTML+''; } else if (qb_links[i].condition == 'R') { col1j.innerHTML = col1j.innerHTML+''; col2j.innerHTML = col2j.innerHTML+'+'; } else { col1j.innerHTML = col1j.innerHTML+''; col2j.innerHTML = col2j.innerHTML+''; } if (col1j.innerHTML.indexOf('+') > -1){ col1j.style.backgroundColor= ""; } else { col1j.style.backgroundColor= "#DDDDDD"; } if (col2j.innerHTML.indexOf('+') > -1){ col2j.style.backgroundColor= ""; } else { col2j.style.backgroundColor= "#DDDDDD"; } } if ( col1 && !col2 ){ col1.style.backgroundColor= ""; col1j.style.backgroundColor= ""; } if ( !col1 && col2 ){ col2.style.backgroundColor= ""; col2j.style.backgroundColor= ""; } } } } function qb_abs1(a){ return (a<0)?-a:(a>0?a:1); } function qb_checkOuterLink() { var menu = html_GetElement("defaultLinkMenu"); var removeOlink = menu.childNodes[0].childNodes[3]; var i; var link; for(i=qb_links.length-1;i>=0;i--){ link = qb_links[i]; if (qb_links[i].id == qb_linkMenuNode && (qb_links[i].condition == 'R' || qb_links[i].condition == 'L' )) { // show remove outer join removeOlink.style.display="block"; } else { // hide remove outer join removeOlink.style.display="none"; } } }