2016-07-18 20:57:55 -07:00
|
|
|
|
define(['itemHelper'], function (itemHelper) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2016-07-18 20:57:55 -07:00
|
|
|
|
|
|
|
|
|
function initSyncButtons(view) {
|
|
|
|
|
|
|
|
|
|
var apiClient = window.ApiClient;
|
|
|
|
|
|
|
|
|
|
if (!apiClient || !apiClient.getCurrentUserId()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apiClient.getCurrentUser().then(function (user) {
|
|
|
|
|
|
|
|
|
|
var item = {
|
|
|
|
|
SupportsSync: true
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var categorySyncButtons = view.querySelectorAll('.categorySyncButton');
|
|
|
|
|
for (var i = 0, length = categorySyncButtons.length; i < length; i++) {
|
|
|
|
|
categorySyncButtons[i].addEventListener('click', onCategorySyncButtonClick);
|
|
|
|
|
if (itemHelper.canSync(user, item)) {
|
|
|
|
|
categorySyncButtons[i].classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
categorySyncButtons[i].classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onCategorySyncButtonClick(e) {
|
|
|
|
|
|
|
|
|
|
var button = this;
|
|
|
|
|
var category = button.getAttribute('data-category');
|
|
|
|
|
var parentId = LibraryMenu.getTopParentId();
|
|
|
|
|
|
|
|
|
|
require(['syncDialog'], function (syncDialog) {
|
|
|
|
|
syncDialog.showMenu({
|
|
|
|
|
ParentId: parentId,
|
2016-08-22 23:42:15 -07:00
|
|
|
|
Category: category,
|
|
|
|
|
serverId: ApiClient.serverId()
|
2016-07-18 20:57:55 -07:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
init: function (view) {
|
|
|
|
|
initSyncButtons(view);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
});
|