From 4c63e00e826fa42e5abda180bac1d7a626030c14 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Sat, 11 Feb 2012 12:32:36 +0100 Subject: [PATCH] Handle the download button by calling the download controller; add some style --- public/javascripts/plemp-ui.js | 10 ++++++++-- public/stylesheets/style.css | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/public/javascripts/plemp-ui.js b/public/javascripts/plemp-ui.js index 8995b77..7ea5d4c 100644 --- a/public/javascripts/plemp-ui.js +++ b/public/javascripts/plemp-ui.js @@ -21,8 +21,8 @@ $(document).ready(function() { .hover(function() { $(this).find(".comments").fadeIn(); }, function() { $(this).find(".comments").fadeOut(); }); this.find(".delete").click({ id: this.attr("id"), - element: this }, - delete_draggable); + element: this }, delete_draggable); + this.find(".download").click({ id: this.attr("id") }, download_draggable); this.find(".title").editable('draggables/' + this.attr("id"), { tooltip: "Click to edit…", name: 'title', @@ -101,6 +101,12 @@ function delete_draggable(event) { }, "json"); } +// Download a draggable from the server. +function download_draggable(event) { + event.preventDefault(); + window.open("download/" + event.data.id); +} + // Raise the draggable to the foreground. function raise_draggable(event) { var max = 0; diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index 8e891ff..e496eac 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -108,6 +108,7 @@ pre { font-weight: bold; } +.draggable h2 .download, .draggable h2 .delete { width: auto; float: right; @@ -116,7 +117,12 @@ pre { color: #ccc; } -.draggable h2 .delete:hover { +.draggable h2 .download { + margin-right: 4px; + padding: 0px 4px; +} + +.draggable h2 :hover { color: #000; cursor: pointer; }