123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| BI and PM: prmt
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- /*
- CPromptButton.js
- This script defines the prompt button object
- */
- //Constructor to create a button component
- // oParent: the button element
- // sType: the type of button (e.g. OK, Cancel, Back, Next, Finish, Reprompt)
- // bEnabled: the initial state of the button (true/false)
- function CPromptButton(oParent, iType, bEnabled, sCVId)
- {
- this.setCVId(sCVId);
- this.m_oParent = oParent;
- this.m_iType = iType;
- this.m_bEnabled = bEnabled;
- this.draw();
- }
- CPromptButton.prototype = new CPromptControl();
- //return the type of button
- function CPromptButton_getType()
- {
- return this.m_iType;
- }
- //change the state of the button
- function CPromptButton_setEnabled(bEnabled)
- {
- this.m_bEnabled = bEnabled;
- this.draw();
- }
- //draw the button in its current state
- function CPromptButton_draw()
- {
- if (typeof this.m_oParent.disabled != K_PRMT_sUNDEFINED)
- {
- if (this.m_bEnabled == false)
- {
- this.m_oParent.disabled = true;
- PRMTUtils.f_removeClass( this.m_oParent, "bph" );
- PRMTUtils.f_addClass( this.m_oParent, "bpd" );
- }
- else
- {
- this.m_oParent.disabled = false;
- PRMTUtils.f_removeClass( this.m_oParent, "bpd" );
- }
-
- // defect 185307; don't need mouseover and mouseout for disabled button
-
- // save generated mouseover and mouseout function in xslt file
- this.m_fParentMouseover = this.m_oParent.onmouseover;
- this.m_fParentMouseout = this.m_oParent.onmouseout;
-
- if (this.m_oParent.disabled)
- {
- this.m_oParent.onmouseover = null;
- this.m_oParent.onmouseout = null;
- }
- else
- {
- this.m_oParent.onmouseover = this.m_fParentMouseover;
- this.m_oParent.onmouseout = this.m_fParentMouseout;
- }
- }
- }
- //Prototypes to assign methods to new instances of the object
- CPromptButton.prototype.getType = CPromptButton_getType;
- CPromptButton.prototype.setEnabled = CPromptButton_setEnabled;
- CPromptButton.prototype.draw = CPromptButton_draw;
- //handle the cancel event, get the back URL from the page if it is available
- //perform a browser back if nothing else can be found
- function promptButtonCancel(s)
- {
- //detect for the existance of a predefined cancel
- //function in the page (e.g. RV or Cognos Connection page)
- //if it exists, call it
- if (typeof cancel != K_PRMT_sUNDEFINED)
- {
- cancel();
- return;
- }
- if ( f_CSW_tryCVPromptAction('cancel',s) )
- {
- return;
- }
- var sBackURL = s;
- if (sBackURL == K_PRMT_sEMPTY)
- {
- //close the window if RV does not have
- //a backURL
- //this function is part of RV
- if (typeof getConfigFrame != K_PRMT_sUNDEFINED)
- {
- var tf = getConfigFrame();
- if (tf)
- {
- var sApp = tf.applicationName;
- if ((sApp == "QS") && (typeof tf.cancelPromptPage != K_PRMT_sUNDEFINED)) {
- tf.cancelPromptPage();
- return;
- }
- else {
- sBackURL = tf.frameBackURL;
- if ((sBackURL==null) || (sBackURL==K_PRMT_sEMPTY))
- {
- tf.close();
- }
- else
- {
- tf.location = sBackURL;
- }
- }
- }
- }
- //check the form for a back URL
- if (typeof document.forms["formWarpRequest"] != K_PRMT_sUNDEFINED)
- {
- var elemBackUrl = document.forms["formWarpRequest"].elements["ui.backURL"];
- if ((typeof elemBackUrl != K_PRMT_sUNDEFINED) && (elemBackUrl.value != K_PRMT_sEMPTY))
- {
- sBackURL = elemBackUrl.value;
- }
- }
- }
- if (sBackURL == K_PRMT_sEMPTY)
- {
- self.history.back();
- }
- else
- {
- self.location = sBackURL;
- }
- }
- //set the action method to go back
- //method=back
- function promptButtonBack()
- {
- if ( f_CSW_tryCVPromptAction('back') )
- {
- return;
- }
- SetPromptContinue('true');
- SetPromptMethod(K_ACTION_BACK);
- SetPromptControl(K_ACTION_PROMPT);
- }
- //set the action method to go next
- //method=forward
- function promptButtonNext()
- {
- if ( f_CSW_tryCVPromptAction('next') )
- {
- return;
- }
- SetPromptContinue('true');
- SetPromptMethod(K_ACTION_FORWARD);
- SetPromptControl(K_ACTION_PROMPT);
- }
- //run the report
- //method=forward
- //prevent further prompt pages
- function promptButtonFinish()
- {
- if ( f_CSW_tryCVPromptAction('finish') )
- {
- return;
- }
- SetPromptContinue('false');
- SetPromptMethod(K_ACTION_FORWARD);
- SetPromptControl(K_ACTION_PROMPT);
- }
- //submit the dialog
- //allow other prompts to show up depending on the user setting for 'prompt'
- //method=forward
- function promptButtonOK()
- {
- if ( f_CSW_tryCVPromptAction('ok') )
- {
- return;
- }
- SetPromptMethod(K_ACTION_FORWARD);
- SetPromptControl(K_ACTION_PROMPT);
- }
- function promptAction(sAction, sArg)
- {
- if ( f_CSW_tryCVPromptAction(sAction, sArg) || f_getPromptRequestSubmitFlag() )
- {
- return false;
- }
- switch(sAction)
- {
- case K_ACTION_BACK:
- promptButtonBack();
- break;
- case K_ACTION_CANCEL:
- promptButtonCancel(sArg);
- break;
- case K_ACTION_NEXT:
- promptButtonNext();
- break;
- case K_ACTION_FINISH:
- promptButtonFinish();
- break;
- case K_ACTION_REPROMPT:
- SetPromptControl(sAction);
- break;
- default:
- promptButtonOK();
- }
- f_setPromptRequestSubmitFlag(true);
- }
- //this function can be called to notify
- //any controls that want to observe the
- //state of page navigation
- function promptButtonNotify()
- {
- if (typeof bVerifyPageNavigation != K_PRMT_sUNDEFINED)
- {
- var bCheckNavigation = bVerifyPageNavigation();
- notifyPageNavEnabled(bCheckNavigation);
- }
- }
- //this function will check to see if all controls are
- //ready for navigation to the next page
- function bVerifyPageNavigation()
- {
- var bFormValid = true;
- if ( typeof preProcessControlArray == K_PRMT_sOBJECT )
- {
- var kCount = preProcessControlArray.length;
- var k = 0;
- for (k=0; k<kCount; k++)
- {
- var promptElement = eval(preProcessControlArray[k]);
- if ((typeof promptElement.getValid == K_PRMT_sFUNCTION) && !promptElement.getValid())
- {
- bFormValid = false;
- break;
- }
- }
- }
- return bFormValid;
- }
- //iterate through all page navigation observers
- //and set their states based on element type
- function notifyPageNavEnabled(bEnabled)
- {
- //broadcast to observers
- if ( typeof pageNavigationObserverArray == K_PRMT_sOBJECT )
- {
- var kCount = pageNavigationObserverArray.length;
- //determine if there is a finish button on the page, if so we'll disable the next.
- var bFinishPresent = false;
- var promptElement = null;
- var promptElementType = null;
- for (var j=0; j<kCount; j++)
- {
- promptElement = eval(pageNavigationObserverArray[j]);
- promptElementType = promptElement.getType();
- if (promptElementType == PROMPTBUTTON_FINISH)
- {
- bFinishPresent = true;
- break;
- }
- }
- for (var k=0; k<kCount; k++)
- {
- promptElement = eval(pageNavigationObserverArray[k]);
- promptElementType = promptElement.getType();
- if (bEnabled == false)
- {
- if ((promptElementType == PROMPTBUTTON_NEXT) || (promptElementType == PROMPTBUTTON_OK) || (promptElementType == PROMPTBUTTON_FINISH))
- {
- promptElement.setEnabled(false);
- }
- }
- else
- {
- if (promptElementType == PROMPTBUTTON_FINISH)
- {
- if (bCanFinish == true)
- {
- promptElement.setEnabled(true);
- }
- else
- {
- promptElement.setEnabled(false);
- }
- }
- else if (promptElementType == PROMPTBUTTON_NEXT)
- {
- if ((bNextPage == false) && (bFinishPresent == true))
- {
- promptElement.setEnabled(false);
- }
- else
- {
- promptElement.setEnabled(true);
- }
- }
- else if (promptElementType == PROMPTBUTTON_OK)
- {
- promptElement.setEnabled(true);
- }
- }
- }
- }
- }
- //constants
- var PROMPTBUTTON_OK = 0;
- var PROMPTBUTTON_CANCEL = 1;
- var PROMPTBUTTON_BACK = 2;
- var PROMPTBUTTON_NEXT = 3;
- var PROMPTBUTTON_FINISH = 4;
- var PROMPTBUTTON_REPROMPT = 5;
|