-
Notifications
You must be signed in to change notification settings - Fork 12
add header search box suggestions #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,6 +163,16 @@ function initSearchUI() { | |
| if (urlParams.sort) { | ||
| params.sort = urlParams.sort; | ||
| } | ||
| // set the custom action cause for the initial search | ||
| if ( urlParams.actionCause ) { | ||
| params.actionCause = urlParams.actionCause; | ||
|
|
||
| // changing the URL without reloading the page to remove actionCause | ||
| if ( window.history.pushState ) { | ||
| var newurl = winLoc.href.replace( '&actionCause=' + urlParams.actionCause, '' ); | ||
|
||
| window.history.pushState( { path : newurl }, '', newurl ); | ||
GormFrank marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use replaceState instead of pushState because we don't want users to hit previous and bring them bakc to the actionCause. |
||
| } | ||
| } | ||
|
|
||
| // Auto detect relative path from originLevel3 | ||
| if( !params.originLevel3.startsWith( "/" ) && /http|www/.test( params.originLevel3 ) ) { | ||
|
|
@@ -585,6 +595,12 @@ function initEngine() { | |
| // filter user sensitive content | ||
| requestContent.originLevel3 = params.originLevel3; | ||
|
|
||
| // override actionCause if present | ||
| if ( params.actionCause ) { | ||
| requestContent.actionCause = params.actionCause; | ||
| params.actionCause = ""; // reset the parameter to avoid polluting future searches with the same action cause | ||
| } | ||
|
|
||
| // documentAuthor cannot be longer than 128 chars based on search platform | ||
| if ( requestContent.documentAuthor ) { | ||
| requestContent.documentAuthor = requestContent.documentAuthor.substring( 0, 128 ); | ||
|
|
@@ -612,6 +628,11 @@ function initEngine() { | |
| requestContent.analytics.originLevel3 = params.originLevel3; | ||
| } | ||
|
|
||
| // override actionCause if present | ||
| if ( params.actionCause ) { | ||
| requestContent.analytics.actionCause = params.actionCause; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't you need to clear |
||
| } | ||
|
|
||
| let q = requestContent.q; | ||
| requestContent.q = sanitizeQuery( q ); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Search UI: Styles for Query suggestion List "combobox", TO BE eventually replaced by GCWeb reference implementation codebase | ||
| */ | ||
| .query-suggestions { | ||
| background-color: white; | ||
| border-bottom: 1px solid #ccc; | ||
|
||
| border-left: 1px solid #e0e0e0; | ||
| border-right: 1px solid #e0e0e0; | ||
| width: calc(100% - 30px); | ||
| cursor: pointer; | ||
| list-style-type: none; | ||
| padding: 0; | ||
| position: absolute; | ||
| z-index: 60; | ||
| } | ||
|
|
||
| .query-suggestions li { | ||
| padding: 5px 10px 5px 30px; | ||
| position: relative; | ||
| } | ||
|
|
||
| .query-suggestions li:hover { | ||
| background-color: #ddd; | ||
| } | ||
|
|
||
| .query-suggestions .suggestion-item::before { | ||
| content: "\e003"; | ||
| font-family: "Glyphicons Halflings"; | ||
| font-size: 0.8em; | ||
| line-height: 1.4; | ||
| margin-right: 12px; | ||
| position: relative; | ||
| top: 1px; | ||
| position: absolute; | ||
| transform: translateY(50%); | ||
| left: 8px; | ||
| } | ||
|
|
||
| .query-suggestions .selected-suggestion { | ||
| background-color: #ddd; | ||
| } | ||
|
|
||
| .query-suggestions:has(li) { | ||
| border-bottom: 1px solid #ccc; | ||
| } | ||
|
|
||
| @media screen and (max-width: 991px) { | ||
| .query-suggestions { | ||
| position: relative; | ||
| width: 100%; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bblaisATcoveo Not that there is any changes required here, but please take a moment to brainstorm if there should be an additional condition as part of this
if. I was thinking not an advanced search for instance but I don't think it is a problem if it is... Leaving it to you to figure if other conditions apply.