Skip to content

Commit

Permalink
Image link changed to click handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
setnes committed Dec 7, 2015
1 parent b326073 commit 7c3e23c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions js/galleryimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
' <span class="image-label">' +
' <span class="title">{{label}}</span>' +
' </span>' +
' <a class="image" href="{{targetPath}}" data-path="{{path}}"></a>' +
' <a class="image" data-path="{{path}}"></a>' +
'</div>';

/**
Expand Down Expand Up @@ -97,12 +97,10 @@
image._template = Handlebars.compile(TEMPLATE);
}
var newWidth = Math.round(targetHeight * image.thumbnail.ratio);
var url = image._getLink();
var template = image._template({
targetHeight: targetHeight,
targetWidth: newWidth,
label: OC.basename(image.path),
targetPath: url,
path: image.path
});
image.domDef = $(template);
Expand All @@ -115,6 +113,8 @@
img.alt = encodeURI(image.path);
image.domDef.children('a').append(img);

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

return image.domDef;
});
}
Expand Down Expand Up @@ -156,6 +156,17 @@
}

return url;
},

/**
* Opens the image.
*
* @param event
* @private
*/
_openImage: function (event) {
event.stopPropagation();
location.href = this._getLink();
}
};

Expand Down

0 comments on commit 7c3e23c

Please sign in to comment.