diff --git a/LICENSE b/LICENSE index e59672896..32c200360 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* appchan x - Version 2.9.7 - 2014-03-20 +* appchan x - Version 2.9.7 - 2014-03-21 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 680febb61..7b44a4daa 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -25,7 +25,7 @@ // ==/UserScript== /* -* appchan x - Version 2.9.7 - 2014-03-20 +* appchan x - Version 2.9.7 - 2014-03-21 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -5497,37 +5497,32 @@ return Post.callbacks.execute(posts); }, buildCatalogViews: function() { - var catalogThreads, i, nodes, thread, _i, _len, _ref; + var catalogThreads, i, nodes, root, size, thread; catalogThreads = []; - _ref = Index.sortedThreads; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - thread = _ref[_i]; + nodes = []; + i = 0; + size = Conf['Index Size'] === 'small' ? 150 : 250; + while (thread = Index.sortedThreads[i++]) { if (!thread.catalogView) { catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread)); } + root = thread.catalogView.nodes.root; + Index.sizeSingleCatalogNode(root, size); + nodes.push(root); } CatalogThread.callbacks.execute(catalogThreads); - nodes = []; - i = 0; - while (thread = Index.sortedThreads[i++]) { - nodes.push(thread.catalogView.nodes.root); - } return nodes; }, - sizeCatalogViews: function(nodes) { - var height, node, ratio, size, thumb, width, _i, _len, _ref; - size = Conf['Index Size'] === 'small' ? 150 : 250; - for (_i = 0, _len = nodes.length; _i < _len; _i++) { - node = nodes[_i]; - thumb = node.firstElementChild; - _ref = thumb.dataset, width = _ref.width, height = _ref.height; - if (!width) { - continue; - } - ratio = size / Math.max(width, height); - thumb.style.width = width * ratio + 'px'; - thumb.style.height = height * ratio + 'px'; + sizeSingleCatalogNode: function(node, size) { + var height, ratio, thumb, width, _ref; + thumb = node.firstElementChild; + _ref = thumb.dataset, width = _ref.width, height = _ref.height; + if (!width) { + return; } + ratio = size / Math.max(width, height); + thumb.style.width = width * ratio + 'px'; + return thumb.style.height = height * ratio + 'px'; }, sort: function() { var i, liveData, sortedThreadIDs, sortedThreads, thread, threadID; @@ -5646,7 +5641,6 @@ break; case 'catalog': nodes = Index.buildCatalogViews(); - Index.sizeCatalogViews(nodes); break; default: nodes = []; diff --git a/builds/crx/script.js b/builds/crx/script.js index d23bddad2..a7b1e4df8 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* appchan x - Version 2.9.7 - 2014-03-20 +* appchan x - Version 2.9.7 - 2014-03-21 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -5555,37 +5555,32 @@ return Post.callbacks.execute(posts); }, buildCatalogViews: function() { - var catalogThreads, i, nodes, thread, _i, _len, _ref; + var catalogThreads, i, nodes, root, size, thread; catalogThreads = []; - _ref = Index.sortedThreads; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - thread = _ref[_i]; + nodes = []; + i = 0; + size = Conf['Index Size'] === 'small' ? 150 : 250; + while (thread = Index.sortedThreads[i++]) { if (!thread.catalogView) { catalogThreads.push(new CatalogThread(Build.catalogThread(thread), thread)); } + root = thread.catalogView.nodes.root; + Index.sizeSingleCatalogNode(root, size); + nodes.push(root); } CatalogThread.callbacks.execute(catalogThreads); - nodes = []; - i = 0; - while (thread = Index.sortedThreads[i++]) { - nodes.push(thread.catalogView.nodes.root); - } return nodes; }, - sizeCatalogViews: function(nodes) { - var height, node, ratio, size, thumb, width, _i, _len, _ref; - size = Conf['Index Size'] === 'small' ? 150 : 250; - for (_i = 0, _len = nodes.length; _i < _len; _i++) { - node = nodes[_i]; - thumb = node.firstElementChild; - _ref = thumb.dataset, width = _ref.width, height = _ref.height; - if (!width) { - continue; - } - ratio = size / Math.max(width, height); - thumb.style.width = width * ratio + 'px'; - thumb.style.height = height * ratio + 'px'; + sizeSingleCatalogNode: function(node, size) { + var height, ratio, thumb, width, _ref; + thumb = node.firstElementChild; + _ref = thumb.dataset, width = _ref.width, height = _ref.height; + if (!width) { + return; } + ratio = size / Math.max(width, height); + thumb.style.width = width * ratio + 'px'; + return thumb.style.height = height * ratio + 'px'; }, sort: function() { var i, liveData, sortedThreadIDs, sortedThreads, thread, threadID; @@ -5704,7 +5699,6 @@ break; case 'catalog': nodes = Index.buildCatalogViews(); - Index.sizeCatalogViews(nodes); break; default: nodes = []; diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 6703f6be5..d38099228 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -128,7 +128,7 @@ Index = id: 'catalogIcon' className: 'a-icon' href: "//boards.4chan.org/#{g.BOARD.ID}/" - + @catalogLink.dataset.indexMode = 'catalog' $.on returnLink, 'click', (e) -> @@ -139,7 +139,7 @@ Index = Navigate.navigate.call @, e $.on @catalogLink, 'click', Navigate.navigate - + Header.addShortcut @catalogLink, true Header.addShortcut returnLink, true @@ -518,7 +518,7 @@ Index = delete Index.pageNum Index.req?.abort() Index.notice?.close() - + {sortedThreads} = Index if sortedThreads board = sortedThreads[0].board.ID @@ -673,26 +673,25 @@ Index = buildCatalogViews: -> catalogThreads = [] - for thread in Index.sortedThreads when !thread.catalogView - catalogThreads.push new CatalogThread Build.catalogThread(thread), thread - CatalogThread.callbacks.execute catalogThreads nodes = [] i = 0 + size = if Conf['Index Size'] is 'small' then 150 else 250 while thread = Index.sortedThreads[i++] - nodes.push thread.catalogView.nodes.root + if !thread.catalogView + catalogThreads.push new CatalogThread Build.catalogThread(thread), thread + {root} = thread.catalogView.nodes + Index.sizeSingleCatalogNode root, size + nodes.push root + CatalogThread.callbacks.execute catalogThreads return nodes - 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 = node.firstElementChild - {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 + sizeSingleCatalogNode: (node, size) -> + thumb = node.firstElementChild + {width, height} = thumb.dataset + return unless width + ratio = size / Math.max width, height + thumb.style.width = width * ratio + 'px' + thumb.style.height = height * ratio + 'px' sort: -> sortedThreads = [] @@ -778,7 +777,6 @@ Index = when 'catalog' nodes = Index.buildCatalogViews() - Index.sizeCatalogViews nodes else nodes = [] @@ -835,7 +833,7 @@ Index = while thread = sortedThreads[i++] filtered.push thread if Index.searchMatch thread, keywords Index.sortedThreads = filtered - + searchMatch: (thread, keywords) -> {info, file} = thread.OP