Additional cleanup work.
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 8 Jul 2015 21:15:33 +0000 (17:15 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 8 Jul 2015 21:15:33 +0000 (17:15 -0400)
js/imageUpload/imageUpload.js

index 7a88797..ed7a728 100644 (file)
@@ -282,12 +282,14 @@ jQuery(document).ready(function($) {
         */
        function sendFileToServer(fd, status)
        {
-
+               // Send one (or more) images to the server. Normally only one image here for now.
            var jqXHR=$.ajax({
                    xhr: function() {
                    var xhrobj = $.ajaxSettings.xhr();
                    if (xhrobj.upload) {
                            xhrobj.upload.addEventListener('progress', function(event) {
+
+                               // calculate progress periodically and set the progress bar 
                                var percent = 0;
                                var position = event.loaded || event.position;
                                var total = event.total;
@@ -350,9 +352,14 @@ jQuery(document).ready(function($) {
            }); 
            
            return jqXHR;
-// status.setAbort(jqXHR);
+
        }
        
+       /* 
+        * This function is used to start handling of various things and
+        * to restart handling when an image has been added. I neede to
+        * do this because .on() didn't cover this situation.  
+        */
        function setupExpandedImageEvents() {
 
                // Handle expanded images on hover for image gallery
@@ -379,6 +386,8 @@ jQuery(document).ready(function($) {
                id = $(this).attr("data-id");
                $('#glm-galleryImageLarger_' + id).dialog("close");
            });
+           
+           // Make images sortable and store the list of IDs in a hidden input field when order has changed.
            $('.glm-galleryImages').sortable({
                update: function(event, ui) {
                        var sortedIDs = $(this).sortable('toArray');