Merge branch 'v3'

Conflicts:
	LICENSE
	builds/4chan-X.js
	builds/appchan-x.user.js
	builds/crx/script.js
	src/General/Main.coffee
	src/General/css/style.css
	src/General/html/Settings/Advanced.html
This commit is contained in:
Zixaphir 2013-05-23 15:51:51 -07:00
commit 81bd621d0d
10 changed files with 249 additions and 77 deletions

View File

@ -1,5 +1,5 @@
/*
* appchan x - Version 2.0.4 - 2013-05-21
* appchan x - Version 2.0.4 - 2013-05-23
*
* Licensed under the MIT license.
* https://github.com/zixaphir/appchan-x/blob/master/LICENSE

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -147,6 +147,10 @@ Config =
false
'Replace jpgs.'
]
'Image Prefetching': [
false
'Preload images'
]
'Fappe Tyme': [
false
'Hide posts without images when toggled. *hint* *hint*'

View File

@ -140,7 +140,7 @@ Main =
'Image Expansion': ImageExpand
'Image Expansion (Menu)': ImageExpand.menu
'Reveal Spoilers': RevealSpoilers
'Image Replace': ImageReplace
'Image Loading': ImageLoader
'Image Hover': ImageHover
'Fappe Tyme': FappeTyme
'Comment Expansion': ExpandComment

View File

@ -17,24 +17,24 @@
<legend>Custom Board Navigation</legend>
<div><textarea name=boardnav class=field spellcheck=false></textarea></div>
<span class=note>New lines will be converted into spaces.</span><br><br>
<div>In the following, <code>board</code> can translate to a board ID (<code>a</code>, <code>b</code>, etc...), the current board (<code>current</code>), or the Status/Twitter link (<code>status</code>, <code>@</code>).</div>
<div>
For example:<br>
<div class=note>In the following examples for /g/, <code>g</code> can be changed to a different board ID (<code>a</code>, <code>b</code>, etc...), the current board (<code>current</code>), or the Status/Twitter link (<code>status</code>, <code>@</code>).</div>
<div>Board link: <code>g</code></div>
<div>Title link: <code>g-title</code></div>
<div>Board link (Replace with title when on that board): <code>g-replace</code></div>
<div>Full text link: <code>g-full</code></div>
<div>Custom text link: <code>g-text:"Install Gentoo"</code></div>
<div>Index-only link: <code>g-index</code></div>
<div>Catalog-only link: <code>g-catalog</code></div>
<div>External link: <code>external-text:"Google","http://www.google.com"</code></div>
<div>Combinations are possible: <code>g-index-text:"Technology Index"</code></div>
<div>Full board list toggle: <code>toggle-all</code></div>
<br>
<div class=note>
<code>[ toggle-all ] [current-title] [g-title / a-title / jp-title] [x / wsg / h] [t-text:"Piracy"]</code><br>
will give you<br>
<code>[ + ] [Technology] [Technology / Anime & Manga / Otaku Culture] [x / wsg / h] [Piracy]</code><br>
if you are on /g/.
</div>
<div>Board link: <code>board</code></div>
<div>Title link: <code>board-title</code></div>
<div>Board link (Replace with title when on that board): <code>board-replace</code></div>
<div>Full text link: <code>board-full</code></div>
<div>Custom text link: <code>board-text:"VIP Board"</code></div>
<div>Index-only link: <code>board-index</code></div>
<div>Catalog-only link: <code>board-catalog</code></div>
<div>External link: <code>external-text:"Google","http://www.google.com"</code></div>
<div>Combinations are possible: <code>board-index-text:"VIP Index"</code></div>
<div>Full board list toggle: <code>toggle-all</code></div>
</fieldset>
<fieldset>

View File

@ -72,8 +72,14 @@ ImageExpand =
ImageExpand.expand post
return
ImageExpand.contract post
rect = if Conf['Advance on contract'] and !($.hasClass doc, 'fappeTyme')
post.nodes.root.nextSibling.getBoundingClientRect()
node = post.nodes.root
rect = if Conf['Advance on contract'] then do ->
# FIXME does not work with Quote Threading
while node.nextElementSibling
return post.nodes.root unless node = node.nextElementSibling
continue unless $.hasClass node, 'postContainer'
break if node.offsetHeight > 0 and not $ '.stub', node
node.getBoundingClientRect()
else
post.nodes.root.getBoundingClientRect()
return unless rect.top <= 0 or rect.left <= 0

View File

@ -0,0 +1,42 @@
ImageLoader =
init: ->
return if g.VIEW is 'catalog'
return unless Conf["Image Prefetching"] or Conf["Replace JPG"] or Conf["Replace PNG"] or Conf["Replace GIF"]
Post::callbacks.push
name: 'Image Replace'
cb: @node
return unless Conf['Image Prefetching'] and g.VIEW is 'thread'
prefetch = $.el 'label',
innerHTML: '<input type=checkbox name="prefetch"> Prefetch Images'
@el = prefetch.firstElementChild
$.on @el, 'change', @toggle
$.event 'AddMenuEntry',
type: 'header'
el: prefetch
order: 120
node: ->
return if @isClone or @isHidden or @thread.isHidden or !@file?.isImage
{thumb, URL} = @file
return unless (Conf[string = "Replace #{if (type = (URL.match /\w{3}$/)[0].toUpperCase()) is 'PEG' then 'JPG' else type}"] and !/spoiler/.test thumb.src) or Conf['prefetch']
if @file.isSpoiler
# Revealed spoilers do not have height/width set, this fixes the image's dimensions.
{style} = thumb
style.maxHeight = style.maxWidth = if @isReply then '125px' else '250px'
img = $.el 'img'
if Conf[string]
$.on img, 'load', ->
# Replace the thumbnail once the GIF has finished loading.
thumb.src = URL
img.src = URL
toggle: ->
enabled = Conf['prefetch'] = @checked
if enabled
ImageLoader.node.call post for id, post of g.threads["#{g.BOARD.ID}.#{g.THREADID}"].posts
return

View File

@ -1,21 +0,0 @@
ImageReplace =
init: ->
return if g.VIEW is 'catalog'
Post::callbacks.push
name: 'Image Replace'
cb: @node
node: ->
return if @isClone or @isHidden or @thread.isHidden or !@file?.isImage
{thumb, URL} = @file
return unless Conf["Replace #{if (type = (URL.match /\w{3}$/)[0].toUpperCase()) is 'PEG' then 'JPG' else type}"] and !/spoiler/.test thumb.src
if @file.isSpoiler
# Revealed spoilers do not have height/width set, this fixes auto-gifs dimensions.
{style} = thumb
style.maxHeight = style.maxWidth = if @isReply then '125px' else '250px'
img = $.el 'img'
$.on img, 'load', ->
# Replace the thumbnail once the GIF has finished loading.
thumb.src = URL
img.src = URL