2013-12-01 15:43:46 +00:00
|
|
|
define([
|
|
|
|
"jquery",
|
|
|
|
"underscore",
|
|
|
|
"classes/Extension",
|
2014-09-25 23:25:01 +00:00
|
|
|
"text!html/dialogManageSharingLocation.html"
|
2013-12-01 15:43:46 +00:00
|
|
|
], function($, _, Extension, dialogManageSharingLocationHTML) {
|
|
|
|
|
|
|
|
var dialogManageSharing = new Extension("dialogManageSharing", 'Button "Share"', false, true);
|
|
|
|
|
2014-02-02 21:00:05 +00:00
|
|
|
var eventMgr;
|
|
|
|
dialogManageSharing.onEventMgrCreated = function(eventMgrParam) {
|
|
|
|
eventMgr = eventMgrParam;
|
|
|
|
};
|
|
|
|
|
2013-12-01 15:43:46 +00:00
|
|
|
var fileDesc;
|
|
|
|
var shareListElt;
|
|
|
|
var $msgShareListElt;
|
|
|
|
var $msgNoShareElt;
|
|
|
|
var refreshDocumentSharing = function(fileDescParameter) {
|
|
|
|
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var linkListHtml = _.reduce(fileDesc.publishLocations, function(result, attributes) {
|
|
|
|
if(attributes.sharingLink) {
|
|
|
|
result += _.template(dialogManageSharingLocationHTML, {
|
2014-02-02 21:00:05 +00:00
|
|
|
link: attributes.sharingLink,
|
|
|
|
title: fileDesc.title
|
2013-12-01 15:43:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}, '');
|
|
|
|
shareListElt.innerHTML = linkListHtml;
|
|
|
|
|
|
|
|
$msgShareListElt.toggleClass('hide', linkListHtml.length === 0);
|
|
|
|
$msgNoShareElt.toggleClass('hide', linkListHtml.length !== 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
dialogManageSharing.onFileSelected = function(fileDescParameter) {
|
|
|
|
fileDesc = fileDescParameter;
|
|
|
|
refreshDocumentSharing(fileDescParameter);
|
|
|
|
};
|
|
|
|
|
2014-02-02 21:00:05 +00:00
|
|
|
dialogManageSharing.onNewPublishSuccess = function(fileDescParameter, publishAttributes) {
|
|
|
|
refreshDocumentSharing(fileDescParameter);
|
|
|
|
if(publishAttributes.sharingLink) {
|
|
|
|
$('.modal').modal('hide');
|
|
|
|
$('.modal-manage-sharing').modal('show');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-12-01 15:43:46 +00:00
|
|
|
dialogManageSharing.onPublishRemoved = refreshDocumentSharing;
|
|
|
|
|
|
|
|
dialogManageSharing.onReady = function() {
|
|
|
|
var modalElt = document.querySelector('.modal-manage-sharing');
|
|
|
|
shareListElt = modalElt.querySelector('.share-list');
|
|
|
|
$msgShareListElt = $(modalElt.querySelectorAll('.msg-share-list'));
|
|
|
|
$msgNoShareElt = $(modalElt.querySelectorAll('.msg-no-share'));
|
|
|
|
};
|
|
|
|
|
|
|
|
return dialogManageSharing;
|
|
|
|
|
|
|
|
});
|