From 976baed5f9dec891fedc4756fa272dd5a0f4eae2 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Mon, 15 Dec 2014 15:50:57 +0100 Subject: [PATCH] Remove spinner when toggling file favorite --- apps/files/js/tagsplugin.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index b7bbb6daf54..550026e3b48 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -45,6 +45,17 @@ }); } + /** + * 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 || {}; /** @@ -93,20 +104,14 @@ } 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); }); -- 2.39.5