diff --git a/dashboard-ui/components/sharingwidget.js b/dashboard-ui/components/sharingwidget.js index b817bf079a..7693f7ac22 100644 --- a/dashboard-ui/components/sharingwidget.js +++ b/dashboard-ui/components/sharingwidget.js @@ -1,11 +1,13 @@ -define(['jQuery', 'thirdparty/social-share-kit-1.0.4/dist/js/social-share-kit.min', 'css!thirdparty/social-share-kit-1.0.4/dist/css/social-share-kit.css', 'fade-in-animation', 'fade-out-animation', 'paper-dialog'], function ($) { +define(['paperdialoghelper', 'jQuery', 'thirdparty/social-share-kit-1.0.4/dist/js/social-share-kit.min', 'css!thirdparty/social-share-kit-1.0.4/dist/css/social-share-kit.css'], function (paperDialogHelper, $) { function showMenu(options, successCallback, cancelCallback) { - var id = 'dlg' + new Date().getTime(); - var html = ''; + var dlg = paperDialogHelper.createDialog({ + removeOnClose: true + }); - html += ''; + dlg.id = 'dlg' + new Date().getTime(); + var html = ''; html += '

' + Globalize.translate('HeaderShare') + '

'; @@ -28,48 +30,45 @@ html += '' + Globalize.translate('ButtonCancel') + ''; html += ''; - html += '
'; + dlg.innerHTML = html; - $(document.body).append(html); + document.body.appendChild(dlg); var isShared = false; - setTimeout(function () { + var shareInfo = options.share; - var dlg = document.getElementById(id); + SocialShareKit.init({ + selector: '#' + dlg.id + ' .ssk', + url: shareInfo.Url, + title: shareInfo.Name, + text: shareInfo.Overview, + image: shareInfo.ImageUrl, + via: 'Emby' + }); - dlg.open(); + // Has to be assigned a z-index after the call to .open() + dlg.addEventListener('close', function () { - var shareInfo = options.share; + if (isShared) { + successCallback(options); + } else { + cancelCallback(options); + } + }); - SocialShareKit.init({ - selector: '#' + id + ' .ssk', - url: shareInfo.Url, - title: shareInfo.Name, - text: shareInfo.Overview, - image: shareInfo.ImageUrl, - via: 'Emby' - }); + // Has to be assigned a z-index after the call to .open() + $('.ssk', dlg).on('click', function () { + isShared = true; + paperDialogHelper.close(dlg); + }); - // Has to be assigned a z-index after the call to .open() - $(dlg).on('iron-overlay-closed', function () { - $(this).remove(); - - if (isShared) { - successCallback(options); - } else { - cancelCallback(options); - } - }); - - // Has to be assigned a z-index after the call to .open() - $('.ssk', dlg).on('click', function () { - isShared = true; - dlg.close(); - }); - - }, 100); + // Has to be assigned a z-index after the call to .open() + dlg.querySelector('.btnCancel').addEventListener('click', function () { + paperDialogHelper.close(dlg); + }); + paperDialogHelper.open(dlg); } return {