Fix image expansion

DURR
This commit is contained in:
Zixaphir 2014-01-21 13:57:28 -07:00
parent 11e5f348f0
commit 702a343f5e
4 changed files with 18 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/* /*
* 4chan X - Version 1.3.2 - 2014-01-19 * 4chan X - Version 1.3.2 - 2014-01-21
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE

View File

@ -22,7 +22,7 @@
// ==/UserScript== // ==/UserScript==
/* /*
* 4chan X - Version 1.3.2 - 2014-01-19 * 4chan X - Version 1.3.2 - 2014-01-21
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -7506,9 +7506,9 @@
return ImageExpand.toggle(Get.postFromNode(this)); return ImageExpand.toggle(Get.postFromNode(this));
}, },
toggleAll: function() { toggleAll: function() {
var func; var func, toggle;
$.event('CloseMenu'); $.event('CloseMenu');
func = function(post) { toggle = function(post) {
var file; var file;
file = post.file; file = post.file;
if (!(file && file.isImage && doc.contains(post.nodes.root))) { if (!(file && file.isImage && doc.contains(post.nodes.root))) {
@ -7530,11 +7530,11 @@
} }
return g.posts.forEach(function(post) { return g.posts.forEach(function(post) {
var _i, _len, _ref; var _i, _len, _ref;
func(post); toggle(post);
_ref = post.clones; _ref = post.clones;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
post = _ref[_i]; post = _ref[_i];
func(post); toggle(post);
} }
}); });
}, },

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript // Generated by CoffeeScript
/* /*
* 4chan X - Version 1.3.2 - 2014-01-19 * 4chan X - Version 1.3.2 - 2014-01-21
* *
* Licensed under the MIT license. * Licensed under the MIT license.
* https://github.com/seaweedchan/4chan-x/blob/master/LICENSE * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE
@ -7489,9 +7489,9 @@
return ImageExpand.toggle(Get.postFromNode(this)); return ImageExpand.toggle(Get.postFromNode(this));
}, },
toggleAll: function() { toggleAll: function() {
var func; var func, toggle;
$.event('CloseMenu'); $.event('CloseMenu');
func = function(post) { toggle = function(post) {
var file; var file;
file = post.file; file = post.file;
if (!(file && file.isImage && doc.contains(post.nodes.root))) { if (!(file && file.isImage && doc.contains(post.nodes.root))) {
@ -7513,11 +7513,11 @@
} }
return g.posts.forEach(function(post) { return g.posts.forEach(function(post) {
var _i, _len, _ref; var _i, _len, _ref;
func(post); toggle(post);
_ref = post.clones; _ref = post.clones;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
post = _ref[_i]; post = _ref[_i];
func(post); toggle(post);
} }
}); });
}, },

View File

@ -30,9 +30,10 @@ ImageExpand =
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
e.preventDefault() e.preventDefault()
ImageExpand.toggle Get.postFromNode @ ImageExpand.toggle Get.postFromNode @
toggleAll: -> toggleAll: ->
$.event 'CloseMenu' $.event 'CloseMenu'
func = (post) -> toggle = (post) ->
{file} = post {file} = post
return unless file and file.isImage and doc.contains post.nodes.root return unless file and file.isImage and doc.contains post.nodes.root
if ImageExpand.on and if ImageExpand.on and
@ -40,6 +41,7 @@ ImageExpand =
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0) Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
return return
$.queueTask func, post $.queueTask func, post
if ImageExpand.on = $.hasClass ImageExpand.EAI, 'expand-all-shortcut' if ImageExpand.on = $.hasClass ImageExpand.EAI, 'expand-all-shortcut'
ImageExpand.EAI.className = 'contract-all-shortcut fa fa-compress' ImageExpand.EAI.className = 'contract-all-shortcut fa fa-compress'
ImageExpand.EAI.title = 'Contract All Images' ImageExpand.EAI.title = 'Contract All Images'
@ -48,10 +50,12 @@ ImageExpand =
ImageExpand.EAI.className = 'expand-all-shortcut fa fa-expand' ImageExpand.EAI.className = 'expand-all-shortcut fa fa-expand'
ImageExpand.EAI.title = 'Expand All Images' ImageExpand.EAI.title = 'Expand All Images'
func = ImageExpand.contract func = ImageExpand.contract
g.posts.forEach (post) -> g.posts.forEach (post) ->
func post toggle post
func post for post in post.clones toggle post for post in post.clones
return return
setFitness: -> setFitness: ->
(if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-' (if @checked then $.addClass else $.rmClass) doc, @name.toLowerCase().replace /\s+/g, '-'