diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-12-15 15:50:57 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-12-15 15:50:57 +0100 |
commit | 976baed5f9dec891fedc4756fa272dd5a0f4eae2 (patch) | |
tree | 43768b1b076842661ee9a3769057a1b1a3257739 /apps/files | |
parent | 33eb4483b297d12b7cb76e5a3df25f2d641a96cb (diff) | |
download | nextcloud-server-976baed5f9dec891fedc4756fa272dd5a0f4eae2.tar.gz nextcloud-server-976baed5f9dec891fedc4756fa272dd5a0f4eae2.zip |
Remove spinner when toggling file favorite
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/tagsplugin.js | 23 |
1 files 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); }); |