C_ComboBox.js 16 KB

123456
  1. // Licensed Materials - Property of IBM
  2. // IBM Cognos Products: hal
  3. // (C) Copyright IBM Corp. 2003, 2017.
  4. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. function C_ComboBox(_hY91, _hHO1, _h7O1, _hLN1){G_HAL.F_VerifyDependencies("C_ListView");this._hZ91=_hY91;this._hZ91._hIO1=this;this._hXN1=_hLN1?_hLN1:null;this._hK91=window["G_ResManager"]?G_ResManager:null;if(!_hHO1){var _h0A1=U_XML.F_CreateDocument();_hHO1=_h0A1.appendChild(_h0A1.createElement("comboBox"));}this._hC92=_hHO1.getAttribute("type");if(!this._hC92){this._hC92="dropDownList";}this._hLR=_hHO1.getAttribute( "showSmallIcon" )=="true";this._hGX=true;this._hM3=_hHO1.getAttribute( "showListViewCustomHtml" )=="true";_hY91.cellPadding=0;_hY91.cellSpacing=0;_hY91.className="clsComboBox";if(G_HAL.M_oLibraries["hal"]["enableHighContrastMode"]){_hY91.style.tableLayout="auto";}var d=document;var tr=_hY91.insertRow(_hY91.rows.length);this._hD52=tr.appendChild(d.createElement("TD"));this._hD52.className="clsComboBoxIcon";this._hD52.style.display="none";this._hD52.style.padding="0px 0px 0px 1px";var _hEE2=this._hD52.appendChild(d.createElement("IMG"));_hEE2.alt="";if(this._hLR){var _hTM=_hHO1.getAttribute("smallIconWidth");if(_hTM){this._hD52.style.width=(parseInt(_hTM)+2)+ "px";}}this._hE52=tr.appendChild(d.createElement("TD"));this._hE52.className="clsComboBoxText";if(this._hC92=="dropDown"){var txt=this._hE52.appendChild(d.createElement("INPUT"));txt.id=((this._hZ91.id||this._hZ91.uniqueID)+"_dropDownText");txt.type="text";txt.onchange=C_ComboBox._hU31;}else{var div=this._hE52.appendChild(d.createElement("DIV"));this._hE52.style.cursor="default";}this._hTZ1=tr.appendChild(d.createElement("TD"));this._hTZ1.className="clsComboBoxArrow";this._hTZ1.innerText=" ";if(G_HAL.M_oLibraries["hal"]["enableHighContrastMode"]){var _hHX=d.createElement("IMG");_hHX.style.height="12px";_hHX.style.width="13px";_hHX.src="hal/images/ComboBoxArrow_a11y.png";this._hTZ1.appendChild(_hHX);}this._hHD(_hHO1);this._hAU1=false;this.F_SetEnabled(true);var _h3H1=C_ComboBox._h4H1();this._hR91=_h3H1.appendChild(d.createElement("DIV"));this._hR91.id=((this._hZ91.id||this._hZ91.uniqueID)+"_ListViewDropDown");this._hR91.className="clsListView_dropdown";this._hR91.style.position="absolute";if(G_HAL.M_oLibraries["hal"]["enableAccessibility"]){U_XML.F_CopyAttribute(this._hR91, this._hZ91, "aria-label");}this._hR91.style.visibility="hidden";this._hR91.tabIndex=-1;if(_h7O1){U_XML.F_RemoveNode(_hHO1, "listView");_hHO1.appendChild(U_XML.F_ImportNode(_hHO1.ownerDocument, _h7O1));}var _h2G=_hHO1.selectSingleNode("listView");if(!_h2G){_h2G=_hHO1.appendChild(_hHO1.ownerDocument.createElement("listView"));_h2G.setAttribute( "view", "report" );_h2G.appendChild(_hHO1.ownerDocument.createElement("listItems"));}_h2G.setAttribute( "hoverSelection", "true" );_h2G.setAttribute( "allowCtrlDeselect", "false" );this._hPI=( _hHO1.getAttribute( "resolveIconPath" ) != "false" );_h2G.setAttribute( "resolveIconPath", this._hPI?"true":"false" );this._hV4=_hHO1.getAttribute("textDirection");this._hW6=_hHO1.getAttribute("guiDirection");this._hFZ1=null;this._hPM=null;this._h4(_h2G);this._hAO1=new C_ListView(this._hR91, _h2G, this); };C_ComboBox.prototype.F_ReplaceListView=function(_h7O1){_h7O1.setAttribute( "hoverSelection", "true" );_h7O1.setAttribute( "allowCtrlDeselect", "false" );_h7O1.setAttribute( "resolveIconPath", this._hPI?"true":"false" );this._h4(_h7O1);this._hAO1.F_Detach();this._hAO1=new C_ListView(this._hR91, _h7O1, this);};C_ComboBox.prototype._h4=function(_h7O1){if(this._hV4){_h7O1.setAttribute("textDirection", this._hV4);}if(this._hW6){_h7O1.setAttribute("guiDirection", this._hW6);}this._hFZ1=_h7O1.getAttribute( "guiDirection" )||G_HAL.M_oLibraries["hal"]["defaultGuiDirection"];if(this._hFZ1){this._hZ91.style.direction=this._hFZ1;}this._hPM=_h7O1.getAttribute("textDirection")||this._hFZ1; };C_ComboBox.prototype.F_GetListView=function(){return this._hAO1;};C_ComboBox.prototype.F_Detach=function(){this._hAO1.F_Detach();delete this._hAO1;this._hR91.parentNode.removeChild(this._hR91);U_DOM.F_DeleteTableRows(this._hZ91);this._hZ91._hIO1=null;};C_ComboBox.F_Detach=function(){if(C_ComboBox._h5H1){this._h5H1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"]=null;this._h5H1.onkeydown=null;this._h5H1=null;}};C_ComboBox.prototype.F_SetDropDownHeight=function(_hNZ1){this._hR91.style.height=_hNZ1;};C_ComboBox.prototype.F_SetDropDownWidth=function(_h952){this._hMR=_h952;};C_ComboBox.prototype.F_GetId=function(){return this._hZ91.id;};C_ComboBox.prototype.F_GetContainer=function(){return this._hZ91;};C_ComboBox._h4H1=function(){if(!C_ComboBox._h5H1){C_ComboBox._h5H1=document.body.appendChild(document.createElement("DIV"));var _h3H1=C_ComboBox._h5H1;_h3H1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"] =function(){ this._hIO1._hV31(); };var _hUM=function(e){if(G_HAL.M_oLibraries["hal"]["enableAccessibility"]&&e.keyCode!=U_DOM.K_iKeyArrowLeft&&e.keyCode!=U_DOM.K_iKeyArrowRight){U_DOM.F_CancelEvent(e);}if(e.keyCode==U_DOM.K_iKeyEscape){this._hIO1._hV31();}};_h3H1.onkeydown=_hUM;_h3H1.className="clsComboBoxBlocker";_h3H1.style.visibility="hidden";_h3H1.style.zIndex=10000;}return C_ComboBox._h5H1;};C_ComboBox.prototype._hID=function(){if(this._hXN1&&this._hXN1.F_ComboBox_OnShowDropDown){this._hXN1.F_ComboBox_OnShowDropDown(this, this._hAO1);}};C_ComboBox.prototype._hN3=function(){if(this._hXN1&&this._hXN1.F_ComboBox_OnAfterShowDropDown){setTimeout(this._hXN1.F_ComboBox_OnAfterShowDropDown.bind(this._hXN1, this, this._hAO1));}};C_ComboBox.prototype._hUI=function(){if(this._hXN1&&this._hXN1.F_ComboBox_OnRightClick){this._hXN1.F_ComboBox_OnRightClick(this);}};C_ComboBox.prototype._hJD=function(){if(this._hXN1&&this._hXN1.F_ComboBox_OnHideDropDown){this._hXN1.F_ComboBox_OnHideDropDown(this, this._hAO1);}this._hAO1.F_ClearSelections(false);};C_ComboBox.prototype.F_SelectByIndex=function(_h652){var _hBO1=C_ListView.F_FindListItemByIndex(this._hAO1.F_GetListViewNode(), _h652);if(_hBO1){this.F_SetValueFromListItem(_hBO1);}return(_hBO1!=null);};C_ComboBox.prototype.F_SelectByValue=function(_h552,_hM91){var _hBO1=C_ListView.F_FindListItem(this._hAO1.F_GetListViewNode(), "value", _h552, _hM91);if(_hBO1){this.F_SetValueFromListItem(_hBO1);}return(_hBO1!=null);};C_ComboBox.prototype.F_SelectFirstSelectableListItem=function(){var _hBO1=this._hAO1.F_GetListViewNode().selectSingleNode( "listItems/listItem[not(@selectable) or @selectable='true']" );if(_hBO1){this.F_SetValueFromListItem(_hBO1);}return(_hBO1!=null);};C_ComboBox.prototype._hW31=function(){if(this._h3G){this._h3G.F_Cancel();this._h3G=null;}this._hID();var _h3H1=C_ComboBox._h4H1();_h3H1._hIO1=this;_h3H1.style.visibility="visible";this._hTZ1.className="clsComboBoxArrow_down";if(G_HAL.M_oLibraries["hal"]["enableHighContrastMode"]){this._hTZ1.getElementsByTagName( "IMG" )[0].src = "hal/images/ComboBoxArrow_a11y.png";}var _hC52=document.body;var _hIC2=U_DOM.F_GetRelativeOffset(this._hZ91, _hC52);_hIC2.top+= this._hZ91.offsetHeight;var _hD92=true;if((_hIC2.top+this._hR91.offsetHeight)>(_hC52.clientHeight+_hC52.scrollTop)){_hIC2.top=Math.F_NonNeg(_hIC2.top-this._hR91.offsetHeight-this._hZ91.offsetHeight);_hD92=false;}this._hR91.scrollTop=0;this._hR91.style.left=_hIC2.left+"px";this._hR91.style.top=_hIC2.top+"px";var _hVI=G_HAL.M_oLibraries["hal"]["enableComboBoxAnimation"];this._hR91.style.visibility=_hVI?"hidden":"visible";this._hR91.style.width=this._hMR?this._hMR:(this._hZ91.offsetWidth+"px");if((_hIC2.left+this._hR91.offsetWidth)>(_hC52.clientWidth+_hC52.scrollLeft)){var _h6H1=(_hIC2.left+this._hR91.offsetWidth)-(_hC52.clientWidth+_hC52.scrollLeft);this._hR91.style.left=Math.F_NonNeg(parseInt(this._hR91.style.left, 10)-_h6H1)+"px";_hIC2.left=Math.F_NonNeg(_hIC2.left-_h6H1);}if(!_hVI){this._hR91.focus();this._hN3();}var _hBO1=null;var _h552=this.F_GetValue();if(typeof _h552=="string"){_hBO1=this._hAO1.F_FindListItem("value", _h552, true);}if(G_HAL.M_oLibraries["hal"]["enableAccessibility"]&&_hBO1){document.getElementById(_hBO1.getAttribute("htmlId")).focus();}else{this._hAO1.F_SelectListItem(_hBO1, false);}if(_hVI){if(this._h3G){this._h3G.F_Cancel();this._h3G=null;}var fn=this._hW4.bind(this);this._h3G=new C_Transfer(this._hR91, this._hR91, _hD92?C_Transfer.K_iFromRelationTop:C_Transfer.K_iFromRelationBottom, C_Transfer.K_iToRelationDefault, true, "clsComboBoxPopupTransferProxy", null, null, fn, 100);this._h3G.F_Play();}};C_ComboBox.prototype._hW4=function(){this._hR91.style.visibility="visible";this._hR91.focus();this._hN3();};C_ComboBox.prototype._hV31=function(){var _hVI=G_HAL.M_oLibraries["hal"]["enableComboBoxAnimation"];if(_hVI){if(this._h3G){this._h3G.F_Cancel();this._h3G=null;}}if(G_HAL.M_oLibraries["hal"]["enableAccessibility"]){var _hJO1=(this._hC92=="dropDown")?this._hTZ1:this._hZ91;_hJO1.focus();}this._hTZ1.className="clsComboBoxArrow";if(G_HAL.M_oLibraries["hal"]["enableHighContrastMode"]){this._hTZ1.getElementsByTagName( "IMG" )[0].src = "hal/images/ComboBoxArrow_a11y.png";}this._hR91.style.visibility="hidden";C_ComboBox._h5H1.style.visibility="hidden";C_ComboBox._h5H1._hIO1=null;this._hJD();};C_ComboBox.F_HideDropDown=function(){if(this._h5H1&&this._h5H1._hIO1){this._h5H1._hIO1._hV31();}};C_ComboBox.prototype.F_GetEnabled=function(){return Boolean(this._hAU1);};C_ComboBox.prototype.F_SetEnabled=function(_hFU1,_h1A1){if(_hFU1==this._hAU1){return;}this._hAU1=_hFU1;if(_hFU1){var _hNR=function(e){if(G_HAL.M_oTestListener&&G_HAL.M_oTestListener.F_TestListener_ComboBoxOnMouseDown){G_HAL.M_oTestListener.F_TestListener_ComboBoxOnMouseDown(e, this);}if((e||event).button==U_DOM.K_iLeftMouseButton){this.parentNode.parentNode.parentNode._hIO1._hW31();}};this._hD52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"] = ( this._hC92=="dropDown" )?null:_hNR;this._hE52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"] = ( this._hC92=="dropDown" )?null:_hNR;this._hTZ1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"]=_hNR;this._hTZ1.className="clsComboBoxArrow";if(G_HAL.M_oLibraries["hal"]["enableHighContrastMode"]){this._hTZ1.getElementsByTagName( "IMG" )[0].src = "hal/images/ComboBoxArrow_a11y.png";}var _h2A1=function(e){if((e||event).button==U_DOM.K_iRightMouseButton){this.parentNode.parentNode.parentNode._hIO1._hUI();}};this._hD52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"onmouseup"]=_h2A1;this._hE52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"onmouseup"]=_h2A1;this._hTZ1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"onmouseup"]=_h2A1;this._hH(true);}else{this._hD52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"]=null;this._hE52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"]=null;this._hTZ1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerdown":"onmousedown"]=null;this._hTZ1.className="clsComboBoxArrow_disabled";if(G_HAL.M_oLibraries["hal"]["enableHighContrastMode"]){this._hTZ1.getElementsByTagName( "IMG" )[0].src = U_HighContrast.F_GetHighContrastImgIfNecessary( "hal/images/ComboBoxArrow_disabled.png" ); }this._hD52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"onmouseup"]=null;this._hE52[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"onmouseup"]=null;this._hTZ1[G_BrowserInfo.M_bIsPointerEnabled?"onpointerup":"onmouseup"]=null;this._hH();}if(this._hC92=="dropDown"){U_DOM.F_SetTextInputEnabled(this._hE52.firstChild, _hFU1);}else{U_DOM.F_SetTextEnabled(this._hE52, _hFU1);}if(_h1A1&&this._hD52.getAttribute("_hPG1")){var _hKC2=this._hD52.getAttribute("_hPG1");if(!_hFU1){_hKC2=_hKC2.replace( ".gif", "_disabled.gif" );}this._hD52.firstChild.src=this._hPI?G_HAL.F_GetImageURL(_hKC2):_hKC2;}this._hX2(_hFU1);};C_ComboBox.prototype.F_SetValueFromListItem=function(_hBO1){this.F_SetValue(_hBO1.getAttribute("value"),_hBO1.getAttribute("idsLabel"),_hBO1.getAttribute("label"),_hBO1.getAttribute("smallIcon"),_hBO1.getAttribute("textDirection"),_hBO1.getAttribute("html"));this.F_SetTooltip(_hBO1.getAttribute("tooltip"),_hBO1.getAttribute("idsTooltip"),_hBO1.getAttribute("textDirection"));if(this._hM3&&( _hBO1.getAttribute( "html" )!==null )&&( this._hC92 != "dropDown" )&&this._hXN1&&this._hXN1.F_ComboBox_OnHtmlRender ){this._hXN1.F_ComboBox_OnHtmlRender(this, _hBO1, this._hE52.firstChild);}};C_ComboBox.prototype.F_SetValue=function(_h552,_hUZ1,_hX82,_hPG1,_hLU1,_hA92){if(this._hC92=="dropDown"){this._hE52.firstChild.value=_h552;}else{if(this._hM3&&_hA92){this._hE52.firstChild.innerHTML=_hA92;if(this._hK91){this._hK91.F_ApplyResStrings(this._hE52.firstChild);}}else if(_hUZ1){this._hE52.firstChild.innerText=this._hK91.F_GetString(_hUZ1);}else{this._hE52.firstChild.innerText=(_hX82||_hX82=="")?_hX82:_h552;var _h2O1=_hLU1||this._hPM;if(_h2O1){this._hE52.firstChild.style.direction=_h2O1;}}this._hD52.setAttribute( "_hPG1", _hPG1?_hPG1:"" );if(this._hLR&&this._hD52.getAttribute("_hPG1")){var _hKC2=this._hD52.getAttribute("_hPG1");this._hD52.firstChild.src=this._hPI?G_HAL.F_GetImageURL(_hKC2):_hKC2;this._hD52.style.display="";}else{this._hD52.style.display="none";}}this._hE52._h552=_h552;};C_ComboBox.prototype.F_GetValue=function(){return this._hE52._h552;};C_ComboBox.prototype.F_GetText=function(){if(this._hC92=="dropDown"){return this._hE52.firstChild.value;}return this._hE52.firstChild.innerText;};C_ComboBox.prototype.F_SetTooltip=function(_h3U1,_hBG1,_hLU1){if(!this._hGX){return;}if(_h3U1){this._hZ91.title=_h3U1;}else if(_hBG1){this._hZ91.title=this._hK91.F_GetString(_hBG1);}else{this._hZ91.title=this.F_GetText();}var _h2O1=_hLU1||this._hPM;if(_h2O1){if(_h2O1=="ltr"){this._hZ91.title="\u202A" + this._hZ91.title + "\u202C";}else if(_h2O1=="rtl"){this._hZ91.title="\u202B" + this._hZ91.title + "\u202C";}}this._hD52.getElementsByTagName("IMG").item(0).alt=this._hZ91.title;};C_ComboBox.prototype.F_ListView_OnHtmlRender=function(_hCO1,_hE92,_hF52){if(this._hXN1&&this._hXN1.F_ComboBox_OnHtmlRender){this._hXN1.F_ComboBox_OnHtmlRender(this, _hE92, _hF52);}};C_ComboBox.prototype.F_ListView_OnItemClick=function(_hCO1,_hBO1,_hQ31){if(_hBO1.getAttribute( "selectable" )=="false" ){return;}this.F_SetValueFromListItem(_hBO1);this._hV31();this._hX31(_hBO1);};C_ComboBox._hU31=function(e){e.stopPropagation();var txt=this;var _hIO1=txt.parentNode.parentNode.parentNode.parentNode._hIO1;_hIO1._hE52._h552=txt.value;_hIO1._hX31();};C_ComboBox.prototype._hX31=function(_hBO1){if(this._hXN1&&this._hXN1.F_ComboBox_OnChange){this._hXN1.F_ComboBox_OnChange(this, _hBO1);}};C_ComboBox.prototype._hHD=function(_hHO1){if(!G_HAL.M_oLibraries["hal"]["enableAccessibility"]){return;}this._hZ91.setAttribute( "role", "combobox" );this._hZ91.removeAttribute("aria-describedby");U_Accessibility.F_AddAriaDescribedBy(this._hZ91, this._hE52.firstChild.uniqueID);this._hTZ1.setAttribute( "role", "button" );var _h492=_hHO1.getAttribute("a11y_name");this._hTZ1.setAttribute( "aria-label", ( _h492?( _h492 + " " ):"" ) + G_ResManager.F_GetString( "IDS_HAL_AC_DROPDOWN" ) );if(this._hC92=="dropDown"){if(!this._hTZ1.getAttribute("tabIndex")){this._hTZ1.setAttribute( "tabIndex", "0" );}U_XML.F_CopyAttributes( this._hE52.firstChild, this._hZ91, ["aria-label", "aria-labelledby"] );}else if(!this._hZ91.getAttribute("tabIndex")){this._hZ91.setAttribute( "tabIndex", "0" );}};C_ComboBox.prototype._hH=function(_hLC2){if(!G_HAL.M_oLibraries["hal"]["enableAccessibility"]){return;}if(_hLC2){if(this._hC92=="dropDown"){var _hX6=function(e){if(e.keyCode==U_DOM.K_iKeyEnter||e.keyCode==U_DOM.K_iKeyArrowDown){this.parentNode.parentNode.parentNode._hIO1._hW31();}};this._hTZ1.onkeydown=_hX6;}else{var _hX6=function(e){if(e.keyCode==U_DOM.K_iKeyEnter||e.keyCode==U_DOM.K_iKeyArrowDown){this._hIO1._hW31();}};this._hZ91.onkeydown=_hX6;}}else{if(this._hC92=="dropDown"){this._hTZ1.onkeydown=null;}else{this._hZ91.onkeydown=null;}}};C_ComboBox.prototype._hX2=function(_hVZ1){if(!G_HAL.M_oLibraries["hal"]["enableAccessibility"]){return;}if(!_hVZ1){this._hZ91.removeAttribute("tabIndex");this._hZ91.setAttribute( "disabled", "true" );this._hTZ1.setAttribute( "disabled", "true" );}else{this._hZ91.setAttribute( "tabIndex", "0" );this._hZ91.removeAttribute("disabled");this._hTZ1.removeAttribute("disabled");}U_Accessibility.F_SetAriaStateAndProperty(this._hZ91, "aria-disabled", !_hVZ1);U_Accessibility.F_SetAriaStateAndProperty(this._hE52, "aria-disabled", !_hVZ1);U_Accessibility.F_SetAriaStateAndProperty(this._hTZ1, "aria-disabled", !_hVZ1);};C_ComboBox.prototype.F_AllowFocus=function(){if(!G_HAL.M_oLibraries["hal"]["enableAccessibility"]){return;}this._hZ91.removeAttribute("disabled");};C_ComboBox.prototype.F_AllowTooltip=function(_hG52){this._hGX=_hG52;};C_ComboBox.F_GetComboBoxFromHTMLElement=function(_hZE2){return _hZE2._hIO1?_hZE2._hIO1:null;};