expand from current

This commit is contained in:
James Campos 2012-02-20 21:53:40 -08:00
parent 8341bad881
commit 7637becde3
2 changed files with 24 additions and 9 deletions

View File

@ -101,7 +101,8 @@
'Image Expansion': [true, 'Expand images'],
'Image Hover': [false, 'Show full image on mouseover'],
'Sauce': [true, 'Add sauce to images'],
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail'],
'Expand From Current': [true, 'Expand images from current position to thread end.']
},
Monitoring: {
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.'],
@ -3435,18 +3436,25 @@
return imgExpand.toggle(this);
},
all: function() {
var thumb, _i, _j, _len, _len2, _ref, _ref2;
var i, thumb, thumbs, _i, _j, _len, _len2, _len3, _ref;
imgExpand.on = this.checked;
if (imgExpand.on) {
_ref = $$('img[md5]');
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
thumb = _ref[_i];
thumbs = $$('img[md5]');
if (conf['Expand From Current']) {
for (i = 0, _len = thumbs.length; i < _len; i++) {
thumb = thumbs[i];
if (thumb.getBoundingClientRect().top > 0) break;
}
thumbs = thumbs.slice(i);
}
for (_i = 0, _len2 = thumbs.length; _i < _len2; _i++) {
thumb = thumbs[_i];
imgExpand.expand(thumb);
}
} else {
_ref2 = $$('img[md5][hidden]');
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
thumb = _ref2[_j];
_ref = $$('img[md5][hidden]');
for (_j = 0, _len3 = _ref.length; _j < _len3; _j++) {
thumb = _ref[_j];
imgExpand.contract(thumb);
}
}

View File

@ -24,6 +24,7 @@ config =
'Image Hover': [false, 'Show full image on mouseover']
'Sauce': [true, 'Add sauce to images']
'Reveal Spoilers': [false, 'Replace spoiler thumbnails by the original thumbnail']
'Expand From Current': [true, 'Expand images from current position to thread end.']
Monitoring:
'Thread Updater': [true, 'Update threads. Has more options in its own dialog.']
'Unread Count': [true, 'Show unread post count in tab title']
@ -2767,7 +2768,13 @@ imgExpand =
all: ->
imgExpand.on = @checked
if imgExpand.on #expand
for thumb in $$ 'img[md5]'
thumbs = $$ 'img[md5]'
if conf['Expand From Current']
for thumb, i in thumbs
if thumb.getBoundingClientRect().top > 0
break
thumbs = thumbs[i...]
for thumb in thumbs
imgExpand.expand thumb
else #contract
for thumb in $$ 'img[md5][hidden]'