]> source.dussan.org Git - nextcloud-server.git/commitdiff
Remove spinner when toggling file favorite
authorVincent Petry <pvince81@owncloud.com>
Mon, 15 Dec 2014 14:50:57 +0000 (15:50 +0100)
committerVincent Petry <pvince81@owncloud.com>
Mon, 15 Dec 2014 14:50:57 +0000 (15:50 +0100)
apps/files/js/tagsplugin.js

index b7bbb6daf546701c4b2c7e1b266aec48b2a85c8c..550026e3b486fc0cc79217274ee8c93121f538d2 100644 (file)
                });
        }
 
+       /**
+        * Toggle star icon on action element
+        *
+        * @param {Object} action element
+        * @param {boolean} state true if starred, false otherwise
+        */
+       function toggleStar($actionEl, state) {
+               $actionEl.find('img').attr('src', getStarImage(state));
+               $actionEl.toggleClass('permanent', state);
+       }
+
        OCA.Files = OCA.Files || {};
 
        /**
                                        } else {
                                                tags.push(OC.TAG_FAVORITE);
                                        }
-                                       if ($actionEl.hasClass('icon-loading')) {
-                                               // do nothing
-                                               return;
-                                       }
-                                       $actionEl.addClass('icon-loading permanent');
+                                       toggleStar($actionEl, !isFavorite);
+
                                        self.applyFileTags(
                                                dir + '/' + fileName,
                                                tags
                                        ).then(function(result) {
                                                // read latest state from result
-                                               var isFavorite = (result.tags.indexOf(OC.TAG_FAVORITE) >= 0);
-                                               $actionEl.removeClass('icon-loading');
-                                               $actionEl.find('img').attr('src', getStarImage(isFavorite));
-                                               $actionEl.toggleClass('permanent', isFavorite);
+                                               toggleStar($actionEl, (result.tags.indexOf(OC.TAG_FAVORITE) >= 0));
                                                $file.attr('data-tags', tags.join('|'));
                                                $file.attr('data-favorite', !isFavorite);
                                        });