diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-05 23:52:39 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-05 23:52:39 +0100 |
commit | a6764bf5775ec5cdcf1c45b98246fa7b475345ab (patch) | |
tree | 5906d4f67b79ba36b800e3973729592bf2c10bf3 /module/web | |
parent | working search suggestions (diff) | |
download | pyload-a6764bf5775ec5cdcf1c45b98246fa7b475345ab.tar.xz |
working search for files
Diffstat (limited to 'module/web')
-rw-r--r-- | module/web/static/css/default/style.less | 2 | ||||
-rw-r--r-- | module/web/static/js/models/Package.js | 11 | ||||
-rw-r--r-- | module/web/static/js/views/filterView.js | 27 | ||||
-rw-r--r-- | module/web/templates/default/dashboard.html | 2 |
4 files changed, 35 insertions, 7 deletions
diff --git a/module/web/static/css/default/style.less b/module/web/static/css/default/style.less index 260f9fa52..d3f23478f 100644 --- a/module/web/static/css/default/style.less +++ b/module/web/static/css/default/style.less @@ -422,7 +422,7 @@ footer { // background-color: @greyDark; background: url("../../img/default/bgpatterndark.png") repeat;
color: @grey;
height: @footer-height;
- margin-top: -@footer-height;
+ margin-top: -@footer-height + 10px;
position: relative;
width: 100%;
line-height: 16px;
diff --git a/module/web/static/js/models/Package.js b/module/web/static/js/models/Package.js index c5eb3eaac..ba024381e 100644 --- a/module/web/static/js/models/Package.js +++ b/module/web/static/js/models/Package.js @@ -41,6 +41,15 @@ define(['jquery', 'backbone', 'underscore', 'collections/FileList', 'require'], return Backbone.Model.prototype.fetch.call(this, options); }, + // Create a pseudo package und use search to populate data + search: function(qry, options) { + options || (options = {}); + options.url = 'api/findFiles/"' + qry + '"'; + options.type = "post"; + + return Backbone.Model.prototype.fetch.call(this, options); + }, + save: function(options) { // TODO }, @@ -67,7 +76,7 @@ define(['jquery', 'backbone', 'underscore', 'collections/FileList', 'require'], parse: function(resp) { // Package is loaded from tree collection if (_.has(resp, 'root')) { - if(!this.has('files')) + if (!this.has('files')) resp.root.files = new FileList(_.values(resp.files)); else this.get('files').update(_.values(resp.files)); 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)}, diff --git a/module/web/templates/default/dashboard.html b/module/web/templates/default/dashboard.html index cfd5a2716..8c20973e4 100644 --- a/module/web/templates/default/dashboard.html +++ b/module/web/templates/default/dashboard.html @@ -125,7 +125,7 @@ </li>
<li style="float: right;">
- <form class="form-search">
+ <form class="form-search" action="#">
<div class="input-append">
<input type="text" class="search-query" style="width: 120px">
<button type="submit" class="btn">{{ _("Search") }}</button>
|