diff --git a/ajax/clipboard.php b/ajax/clipboard.php
deleted file mode 100644
index 4c34128..0000000
--- a/ajax/clipboard.php
+++ /dev/null
@@ -1,55 +0,0 @@
-getL10N('files_clipboard');
-
-$user = OCP\User::getUser();
-$view = new \OC\Files\View();
-
-$required = array('operation', 'directory', 'files', 'destination');
-if(count(array_intersect_key(array_flip($required), $_POST)) !== count($required)) {
- OCP\JSON::error();
- exit();
-}
-
-$messages = array();
-$cut = $_POST['operation'] == 'cut';
-foreach($_POST['files'] as $file) {
- $source = $user . "/files/" . \OC\Files\Filesystem::normalizePath(stripslashes($_POST['directory']) . '/' . $file);
- $target = $user . "/files" . \OC\Files\Filesystem::normalizePath(stripslashes($_POST['destination']) . '/' . $file);
-
- if (!$view->file_exists($source)) {
- $messages[] = $l->t("Unable to paste '%s' item does not exists", array($file));
- continue;
- }
-
- if (strpos($target, $source) === 0) {
- if ($cut) {
- $messages[] = $l->t("Unable to move folder '%s' into itself", array($file));
- } else {
- $messages[] = $l->t("Unable to copy folder '%s' into itself", array($file));
- }
- continue;
- }
-
- if ($view->file_exists($target)) {
- if (!$view->unlink($target)) {
- $messages[] = $l->t("Could not remove '%s'", array($file));
- continue;
- }
- }
-
- if ($cut) {
- if (!$view->rename($source, $target)) {
- $messages[] = $l->t("Could not move '%s'", array($file));
- }
- } else {
- if (!$view->copy($source, $target)) {
- $messages[] = $l->t("Could not copy '%s'", array($file));
- }
- }
-}
-
-if (empty($messages)) OCP\JSON::success();
-else OCP\JSON::error(array("messages" => $messages));
diff --git a/appinfo/info.xml b/appinfo/info.xml
index 4672619..1ffd934 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -4,7 +4,7 @@
').addClass('svg').attr('src', OC.imagePath(appid,'cut')))
- .append(' ')
- .append($('').text(t(appid,'Cut')))
- .on('click', function() { cut(); })
- .hide()
- .appendTo('#headerName .selectedActions');
-
-var $copy = $('')
- .attr('id', 'clipboard_copy')
- .append($('
').addClass('svg').attr('src', OC.imagePath(appid,'copy')))
- .append(' ')
- .append($('').text(t(appid,'Copy')))
- .on('click', function() { copy(); })
- .hide()
- .appendTo('#headerName .selectedActions');
-
-var $paste = $('')
- .attr('id', 'clipboard_paste')
- .append($('
').addClass('svg').attr('alt', t(appid, 'Paste')).attr('src', OC.imagePath(appid,'paste')))
- .addClass('button')
- .on('click', paste)
- .hide()
- .appendTo('#controls .creatable');
-
-var clipboard = JSON.parse(sessionStorage.getItem(appid));
-$fileList.on('changeDirectory', function() {
- $fileList.off('DOMNodeRemoved', onRowRemoved);
-});
-$fileList.on('fileActionsReady', function() {
- $fileList.on('DOMNodeRemoved', onRowRemoved);
-});
+$(document).ready(function () {
+ if (!OCA.Files) return;
+
+ var appid = 'files_clipboard',
+ $dir = $('#dir'),
+ $fileList = $('#fileList');
+
+ var $cut = $('')
+ .attr('id', 'clipboard_cut')
+ .append($('
').addClass('svg').attr('src', OC.imagePath(appid, 'cut')))
+ .append(' ')
+ .append($('').text(t(appid, 'Cut')))
+ .on('click', function () { cut(); })
+ .hide()
+ .appendTo('#headerName .selectedActions');
+
+ var $copy = $('')
+ .attr('id', 'clipboard_copy')
+ .append($('
').addClass('svg').attr('src', OC.imagePath(appid, 'copy')))
+ .append(' ')
+ .append($('').text(t(appid, 'Copy')))
+ .on('click', function () { copy(); })
+ .hide()
+ .appendTo('#headerName .selectedActions');
+
+ var $paste = $('')
+ .attr('id', 'clipboard_paste')
+ .append($('
').addClass('svg').attr('alt', t(appid, 'Paste')).attr('src', OC.imagePath(appid, 'paste')))
+ .addClass('button')
+ .on('click', paste)
+ .hide()
+ .appendTo('#controls .creatable');
+
+ var clipboard = JSON.parse(sessionStorage.getItem(appid));
+ $fileList.on('changeDirectory', function () {
+ $fileList.off('DOMNodeRemoved', onRowRemoved);
+ });
+ $fileList.on('fileActionsReady', function () {
+ $fileList.on('DOMNodeRemoved', onRowRemoved);
+ });
-OCA.Files.fileActions.registerAction({
- name: 'Cut',
- displayName: t('files_clipboard', 'Cut'),
- mime: 'all',
- order: -10,
- permissions: OC.PERMISSION_READ,
- icon: OC.imagePath('files_clipboard', 'cut.svg'),
- actionHandler: cut
-});
-OCA.Files.fileActions.registerAction({
- name: 'Copy',
- displayName: t('files_clipboard', 'Copy'),
- mime: 'all',
- order: -9,
- permissions: OC.PERMISSION_READ,
- icon: OC.imagePath('files_clipboard', 'copy.svg'),
- actionHandler: copy
-});
+ OCA.Files.fileActions.registerAction({
+ name: 'Cut',
+ displayName: t('files_clipboard', 'Cut'),
+ mime: 'all',
+ order: -10,
+ permissions: OC.PERMISSION_READ,
+ icon: OC.imagePath('files_clipboard', 'cut.svg'),
+ actionHandler: cut
+ });
+ OCA.Files.fileActions.registerAction({
+ name: 'Copy',
+ displayName: t('files_clipboard', 'Copy'),
+ mime: 'all',
+ order: -9,
+ permissions: OC.PERMISSION_READ,
+ icon: OC.imagePath('files_clipboard', 'copy.svg'),
+ actionHandler: copy
+ });
-function onRowRemoved(event) {
- var $target = $(event.target);
- if (clipboard && clipboard.directory == $dir.val() && $target.is('tr[data-file]')) {
- var fileIndex = clipboard.files.indexOf($target.attr('data-file'));
- if (fileIndex != -1) {
- clipboard.files.splice(fileIndex, 1);
- if (!clipboard.files.length) clipboard = null;
+ function onRowRemoved(event) {
+ var $target = $(event.target);
+ if (clipboard && clipboard.directory == $dir.val() && $target.is('tr[data-file]')) {
+ var fileIndex = clipboard.files.indexOf($target.attr('data-file'));
+ if (fileIndex != -1) {
+ clipboard.files.splice(fileIndex, 1);
+ if (!clipboard.files.length) clipboard = null;
+ }
+ update();
}
- update();
}
-}
-
-function update(blink) {
- var permissions = parseInt($('#permissions').val());
-
- $cut.toggle((permissions & OC.PERMISSION_READ && permissions & OC.PERMISSION_UPDATE) != 0);
- $copy.toggle((permissions & OC.PERMISSION_READ) != 0);
-
- if (clipboard) {
- var sameDirectory = clipboard.directory == $dir.val(),
- noPermissions = !(permissions & OC.PERMISSION_CREATE),
- disabled = noPermissions || sameDirectory,
- title;
- if (sameDirectory) title = t(appid, 'Unable to paste: the files come from this directory.')
- else if (noPermissions) title = t(appid, 'Unable to paste: you do not have the permissions to create files in this directory.')
- else title = n(appid, 'Paste %n item', 'Paste %n items', clipboard.files.length);
-
- $paste
- .toggleClass('disabled', disabled)
- .attr('title', title)
- .tipsy({gravity:'ne', fade:true})
- .show();
-
- if (clipboard.operation == 'cut' && clipboard.directory == $dir.val()) {
- var $trs = $('tr', $fileList);
- clipboard.files.forEach(function(file) {
- $trs.filterAttr('data-file', file).addClass('cut');
- });
- }
-
- if (blink === true) {
- $paste.addClass('blink');
- setTimeout(function () { $paste.removeClass('blink'); }, 500);
+
+ function update(blink) {
+ var permissions = parseInt($('#permissions').val());
+
+ $cut.toggle((permissions & OC.PERMISSION_READ && permissions & OC.PERMISSION_UPDATE) != 0);
+ $copy.toggle((permissions & OC.PERMISSION_READ) != 0);
+
+ if (clipboard) {
+ var sameDirectory = clipboard.directory == $dir.val(),
+ noPermissions = !(permissions & OC.PERMISSION_CREATE),
+ disabled = noPermissions || sameDirectory,
+ title;
+ if (sameDirectory) title = t(appid, 'Unable to paste: the files come from this directory.')
+ else if (noPermissions) title = t(appid, 'Unable to paste: you do not have the permissions to create files in this directory.')
+ else title = n(appid, 'Paste %n item', 'Paste %n items', clipboard.files.length);
+
+ $paste
+ .toggleClass('disabled', disabled)
+ .attr('title', title)
+ .tipsy({ gravity: 'ne', fade: true })
+ .show();
+
+ if (clipboard.operation == 'cut' && clipboard.directory == $dir.val()) {
+ var $trs = $('tr', $fileList);
+ clipboard.files.forEach(function (file) {
+ $trs.filterAttr('data-file', file).addClass('cut');
+ });
+ }
+
+ if (blink === true) {
+ $paste.addClass('blink');
+ setTimeout(function () { $paste.removeClass('blink'); }, 500);
+ }
+ } else {
+ $paste.hide();
}
- } else {
- $paste.hide();
+ };
+
+ function clearCut() {
+ $('tr[data-file]', $fileList).removeClass('cut');
+ }
+
+ function cut(file) {
+ var files = file ? [file] : FileList.getSelectedFiles().map(function (file) { return file.name; });
+ clipboard = { operation: 'cut', directory: $dir.val(), files: files };
+ sessionStorage.setItem(appid, JSON.stringify(clipboard));
+ clearCut();
+ clearSelection();
+ update(true);
+ }
+
+ function copy(file) {
+ var files = file ? [file] : FileList.getSelectedFiles().map(function (file) { return file.name; });
+ clipboard = { operation: 'copy', directory: $dir.val(), files: files };
+ sessionStorage.setItem(appid, JSON.stringify(clipboard));
+ clearCut();
+ clearSelection();
+ update(true);
}
-};
-
-function clearCut() {
- $('tr[data-file]', $fileList).removeClass('cut');
-}
-
-function cut (file) {
- var files = file ? [ file ] : FileList.getSelectedFiles().map(function(file) { return file.name; });
- clipboard = { operation: 'cut', directory: $dir.val(), files: files };
- sessionStorage.setItem(appid, JSON.stringify(clipboard));
- clearCut();
- clearSelection();
- update(true);
-}
-
-function copy (file) {
- var files = file ? [ file ] : FileList.getSelectedFiles().map(function(file) { return file.name; });
- clipboard = { operation: 'copy', directory: $dir.val(), files: files };
- sessionStorage.setItem(appid, JSON.stringify(clipboard));
- clearCut();
- clearSelection();
- update(true);
-}
-
-function clearSelection() {
- $('tr[data-file]', $fileList).removeClass('selected');
- $('tr[data-file] input[type="checkbox"]', $fileList).removeAttr('checked');
- FileList._selectedFiles = {};
- FileList._selectionSummary.clear();
- FileList.updateSelectionSummary();
-}
-
-function paste() {
- if ($(this).hasClass('disabled')) return;
- FileList.showMask();
- clipboard.destination = $dir.val();
- $(window).on('beforeunload', processing);
- replaceExistingFiles(function(replace) {
- if (!replace) FileList.hideMask();
- else $.ajax({
- type: 'POST',
- url: OC.filePath(appid, 'ajax', 'clipboard.php'),
- data: clipboard,
- success: function (data) {
- if (data.status == 'error') {
- var message;
- if (data.messages.length === 1) {
- message = data.messages[0];
- } else {
- if (clipboard.operation == 'cut') message = '' + t(appid, 'An error occurred during the move.') + '';
- else message = '' + t(appid, 'An error occurred during the copy.') + '';
- message += '
';
- for (var i = data.messages.length - 1; i >= 0; --i) message += data.messages[i] + '
';
- message += '
';
+ for (var i = rejectedFiles.length - 1; i >= 0; --i) message += rejectedFiles[i] + '
';
+ message += '