2016-06-04 17:17:35 -07:00
|
|
|
|
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', 'emby-button'], function (dialogHelper, layoutManager, globalize) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-04-28 20:10:48 -07:00
|
|
|
|
function showMenu(options) {
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-03-23 12:03:17 -07:00
|
|
|
|
var dlg = dialogHelper.createDialog({
|
2016-03-22 11:02:37 -07:00
|
|
|
|
removeOnClose: true,
|
2016-04-28 20:31:52 -07:00
|
|
|
|
autoFocus: layoutManager.tv
|
2016-03-22 10:57:53 -07:00
|
|
|
|
});
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-03-22 10:57:53 -07:00
|
|
|
|
dlg.id = 'dlg' + new Date().getTime();
|
|
|
|
|
var html = '';
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-04-28 20:10:48 -07:00
|
|
|
|
html += '<h2>' + Globalize.translate('Share') + '</h2>';
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
html += '<div class="ssk-group ssk-round ssk-lg">';
|
|
|
|
|
|
|
|
|
|
// 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.
|
2016-04-28 20:10:48 -07:00
|
|
|
|
html += '<a href="" class="ssk ssk-facebook"></a>';
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
|
|
|
|
html += '<a href="" class="ssk ssk-twitter"></a><a href="" class="ssk ssk-google-plus"></a><a href="" class="ssk ssk-pinterest"></a><a href="" class="ssk ssk-tumblr"></a></div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div class="buttons">';
|
2016-06-04 17:17:35 -07:00
|
|
|
|
html += '<button is="emby-button" type="button" class="btnCancel">' + globalize.translate('sharedcomponents#ButtonCancel') + '</button>';
|
2015-12-14 08:43:03 -07:00
|
|
|
|
html += '</div>';
|
|
|
|
|
|
2016-03-22 10:57:53 -07:00
|
|
|
|
dlg.innerHTML = html;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
2016-03-22 10:57:53 -07:00
|
|
|
|
document.body.appendChild(dlg);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
|
|
|
|
|
var isShared = false;
|
|
|
|
|
|
2016-03-22 10:57:53 -07:00
|
|
|
|
var shareInfo = options.share;
|
|
|
|
|
|
|
|
|
|
SocialShareKit.init({
|
|
|
|
|
selector: '#' + dlg.id + ' .ssk',
|
|
|
|
|
url: shareInfo.Url,
|
|
|
|
|
title: shareInfo.Name,
|
|
|
|
|
text: shareInfo.Overview,
|
|
|
|
|
image: shareInfo.ImageUrl,
|
|
|
|
|
via: 'Emby'
|
|
|
|
|
});
|
|
|
|
|
|
2016-04-27 19:56:18 -07:00
|
|
|
|
function onSskButtonClick(e) {
|
2016-03-22 10:57:53 -07:00
|
|
|
|
isShared = true;
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.close(dlg);
|
2016-04-27 19:56:18 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
}
|
2016-03-22 10:57:53 -07:00
|
|
|
|
|
|
|
|
|
// Has to be assigned a z-index after the call to .open()
|
|
|
|
|
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.close(dlg);
|
2016-03-22 10:57:53 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-04-28 20:10:48 -07:00
|
|
|
|
var promise = new Promise(function (resolve, reject) {
|
|
|
|
|
|
|
|
|
|
dlg.addEventListener('close', function () {
|
|
|
|
|
if (isShared) {
|
|
|
|
|
resolve();
|
|
|
|
|
} else {
|
|
|
|
|
reject();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-03-23 12:03:17 -07:00
|
|
|
|
dialogHelper.open(dlg);
|
2016-04-28 20:10:48 -07:00
|
|
|
|
|
|
|
|
|
return promise;
|
2015-12-14 08:43:03 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
showMenu: showMenu
|
|
|
|
|
};
|
|
|
|
|
});
|