Permalink
Browse files

Select the right platform from the query in the URL. Closes #13.

  • Loading branch information...
floere committed Dec 8, 2013
1 parent c5f9c50 commit 2c99ac47d9831ae1a013ebb194de8795ecd23532
Showing with 14 additions and 13 deletions.
  1. +14 −13 source/javascripts/search.config.js
@@ -159,9 +159,21 @@ $(window).ready(function() {
// Before a query is inserted into the search field
// we clean it of any platform terms.
//
+ // And if there are any platform terms, we select
+ // the right platform selector.
+ //
beforeInsert: function(query) {
- if ('' != query) { prepareSearchInterfaceForResults(); }
- return query.replace(platformRemoverRegexp, '');
+ if ('' != query) {
+ prepareSearchInterfaceForResults();
+ var platforms = query.match(platformRemoverRegexp);
+ if (platforms) {
+ var chosenPlatform = platformSelect.find('input[value="' + platforms[0].replace(/\s+$/g, '') + '"]');
+ chosenPlatform.attr('checked', 'checked');
+ platformSelect.find('label').removeClass('selected');
+ platformSelect.find('input:checked + label').addClass('selected');
+ }
+ return query.replace(platformRemoverRegexp, '');
+ }
},
// Before Picky sends any data to the server.
//
@@ -337,17 +349,6 @@ $(window).ready(function() {
selectCheckedPlatform();
$("#pod_search").focus();
});
-
- // Initially select the right platform.
- //
- selectCheckedPlatform();
-
- // Initially insert the query given in the URL
- // if there is one.
- //
- if (window.initial_query != "") {
- pickyClient.insertFromURL(window.initial_query);
- }
// Make all clicks in the search container set focus.
//

0 comments on commit 2c99ac4

Please sign in to comment.