Merge branch 'master' into sharing
This commit is contained in:
commit
17058c9467
9 changed files with 122 additions and 45 deletions
|
@ -1,8 +1,6 @@
|
|||
<?php
|
||||
|
||||
if(OC_App::getCurrentApp()=='files'){
|
||||
OC_Util::addScript( 'files_imageviewer', 'lightbox' );
|
||||
OC_Util::addStyle( 'files_imageviewer', 'lightbox' );
|
||||
}
|
||||
OC_Util::addScript( 'files_imageviewer', 'lightbox' );
|
||||
OC_Util::addStyle( 'files_imageviewer', 'lightbox' );
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,31 +1,48 @@
|
|||
|
||||
var lightBoxShown=false;
|
||||
$(document).ready(function() {
|
||||
images={};//image cache
|
||||
var overlay=$('<div id="lightbox_overlay"/>');
|
||||
$( 'body' ).append(overlay);
|
||||
var container=$('<div id="lightbox"/>');
|
||||
$( 'body' ).append(container);
|
||||
$( 'body' ).click(hideLightbox);
|
||||
if(typeof FileActions!=='undefined'){
|
||||
images={};//image cache
|
||||
var overlay=$('<div id="lightbox_overlay"/>');
|
||||
$( 'body' ).append(overlay);
|
||||
var container=$('<div id="lightbox"/>');
|
||||
$( 'body' ).append(container);
|
||||
FileActions.register('image','View','',function(filename){
|
||||
var location='ajax/download.php?files='+filename+'&dir='+$('#dir').val();
|
||||
overlay.show();
|
||||
if(!images[location]){
|
||||
var img = new Image();
|
||||
img.onload = function(){
|
||||
images[location]=img;
|
||||
showLightbox(container,img);
|
||||
}
|
||||
img.src = location;
|
||||
}else{
|
||||
showLightbox(container,images[location]);
|
||||
}
|
||||
viewImage($('#dir').val(),filename);
|
||||
});
|
||||
$( 'body' ).click(hideLightbox);
|
||||
FileActions.setDefault('image','View');
|
||||
}
|
||||
OC.search.customResults.Images=function(row,item){
|
||||
var image=item.link.substr(item.link.indexOf('file=')+5);
|
||||
var a=row.find('a');
|
||||
var container=$('<div id="lightbox"/>');
|
||||
a.attr('href','#');
|
||||
a.click(function(){
|
||||
var file=image.split('/').pop();
|
||||
var dir=image.substr(0,image.length-file.length-1);
|
||||
viewImage(dir,file);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function viewImage(dir,file){
|
||||
var location=OC.filePath('files','ajax','download.php')+'?files='+file+'&dir='+dir;
|
||||
var overlay=$('#lightbox_overlay');
|
||||
var container=$('#lightbox');
|
||||
overlay.show();
|
||||
if(!images[location]){
|
||||
var img = new Image();
|
||||
img.onload = function(){
|
||||
images[location]=img;
|
||||
showLightbox(container,img);
|
||||
}
|
||||
img.src = location;
|
||||
}else{
|
||||
showLightbox(container,images[location]);
|
||||
}
|
||||
}
|
||||
|
||||
function showLightbox(container,img){
|
||||
var maxWidth = $( window ).width() - 50;
|
||||
var maxHeight = $( window ).height() - 50;
|
||||
|
@ -49,8 +66,9 @@ function showLightbox(container,img){
|
|||
},100);
|
||||
}
|
||||
|
||||
function hideLightbox(){
|
||||
function hideLightbox(event){
|
||||
if(lightBoxShown){
|
||||
event.stopPropagation();
|
||||
$('#lightbox_overlay').hide();
|
||||
$('#lightbox').hide();
|
||||
lightBoxShown=false;
|
||||
|
|
|
@ -70,14 +70,18 @@ OC={
|
|||
},
|
||||
search:function(query){
|
||||
if(query){
|
||||
OC.addScript('search','result',function(){
|
||||
OC.addStyle('search','results');
|
||||
$.getJSON(OC.filePath('search','ajax','search.php')+'?query='+encodeURIComponent(query), OC.search.showResults);
|
||||
OC.addStyle('search','results');
|
||||
$.getJSON(OC.filePath('search','ajax','search.php')+'?query='+encodeURIComponent(query), function(results){
|
||||
OC.search.lastResults=results;
|
||||
OC.search.showResults(results);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
OC.search.customResults={};
|
||||
OC.search.currentResult=-1;
|
||||
OC.search.lastQuery='';
|
||||
OC.search.lastResults={};
|
||||
OC.addStyle.loaded=[];
|
||||
OC.addScript.loaded=[];
|
||||
|
||||
|
@ -133,15 +137,40 @@ $(document).ready(function(){
|
|||
element.attr('src',src.substr(0,src.length-3)+'png');
|
||||
});
|
||||
};
|
||||
$('#searchbox').keyup(function(){
|
||||
var query=$('#searchbox').val();
|
||||
if(query.length>2){
|
||||
OC.search(query);
|
||||
$('form.searchbox').submit(function(event){
|
||||
event.preventDefault();
|
||||
})
|
||||
$('#searchbox').keyup(function(event){
|
||||
if(event.keyCode==13){//enter
|
||||
if(OC.search.currentResult>-1){
|
||||
var result=$('#searchresults tr.result a')[OC.search.currentResult];
|
||||
$(result).click();
|
||||
}
|
||||
}else if(event.keyCode==38){//up
|
||||
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();
|
||||
}
|
||||
}else if(event.keyCode==27){//esc
|
||||
OC.search.hide();
|
||||
}else{
|
||||
if(OC.search.hide){
|
||||
OC.search.hide();
|
||||
var query=$('#searchbox').val();
|
||||
if(OC.search.lastQuery!=query){
|
||||
OC.search.lastQuery=query;
|
||||
OC.search.currentResult=-1;
|
||||
if(query.length>2){
|
||||
OC.search(query);
|
||||
}else{
|
||||
if(OC.search.hide){
|
||||
OC.search.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#searchbox').click(function(){$('#searchbox').trigger('keyup')});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<form class="searchbox" action="<?php echo $_['searchurl']?>" method="post">
|
||||
<form class="searchbox" action="#" method="post">
|
||||
<input id='searchbox' type="search" name="query" value="<?php if(isset($_POST['query'])){echo $_POST['query'];};?>" class="prettybutton" />
|
||||
</form>
|
||||
|
|
15
lib/base.php
15
lib/base.php
|
@ -91,6 +91,14 @@ if( !OC_Config::getValue( "installed", false )){
|
|||
OC_User::useBackend( OC_Config::getValue( "userbackend", "database" ));
|
||||
OC_Group::setBackend( OC_Config::getValue( "groupbackend", "database" ));
|
||||
|
||||
// Add the stuff we need always
|
||||
OC_Util::addScript( "jquery-1.6.2.min" );
|
||||
OC_Util::addScript( "jquery-ui-1.8.14.custom.min" );
|
||||
OC_Util::addScript( "js" );
|
||||
OC_Util::addScript('search','result');
|
||||
OC_Util::addStyle( "jquery-ui-1.8.14.custom" );
|
||||
OC_Util::addStyle( "styles" );
|
||||
|
||||
// Load Apps
|
||||
// This includes plugins for users and filesystems as well
|
||||
if(!$error and !$RUNTIME_NOAPPS ){
|
||||
|
@ -107,13 +115,6 @@ if(!$error and !$RUNTIME_NOSETUPFS ){
|
|||
OC_Util::setupFS();
|
||||
}
|
||||
|
||||
// Add the stuff we need always
|
||||
OC_Util::addScript( "jquery-1.6.2.min" );
|
||||
OC_Util::addScript( "jquery-ui-1.8.14.custom.min" );
|
||||
OC_Util::addScript( "js" );
|
||||
OC_Util::addStyle( "jquery-ui-1.8.14.custom" );
|
||||
OC_Util::addStyle( "styles" );
|
||||
|
||||
|
||||
// FROM Connect.php
|
||||
function OC_CONNECT_TEST($path,$user,$password){
|
||||
|
|
|
@ -574,14 +574,17 @@ class OC_Filesystem{
|
|||
|
||||
static public function search($query){
|
||||
$files=array();
|
||||
$fakeRootLength=strlen(self::$fakeRoot);
|
||||
$fakeRoot=self::$fakeRoot;
|
||||
$fakeRootLength=strlen($fakeRoot);
|
||||
foreach(self::$storages as $mountpoint=>$storage){
|
||||
$results=$storage->search($query);
|
||||
if(is_array($results)){
|
||||
foreach($results as $result){
|
||||
$file=str_replace('//','/',$mountpoint.$result);
|
||||
$file=substr($file,$fakeRootLength);
|
||||
$files[]=$file;
|
||||
if(substr($file,0,$fakeRootLength)==$fakeRoot){
|
||||
$file=substr($file,$fakeRootLength);
|
||||
$files[]=$file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,17 @@ class OC_Search_Provider_File extends OC_Search_Provider{
|
|||
if(OC_Filesystem::is_dir($file)){
|
||||
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'index.php?dir='.$file ),'Files');
|
||||
}else{
|
||||
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Files');
|
||||
$mime=OC_Filesystem::getMimeType($file);
|
||||
$mimeBase=substr($mime,0,strpos($mime,'/'));
|
||||
switch($mimeBase){
|
||||
case 'audio':
|
||||
break;
|
||||
case 'image':
|
||||
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Images');
|
||||
break;
|
||||
default:
|
||||
$results[]=new OC_Search_Result(basename($file),'',OC_Helper::linkTo( 'files', 'download.php?file='.$file ),'Files');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
#searchresults td.result{width:30em;}
|
||||
#searchresults td.result *{cursor:pointer}
|
||||
#searchresults td.type{width:7em;text-align:right; border-right:1px solid #aaa;border-bottom:none}
|
||||
#searchresults tr.current{background-color:#ddd}
|
||||
|
|
|
@ -16,6 +16,9 @@ OC.search.hide=function(){
|
|||
};
|
||||
}
|
||||
OC.search.showResults=function(results){
|
||||
if(results.length==0){
|
||||
return;
|
||||
}
|
||||
if(!OC.search.showResults.loaded){
|
||||
var parent=$('<div/>');
|
||||
$('body').append(parent);
|
||||
|
@ -27,12 +30,14 @@ OC.search.showResults=function(results){
|
|||
$(window).click(function(event){
|
||||
OC.search.hide();
|
||||
});
|
||||
OC.search.lastResults=results;
|
||||
OC.search.showResults(results);
|
||||
});
|
||||
}else{
|
||||
var types=OC.search.catagorizeResults(results);
|
||||
$('#searchresults').show();
|
||||
$('#searchresults tr.result').remove();
|
||||
var index=0;
|
||||
for(var name in types){
|
||||
var type=types[name];
|
||||
if(type.length>0){
|
||||
|
@ -43,6 +48,8 @@ OC.search.showResults=function(results){
|
|||
row.find('td.result a').attr('href',type[0].link);
|
||||
row.find('td.result div.name').text(type[0].name);
|
||||
row.find('td.result div.text').text(type[0].text);
|
||||
row.data('index',index);
|
||||
index++;
|
||||
if(OC.search.customResults[name]){//give plugins the ability to customize the entries in here
|
||||
OC.search.customResults[name](row,type[0]);
|
||||
}
|
||||
|
@ -54,6 +61,8 @@ OC.search.showResults=function(results){
|
|||
row.find('td.result a').attr('href',type[i].link);
|
||||
row.find('td.result div.name').text(type[i].name);
|
||||
row.find('td.result div.text').text(type[i].text);
|
||||
row.data('index',index);
|
||||
index++;
|
||||
if(OC.search.customResults[name]){//give plugins the ability to customize the entries in here
|
||||
OC.search.customResults[name](row,type[i]);
|
||||
}
|
||||
|
@ -64,3 +73,11 @@ OC.search.showResults=function(results){
|
|||
}
|
||||
}
|
||||
OC.search.showResults.loaded=false;
|
||||
|
||||
OC.search.renderCurrent=function(){
|
||||
if($('#searchresults tr.result')[OC.search.currentResult]){
|
||||
var result=$('#searchresults tr.result')[OC.search.currentResult];
|
||||
$('#searchresults tr.result').removeClass('current');
|
||||
$(result).addClass('current');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue