Skip to content

Commit

Permalink
Expando: Do not float
Browse files Browse the repository at this point in the history
Expandos got a css rule added to them to support the NSFW interstitial
flow, but this caused some unintended bugs with subreddit CSS.  The
positioning of the interstitial's button on the media preview overlay
is dependent on the floating, so this moves the application of the
float rule to a child element on media previews only so the expando
element itself can remain unfloated.
  • Loading branch information
Matt Lee committed Oct 7, 2016
1 parent 7770ad7 commit 7d3217a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
21 changes: 14 additions & 7 deletions r2/r2/public/static/css/reddit.less
Original file line number Diff line number Diff line change
Expand Up @@ -5027,9 +5027,12 @@ ul.tabmenu.formtab {
/******* embed stuff ******/
.expando {
clear: left;
float: left;
margin: 5px 0 5px 0;
position: relative;

.form-bar {
float: left;
}
}

.link.over18 .expando-uninitialized {
Expand All @@ -5039,10 +5042,6 @@ ul.tabmenu.formtab {
}
}

.link.self .expando {
float: none;
}

.expando-content {
display: none;
}
Expand Down Expand Up @@ -5125,11 +5124,12 @@ ul.tabmenu.formtab {
}

.form-bar {
position: relative;
background: lighten(@color-pale-grey, 10%);
border: 1px solid @color-pale-grey;
padding: unit(@margin-x-small, px) unit(@margin-small, px);
clear: left;
margin-top: unit(@margin-small, px);
padding: unit(@margin-x-small, px) unit(@margin-small, px);
position: relative;

.md {
float: left;
Expand All @@ -5142,6 +5142,13 @@ ul.tabmenu.formtab {
}

.media-preview {
overflow: auto;
position: relative;

.media-preview-content {
float: left;
}

img {
width: 100%;
height: auto;
Expand Down
8 changes: 4 additions & 4 deletions r2/r2/public/static/js/expando/nsfwflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@
}

var $expando = expando.$expando;
var $media = $expando.find('.media-embed');
var $media = $expando.children();
var width = $media.width();
var height = $media.height();
// if it's a `.media-preview`, interstial is shown _over_ the blurred image
var isOverlay = !$media.length;
var isOverlay = $media.hasClass('media-preview');
var isWarning = !_state.noProfanity;

nsfwFlow = new ExpandoNSFWFlow({
Expand All @@ -262,9 +262,9 @@
expando.listenTo(nsfwFlow, 'show', destroyNsfwFlow);

if (nsfwFlow.isOverlay) {
expando.$expando.append(nsfwFlow.el);
$media.append(nsfwFlow.el);
} else {
expando.$expando.html(nsfwFlow.el);
$expando.html(nsfwFlow.el);
}

expando.showExpandoContent();
Expand Down
4 changes: 3 additions & 1 deletion r2/r2/templates/mediapreview.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
<div class="media-preview"
id="media-preview-${thing.id36}"
style="max-width: ${thing.width}px">
${unsafe(thing.media_content)}
<div class="media-preview-content">
${unsafe(thing.media_content)}
</div>
</div>

0 comments on commit 7d3217a

Please sign in to comment.