From 71e0ab278cd37637cc1f7b705b759596e38cbd1c Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 6 Nov 2011 15:12:46 +0000 Subject: [PATCH] add dialog when making a list private that has subscribers --- static/js/pandora/account.js | 6 +++--- static/js/pandora/deleteListDialog.js | 22 +++++++++++++++------- static/js/pandora/folderList.js | 6 ++---- static/js/pandora/listDialog.js | 5 +---- static/js/pandora/utils.js | 26 ++++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/static/js/pandora/account.js b/static/js/pandora/account.js index 23234cd9f..294eaa596 100644 --- a/static/js/pandora/account.js +++ b/static/js/pandora/account.js @@ -319,8 +319,8 @@ pandora.ui.accountSignoutDialog = function() { var that = Ox.Dialog({ buttons: [ Ox.Button({ - id: 'cancel', - title: 'Cancel' + id: 'stay', + title: 'Stay Signed In' }).bindEvent('click', function() { that.close().remove(); pandora.URL.update(); @@ -348,7 +348,7 @@ pandora.ui.accountSignoutDialog = function() { ), fixedSize: true, height: 128, - keys: {enter: 'signout', escape: 'cancel'}, + keys: {enter: 'signout', escape: 'stay'}, title: 'Sign Out', width: 304 }); diff --git a/static/js/pandora/deleteListDialog.js b/static/js/pandora/deleteListDialog.js index a92d19e77..06e606a5e 100644 --- a/static/js/pandora/deleteListDialog.js +++ b/static/js/pandora/deleteListDialog.js @@ -9,8 +9,8 @@ pandora.ui.deleteListDialog = function() { that = Ox.Dialog({ buttons: [ Ox.Button({ - id: 'cancel', - title: 'Cancel' + id: 'keep', + title: 'Keep List' }).bindEvent({ click: function() { that.close(); @@ -18,7 +18,7 @@ pandora.ui.deleteListDialog = function() { }), Ox.Button({ id: 'delete', - title: 'Delete' + title: 'Delete List' }).bindEvent({ click: function() { that.close(); @@ -42,11 +42,19 @@ pandora.ui.deleteListDialog = function() { } }) ], - content: $('
') - .css({margin: '16px'}) - .html('Do you want to delete the list "' + listData.id + '"?'), + content: Ox.Element() + .append( + $('') + .attr({src: '/static/png/icon64.png'}) + .css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'}) + ) + .append( + $('
') + .css({position: 'absolute', left: '96px', top: '16px', width: '192px'}) + .html('Are you sure you want to delete the list "' + listData.id + '"?') + ), height: 128, - keys: {enter: 'delete', escape: 'cancel'}, + keys: {enter: 'delete', escape: 'keep'}, title: 'Delete List', width: 304 }); diff --git a/static/js/pandora/folderList.js b/static/js/pandora/folderList.js index 0422082ad..9556f8eb7 100644 --- a/static/js/pandora/folderList.js +++ b/static/js/pandora/folderList.js @@ -299,10 +299,8 @@ pandora.ui.folderList = function(id) { pandora.$ui.listDialog = pandora.ui.listDialog('query').open(); } } else if (data.key == 'status') { - pandora.api.editList({ - id: data.id, - status: that.value(data.id, data.key) == 'private' ? 'public' : 'private' - }, function(result) { + var status = that.value(data.id, data.key) == 'private' ? 'public' : 'private'; + pandora.changeListStatus(data.id, status, function(result) { that.value(result.data.id, 'status', result.data.status); }); } else if (data.key == 'path') { diff --git a/static/js/pandora/listDialog.js b/static/js/pandora/listDialog.js index 28c673827..35824f8ec 100644 --- a/static/js/pandora/listDialog.js +++ b/static/js/pandora/listDialog.js @@ -244,10 +244,7 @@ pandora.ui.listGeneralPanel = function(listData) { } function editStatus(data) { var status = data.selected[0].id; - pandora.api.editList({ - id: listData.id, - status: status - }, function(result) { + pandora.changeListStatus(listData.id, status, function(result) { listData.status = result.data.status; $subscribersInput[getSubscribersAction()](); $descriptionInput diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 56e64dde7..d90bae4b2 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -136,6 +136,32 @@ pandora.addList = function() { } }; +pandora.changeListStatus = function(id, status, callback) { + if (status == 'private') { + pandora.api.findLists({ + query: {conditions: [{key: 'id', value: id, operator: '=='}]}, + keys: ['subscribers'] + }, function(result) { + var subscribers = result.data.items[0].subscribers; + if (subscribers) { + pandora.ui.makeListPrivateDialog(subscribers, function(makePrivate) { + makePrivate && changeListStatus(); + }).open(); + } else { + changeListStatus(); + } + }); + } else { + changeListStatus(); + } + function changeListStatus() { + pandora.api.editList({ + id: is, + status: status + }, callback); + } +}; + pandora.clickLink = function(e) { if (e.target.hostname == document.location.hostname) { pandora.URL.push(e.target.pathname);