diff options
author | Phil Hughes <me@iamphill.com> | 2017-10-11 08:10:35 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-10-11 08:10:35 +0000 |
commit | 57d331d7514f36d5805a68ac7523d6a075d3e7a7 (patch) | |
tree | 81dc6904e6a35398d7507c8eb732d6c5b31c52af | |
parent | a6b33275c042253eb6ccfb00eaab62a388a931cf (diff) | |
parent | 696ffac0ec7435430d633173a207aa47d1254903 (diff) | |
download | gitlab-ce-57d331d7514f36d5805a68ac7523d6a075d3e7a7.tar.gz |
Merge branch '38869-start' into 'master'
Enable eslint in star and remove from main.js
See merge request gitlab-org/gitlab-ce!14795
-rw-r--r-- | app/assets/javascripts/main.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/star.js | 40 |
2 files changed, 21 insertions, 20 deletions
diff --git a/app/assets/javascripts/main.js b/app/assets/javascripts/main.js index 09cf5a2a3cb..8d7608ce0f4 100644 --- a/app/assets/javascripts/main.js +++ b/app/assets/javascripts/main.js @@ -116,7 +116,6 @@ import './right_sidebar'; import './search'; import './search_autocomplete'; import './smart_interval'; -import './star'; import './subscription'; import './subscription_select'; import initBreadcrumbs from './breadcrumb'; diff --git a/app/assets/javascripts/star.js b/app/assets/javascripts/star.js index 77db075d1ef..1a8dc085772 100644 --- a/app/assets/javascripts/star.js +++ b/app/assets/javascripts/star.js @@ -1,27 +1,29 @@ -/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-unused-vars, one-var, no-var, one-var-declaration-per-line, prefer-arrow-callback, no-new, max-len */ import Flash from './flash'; import { __, s__ } from './locale'; export default class Star { constructor() { - $('.project-home-panel .toggle-star').on('ajax:success', function(e, data, status, xhr) { - var $starIcon, $starSpan, $this, toggleStar; - $this = $(this); - $starSpan = $this.find('span'); - $starIcon = $this.find('i'); - toggleStar = function(isStarred) { - $this.parent().find('.star-count').text(data.star_count); - if (isStarred) { - $starSpan.removeClass('starred').text(s__('StarProject|Star')); - $starIcon.removeClass('fa-star').addClass('fa-star-o'); - } else { - $starSpan.addClass('starred').text(__('Unstar')); - $starIcon.removeClass('fa-star-o').addClass('fa-star'); + $('.project-home-panel .toggle-star') + .on('ajax:success', function handleSuccess(e, data) { + const $this = $(this); + const $starSpan = $this.find('span'); + const $starIcon = $this.find('i'); + + function toggleStar(isStarred) { + $this.parent().find('.star-count').text(data.star_count); + if (isStarred) { + $starSpan.removeClass('starred').text(s__('StarProject|Star')); + $starIcon.removeClass('fa-star').addClass('fa-star-o'); + } else { + $starSpan.addClass('starred').text(__('Unstar')); + $starIcon.removeClass('fa-star-o').addClass('fa-star'); + } } - }; - toggleStar($starSpan.hasClass('starred')); - }).on('ajax:error', function(e, xhr, status, error) { - new Flash('Star toggle failed. Try again later.', 'alert'); - }); + + toggleStar($starSpan.hasClass('starred')); + }) + .on('ajax:error', () => { + Flash('Star toggle failed. Try again later.', 'alert'); + }); } } |