|
|
|
@ -20,23 +20,31 @@ var MultiShare = MultiShare || {};
|
|
|
|
|
|
|
|
|
|
(function() { |
|
|
|
|
var TEMPLATE_BASE = |
|
|
|
|
'<div class="shareTabView">' + |
|
|
|
|
'<h3 style="padding-top: 15px;">Multi share</h3>' + |
|
|
|
|
'{{#if isSharingAllowed}}' + |
|
|
|
|
'<label for="shareWith-{{cid}}" class="hidden-visually">{{shareLabel}}</label>' + |
|
|
|
|
'<div class="oneline">' + |
|
|
|
|
' <input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{sharePlaceholder}}" />' + |
|
|
|
|
' <span class="shareWithLoading icon-loading-small hidden"></span>'+ |
|
|
|
|
'{{{shareInfo}}}' + |
|
|
|
|
'</div>' + |
|
|
|
|
'{{/if}}' + |
|
|
|
|
'<div class="loading hidden" style="height: 50px"></div>' + |
|
|
|
|
'<a class="close icon-close" href="#" alt="{{closeLabel}}"></a>' + |
|
|
|
|
'</div>'; |
|
|
|
|
|
|
|
|
|
var TEMPLATE_SHARE_INFO = |
|
|
|
|
'<span class="icon icon-info shareWithRemoteInfo hasTooltip" ' + |
|
|
|
|
'title="{{tooltip}}"></span>'; |
|
|
|
|
'<div class="shareTabView">' + |
|
|
|
|
'<h3 style="padding-top: 15px;">Multi share</h3>' + |
|
|
|
|
'{{#if isSharingAllowed}}' + |
|
|
|
|
'<label for="shareWith-{{cid}}" class="hidden-visually">{{shareLabel}}</label>' + |
|
|
|
|
'<div class="oneline">' + |
|
|
|
|
' <input id="shareWith-{{cid}}" class="shareWithField" type="text" placeholder="{{sharePlaceholder}}" />' + |
|
|
|
|
' <span class="shareWithLoading icon-loading-small hidden"></span>'+ |
|
|
|
|
'{{{shareInfo}}}' + |
|
|
|
|
'</div>' + |
|
|
|
|
'<div class="multishare hidden">' + |
|
|
|
|
' <p>' + |
|
|
|
|
' <span id="multishare-complete">0</span> of ' + |
|
|
|
|
' <span id="multishare-total">0</span> completed' + |
|
|
|
|
' </p>' + |
|
|
|
|
' <div class="multishare hidden multishare-error">' + |
|
|
|
|
' Error when sharing:' + |
|
|
|
|
' <ul id="multishare-errors"></ul>' + |
|
|
|
|
' </div>' + |
|
|
|
|
'</div>' + |
|
|
|
|
'{{/if}}' + |
|
|
|
|
'<div class="loading hidden" style="height: 50px"></div>' + |
|
|
|
|
'<a class="close icon-close" href="#" alt="{{closeLabel}}"></a>' + |
|
|
|
|
'</div>', |
|
|
|
|
TEMPLATE_SHARE_INFO = |
|
|
|
|
'<span class="icon icon-info shareWithRemoteInfo hasTooltip" title="{{tooltip}}"></span>'; |
|
|
|
|
|
|
|
|
|
var ShareDialogView = OC.Backbone.View.extend({ |
|
|
|
|
_templates: {}, |
|
|
|
@ -70,19 +78,21 @@ var MultiShare = MultiShare || {};
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_onClose: function(event) { |
|
|
|
|
OC.Apps.hideAppSidebar(this.$el); |
|
|
|
|
this._sidebar_visible = false; |
|
|
|
|
this.showHide(false); |
|
|
|
|
event.preventDefault(); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
showHide: function () { |
|
|
|
|
if (!this._sidebar_visible) { |
|
|
|
|
showHide: function (show) { |
|
|
|
|
var forceShow = show !== undefined ? show : false; |
|
|
|
|
|
|
|
|
|
if (forceShow || !this._sidebar_visible) { |
|
|
|
|
OC.Apps.showAppSidebar(this.$el); |
|
|
|
|
this._sidebar_visible = true; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
OC.Apps.hideAppSidebar(this.$el); |
|
|
|
|
this._sidebar_visible = false; |
|
|
|
|
this.$el.find(".multishare").addClass("hidden"); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -260,9 +270,14 @@ var MultiShare = MultiShare || {};
|
|
|
|
|
|
|
|
|
|
var $loading = this.$el.find('.shareWithLoading'), |
|
|
|
|
$shareInfo = this.$el.find('.shareWithRemoteInfo'), |
|
|
|
|
$fileTotal = $("#multishare-total"), |
|
|
|
|
$fileComplete = $("#multishare-complete"), |
|
|
|
|
$fileErrorList = $("#multishare-errors"), |
|
|
|
|
files = OCA.Files.App.fileList.getSelectedFiles(), |
|
|
|
|
self = this, |
|
|
|
|
fileErrorListVisible = false, |
|
|
|
|
tempRunningShare = [], |
|
|
|
|
uploadedFiles = 0, |
|
|
|
|
fileInfoTemp, |
|
|
|
|
modelTemp; |
|
|
|
|
|
|
|
|
@ -277,11 +292,15 @@ var MultiShare = MultiShare || {};
|
|
|
|
|
$loading.removeClass('hidden').addClass('inlineblock'); |
|
|
|
|
$shareInfo.addClass('hidden'); |
|
|
|
|
|
|
|
|
|
files.forEach(function(element, idx) { |
|
|
|
|
$fileTotal.text(files.length); |
|
|
|
|
$fileComplete.text(0); |
|
|
|
|
this.$el.find(".multishare.hidden").not(".multishare-error").removeClass("hidden"); |
|
|
|
|
|
|
|
|
|
files.forEach(function(element) { |
|
|
|
|
fileInfoTemp = new OCA.Files.FileInfoModel(element); |
|
|
|
|
var options = { |
|
|
|
|
fileInfoModel: fileInfoTemp, |
|
|
|
|
configModel: self.configModel}, |
|
|
|
|
fileInfoModel: fileInfoTemp, |
|
|
|
|
configModel: self.configModel}, |
|
|
|
|
attributes = { |
|
|
|
|
itemType: fileInfoTemp.isDirectory() ? 'folder' : 'file', |
|
|
|
|
itemSource: fileInfoTemp.get('id'), |
|
|
|
@ -292,8 +311,37 @@ var MultiShare = MultiShare || {};
|
|
|
|
|
|
|
|
|
|
tempRunningShare.push( |
|
|
|
|
modelTemp.addShare(s.item.value, { |
|
|
|
|
complete: function () { |
|
|
|
|
uploadedFiles = uploadedFiles + 1; |
|
|
|
|
$fileComplete.text(uploadedFiles); |
|
|
|
|
}, |
|
|
|
|
error: function (obj, msg) { |
|
|
|
|
OC.Notification.showTemporary(msg); |
|
|
|
|
var existingShare = false, |
|
|
|
|
fullMsg = ""; |
|
|
|
|
|
|
|
|
|
// Get up to date information from the server
|
|
|
|
|
obj.fetch() |
|
|
|
|
.done(function () { |
|
|
|
|
existingShare = obj.getSharesWithCurrentItem().find(function (share) { |
|
|
|
|
return share.share_with === s.item.label; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (existingShare) { |
|
|
|
|
// Ignore existing shares, as they are returned as "errors",
|
|
|
|
|
// when, to the user, they are successful
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!fileErrorListVisible) { |
|
|
|
|
$fileErrorList.parent().removeClass("hidden"); |
|
|
|
|
fileErrorListVisible = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fullMsg = obj.fileInfoModel.attributes.name + " with " + s.item.label; |
|
|
|
|
$fileErrorList.append( |
|
|
|
|
$("<li>").text(fullMsg) |
|
|
|
|
); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
@ -301,7 +349,7 @@ var MultiShare = MultiShare || {};
|
|
|
|
|
|
|
|
|
|
// Wait for the call backs to finish,
|
|
|
|
|
// then refresh the file list to show shared status
|
|
|
|
|
$.when.apply(null, tempRunningShare).done(function () { |
|
|
|
|
$.when.apply(null, tempRunningShare).always(function () { |
|
|
|
|
window.setTimeout(function() { |
|
|
|
|
OC.Share.loadIcons("file", OCA.Files.App.fileList); |
|
|
|
|
}, 1000); |
|
|
|
@ -378,7 +426,7 @@ var MultiShare = MultiShare || {};
|
|
|
|
|
return t('core', 'Name, federated cloud ID or email address...'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return t('core', 'Name...'); |
|
|
|
|
return t('core', 'Name...'); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
_getTemplate: function (key, template) { |
|
|
|
|