(function (window, $) { function submitJob(userId, items, form) { var target = $('.radioSync:checked', form).get().map(function (c) { return c.getAttribute('data-targetid'); })[0]; if (!target) { Dashboard.alert('Please select a device to sync to.'); return; } var options = { userId: userId, TargetId: target, ItemIds: items.map(function (i) { return i.Id; }).join(','), Quality: $('.radioSyncQuality', form)[0].getAttribute('data-value') }; ApiClient.ajax({ type: "POST", url: ApiClient.getUrl("Sync/Jobs"), data: JSON.stringify(options), contentType: "application/json" }).done(function () { }); } function showSyncMenu(items) { var userId = Dashboard.getCurrentUserId(); ApiClient.getJSON(ApiClient.getUrl('Sync/Targets', { UserId: userId })).done(function (targets) { var html = '
'; html += '
'; html += '

Sync Media

'; html += '
'; html += '
'; html += '
'; html += 'Sync to:'; html += targets.map(function (t) { var targetHtml = ''; targetHtml += ''; return targetHtml; }).join(''); html += '
'; html += '
'; html += '
'; html += '
'; html += '
'; html += 'Quality:'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '
'; html += '
'; html += '
'; html += '

'; html += ''; html += '

'; html += '
'; html += '
'; html += '
'; $(document.body).append(html); var elem = $('.syncPanel').panel({}).trigger('create').panel("open").on("panelclose", function () { $(this).off("panelclose").remove(); }); $('form', elem).on('submit', function () { submitJob(userId, items, this); return false; }); }); } function isAvailable(item, user) { return false; return item.SupportsSync; } window.SyncManager = { showMenu: showSyncMenu, isAvailable: isAvailable }; })(window, jQuery);