2013-05-27 19:45:33 +00:00
|
|
|
define([
|
|
|
|
"jquery",
|
2013-06-10 21:22:32 +00:00
|
|
|
"underscore",
|
|
|
|
"text!html/dialogManagePublicationLocation.html",
|
|
|
|
], function($, _, dialogManagePublicationLocationHTML) {
|
2013-05-29 19:55:23 +00:00
|
|
|
|
2013-06-10 21:22:32 +00:00
|
|
|
var dialogManagePublication = {
|
|
|
|
extensionId: "dialogManagePublication",
|
|
|
|
extensionName: 'Dialog "Manage publication"',
|
2013-05-29 19:55:23 +00:00
|
|
|
settingsBloc: '<p>Populates the "Manage publication" dialog box.</p>'
|
|
|
|
};
|
|
|
|
|
|
|
|
var fileMgr = undefined;
|
2013-06-10 21:22:32 +00:00
|
|
|
dialogManagePublication.onFileMgrCreated = function(fileMgrParameter) {
|
2013-05-29 19:55:23 +00:00
|
|
|
fileMgr = fileMgrParameter;
|
|
|
|
};
|
|
|
|
|
|
|
|
var fileDesc = undefined;
|
|
|
|
var removeButtonTemplate = '<a class="btn" title="Remove this location"><i class="icon-trash"></i></a>';
|
|
|
|
var refreshDialog = function(fileDescParameter) {
|
|
|
|
if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var publishAttributesList = _.values(fileDesc.publishLocations);
|
|
|
|
$(".msg-no-publish, .msg-publish-list").addClass("hide");
|
|
|
|
var publishList = $("#manage-publish-list").empty();
|
|
|
|
if(publishAttributesList.length > 0) {
|
|
|
|
$(".msg-publish-list").removeClass("hide");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$(".msg-no-publish").removeClass("hide");
|
|
|
|
}
|
|
|
|
_.each(publishAttributesList, function(publishAttributes) {
|
|
|
|
formattedAttributes = _.omit(publishAttributes, "provider", "publishIndex", "sharingLink");
|
|
|
|
if(formattedAttributes.password) {
|
|
|
|
formattedAttributes.password = "********";
|
|
|
|
}
|
|
|
|
var publishDesc = JSON.stringify(formattedAttributes).replace(/{|}|"/g, "").replace(/,/g, ", ");
|
2013-06-10 21:22:32 +00:00
|
|
|
var lineElement = $(_.template(dialogManagePublicationLocationHTML, {
|
2013-05-29 19:55:23 +00:00
|
|
|
provider: publishAttributes.provider,
|
|
|
|
publishDesc: publishDesc
|
|
|
|
}));
|
|
|
|
lineElement.append($(removeButtonTemplate).click(function() {
|
|
|
|
fileMgr.removePublish(publishAttributes);
|
|
|
|
}));
|
|
|
|
publishList.append(lineElement);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-06-10 21:22:32 +00:00
|
|
|
dialogManagePublication.onFileSelected = function(fileDescParameter) {
|
2013-05-29 19:55:23 +00:00
|
|
|
fileDesc = fileDescParameter;
|
|
|
|
refreshDialog(fileDescParameter);
|
|
|
|
};
|
|
|
|
|
2013-06-10 21:22:32 +00:00
|
|
|
dialogManagePublication.onNewPublishSuccess = refreshDialog;
|
|
|
|
dialogManagePublication.onPublishRemoved = refreshDialog;
|
2013-05-29 19:55:23 +00:00
|
|
|
|
2013-06-10 21:22:32 +00:00
|
|
|
return dialogManagePublication;
|
2013-05-29 19:55:23 +00:00
|
|
|
|
2013-05-26 22:59:17 +00:00
|
|
|
});
|