diff --git a/TODO b/TODO index e5661e88..30d04ae8 100644 --- a/TODO +++ b/TODO @@ -2,9 +2,6 @@ This is transient file that lists functionalities to be implemented before first major release. everything related to posts: - - uploads - - fix thumbnails for files that are neither youtube or images - - post list - add style for hovered and focused element - fav count diff --git a/public_html/js/Presenters/PostUploadPresenter.js b/public_html/js/Presenters/PostUploadPresenter.js index cd78c677..d5432efb 100644 --- a/public_html/js/Presenters/PostUploadPresenter.js +++ b/public_html/js/Presenters/PostUploadPresenter.js @@ -124,16 +124,17 @@ App.Presenters.PostUploadPresenter = function( function addPostFromUrl(url) { var post = _.extend({}, getDefaultPost(), {url: url, source: url, fileName: url}); + postAdded(post); var matches = url.match(/watch.*?=([a-zA-Z0-9_-]+)/); if (matches) { var youtubeThumbnailUrl = 'http://img.youtube.com/vi/' + matches[1] + '/mqdefault.jpg'; post.thumbnail = youtubeThumbnailUrl; - } else { + postThumbnailLoaded(post); + } else if (url.match(/image|img|jpg|png|gif/i)) { post.thumbnail = url; + postThumbnailLoaded(post); } - postAdded(post); - postThumbnailLoaded(post); } function postAdded(post) { @@ -184,13 +185,19 @@ App.Presenters.PostUploadPresenter = function( } function updatePostThumbnailInForm(post) { - $el.find('.form-slider .thumbnail img')[0].setAttribute('src', post.thumbnail); + if (post.thumbnail === null) { + $el.find('.form-slider .thumbnail img').hide(); + } else { + $el.find('.form-slider .thumbnail img').show()[0].setAttribute('src', post.thumbnail); + } } function updatePostThumbnailInTable(post) { var $row = post.$tableRow; + if (post.thumbnail === null) { + $row.find('img')[0].setAttribute('src', util.transparentPixel()); //huge speedup thanks to this condition - if ($row.find('img').attr('src') !== post.thumbnail && post.thumbnail !== null) { + } else if ($row.find('img').attr('src') !== post.thumbnail) { $row.find('img')[0].setAttribute('src', post.thumbnail); } } @@ -409,7 +416,7 @@ App.Presenters.PostUploadPresenter = function( function postTableRowImageHovered(e) { var $img = jQuery(this); - if ($img.attr('src')) { + if ($img.parents('tr').data('post').thumbnail) { var $lightbox = jQuery('#lightbox'); $lightbox.find('img').attr('src', $img.attr('src')); $lightbox diff --git a/public_html/js/Util.js b/public_html/js/Util.js index 2f71dfcd..b958cdf2 100644 --- a/public_html/js/Util.js +++ b/public_html/js/Util.js @@ -5,6 +5,10 @@ App.Util = function(_, jQuery, promise) { var templateCache = {}; var exitConfirmationEnabled = false; + function transparentPixel() { + return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; + } + function enableExitConfirmation() { exitConfirmationEnabled = true; jQuery(window).bind('beforeunload', function(e) { @@ -156,6 +160,7 @@ App.Util = function(_, jQuery, promise) { enableExitConfirmation: enableExitConfirmation, disableExitConfirmation: disableExitConfirmation, isExitConfirmationEnabled: isExitConfirmationEnabled, + transparentPixel: transparentPixel, }; };