2013-05-27 19:45:33 +00:00
|
|
|
define([
|
|
|
|
"jquery",
|
|
|
|
"underscore"
|
|
|
|
], function($, _) {
|
2013-05-26 22:59:17 +00:00
|
|
|
|
2013-05-27 19:45:33 +00:00
|
|
|
var buttonShare = {
|
|
|
|
extensionId: "buttonShare",
|
|
|
|
extensionName: 'Button "Share"',
|
2013-05-26 22:59:17 +00:00
|
|
|
optional: true,
|
2013-05-27 19:45:33 +00:00
|
|
|
settingsBloc: '<p>Adds a "Share document" button in the navigation bar.</p>'
|
2013-05-26 22:59:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var fileDesc = undefined;
|
|
|
|
var lineTemplate = [
|
|
|
|
'<div class="input-prepend">',
|
|
|
|
'<a href="<%= link %>" class="add-on" title="Sharing location"><i class="icon-link"></i></a>',
|
|
|
|
'<input class="span2" type="text" value="<%= link %>" readonly />',
|
2013-05-27 19:45:33 +00:00
|
|
|
'</div>'].join("");
|
2013-05-26 22:59:17 +00:00
|
|
|
var refreshDocumentSharing = function(fileDescParameter) {
|
|
|
|
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var linkList = $("#link-container .link-list").empty();
|
|
|
|
$("#link-container .no-link").show();
|
|
|
|
|
|
|
|
var attributesList = _.values(fileDesc.publishLocations);
|
|
|
|
_.each(attributesList, function(attributes) {
|
|
|
|
if(attributes.sharingLink) {
|
|
|
|
var lineElement = $(_.template(lineTemplate, {
|
|
|
|
link: attributes.sharingLink
|
|
|
|
}));
|
|
|
|
lineElement.click(function(event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
});
|
|
|
|
linkList.append(lineElement);
|
|
|
|
$("#link-container .no-link").hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-05-27 19:45:33 +00:00
|
|
|
buttonShare.onFileSelected = function(fileDescParameter) {
|
2013-05-26 22:59:17 +00:00
|
|
|
fileDesc = fileDescParameter;
|
|
|
|
refreshDocumentSharing(fileDescParameter);
|
|
|
|
};
|
|
|
|
|
2013-05-27 19:45:33 +00:00
|
|
|
buttonShare.onNewPublishSuccess = refreshDocumentSharing;
|
|
|
|
buttonShare.onPublishRemoved = refreshDocumentSharing;
|
2013-05-26 22:59:17 +00:00
|
|
|
|
2013-05-27 19:45:33 +00:00
|
|
|
return buttonShare;
|
2013-05-26 22:59:17 +00:00
|
|
|
|
|
|
|
});
|