define(['dialogHelper', 'layoutManager', 'globalize', './social-share-kit-1.0.4/dist/js/social-share-kit.min', 'css!./social-share-kit-1.0.4/dist/css/social-share-kit.css'], function (dialogHelper, layoutManager, globalize) { function showMenu(options) { var dlg = dialogHelper.createDialog({ removeOnClose: true, autoFocus: layoutManager.tv }); dlg.id = 'dlg' + new Date().getTime(); var html = ''; html += '

' + Globalize.translate('Share') + '

'; html += '
'; html += '
'; // We can only do facebook if we can guarantee that the current page is available over the internet, since FB will try to probe it. html += ''; html += '
'; html += '
'; html += '
'; html += '' + globalize.translate('sharedcomponents#ButtonCancel') + ''; html += '
'; dlg.innerHTML = html; document.body.appendChild(dlg); var isShared = false; var shareInfo = options.share; SocialShareKit.init({ selector: '#' + dlg.id + ' .ssk', url: shareInfo.Url, title: shareInfo.Name, text: shareInfo.Overview, image: shareInfo.ImageUrl, via: 'Emby' }); function onSskButtonClick(e) { isShared = true; dialogHelper.close(dlg); } // Has to be assigned a z-index after the call to .open() var sskButtons = dlg.querySelectorAll('.ssk'); for (var i = 0, length = sskButtons.length; i < length; i++) { sskButtons[i].addEventListener('click', onSskButtonClick); } // Has to be assigned a z-index after the call to .open() dlg.querySelector('.btnCancel').addEventListener('click', function () { dialogHelper.close(dlg); }); var promise = new Promise(function (resolve, reject) { dlg.addEventListener('close', function () { if (isShared) { resolve(); } else { reject(); } }); }); dialogHelper.open(dlg); return promise; } return { showMenu: showMenu }; });