Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-12-06 02:53:06 +0300
committerJörn Friedrich Dreyer <jfd@butonic.de>2015-01-02 12:28:41 +0300
commitd3662722f66eb5b97593922a11e5357eff0fb042 (patch)
treedd45389e024f914ff5e454e0523b82f3349fdd48 /core
parent0ba3093196fee7079583847b40ef3a8e00df47a7 (diff)
new OC.Search, add search result formatters and handlers, use full content width for results
Diffstat (limited to 'core')
-rw-r--r--core/ajax/preview.php2
-rw-r--r--core/js/js.js77
2 files changed, 58 insertions, 21 deletions
diff --git a/core/ajax/preview.php b/core/ajax/preview.php
index 56ef5ea847b..03dfb483062 100644
--- a/core/ajax/preview.php
+++ b/core/ajax/preview.php
@@ -40,9 +40,9 @@ try {
$preview->setMaxY($maxY);
$preview->setScalingUp($scalingUp);
$preview->setKeepAspect($keepAspect);
+ $preview->showPreview();
}
- $preview->showPreview();
} catch (\Exception $e) {
\OC_Response::setStatus(500);
\OC_Log::write('core', $e->getmessage(), \OC_Log::DEBUG);
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();
}
}
}