summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/views
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-05 23:52:39 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-05 23:52:39 +0100
commita6764bf5775ec5cdcf1c45b98246fa7b475345ab (patch)
tree5906d4f67b79ba36b800e3973729592bf2c10bf3 /module/web/static/js/views
parentworking search suggestions (diff)
downloadpyload-a6764bf5775ec5cdcf1c45b98246fa7b475345ab.tar.xz
working search for files
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r--module/web/static/js/views/filterView.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/module/web/static/js/views/filterView.js b/module/web/static/js/views/filterView.js
index 19501430a..14968f2cc 100644
--- a/module/web/static/js/views/filterView.js
+++ b/module/web/static/js/views/filterView.js
@@ -1,5 +1,5 @@
-define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'],
- function($, Backbone, _, App, Api) {
+define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'models/Package'],
+ function($, Backbone, _, App, Api, Package) {
// Modified version of type ahead show, nearly the same without absolute positioning
function show() {
@@ -17,7 +17,8 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'],
events: {
'click .filter-type': 'filter_type',
- 'click .filter-state': 'switch_filter'
+ 'click .filter-state': 'switch_filter',
+ 'submit .form-search': 'search'
},
state: null,
@@ -43,8 +44,26 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes'],
return this;
},
+ // TODO: app level api request
+
+ search: function(e) {
+ e.stopPropagation();
+ var input = this.$('.search-query');
+ var query = input.val();
+ input.val('');
+
+ var pack = new Package();
+ // Overwrite fetch method to use a search
+ // TODO: quite hackish, could be improved to filter packages
+ // or show performed search
+ pack.fetch = function(options) {
+ pack.search(query, options);
+ };
+
+ App.dashboard.openPackage(pack);
+ },
+
getSuggestions: function(query, callback) {
- console.log(callback);
$.ajax('/api/searchSuggestions', {
method: 'POST',
data: {pattern: JSON.stringify(query)},