Merge branch 'mayhem' into v3

Conflicts:
	CHANGELOG.md
	package.json
	src/Images/ImageExpand.coffee
	src/Images/ImageHover.coffee
	src/Miscellaneous/FileInfo.coffee
	src/Posting/QR.coffee
This commit is contained in:
Zixaphir 2014-04-04 20:24:12 -07:00
commit f6353729eb
14 changed files with 172 additions and 261 deletions

View File

@ -1,5 +1,13 @@
<<<<<<< HEAD
**duckness**:
- Merge changes from Mayhem fork
=======
## 3.20.0 - *2014-04-05*
- Add support for .webm files.
### 3.19.5 - *2014-04-03*
>>>>>>> mayhem
**MayhemYDG**:
- Fix captcha submission:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,15 +28,15 @@
},
"devDependencies": {
"font-awesome": "~4.0.3",
"grunt": "~0.4.2",
"grunt": "~0.4.4",
"grunt-bump": "~0.0.13",
"grunt-concurrent": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-coffee": "~0.10.0",
"grunt-contrib-coffee": "~0.10.1",
"grunt-contrib-compress": "~0.7.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-concat": "~0.4.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-watch": "~0.6.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-shell": "~0.6.4",
"load-grunt-tasks": "~0.4.0"
},

View File

@ -149,7 +149,8 @@ Filter =
return post.file.name
false
dimensions: (post) ->
if post.file and post.file.isImage
{file} = post
if file and (file.isImage or file.isVideo)
return post.file.dimensions
false
filesize: (post) ->

View File

@ -7,8 +7,9 @@ Build =
# OPs have a +10 characters threshold.
# The file extension is not taken into account.
threshold = if isReply then 30 else 40
if filename.length - 4 > threshold
"#{filename[...threshold - 5]}(...).#{filename[-3..]}"
ext = filename.match(/\.[^.]+$/)[0]
if filename.length - ext.length > threshold
"#{filename[...threshold - 5]}(...)#{ext}"
else
filename
thumbRotate: do ->

View File

@ -388,6 +388,7 @@ Settings =
sizeInBytes: 276 * 1024
dimensions: '1280x720'
isImage: true
isVideo: false
isSpoiler: true
funk = FileInfo.createFunc @value
@nextElementSibling.innerHTML = funk FileInfo, data

View File

@ -108,7 +108,7 @@ div.center:not(.ad-cnt) {
/* fixed, z-index */
#overlay,
#fourchanx-settings,
#qp, .ihover,
#qp, #ihover,
#navlinks, .fixed #header-bar,
:root.float #updater,
:root.float #thread-stats,
@ -124,7 +124,7 @@ div.center:not(.ad-cnt) {
#notifications {
z-index: 70;
}
#qp, .ihover {
#qp, #ihover {
z-index: 60;
}
#menu {
@ -840,7 +840,7 @@ span.hide-announcement {
:root.gecko.fit-width .full-image {
width: 100%;
}
.ihover {
#ihover {
-moz-box-sizing: border-box;
box-sizing: border-box;
max-height: 100%;

View File

@ -116,7 +116,7 @@ class Post
parseFile: (that) ->
return unless (fileEl = $ '.file', @nodes.post) and thumb = $ 'img[data-md5]', fileEl
# Supports JPG/PNG/GIF/PDF.
# Supports JPG/PNG/GIF/WEBM/PDF.
# Flash files are not supported.
anchor = thumb.parentNode
fileText = fileEl.firstElementChild

View File

@ -32,4 +32,3 @@ AutoGIF =
else
thumb.src = URL
gif.src = URL

View File

@ -14,7 +14,7 @@ ImageExpand =
name: 'Image Expansion'
cb: @node
node: ->
return unless @file?.isImage or @file?.isVideo
return unless @file and (@file.isImage or @file.isVideo)
{thumb} = @file
$.on thumb.parentNode, 'click', ImageExpand.cb.toggle
if @isClone and $.hasClass thumb, 'expanding'
@ -46,7 +46,7 @@ ImageExpand =
for post in [post].concat post.clones
{file} = post
return unless file and (file.isImage or file.isVideo) and doc.contains post.nodes.root
if ImageExpand.on and
if ImageExpand.on and !post.isHidden and
(!Conf['Expand spoilers'] and file.isSpoiler or
Conf['Expand from here'] and Header.getTopOf(file.thumb) < 0)
return
@ -87,10 +87,10 @@ ImageExpand =
ImageExpand.contract post
contract: (post) ->
post.file.fullImage?.pause() if post.file.isVideo
$.rmClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
post.file.isExpanded = false
post.file.fullImage.pause() if post.file.isVideo
post.file.videoControls?.map($.rm)
delete post.file.videoControls
@ -99,41 +99,37 @@ ImageExpand =
{thumb, isVideo} = post.file
return if post.isHidden or post.file.isExpanded or $.hasClass thumb, 'expanding'
$.addClass thumb, 'expanding'
naturalHeight = if isVideo then 'videoHeight' else 'naturalHeight'
if img = post.file.fullImage
if post.file.fullImage
# Expand already-loaded/ing picture.
$.rmClass img, 'ihover'
$.addClass img, 'full-image'
img.controls = (img.parentNode isnt thumb.parentNode)
$.asap (-> img[naturalHeight]), ->
$.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), ->
ImageExpand.completeExpand post
return
post.file.fullImage = img = $.el (if isVideo then 'video' else 'img'),
file =
$.el (if post.file.isImage then 'img' else 'video'),
className: 'full-image'
src: src or post.file.URL
post.file.fullImage = file
if isVideo
img.loop = true
img.controls = Conf['Show Controls']
$.on img, 'error', ImageExpand.error
$.asap (-> post.file.fullImage[naturalHeight]), ->
file.loop = true
file.controls = Conf['Show Controls']
$.on file, 'error', ImageExpand.error
$.asap (-> post.file.isVideo or post.file.fullImage.naturalHeight), ->
ImageExpand.completeExpand post
$.after (if img.controls then thumb.parentNode else thumb), img
$.after (if file.controls then thumb.parentNode else thumb), file
completeExpand: (post) ->
{thumb} = post.file
return unless $.hasClass thumb, 'expanding' # contracted before the image loaded
post.file.isExpanded = true
ImageExpand.setupVideo post if post.file.isVideo
$.addClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
unless post.nodes.root.parentNode
# Image might start/finish loading before the post is inserted.
# Don't scroll when it's expanded in a QP for example.
$.addClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
return
{bottom} = post.nodes.root.getBoundingClientRect()
$.queueTask ->
$.addClass post.nodes.root, 'expanded-image'
$.rmClass post.file.thumb, 'expanding'
return unless bottom <= 0
window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - bottom

View File

@ -9,45 +9,36 @@ ImageHover =
name: 'Image Hover'
cb: @catalogNode
node: ->
return unless @file?.isImage or @file?.isVideo
return unless @file and (@file.isImage or @file.isVideo)
$.on @file.thumb, 'mouseover', ImageHover.mouseover
catalogNode: ->
return unless @thread.OP.file?.isImage
return unless @thread.OP.file and (@thread.OP.file.isImage or @thread.OP.file.isVideo)
$.on @nodes.thumb, 'mouseover', ImageHover.mouseover
mouseover: (e) ->
post = if $.hasClass @, 'thumb'
g.posts[@parentNode.dataset.fullID]
else
Get.postFromNode @
{isVideo} = post.file
if post.file.fullImage
el = post.file.fullImage
$.rmClass el, 'full-image'
$.addClass el, 'ihover'
else
el = $.el (if isVideo then 'video' else 'img'),
className: 'ihover'
el = if post.file.isImage
$.el 'img',
id: 'ihover'
src: post.file.URL
post.file.fullImage = el
{thumb} = post.file
$.after (if isVideo and Conf['Show Controls'] then thumb.parentNode else thumb), el
else
$.el 'video',
controls: false
id: 'ihover'
src: post.file.URL
autoplay: Conf['Autoplay']
muted: !Conf['Allow Sound']
loop: true
$.add Header.hover, el
el.dataset.fullID = post.fullID
if isVideo
el.loop = true
el.controls = false
el.muted = not Conf['Allow Sound']
el.play() if Conf['Autoplay']
naturalHeight = if post.file.isVideo then 'videoHeight' else 'naturalHeight'
UI.hover
root: @
el: el
latestEvent: e
endEvents: 'mouseout click'
asapTest: -> el[naturalHeight]
cb: ->
el.pause() if isVideo
$.rmClass el, 'ihover'
$.addClass el, 'full-image'
asapTest: -> post.file.isVideo or el.naturalHeight
$.on el, 'error', ImageHover.error
error: ->
return unless doc.contains @

View File

@ -47,4 +47,4 @@ FileInfo =
B: -> FileInfo.convertUnit @file.sizeInBytes, 'B'
K: -> FileInfo.convertUnit @file.sizeInBytes, 'KB'
M: -> FileInfo.convertUnit @file.sizeInBytes, 'MB'
r: -> if @file.isImage or @file.isVideo then @file.dimensions else 'PDF'
r: -> @file.dimensions or 'PDF'

View File

@ -1,7 +1,4 @@
QR =
# Add empty mimeType to avoid errors with URLs selected in Window's file dialog.
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/x-shockwave-flash', 'video/webm', '']
init: ->
return if !Conf['Quick Reply']
@ -390,23 +387,15 @@ QR =
if file.size > max
QR.error "#{file.name}: File too large (file: #{$.bytesToString file.size}, max: #{$.bytesToString max})."
return
else unless file.type in QR.mimeTypes
unless /^text/.test file.type
QR.error "#{file.name}: Unsupported file type."
return
if isSingle
post = QR.selected
else if (post = QR.posts[QR.posts.length - 1]).com
post = new QR.post()
post.pasteText file
return
if isSingle
post = QR.selected
else if (post = QR.posts[QR.posts.length - 1]).file
post = new QR.post()
if /^text/.test file.type
post.pasteText file
else
post.setFile file
openFileInput: (e) ->
openFileInput: ->
e.stopPropagation()
if e.shiftKey and e.type is 'click'
return QR.selected.rmFile()
@ -416,7 +405,6 @@ QR =
return $.on QR.nodes.filename, 'blur', -> $.rmClass QR.nodes.filename, 'edit'
return if e.target.nodeName is 'INPUT' or (e.keyCode and e.keyCode not in [32, 13]) or e.ctrlKey
e.preventDefault()
QR.nodes.fileInput.click()
generatePostableThreadsList: ->
return unless QR.nodes