Remove entry.requirement, somply use entry.open to determine if the entry is valid for the selected post or not.
This commit is contained in:
parent
5e9483118d
commit
abfc9cbe49
@ -1107,7 +1107,9 @@
|
|||||||
},
|
},
|
||||||
node: function(post) {
|
node: function(post) {
|
||||||
var a;
|
var a;
|
||||||
if (!(a = $('.menu_button', post.el))) {
|
if (post.isInlined && !post.isCrosspost) {
|
||||||
|
a = $('.menu_button', post.el);
|
||||||
|
} else {
|
||||||
a = Menu.a.cloneNode(true);
|
a = Menu.a.cloneNode(true);
|
||||||
$.add($('.postInfo', post.el), a);
|
$.add($('.postInfo', post.el), a);
|
||||||
}
|
}
|
||||||
@ -1136,10 +1138,7 @@
|
|||||||
_ref = Menu.entries;
|
_ref = Menu.entries;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
entry = _ref[_i];
|
entry = _ref[_i];
|
||||||
if (entry.requirement(post)) {
|
if (entry.open(post)) {
|
||||||
if (typeof entry.open === "function") {
|
|
||||||
entry.open(post);
|
|
||||||
}
|
|
||||||
$.add(el, entry.el);
|
$.add(el, entry.el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3927,12 +3926,13 @@
|
|||||||
});
|
});
|
||||||
return Menu.addEntry({
|
return Menu.addEntry({
|
||||||
el: a,
|
el: a,
|
||||||
open: function() {
|
open: function(post) {
|
||||||
|
if (post.isArchived) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
a.textContent = 'Delete this post';
|
a.textContent = 'Delete this post';
|
||||||
return $.on(a, 'click', DeleteLink["delete"]);
|
$.on(a, 'click', DeleteLink["delete"]);
|
||||||
},
|
return true;
|
||||||
requirement: function(post) {
|
|
||||||
return post.isArchived === false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -3991,7 +3991,7 @@
|
|||||||
$.on(a, 'click', this.report);
|
$.on(a, 'click', this.report);
|
||||||
return Menu.addEntry({
|
return Menu.addEntry({
|
||||||
el: a,
|
el: a,
|
||||||
requirement: function(post) {
|
open: function(post) {
|
||||||
return post.isArchived === false;
|
return post.isArchived === false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -4020,12 +4020,13 @@
|
|||||||
el: a,
|
el: a,
|
||||||
open: function(post) {
|
open: function(post) {
|
||||||
var fileText;
|
var fileText;
|
||||||
|
if (!post.img) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
a.href = post.img.parentNode.href;
|
a.href = post.img.parentNode.href;
|
||||||
fileText = post.fileInfo.firstElementChild;
|
fileText = post.fileInfo.firstElementChild;
|
||||||
return a.download = Conf['File Info Formatting'] ? fileText.dataset.filename : $('span', fileText).title;
|
a.download = Conf['File Info Formatting'] ? fileText.dataset.filename : $('span', fileText).title;
|
||||||
},
|
return true;
|
||||||
requirement: function(post) {
|
|
||||||
return post.img;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -4036,20 +4037,19 @@
|
|||||||
var a;
|
var a;
|
||||||
a = $.el('a', {
|
a = $.el('a', {
|
||||||
className: 'archive_link',
|
className: 'archive_link',
|
||||||
target: '_blank'
|
target: '_blank',
|
||||||
|
textContent: 'Archived post'
|
||||||
});
|
});
|
||||||
return Menu.addEntry({
|
return Menu.addEntry({
|
||||||
el: a,
|
el: a,
|
||||||
open: function(post) {
|
open: function(post) {
|
||||||
var path;
|
var href, path;
|
||||||
path = $('.postNum > a[title="Highlight this post"]', post.el).pathname.split('/');
|
path = $('.postNum > a[title="Highlight this post"]', post.el).pathname.split('/');
|
||||||
a.href = Redirect.thread(path[1], path[3], post.ID);
|
if ((href = Redirect.thread(path[1], path[3], post.ID)) === ("//boards.4chan.org/" + path[1] + "/")) {
|
||||||
return a.textContent = 'Archived post';
|
return false;
|
||||||
},
|
}
|
||||||
requirement: function(post) {
|
a.href = href;
|
||||||
var path;
|
return true;
|
||||||
path = $('.postNum > a[title="Highlight this post"]', post.el).pathname.split('/');
|
|
||||||
return Redirect.thread(path[1], path[3]) !== ("//boards.4chan.org/" + path[1] + "/");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -840,7 +840,9 @@ Menu =
|
|||||||
|
|
||||||
Main.callbacks.push @node
|
Main.callbacks.push @node
|
||||||
node: (post) ->
|
node: (post) ->
|
||||||
unless a = $ '.menu_button', post.el
|
if post.isInlined and !post.isCrosspost
|
||||||
|
a = $ '.menu_button', post.el
|
||||||
|
else
|
||||||
a = Menu.a.cloneNode true
|
a = Menu.a.cloneNode true
|
||||||
$.add $('.postInfo', post.el), a
|
$.add $('.postInfo', post.el), a
|
||||||
$.on a, 'click', Menu.toggle
|
$.on a, 'click', Menu.toggle
|
||||||
@ -873,8 +875,7 @@ Menu =
|
|||||||
# className: 'entry'
|
# className: 'entry'
|
||||||
# textContent: "#{i}: #{post[i]}"
|
# textContent: "#{i}: #{post[i]}"
|
||||||
for entry in Menu.entries
|
for entry in Menu.entries
|
||||||
if entry.requirement post
|
if entry.open post
|
||||||
entry.open? post
|
|
||||||
$.add el, entry.el
|
$.add el, entry.el
|
||||||
|
|
||||||
$.addClass $('.entry', Menu.el), 'focused'
|
$.addClass $('.entry', Menu.el), 'focused'
|
||||||
@ -3082,11 +3083,12 @@ DeleteLink =
|
|||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
Menu.addEntry
|
Menu.addEntry
|
||||||
el: a
|
el: a
|
||||||
open: ->
|
open: (post) ->
|
||||||
|
if post.isArchived
|
||||||
|
return false
|
||||||
a.textContent = 'Delete this post'
|
a.textContent = 'Delete this post'
|
||||||
$.on a, 'click', DeleteLink.delete
|
$.on a, 'click', DeleteLink.delete
|
||||||
requirement: (post) ->
|
true
|
||||||
post.isArchived is false
|
|
||||||
delete: ->
|
delete: ->
|
||||||
$.off @, 'click', DeleteLink.delete
|
$.off @, 'click', DeleteLink.delete
|
||||||
@textContent = 'Deleting...'
|
@textContent = 'Deleting...'
|
||||||
@ -3137,7 +3139,7 @@ ReportLink =
|
|||||||
$.on a, 'click', @report
|
$.on a, 'click', @report
|
||||||
Menu.addEntry
|
Menu.addEntry
|
||||||
el: a
|
el: a
|
||||||
requirement: (post) ->
|
open: (post) ->
|
||||||
post.isArchived is false
|
post.isArchived is false
|
||||||
report: ->
|
report: ->
|
||||||
a = $ '.postNum > a[title="Highlight this post"]', $.id @parentNode.dataset.rootid
|
a = $ '.postNum > a[title="Highlight this post"]', $.id @parentNode.dataset.rootid
|
||||||
@ -3156,6 +3158,8 @@ DownloadLink =
|
|||||||
Menu.addEntry
|
Menu.addEntry
|
||||||
el: a
|
el: a
|
||||||
open: (post) ->
|
open: (post) ->
|
||||||
|
unless post.img
|
||||||
|
return false
|
||||||
a.href = post.img.parentNode.href
|
a.href = post.img.parentNode.href
|
||||||
fileText = post.fileInfo.firstElementChild
|
fileText = post.fileInfo.firstElementChild
|
||||||
a.download =
|
a.download =
|
||||||
@ -3163,23 +3167,22 @@ DownloadLink =
|
|||||||
fileText.dataset.filename
|
fileText.dataset.filename
|
||||||
else
|
else
|
||||||
$('span', fileText).title
|
$('span', fileText).title
|
||||||
requirement: (post) ->
|
true
|
||||||
post.img
|
|
||||||
|
|
||||||
ArchiveLink =
|
ArchiveLink =
|
||||||
init: ->
|
init: ->
|
||||||
a = $.el 'a',
|
a = $.el 'a',
|
||||||
className: 'archive_link'
|
className: 'archive_link'
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
|
textContent: 'Archived post'
|
||||||
Menu.addEntry
|
Menu.addEntry
|
||||||
el: a
|
el: a
|
||||||
open: (post) ->
|
open: (post) ->
|
||||||
path = $('.postNum > a[title="Highlight this post"]', post.el).pathname.split '/'
|
path = $('.postNum > a[title="Highlight this post"]', post.el).pathname.split '/'
|
||||||
a.href = Redirect.thread path[1], path[3], post.ID
|
if (href = Redirect.thread path[1], path[3], post.ID) is "//boards.4chan.org/#{path[1]}/"
|
||||||
a.textContent = 'Archived post'
|
return false
|
||||||
requirement: (post) ->
|
a.href = href
|
||||||
path = $('.postNum > a[title="Highlight this post"]', post.el).pathname.split '/'
|
true
|
||||||
Redirect.thread(path[1], path[3]) isnt "//boards.4chan.org/#{path[1]}/"
|
|
||||||
|
|
||||||
ThreadStats =
|
ThreadStats =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user