123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567 |
- /********************************************************************************************************************************
- * Licensed Materials - Property of IBM *
- * *
- * IBM Cognos Products: AGS *
- * *
- * (C) Copyright IBM Corp. 2005, 2014 *
- * *
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
- *********************************************************************************************************************************/
- var x = -1;
- var y = -1;
- var mouseDown = false;
- var previousSubmit = null;
- var launchingStack = null;
- var popUpClosed = false;
- var popUpOpened = true;
- var popUpOpen = false;
- var popUpClosureFlag = false;
- var popUpNextOpenSize = null;
- var resetOM = null;
-
- function mouseDownSpan()
- {
- mouseDown=true;
- x=window.event.x;
- y=window.event.y;
- }
-
- function mouseUpSpan()
- {
- mouseDown = false;
- }
-
- function mouseMoveSpan()
- {
- if (mouseDown) {
- var delx = window.event.x - x;
- var dely = window.event.y - y;
-
- // find the span
- var span = document.getElementById('popUpSpan');
-
- // get the numbers
- var re = /(.*)px/;
- var left = span.style.left.replace(re,"$1");
- var top = span.style.top.replace(re,"$1");
-
- if (left.length == 0) {
- left = "0";
- }
- if (top.length == 0) {
- top = "0";
- }
-
- // move it
- span.style.left = parseInt(left) + delx + "px";
- span.style.top = parseInt(top) + dely + "px";
-
- //save the new pos
- x = window.event.x;
- y = window.event.y;
- }
- }
- function isPopUpFrame(aFrame){
- return aFrame && aFrame.name == 'popUpFrame';
- }
- function popUpIsOpen()
- {
- return popUpOpen;
- }
- function setPopUpState(state)
- {
- popUpOpen = state;
- //Reset the index
- history.startIndex = undefined;
- }
- function doOpenPopUpToSize(width, height)
- {
- //guard clause when the popup is already open
- if(popUpIsOpen()) {
- return;
- }
-
- var popUpFrameElement = parent.document.getElementById('popUpFrame');
- popUpFrameElement.style.display = "inline";
- popUpFrameElement.style.height = "100%";
- popUpFrameElement.style.width = "100%";
- popUpFrameElement.focus();
-
- // show the guard
- var guard = parent.document.getElementById('guard');
- guard.style.display='inline';
-
- // get the span
- var span = parent.document.getElementById('popUpSpan');
- span.style.display='inline';
-
- if(browserCheck.isIE5Up()){
- span.style.width=width + "px";
- span.style.height=height + "px";
- }else{
- span.style.width=width + "px";
- span.style.height=height + "px";
- }
- //span.style.visibility = 'visible';
-
- var our_top;
- var our_width;
-
- if(browserCheck.isIE5Up()){
- our_top = parent.document.body.clientHeight / 2 - height / 2;
- our_width = parent.document.body.clientWidth / 2 - width / 2;
- }else{
- our_top = parent.innerHeight / 2 - height / 2;
- our_width = parent.innerWidth / 2 - width / 2;
- }
-
- span.style.top = our_top;
- span.style.left = our_width;
- //change the z index -
- //Need to pop over the splash screen so makes sure zIndex is hig enough
- span.style.zIndex=20101;
- popUpFrameElement.style.zIndex=20102;
- guard.style.zIndex=2010;
-
- doShim(true);
- // we've opened the pop up
- setPopUpState(popUpOpened);
- }
- function setPopUpNextOpenSize(our_width, our_height){
- popUpNextOpenSize = new Object();
- popUpNextOpenSize.width = our_width;
- popUpNextOpenSize.height = our_height;
- }
- function doOpenPopUp()
- {
- var our_width = "700";
- var our_height = "600";
-
- if(popUpNextOpenSize){
- our_width = popUpNextOpenSize.width;
- our_height = popUpNextOpenSize.height;
- }
-
- var popUpForm = getPopUpFrame().document.forms[0];
-
- if(popUpForm["m"] && popUpForm["m"].value=="prompting/promptDataSource.xts"){
- our_width = "350";
- our_height = "300";
- }
-
- doOpenPopUpToSize(our_width, our_height);
-
- popUpNextOpenSize = null;
- }
- function doOpenPopUpToCurrentSize() {
- //guard clause when the popup is already open
- if(popUpIsOpen()) {
- return;
- }
-
- var popUpFrameElement = parent.document.getElementById('popUpFrame');
- popUpFrameElement.style.display = "inline";
- popUpFrameElement.style.height = "100%";
- popUpFrameElement.style.width = "100%";
-
- // show the guard
- var guard = parent.document.getElementById('guard');
- guard.style.display='inline';
-
- // get the span
- var span = parent.document.getElementById('popUpSpan');
- span.style.display='inline';
- //span.style.visibility = 'visible';
- //change the z index
- //Need to pop over the splash screen so makes sure zIndex is hig enough
- span.style.zIndex=20101;
- popUpFrameElement.style.zIndex=20102;
- guard.style.zIndex=2010;
-
- doShim(true);
- // we've opened the pop up
- setPopUpState(popUpOpened);
- }
- function doSetPopUpClosureFlag()
- {
- popUpClosureFlag = true;
- }
- function doResetPopUpClosureFlag()
- {
- popUpClosureFlag = false;
- }
- function popUpIsFlaggedForClosure()
- {
- return popUpClosureFlag;
- }
- function doClosePopUp()
- {
- //no is open guard here as the prompting pages sometimes leave the
- //pop up frame closure flag and open state out of synch because the prompting reloads
- //pages in the frame and the second time only the frame onload gets called
- //and it needs to be closed, but is already open
- var guard = document.getElementById('guard');
- //guard.style.display='none';
- var span = document.getElementById('popUpSpan');
- if (!document.all) {
- span.style.display='none';
- }
- var popUpFrameElement = parent.document.getElementById('popUpFrame');
-
- // we've closed the pop_up
- setPopUpState(popUpClosed);
- // reset the closure flag
- popUpClosureFlag = false;
- launchingStack = null;
- applicationActionManager.allowActions();
-
- //hide the popup by setting the zindex so that the message is displayed on top
- //Need to pop over the splash screen but now zIndex need to be changed back.
- span.style.zIndex=-20101;
- //span.style.visibility = 'hidden';
-
- popUpFrameElement.style.zIndex=-20102;
- guard.style.zIndex=-2010;
- doShim(false);
- }
- function utmlClosePopUp()
- {
- var ret_value = false;
- var popUpFrame = getPopUpFrame();
- var popUpFrameContentDocument = getFrameDocument(popUpFrame);
- var popUpForm = popUpFrameContentDocument.forms[0];
- if (popUpForm.ps_nav_op &&
- (popUpForm.ps_nav_op.value=='stack-down' ||
- popUpForm.ps_nav_op.value=='stack-down-save' ||
- popUpForm.ps_nav_op.value=='drop' ||
- popUpForm.ps_nav_op.value=='pop') &&
- popUpForm.ps_nav_stack &&
- popUpForm.ps_nav_stack.value == launchingStack) {
- // we can close the pop up
- ret_value = true;
- }
- return ret_value;
- }
- function controllerTemplateClosePopUp()
- {
- var ret_value = false;
- var popUpFrame = getPopUpFrame();
- var popUpFrameContentDocument = getFrameDocument(popUpFrame);
- var popUpForm = popUpFrameContentDocument.forms[0];
-
- if (popUpForm.controller_state) {
- // get the controller state
- var controller_state_value = popUpForm.controller_state.value;
- var controller_state_popup_override_value = 'false';
- var cf = parent.getConfigFrame();
- if(cf){
- controller_state_popup_override_value = cf.cfgGet("controller_state_popup_override");
- }
-
- // check to see if we end in finished or ok
- var finished_re = /.*finished$/;
- var cancelled_re = /.*canceled$/;
- if ( (controller_state_value.match(finished_re) ||
- controller_state_value.match(cancelled_re)) && controller_state_popup_override_value != 'true') {
- // we're closing
- ret_value = true;
- }
- }
- return ret_value;
- }
- function popUpFrameSubmitHandler()
- {
- //return false;
- processPopUpSubmit();
- }
- function resetToOriginalPage() {
- history.go(history.loginIndex);
- getCommandStackManager().processCommandStack();
- }
- function processPopUpSubmit() {
- // have to get this in different ways for different browsers
- var popUpFrame = getPopUpFrame();
- var popUpFrameContentDocument = getFrameDocument(popUpFrame);
- var popUpForm = popUpFrameContentDocument.forms[0];
- var target = popUpForm.target;
- //Are we closing the popup?
- var closingPopUp = (controllerTemplateClosePopUp() || utmlClosePopUp());
- // where are we going
- if (closingPopUp) {
- //Alter the destination XTS and keep track of original destination
- //append this information to the form, and submit.
-
- var m = popUpForm.m;
- var original_m = m.value;
- m.value = "/ags/doLoginProxy.xts";
- //Create hidden inputs
- var o_m_input = createHiddenInput(popUpFrameContentDocument,"original_m",original_m);
- var orig_input = createHiddenInput(popUpFrameContentDocument,"origin","popUpFrame");
- //append to form
- popUpForm.appendChild(o_m_input);
- popUpForm.appendChild(orig_input);
- //stay in the same frame
- target = "";
- } else {
- // Don't allow the form to submit to the _parent which is our main window, otherwise it
- // will blow away agent studio.
- //
- target = popUpForm.target=="_parent"?"messageIFrame":popUpForm.target;
- }
- var sessionExpired = (popUpForm.h_CAM_action && popUpForm.h_CAM_action.value.indexOf(K_logon) == 0) ? true : false;
- if (sessionExpired) {
- if(history.startIndex == undefined || history.startIndex < 0) {
- //Have a logon fault, and it is the first
- //time we see it so start the marker in history.
- history.startIndex = 0;
- } else {
- history.startIndex++;
- }
- } else {
- //We are logged in so remove the marker
- history.startIndex = undefined;
- }
- popUpForm.target = target;
- // call the original submit
- popUpForm.submit = previousSubmit;
- popUpForm.submit();
- // Restore our submit handler hook!! Incase the user clicks on the submit button more than once!!
- popUpForm.submit = popUpFrameSubmitHandler;
- }
- function setResetOM(omValue)
- {
- resetOM = omValue;
- }
- function popUpFrameOnLoad()
- {
- // have to get this in different ways for different browsers
- var popUpFrame = getPopUpFrame();
- var popUpFrameContentDocument = getFrameDocument(popUpFrame);
- var popUpHeight="600";
- var popUpWidth="700";
- var resize = true;
-
- if (popUpFrameContentDocument.forms && popUpFrameContentDocument.forms.length > 0) {
- var popUpForm = popUpFrameContentDocument.forms[0];
-
- //register a key down handler to detect changes
- eventHandlerChainUtil.doEventHandlerChain(popUpFrameContentDocument,"keydown",keyDownChecker.check);
-
- //Bug: 503051. A fix to set the form size to a reasonable dimesnions to fit in the popup frame.
- //Works for IE and firefox. IE seems to default to a minimum size that we can not go beyond.
- if (popUpForm["ui.action"] && popUpForm["ui.action"].value=="wait" && popUpForm["m"] && popUpForm["m"].value=="prompting/promptDataSource.xts") {
- popUpHeight = "200";
- popUpWidth = "280";
- }
- //check if the height and width have been explicitly set
- else {
- if (popUpForm["popUpHeight"] && popUpForm["popUpHeight"].value != "") {
- popUpHeight = popUpForm["popUpHeight"].value;
- resize = false;
- }
- if (popUpForm["popUpWidth"] && popUpForm["popUpWidth"].value != "") {
- popUpWidth = popUpForm["popUpWidth"].value;
- resize = false;
- }
- }
- // find the form
- previousSubmit = popUpForm.submit;
-
- //install our own onSubmit
- popUpForm.submit = popUpFrameSubmitHandler;
- if (!popUpIsOpen() && !popUpIsFlaggedForClosure()) {
- // open up the pop up
- doOpenPopUpToSize(popUpWidth, popUpHeight);
- }else if(popUpIsFlaggedForClosure()){
- doClosePopUp();
- parent.document.getElementById("messageIFrame").focus();
- return;
- }
- // keep the stack value if this is the first load
- if(!launchingStack && popUpForm.ps_nav_stack){
- // keep a copy of the nav_stack here too
- launchingStack = popUpForm.ps_nav_stack.value;
- }
-
- //bug#CQ00210567 logon screen was partially displayed after
- //session expiry in Event studio.
-
- if(isLogonPage(popUpForm)){
- popUpWidth = "100%";
- popUpHeight = "100%";
- setPopUpSize(popUpWidth, popUpHeight);
- resize = false;
- }
- //only resize if height and width not passed to popup frame
- if (resize) {
- resizePopUp();
- }
- }
- }
- function isLogonPage(popUpForm) {
- // look for : <input type="hidden" name="h_CAM_action" value="logonAs">
- if (popUpForm["h_CAM_action"]) {
- return popUpForm["h_CAM_action"].value.indexOf('logon')==0;
- }
- else {
- return false;
- }
- }
- function setPopUpSize(width, hight) {
-
- var span = parent.document.getElementById('popUpSpan');
- span.style.top = 0;
- span.style.left =0;
- span.style.width = width;
- span.style.height = hight;
-
- doShim(true);
- }
- function resizePopUp() {
-
- var popUpFrameElement = parent.document.getElementById('popUpFrame');
- var span = parent.document.getElementById('popUpSpan');
- var windowWidth = (!document.all)?window.innerWidth:document.body.clientWidth;
- var windowHeight = (!document.all)?window.innerHeight:document.body.clientHeight;
- var iMaxWidth = Math.round(windowWidth * 0.70);
- var iMaxHeight = Math.round(windowHeight * 0.90);
- var iWidth = 0;
- var iHeight = 0;
-
- //span.style values can not be used as they are treated as strings, and also
- //"px" will be added to the end of them
- var issW = 0;
- var issH = 0;
- var popUpFrame = getPopUpFrame();
- var popUpFrameContentDocument = getFrameDocument(popUpFrame);
-
- if (document.all) {
- iWidth = popUpFrameContentDocument.body.scrollWidth + 20;
- iHeight = popUpFrameContentDocument.body.scrollHeight + 15;
- } else {
- iWidth = popUpFrameContentDocument.body.offsetWidth + 50;
- iHeight = popUpFrameContentDocument.body.offsetHeight + 40;
- }
- //Defualt is 700X600 if the main window is smaller
- //than the popup we then use default values.
- if (iWidth < windowWidth) {
- iWidth = iWidth > iMaxWidth?iMaxWidth:iWidth;
- issW = iWidth;
- }
- else {
- issW = iMaxWidth;
- }
-
- //only set the left we are talking horizontaly
- if (issW < windowWidth) {
- span.style.left = (windowWidth - issW ) / 2;
- } else {
- span.style.left = 250;
- }
- if (iHeight < windowHeight) {
- iHeight = iHeight > iMaxHeight?iMaxHeight:iHeight;
- issH = iHeight;
- }
- else {
- issH = iMaxHeight;
- }
-
- //maintain an aspect ratio
- issH = (issH > (issW * 1.2)) ? issW * 1.2 : issH;
-
- //only set the top we are talking verticaly
- if (issH < windowHeight) {
- span.style.top = (windowHeight - issH) / 2;
- } else {
- span.style.top = 200;
- }
-
- span.style.width = issW + "px";
- span.style.height = issH + "px";
- if (document.all) {
- popUpFrameContentDocument.forms[0].style.width=issW-4;
- } else {
- popUpFrameContentDocument.body.style.width="100%";
- popUpFrameContentDocument.body.style.height="100%";
- }
- popUpFrameContentDocument.body.style.margin = "0";
- popUpFrameContentDocument.body.style.padding = "0";
- doShim(true);
- }
- // to enable the pop up div to float above selects
- //we must put a rabbish div beneath the span that surrounds our
- //proper iframe!
- function doShim(bShow){
- var popUpFrameShim = parent.document.getElementById('popUpShim');
- var span = parent.document.getElementById('popUpSpan');
-
- if(bShow){
- popUpFrameShim.style.top = span.style.top;
- popUpFrameShim.style.left = span.style.left;
- popUpFrameShim.style.height = span.offsetHeight;
- popUpFrameShim.style.width = span.offsetWidth;
- //popUpFrameShim.style.display = "block";
- //Need to pop over the splash screen so make sure zIndex is hig enough
- popUpFrameShim.style.zIndex=20100;
- }else{
- //popUpFrameShim.style.display = "none";
- popUpFrameShim.style.zIndex=-20100;
- }
- }
|