jellyfin-web/dashboard-ui/components/categorysyncbuttons.js
2017-01-27 22:16:59 -05:00

1 line
879 B
JavaScript

define(["itemHelper"],function(itemHelper){"use strict";function initSyncButtons(view){var apiClient=window.ApiClient;apiClient&&apiClient.getCurrentUserId()&&apiClient.getCurrentUser().then(function(user){for(var item={SupportsSync:!0},categorySyncButtons=view.querySelectorAll(".categorySyncButton"),i=0,length=categorySyncButtons.length;i<length;i++)categorySyncButtons[i].addEventListener("click",onCategorySyncButtonClick),itemHelper.canSync(user,item)?categorySyncButtons[i].classList.remove("hide"):categorySyncButtons[i].classList.add("hide")})}function onCategorySyncButtonClick(e){var button=this,category=button.getAttribute("data-category"),parentId=LibraryMenu.getTopParentId();require(["syncDialog"],function(syncDialog){syncDialog.showMenu({ParentId:parentId,Category:category,serverId:ApiClient.serverId()})})}return{init:function(view){initSyncButtons(view)}}});