From be50e4b1f484635a22f091f597486b1f5b550146 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 7 Apr 2014 21:17:19 -0700 Subject: [PATCH] add 'Expand videos' setting --- builds/4chan-X.user.js | 5 +++-- builds/crx/script.js | 5 +++-- src/General/Config.coffee | 4 ++++ src/Images/ImageExpand.coffee | 7 +++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index b33fa2622..6b41ed99e 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -245,6 +245,7 @@ 'Fit width': [false, ''], 'Fit height': [false, ''], 'Expand spoilers': [true, 'Expand all images along with spoilers.'], + 'Expand videos': [false, 'Expand all images also expands videos (no autoplay).'], 'Expand from here': [false, 'Expand all images only from current position to thread end.'], 'Advance on contract': [false, 'Advance to next post when contracting an expanded image.'] }, @@ -7613,7 +7614,7 @@ return ImageExpand.startVideo(clone); }); } - } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler)) { + } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) { return ImageExpand.expand(this, null, true); } }, @@ -7639,7 +7640,7 @@ if (!(file && (file.isImage || file.isVideo) && doc.contains(post.nodes.root))) { return; } - if (ImageExpand.on && (!Conf['Expand spoilers'] && file.isSpoiler || Conf['Expand from here'] && Header.getTopOf(file.thumb) < 0)) { + if (ImageExpand.on && (!Conf['Expand spoilers'] && file.isSpoiler || !Conf['Expand videos'] && file.isVideo || Conf['Expand from here'] && Header.getTopOf(file.thumb) < 0)) { return; } return $.queueTask(func, post); diff --git a/builds/crx/script.js b/builds/crx/script.js index 73da113d3..bed290599 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -221,6 +221,7 @@ 'Fit width': [false, ''], 'Fit height': [false, ''], 'Expand spoilers': [true, 'Expand all images along with spoilers.'], + 'Expand videos': [false, 'Expand all images also expands videos (no autoplay).'], 'Expand from here': [false, 'Expand all images only from current position to thread end.'], 'Advance on contract': [false, 'Advance to next post when contracting an expanded image.'] }, @@ -7632,7 +7633,7 @@ return ImageExpand.startVideo(clone); }); } - } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler)) { + } else if (ImageExpand.on && !this.isHidden && (Conf['Expand spoilers'] || !this.file.isSpoiler) && (Conf['Expand videos'] || !this.file.isVideo)) { return ImageExpand.expand(this, null, true); } }, @@ -7658,7 +7659,7 @@ if (!(file && (file.isImage || file.isVideo) && doc.contains(post.nodes.root))) { return; } - if (ImageExpand.on && (!Conf['Expand spoilers'] && file.isSpoiler || Conf['Expand from here'] && Header.getTopOf(file.thumb) < 0)) { + if (ImageExpand.on && (!Conf['Expand spoilers'] && file.isSpoiler || !Conf['Expand videos'] && file.isVideo || Conf['Expand from here'] && Header.getTopOf(file.thumb) < 0)) { return; } return $.queueTask(func, post); diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 6a98ce1ab..d12ec6f61 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -413,6 +413,10 @@ Config = true 'Expand all images along with spoilers.' ] + 'Expand videos': [ + false + 'Expand all images also expands videos (no autoplay).' + ] 'Expand from here': [ false 'Expand all images only from current position to thread end.' diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 62bb87524..41c13f52f 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -27,8 +27,10 @@ ImageExpand = ImageExpand.setupVideoControls clone unless clone.origin.file.fullImage.paused $.queueTask -> ImageExpand.startVideo clone - else if ImageExpand.on and !@isHidden and (Conf['Expand spoilers'] or !@file.isSpoiler) - ImageExpand.expand @, null, true + else if ImageExpand.on and !@isHidden and + (Conf['Expand spoilers'] or !@file.isSpoiler) and + (Conf['Expand videos'] or !@file.isVideo) + ImageExpand.expand @, null, true cb: toggle: (e) -> return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 @@ -44,6 +46,7 @@ ImageExpand = return unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root if ImageExpand.on and (!Conf['Expand spoilers'] and file.isSpoiler or + !Conf['Expand videos'] and file.isVideo or Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0) return $.queueTask func, post