From 06e53b359ac806b9103cb617e7a6bad8cbadb519 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 20 May 2014 11:44:18 +0200 Subject: Added "dir" in file actions handler context and fixed versions Added "dir" in file actions handler context so that handlers can know what the path of the file was without having to look it up from the file list. Fixed versions app to use the context.dir instead of the old $('#dir') element. This makes the versions popup work in the sharing overview. --- apps/files_versions/js/versions.js | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'apps/files_versions') diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index b452bc25b13..a23935495d7 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -1,3 +1,14 @@ +/* + * Copyright (c) 2014 + * + * This file is licensed under the Affero General Public License version 3 + * or later. + * + * See the COPYING-README file. + * + */ + +/* global FileActions, scanFiles, escapeHTML, formatDate */ $(document).ready(function(){ if ($('#isPublic').val()){ @@ -10,18 +21,17 @@ $(document).ready(function(){ if (typeof FileActions !== 'undefined') { // Add versions button to 'files/index.php' FileActions.register( - 'file' - , 'Versions' - , OC.PERMISSION_UPDATE - , function() { + 'file', + 'Versions', + OC.PERMISSION_UPDATE, + function() { // Specify icon for hitory button return OC.imagePath('core','actions/history'); - } - ,function(filename){ + }, function(filename, context){ // Action to perform when clicked if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback - var file = $('#dir').val().replace(/(?!<=\/)$|\/$/, '/' + filename); + var file = context.dir.replace(/(?!<=\/)$|\/$/, '/' + filename); var createDropDown = true; // Check if drop down is already visible for a different file if (($('#dropdown').length > 0) ) { @@ -33,10 +43,9 @@ $(document).ready(function(){ } if(createDropDown === true) { - createVersionsDropdown(filename, file); + createVersionsDropdown(filename, file, context.fileList); } - } - , t('files_versions', 'Versions') + }, t('files_versions', 'Versions') ); } @@ -75,7 +84,7 @@ function goToVersionPage(url){ window.location.assign(url); } -function createVersionsDropdown(filename, files) { +function createVersionsDropdown(filename, files, fileList) { var start = 0; var fileEl; @@ -88,7 +97,7 @@ function createVersionsDropdown(filename, files) { html += ''; if (filename) { - fileEl = FileList.findFileEl(filename); + fileEl = fileList.findFileEl(filename); fileEl.addClass('mouseOver'); $(html).appendTo(fileEl.find('td.filename')); } else { -- cgit v1.2.3