diff options
author | C. Montero Luque <cmonteroluque@users.noreply.github.com> | 2016-03-04 16:41:26 -0500 |
---|---|---|
committer | C. Montero Luque <cmonteroluque@users.noreply.github.com> | 2016-03-04 16:41:26 -0500 |
commit | 5d402fc8179e5441ad2f5e42185351d948b4b63d (patch) | |
tree | c23a0b45d9cee4e1763630d03f5f7175d0d959ca | |
parent | b3c9ed8d5cd3f466311b3479ec67d5bacc49105c (diff) | |
parent | e6c6ee8d2ace97b301ace4022feb298f380f416d (diff) | |
download | nextcloud-server-5d402fc8179e5441ad2f5e42185351d948b4b63d.tar.gz nextcloud-server-5d402fc8179e5441ad2f5e42185351d948b4b63d.zip |
Merge pull request #22848 from owncloud/stable9-fileactions-downloadspinnerfix
[stable9] Fix download spinner to work with CSS styles
-rw-r--r-- | apps/files/css/files.css | 13 | ||||
-rw-r--r-- | apps/files/js/fileactions.js | 19 | ||||
-rw-r--r-- | apps/files/tests/js/fileactionsSpec.js | 20 |
3 files changed, 42 insertions, 10 deletions
diff --git a/apps/files/css/files.css b/apps/files/css/files.css index b65af1fa0f3..bfa5340fe09 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -793,6 +793,19 @@ html.ie8 #controls .button.new { background-size: 16px 16px; } +#filestable .filename .action .icon.hidden, +#filestable .selectedActions a .icon.hidden, +#controls .actions .button .icon.hidden { + display: none; +} + +#filestable .filename .action .icon.loading, +#filestable .selectedActions a .icon.loading, +#controls .actions .button .icon.loading { + width: 15px; + height: 15px; +} + .app-files .actions .button.new .icon { margin-bottom: 2px; } diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index 05ff2f0cbfa..69e32d500c4 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -659,19 +659,18 @@ * Replaces the download icon with a loading spinner and vice versa * - also adds the class disabled to the passed in element * - * @param downloadButtonElement download fileaction + * @param {jQuery} $downloadButtonElement download fileaction * @param {boolean} showIt whether to show the spinner(true) or to hide it(false) */ - OCA.Files.FileActions.updateFileActionSpinner = function(downloadButtonElement, showIt) { - var icon = downloadButtonElement.find('img'), - sourceImage = icon.attr('src'); - - if(showIt) { - downloadButtonElement.addClass('disabled'); - icon.attr('src', sourceImage.replace('actions/download.svg', 'loading-small.gif')); + OCA.Files.FileActions.updateFileActionSpinner = function($downloadButtonElement, showIt) { + var $icon = $downloadButtonElement.find('.icon'); + if (showIt) { + var $loadingIcon = $('<span class="icon loading"></span>'); + $icon.after($loadingIcon); + $icon.addClass('hidden'); } else { - downloadButtonElement.removeClass('disabled'); - icon.attr('src', sourceImage.replace('loading-small.gif', 'actions/download.svg')); + $downloadButtonElement.find('.loading').remove(); + $downloadButtonElement.find('.icon').removeClass('hidden'); } }; diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js index 470f2854f43..3f46a27d1f9 100644 --- a/apps/files/tests/js/fileactionsSpec.js +++ b/apps/files/tests/js/fileactionsSpec.js @@ -656,4 +656,24 @@ describe('OCA.Files.FileActions tests', function() { }); }); }); + describe('download spinner', function() { + var FileActions = OCA.Files.FileActions; + var $el; + + beforeEach(function() { + $el = $('<a href="#"><span class="icon icon-download"></span><span>Download</span></a>'); + }); + + it('replaces download icon with spinner', function() { + FileActions.updateFileActionSpinner($el, true); + expect($el.find('.icon.loading').length).toEqual(1); + expect($el.find('.icon.icon-download').hasClass('hidden')).toEqual(true); + }); + it('replaces spinner back with download icon with spinner', function() { + FileActions.updateFileActionSpinner($el, true); + FileActions.updateFileActionSpinner($el, false); + expect($el.find('.icon.loading').length).toEqual(0); + expect($el.find('.icon.icon-download').hasClass('hidden')).toEqual(false); + }); + }); }); |