2013-05-27 19:45:33 +00:00
|
|
|
define([
|
|
|
|
"jquery",
|
2013-06-10 21:22:32 +00:00
|
|
|
"underscore",
|
2013-06-22 23:48:57 +00:00
|
|
|
"classes/Extension",
|
2013-06-10 21:22:32 +00:00
|
|
|
"text!html/dialogManagePublicationLocation.html",
|
2013-06-22 23:48:57 +00:00
|
|
|
], function($, _, Extension, dialogManagePublicationLocationHTML) {
|
2013-05-29 19:55:23 +00:00
|
|
|
|
2013-06-22 23:48:57 +00:00
|
|
|
var dialogManagePublication = new Extension("dialogManagePublication", 'Dialog "Manage publication"');
|
|
|
|
dialogManagePublication.settingsBlock = '<p>Populates the "Manage publication" dialog box.</p>';
|
2013-05-29 19:55:23 +00:00
|
|
|
|
2013-07-30 08:46:36 +00:00
|
|
|
var eventMgr = undefined;
|
|
|
|
dialogManagePublication.onEventMgrCreated = function(eventMgrParameter) {
|
|
|
|
eventMgr = eventMgrParameter;
|
2013-05-29 19:55:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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() {
|
2013-06-16 10:47:35 +00:00
|
|
|
fileDesc.removePublishLocation(publishAttributes);
|
2013-07-30 08:46:36 +00:00
|
|
|
eventMgr.onPublishRemoved(fileDesc, publishAttributes);
|
2013-05-29 19:55:23 +00:00
|
|
|
}));
|
|
|
|
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
|
|
|
});
|