From cae5b4accca2f880bbd4a5ffae265f78c689075c Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 1 Sep 2009 23:13:45 +0200 Subject: Added javascript goodness to add and sort and drag and drop images on pages --- public/javascripts/admin_interface.js | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'public/javascripts/admin_interface.js') diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js index ce971a4..977e42a 100644 --- a/public/javascripts/admin_interface.js +++ b/public/javascripts/admin_interface.js @@ -4,6 +4,7 @@ $(document).ready(function () { meta_data.initialize(); menu_item_sorter.initialize(); + jQuery.ajaxSetup({ 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} }) @@ -27,6 +28,7 @@ meta_data = { if ($("#button").attr("class") == "unselected") { $("#button").attr("class", "selected"); + image_interface.initialize(); } else { $("#button").attr("class", "unselected"); @@ -110,5 +112,39 @@ menu_item_sorter = { $(".ui-state-highlight").html(""); } } + +image_interface = { + initialize : function() { + $("ul#image_box").sortable({ + revert : true, + stop : function(event, ui) { + $.ajax({ + type : "POST", + url : "/pages/" + $("ul#image_box").attr("rel") + "/sort_images", + dataType : "json", + data : $("ul#image_box").sortable("serialize", {attribute : "rel"}) + "&_method=put", + success : function() {} + }); + } + }); + + $("ul#image_box").droppable({ + out : function(event, ui) { + $(ui.draggable).bind("mouseup", function() {$(this).remove()}) + } + }); + + $("div#asset_toolbox ul li").draggable({ + connectToSortable : 'ul#image_box', + helper : 'clone', + revert : 'invalid', + stop : function() { + + } + }); + + $("ul, li").disableSelection(); + } +} -- cgit v1.3