mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -05:00
Merge pull request #1093 from ZogStriP/soften-the-lightbox-overlay
soften the lightbox overlay
This commit is contained in:
commit
7a16472041
3 changed files with 74 additions and 44 deletions
|
@ -2,24 +2,31 @@
|
||||||
@import "foundation/mixins";
|
@import "foundation/mixins";
|
||||||
|
|
||||||
.lightbox {
|
.lightbox {
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
background: black;
|
display: inline-block;
|
||||||
|
|
||||||
img {
|
&:hover .meta {
|
||||||
|
background: rgba(0, 0, 0, .5);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
@include transition(opacity .2s);
|
@include transition(opacity .5s);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.meta {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
color: white;
|
||||||
|
background: black;
|
||||||
|
opacity: 0;
|
||||||
|
@include transition(opacity .2s);
|
||||||
|
|
||||||
span {
|
span {
|
||||||
color: white;
|
float: left;
|
||||||
position: absolute;
|
}
|
||||||
display: none;
|
|
||||||
font-size: 18px;
|
|
||||||
|
|
||||||
&.filename {
|
.filename {
|
||||||
top: 0;
|
margin: 5px;
|
||||||
left: 0;
|
|
||||||
&:before {
|
&:before {
|
||||||
font-family: "FontAwesome";
|
font-family: "FontAwesome";
|
||||||
content: "\F03E";
|
content: "\F03E";
|
||||||
|
@ -27,31 +34,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&.informations {
|
.informations {
|
||||||
|
margin: 6px;
|
||||||
|
padding-right: 20px;
|
||||||
color: $dark_gray;
|
color: $dark_gray;
|
||||||
top: 20px;
|
|
||||||
left: 0;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.expand {
|
.expand {
|
||||||
top: 0;
|
position: absolute;
|
||||||
right: 0;
|
bottom: 4px;
|
||||||
|
right: 7px;
|
||||||
&:before {
|
&:before {
|
||||||
font-family: "FontAwesome";
|
font-family: "FontAwesome";
|
||||||
content: "\F065";
|
content: "\F065";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@include hover {
|
// this should be removed once all the posts have been rebaked with the new lightboxes overlays
|
||||||
img {
|
.lightbox > span {
|
||||||
opacity: .2;
|
display: none;
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
display: inline;
|
|
||||||
margin: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,21 +126,28 @@ class CookedPostProcessor
|
||||||
|
|
||||||
# not a hyperlink so we can apply
|
# not a hyperlink so we can apply
|
||||||
img['src'] = upload.thumbnail_url if (upload && upload.thumbnail_url.present?)
|
img['src'] = upload.thumbnail_url if (upload && upload.thumbnail_url.present?)
|
||||||
|
# first, create a div to hold our lightbox
|
||||||
|
lightbox = Nokogiri::XML::Node.new "div", @doc
|
||||||
|
img.add_next_sibling lightbox
|
||||||
|
lightbox.add_child img
|
||||||
|
# then, the link to our larger image
|
||||||
a = Nokogiri::XML::Node.new "a", @doc
|
a = Nokogiri::XML::Node.new "a", @doc
|
||||||
img.add_next_sibling(a)
|
img.add_next_sibling(a)
|
||||||
a["href"] = src
|
a["href"] = src
|
||||||
a["class"] = "lightbox"
|
a["class"] = "lightbox"
|
||||||
a.add_child(img)
|
a.add_child(img)
|
||||||
|
# then, some overlay informations
|
||||||
|
meta = Nokogiri::XML::Node.new "div", @doc
|
||||||
|
meta["class"] = "meta"
|
||||||
|
img.add_next_sibling meta
|
||||||
|
|
||||||
# some overlay informations
|
|
||||||
filename = upload ? upload.original_filename : File.basename(src)
|
filename = upload ? upload.original_filename : File.basename(src)
|
||||||
informations = "#{original_width}x#{original_height}"
|
informations = "#{original_width}x#{original_height}"
|
||||||
informations << " | #{number_to_human_size(upload.filesize)}" if upload
|
informations << " | #{number_to_human_size(upload.filesize)}" if upload
|
||||||
|
|
||||||
a.add_child create_span_node("filename", filename)
|
meta.add_child create_span_node("filename", filename)
|
||||||
a.add_child create_span_node("informations", informations)
|
meta.add_child create_span_node("informations", informations)
|
||||||
a.add_child create_span_node("expand")
|
meta.add_child create_span_node("expand")
|
||||||
# TODO: download
|
# TODO: download
|
||||||
# TODO: views-count
|
# TODO: views-count
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,28 @@ describe CookedPostProcessor do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a large image" do
|
||||||
|
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
let(:topic) { Fabricate(:topic, user: user) }
|
||||||
|
let(:post) { Fabricate.build(:post_with_uploads, topic: topic, user: user) }
|
||||||
|
let(:processor) { CookedPostProcessor.new(post) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
FastImage.stubs(:size).returns([1000, 1000])
|
||||||
|
processor.post_process_images
|
||||||
|
end
|
||||||
|
|
||||||
|
it "generates overlay information" do
|
||||||
|
processor.html.should =~ /class="lightbox"/
|
||||||
|
processor.html.should =~ /class="meta"/
|
||||||
|
processor.html.should =~ /class="filename"/
|
||||||
|
processor.html.should =~ /class="informations"/
|
||||||
|
processor.html.should =~ /class="expand"/
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'link convertor' do
|
context 'link convertor' do
|
||||||
|
|
Loading…
Reference in a new issue