From 0b6d9c6ba066f3ff318170b7d381a141741fb7c3 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 17 Jan 2012 14:27:52 +0100 Subject: [PATCH] Raise a draggable on click --- public/javascripts/plemp-ui.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/javascripts/plemp-ui.js b/public/javascripts/plemp-ui.js index 1bd674f..746d8c8 100644 --- a/public/javascripts/plemp-ui.js +++ b/public/javascripts/plemp-ui.js @@ -17,6 +17,7 @@ $(document).ready(function() { cancel: "audio, video", distance: 10, stop: update_drag_info }) + .click(raise_draggable) .hover(function() { $(this).find(".comments").fadeIn(); }, function() { $(this).find(".comments").fadeOut(); }); this.find(".delete").click({ id: this.attr("id"), @@ -73,6 +74,16 @@ function delete_draggable(event) { }, "json"); } +// Raise the draggable to the foreground. +function raise_draggable(event) { + var max = 0; + $(".draggable").each(function() { + var cur = parseFloat($(this).css("z-index")); + max = cur > max ? cur : max; + }); + $(this).css("z-index", max + 1); +} + // Update the position of a draggable on the server. function update_drag_info(event, ui) { $.post("draggables/" + ui.helper.context.id, ui.position, "json");