diff options
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/file-upload.js | 2 | ||||
-rw-r--r-- | apps/files/js/fileactions.js | 12 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 35 | ||||
-rw-r--r-- | apps/files/js/files.js | 7 |
4 files changed, 52 insertions, 4 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 402dd5075e7..42f08112619 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -260,6 +260,7 @@ $(document).ready(function() { getMimeIcon(result.data.mime,function(path){ tr.find('td.filename').attr('style','background-image:url('+path+')'); }); + FileActions.display(tr.find('td.filename'), true); } else { OC.dialogs.alert(result.data.message, t('core', 'Error')); } @@ -324,6 +325,7 @@ $(document).ready(function() { getMimeIcon(mime,function(path){ tr.find('td.filename').attr('style','background-image:url('+path+')'); }); + FileActions.display(tr.find('td.filename'), true); }); eventSource.listen('error',function(error){ $('#uploadprogressbar').fadeOut(); diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 5976bb49912..dbbc57c3b6a 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -61,7 +61,13 @@ var FileActions = { var actions = this.get(mime, type, permissions); return actions[name]; }, - display: function (parent) { + /** + * Display file actions for the given element + * @param parent "td" element of the file for which to display actions + * @param triggerEvent if true, triggers the fileActionsReady on the file + * list afterwards (false by default) + */ + display: function (parent, triggerEvent) { FileActions.currentFile = parent; var actions = FileActions.get(FileActions.getCurrentMimeType(), FileActions.getCurrentType(), FileActions.getCurrentPermissions()); var file = FileActions.getCurrentFile(); @@ -140,6 +146,10 @@ var FileActions = { element.on('click', {a: null, elem: parent, actionFunc: actions['Delete']}, actionHandler); parent.parent().children().last().append(element); } + + if (triggerEvent){ + $('#fileList').trigger(jQuery.Event("fileActionsReady")); + } }, getCurrentFile: function () { return FileActions.currentFile.parent().attr('data-file'); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 40a4ae95c98..7863903fa19 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -130,7 +130,7 @@ var FileList={ if (hidden) { tr.hide(); } - FileActions.display(tr.find('td.filename')); + FileActions.display(tr.find('td.filename'), true); return tr; }, refresh:function(data) { @@ -367,6 +367,37 @@ var FileList={ }); } }); + }, + scrollTo:function(file) { + //scroll to and highlight preselected file + var $scrolltorow = $('tr[data-file="'+file+'"]'); + if ($scrolltorow.exists()) { + $scrolltorow.addClass('searchresult'); + $(window).scrollTop($scrolltorow.position().top); + //remove highlight when hovered over + $scrolltorow.one('hover', function() { + $scrolltorow.removeClass('searchresult'); + }); + } + }, + filter:function(query) { + $('#fileList tr:not(.summary)').each(function(i,e) { + if ($(e).data('file').toString().toLowerCase().indexOf(query.toLowerCase()) !== -1) { + $(e).addClass("searchresult"); + } else { + $(e).removeClass("searchresult"); + } + }); + //do not use scrollto to prevent removing searchresult css class + var first = $('#fileList tr.searchresult').first(); + if (first.exists()) { + $(window).scrollTop(first.position().top); + } + }, + unfilter:function() { + $('#fileList tr.searchresult').each(function(i,e) { + $(e).removeClass("searchresult"); + }); } }; @@ -473,7 +504,7 @@ $(document).ready(function(){ data.context.attr('data-permissions', file.permissions); data.context.data('permissions', file.permissions); } - FileActions.display(data.context.find('td.filename')); + FileActions.display(data.context.find('td.filename'), true); if (FileList.loadingDone) { FileList.loadingDone(file.name, file.id); } diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 7581ff3ec56..d8aca4dd26a 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -546,6 +546,11 @@ $(document).ready(function() { } }); } + + //scroll to and highlight preselected file + if (getURLParameter('scrollto')) { + FileList.scrollTo(getURLParameter('scrollto')); + } }); function scanFiles(force, dir, users){ @@ -666,7 +671,7 @@ var folderDropOptions={ return false; } - var target=$.trim($(this).find('.nametext').text()); + var target = $(this).closest('tr').data('file'); var files = ui.helper.find('tr'); $(files).each(function(i,row){ |