diff --git a/static/js/pandora/UI.js b/static/js/pandora/UI.js index a22390512..73b7854c1 100644 --- a/static/js/pandora/UI.js +++ b/static/js/pandora/UI.js @@ -58,6 +58,9 @@ pandora.UI = (function() { if (args.section == 'texts') { trigger['section'] = args['section']; trigger['text'] = args['text']; + } else if (args.section == 'edits') { + trigger['section'] = args['section']; + trigger['edit'] = args['edit']; } else { if ('find' in args) { // the challenge here is that find may change list, diff --git a/static/js/pandora/folders.js b/static/js/pandora/folders.js index b224f2b30..bcccf3394 100644 --- a/static/js/pandora/folders.js +++ b/static/js/pandora/folders.js @@ -113,6 +113,34 @@ pandora.ui.folders = function() { ]('deletetext'); }) ]; + } else if(ui.section == 'edits') { + extras = [ + pandora.$ui.personalListsMenu = Ox.MenuButton({ + items: [ + { id: 'newedit', title: Ox._('New Edit') }, + {}, + { id: 'deleteedit', title: Ox._('Delete Selected Edit...'), disabled: !ui.text } + ], + title: 'edit', + tooltip: Ox._('Manage Personal Edits'), + type: 'image' + }) + .bindEvent({ + click: function(data) { + var $list = pandora.$ui.folderList[folder.id]; + if (data.id == 'newedit') { + pandora.addEdit(); + } else if (data.id == 'deleteedit') { + pandora.ui.deleteListDialog().open(); + } + } + }) + .bindEvent('pandora_edit', function(data) { + pandora.$ui.personalListsMenu[ + data.value && data.value.length ? 'enableItem' : 'disableItem' + ]('deleteedit'); + }) + ]; } else { extras = []; } diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index e8cde7adf..cf85e5c68 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -12,6 +12,26 @@ pandora.addItem = function() { }); }; +pandora.addEdit = function(options) { + var $folderList = pandora.$ui.folderList.personal; + options = options || {}; + pandora.api.addEdit(options, function(result) { + reloadFolder(result.data.id); + }); + function reloadFolder(newId) { + pandora.$ui.folder[0].options({collapsed: false}); + Ox.Request.clearCache('findEdits'); + $folderList.bindEventOnce({ + load: function(data) { + $folderList.gainFocus() + .options({selected: [newId]}) + .editCell(newId, 'name', true); + pandora.UI.set(pandora.user.ui.section.slice(0, -1), newId); + } + }).reloadList(); + } +} + pandora.addList = function() { // addList(isSmart, isFrom) or addList(list) [=duplicate] var $folderList = pandora.$ui.folderList.personal,