define([ "jquery", "underscore" ], function($, _) { var manageSynchronization = { extensionId: "manageSynchronization", extensionName: "Manage synchronization", settingsBloc: '

Populates the "Manage synchronization" dialog box.

' }; var fileMgr = undefined; manageSynchronization.onFileMgrCreated = function(fileMgrParameter) { fileMgr = fileMgrParameter; }; var fileDesc = undefined; var lineTemplate = [ '
', ' ', ' ', ' ', ' ', '
' ].join(""); var removeButtonTemplate = ''; var refreshDialog = function(fileDescParameter) { if(fileDescParameter !== undefined && fileDescParameter !== fileDesc) { return; } var syncAttributesList = _.values(fileDesc.syncLocations); $(".msg-no-sync, .msg-sync-list").addClass("hide"); var syncList = $("#manage-sync-list").empty(); if(syncAttributesList.length > 0) { $(".msg-sync-list").removeClass("hide"); } else { $(".msg-no-sync").removeClass("hide"); } _.each(syncAttributesList, function(syncAttributes) { var syncDesc = syncAttributes.id || syncAttributes.path; var lineElement = $(_.template(lineTemplate, { provider: syncAttributes.provider, syncDesc: syncDesc })); lineElement.append($(removeButtonTemplate).click(function() { fileMgr.removeSync(syncAttributes); })); syncList.append(lineElement); }); }; manageSynchronization.onFileSelected = function(fileDescParameter) { fileDesc = fileDescParameter; refreshDialog(fileDescParameter); }; manageSynchronization.onSyncExportSuccess = refreshDialog; manageSynchronization.onSyncRemoved = refreshDialog; return manageSynchronization; });