summaryrefslogtreecommitdiffstats
path: root/core/js/js.js
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-12-06 00:53:06 +0100
committerJörn Friedrich Dreyer <jfd@butonic.de>2015-01-02 10:28:41 +0100
commitd3662722f66eb5b97593922a11e5357eff0fb042 (patch)
treedd45389e024f914ff5e454e0523b82f3349fdd48 /core/js/js.js
parent0ba3093196fee7079583847b40ef3a8e00df47a7 (diff)
downloadnextcloud-server-d3662722f66eb5b97593922a11e5357eff0fb042.tar.gz
nextcloud-server-d3662722f66eb5b97593922a11e5357eff0fb042.zip
new OC.Search, add search result formatters and handlers, use full content width for results
Diffstat (limited to 'core/js/js.js')
-rw-r--r--core/js/js.js77
1 files changed, 57 insertions, 20 deletions
diff --git a/core/js/js.js b/core/js/js.js
index 57ce1ab6955..9d62b7cac1e 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -319,8 +319,8 @@ var OC={
}
}
$.getJSON(OC.generateUrl('search/ajax/search.php'), {inApps:inApps, query:query}, function(results){
- OC.search.lastResults=results;
- OC.search.showResults(results);
+ OC.Search.lastResults=results;
+ OC.Search.showResults(results);
});
}
}, 500),
@@ -608,10 +608,47 @@ OC.Plugins = {
/**
* @namespace OC.search
*/
-OC.search.customResults={};
-OC.search.currentResult=-1;
-OC.search.lastQuery='';
-OC.search.lastResults={};
+OC.search.customResults = {};
+/**
+ * @deprecated use get/setFormatter() instead
+ */
+OC.search.resultTypes = {};
+
+/**
+ * @namespace OC.Search
+ */
+OC.Search = {
+ /**
+ * contains closures that are called to format search results
+ */
+ formatter:{},
+ setFormatter: function(type, formatter) {
+ this.formatter[type] = formatter;
+ },
+ hasFormatter: function(type) {
+ return typeof this.formatter[type] !== 'undefined';
+ },
+ getFormatter: function(type) {
+ return this.formatter[type];
+ },
+ /**
+ * contains closures that are called when a search result has been clicked
+ */
+ handler:{},
+ setHandler: function(type, handler) {
+ this.handler[type] = handler;
+ },
+ hasHandler: function(type) {
+ return typeof this.handler[type] !== 'undefined';
+ },
+ getHandler: function(type) {
+ return this.handler[type];
+ },
+ currentResult:-1,
+ lastQuery:'',
+ lastResults:{}
+};
+
OC.addStyle.loaded=[];
OC.addScript.loaded=[];
@@ -1043,38 +1080,38 @@ function initCore() {
});
$('#searchbox').keyup(function(event){
if(event.keyCode===13){//enter
- if(OC.search.currentResult>-1){
- var result=$('#searchresults tr.result a')[OC.search.currentResult];
+ if(OC.Search.currentResult>-1){
+ var result=$('#searchresults tr.result a')[OC.Search.currentResult];
window.location = $(result).attr('href');
}
}else if(event.keyCode===38){//up
- if(OC.search.currentResult>0){
- OC.search.currentResult--;
- OC.search.renderCurrent();
+ if(OC.Search.currentResult>0){
+ OC.Search.currentResult--;
+ OC.Search.renderCurrent();
}
}else if(event.keyCode===40){//down
- if(OC.search.lastResults.length>OC.search.currentResult+1){
- OC.search.currentResult++;
- OC.search.renderCurrent();
+ if(OC.Search.lastResults.length>OC.Search.currentResult+1){
+ OC.Search.currentResult++;
+ OC.Search.renderCurrent();
}
}else if(event.keyCode===27){//esc
- OC.search.hide();
+ OC.Search.hide();
if (FileList && typeof FileList.unfilter === 'function') { //TODO add hook system
FileList.unfilter();
}
}else{
var query=$('#searchbox').val();
- if(OC.search.lastQuery!==query){
- OC.search.lastQuery=query;
- OC.search.currentResult=-1;
+ if(OC.Search.lastQuery!==query){
+ OC.Search.lastQuery=query;
+ OC.Search.currentResult=-1;
if (FileList && typeof FileList.filter === 'function') { //TODO add hook system
FileList.filter(query);
}
if(query.length>2){
OC.search(query);
}else{
- if(OC.search.hide){
- OC.search.hide();
+ if(OC.Search.hide){
+ OC.Search.hide();
}
}
}