Add Image Size.

This commit is contained in:
Mayhem 2014-02-11 09:23:39 +01:00
parent 13e18f6c6c
commit 871cdfe0c9
6 changed files with 47 additions and 6 deletions

View File

@ -1,3 +1,5 @@
- Added `Image Size` setting for the catalog.
### 3.17.1 - *2014-02-10* ### 3.17.1 - *2014-02-10*
- `Index Mode` and `Index Sort` have been moved out of the header's menu into the index page. - `Index Mode` and `Index Sort` have been moved out of the header's menu into the index page.

View File

@ -415,12 +415,18 @@ a[href="javascript:;"] {
text-align: left; text-align: left;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
width: 165px;
margin: 0 2px 5px; margin: 0 2px 5px;
max-height: 320px;
word-break: break-word; word-break: break-word;
vertical-align: top; vertical-align: top;
} }
.catalog-small .catalog-thread {
width: 165px;
max-height: 320px;
}
.catalog-large .catalog-thread {
width: 270px;
max-height: 410px;
}
.thumb { .thumb {
flex-shrink: 0; flex-shrink: 0;
position: relative; position: relative;

View File

@ -17,3 +17,8 @@
<option value="replycount">Reply count</option> <option value="replycount">Reply count</option>
<option value="filecount">File count</option> <option value="filecount">File count</option>
</select> </select>
<select id="index-size" name="Index Size">
<option disabled>Image Size</option>
<option value="small">Small</option>
<option value="large">Large</option>
</select>

View File

@ -294,9 +294,8 @@ Build =
$.addClass thumb, 'deleted-file' $.addClass thumb, 'deleted-file'
else if thread.OP.file else if thread.OP.file
src = thread.OP.file.thumbURL src = thread.OP.file.thumbURL
max = Math.max data.tn_w, data.tn_h thumb.dataset.width = data.tn_w
thumb.style.width = data.tn_w * 150 / max + 'px' thumb.dataset.height = data.tn_h
thumb.style.height = data.tn_h * 150 / max + 'px'
else else
src = "#{staticPath}nofile.png" src = "#{staticPath}nofile.png"
$.addClass thumb, 'no-file' $.addClass thumb, 'no-file'

View File

@ -141,6 +141,7 @@ Config =
'Index Mode': 'paged' 'Index Mode': 'paged'
'Previous Index Mode': 'paged' 'Previous Index Mode': 'paged'
'Index Sort': 'bump' 'Index Sort': 'bump'
'Index Size': 'small'
'Threads per Page': 0 'Threads per Page': 0
'Show Replies': true 'Show Replies': true
'Anchor Hidden Threads': true 'Anchor Hidden Threads': true

View File

@ -70,14 +70,16 @@ Index =
@hideLabel = $ '#hidden-label', @navLinks @hideLabel = $ '#hidden-label', @navLinks
@selectMode = $ '#index-mode', @navLinks @selectMode = $ '#index-mode', @navLinks
@selectSort = $ '#index-sort', @navLinks @selectSort = $ '#index-sort', @navLinks
@selectSize = $ '#index-size', @navLinks
$.on @searchInput, 'input', @onSearchInput $.on @searchInput, 'input', @onSearchInput
$.on $('#index-search-clear', @navLinks), 'click', @clearSearch $.on $('#index-search-clear', @navLinks), 'click', @clearSearch
$.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads $.on $('#hidden-toggle a', @navLinks), 'click', @cb.toggleHiddenThreads
for select in [@selectMode, @selectSort] for select in [@selectMode, @selectSort, @selectSize]
select.value = Conf[select.name] select.value = Conf[select.name]
$.on select, 'change', $.cb.value $.on select, 'change', $.cb.value
$.on @selectMode, 'change', @cb.mode $.on @selectMode, 'change', @cb.mode
$.on @selectSort, 'change', @cb.sort $.on @selectSort, 'change', @cb.sort
$.on @selectSize, 'change', @cb.size
@root = $.el 'div', className: 'board' @root = $.el 'div', className: 'board'
@pagelist = $.el 'div', @pagelist = $.el 'div',
@ -87,7 +89,10 @@ Index =
@currentPage = @getCurrentPage() @currentPage = @getCurrentPage()
$.on window, 'popstate', @cb.popstate $.on window, 'popstate', @cb.popstate
$.on @pagelist, 'click', @cb.pageNav $.on @pagelist, 'click', @cb.pageNav
@cb.toggleCatalogMode() @cb.toggleCatalogMode()
@cb.size()
$.asap (-> $('.board', doc) or d.readyState isnt 'loading'), -> $.asap (-> $('.board', doc) or d.readyState isnt 'loading'), ->
board = $ '.board' board = $ '.board'
$.replace board, Index.root $.replace board, Index.root
@ -230,6 +235,17 @@ Index =
sort: -> sort: ->
Index.sort() Index.sort()
Index.buildIndex() Index.buildIndex()
size: (e) ->
if Conf['Index Mode'] isnt 'catalog'
$.rmClass Index.root, 'catalog-small'
$.rmClass Index.root, 'catalog-large'
else if Conf['Index Size'] is 'small'
$.addClass Index.root, 'catalog-small'
$.rmClass Index.root, 'catalog-large'
else
$.addClass Index.root, 'catalog-large'
$.rmClass Index.root, 'catalog-small'
Index.buildIndex() if e
threadsNum: -> threadsNum: ->
return unless Conf['Index Mode'] is 'paged' return unless Conf['Index Mode'] is 'paged'
Index.buildPagelist() Index.buildPagelist()
@ -498,6 +514,17 @@ Index =
catalogThreads.push new CatalogThread Build.catalogThread(thread), thread catalogThreads.push new CatalogThread Build.catalogThread(thread), thread
Main.callbackNodes CatalogThread, catalogThreads Main.callbackNodes CatalogThread, catalogThreads
threads.map (thread) -> thread.catalogView.nodes.root threads.map (thread) -> thread.catalogView.nodes.root
sizeCatalogViews: (nodes) ->
# XXX When browsers support CSS3 attr(), use it instead.
size = if Conf['Index Size'] is 'small' then 150 else 250
for node in nodes
thumb = $ '.thumb', node
{width, height} = thumb.dataset
continue unless width
ratio = size / Math.max width, height
thumb.style.width = width * ratio + 'px'
thumb.style.height = height * ratio + 'px'
return
sort: -> sort: ->
switch Conf['Index Sort'] switch Conf['Index Sort']
when 'bump' when 'bump'
@ -539,6 +566,7 @@ Index =
nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)] nodes = Index.sortedNodes[nodesPerPage * pageNum ... nodesPerPage * (pageNum + 1)]
when 'catalog' when 'catalog'
nodes = Index.buildCatalogViews() nodes = Index.buildCatalogViews()
Index.sizeCatalogViews nodes
else else
nodes = Index.sortedNodes nodes = Index.sortedNodes
$.rmAll Index.root $.rmAll Index.root