commonsearch / cosr-front

Frontend of Common Search. Go server for fetching and rendering results + HTML5 UI to browse them.
https://uidemo.commonsearch.org
Apache License 2.0
60 stars 13 forks source link

Keep language in logo link #32

Closed chaconnewu closed 8 years ago

chaconnewu commented 8 years ago

This commit approaches the issue by clearing current search states, cancelling any pending timeouts, and appending the language to the url using window.history.pushState

sylvinus commented 8 years ago

Hi @chaconnewu!

Thanks for the patch!

However I think it's a bit too complex for what we want to achieve here. We are going to add more and more state into the page, and we'll need to clear that all just to make the logo link work again. Also transforming the <a> into a <div> is not good for javascript-less browsers.

Wouldn't it be more simple to just update the logo link dynamically and have the page reset entirely when the user follows the link?

chaconnewu commented 8 years ago

@sylvinus Thanks a lot for the comments and suggestions! I totally agree with you. What about the new implementation in the new commit? It pretty much follows what you described.

sylvinus commented 8 years ago

Great! Maybe we should do it in the eltLang.onchange instead?

chaconnewu commented 8 years ago

If we do it in eltLang.onchange, the language will be reset after page is reloaded, and you have to select the dropdown again in order retain the language postfix. Putting it in eltLogo will not have this issue. Or did I misunderstand the original issue?

sylvinus commented 8 years ago

Right - we should also change the link in the HTML template so that the right language is in the link when the page reloads?

chaconnewu commented 8 years ago

I used a function to set the href for logo when page load or language is selected with dropdown.

sylvinus commented 8 years ago

Great, thanks!