-
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 all 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 ); | ||
|
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. During our next technical touchpoint with GC Search team, let's make it an item to consider and test this in case of edge cases such as other parameters used; I'm thinking Canadian Food Guide (https://food-guide.canada.ca/en/), as well as Canada Gazette (https://gazette.gc.ca/accueil-home-eng.html). |
||
| } | ||
| } | ||
|
|
||
| // 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; | ||
|
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 remove this line since the style will apply from line 44 in this file instead. And please ensure the border color is consistent. |
||
| 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.
You should use params.actionCause on this line