123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| BI and PM: prmt
- *| (C) Copyright IBM Corp. 2002, 2020
- *|
- *| US Government Users Restricted Rights - Use, duplication or
- *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *|
- *+------------------------------------------------------------------------+
- */
- /**
- @private
- @class
- */
- cognos.Prompt.Control.Search = cognos.Prompt.Control.f_extend({
- f_initialize: function( v_oProps )
- {
- this._type_ = "cognos.Prompt.Control.Search";
- this.f_parent( v_oProps ); // call parent's initialize()
- this.m_sCacheDelimiter = "\n";
- this.f_initCompleted();
- },
- checkData: function()
- {
- this.f_parent(); // call parent's checkData
- var v_aPV = ( this.m_oChoices ? this.m_oChoices.f_getPV() : this.f_getPV() );
- var values = ( v_aPV && v_aPV.length > 0 );
- if ( this.isRequired() && !values )
- {
- this.m_bValid = false;
- this.checkFail();
- }
- else
- {
- this.m_bValid = true;
- this.checkPass();
- }
-
- if (this.m_bValid)
- {
- this.cacheControlValue(this._type_);
- }
- return this.m_bValid;
- },
- clearValues: function()
- {
- this.f_parent();
- this.f_clearResults();
- },
- f_drawCompleted: function()
- {
- // We keep a reference to the parent function.
- var v_fnParent = this.f_parent;
- var v_oResults = this.m_oResults;
- if ( v_oResults )
- {
- v_oResults.f_drawCompleted();
- }
- // call parent's checkData using saved reference.
- this.f_parent = v_fnParent;
- this.f_parent();
- var v_inputId = this.f_getId("swsInput");
- var v_input = this.$( v_inputId );
- if ( typeof Search_DisableEnterKeyAutoSubmit != K_PRMT_sUNDEFINED && Search_DisableEnterKeyAutoSubmit !== true )
- {
- PRMTUtils.f_addEvent( v_input, "keydown", this.f_keyDownHandler.bind(this) );
- }
- if ( G_IsBidiEnabled && this["@contentTextDirection"] )
- {
- PRMTUtils.f_addEvent( v_input, "keyup", this.f_keyUpHandler.bind(this) );
- }
- var v_elImg = this.$( this.f_getId("imgAdvancedArrow") );
- if (v_elImg)
- {
- var v_td = v_elImg.parentNode;
- if ( this[K_PRMT_sATTR_DISABLED] )
- {
- v_td.setAttribute( "disabled", "disabled" );
- }
- else
- {
- var v_elContainer = this.$( this.f_getId("idAdvancedOptions") );
- PRMTUtils.f_addEvent( v_elImg.parentNode, "click", this.f_toggleOptions.bind(this) );
- }
- }
- var v_btnSearch = this.$( this.f_getId("searchButton") );
- PRMTUtils.f_addEvent( v_btnSearch, "click", this.f_search.bind(this) );
- this.f_setDefaultSelection();
- if ( G_IsBidiEnabled && this["@contentTextDirection"] ) {
- v_input.style.direction = PRMT_BidiUtils.getTextDirection(v_input.value, this["@contentTextDirection"]);
- }
- // link a11y label if it exists using FOR
- var v_a11yLabel = this.$( this.f_getId("PRMT_LBL_") );
- if ( v_a11yLabel && !v_a11yLabel.getAttribute("for")) {
- v_a11yLabel.setAttribute("for", v_inputId);
- }
- this.processAriaRequired();
- // focus Search and Select control editbox and searchButton
- var oCV = this.f_getCV();
- if (oCV && typeof oCV.getCurrentPromptControlFocus == K_PRMT_sFUNCTION){
- if (this["@name"] == oCV.getCurrentPromptControlFocus()) {
- var v_input = this.$( v_inputId );
- v_input.focus();
- oCV.setCurrentPromptControlFocus(null);
- }
- if (this["@name"] + "_searchButtonfocus" == oCV.getCurrentPromptControlFocus()) {
- v_btnSearch.focus();
- oCV.setCurrentPromptControlFocus(null);
- }
- }
- }
- });
- /**
- * If the prompt value is Required add the tag aria-required to the right element
- *
- See {@link cognos.Prompt.Control.addValues} for more info.
- @param {cognos.Value[]}
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.processAriaRequired = function( ) {
- if ( !this.isMulti() ) {
- if (this.m_oResults.isRequired()) {
- this.m_oResults.setAriaRequired();
- }
- }
- };
- /**
- See {@link cognos.Prompt.Control.addValues} for more info.
- @param {cognos.Value[]}
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.addValues = function( aValues )
- {
- if (this.m_oChoices)
- {
- this.m_oChoices.addValues( aValues );
- }
- else
- {
- var v_iLimit = ( this.isMulti() ? aValues.length : 1);
- this.cachedResults = this.buildCachedResults();
- for (var v_idx = 0; v_idx < v_iLimit; v_idx++)
- {
- var v_oValue = aValues[v_idx];
- this.f_addResults( v_oValue[K_PRMT_sUSE], v_oValue[K_PRMT_sDISPLAY], true );
- }
- delete this.cachedResults;
- this.cachedResults = null;
- // We need to enforce Bidi text direction
- if ( G_IsBidiEnabled && this["@contentTextDirection"] ) {
- this.m_oResults.f_drawCompleted();
- }
- }
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.buildCachedResults = function()
- {
- var cache = {};
- var v_aOptions = this.m_oResults.m_elPrompt.options;
- for (var i = 0; i < v_aOptions.length; i++) {
- var v_opt = v_aOptions[i];
- cache[ v_opt.value + this.m_sCacheDelimiter + v_opt.getAttribute("dv") ] = v_opt;
- }
- return cache;
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_addResults = function(v_sUse, v_sDisplay, v_bSelected)
- {
- var v_opt = (this.cachedResults ? this.cachedResults[v_sUse + this.m_sCacheDelimiter + v_sDisplay] : this.f_getOption( v_sUse, v_sDisplay ));
- if ( !v_opt )
- {
- v_opt = new Option( v_sDisplay, v_sUse );
- v_opt.setAttribute("dv", v_sDisplay );
- var v_elOptions = this.m_oResults.m_elPrompt.options;
- v_elOptions[v_elOptions.length] = v_opt;
- if (this.cachedResults) {
- this.cachedResults[v_sUse + this.m_sCacheDelimiter + v_sDisplay] = v_opt;
- }
- }
- if ( v_bSelected )
- {
- v_opt.selected = true;
- }
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_clearResults = function()
- {
- var v_oResults = this.m_oResults;
- if ( v_oResults )
- {
- v_oResults = v_oResults.m_elPrompt;
- while (v_oResults.hasChildNodes()) {
- v_oResults.removeChild(v_oResults.firstChild);
- }
- }
- };
- /**
- Sets the JavaScript references used by custom scripts based on generated code from Blaring and before.
- (Custom Scripts Workaround)
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_CSW_init = function()
- {
- this.f_CSW_createJSObject( "search" );
- };
- /**
- @private
- @param {C_PromptElement} v_el Container.
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_drawInput = function( v_el )
- {
- var v_sPrefix = K_PRMT_sEMPTY;
- var v_tbl = $CE( "table", {"border": K_PRMT_DEBUG_TABLEBORDER, "cellPadding":0, "cellSpacing":0,"role":K_PRMT_ARIA_ROLE_PRESENTATION}, v_el );
- var v_tbd = $CE( "tbody", {}, v_tbl );
- var v_tr = $CE( "tr", {}, v_tbd );
- var v_inputId = this.f_getId( "swsInput" );
- var v_td = $CE( "td", {"class": "clsControlLabel pc"}, v_tr );
- var v_keywordsLabel = $CE( "label", { "for": v_inputId }, v_td );
- v_keywordsLabel.f_appendText( this[K_PRMT_LABEL_SEARCH_KEYWORDS] );
- v_tr = $CE( "tr", {}, v_tbd );
- v_td = $CE( "td", {"class": "clsDialogIntroduction pi"}, v_tr );
- var v_descId = this.f_getId( "swsInputDesc" );
- v_td = $CE( "div", {"id": v_descId}, v_td );
- v_td.f_appendText(this[K_PRMT_LABEL_SEARCH_INSTRUCTIONS_TEXT]);
- // Search criteria & button
- v_tr = $CE( "tr", {}, v_tbd );
- v_td = $CE( "td", {}, v_tr );
- var v_tblCriteria = $CE( "table", {"border": K_PRMT_DEBUG_TABLEBORDER, "cellPadding":0, "cellSpacing":0, "role":K_PRMT_ARIA_ROLE_PRESENTATION}, v_td );
- var v_tbdCriteria = $CE( "tbody", {}, v_tblCriteria );
- v_tr = $CE( "tr", {}, v_tbdCriteria );
- v_td = $CE( "td", {}, v_tr );
- var v_ipt = $CE( "input", {
- "id": v_inputId,
- "type": "text",
- "name": v_sPrefix + "_searchValue",
- "class": "clsSwsEditBox",
- "aria-describedby" : v_descId,
- "aria-required" : (this.isRequired() ? "true" : "false"),
- "onkeydown": "return (event.keyCode!=13);",
- "value": ( typeof this["@searchValue"] != K_PRMT_sUNDEFINED ? this["@searchValue"] : K_PRMT_sEMPTY )
- }, v_td );
- this.f_setStyle( v_ipt, "swsEditBox" );
- v_td = $CE( "td", {nowrap:"nowrap"}, v_tr );
- var v_btn = $CE( "button", {
- "type": "button",
- "name": this.f_getId("searchButton"),
- "id": this.f_getId("searchButton"),
- "class": "clsPromptButton",
- "onMouseOver": "this.className = 'clsPromptButtonOver';",
- "onMouseOut": "this.className = 'clsPromptButton';"
- }, v_td );
- this.f_setStyle( v_btn, "swsSearchButton" );
- if ( this[K_PRMT_sATTR_DISABLED] )
- {
- v_ipt.f_setProperty( "disabled", "disabled" );
- v_btn.f_setProperty( "disabled", "disabled" );
- }
- v_btn.f_appendText( this[K_PRMT_LABEL_SEARCH_BTN_LABEL] );
- var v_img = $CE( "img", {
- "src": this.m_sSkin + "/prompting/images/prompt_search.gif",
- "name": this.f_getId( "imgBusy" ),
- "id": this.f_getId( "imgBusy" ),
- "alt": K_PRMT_sEMPTY,
- "border": "0",
- "height": "16",
- "width": "15",
- "align": "top"
- }, v_btn );
- // options links
- v_tr = $CE( "tr", {}, v_tbd );
- v_td = $CE( "td", {"vAlign": "top", "class": "clsOptions pe", "style": "padding:3px;"}, v_tr );
-
- var v_fieldSet = $CE( "fieldset", {"style":"border:0; margin-top:3px; margin-left:0px; padding:0px"}, v_td );
- var v_optionsContainerId = this.f_getId("idAdvancedOptions");
- var v_optionsLegendId = this.f_getId("idSearchOptionsLegend");
- var v_legend = $CE( "legend", {"id": v_optionsLegendId, "aria-controls": v_optionsContainerId, "role": "button", "aria-expanded": false}, v_fieldSet );
- var v_linksSpan = $CE( "span", { "style": "padding:0px; margin: 0px;"}, v_legend );
- // Use a link, to be a tab stop.
- var v_a = $CE( "a", { "class": "clsLink pl", "href": "javascript:;", "onclick": "document.location.hash='';" }, v_linksSpan );
- v_a.f_appendText( this[K_PRMT_LABEL_SEARCH_OPTIONS_TEXT] );
- var v_sCustomDir = cssParser( this["@style"], "direction", true );
- var v_sFinalDir = ((v_sCustomDir == "ltr" || v_sCustomDir == "rtl") ? v_sCustomDir : PRMT_BidiUtils.lookupDirection(this.$( this.f_getId(this.m_sDivPrefix) )));
- v_img = $CE( "img", {
- "id": this.f_getId("imgAdvancedArrow"),
- "class" : "clsSearchOptionsExpand",
- "src": this.m_sSkin + "/prompting/images/blank.gif",
- "border": "0",
- "alt": K_PRMT_sEMPTY,
- "align": "top",
- "style": (v_sFinalDir == "rtl" ? "margin-right: 5px" : "margin-left: 5px")
- }, v_linksSpan );
- // Options
- var v_div = $CE( "div", {"class": "clsSwsOptions pe"}, v_fieldSet );
- this.m_bShowOptions = ( this["@showOptions"] === true );
- var v_tblOptions = $CE( "table", {
- "id": v_optionsContainerId,
- "border": K_PRMT_DEBUG_TABLEBORDER,
- "style": ( this.m_bShowOptions ? K_PRMT_sEMPTY : "display:none" ),
- "role":K_PRMT_ARIA_ROLE_PRESENTATION
- }, v_div );
- var v_tbdOptions = $CE( "tbody", {}, v_tblOptions );
- var v_nStyle = this.getChildByName("swsOptions");
- var v_sOptionStyle = ( v_nStyle && v_nStyle["@style"] ? v_nStyle["@style"] : K_PRMT_sEMPTY );
- this.f_drawOption( v_tbdOptions, "swsStartAny", PMT_SSM_STARTANY, v_sOptionStyle, ( !this["@matchAnywhere"] && !this["@matchAll"] ) );
- this.f_drawOption( v_tbdOptions, "swsStartAll", PMT_SSM_STARTALL, v_sOptionStyle, ( !this["@matchAnywhere"] && this["@matchAll"] ) );
- this.f_drawOption( v_tbdOptions, "swsMatchAny", PMT_SSM_CONTAINANY, v_sOptionStyle, ( this["@matchAnywhere"] && !this["@matchAll"] ) );
- this.f_drawOption( v_tbdOptions, "swsMatchAll", PMT_SSM_CONTAINALL, v_sOptionStyle, ( this["@matchAnywhere"] && this["@matchAll"] ) );
- this.f_drawOption( v_tbdOptions, "swsCaseInsensitive", PMT_SSM_CASEINSENSITIVE, "padding-top:10px;" + v_sOptionStyle, this["@caseInsensitiveIsDefault"], true );
- if ( this["@noResultsFound"] )
- {
- $CE("div", {
- "style": "margin: 5px;white-space:nowrap;",
- "tabindex": "0"
- }, v_el).f_appendText( PMT_SSM_NORESULTSFOUND );
- }
- };
- /**
- @private
- @param {C_PromptElement} v_el Container.
- @param {C_PromptElement} v_tdLayout Container.
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_drawResultList = function( v_el, v_tdLayout )
- {
- var v_sel = $CE( "select", {
- "id": this.f_getId(K_PRMT_sSV_PREFIX),
- "size": 3,
- "aria-required" : (this.isRequired() ? "true" : "false"),
- "multiple": "multiple"
- }, v_tdLayout );
- var v_oSV = {};
- v_oSV._type_ = null;
- v_oSV.n = "selectValue";
- v_oSV["@selectValueUI"] = "listBox";
- v_oSV["@required"] = ( this.isRequired() && !this.isMulti() );
- v_oSV["@multiSelect"] = this["@multiSelect"];
- v_oSV[K_PRMT_sATTR_DISABLED] = this[K_PRMT_sATTR_DISABLED];
- v_oSV["@style"] = cssParser(this["@style"], "color,font,text,direction");
- v_oSV["@contentTextDirection"] = this["@contentTextDirection"];
- if ( this.isMulti() )
- {
- v_oSV["@listSize"] = 9;
- }
- v_oSV._id_ = this.f_getId();
- v_oSV.m_bIsAComponent = true;
- v_oSV.m_oOwner = this;
- v_oSV[K_PRMT_LABEL_RESULTS_SELECT_ALL] = this[K_PRMT_LABEL_RESULTS_SELECT_ALL];
- v_oSV[K_PRMT_LABEL_RESULTS_DESELECT_ALL] = this[K_PRMT_LABEL_RESULTS_DESELECT_ALL];
- v_oSV[K_PRMT_LABEL_DESELECT] = this[K_PRMT_LABEL_DESELECT];
- var v_oResultsList = new cognos.Prompt.Control.SelectValue( v_oSV );
- var v_sListStyle = this.f_getStyleForNode("swsResultsListbox");
- if ( v_sListStyle )
- {
- v_oResultsList["@listStyle"] = v_sListStyle;
- }
- if (typeof SYSTEMPROPERTY_CSEARCH_AUTO_RESIZE_RESULT_LIST == K_PRMT_sUNDEFINED || !SYSTEMPROPERTY_CSEARCH_AUTO_RESIZE_RESULT_LIST)
- {
- v_oResultsList["@style"] += ";width:200px;";
- }
- var v_elResults =v_oResultsList.f_drawInput( v_el );
- this.m_oResults = v_oResultsList;
- };
- /**
- Renders the layout of the control: position lists, adornments and control inputs.
- @private
- @param {C_PromptElement} v_trLayout Container for this control.
- @return {C_PromptElement}
- */
- cognos.Prompt.Control.Search.prototype.f_drawLayout = function( v_trLayout )
- {
- var v_tdLayout = $CE( "td", {}, v_trLayout );
- var v_oPrompt = this.f_drawInput( v_tdLayout );
- var v_tbl = $CE( "table", {"border": K_PRMT_DEBUG_TABLEBORDER, "cellPadding":0, "cellSpacing":0, "role":K_PRMT_ARIA_ROLE_PRESENTATION}, v_tdLayout );
- if ( this[K_PRMT_sATTR_DISABLED] )
- {
- v_tbl.f_setProperty( "disabled", "disabled" );
- }
- var v_tbd = $CE( "tbody", {}, v_tbl );
- var v_tr = $CE( "tr", {}, v_tbd );
- var v_resultListId = this.f_getId(K_PRMT_sSV_PREFIX);
- if ( this.isMulti() )
- {
- var v_td1 = $CE( "td", {}, v_tr );
- var v_div1 = $CE( "div", {"vAlign":"top", "class": "clsControlLabel pc"}, v_td1 );
- var v_choiceLabel = $CE( "label", { "for": v_resultListId }, v_div1 );
- v_choiceLabel.f_appendText( this[K_PRMT_LABEL_SEARCH_RESULTS_TEXT] );
- var v_sDivStyle = this.f_getStyleForNode( "swsResultsHeader" );
- if ( v_sDivStyle )
- {
- v_div1.f_setProperty( "style", v_sDivStyle );
- }
- this.f_drawResultList( v_td1, v_tdLayout );
- if ( cssParser( this["@style"], "width" ) )
- {
- v_td1.f_setProperty( "width", "100%" );
- v_tbl.f_setProperty( "width", "100%" );
- v_td.f_setProperty( "width", "100%" );
- }
- var v_oChoices = new C_Choices( this );
- v_oChoices["@listSize"] = 9;
- var v_aMO = this.f_getCV().multipleObserverArray;
- if (v_aMO) {
- v_aMO.push( v_oChoices );
- }
- if (typeof SYSTEMPROPERTY_CSEARCH_AUTO_RESIZE_RESULT_LIST == K_PRMT_sUNDEFINED || !SYSTEMPROPERTY_CSEARCH_AUTO_RESIZE_RESULT_LIST)
- {
- v_oChoices["@listWidth"] = "200px";
- }
- var v_sListStyle = this.f_getStyleForNode( "swsChoicesListbox" );
- if ( v_sListStyle )
- {
- v_oChoices["@listStyle"] = v_sListStyle;
- }
- v_oChoices.F_Draw( v_tr );
- this.m_oChoices = v_oChoices;
- }
- else
- {
- var v_td1 = $CE( "td", {"vAlign":"top", "class": "clsControlLabel pc"}, v_tr );
- if ( this.isRequired() && !this["@hideAdornments"] )
- {
- var v_imgReq = $CE( "img", {
- "src": this.m_sSkin + "/prompting/images/icon_required.gif",
- "class": "clsErrorRequired",
- "vAlign": "top",
- "height": 10,
- "width": 10,
- "border": 0
- }, v_td1);
- }
- var v_choiceLabel = $CE( "label", { "for": v_resultListId }, v_td1 );
- v_choiceLabel.f_appendText( this[K_PRMT_LABEL_CHOICES] );
- v_tr = $CE( "tr", {}, v_tbd );
- v_td1 = $CE( "td", {}, v_tr );
- this.f_drawResultList( v_td1, v_tdLayout );
- }
- this.m_elPrompt = v_oPrompt;
- return (v_oPrompt);
- };
- /**
- Render Search option.
- @private
- @param {HTMLtlement} v_tbd Container (Table).
- @param {String} v_sIdPrefix
- @param {String} v_sText Text in the UI for this option
- @param {String} v_sOptionStyle
- @param {boolean} [v_bChecked]
- @param {boolean} [v_bCheckBox]
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_drawOption = function( v_tbd, v_sIdPrefix, v_sText, v_sOptionStyle, v_bChecked, v_bCheckBox )
- {
- var v_tr = $CE( "tr", {}, v_tbd );
- var v_td = $CE( "td", {
- "class": "clsSwsOptions pe",
- "style": v_sOptionStyle,
- "vAlign": "top"
- }, v_tr );
- var v_sID = this.f_getId( v_sIdPrefix );
- var v_className = (v_bCheckBox ? K_PRMT_CSS_CHECKBOX : K_PRMT_CSS_RADIOBUTTON);
- if (v_bChecked) {
- v_className = (v_bCheckBox ? K_PRMT_CSS_CHECKBOX_CHECKED : K_PRMT_CSS_RADIOBUTTON_CHECKED);
- }
- var v_optionDiv = $CE( "div", {"class": v_className}, v_td );
- var v_oInputAttrib = {
- "type": ( v_bCheckBox ? "checkbox" : "radio" ),
- "name": ( v_bCheckBox ? "swsCaseInsensitive" : this.f_getId( "swsOption" ) ),
- "id": v_sID,
- "class": "dijitCheckBoxInput"
- };
- if (!v_bCheckBox) {
- v_oInputAttrib.onclick = "return PRMTUtils.f_updateRadioButtons(this);";
- v_oInputAttrib.onkeypress = "return PRMTUtils.f_updateRadioButtons(this);";
- } else {
- v_oInputAttrib.onclick = "return PRMTUtils.F_OnChange(event, this);";
- v_oInputAttrib.onkeypress = "return PRMTUtils.F_OnChange(event, this);";
- }
- v_oInputAttrib.onFocus = "PRMTUtils.f_SearchOptionOnFocus(this)";
- v_oInputAttrib.onBlur = "PRMTUtils.f_SearchOptionOnBlur(this)";
- var v_ipt = $CE( "input", v_oInputAttrib, v_optionDiv);
- if ( this[K_PRMT_sATTR_DISABLED] )
- {
- v_ipt.f_setProperty( "disabled", "true" );
- }
- if ( v_bChecked )
- {
- v_ipt.f_setProperty( "checked", "checked" );
- }
- var v_td = $CE( "td", {
- "class": "clsSwsOptions pe",
- "style": v_sOptionStyle,
- "nowrap": "nowrap"
- }, v_tr );
- var v_label = $CE( "label", {"for": v_sID}, v_td );
- v_label.f_appendText( v_sText );
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_keyDownHandler = function()
- {
- var v_lastEvt = ( arguments && arguments.length ? arguments[arguments.length-1] : null );
- if ( v_lastEvt && v_lastEvt.keyCode == 13 )
- {
- // set Search and Select control name for focus
- var oCV = this.f_getCV();
- if (oCV && oCV.setCurrentPromptControlFocus && typeof oCV.setCurrentPromptControlFocus == K_PRMT_sFUNCTION)
- {
- oCV.setCurrentPromptControlFocus(this["@name"]);
- }
- this.f_search();
- }
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_keyUpHandler = function(evt)
- {
- PRMT_BidiUtils.fixInputDirection(evt.target ? evt.target : evt.srcElement, this["@contentTextDirection"], 'true');
- };
- /**
- @private
- @return {HTML object} null if no results.
- */
- cognos.Prompt.Control.Search.prototype.f_getOption = function( v_sUse, v_sDisplay )
- {
- var v_aOptions = this.m_oResults.m_elPrompt.options;
- for (var i = 0; i < v_aOptions.length; i++)
- {
- var v_opt = v_aOptions[i];
- if ( v_sUse == v_opt.value && v_sDisplay == v_opt.getAttribute("dv") )
- {
- return v_opt;
- }
- }
- return null;
- };
- /**
- @private
- @return {cognos.Value[]} null if no results.
- */
- cognos.Prompt.Control.Search.prototype.f_getPV = function()
- {
- var v_oResults = this.m_oResults;
- var v_aPV = [];
- if ( v_oResults )
- {
- v_aPV = v_oResults.f_getPV();
- }
- return v_aPV;
- };
- /**
- @private
- @return {object}
- */
- cognos.Prompt.Control.Search.prototype.f_getSearchOptions = function()
- {
- var v_oSearchOptions = {};
- var v_oInput = this.$( this.f_getId( "swsInput" ) );
- if ( v_oInput )
- {
- var v_sValue = v_oInput.value;
- var v_sName = ( this["@name"] ? this["@name"] : "" );
- if ( v_sValue )
- {
- v_oSearchOptions["_sws_"+ v_sName + "_searchValue"] = v_sValue;
- v_oSearchOptions["_sws_"+ v_sName + "_showOptions"] = this.m_bShowOptions;
- v_oSearchOptions["_sws_"+ v_sName + "_submit"] = true;
- } else
- {
- v_oSearchOptions["_sws_"+ v_sName + "_searchValue"] = "";
- v_oSearchOptions["_sws_"+ v_sName + "_submit"] = true;
- }
- var v_oCaseInsensitive = this.$( this.f_getId( "swsCaseInsensitive" ) );
- var v_oStartAll = this.$( this.f_getId( "swsStartAll" ) );
- var v_oMatchAny = this.$( this.f_getId( "swsMatchAny" ) );
- var v_oMatchAll = this.$( this.f_getId( "swsMatchAll" ) );
- v_oSearchOptions["_sws_"+ v_sName + "_matchAnywhere"] = (v_oMatchAny && v_oMatchAny.checked) || (v_oMatchAll && v_oMatchAll.checked);
- v_oSearchOptions["_sws_"+ v_sName + "_matchAll"] = (v_oStartAll && v_oStartAll.checked) || (v_oMatchAll && v_oMatchAll.checked);
- v_oSearchOptions["_sws_"+ v_sName + "_caseInsensitive"] = (v_oCaseInsensitive && v_oCaseInsensitive.checked);
- v_oSearchOptions["_sws_"+ this["@parameter"]] = this.f_getXMLOptionValues();
- }
- return v_oSearchOptions;
- };
- /**
- * Get the search results options in XML format
- *
- */
- cognos.Prompt.Control.Search.prototype.f_getXMLOptionValues = function()
- {
- var v_aOptionXml = ['<selectOption', ' useValue="',K_PRMT_sEMPTY,'" displayValue="',K_PRMT_sEMPTY,'" />'];
- var result = "<selectOptions>";
- if (this.m_oResults) {
- var v_aSO = this.f_getChildByTagName( "selectOptions" );
- if ( v_aSO && v_aSO.c && v_aSO.c.length )
- {
- for ( var i = 0; i < v_aSO.c.length; i++ )
- {
- v_aOptionXml[2] = sDecodeU003( v_aSO.c[i]["@useValue"] );
- v_aOptionXml[4] = sDecodeU003( v_aSO.c[i]["@displayValue"] );
- result += v_aOptionXml.join(K_PRMT_sEMPTY);
- }
- }
- }
- result += "</selectOptions>";
- return result;
- }
- /**
- Return the style attribute for this control (@style).
- @private
- @param {v_sNode} v_sNode name of the node.
- @return {String} CSS string
- */
- cognos.Prompt.Control.Search.prototype.f_getStyleForNode = function( v_sNode )
- {
- var v_sStyle = null;
- var v_nStyle = this.getChildByName(v_sNode);
- if ( v_nStyle && v_nStyle["@style"] )
- {
- v_sStyle = v_nStyle["@style"];
- }
- return v_sStyle;
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_search = function()
- {
- // set Search and Select prompt name for search button focus
- var v_lastEvt = ( arguments && arguments.length ? arguments[arguments.length-1] : null );
- if ( v_lastEvt && v_lastEvt.type == "click" )
- {
- var oCV = this.f_getCV();
- if (oCV && oCV.setCurrentPromptControlFocus && typeof oCV.setCurrentPromptControlFocus == K_PRMT_sFUNCTION)
- {
- oCV.setCurrentPromptControlFocus( this["@name"] + "_searchButtonfocus");
- }
- }
- var v_img = this.$( this.f_getId( "imgBusy" ) );
- if ( v_img )
- {
- v_img.setAttribute( "src", this.m_sSkin + "/prompting/images/prompt_search_ani.gif" );
- }
- this.f_clearResults();
- //prevent the single select search from sending
- //the user's choice to the server when the user
- //has pressed search
- if ( this["@multiSelect"] == false )
- {
- this.m_bSubmitChoices = false;
- }
- // allow overriding of default search functionality
- if (this["@searchFunction"])
- {
- eval(this["@searchFunction"] + "();");
- }
- else
- {
- // get the search options for all search controls to repopulate them
- var v_oSearchOptions = [];
- var v_aReportControls = this.f_getCV().preProcessControlArray;
- if (v_aReportControls) {
- var kCount = v_aReportControls.length;
- for ( var k=0; k < kCount; k++ ) {
- if (v_aReportControls[k].f_getSearchOptions) {
- var tmp = v_aReportControls[k].f_getSearchOptions();
- for (var opt in tmp) {
- v_oSearchOptions[opt] = tmp[opt];
- }
- }
- }
- }
- // set parameters name for the _searchParameter variable
- v_oSearchOptions["_searchParameter"] = this["@parameter"];
- v_oSearchOptions["_promptIdBasedNames"] = true;
- v_oSearchOptions["_promptControl"] = K_ACTION_SEARCH;
- var oCV = this.f_getCV();
- if (oCV && typeof oCV.submitPromptValues == K_PRMT_sFUNCTION && typeof ViewerDispatcherEntry == K_PRMT_sFUNCTION) {
- var oReq = new ViewerDispatcherEntry(oCV);
- oReq.addFormField("ui.action", K_ACTION_FORWARD);
- for (var v_opt in v_oSearchOptions)
- {
- oReq.addFormField( v_opt, v_oSearchOptions[ v_opt ] );
- }
- oCV.submitPromptValues(oReq);
- }
- else
- {
- // No Cognos Viewer object, use the <form>, like SetPromptMethod and SetPromptControl do.
- var frm = document.forms[0];
- if (frm)
- {
- for (var v_opt in v_oSearchOptions)
- {
- genHiddenInputHTML( frm.name, v_opt, v_oSearchOptions[ v_opt ] );
- }
- }
- SetPromptMethod(K_ACTION_FORWARD);
- SetPromptControl(K_ACTION_SEARCH);
- }
- }
- };
- /**
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_setDefaultSelection = function()
- {
- if (!this.m_oResults) {return;}
- var v_aSO = this.f_getChildByTagName( "selectOptions" );
- if ( v_aSO && v_aSO.c && v_aSO.c.length )
- {
- this.cachedResults = this.buildCachedResults();
- for ( var i = 0; i < v_aSO.c.length; i++ )
- {
- var v_sUse = sDecodeU003( v_aSO.c[i]["@useValue"] );
- var v_sDisplay = sDecodeU003( v_aSO.c[i]["@displayValue"] );
- this.f_addResults( v_sUse, v_sDisplay, v_aSO.c[i]["@selected"] );
- }
- delete this.cachedResults;
- this.cachedResults = null;
- // We need to enforce Bidi text direction
- if ( G_IsBidiEnabled && this["@contentTextDirection"] ) {
- this.m_oResults.f_drawCompleted();
- }
- }
- v_aSO = this.f_getChildByTagName( "selectChoices" );
- if ( !this.isMulti() && v_aSO && v_aSO.c && v_aSO.c.length )
- {
- this.cachedResults = this.buildCachedResults();
- for ( var i = 0; i < v_aSO.c.length; i++ )
- {
- var v_sUse = sDecodeU003( v_aSO.c[i]["@useValue"] );
- var v_sDisplay = sDecodeU003( v_aSO.c[i]["@displayValue"] );
- this.f_addResults( v_sUse, v_sDisplay, true );
- }
- delete this.cachedResults;
- this.cachedResults = null;
- // We need to enforce Bidi text direction
- if ( G_IsBidiEnabled && this["@contentTextDirection"] ) {
- this.m_oResults.f_drawCompleted();
- }
- }
- };
- /**
- @private
- @param {cognos.Value[]} v_oPV
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_setPV = function( v_oPV )
- {
- if ( this.m_oChoices )
- {
- this.m_oChoices.f_setPV( v_oPV );
- }
- this.m_oResults.f_setPV( v_oPV );
- };
- /**
- @private
- @param {C_PromptElement} v_el Element to update.
- @[aram {String} v_sNode Node with @style attribute.
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_setStyle = function( v_el, v_sNode )
- {
- var v_sStyle = this.f_getStyleForNode( v_sNode );
- if ( v_sStyle )
- {
- v_el.f_setProperty( "style", v_sStyle );
- }
- };
- /**
- Show/hide the advanced search options.
- @private
- @return {void}
- */
- cognos.Prompt.Control.Search.prototype.f_toggleOptions = function()
- {
- var v_elContainer = this.$( this.f_getId("idAdvancedOptions") );
- var v_elImg = this.$( this.f_getId("imgAdvancedArrow") );
- //show the dialog if not already visible
- if ( v_elContainer )
- {
- var v_optionsLegend = this.$( this.f_getId("idSearchOptionsLegend") );
- if (v_elContainer.style.display != "none")
- {
- v_elContainer.style.display = "none";
- v_elImg.className = "clsSearchOptionsExpand";
- this.m_bShowOptions = false;
- v_optionsLegend.setAttribute("aria-expanded", false);
- }
- else
- {
- v_elContainer.style.display = K_PRMT_sEMPTY;
- v_elImg.className = "clsSearchOptionsCollapse";
- this.m_bShowOptions = true;
- v_optionsLegend.setAttribute("aria-expanded", true);
- }
- }
- };
- var C_Search = cognos.Prompt.Control.Search; // Keep old reference for backward compatibility with custom scripts.
|