summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/star.js
diff options
context:
space:
mode:
authorMartin Wortschack <mwortschack@gitlab.com>2018-12-13 12:37:54 +0000
committerSean McGivern <sean@gitlab.com>2018-12-13 12:37:54 +0000
commit388d4170907d2cad58c5999d32a74c1629681e4f (patch)
tree7a68bf6eb17f5c3e1439ea2e1de4fffbb0ccb6e7 /app/assets/javascripts/star.js
parentb96150d8d59d124de8e3a4acc6facff0726ddce0 (diff)
downloadgitlab-ce-388d4170907d2cad58c5999d32a74c1629681e4f.tar.gz
Resolve "Redesign project lists UI"
Diffstat (limited to 'app/assets/javascripts/star.js')
-rw-r--r--app/assets/javascripts/star.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/app/assets/javascripts/star.js b/app/assets/javascripts/star.js
index 9af5d5b23cb..7404dfbf22a 100644
--- a/app/assets/javascripts/star.js
+++ b/app/assets/javascripts/star.js
@@ -5,11 +5,12 @@ import { spriteIcon } from './lib/utils/common_utils';
import axios from './lib/utils/axios_utils';
export default class Star {
- constructor() {
- $('.project-home-panel .toggle-star').on('click', function toggleStarClickCallback() {
+ constructor(container = '.project-home-panel') {
+ $(`${container} .toggle-star`).on('click', function toggleStarClickCallback() {
const $this = $(this);
const $starSpan = $this.find('span');
- const $startIcon = $this.find('svg');
+ const $starIcon = $this.find('svg');
+ const iconClasses = $starIcon.attr('class').split(' ');
axios
.post($this.data('endpoint'))
@@ -22,12 +23,12 @@ export default class Star {
if (isStarred) {
$starSpan.removeClass('starred').text(s__('StarProject|Star'));
- $startIcon.remove();
- $this.prepend(spriteIcon('star-o', 'icon'));
+ $starIcon.remove();
+ $this.prepend(spriteIcon('star-o', iconClasses));
} else {
$starSpan.addClass('starred').text(__('Unstar'));
- $startIcon.remove();
- $this.prepend(spriteIcon('star', 'icon'));
+ $starIcon.remove();
+ $this.prepend(spriteIcon('star', iconClasses));
}
})
.catch(() => Flash('Star toggle failed. Try again later.'));