2015-06-30 16:59:45 -07:00
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
|
|
function onSharingSuccess(options) {
|
|
|
|
|
|
2015-07-02 05:55:07 -07:00
|
|
|
|
Logger.log('share success. shareId: ' + options.share.Id);
|
2015-06-30 16:59:45 -07:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onSharingCancel(options) {
|
|
|
|
|
|
|
|
|
|
var shareId = options.share.Id;
|
|
|
|
|
|
2015-07-02 05:55:07 -07:00
|
|
|
|
Logger.log('share cancelled. shareId: ' + shareId);
|
2015-06-30 16:59:45 -07:00
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
})();
|