commit
6d3b61f388
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
"camelCase": true,
|
||||||
|
"eqeqeq": true,
|
||||||
|
"immed": true,
|
||||||
|
"latedef": false,
|
||||||
|
"noarg": true,
|
||||||
|
"nonbsp": true,
|
||||||
|
"undef": true,
|
||||||
|
"unused": true,
|
||||||
|
"trailing": true,
|
||||||
|
"maxparams": 5,
|
||||||
|
"curly": true,
|
||||||
|
"jquery": true,
|
||||||
|
"maxlen": 80,
|
||||||
|
"indent": 4,
|
||||||
|
"browser": true,
|
||||||
|
"globals": {
|
||||||
|
"console": true,
|
||||||
|
"it": true,
|
||||||
|
"itx": true,
|
||||||
|
"expect": true,
|
||||||
|
"describe": true,
|
||||||
|
"beforeEach": true,
|
||||||
|
"afterEach": true,
|
||||||
|
"sinon": true,
|
||||||
|
"fakeServer": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,13 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3
|
||||||
|
* or later.
|
||||||
|
*
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
function switchPublicFolder()
|
function switchPublicFolder()
|
||||||
{
|
{
|
||||||
var publicEnable = $('#publicEnable').is(':checked');
|
var publicEnable = $('#publicEnable').is(':checked');
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3
|
||||||
|
* or later.
|
||||||
|
*
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The file upload code uses several hooks to interact with blueimps jQuery file upload library:
|
* The file upload code uses several hooks to interact with blueimps jQuery file upload library:
|
||||||
* 1. the core upload handling hooks are added when initializing the plugin,
|
* 1. the core upload handling hooks are added when initializing the plugin,
|
||||||
|
@ -8,6 +18,8 @@
|
||||||
* - TODO music upload button
|
* - TODO music upload button
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global OC, t, n */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function that will allow us to know if Ajax uploads are supported
|
* Function that will allow us to know if Ajax uploads are supported
|
||||||
* @link https://github.com/New-Bamboo/example-ajax-upload/blob/master/public/index.html
|
* @link https://github.com/New-Bamboo/example-ajax-upload/blob/master/public/index.html
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2014
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3
|
||||||
|
* or later.
|
||||||
|
*
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global OC, FileList */
|
||||||
|
/* global trashBinApp */
|
||||||
var FileActions = {
|
var FileActions = {
|
||||||
actions: {},
|
actions: {},
|
||||||
defaults: {},
|
defaults: {},
|
||||||
|
@ -45,8 +57,9 @@ var FileActions = {
|
||||||
return filteredActions;
|
return filteredActions;
|
||||||
},
|
},
|
||||||
getDefault: function (mime, type, permissions) {
|
getDefault: function (mime, type, permissions) {
|
||||||
|
var mimePart;
|
||||||
if (mime) {
|
if (mime) {
|
||||||
var mimePart = mime.substr(0, mime.indexOf('/'));
|
mimePart = mime.substr(0, mime.indexOf('/'));
|
||||||
}
|
}
|
||||||
var name = false;
|
var name = false;
|
||||||
if (mime && FileActions.defaults[mime]) {
|
if (mime && FileActions.defaults[mime]) {
|
||||||
|
@ -141,13 +154,14 @@ var FileActions = {
|
||||||
parent.parent().children().last().find('.action.delete').remove();
|
parent.parent().children().last().find('.action.delete').remove();
|
||||||
if (actions['Delete']) {
|
if (actions['Delete']) {
|
||||||
var img = FileActions.icons['Delete'];
|
var img = FileActions.icons['Delete'];
|
||||||
|
var html;
|
||||||
if (img.call) {
|
if (img.call) {
|
||||||
img = img(file);
|
img = img(file);
|
||||||
}
|
}
|
||||||
if (typeof trashBinApp !== 'undefined' && trashBinApp) {
|
if (typeof trashBinApp !== 'undefined' && trashBinApp) {
|
||||||
var html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete delete-icon" />';
|
html = '<a href="#" original-title="' + t('files', 'Delete permanently') + '" class="action delete delete-icon" />';
|
||||||
} else {
|
} else {
|
||||||
var html = '<a href="#" class="action delete delete-icon" />';
|
html = '<a href="#" class="action delete delete-icon" />';
|
||||||
}
|
}
|
||||||
var element = $(html);
|
var element = $(html);
|
||||||
element.data('action', actions['Delete']);
|
element.data('action', actions['Delete']);
|
||||||
|
@ -174,10 +188,11 @@ var FileActions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
var downloadScope;
|
||||||
if ($('#allowZipDownload').val() == 1) {
|
if ($('#allowZipDownload').val() == 1) {
|
||||||
var downloadScope = 'all';
|
downloadScope = 'all';
|
||||||
} else {
|
} else {
|
||||||
var downloadScope = 'file';
|
downloadScope = 'file';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof disableDownloadActions == 'undefined' || !disableDownloadActions) {
|
if (typeof disableDownloadActions == 'undefined' || !disableDownloadActions) {
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
var FileList={
|
/*
|
||||||
|
* Copyright (c) 2014
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3
|
||||||
|
* or later.
|
||||||
|
*
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global OC, t, n, FileList, FileActions, Files */
|
||||||
|
/* global procesSelection, dragOptions, SVGSupport, replaceSVG */
|
||||||
|
window.FileList={
|
||||||
useUndo:true,
|
useUndo:true,
|
||||||
postProcessList: function() {
|
postProcessList: function() {
|
||||||
$('#fileList tr').each(function() {
|
$('#fileList tr').each(function() {
|
||||||
|
@ -191,6 +203,7 @@ var FileList={
|
||||||
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
|
return OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent(dir).replace(/%2F/g, '/');
|
||||||
},
|
},
|
||||||
setCurrentDir: function(targetDir, changeUrl) {
|
setCurrentDir: function(targetDir, changeUrl) {
|
||||||
|
var url;
|
||||||
$('#dir').val(targetDir);
|
$('#dir').val(targetDir);
|
||||||
if (changeUrl !== false) {
|
if (changeUrl !== false) {
|
||||||
if (window.history.pushState && changeUrl !== false) {
|
if (window.history.pushState && changeUrl !== false) {
|
||||||
|
|
|
@ -1,4 +1,16 @@
|
||||||
Files={
|
/*
|
||||||
|
* Copyright (c) 2014
|
||||||
|
*
|
||||||
|
* This file is licensed under the Affero General Public License version 3
|
||||||
|
* or later.
|
||||||
|
*
|
||||||
|
* See the COPYING-README file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global OC, t, n, FileList, FileActions */
|
||||||
|
/* global getURLParameter, isPublic */
|
||||||
|
var Files = {
|
||||||
// file space size sync
|
// file space size sync
|
||||||
_updateStorageStatistics: function() {
|
_updateStorageStatistics: function() {
|
||||||
Files._updateStorageStatisticsTimeout = null;
|
Files._updateStorageStatisticsTimeout = null;
|
||||||
|
@ -68,17 +80,25 @@ Files={
|
||||||
return fileName;
|
return fileName;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the given file name is valid.
|
||||||
|
* @param name file name to check
|
||||||
|
* @return true if the file name is valid.
|
||||||
|
* Throws a string exception with an error message if
|
||||||
|
* the file name is not valid
|
||||||
|
*/
|
||||||
isFileNameValid: function (name) {
|
isFileNameValid: function (name) {
|
||||||
if (name === '.') {
|
var trimmedName = name.trim();
|
||||||
throw t('files', '\'.\' is an invalid file name.');
|
if (trimmedName === '.' || trimmedName === '..') {
|
||||||
} else if (name.length === 0) {
|
throw t('files', '"{name}" is an invalid file name.', {name: name});
|
||||||
|
} else if (trimmedName.length === 0) {
|
||||||
throw t('files', 'File name cannot be empty.');
|
throw t('files', 'File name cannot be empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for invalid characters
|
// check for invalid characters
|
||||||
var invalid_characters = ['\\', '/', '<', '>', ':', '"', '|', '?', '*'];
|
var invalid_characters =
|
||||||
|
['\\', '/', '<', '>', ':', '"', '|', '?', '*', '\n'];
|
||||||
for (var i = 0; i < invalid_characters.length; i++) {
|
for (var i = 0; i < invalid_characters.length; i++) {
|
||||||
if (name.indexOf(invalid_characters[i]) !== -1) {
|
if (trimmedName.indexOf(invalid_characters[i]) !== -1) {
|
||||||
throw t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.");
|
throw t('files', "Invalid name, '\\', '/', '<', '>', ':', '\"', '|', '?' and '*' are not allowed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -655,10 +675,10 @@ function procesSelection() {
|
||||||
var totalSize = 0;
|
var totalSize = 0;
|
||||||
for(var i=0; i<selectedFiles.length; i++) {
|
for(var i=0; i<selectedFiles.length; i++) {
|
||||||
totalSize+=selectedFiles[i].size;
|
totalSize+=selectedFiles[i].size;
|
||||||
};
|
}
|
||||||
for(var i=0; i<selectedFolders.length; i++) {
|
for(var i=0; i<selectedFolders.length; i++) {
|
||||||
totalSize+=selectedFolders[i].size;
|
totalSize+=selectedFolders[i].size;
|
||||||
};
|
}
|
||||||
$('#headerSize').text(humanFileSize(totalSize));
|
$('#headerSize').text(humanFileSize(totalSize));
|
||||||
var selection = '';
|
var selection = '';
|
||||||
if (selectedFolders.length > 0) {
|
if (selectedFolders.length > 0) {
|
||||||
|
@ -770,10 +790,11 @@ Files.lazyLoadPreview = function(path, mime, ready, width, height, etag) {
|
||||||
}
|
}
|
||||||
img.src = previewURL;
|
img.src = previewURL;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function getUniqueName(name) {
|
function getUniqueName(name) {
|
||||||
if (FileList.findFileEl(name).exists()) {
|
if (FileList.findFileEl(name).exists()) {
|
||||||
|
var numMatch;
|
||||||
var parts=name.split('.');
|
var parts=name.split('.');
|
||||||
var extension = "";
|
var extension = "";
|
||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
|
@ -807,7 +828,7 @@ function checkTrashStatus() {
|
||||||
|
|
||||||
function onClickBreadcrumb(e) {
|
function onClickBreadcrumb(e) {
|
||||||
var $el = $(e.target).closest('.crumb'),
|
var $el = $(e.target).closest('.crumb'),
|
||||||
$targetDir = $el.data('dir');
|
$targetDir = $el.data('dir'),
|
||||||
isPublic = !!$('#isPublic').val();
|
isPublic = !!$('#isPublic').val();
|
||||||
|
|
||||||
if ($targetDir !== undefined && !isPublic) {
|
if ($targetDir !== undefined && !isPublic) {
|
||||||
|
|
|
@ -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 OC */
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var eventSource, total, bar = $('#progressbar');
|
var eventSource, total, bar = $('#progressbar');
|
||||||
console.log('start');
|
console.log('start');
|
||||||
|
|
|
@ -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 OC */
|
||||||
function Upload(fileSelector) {
|
function Upload(fileSelector) {
|
||||||
if ($.support.xhrFileUpload) {
|
if ($.support.xhrFileUpload) {
|
||||||
return new XHRUpload(fileSelector.target.files);
|
return new XHRUpload(fileSelector.target.files);
|
||||||
|
|
|
@ -18,7 +18,10 @@
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global OC, FileActions, FileList */
|
||||||
describe('FileActions tests', function() {
|
describe('FileActions tests', function() {
|
||||||
|
var $filesTable;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// init horrible parameters
|
// init horrible parameters
|
||||||
var $body = $('body');
|
var $body = $('body');
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global OC, FileList */
|
||||||
describe('FileList tests', function() {
|
describe('FileList tests', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
// init horrible parameters
|
// init horrible parameters
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global Files */
|
||||||
describe('Files tests', function() {
|
describe('Files tests', function() {
|
||||||
describe('File name validation', function() {
|
describe('File name validation', function() {
|
||||||
it('Validates correct file names', function() {
|
it('Validates correct file names', function() {
|
||||||
|
@ -36,12 +38,14 @@ describe('Files tests', function() {
|
||||||
'und Ümläüte sind auch willkommen'
|
'und Ümläüte sind auch willkommen'
|
||||||
];
|
];
|
||||||
for ( var i = 0; i < fileNames.length; i++ ) {
|
for ( var i = 0; i < fileNames.length; i++ ) {
|
||||||
|
var error = false;
|
||||||
try {
|
try {
|
||||||
expect(Files.isFileNameValid(fileNames[i])).toEqual(true);
|
expect(Files.isFileNameValid(fileNames[i])).toEqual(true);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
fail();
|
error = e;
|
||||||
}
|
}
|
||||||
|
expect(error).toEqual(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
it('Detects invalid file names', function() {
|
it('Detects invalid file names', function() {
|
||||||
|
@ -69,7 +73,7 @@ describe('Files tests', function() {
|
||||||
var threwException = false;
|
var threwException = false;
|
||||||
try {
|
try {
|
||||||
Files.isFileNameValid(fileNames[i]);
|
Files.isFileNameValid(fileNames[i]);
|
||||||
fail();
|
console.error('Invalid file name not detected:', fileNames[i]);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
threwException = true;
|
threwException = true;
|
||||||
|
|
Loading…
Reference in New Issue