1/* 2 * The following widget(s) extend the WidgetMaster object defined in widgetParent.js 3 */ 4 5/* 6 * Search Filter Widget 7 * 8 */ 9 10function SearchFilterWidget(widgetId, widgetParams, articleContext) { 11 WidgetMaster.call(this, widgetId, widgetParams, articleContext); 12} 13 14SearchFilterWidget.prototype = Object.create(WidgetMaster.prototype); 15SearchFilterWidget.prototype.constructor = SearchFilterWidget; 16 17SearchFilterWidget.prototype.render = function () { 18 19 var widgetDiv = document.getElementById(this.widgetId); 20 if (widgetDiv) { 21 this.renderWidget(widgetDiv); 22 } 23}; 24 25SearchFilterWidget.prototype.renderWidget = function (parentElement) { 26 27 this.renderWrapperContainer(parentElement); //wrapperContainer added for [AVT-4216] 28 var idCount = 0; 29 var container = tsCreateDiv(); 30 container.id = "searchFilters"; 31 this.wrapperContainer.appendChild(container); 32 var isDropDown = ""; 33 if (this.widgetParams["dropDownFormat"]) { 34 isDropDown = this.widgetParams["dropDownFormat"].toLowerCase(); 35 } 36 if (!this.articleContext.searchFilters) 37 return; 38 39 var currentPage = (location.href.indexOf("loadArticle.asp") > -1 ? "loadArticle.asp" : "default.asp"); 40 41 if (isDropDown == "true" || isDropDown == "t") { 42 var filterForm = container.appendChild(tsCreateForm(currentPage)); 43 filterForm.appendChild(tsCreateHidden(encodeURIComponent(sTokenName), sToken)); 44 filterForm.appendChild(tsCreateHidden("doWork::WScontent::search", "")); 45 filterForm.appendChild(tsCreateHidden("BOparam::WScontent::search::article_search_id", this.articleContext.articleId)); 46 } 47 48 for (var i = 0; i < this.articleContext.searchFilters.length; i++) { 49 50 var currentFilter = this.articleContext.searchFilters[i]; 51 if (currentFilter.values.length == 0) { 52 continue; 53 } 54 55 if (isDropDown == "true" || isDropDown == "t") { 56 var ul = filterForm.appendChild(tsCreateList(currentFilter.className + "-dropdown list-unstyled")); 57 var listItem = ul.appendChild(tsCreateListItem()); 58 var elem = document.createElement("select"); 59 elem.setAttribute("onChange", "this.form.submit();"); 60 elem.setAttribute("name", "BOset::WScontent::SearchCriteria::" + encodeURIComponent(currentFilter.name)); 61 if (currentFilter.values.length > 1) { 62 var defaultOption = document.createElement("option"); 63 defaultOption.value = ""; 64 defaultOption.appendChild(document.createTextNode(currentFilter.label)) 65 elem.appendChild(defaultOption) 66 } 67 for (var j = 0; j < currentFilter.values.length; j++) { 68 var boundValue = currentFilter.values[j][0]; 69 var boundLabel = currentFilter.values[j][1]; 70 var url = currentPage; 71 url += "?BOset::WScontent::SearchCriteria::" + encodeURIComponent(currentFilter.name) + "=" + encodeURIComponent(boundValue); 72 url += "&BOparam::WScontent::search::article_search_id=" + this.articleContext.articleId; 73 url += "&doWork::WScontent::search"; 74 75 var addOption = document.createElement("option") 76 addOption.value = boundValue; 77 addOption.appendChild(document.createTextNode(boundLabel)); 78 elem.appendChild(addOption); 79 } 80 listItem.appendChild(elem); 81 82 } else { 83 var heading = document.createElement("h3"); 84 heading.id = currentFilter.label + idCount; 85 idCount++; 86 heading.appendChild(tsCreateSpan(currentFilter.label)); 87 container.appendChild(heading); 88 container.setAttribute("role","navigation"); 89 container.setAttribute("aria-labelledby", heading.id); 90 var ul = container.appendChild(tsCreateList(currentFilter.className + " list-unstyled")); 91 for (var j = 0; j < currentFilter.values.length; j++) 92 { 93 var newItem = this.renderFilterElement(ul, currentFilter, currentFilter.values[j], currentPage); 94 95 if(currentFilter.children!=undefined && currentFilter.children.length>0) 96 { 97 for (var k = 0; k < currentFilter.children.length; k++) 98 { 99 if(currentFilter.children[k].parentName != currentFilter.values[j][0]) continue; 100 101 var currentChild = currentFilter.children[k]; 102 var elemId = "Filters::"+currentChild.parentName+"::"+currentChild.name; 103 if(currentChild.values.length>0) 104 { 105 var expandListImg = document.createElement("img"); 106 expandListImg.src = currentChild.selectedValue ? "/Images/cminus.gif" : "/Images/cplus.gif"; 107 newItem.appendChild(expandListImg); 108 expandListImg.setAttribute("onclick", "tsToggleChildFilter(event, '"+elemId+"')" ); 109 } 110 var newSubItem = newItem.appendChild(tsCreateList(currentChild.className + " list-unstyled")); 111 newSubItem.id = elemId; 112 newSubItem.style.display = currentChild.selectedValue ? "block" : "none"; 113 114 for (var p = 0; p < currentChild.values.length; p++) 115 { 116 this.renderFilterElement(newSubItem, currentChild, currentChild.values[p], currentPage); 117 } 118 if (currentChild.selectedValue) { 119 var clearUrl = currentPage; 120 clearUrl += "?BOset::WScontent::SearchCriteria::" + encodeURIComponent(currentChild.name) + "="; 121 clearUrl += "&BOparam::WScontent::search::article_search_id=" + this.articleContext.articleId; 122 clearUrl += "&doWork::WScontent::search";
123 var clearItem = newSubItem.appendChild(tsCreateListItem("clear-filter")); 124 clearItem.appendChild(tsCreateLink(clearUrl, currentChild.clearFilterLabel)); 125 } 126 } 127 } 128 } 129 } 130 if (currentFilter.selectedValue) { 131 var clearUrl = currentPage; 132 clearUrl += "?BOset::WScontent::SearchCriteria::" + encodeURIComponent(currentFilter.name) + "="; // Clear value 133 clearUrl += "&BOparam::WScontent::search::article_search_id=" + this.articleContext.articleId; 134 clearUrl += "&doWork::WScontent::search"; 135 var clearItem = ul.appendChild(tsCreateListItem("clear-filter")); 136 clearItem.appendChild(tsCreateLink(clearUrl, currentFilter.clearFilterLabel)); 137 } 138 } 139}; 140 141 142SearchFilterWidget.prototype.renderFilterElement = function (parentElement, currentFilter, currentValues, currentPage) 143{ 144 var listItem = parentElement.appendChild(tsCreateListItem()); 145 var boundValue = currentValues[0]; 146 var boundLabel = currentValues[1]; 147 148 var url = currentPage; 149 url += "?BOset::WScontent::SearchCriteria::" + encodeURIComponent(currentFilter.name) + "=" + encodeURIComponent(boundValue); 150 url += "&BOparam::WScontent::search::article_search_id=" + this.articleContext.articleId; 151 url += "&doWork::WScontent::search"; 152 153 var elem = document.createElement("a"); 154 elem.href = url; 155 elem.title = boundLabel; 156 elem.appendChild(document.createTextNode(boundLabel)); 157 158 listItem.appendChild(elem); 159 160 if (boundValue === currentFilter.selectedValue) { 161 elem.appendChild(tsCreateSpan("*")); 162 elem.title += "*"; 163 } 164 165 return listItem; 166}; 167 168 169 170
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.