Faster Menu's makeButton. Callback name fixes.
This commit is contained in:
parent
6b87f9c977
commit
d4089d09c5
@ -1679,7 +1679,7 @@
|
||||
return;
|
||||
}
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Thread Hiding',
|
||||
name: 'Filter',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
@ -2104,7 +2104,7 @@
|
||||
if (!Conf['Hiding Buttons']) {
|
||||
return;
|
||||
}
|
||||
return $.replace($('.sideArrows', this.nodes.root), ReplyHiding.makeButton(this, 'hide'));
|
||||
return $.replace(this.nodes.root.firstElementChild, ReplyHiding.makeButton(this, 'hide'));
|
||||
},
|
||||
getHiddenPosts: function() {
|
||||
var hiddenPosts;
|
||||
@ -2348,20 +2348,25 @@
|
||||
}
|
||||
return $.add(this.nodes.info, [$.tn('\u00A0'), button]);
|
||||
},
|
||||
makeButton: function(post) {
|
||||
makeButton: (function() {
|
||||
var a;
|
||||
a = $.el('a', {
|
||||
className: 'menu-button',
|
||||
innerHTML: '[<span></span>]',
|
||||
href: 'javascript:;'
|
||||
});
|
||||
a.setAttribute('data-postid', post.fullID);
|
||||
if (post.isClone) {
|
||||
a.setAttribute('data-clone', true);
|
||||
}
|
||||
$.on(a, 'click', Menu.toggle);
|
||||
return a;
|
||||
},
|
||||
a = null;
|
||||
return function(post) {
|
||||
var clone;
|
||||
a || (a = $.el('a', {
|
||||
className: 'menu-button',
|
||||
innerHTML: '[<span></span>]',
|
||||
href: 'javascript:;'
|
||||
}));
|
||||
clone = a.cloneNode(true);
|
||||
clone.setAttribute('data-postid', post.fullID);
|
||||
if (post.isClone) {
|
||||
clone.setAttribute('data-clone', true);
|
||||
}
|
||||
$.on(clone, 'click', Menu.toggle);
|
||||
return clone;
|
||||
};
|
||||
})(),
|
||||
toggle: function(e) {
|
||||
var post;
|
||||
post = this.dataset.clone ? Get.postFromNode(this) : g.posts[this.dataset.postid];
|
||||
@ -4611,7 +4616,7 @@
|
||||
return;
|
||||
}
|
||||
return Post.prototype.callbacks.push({
|
||||
name: 'Auto-GIF',
|
||||
name: 'Image Hover',
|
||||
cb: this.node
|
||||
});
|
||||
},
|
||||
|
||||
@ -666,7 +666,7 @@ Filter =
|
||||
|
||||
return unless Object.keys(@filters).length
|
||||
Post::callbacks.push
|
||||
name: 'Thread Hiding'
|
||||
name: 'Filter'
|
||||
cb: @node
|
||||
|
||||
createFilter: (regexp, op, stub, hl, top) ->
|
||||
@ -1036,7 +1036,7 @@ ReplyHiding =
|
||||
else
|
||||
Recursive.hide @, data.makeStub
|
||||
return unless Conf['Hiding Buttons']
|
||||
$.replace $('.sideArrows', @nodes.root), ReplyHiding.makeButton @, 'hide'
|
||||
$.replace @nodes.root.firstElementChild, ReplyHiding.makeButton @, 'hide'
|
||||
|
||||
getHiddenPosts: ->
|
||||
hiddenPosts = $.get "hiddenPosts.#{g.BOARD}"
|
||||
@ -1209,15 +1209,18 @@ Menu =
|
||||
return
|
||||
$.add @nodes.info, [$.tn('\u00A0'), button]
|
||||
|
||||
makeButton: (post) ->
|
||||
a = $.el 'a',
|
||||
className: 'menu-button'
|
||||
innerHTML: '[<span></span>]'
|
||||
href: 'javascript:;'
|
||||
a.setAttribute 'data-postid', post.fullID
|
||||
a.setAttribute 'data-clone', true if post.isClone
|
||||
$.on a, 'click', Menu.toggle
|
||||
a
|
||||
makeButton: do ->
|
||||
a = null
|
||||
(post) ->
|
||||
a or= $.el 'a',
|
||||
className: 'menu-button'
|
||||
innerHTML: '[<span></span>]'
|
||||
href: 'javascript:;'
|
||||
clone = a.cloneNode true
|
||||
clone.setAttribute 'data-postid', post.fullID
|
||||
clone.setAttribute 'data-clone', true if post.isClone
|
||||
$.on clone, 'click', Menu.toggle
|
||||
clone
|
||||
|
||||
toggle: (e) ->
|
||||
post =
|
||||
@ -3070,7 +3073,7 @@ ImageHover =
|
||||
return if g.VIEW is 'catalog' or !Conf['Image Hover']
|
||||
|
||||
Post::callbacks.push
|
||||
name: 'Auto-GIF'
|
||||
name: 'Image Hover'
|
||||
cb: @node
|
||||
node: ->
|
||||
return unless @file?.isImage
|
||||
|
||||
@ -431,6 +431,7 @@ Main =
|
||||
# get the nodes' length only once
|
||||
len = nodes.length
|
||||
for callback in klass::callbacks
|
||||
# console.profile callback.name
|
||||
for i in [0...len]
|
||||
node = nodes[i]
|
||||
try
|
||||
@ -441,6 +442,7 @@ Main =
|
||||
errors.push
|
||||
message: "\"#{callback.name}\" crashed on #{klass.name} No.#{node} (/#{node.board}/)."
|
||||
error: err
|
||||
# console.profileEnd callback.name
|
||||
Main.handleErrors errors if errors
|
||||
|
||||
handleErrors: (errors) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user