summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/javascripts/admin_interface.js41
1 files changed, 31 insertions, 10 deletions
diff --git a/public/javascripts/admin_interface.js b/public/javascripts/admin_interface.js
index 5ca68c1..fad468e 100644
--- a/public/javascripts/admin_interface.js
+++ b/public/javascripts/admin_interface.js
@@ -114,29 +114,44 @@ menu_item_sorter = {
114} 114}
115 115
116image_interface = { 116image_interface = {
117
118 current_images : "",
119
117 initialize : function() { 120 initialize : function() {
118 $("ul#image_box").sortable({ 121 $("ul#image_box").sortable({
119 revert : true, 122 revert : true,
123 start : function(event, ui) {
124 image_interface.current_images = $("ul#image_box").sortable(
125 "serialize",
126 {attribute : "rel"}
127 )
128 },
120 stop : function(event, ui) { 129 stop : function(event, ui) {
121 $.ajax({ 130 images = $("ul#image_box").sortable("serialize", {attribute : "rel"});
122 type : "POST", 131
123 url : "/pages/" + $("ul#image_box").attr("rel") + "/sort_images", 132 if (images != image_interface.current_images) {
124 dataType : "json", 133 $.ajax({
125 data : $("ul#image_box").sortable("serialize", {attribute : "rel"}) + 134 type : "POST",
126 "&_method=put", 135 url : "/pages/" + $("ul#image_box").attr("rel") + "/sort_images",
127 success : function() {} 136 dataType : "json",
128 }); 137 data : images + "&_method=put",
138 success : function() {}
139 });
140 }
129 } 141 }
130 }); 142 });
131 143
132 $("ul#image_box").droppable({ 144 $("ul#image_box").droppable({
133 out : function(event, ui) { 145 out : function(event, ui) {
146 $(ui.draggable).fadeTo("fast", 0.5);
147
134 $(ui.draggable).bind("mouseup", function() { 148 $(ui.draggable).bind("mouseup", function() {
135 $(this).remove() 149 $(this).remove();
136 }); 150 });
137 }, 151 },
138 over : function(event, ui) { 152 over : function(event, ui) {
139 $(ui.draggable).unbind("mouseup") 153 $(ui.draggable).fadeTo("fast", 1.0);
154 $(ui.draggable).unbind("mouseup");
140 } 155 }
141 }); 156 });
142 157
@@ -144,6 +159,12 @@ image_interface = {
144 connectToSortable : 'ul#image_box', 159 connectToSortable : 'ul#image_box',
145 helper : 'clone', 160 helper : 'clone',
146 revert : 'invalid', 161 revert : 'invalid',
162 start : function(event, ui) {
163 image_interface.current_images = $("ul#image_box").sortable(
164 "serialize",
165 {attribute : "rel"}
166 )
167 },
147 stop : function() { 168 stop : function() {
148 169
149 } 170 }