2013-05-27 19:45:33 +00:00
|
|
|
define([
|
|
|
|
"jquery",
|
|
|
|
"underscore"
|
|
|
|
], function($, _) {
|
2013-05-26 22:59:17 +00:00
|
|
|
|
|
|
|
var managePublication = {
|
|
|
|
extensionId: "managePublication",
|
2013-05-27 23:27:38 +00:00
|
|
|
extensionName: "Manage publication",
|
2013-05-27 19:45:33 +00:00
|
|
|
settingsBloc: '<p>Populates the "Manage publication" dialog box.</p>'
|
2013-05-26 22:59:17 +00:00
|
|
|
};
|
|
|
|
|
2013-05-27 19:45:33 +00:00
|
|
|
var fileMgr = undefined;
|
|
|
|
managePublication.onFileMgrCreated = function(fileMgrParameter) {
|
|
|
|
fileMgr = fileMgrParameter;
|
2013-05-26 22:59:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var fileDesc = undefined;
|
|
|
|
var lineTemplate = [
|
|
|
|
'<div class="input-prepend input-append">',
|
|
|
|
'<span class="add-on" title="<%= provider.providerName %>">',
|
|
|
|
'<i class="icon-<%= provider.providerId %>"></i>',
|
|
|
|
'</span>',
|
|
|
|
'<input class="span5" type="text" value="<%= publishDesc %>" disabled />',
|
|
|
|
'</div>'].join("");
|
|
|
|
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) {
|
2013-05-28 23:41:09 +00:00
|
|
|
formattedAttributes = _.omit(publishAttributes, "provider", "publishIndex", "sharingLink");
|
|
|
|
if(formattedAttributes.password) {
|
|
|
|
formattedAttributes.password = "********";
|
2013-05-26 22:59:17 +00:00
|
|
|
}
|
2013-05-28 23:41:09 +00:00
|
|
|
var publishDesc = JSON.stringify(formattedAttributes).replace(/{|}|"/g, "").replace(/,/g, ", ");
|
2013-05-26 22:59:17 +00:00
|
|
|
var lineElement = $(_.template(lineTemplate, {
|
2013-05-27 22:13:41 +00:00
|
|
|
provider: publishAttributes.provider,
|
2013-05-26 22:59:17 +00:00
|
|
|
publishDesc: publishDesc
|
|
|
|
}));
|
|
|
|
lineElement.append($(removeButtonTemplate).click(function() {
|
2013-05-27 19:45:33 +00:00
|
|
|
fileMgr.removePublish(publishAttributes);
|
2013-05-26 22:59:17 +00:00
|
|
|
}));
|
|
|
|
publishList.append(lineElement);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
managePublication.onFileSelected = function(fileDescParameter) {
|
|
|
|
fileDesc = fileDescParameter;
|
|
|
|
refreshDialog(fileDescParameter);
|
|
|
|
};
|
|
|
|
|
|
|
|
managePublication.onNewPublishSuccess = refreshDialog;
|
|
|
|
managePublication.onPublishRemoved = refreshDialog;
|
|
|
|
|
|
|
|
return managePublication;
|
|
|
|
|
|
|
|
});
|