Add file deletion in the menu. Close #587

This commit is contained in:
Nicolas Stepien 2012-07-11 23:15:06 +02:00
parent 5774217b59
commit 9c59c0d6f9
3 changed files with 77 additions and 26 deletions

View File

@ -111,7 +111,7 @@
Menu: {
'Menu': [true, 'Add a drop-down menu in posts.'],
'Report Link': [true, 'Add a report link to the menu.'],
'Delete Link': [true, 'Add a delete link to the menu.'],
'Delete Link': [true, 'Add post and image deletion links to the menu.'],
'Download Link': [true, 'Add a download with original filename link to the menu. Chrome-only currently.'],
'Archive Link': [true, 'Add an archive link to the menu.']
},
@ -4067,33 +4067,59 @@
DeleteLink = {
init: function() {
var a;
a = $.el('a', {
var aImage, aPost, children, div;
div = $.el('div', {
className: 'delete_link',
textContent: 'Delete'
});
aPost = $.el('a', {
className: 'delete_post',
href: 'javascript:;'
});
return Menu.addEntry({
el: a,
open: function(post) {
if (post.isArchived) {
return false;
}
a.textContent = 'Delete this post';
$.on(a, 'click', DeleteLink["delete"]);
aImage = $.el('a', {
className: 'delete_image',
href: 'javascript:;'
});
children = [];
children.push({
el: aPost,
open: function() {
aPost.textContent = 'Post';
$.on(aPost, 'click', DeleteLink["delete"]);
return true;
}
});
children.push({
el: aImage,
open: function(post) {
if (!post.img) {
return false;
}
aImage.textContent = 'Image';
$.on(aImage, 'click', DeleteLink["delete"]);
return true;
}
});
return Menu.addEntry({
el: div,
open: function(post) {
return !post.isArchived;
},
children: children
});
},
"delete": function() {
var board, form, id, m, pwd, self;
var board, form, id, m, menu, pwd, self;
$.off(this, 'click', DeleteLink["delete"]);
this.textContent = 'Deleting...';
pwd = (m = d.cookie.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $.id('delPassword').value;
id = this.parentNode.dataset.id;
board = $('.postNum > a[title="Highlight this post"]', $.id(this.parentNode.dataset.rootid)).pathname.split('/')[1];
menu = $.id('menu');
id = menu.dataset.id;
board = $('.postNum > a[title="Highlight this post"]', $.id(menu.dataset.rootid)).pathname.split('/')[1];
self = this;
form = {
mode: 'usrdel',
onlyimgdel: /\bdelete_image\b/.test(this.className),
pwd: pwd
};
form[id] = 'delete';

View File

@ -1,4 +1,6 @@
master
- Mayhem
Divide the Delete Link in the Menu into a Post and Image deletion links.
2.34.1
- Mayhem

View File

@ -27,7 +27,7 @@ Config =
Menu:
'Menu': [true, 'Add a drop-down menu in posts.']
'Report Link': [true, 'Add a report link to the menu.']
'Delete Link': [true, 'Add a delete link to the menu.']
'Delete Link': [true, 'Add post and image deletion links to the menu.']
'Download Link': [true, 'Add a download with original filename link to the menu. Chrome-only currently.']
'Archive Link': [true, 'Add an archive link to the menu.']
Monitoring:
@ -3231,17 +3231,38 @@ Quotify =
DeleteLink =
init: ->
a = $.el 'a',
div = $.el 'div',
className: 'delete_link'
textContent: 'Delete'
aPost = $.el 'a',
className: 'delete_post'
href: 'javascript:;'
Menu.addEntry
el: a
open: (post) ->
if post.isArchived
return false
a.textContent = 'Delete this post'
$.on a, 'click', DeleteLink.delete
aImage = $.el 'a',
className: 'delete_image'
href: 'javascript:;'
children = []
children.push
el: aPost
open: ->
aPost.textContent = 'Post'
$.on aPost, 'click', DeleteLink.delete
true
children.push
el: aImage
open: (post) ->
return false unless post.img
aImage.textContent = 'Image'
$.on aImage, 'click', DeleteLink.delete
true
Menu.addEntry
el: div
open: (post) -> !post.isArchived
children: children
delete: ->
$.off @, 'click', DeleteLink.delete
@textContent = 'Deleting...'
@ -3252,13 +3273,15 @@ DeleteLink =
else
$.id('delPassword').value
id = @parentNode.dataset.id
menu = $.id 'menu'
id = menu.dataset.id
board = $('.postNum > a[title="Highlight this post"]',
$.id @parentNode.dataset.rootid).pathname.split('/')[1]
self = this
$.id menu.dataset.rootid).pathname.split('/')[1]
self = @
form =
mode: 'usrdel'
onlyimgdel: /\bdelete_image\b/.test @className
pwd: pwd
form[id] = 'delete'