Merge branch 'bstable'

Conflicts:
	LICENSE
	builds/4chan-X-beta.crx
	builds/4chan-X-beta.meta.js
	builds/4chan-X-beta.user.js
	builds/4chan-X-noupdate.crx
	builds/4chan-X-noupdate.user.js
	builds/4chan-X.crx
	builds/4chan-X.meta.js
	builds/4chan-X.user.js
	builds/4chan-X.zip
	builds/updates-beta.xml
	builds/updates.xml
	package.json
	src/Images/ImageExpand.coffee
This commit is contained in:
ccd0 2015-01-31 23:43:10 -08:00
commit 8263d61d80
5 changed files with 42 additions and 2 deletions

View File

@ -6,11 +6,18 @@ The links to individual versions below are to copies of the script with the upda
### v1.9.22.0
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.0/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.22.0/builds/4chan-X-noupdate.crx "Chromium version")]
Based on v1.9.21.9.
- Open new videos with the mute and volume settings of the last video adjusted.
- Add default volume control in the header menu, and duplicate "Allow Sounds" there.
- Minor fixes.
<!-- v1.9.21.x -->
### v1.9.21.10
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.10/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.10/builds/4chan-X-noupdate.crx "Chromium version")]
- Add `Click Passthrough` option (off by default) to allow clicks on videos to perform the browser's default function. Restore dragging to the left to contract and the contract button (shown if `Click Passthrough` is on).
### v1.9.21.9
*2015-01-31* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.9/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.9.21.9/builds/4chan-X-noupdate.crx "Chromium version")]

View File

@ -251,6 +251,11 @@ Config =
true
'Show controls on videos expanded inline.'
]
'Click Passthrough': [
false
'Clicks on videos trigger your browser\'s default behavior. Videos can be contracted with button / dragging to the left.'
1
]
'Allow Sound': [
true
'Open videos with the sound unmuted.'

View File

@ -60,6 +60,7 @@ class Clone extends Post
@file.text = file.firstElementChild
@file.thumb = $ '.fileThumb > [data-md5]', file
@file.fullImage = $ '.full-image', file
@file.videoControls = $ '.video-controls', @file.text
@file.thumb.muted = true if @file.videoThumb

View File

@ -82,7 +82,8 @@ ImageCommon =
# XXX Estimate whether clicks are on the video controls and should be ignored.
onControls: (e) ->
e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35
(Conf['Show Controls'] and Conf['Click Passthrough']) or
(e.target.controls and e.target.getBoundingClientRect().bottom - e.clientY < 35)
download: (e) ->
return true if @protocol is 'blob:'

View File

@ -11,6 +11,8 @@ ImageExpand =
$.on @EAI, 'click', @cb.toggleAll
Header.addShortcut @EAI, 3
$.on d, 'scroll visibilitychange', @cb.playVideos
@videoControls = $.el 'span', className: 'video-controls'
$.extend @videoControls, <%= html('\u00A0<a href="javascript:;" title="You can also contract the video by dragging it to the left.">contract</a>') %>
Post.callbacks.push
name: 'Image Expansion'
@ -29,6 +31,7 @@ ImageExpand =
else if @file.isExpanded and @file.isVideo
Volume.setup @file.fullImage
ImageExpand.setupVideoCB @
ImageExpand.setupVideo @, !@origin.file.fullImage?.paused or @origin.file.wasPlaying, @file.fullImage.controls
else if ImageExpand.on and !@isHidden and !@isFetchedQuote and
@ -118,9 +121,10 @@ ImageExpand =
$.rmClass post.nodes.root, 'expanded-image'
$.rmClass file.thumb, 'expanding'
$.rm file.videoControls if file.videoControls
file.thumb.parentNode.href = file.URL
file.thumb.parentNode.target = '_blank'
for x in ['isExpanding', 'isExpanded', 'wasPlaying', 'scrollIntoView']
for x in ['isExpanding', 'isExpanded', 'videoControls', 'wasPlaying', 'scrollIntoView']
delete file[x]
return unless el
@ -140,6 +144,8 @@ ImageExpand =
ImageCommon.pushCache el
if file.isVideo
el.pause()
for eventName, cb of ImageExpand.videoCB
$.off el, eventName, cb
ImageCommon.rewind file.thumb if Conf['Restart when Opened']
delete file.fullImage
$.queueTask ->
@ -176,12 +182,18 @@ ImageExpand =
$.after thumb, el
if isVideo
# add contract link to file info
if Conf['Show Controls'] and Conf['Click Passthrough'] and !file.videoControls
file.videoControls = ImageExpand.videoControls.cloneNode true
$.add file.text, file.videoControls
# disable link to file so native controls can work
thumb.parentNode.removeAttribute 'href'
thumb.parentNode.removeAttribute 'target'
el.loop = true
Volume.setup el, isNew
ImageExpand.setupVideoCB post
if !isVideo
$.asap (-> el.naturalHeight), -> ImageExpand.completeExpand post
@ -231,6 +243,20 @@ ImageExpand =
if controls
ImageCommon.addControls fullImage
videoCB: do ->
# dragging to the left contracts the video
mousedown = false
mouseover: -> mousedown = false
mousedown: (e) -> mousedown = true if e.button is 0
mouseup: (e) -> mousedown = false if e.button is 0
mouseout: (e) -> ImageExpand.toggle(Get.postFromNode @) if mousedown and e.clientX <= @getBoundingClientRect().left
setupVideoCB: (post) ->
for eventName, cb of ImageExpand.videoCB
$.on post.file.fullImage, eventName, cb
if post.file.videoControls
$.on post.file.videoControls.firstElementChild, 'click', -> ImageExpand.toggle post
error: ->
post = Get.postFromNode @
$.rm @