Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click handlers for image and album thumbnails. #471

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,16 @@ div.crumb.last a {

#gallery .item-container .album-label,
#gallery .item-container .image-label {
background: rgba(0, 0, 0, 0.4);
position: absolute;
width: 100%;
height: 100%;
transition: opacity 200ms linear;
opacity: 1;
background-image: linear-gradient(rgba(0,0,0,0) 65%,rgba(0,0,0,0.35));
}

#gallery .item-container .image-label .title {
#gallery .item-container .image-label .title,
#gallery .item-container .album-label .title {
display: inline-block;
color: #fff;
text-align: center;
Expand All @@ -152,9 +158,13 @@ div.crumb.last a {
overflow-x: hidden;
white-space: nowrap;
text-overflow: ellipsis;
left: 0;
bottom: 10px;
position: absolute;
}

#gallery .item-container .image-label .title:hover {
#gallery .item-container .image-label .title:hover,
#gallery .item-container .album-label .title:hover {
overflow: visible;
white-space: normal;
}
Expand Down Expand Up @@ -182,7 +192,7 @@ div.crumb.last a {
opacity: .5;
}

#gallery a.image > img {
#gallery .image-container .image > img {
max-height: 200px;
}

Expand Down
25 changes: 14 additions & 11 deletions js/galleryalbum.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"use strict";

var TEMPLATE =
'<div class="item-container album-container" ' +
'<a class="item-container album-container album" ' +
'style="width: {{targetWidth}}px; height: {{targetHeight}}px;" ' +
'data-width="{{targetWidth}}" data-height="{{targetHeight}}">' +
'data-width="{{targetWidth}}" data-height="{{targetHeight}}"' +
'href="{{targetPath}}">' +
' <span class="album-label">' +
' <span class="title">{{label}}</span>' +
' </span>' +
' <div class="album-loader loading"></div>' +
' <span class="album-label">{{label}}</span>' +
' <a class="album" href="{{targetPath}}"></a>' +
'</div>';
'</a>';


/**
* Creates a new album object to store information about an album
Expand Down Expand Up @@ -59,10 +62,9 @@
album.domDef = $(template);
album.loader = album.domDef.children('.album-loader');
album.loader.hide();
album.domDef.click(album._showLoader.bind(album));
album.domDef.click(album._openAlbum.bind(album));

album._fillSubAlbum(targetHeight);

return album.domDef;
});
},
Expand Down Expand Up @@ -126,13 +128,14 @@
},

/**
* Shows a loading animation
* Call when the album is clicked on.
*
* @param event
* @private
*/
_showLoader: function (event) {
_openAlbum: function (event) {
event.stopPropagation();
// show loading animation
this.loader.show();
},

Expand Down Expand Up @@ -222,7 +225,7 @@
// At least one thumbnail could not be retrieved
if (fail) {
// Clean up the album
a.children().remove();
a.children('div.cropped').remove();
// Send back the list of images which have thumbnails
def.reject(validImages);
}
Expand All @@ -244,7 +247,7 @@
*/
_fillSubAlbum: function (targetHeight) {
var album = this;
var a = this.domDef.children('a');
var a = this.domDef;

if (this.images.length >= 1) {
this._getFourImages(this.images, targetHeight, a).fail(function (validImages) {
Expand Down
26 changes: 20 additions & 6 deletions js/galleryimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
"use strict";

var TEMPLATE =
'<div class="item-container image-container" ' +
'<a class="item-container image-container" ' +
'style="width: {{targetWidth}}px; height: {{targetHeight}}px;" ' +
'data-width="{{targetWidth}}" data-height="{{targetHeight}}">' +
'data-width="{{targetWidth}}" data-height="{{targetHeight}}"' +
'href="{{targetPath}}">' +
' <span class="image-label">' +
' <span class="title">{{label}}</span>' +
' </span>' +
' <a class="image" href="{{targetPath}}" data-path="{{path}}"></a>' +
'</div>';
' <span class="image" data-path="{{path}}"></span>' +
'</a>';

/**
* Creates a new image object to store information about a media file
Expand Down Expand Up @@ -113,7 +114,9 @@
'height': targetHeight
});
img.alt = encodeURI(image.path);
image.domDef.children('a').append(img);
image.domDef.find('.image').append(img);

image.domDef.click(image._openImage.bind(image));

return image.domDef;
});
Expand All @@ -127,7 +130,7 @@
* @private
*/
_addLabel: function () {
var imageLabel = this.domDef.children('.image-label');
var imageLabel = this.domDef.find('.image-label');
this.domDef.hover(function () {
imageLabel.slideToggle(OC.menuSpeed);
}, function () {
Expand Down Expand Up @@ -156,6 +159,17 @@
}

return url;
},

/**
* Call when the image is clicked on.
*
* @param event
* @private
*/
_openImage: function (event) {
event.stopPropagation();
// click function for future use.
}
};

Expand Down