+
+ hideAndShowData = function(activationElements, activeElements, hideElement, showElement) {
+ $(activationElements).click(function() {
+ imageId = $(this).closest(".image").find(".image-id").text();
+ $(hideElement, $("#image-" + imageId)).hide();
+ $(showElement, $("#image-" + imageId)).show();
+ $(document).click(function(event) {
+ if ($(event.target).closest("#image-" + imageId).size() == 0) {
+ $(showElement).hide();
+ $(hideElement).show();
+ }
+ return $(event.target).is("button");
+ });
+ });
+ };
+
+ hideAndShowData(".image-title, .image-description", ".image", ".show-data", ".edit-data");