mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
add new sharing function
This commit is contained in:
parent
d1842ae4e3
commit
c8eb5f2b0c
14 changed files with 504 additions and 8 deletions
|
@ -52,6 +52,12 @@
|
|||
$('.btnSync', page).addClass('hide');
|
||||
}
|
||||
|
||||
if (user.Policy.EnablePublicSharing) {
|
||||
$('.btnShare', page).removeClass('hide');
|
||||
} else {
|
||||
$('.btnShare', page).addClass('hide');
|
||||
}
|
||||
|
||||
if (!item.LocalTrailerCount && item.RemoteTrailers.length && item.PlayAccess == 'Full') {
|
||||
|
||||
$('.btnPlayExternalTrailer', page).removeClass('hide').attr('href', item.RemoteTrailers[0].Url);
|
||||
|
@ -1623,6 +1629,13 @@
|
|||
});
|
||||
});
|
||||
|
||||
$('.btnShare', page).on('click', function () {
|
||||
|
||||
require(['sharingmanager'], function () {
|
||||
SharingManager.showMenu(Dashboard.getCurrentUserId(), currentItem.Id);
|
||||
});
|
||||
});
|
||||
|
||||
$('.btnMoreCommands', page).on('click', function () {
|
||||
|
||||
var button = this;
|
||||
|
|
|
@ -180,6 +180,8 @@
|
|||
elem.classList.add('noMediaProgress');
|
||||
}
|
||||
|
||||
$.mobile.loadPage('nowplaying.html');
|
||||
|
||||
bindEvents(elem);
|
||||
|
||||
return elem;
|
||||
|
|
|
@ -787,13 +787,9 @@
|
|||
|
||||
currentImgUrl = null;
|
||||
|
||||
Dashboard.ready(function () {
|
||||
$(MediaController).on('playerchange', onPlayerChange);
|
||||
|
||||
$(MediaController).on('playerchange', onPlayerChange);
|
||||
|
||||
bindToPlayer(page, MediaController.getCurrentPlayer());
|
||||
|
||||
});
|
||||
bindToPlayer(page, MediaController.getCurrentPlayer());
|
||||
|
||||
loadPlaylist(page);
|
||||
|
||||
|
|
59
dashboard-ui/scripts/sharingmanager.js
Normal file
59
dashboard-ui/scripts/sharingmanager.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
(function () {
|
||||
|
||||
function onSharingSuccess(options) {
|
||||
|
||||
console.log('share success. shareId: ' + options.share.Id);
|
||||
|
||||
}
|
||||
|
||||
function onSharingCancel(options) {
|
||||
|
||||
var shareId = options.share.Id;
|
||||
|
||||
console.log('share cancelled. shareId: ' + shareId);
|
||||
|
||||
// Delete the share since it was cancelled
|
||||
ApiClient.ajax({
|
||||
|
||||
type: 'DELETE',
|
||||
url: ApiClient.getUrl('Social/Shares/' + shareId)
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function showMenu(userId, itemId) {
|
||||
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
require(['sharingwidget'], function () {
|
||||
|
||||
ApiClient.ajax({
|
||||
type: 'POST',
|
||||
url: ApiClient.getUrl('Social/Shares', {
|
||||
|
||||
ItemId: itemId,
|
||||
UserId: userId
|
||||
}),
|
||||
dataType: "json"
|
||||
|
||||
}).done(function (share) {
|
||||
|
||||
var options = {
|
||||
share: share
|
||||
};
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
SharingWidget.showMenu(options, onSharingSuccess, onSharingCancel);
|
||||
|
||||
}).fail(function () {
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
window.SharingManager = {
|
||||
showMenu: showMenu
|
||||
};
|
||||
|
||||
})();
|
78
dashboard-ui/scripts/sharingwidget.js
Normal file
78
dashboard-ui/scripts/sharingwidget.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
(function () {
|
||||
|
||||
function showMenu(options, successCallback, cancelCallback) {
|
||||
|
||||
Dashboard.importCss('thirdparty/social-share-kit-1.0.4/dist/css/social-share-kit.css');
|
||||
|
||||
require(['paperbuttonstyle', 'thirdparty/social-share-kit-1.0.4/dist/js/social-share-kit.min'], function () {
|
||||
|
||||
var id = 'dlg' + new Date().getTime();
|
||||
var html = '';
|
||||
|
||||
html += '<paper-dialog id="' + id + '" entry-animation="fade-in-animation" exit-animation="fade-out-animation" with-backdrop>';
|
||||
|
||||
html += '<h2>' + Globalize.translate('HeaderShare') + '</h2>';
|
||||
|
||||
html += '<div>';
|
||||
html += '<div class="ssk-group ssk-round ssk-lg"><a href="" class="ssk ssk-facebook"></a><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 style="max-width:240px;">';
|
||||
html += Globalize.translate('ButtonShareHelp');
|
||||
html += '</div>';
|
||||
|
||||
html += '<div class="buttons">';
|
||||
html += '<paper-button class="btnCancel" dialog-dismiss>' + Globalize.translate('ButtonCancel') + '</paper-button>';
|
||||
html += '</div>';
|
||||
|
||||
html += '</paper-dialog>';
|
||||
|
||||
$(document.body).append(html);
|
||||
|
||||
var isShared = false;
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
var dlg = document.getElementById(id);
|
||||
|
||||
dlg.open();
|
||||
|
||||
var shareInfo = options.share;
|
||||
|
||||
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()
|
||||
$(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);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
window.SharingWidget = {
|
||||
showMenu: showMenu
|
||||
};
|
||||
|
||||
|
||||
})();
|
|
@ -2000,6 +2000,9 @@ var AppInfo = {};
|
|||
define("actionsheet", ["scripts/actionsheet"]);
|
||||
}
|
||||
|
||||
define("sharingmanager", ["scripts/sharingmanager"]);
|
||||
define("sharingwidget", ["scripts/sharingwidget"]);
|
||||
|
||||
//requirejs(['http://viblast.com/player/free-version/qy2fdwajo1/viblast.js']);
|
||||
|
||||
$.extend(AppInfo, Dashboard.getAppInfo(appName, deviceId, deviceName));
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
$('#chkEnableSync', page).checked(user.Policy.EnableSync).checkboxradio("refresh");
|
||||
$('#chkEnableSyncTranscoding', page).checked(user.Policy.EnableSyncTranscoding).checkboxradio("refresh");
|
||||
$('#chkEnableSharing', page).checked(user.Policy.EnablePublicSharing).checkboxradio("refresh");
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
}
|
||||
|
@ -151,6 +152,7 @@
|
|||
|
||||
user.Policy.EnableSync = $('#chkEnableSync', page).checked();
|
||||
user.Policy.EnableSyncTranscoding = $('#chkEnableSyncTranscoding', page).checked();
|
||||
user.Policy.EnablePublicSharing = $('#chkEnableSharing', page).checked();
|
||||
|
||||
ApiClient.updateUser(user).done(function () {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue