+
+ /* ID of the image currently being edited. */
+ editingImageId = null;
+
+ /**
+ * Shows the form for editing an image.
+ *
+ * @param imageId The ID of the image to edit.
+ */
+ function editImage(imageId) {
+ if (editingImageId != imageId) {
+ cancelEditing();
+ } else {
+ return;
+ }
+ $(".show-data", "#image-" + imageId).hide();
+ $(".edit-data", "#image-" + imageId).show();
+ $(document).bind("click.sone", function(event) {
+ console.log("event: " + event);
+ console.log("closest: " + $(event.target).closest("#image-" + imageId));
+ if ($(event.target).closest("#image-" + imageId).size() == 0) {
+ cancelEditing();
+ }
+ });
+ }
+
+ /**
+ * Cancels all image editing.
+ */
+ function cancelEditing() {
+ $(".show-data").show();
+ $(".edit-data").hide();
+ $("form.edit-image").each(function() {
+ this.reset();
+ });
+ $(document).unbind("click.sone");
+ editingImageId = null;
+ }
+