pandora/static/js/pandora/deleteListDialog.js

72 lines
2.8 KiB
JavaScript
Raw Normal View History

2011-09-29 17:25:04 +00:00
// vim: et:ts=4:sw=4:sts=4:ft=javascript
2011-11-05 17:04:10 +00:00
'use strict';
pandora.ui.deleteListDialog = function(list) {
2013-02-16 01:20:40 +00:00
var ui = pandora.user.ui,
folderItems = ui.section == 'items' ? 'Lists' : Ox.toTitleCase(ui.section),
folderItem = folderItems.slice(0, -1);
2011-09-29 17:25:04 +00:00
var listData = pandora.getListData(list),
2011-09-29 17:25:04 +00:00
$folderList = pandora.$ui.folderList[listData.folder],
that = Ox.Dialog({
buttons: [
Ox.Button({
id: 'keep',
2013-02-16 01:20:40 +00:00
title: 'Keep ' + folderItem
2011-09-29 17:25:04 +00:00
}).bindEvent({
click: function() {
that.close();
}
}),
Ox.Button({
id: 'delete',
2013-02-16 01:20:40 +00:00
title: 'Delete ' + folderItem
2011-09-29 17:25:04 +00:00
}).bindEvent({
click: function() {
that.close();
2013-02-16 01:20:40 +00:00
pandora.api['remove' + folderItem]({
2011-09-29 17:25:04 +00:00
id: listData.id
}, function(result) {
2013-02-16 01:20:40 +00:00
Ox.Request.clearCache('find' + folderItems);
2011-09-29 17:25:04 +00:00
Ox.Request.clearCache(listData.id);
$folderList
.options({selected: []})
.bindEventOnce({
load: function() {
2013-02-16 01:20:40 +00:00
if (ui.section == 'items') {
pandora.UI.set('lists.' + listData.id, null);
pandora.UI.set({
find: pandora.site.user.ui.find
});
} else {
pandora.UI.set(folderItem.toLowerCase(), '');
}
2011-09-29 17:25:04 +00:00
}
})
.reloadList();
});
}
})
],
content: Ox.Element()
.append(
$('<img>')
.attr({src: '/static/png/icon.png'})
.css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'})
)
.append(
$('<div>')
.css({position: 'absolute', left: '96px', top: '16px', width: '192px'})
2013-02-16 01:20:40 +00:00
.html('Are you sure you want to delete the ' + folderItem.toLowerCase() + ' "' + listData.name + '"?')
),
2011-09-29 17:25:04 +00:00
height: 128,
keys: {enter: 'delete', escape: 'keep'},
2011-09-29 17:25:04 +00:00
title: 'Delete List',
width: 304
});
return that;
2013-02-16 01:20:40 +00:00
}