Merge branch 'v3'
Conflicts: CHANGELOG.md LICENSE README.md builds/appchan-x.user.js builds/crx/manifest.json builds/crx/script.js builds/updates.xml latest.js package.json
This commit is contained in:
commit
6dcbb80070
@ -1,3 +1,7 @@
|
||||
**ccd0**:
|
||||
- Support expansion of .webm videos.
|
||||
- Update archives with data from MayhemYDG fork.
|
||||
|
||||
### v2.9.11
|
||||
*2014-04-03*
|
||||
|
||||
|
||||
@ -50,7 +50,6 @@ module.exports = (grunt) ->
|
||||
crx:
|
||||
files:
|
||||
'builds/crx/manifest.json': 'src/General/meta/manifest.json'
|
||||
'builds/updates.xml': 'src/General/meta/updates.xml'
|
||||
'builds/crx/script.js': [
|
||||
'src/General/meta/botproc.js'
|
||||
'src/General/meta/banner.js'
|
||||
|
||||
2
LICENSE
2
LICENSE
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* appchan x - Version 2.9.11 - 2014-04-03
|
||||
* appchan x - Version 2.9.11 - 2014-04-04
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name 4chan X
|
||||
// @version 1.4.5
|
||||
// @version 1.5.0
|
||||
// @minGMVer 1.14
|
||||
// @minFFVer 26
|
||||
// @namespace 4chan-X
|
||||
@ -17,7 +17,7 @@
|
||||
// @grant GM_openInTab
|
||||
// @grant GM_xmlhttpRequest
|
||||
// @run-at document-start
|
||||
// @updateURL https://github.com/ccd0/4chan-x/raw/stable/builds/4chan-X.meta.js
|
||||
// @downloadURL https://github.com/ccd0/4chan-x/raw/stable/builds/4chan-X.user.js
|
||||
// @updateURL https://ccd0.github.io/4chan-x/builds/4chan-X.meta.js
|
||||
// @downloadURL https://ccd0.github.io/4chan-x/builds/4chan-X.user.js
|
||||
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAF5JREFUeNrtkTESABAQxPD/R6tsE2dUGYUtFJvLDKf93KevHJAjpBorAQWSBIKqFASC4G0pCAkm4GfaEvgYXl0T6HBaE97f0vmnfYHbZOMLZCx9ISdKWwjOWZSC8GYm4SUGwfYgqI4AAAAASUVORK5CYII=
|
||||
// ==/UserScript==
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
// @grant GM_openInTab
|
||||
// @grant GM_xmlhttpRequest
|
||||
// @run-at document-start
|
||||
// @updateURL https://github.com/zixaphir/appchan-x/raw/stable/builds/appchan-x.meta.js
|
||||
// @downloadURL https://github.com/zixaphir/appchan-x/raw/stable/builds/appchan-x.user.js
|
||||
// @updateURL appchan-x.meta.js
|
||||
// @downloadURL appchan-x.user.js
|
||||
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEX///8EZgR8ulSk0oT///8EAgQ1A88mAAAAAXRSTlMAQObYZgAAAIpJREFUeF6t0sENwjAMhWF84N4H6gAYMUBkdQMYwfuvwmstEeD4kl892P0OaaWcpga2/K0SGII1HNBXARgu7veoY3ANd+esgMHZIz85u0EABrbms3pl/bkC1Tn5ihGOfQwqHeZ/FdYdirEMgCG2ZAQWDTL0m9FvjAhcvoGNAK2gZhGYYX9+ZgFm9gaiNmNkMENY4QAAAABJRU5ErkJggg==
|
||||
// ==/UserScript==
|
||||
|
||||
File diff suppressed because one or more lines are too long
BIN
builds/crx.crx
BIN
builds/crx.crx
Binary file not shown.
@ -15,7 +15,7 @@
|
||||
"run_at": "document_start"
|
||||
}],
|
||||
"homepage_url": "http://zixaphir.github.com/appchan-x/",
|
||||
"update_url": "https://github.com/zixaphir/appchan-x/raw/master/builds/updates.xml",
|
||||
"update_url": "updates.xml",
|
||||
"minimum_chrome_version": "32",
|
||||
"permissions": [
|
||||
"storage",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
|
||||
<app appid='appchan x'>
|
||||
<updatecheck codebase='https://github.com/zixaphir/appchan-x/raw/master/builds/crx.crx' version='2.9.11' />
|
||||
</app>
|
||||
</gupdate>
|
||||
|
||||
@ -6,9 +6,9 @@ Redirect =
|
||||
file: {}
|
||||
|
||||
archives = {}
|
||||
for {name, boards, files, data} in Redirect.archives
|
||||
archives[name] = {boards, files, data}
|
||||
{software} = data
|
||||
for data in Redirect.archives
|
||||
{name, boards, files, software} = data
|
||||
archives[name] = data
|
||||
for boardID in boards
|
||||
o.thread[boardID] = data unless boardID of o.thread
|
||||
o.post[boardID] = data unless boardID of o.post or software isnt 'foolfuuka'
|
||||
@ -18,134 +18,11 @@ Redirect =
|
||||
for type, id of record when (archive = archives[id])
|
||||
boards = if type is 'file' then archive.files else archive.boards
|
||||
continue unless boardID in boards
|
||||
o[type][boardID] = archive.data
|
||||
o[type][boardID] = archive
|
||||
|
||||
Redirect.data = o
|
||||
|
||||
archives: [
|
||||
name: "Foolz"
|
||||
boards: ["a", "biz", "co", "diy", "gd", "jp", "m", "sci", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"]
|
||||
files: ["a", "biz", "diy", "gd", "jp", "m", "sci", "tg", "vg", "vp", "vr", "wsg"]
|
||||
data:
|
||||
domain: "archive.foolz.us"
|
||||
http: false
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "NSFW Foolz"
|
||||
boards: ["u"]
|
||||
files: ["u"]
|
||||
data:
|
||||
domain: "nsfw.foolz.us"
|
||||
http: false
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "The Dark Cave"
|
||||
boards: ["c", "int", "out", "po"]
|
||||
files: ["c", "po"]
|
||||
data:
|
||||
domain: "archive.thedarkcave.org"
|
||||
http: true
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "4plebs"
|
||||
boards: ["adv", "hr", "o", "pol", "s4s", "tg", "trv", "tv", "x"]
|
||||
files: ["adv", "hr", "o", "pol", "s4s", "tg", "trv", "tv", "x"]
|
||||
data:
|
||||
domain: "archive.4plebs.org"
|
||||
http: true
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "4plebs Flash Archive",
|
||||
boards: ["f"]
|
||||
files: ["f"]
|
||||
data:
|
||||
domain: "flash.4plebs.org"
|
||||
http: true
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "Nyafuu"
|
||||
boards: ["c", "e", "w", "wg"]
|
||||
files: ["c", "e", "w", "wg"]
|
||||
data:
|
||||
domain: "archive.nyafuu.org"
|
||||
http: true
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "Love is Over"
|
||||
boards: ["d", "i"]
|
||||
files: ["d", "i"]
|
||||
data:
|
||||
domain: "loveisover.me"
|
||||
http: true
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "Rebecca Black Tech"
|
||||
boards: ["cgl", "g", "mu", "w"]
|
||||
files: ["cgl", "g", "mu", "w"]
|
||||
data:
|
||||
domain: "archive.rebeccablacktech.com"
|
||||
http: true
|
||||
https: true
|
||||
software: "fuuka"
|
||||
,
|
||||
name: "Heinessen"
|
||||
boards: ["an", "fit", "k", "mlp", "r9k", "toy"]
|
||||
files: ["an", "fit", "k", "r9k", "toy"]
|
||||
data:
|
||||
domain: "archive.heinessen.com"
|
||||
http: true
|
||||
software: "fuuka"
|
||||
,
|
||||
name: "warosu"
|
||||
boards: ["3", "biz", "cgl", "ck", "diy", "fa", "g", "ic", "jp", "lit", "sci", "tg", "vr"]
|
||||
files: ["3", "biz", "cgl", "ck", "diy", "fa", "ic", "jp", "lit", "sci", "tg", "vr"]
|
||||
data:
|
||||
domain: "fuuka.warosu.org"
|
||||
https: true
|
||||
software: "fuuka"
|
||||
,
|
||||
name: "fgts"
|
||||
boards: ["cm", "hm", "r", "soc", "y"]
|
||||
files: ["cm", "hm", "r", "soc", "y"]
|
||||
data:
|
||||
domain: "fgst.eu"
|
||||
http: true
|
||||
https: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "maware"
|
||||
boards: ["t"]
|
||||
files: ["t"]
|
||||
data:
|
||||
domain: "archive.mawa.re"
|
||||
http: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "InstallGentoo"
|
||||
boards: ["g", "t"]
|
||||
files: ["g", "t"]
|
||||
data:
|
||||
domain: "chan.installgentoo.com"
|
||||
http: true
|
||||
software: "foolfuuka"
|
||||
,
|
||||
name: "Foolz Beta"
|
||||
boards: ["a", "biz", "co", "d", "diy", "gd", "jp", "m", "mlp", "s4s", "sci", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
|
||||
files: ["a", "biz", "d", "diy", "gd", "jp", "m", "s4s", "sci", "tg", "u", "vg", "vp", "vr", "wsg"]
|
||||
data:
|
||||
domain: "beta.foolz.us"
|
||||
http: true
|
||||
https: true
|
||||
withCredentials: true
|
||||
software: "foolfuuka"
|
||||
]
|
||||
archives: `<%= JSON.stringify(grunt.file.readJSON('src/Archive/archives.json')) %>`
|
||||
|
||||
to: (dest, data) ->
|
||||
archive = (if dest in ['search', 'board'] then Redirect.data.thread else Redirect.data[dest])[data.boardID]
|
||||
|
||||
128
src/Archive/archives.json
Normal file
128
src/Archive/archives.json
Normal file
@ -0,0 +1,128 @@
|
||||
[{
|
||||
"uid": 0,
|
||||
"name": "Foolz",
|
||||
"domain": "archive.foolz.us",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["a", "biz", "co", "diy", "gd", "jp", "m", "sci", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"],
|
||||
"files": ["a", "biz", "gd", "diy", "jp", "m", "sci", "tg", "vg", "vp", "vr", "wsg"]
|
||||
}, {
|
||||
"uid": 1,
|
||||
"name": "NSFW Foolz",
|
||||
"domain": "nsfw.foolz.us",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["u"],
|
||||
"files": ["u"]
|
||||
}, {
|
||||
"uid": 2,
|
||||
"name": "The Dark Cave",
|
||||
"domain": "archive.thedarkcave.org",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["c", "int", "out", "po"],
|
||||
"files": ["c", "po"]
|
||||
}, {
|
||||
"uid": 3,
|
||||
"name": "4plebs Archive",
|
||||
"domain": "archive.4plebs.org",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["adv", "hr", "o", "pol", "s4s", "tg", "trv", "tv", "x"],
|
||||
"files": ["adv", "hr", "o", "pol", "s4s", "tg", "trv", "tv", "x"]
|
||||
}, {
|
||||
"uid": 18,
|
||||
"name": "4plebs Flash Archive",
|
||||
"domain": "flash.4plebs.org",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["f"],
|
||||
"files": ["f"]
|
||||
}, {
|
||||
"uid": 4,
|
||||
"name": "Nyafuu",
|
||||
"domain": "archive.nyafuu.org",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["c", "e", "w", "wg"],
|
||||
"files": ["c", "e", "w", "wg"]
|
||||
}, {
|
||||
"uid": 5,
|
||||
"name": "Love is Over",
|
||||
"domain": "loveisover.me",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["d", "i"],
|
||||
"files": ["d", "i"]
|
||||
}, {
|
||||
"uid": 8,
|
||||
"name": "Rebecca Black Tech",
|
||||
"domain": "rbt.asia",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "fuuka",
|
||||
"boards": ["cgl", "g", "mu", "w"],
|
||||
"files": ["cgl", "g", "mu", "w"]
|
||||
}, {
|
||||
"uid": 9,
|
||||
"name": "Heinessen",
|
||||
"domain": "archive.heinessen.com",
|
||||
"http": true,
|
||||
"https": false,
|
||||
"software": "fuuka",
|
||||
"boards": ["an", "fit", "k", "mlp", "r9k", "toy"],
|
||||
"files": ["an", "fit", "k", "r9k", "toy"]
|
||||
}, {
|
||||
"uid": 10,
|
||||
"name": "warosu",
|
||||
"domain": "fuuka.warosu.org",
|
||||
"http": false,
|
||||
"https": true,
|
||||
"software": "fuuka",
|
||||
"boards": ["3", "biz", "cgl", "ck", "diy", "fa", "g", "ic", "jp", "lit", "sci", "tg", "vr"],
|
||||
"files": ["3", "biz", "cgl", "ck", "diy", "fa", "ic", "jp", "lit", "sci", "tg", "vr"]
|
||||
}, {
|
||||
"uid": 15,
|
||||
"name": "fgts",
|
||||
"domain": "fgts.eu",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["cm", "hm", "r", "soc", "y"],
|
||||
"files": ["cm", "hm", "r", "soc", "y"]
|
||||
}, {
|
||||
"uid": 16,
|
||||
"name": "maware",
|
||||
"domain": "archive.mawa.re",
|
||||
"http": true,
|
||||
"https": false,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["t"],
|
||||
"files": ["t"]
|
||||
}, {
|
||||
"uid": 17,
|
||||
"name": "installgentoo.com",
|
||||
"domain": "chan.installgentoo.com",
|
||||
"http": true,
|
||||
"https": false,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["g", "t"],
|
||||
"files": ["g", "t"]
|
||||
}, {
|
||||
"uid": 13,
|
||||
"name": "Foolz Beta",
|
||||
"domain": "beta.foolz.us",
|
||||
"http": true,
|
||||
"https": true,
|
||||
"withCredentials": true,
|
||||
"software": "foolfuuka",
|
||||
"boards": ["a", "biz", "co", "d", "diy", "gd", "jp", "m", "s4s", "sci", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
|
||||
"files": ["a", "biz", "d", "diy", "gd", "jp", "m", "s4s", "sci", "tg", "u", "vg", "vp", "vr", "wsg"]
|
||||
}]
|
||||
@ -114,10 +114,10 @@ Config =
|
||||
'Show stubs of hidden threads / replies.'
|
||||
]
|
||||
|
||||
'Images':
|
||||
'Images and Videos':
|
||||
'Image Expansion': [
|
||||
true
|
||||
'Expand images.'
|
||||
'Expand images / videos.'
|
||||
]
|
||||
'Image Hover': [
|
||||
true
|
||||
@ -163,6 +163,14 @@ Config =
|
||||
false
|
||||
'Hide all post images when toggled.'
|
||||
]
|
||||
'Autoplay': [
|
||||
true
|
||||
'Videos begin playing immediately when opened inline.'
|
||||
]
|
||||
'Show Controls': [
|
||||
true
|
||||
'Show native seek and volume controls on videos. Contract videos when dragged to the left.'
|
||||
]
|
||||
|
||||
'Menu':
|
||||
'Menu': [
|
||||
|
||||
@ -265,14 +265,14 @@ Settings =
|
||||
$.on $.id('apply-css'), 'click', Settings.usercss
|
||||
|
||||
archBoards = {}
|
||||
for {name, boards, files, data} in Redirect.archives
|
||||
for {name, boards, files, software} in Redirect.archives
|
||||
for boardID in boards
|
||||
o = archBoards[boardID] or=
|
||||
thread: []
|
||||
post: []
|
||||
file: []
|
||||
o.thread.push name
|
||||
o.post.push name if data.software is 'foolfuuka'
|
||||
o.post.push name if software is 'foolfuuka'
|
||||
o.file.push name if boardID in files
|
||||
|
||||
rows = []
|
||||
|
||||
@ -825,7 +825,7 @@ span.hide-announcement {
|
||||
.fileText:hover .fntrunc,
|
||||
.fileText:not(:hover) .fnfull,
|
||||
.expanded-image > .post > .file > .fileThumb > img[data-md5],
|
||||
:not(.expanded-image) > .post > .file > .fileThumb > .full-image {
|
||||
:not(.expanded-image) > .post > .file .full-image {
|
||||
display: none;
|
||||
}
|
||||
.expanding {
|
||||
|
||||
@ -147,7 +147,9 @@ class Post
|
||||
# http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data
|
||||
@file.name = @file.name.replace /%22/g, '"'
|
||||
<% } %>
|
||||
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
|
||||
@file.isImage = /(jpg|png|gif)$/i.test @file.name
|
||||
@file.isVideo = /webm$/i.test @file.name
|
||||
if @file.isImage or @file.isVideo
|
||||
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]
|
||||
|
||||
cleanup: (root, post) ->
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
"run_at": "document_start"
|
||||
}],
|
||||
"homepage_url": "<%= meta.page %>",
|
||||
"update_url": "<%= meta.repo %>raw/master/builds/updates.xml",
|
||||
"update_url": "<%= meta.downloads %>updates.xml",
|
||||
"minimum_chrome_version": "<%= meta.min.chrome %>",
|
||||
"permissions": [
|
||||
"storage",
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
// @grant GM_openInTab
|
||||
// @grant GM_xmlhttpRequest
|
||||
// @run-at document-start
|
||||
// @updateURL <%= meta.repo %>raw/stable/builds/<%= meta.files.metajs %>
|
||||
// @downloadURL <%= meta.repo %>raw/stable/builds/<%= meta.files.userjs %>
|
||||
// @updateURL <%= meta.downloads %><%= meta.files.metajs %>
|
||||
// @downloadURL <%= meta.downloads %><%= meta.files.userjs %>
|
||||
// @icon data:image/png;base64,<%= grunt.file.read('src/General/img/icon48.png', {encoding: 'base64'}) %>
|
||||
// ==/UserScript==
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
|
||||
<app appid='<%= meta.name %>'>
|
||||
<updatecheck codebase='<%= meta.repo %>raw/master/builds/crx.crx' version='<%= version %>' />
|
||||
<app appid='<%= meta.appid %>'>
|
||||
<updatecheck codebase='<%= meta.downloads %>crx.crx' version='<%= version %>' />
|
||||
</app>
|
||||
</gupdate>
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ ImageExpand =
|
||||
cb: @node
|
||||
|
||||
node: ->
|
||||
return unless @file?.isImage
|
||||
return unless @file?.isImage or @file?.isVideo
|
||||
{thumb} = @file
|
||||
$.on thumb.parentNode, 'click', ImageExpand.cb.toggle
|
||||
if @isClone and $.hasClass thumb, 'expanding'
|
||||
@ -36,7 +36,6 @@ ImageExpand =
|
||||
|
||||
toggleAll: ->
|
||||
$.event 'CloseMenu'
|
||||
|
||||
if ImageExpand.on = $.hasClass ImageExpand.EAI, 'expand-all-shortcut'
|
||||
ImageExpand.EAI.className = 'contract-all-shortcut a-icon'
|
||||
ImageExpand.EAI.title = 'Contract All Images'
|
||||
@ -49,7 +48,7 @@ ImageExpand =
|
||||
g.posts.forEach (post) ->
|
||||
for post in [post].concat post.clones
|
||||
{file} = post
|
||||
return unless file and file.isImage and doc.contains post.nodes.root
|
||||
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 from here'] and Header.getTopOf(file.thumb) < 0)
|
||||
@ -91,32 +90,40 @@ 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.videoControls?.map($.rm)
|
||||
delete post.file.videoControls
|
||||
|
||||
expand: (post, src) ->
|
||||
# Do not expand images of hidden/filtered replies, or already expanded pictures.
|
||||
{thumb} = post.file
|
||||
return if post.file.isExpanded or $.hasClass thumb, 'expanding'
|
||||
{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 post.file.fullImage
|
||||
# Expand already-loaded/ing picture.
|
||||
$.asap (-> post.file.fullImage.naturalHeight), ->
|
||||
$.asap (-> post.file.fullImage[naturalHeight]), ->
|
||||
ImageExpand.completeExpand post
|
||||
return
|
||||
post.file.fullImage = img = $.el 'img',
|
||||
post.file.fullImage = img = $.el (if isVideo then 'video' else 'img'),
|
||||
className: 'full-image'
|
||||
src: src or post.file.URL
|
||||
if isVideo
|
||||
img.loop = true
|
||||
img.controls = Conf['Show Controls']
|
||||
$.on img, 'error', ImageExpand.error
|
||||
$.asap (-> post.file.fullImage.naturalHeight), ->
|
||||
$.asap (-> post.file.fullImage[naturalHeight]), ->
|
||||
ImageExpand.completeExpand post
|
||||
$.after thumb, img
|
||||
$.after (if img.controls then thumb.parentNode else thumb), img
|
||||
|
||||
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
|
||||
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.
|
||||
@ -130,6 +137,39 @@ ImageExpand =
|
||||
return unless bottom <= 0
|
||||
window.scrollBy 0, post.nodes.root.getBoundingClientRect().bottom - bottom
|
||||
|
||||
setupVideo: (post) ->
|
||||
{file} = post
|
||||
video = file.fullImage
|
||||
file.videoControls = []
|
||||
video.muted = true
|
||||
if video.controls
|
||||
# contract link in file info
|
||||
contract = $.el 'a',
|
||||
textContent: 'contract'
|
||||
href: 'javascript:;'
|
||||
title: 'You can also contract the video by dragging it to the left.'
|
||||
$.on contract, 'click', (e) -> ImageExpand.contract post
|
||||
file.videoControls.push $.tn('\u00A0'), contract
|
||||
# drag left to contract
|
||||
file.mousedown = false
|
||||
$.on video, 'mousedown', (e) -> file.mousedown = true if e.button is 0
|
||||
$.on video, 'mouseup', (e) -> file.mousedown = false if e.button is 0
|
||||
$.on video, 'mouseover', (e) -> file.mousedown = false
|
||||
$.on video, 'mouseout', (e) ->
|
||||
if file.mousedown and e.clientX <= video.getBoundingClientRect().left
|
||||
ImageExpand.contract post
|
||||
if Conf['Autoplay']
|
||||
video.play()
|
||||
else unless video.controls
|
||||
play = $.el 'a',
|
||||
textContent: 'play'
|
||||
href: 'javascript:;'
|
||||
$.on play, 'click', (e) ->
|
||||
video[@textContent]()
|
||||
@textContent = if @textContent is 'play' then 'pause' else 'play'
|
||||
file.videoControls.push $.tn('\u00A0'), play
|
||||
$.add file.text, file.videoControls
|
||||
|
||||
error: ->
|
||||
post = Get.postFromNode @
|
||||
$.rm @
|
||||
|
||||
@ -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 then @file.dimensions else 'PDF'
|
||||
r: -> if @file.isImage or @file.isVideo then @file.dimensions else 'PDF'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user