From b23c0f7ae4e3913ba42b939f9c388920a3520664 Mon Sep 17 00:00:00 2001 From: Pablo Cuadrado Date: Sun, 11 Jan 2015 10:35:13 -0300 Subject: [PATCH] ensuring that the oembed element has the same size of the thumb --- app/assets/javascripts/app/views/content_view.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/assets/javascripts/app/views/content_view.js b/app/assets/javascripts/app/views/content_view.js index a7cbc8f63..73c86c24b 100644 --- a/app/assets/javascripts/app/views/content_view.js +++ b/app/assets/javascripts/app/views/content_view.js @@ -108,9 +108,19 @@ app.views.OEmbed = app.views.Base.extend({ showOembedContent : function (evt) { if( $(evt.target).is('a') ) return; + var clickedThumb = false; + if ($(evt.target).hasClass(".thumb")) { + clickedThumb = $(evt.target); + } else { + clickedThumb = $(evt.target).parent(".thumb"); + } var insertHTML = $(app.helpers.oEmbed.html(this.model.get("o_embed_cache"))); var paramSeparator = ( /\?/.test(insertHTML.attr("src")) ) ? "&" : "?"; insertHTML.attr("src", insertHTML.attr("src") + paramSeparator + "autoplay=1&wmode=opaque"); + if (clickedThumb) { + insertHTML.attr("width", clickedThumb.width()); + insertHTML.attr("height", clickedThumb.height()); + } this.$el.html(insertHTML); } });