summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-05-21 12:54:34 +0200
committerVincent Petry <pvince81@owncloud.com>2014-05-30 10:06:29 +0200
commit1d9129eac35b49a4e8d0d642a68d7d634f31c905 (patch)
tree513bdd46bb2e557bbac678aff73d1766b8e3c9c6 /core
parent6fbf4d8548133dff4419e5e2e0c649f49e177669 (diff)
downloadnextcloud-server-1d9129eac35b49a4e8d0d642a68d7d634f31c905.tar.gz
nextcloud-server-1d9129eac35b49a4e8d0d642a68d7d634f31c905.zip
Sharing overview fixes and unit tests
- Fixed renaming and fileActionsReady event - Added unit tests for shares list - Fixed public page with defer - Fixed file actions in sharing overview - Fixed sharing counterpart list (10 entries max) - Fixed file path attribute to be used in download action - Fix sharing list headers - OC.Share icons now operate on fileList instance - Fix OC.Share.updateIcon when more than one list in DOM
Diffstat (limited to 'core')
-rw-r--r--core/js/share.js45
1 files changed, 24 insertions, 21 deletions
diff --git a/core/js/share.js b/core/js/share.js
index 279b1d11663..894f0d488f4 100644
--- a/core/js/share.js
+++ b/core/js/share.js
@@ -32,27 +32,26 @@ OC.Share={
* (not reloaded from server)
*
* @param itemType item type
- * @param fileList file list instance or file list jQuery element,
+ * @param fileList file list instance
* defaults to OCA.Files.App.fileList
*/
updateIcons:function(itemType, fileList){
var item;
- var $fileList = (fileList || OCA.Files.App.fileList);
- // in case the jQuery element was passed instead
- if ($fileList.$fileList) {
- $fileList = $fileList.$fileList;
- }
+ fileList = fileList || OCA.Files.App.fileList;
+ var $fileList = fileList.$fileList;
+ var currentDir = fileList.getCurrentDirectory();
for (item in OC.Share.statuses){
+ var image;
var data = OC.Share.statuses[item];
- var hasLink = data['link'];
+ var hasLink = data.link;
// Links override shared in terms of icon display
if (hasLink) {
- var image = OC.imagePath('core', 'actions/public');
+ image = OC.imagePath('core', 'actions/public');
} else {
- var image = OC.imagePath('core', 'actions/shared');
+ image = OC.imagePath('core', 'actions/shared');
}
- if (itemType != 'file' && itemType != 'folder') {
+ if (itemType !== 'file' && itemType !== 'folder') {
$fileList.find('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
} else {
var file = $fileList.find('tr[data-id="'+item+'"]');
@@ -62,17 +61,17 @@ OC.Share={
action.addClass('permanent');
action.html(' <span>'+t('core', 'Shared')+'</span>').prepend(img);
} else {
- var dir = $('#dir').val();
+ var dir = currentDir;
if (dir.length > 1) {
var last = '';
var path = dir;
// Search for possible parent folders that are shared
while (path != last) {
- if (path == data['path'] && !data['link']) {
+ if (path === data.path && !data.link) {
var actions = $fileList.find('.fileactions .action[data-action="Share"]');
$.each(actions, function(index, action) {
var img = $(action).find('img');
- if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
+ if (img.attr('src') !== OC.imagePath('core', 'actions/public')) {
img.attr('src', image);
$(action).addClass('permanent');
$(action).html(' <span>'+t('core', 'Shared')+'</span>').prepend(img);
@@ -112,14 +111,18 @@ OC.Share={
var file = $('tr').filterAttr('data-id', String(itemSource));
if (file.length > 0) {
var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share');
- var img = action.find('img').attr('src', image);
- if (shares) {
- action.addClass('permanent');
- action.html(' <span>'+ escapeHTML(t('core', 'Shared'))+'</span>').prepend(img);
- } else {
- action.removeClass('permanent');
- action.html(' <span>'+ escapeHTML(t('core', 'Share'))+'</span>').prepend(img);
- }
+ // in case of multiple lists/rows, there might be more than one visible
+ action.each(function() {
+ var action = $(this);
+ var img = action.find('img').attr('src', image);
+ if (shares) {
+ action.addClass('permanent');
+ action.html(' <span>'+ escapeHTML(t('core', 'Shared'))+'</span>').prepend(img);
+ } else {
+ action.removeClass('permanent');
+ action.html(' <span>'+ escapeHTML(t('core', 'Share'))+'</span>').prepend(img);
+ }
+ });
}
}
if (shares) {