From ff5481df13ac798ffd6b1d6ad90d731a07afefb6 Mon Sep 17 00:00:00 2001
From: Paul van Tilburg
Date: Sun, 12 Sep 2010 12:38:15 +0200
Subject: [PATCH] Set up the draggables 'on load', no need for a script element
per draggable.
---
plemp.rb | 4 ++--
public/dragreg.js | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/plemp.rb b/plemp.rb
index 277493d..43e856b 100644
--- a/plemp.rb
+++ b/plemp.rb
@@ -129,7 +129,7 @@ module Plemp::Views
"init_plemp();"
end
end
- body do
+ body(:onLoad => "return setup_draggables();") do
self << yield
end
end
@@ -202,8 +202,8 @@ module Plemp::Views
em "#{d.file}: Unsupported file type!"
end
end
- script(:type => "text/javascript") { "setup_draggable('#{d.file}')" }
end
end
end
+
end
diff --git a/public/dragreg.js b/public/dragreg.js
index e42229c..7170f79 100644
--- a/public/dragreg.js
+++ b/public/dragreg.js
@@ -5,6 +5,10 @@ function init_plemp(base_url) {
}
// Creates a Draggable for each div with the given ID.
+function setup_draggables() {
+ $$('.draggable').each(function(d) { setup_draggable(d.id); });
+}
+
function setup_draggable(id) {
drag = new Draggable(id, { scroll: window });
old_endeffect = drag.options.endeffect;