Merge pull request #5102 from Faldrian/feature/4474-fix_lightbox_thumbnails
Feature/4474 fix lightbox thumbnails
This commit is contained in:
commit
bd388d61e7
6 changed files with 80 additions and 7 deletions
|
|
@ -22,6 +22,7 @@
|
||||||
* Port admin pages to bootstrap, polish user search results, allow accounts to be closed from the backend [#5046](https://github.com/diaspora/diaspora/pull/5046)
|
* Port admin pages to bootstrap, polish user search results, allow accounts to be closed from the backend [#5046](https://github.com/diaspora/diaspora/pull/5046)
|
||||||
* Reference Salmon endpoint in Webfinger XRD to aid discovery by alternative implementations [#5062](https://github.com/diaspora/diaspora/pull/5062)
|
* Reference Salmon endpoint in Webfinger XRD to aid discovery by alternative implementations [#5062](https://github.com/diaspora/diaspora/pull/5062)
|
||||||
* Change minimal birth year for the birthday field to 1910 [#5083](https://github.com/diaspora/diaspora/pull/5083)
|
* Change minimal birth year for the birthday field to 1910 [#5083](https://github.com/diaspora/diaspora/pull/5083)
|
||||||
|
* Add scrolling thumbnail switcher in the lightbox [#5102](https://github.com/diaspora/diaspora/pull/5102)
|
||||||
|
|
||||||
# 0.4.0.1
|
# 0.4.0.1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ app.views.Content = app.views.Base.extend({
|
||||||
smallPhotos : function() {
|
smallPhotos : function() {
|
||||||
var photos = this.model.get("photos")
|
var photos = this.model.get("photos")
|
||||||
if(!photos || photos.length < 2) { return }
|
if(!photos || photos.length < 2) { return }
|
||||||
return photos
|
photos.splice(0, 1); // remove first photo as it is already shown as largePhoto
|
||||||
|
return photos;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,12 @@ jQuery.fn.center = (function() {
|
||||||
this.subscribe("widget/ready", function(evt) {
|
this.subscribe("widget/ready", function(evt) {
|
||||||
$.extend(self, {
|
$.extend(self, {
|
||||||
lightbox: $("#lightbox"),
|
lightbox: $("#lightbox"),
|
||||||
|
navigation: $("#lightbox-navigation"),
|
||||||
imageset: $("#lightbox-imageset"),
|
imageset: $("#lightbox-imageset"),
|
||||||
backdrop: $("#lightbox-backdrop"),
|
backdrop: $("#lightbox-backdrop"),
|
||||||
closelink: $("#lightbox-close-link"),
|
closelink: $("#lightbox-close-link"),
|
||||||
|
scrollleft: $("#lightbox-scrollleft"),
|
||||||
|
scrollright: $("#lightbox-scrollright"),
|
||||||
image: $("#lightbox-image"),
|
image: $("#lightbox-image"),
|
||||||
body: $(document.body),
|
body: $(document.body),
|
||||||
window: $(window)
|
window: $(window)
|
||||||
|
|
@ -47,7 +50,6 @@ jQuery.fn.center = (function() {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
self.resetLightbox();
|
self.resetLightbox();
|
||||||
});
|
});
|
||||||
self.backdrop.click(self.resetLightbox);
|
|
||||||
self.lightbox.click(self.resetLightbox);
|
self.lightbox.click(self.resetLightbox);
|
||||||
|
|
||||||
self.backdrop.click(function(evt) {
|
self.backdrop.click(function(evt) {
|
||||||
|
|
@ -55,6 +57,20 @@ jQuery.fn.center = (function() {
|
||||||
self.resetLightbox();
|
self.resetLightbox();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.scrollleft.click(function(evt){
|
||||||
|
evt.preventDefault();
|
||||||
|
evt.stopPropagation();
|
||||||
|
self.navigation.animate({scrollLeft: (self.navigation.scrollLeft()
|
||||||
|
- (self.window.width() - 150))}, 200, 'swing');
|
||||||
|
});
|
||||||
|
|
||||||
|
self.scrollright.click(function(evt){
|
||||||
|
evt.preventDefault();
|
||||||
|
evt.stopPropagation();
|
||||||
|
self.navigation.animate({scrollLeft: (self.navigation.scrollLeft()
|
||||||
|
+ (self.window.width() - 150))}, 200, 'swing');
|
||||||
|
});
|
||||||
|
|
||||||
self.body.keydown(function(evt) {
|
self.body.keydown(function(evt) {
|
||||||
var imageThumb = self.imageset.find("img.selected");
|
var imageThumb = self.imageset.find("img.selected");
|
||||||
|
|
||||||
|
|
@ -122,6 +138,8 @@ jQuery.fn.center = (function() {
|
||||||
self
|
self
|
||||||
.selectImage(imageThumb)
|
.selectImage(imageThumb)
|
||||||
.revealLightbox();
|
.revealLightbox();
|
||||||
|
|
||||||
|
self.scrollToThumbnail(imageThumb);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.imagesetImageClicked = function(evt) {
|
this.imagesetImageClicked = function(evt) {
|
||||||
|
|
@ -131,11 +149,18 @@ jQuery.fn.center = (function() {
|
||||||
self.selectImage($(this));
|
self.selectImage($(this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.scrollToThumbnail = function(imageThumb) {
|
||||||
|
self.navigation.animate({scrollLeft: (self.navigation.scrollLeft()
|
||||||
|
+ imageThumb.offset().left +35 - (self.window.width() / 2))}, 200, 'swing');
|
||||||
|
}
|
||||||
|
|
||||||
this.selectImage = function(imageThumb) {
|
this.selectImage = function(imageThumb) {
|
||||||
$(".selected", self.imageset).removeClass("selected");
|
$(".selected", self.imageset).removeClass("selected");
|
||||||
imageThumb.addClass("selected");
|
imageThumb.addClass("selected");
|
||||||
self.image.attr("src", imageThumb.attr("data-full-photo"));
|
self.image.attr("src", imageThumb.attr("data-full-photo"));
|
||||||
|
|
||||||
|
self.scrollToThumbnail(imageThumb);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,16 +88,44 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#lightbox-imageset{
|
#lightbox-navigation{
|
||||||
z-index: 1004;
|
z-index: 1004;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
display: none;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
background-color: rgba(0,0,0,0.4);
|
background-color: rgba(0,0,0,0.4);
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
#lightbox-scrollleft, #lightbox-scrollright{
|
||||||
|
z-index: 1005;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #0f0f0f;
|
||||||
|
display: inline-block;
|
||||||
|
height: 70px;
|
||||||
|
width: 30px;
|
||||||
|
position: fixed;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#lightbox-scrollleft{
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#lightbox-scrollright{
|
||||||
|
right: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#lightbox-imageset{
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: bottom;
|
||||||
|
padding-left: 50px;
|
||||||
|
padding-right: 50px;
|
||||||
|
|
||||||
img{
|
img{
|
||||||
@include transition(opacity, 0.2s);
|
@include transition(opacity, 0.2s);
|
||||||
|
|
@ -120,8 +148,7 @@
|
||||||
|
|
||||||
body.lightboxed{
|
body.lightboxed{
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
#lightbox-backdrop,
|
#lightbox-backdrop{
|
||||||
#lightbox-imageset{
|
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,11 @@
|
||||||
<div id="lightbox-content">
|
<div id="lightbox-content">
|
||||||
<a href="#" id="lightbox-close-link">[x] {{t "header.close"}}</a>
|
<a href="#" id="lightbox-close-link">[x] {{t "header.close"}}</a>
|
||||||
<img id="lightbox-image">
|
<img id="lightbox-image">
|
||||||
<div id="lightbox-imageset"></div>
|
<div id="lightbox-navigation">
|
||||||
|
<div id="lightbox-scrollleft">«</div>
|
||||||
|
<div id="lightbox-imageset"></div>
|
||||||
|
<div id="lightbox-scrollright">»</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="lightbox-backdrop"></div>
|
<div id="lightbox-backdrop"></div>
|
||||||
|
|
|
||||||
15
spec/javascripts/app/views/content_view_spec.js
Normal file
15
spec/javascripts/app/views/content_view_spec.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
describe("app.views.Content", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
this.post = new app.models.StatusMessage();
|
||||||
|
this.view = new app.views.Content({model : this.post})
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("rendering", function(){
|
||||||
|
|
||||||
|
it("should return all but the first photo from the post", function() {
|
||||||
|
this.post.set({photos : [1,2]}) // set 2 Photos
|
||||||
|
expect(this.view.smallPhotos().length).toEqual(1)
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue