C_SelectWithSearch.js 11 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. var C_SelectWithSearch=function(_hH12,_hKA2,_h772){G_HAL.F_VerifyDependencies("G_ResManager");G_HAL.F_VerifyDependencies("C_ListView");this._hA22=U_XML.F_CreateDocument();this._hB22=_hH12;this._hLA2=_hKA2;this._h872=_h772;this._h972={};this._hSQ1=[];this._h8H();this._h2D1();this._hL61=G_ResManager.F_GetString("IDS_HAL_SEARCH_LABEL");this._hMK1=G_ResManager.F_GetString("IDS_HAL_SEARCH_HINT");if(this._hM61===true){this._h9H=G_ResManager.F_GetString("IDS_HAL_SEARCH_CHECKBOX_LABEL");}this._hTQ1=G_ResManager.F_GetString("IDS_HAL_SEARCH_LIST_HINT");this._h7P=G_ResManager.F_GetString("IDS_HAL_SEARCH_CASE");this._hOU=[];this._hOU.push(G_ResManager.F_GetString("IDS_HAL_SEARCH_START_WITH_ANY"));this._hOU.push(G_ResManager.F_GetString("IDS_HAL_SEARCH_START_WITH_FIRST"));this._hOU.push(G_ResManager.F_GetString("IDS_HAL_SEARCH_START_CONTAIN_ANY"));this._hOU.push(G_ResManager.F_GetString("IDS_HAL_SEARCH_START_CONTAIN_ALL"));};C_SelectWithSearch.prototype.F_Detach=function(){while(this._hSQ1.length>0){this._hSQ1.pop()._hA72();}if(this._hAO1){this._hAO1.F_Detach();}if(this._h3D1){this._h3D1.F_Detach();}this._hOU=[];if(this._hMA2&&this._hB22){this._hB22.removeChild(this._hMA2);}};C_SelectWithSearch.prototype._h8H=function(){this._hNK1=this._hLA2.getAttribute("parameter")||"";this._hM61=(this._hLA2.getAttribute("multiSelect")==="true")?true:false;this._hF2=(this._hLA2.getAttribute("caseInsensitiveIsDefault")==="false")?false:true;this._hUQ1=(this._hLA2.getAttribute("required")==="false")?false:true;this._h8P=(this._hLA2.getAttribute("hideAdornments")==="true")?true:false;this._hPU=(this._hLA2.getAttribute("matchAnywhere")==="true")?true:false;this._hVQ1=(this._hLA2.getAttribute("matchAll")==="true")?true:false;};C_SelectWithSearch.prototype._h2D1=function(){this._hNA2={};var _hC22, _hQU=this._hLA2.selectNodes("selectOptions/selectOption");var _hBD2, _hWW1=this._hNA2["options"]=[];for(_hBD2=0; _hBD2<_hQU.length; _hBD2++){_hC22=_hQU[_hBD2];_hWW1.push({"value": _hC22.getAttribute("useValue"), "label": _hC22.getAttribute("displayValue")});}};C_SelectWithSearch.prototype.F_Draw=function(){var _hWQ1='<div class="clsSelectWithSearch" style="display: flex; flex-direction: column; font-family: Arial, Helvetica, sans-serif; font-size: 14px; width: 100%; min-width: 200px; height: 100%; min-height: 200px">' +'<div style="padding-right: 16px; line-height: 40px; text-align: middle">' + this._hL61 + '</div>' +'<div style="flex: 1; display: flex; flex-direction: column">' +'<div style="display: flex; flex-direction: row; overflow: hidden">' +'<div style="flex: 1">' +'<input class="clsSearchText" type="text" placeholder="' + this._hMK1 + '" style="width: 100%; height: 40px; font-family: Arial, Helvetica, sans-serif; font-size: 14px; border: 1px solid #4178BE; padding: 0 8px 0 8px"/>' +'</div>'+'<button class="clsSearchButton" style="width: 40px; height: 40px; line-height: 40px; text-align: center; background-color: #4178BE; border: 1px solid #4178BE" tabIndex="0">' +'<img src="hal/images/search_small.svg" alt="$Search" width="24" height="24" style="vertical-align: -7px; "></img>' +'</button>'+'</div>'+'<div class="clsAdorment" style="flex: 1; padding: 8px; display: flex; flex-direction: column">' +(this._hM61? '<div>'+'<div style="line-height: 40px">' +'<input class="clsSelectAll" id="_selectAll" type="checkbox" name="selectAll" value=""/>' +'<label for="_selectAll" style="color: #4178BE">' + this._h9H + '</label>' +'</div>'+'<div style="height: 2px; margin: 0 8px 0 8px; border-top: 1px solid #AEB8B8"></div>' +'</div>': '')+'<div class="clsListViewHolder" style="flex: 1; position: relative">' +'<div style="line-height: 40px; text-align: center; color: #AEB8B8">' + this._hTQ1 + '</div>' +'</div>'+'</div>'+'<div style="padding: 5px 3px 0px 3px">' +'<table class="clsCboOptions" style="width: 100%"></table>' +'</div>'+'<div style="line-height: 40px">' +'<input class="clsCaseInsensitive" id="_caseInsensitive" type="checkbox" name="caseInsensitive" value="" style="cursor: pointer"' + (this._hF2?'checked="true"':'') + '/>' +'<label for="_caseInsensitive" style="cursor: pointer">' + this._h7P + '</label>' +'</div>'+'</div>'+'</div>';this._hB22.innerHTML=_hWQ1;this._hMA2=this._hB22.firstChild;this._h9P=this._hB22.getElementsByClassName("clsListViewHolder")[0];this._h4D1=this._hB22.getElementsByClassName("clsSearchText")[0];this._hAP(this._h4D1, "keyup", this._hAH);this._hL01=this._hB22.getElementsByClassName("clsSearchButton")[0];this._hAP(this._hL01, "click", this._h5C);if(this._hM61){this._hOK1=this._hB22.getElementsByClassName("clsSelectAll")[0];this._hAP(this._hOK1, "change", this._hBH);this._hYK(true);}this._hZK();this._h0L=this._hB22.getElementsByClassName("clsCaseInsensitive")[0];this._hAP(this._h0L, "change", this._h24);this._h6C(true);};C_SelectWithSearch.prototype._hAP=function(_hOA2,_hXW1,_hPH1){var _hPA2=_hPH1.bind(this);_hOA2.addEventListener(_hXW1, _hPA2);this._hSQ1.push({_hA72: function(){_hOA2.removeEventListener(_hXW1, _hPA2);}});};C_SelectWithSearch.prototype._hZK=function(){var _h5D1=this._hB22.getElementsByClassName("clsCboOptions")[0];this._h3D1=new C_ComboBox(_h5D1, null, null, this);var _hBD2, _hD22, _hBO1, _hCO1=this._h3D1.F_GetListView();var _hWZ1=["beginWithAny", "beginAndContain", "containAny", "containAll"];for(_hBD2=0; _hBD2<this._hOU.length; _hBD2++){_hD22=this._hOU[_hBD2];_hBO1=_hCO1.F_AppendNewListItem();_hBO1.setAttribute("label", _hD22);_hBO1.setAttribute("value", _hWZ1[_hBD2]);}_hCO1.F_Draw();this._hN61=(this._hYW1===true)?((this._hPU===true)?"containAll":"beginAndContain"):((this._hPU===true)?"containAny":"beginWithAny");this._h3D1.F_SelectByValue(this._hN61);};C_SelectWithSearch.prototype._hRU=function(_hQA2){if(this._h9P){var _hBP=this._h9P;while(_hBP.hasChildNodes()){_hBP.removeChild(_hBP.firstChild);}var _hWW1, _hE22=this._h4D1.value.trim();if(this._h872){if(_hQA2){_hWW1=_hQA2["options"];}else{_hBP.innerHTML ='<div style="line-height: 40px; text-align: center; color: #AEB8B8">' +'<img src="hal/images/progress.gif" alt="Working..." width="24" height="24" style="vertical-align: -7px; "></img>' +'</div>';this._h872.requestData(_hE22, this._hRU.bind(this));return;}}else{var _hXQ1=(this._hF2===true)?"i":"";var _hF22=new RegExp("^"+_hE22, _hXQ1);_hWW1=(!_hE22||_hE22.length===0)?[]:this._hNA2["options"];_hWW1=_hWW1.filter(function(option){return option.label.search(_hF22)>=0;});}if(_hWW1.length===0){if(this._hAO1){this._hAO1.F_Detach();this._hAO1=undefined;this._hG22();}_hBP.innerHTML='<div style="line-height: 40px; text-align: center; color: #AEB8B8">' + this._hTQ1 + '</div>';if(this._hM61===true){this._hYK(true);}}else{_hBP.innerHTML='<div class="clsListView" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; border: none"></div>';var _h7O1=this._hA22.createElement("listView");var _h1I1=_h7O1.appendChild(_h7O1.ownerDocument.createElement("listItems"));if(this._hM61===true){_h7O1.setAttribute("view", "checkbox");_h7O1.setAttribute("multiSelect", "true");this._hOK1.checked=false;this._hYK(false);}else{_h7O1.setAttribute("view", "radio");}var _hBD2, _hBO1, _hH22;for(_hBD2=0; _hBD2<_hWW1.length; _hBD2++){_hBO1=_h1I1.appendChild(_h1I1.ownerDocument.createElement("listItem"));_hH22=_hWW1[_hBD2];_hBO1.setAttribute("value", _hH22["value"]);_hBO1.setAttribute("label", _hH22["label"]);}this._hAO1=new C_ListView(_hBP.firstChild, _h7O1, this);this._hAO1.F_Draw();this._hG22();}}};C_SelectWithSearch.prototype._hAH=function(evt){evt.stopPropagation();var _hE22=evt.target.value.trim();if(evt.keyCode===U_DOM.K_iKeyEnter){if(_hE22!==""){this._hRU();}}else{if(_hE22===""){this._h6C(true);}else{this._h6C(false);}}};C_SelectWithSearch.prototype._h6C=function(_h9P1){this._hL01.disabled=_h9P1;this._hL01.style.opacity=_h9P1?"0.3":"1.0";this._hL01.style.cursor=_h9P1?"initial":"pointer";};C_SelectWithSearch.prototype._hYK=function(_h9P1){this._hOK1.disabled=_h9P1;this._hOK1.style.cursor=_h9P1?"initial":"pointer";this._hOK1.nextSibling.style.opacity=_h9P1?"0.3":"1.0";this._hOK1.nextSibling.style.cursor=_h9P1?"initial":"pointer";};C_SelectWithSearch.prototype._h5C=function(evt){evt.stopPropagation();this._hRU();};C_SelectWithSearch.prototype._hBH=function(evt){evt.stopPropagation();if(evt.target.checked===true){this._hAO1.F_CheckAll();}else{this._hAO1.F_UncheckAll();}this._hG22();};C_SelectWithSearch.prototype._hG22=function(){var _hRA2=[];if(this._hAO1){var _h6I1, _hBO1;if(this._hM61===true){_h6I1=this._hAO1.F_GetCheckedListItems();}else{_h6I1=this._hAO1.F_GetSelectedListItems();}for(var _hBD2=0; _hBD2<_h6I1.length; _hBD2++){_hBO1=_h6I1[_hBD2];_hRA2.push({"value": _hBO1.getAttribute("value"), "label": _hBO1.getAttribute("label")});}}this.F_Publish("/OnValueChange", _hRA2);};C_SelectWithSearch.prototype._h24=function(evt){evt.stopPropagation();this._hF2=evt.target.checked;};C_SelectWithSearch.prototype.F_ListView_OnItemClick=function(_hCO1,_hBO1,_hQ31){this._hG22();};C_SelectWithSearch.prototype.F_ListView_OnCheckboxClick=function(_hCO1,_hBO1){this._hG22();};C_SelectWithSearch.prototype.F_Subscribe=function(_hB72,_hPH1){if(!this._h972[_hB72]){this._h972[_hB72]=[];}this._h972[_hB72].push(_hPH1);};C_SelectWithSearch.prototype.F_Publish=function(_hB72,_hRA2){if(this._h972[_hB72]){for(var i=0; i<this._h972[_hB72].length; i++){this._h972[_hB72][i](_hRA2);}}};C_SelectWithSearch.prototype.F_IsCaseInsensitive=function(){return this._hF2;};C_SelectWithSearch.prototype.F_ComboBox_OnChange=function(_h6D1,_hBO1){this._hN61=_hBO1.getAttribute("value");};C_SelectWithSearch.prototype.F_GetOptionValue=function(){return this._hN61;};C_SelectWithSearch.prototype.F_ClearSelections=function(){if(this._hAO1){if(this._hM61===true){this._hAO1.F_UncheckAll();this._hOK1.checked=false;}else{this._hAO1.F_DeselectAll();}this._hG22();}};C_SelectWithSearch.prototype.F_AddSelectedValues=function(_hWZ1){var _hBD2, _hK52;if(!_hWZ1){_hWZ1=[];}if(!this._hAO1){var _hRA2=[];for(_hBD2=0; _hBD2<_hWZ1.length; _hBD2++){_hK52=_hWZ1[_hBD2];_hRA2.push({"value": _hK52["use"], "label": _hK52["display"]});}this._hRU({"options": _hRA2});}var _h7O1=this._hAO1.F_GetListViewNode();var _hSA2=this._hM61?"checked":"selected", _hBO1;for(_hBD2=0; _hBD2<_hWZ1.length; _hBD2++){_hK52=_hWZ1[_hBD2];_hBO1=C_ListView.F_FindListItem(_h7O1, "value", _hK52["use"]);if(!_hBO1){_hBO1=this._hAO1.F_AppendNewListItem();_hBO1.setAttribute("value", _hK52["use"]);_hBO1.setAttribute("label", _hK52["display"]);}if(_hBO1.getAttribute(_hSA2)!="true"){_hBO1.setAttribute(_hSA2, "true");}}this._hAO1.F_Draw();this._hG22();};