From 90fb2057a93e99bc0c80769da8780e7a9285e715 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Tue, 14 Feb 2012 18:50:49 +0100 Subject: [PATCH] Send resize updates and handle resize server events (closes: #1a4507) --- public/javascripts/plemp-ui.js | 16 +++++++++++++--- public/stylesheets/style.css | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/public/javascripts/plemp-ui.js b/public/javascripts/plemp-ui.js index b8ad916..e472537 100644 --- a/public/javascripts/plemp-ui.js +++ b/public/javascripts/plemp-ui.js @@ -181,7 +181,12 @@ function raise_draggable(event) { // Update the position of a draggable on the server. function update_drag_info(event, ui) { - $.post("draggables/" + ui.helper.context.id, ui.position, "json"); + if (ui.size) { + $.post("draggables/" + ui.helper.context.id, ui.size, "json"); + } + else { + $.post("draggables/" + ui.helper.context.id, ui.position, "json"); + } } // Poll for server events via AJAX. @@ -194,10 +199,15 @@ function poll_server(timestamp) { // Handle server events. function handle_server_event(event) { + var drag = $("#draggables #" + event.data.id); switch(event.type) { case "reposition": - $("#draggables #" + event.data.id).animate({ top: event.data.top, - left: event.data.left }); + drag.animate({ top: event.data.top, left: event.data.left }); + break; + case "resize": + drag.animate({ width: event.data.width, height: event.data.height }) + // Fix the height of the pre. FIXME: can this be improved? + .find("pre").animate({ height: event.data.height - 80 }); break; case "title update": $("#draggables #" + event.data.id + " h2 .title").text(event.data.title); diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 162a100..4b821bf 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -118,3 +118,5 @@ pre { /* JQuery UI CSS overrides */ .ui-widget { font-size: 100%; } + +.ui-resizable-handle { z-index: auto !important; }