Skip to content

Commit

Permalink
0.6.0 : owncloud 10 and nextcloud 12 support, dropped owncloud 8 supp…
Browse files Browse the repository at this point in the history
…ort, PR #14 review
  • Loading branch information
leizh committed Aug 6, 2017
1 parent 7b5d14d commit 40bd1bc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 49 deletions.
2 changes: 0 additions & 2 deletions ajax/clipboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
$messages[] = $l->t("Could not copy '%s'", array($file));
}
}
$error = error_get_last();
if ($error) $messages[] = $error->message;
}

if (empty($messages)) OCP\JSON::success();
Expand Down
6 changes: 2 additions & 4 deletions appinfo/app.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
if(\OC_User::isLoggedIn()) {
if(OCP\Util::getVersion()[0] >= 8) {
OCP\Util::addTranslations('files_clipboard');
}
OCP\Util::addTranslations('files_clipboard');
OCP\Util::addScript('files_clipboard', 'clipboard');
OCP\Util::addStyle('files_clipboard', 'clipboard');
} else {
OCP\Util::addScript('files_clipboard', 'clearClipboard');
}
}
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<id>files_clipboard</id>
<name>Files clipboard</name>
<description>Clipboard operations for the files interface.</description>
<version>0.5.0</version>
<version>0.6.0</version>
<licence>AGPL</licence>
<author>Leizh</author>
<dependencies>
<owncloud min-version="8.2" max-version="9.1" />
<owncloud min-version="9.0" max-version="10.0" />
<php min-version="5.4" max-version="7.0" />
</dependencies>
</info>
2 changes: 1 addition & 1 deletion appinfo/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.6.0
7 changes: 7 additions & 0 deletions css/clipboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ tr.cut div.thumbnail {
margin-bottom: 0.4em;
padding: 0.2em;
}

@media only screen and (max-width: 768px) {
#clipboard_cut > span:not(.svg),
#clipboard_copy > span:not(.svg) {
display: none;
}
}
66 changes: 26 additions & 40 deletions js/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ var appid = 'files_clipboard',
var $cut = $('<a/>')
.attr('id', 'clipboard_cut')
.append($('<img/>').addClass('svg').attr('src', OC.imagePath(appid,'cut')))
.append(' ' + t(appid,'Cut'))
.on('click', cut)
.append(' ')
.append($('<span/>').text(t(appid,'Cut')))
.on('click', function() { cut(); })
.hide()
.appendTo('#headerName .selectedActions');

var $copy = $('<a/>')
.attr('id', 'clipboard_copy')
.append($('<img/>').addClass('svg').attr('src', OC.imagePath(appid,'copy')))
.append(' ' + t(appid,'Copy'))
.on('click', copy)
.append(' ')
.append($('<span/>').text(t(appid,'Copy')))
.on('click', function() { copy(); })
.hide()
.appendTo('#headerName .selectedActions');

Expand All @@ -37,32 +39,24 @@ $fileList.on('fileActionsReady', function() {
$fileList.on('DOMNodeRemoved', onRowRemoved);
});

if (location.pathname.indexOf("files") != -1) {
if (typeof FileActions !== 'undefined') {
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: function(filename) {
cut(filename);
}
});
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: function(filename) {
copy(filename);
}
});
}
}
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);
Expand Down Expand Up @@ -118,11 +112,7 @@ function clearCut() {
}

function cut (file) {
if (typeof file === "string") {
var files = [file];
} else {
var files = FileList.getSelectedFiles().map(function(file) { return file.name; });
}
let 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();
Expand All @@ -131,11 +121,7 @@ function cut (file) {
}

function copy (file) {
if (typeof file === "string") {
var files = [file];
} else {
var files = FileList.getSelectedFiles().map(function(file) { return file.name; });
}
let 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();
Expand Down

0 comments on commit 40bd1bc

Please sign in to comment.