var PopMasterWin; var PopMasterFormObject; function PopMaster(FormObject, Parameters, CustomWhere, OpenWinOrIFrame, FormFieldNameFull='') { // alert("Parameters="+Parameters+", CustomWhere="+CustomWhere); var AllParameters = Parameters.split(","); var i=0; var OneParameter; // document.forms[0].AssignedTo, 'Entity=User,UsernameName like AssignedToName%,Row=3,Multiple' var PopEntity=""; var PopProperty=""; var PopValue=""; var PopEquality=""; var PopValuePrefix=""; var PopValueSuffix=""; var PopRow=""; var PopMultipleYN="N"; var PopFormField = FormObject.name; var PopForm = FormObject.form.name; for(i=0; i400) { PopMasterWinHeight = 400;} PopMasterWin.resizeTo(PopMasterWin.document.body.scrollWidth+PopMasterWin.outerWidth-PopMasterWin.innerWidth, PopMasterWinHeight); } window.setTimeout("FocusMe();", 1000); } else if(OpenWinOrIFrame=="IFrame") { ClosePopMasterIFrame(); // earlier opened and not closed. if(document.getElementById("IFramePopMaster")) { var IFramePopMaster=document.getElementById("IFramePopMaster"); var DivPopMaster=document.getElementById("DivPopMaster"); } else { var IFramePopMaster=document.createElement('iframe'); IFramePopMaster.id='IFramePopMaster'; // IFramePopMaster.style.width="100%"; // IFramePopMaster.style.height="100%"; var DivPopMaster=document.createElement('div'); DivPopMaster.id="DivPopMaster"; DivPopMaster.style.display='none';//Just now, will be made visible after it's READY DivPopMaster.style.opacity='0.1'; DivPopMaster.classList.add("Shadow"); DivPopMaster.style.transition='opacity 1s ease'; DivPopMaster.style.left='100px'; // Factory default! DivPopMaster.style.top='100px'; DivPopMaster.style.position='absolute'; DivPopMaster.style.zIndex='100'; DivPopMaster.style.height='400px'; DivPopMaster.style.width='700px'; DivPopMaster.style.borderTop='1px solid white'; DivPopMaster.style.borderLeft='1px solid #267CB5'; DivPopMaster.style.borderRight='1px solid #267CB5'; DivPopMaster.style.borderBottom='1px solid #267CB5'; var TablePopMaster=document.createElement('table'); TablePopMaster.id="TablePopMaster"; TablePopMaster.style.cellSpacing='0'; TablePopMaster.style.cellPadding='0'; TablePopMaster.style.border='1'; TablePopMaster.style.backgroundColor='#267CB5'; var TR=document.createElement('tr'); var TD=document.createElement('td'); TD.classList.add("Header"); TD.id="PopMasterTitle"; TD.style.height='25px'; TD.style.color='white'; TD.style.backgroundColor='#267CB5'; TD.style.width='100%'; TR.appendChild(TD); TD=null; TD=document.createElement('td'); TD.style.width='10'; TD.style.height='12'; TD.style.textAlign='right'; TD.style.verticalAlign='top'; TD.style.paddingLeft='0px'; TD.style.paddingRight='0px'; TD.classList.add("Header"); TD.style.backgroundColor='#267CB5'; var A=document.createElement('a'); A.href="javascript:ClosePopMasterIFrame();"; A.style.textDecoration='none'; A.style.color='red'; A.innerHTML='❎'; TD.appendChild(A); TR.appendChild(TD); TablePopMaster.appendChild(TR); DivPopMaster.appendChild(TablePopMaster); DivPopMaster.appendChild(IFramePopMaster); document.body.appendChild(DivPopMaster); } // IFramePopMaster.contentWindow.location.href=PopMasterURL; IFramePopMaster.src=PopMasterURL; var TD=document.getElementById("PopMasterTitle"); TD.innerHTML='Select '+PopEntity; PopMasterFormObject=FormObject; window.setTimeout("PlacePopMaster();", 500); } // OpenWinOrIFrame=="IFrame") { } function PlacePopMaster() { var FormObjectRect=PopMasterFormObject.getBoundingClientRect(); // ViewPort var BodyRect=document.body.getBoundingClientRect(); // "ground" reference var DivPopMaster=document.getElementById("DivPopMaster"); var TD=document.getElementById("PopMasterTitle"); // Ideally the code below should lie within a Promise var DivPopMasterX=FormObjectRect.x+FormObjectRect.width-BodyRect.x+10; console.log(DivPopMasterX); console.log(window.innerWidth/2); DivPopMaster.style.display='inline-block'; // Otherwise "width" is ZERO if(DivPopMasterX < window.innerWidth/2) { DivPopMaster.style.left=DivPopMasterX+"px"; DivPopMaster.style.top=(FormObjectRect.y-BodyRect.y)+"px"; } else { console.log(document.getElementById("DivPopMaster").getBoundingClientRect().width); var DivPopMasterStyleLeft=DivPopMasterX-DivPopMaster.getBoundingClientRect().width; if(DivPopMasterStyleLeft<0) { DivPopMasterStyleLeft=0; } DivPopMaster.style.left=DivPopMasterStyleLeft+"px"; DivPopMaster.style.top=(FormObjectRect.y-BodyRect.y+FormObjectRect.height)+"px"; } IFramePopMaster.style.width="100px"; // Important. Provides initial baseline. IFramePopMaster.style.height="100px"; // Important. Provides initial baseline. IFramePopMaster.style.left="100px"; // Important. Provides initial baseline. IFramePopMaster.style.top="100px"; // Important. Provides initial baseline. DivPopMaster.style.width="100px"; DivPopMaster.style.height="100px"; window.setTimeout("ResizePopMaster();", 500); } function ResizePopMaster() { var MaxHeight=500; var MaxWidth=800; Height=MaxHeight; if(IFramePopMaster.contentWindow.document.body.scrollHeight window.innerWidth/2) { var DivPopMasterStyleLeft=DivPopMasterX-DivPopMaster.getBoundingClientRect().width; if(DivPopMasterStyleLeft<0) { DivPopMasterStyleLeft=0; } DivPopMaster.style.left=DivPopMasterStyleLeft+"px"; } DivPopMaster.style.opacity='1'; } function ClosePopMasterIFrame() { if(document.getElementById("PopMasterTitle")) document.getElementById("PopMasterTitle").innerHTML=''; if(document.getElementById("DivPopMaster")) { document.getElementById("DivPopMaster").style.display='none'; document.getElementById("DivPopMaster").style.opacity='0'; } } function FocusMe() { if(PopMasterWin) { PopMasterWin.focus(); } }