2 Copyright 2007-2009 University of Cambridge
3 Copyright 2007-2009 University of Toronto
4 Copyright 2007-2009 University of California, Berkeley
6 Licensed under the Educational Community License (ECL), Version 2.0 or the New
7 BSD license. You may not use this file except in compliance with one these
10 You may obtain a copy of the ECL 2.0 License and BSD License at
11 https://source.fluidproject.org/svn/LICENSE.txt
18 var atutor = atutor || {};
19 (function (jQuery, fluid) {
20 var afterMoveListener = function (thePhotoThatMoved, position, allPhotos) {
21 // Loop through each item in the ordered list and update its hidden form field.
22 allPhotos.each(function (idx, photo) {
23 jQuery(photo).children("a").children("input").val(idx+1);
26 //POST it back to the server
30 // Serialize the form and post it back to the server.
31 var postOrder = function () {
32 var form = jQuery("#reorder-images-form"); // Get the form out of the DOM
33 var photoRequest = jQuery(form).serialize(); // Use jQuery to serialize it into a standard form request.
35 // Send it back to the server via an AJAX POST request.
38 url: form.attr('action'),
40 complete: function (data, ajaxStatus) {
41 // Handle success or failure by being nice to the user.
48 * Which actually uses the Grid reorderer
50 atutor.formBasedImageReorderer = function () {
51 var reorderer = fluid.reorderGrid("#reorder-images-form", {
53 movables: ".photo_wrapper"
56 afterMove: afterMoveListener