From 2544e7b7892ccb5abc259c56c08db95c2344cc5f Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Tue, 15 Nov 2016 21:01:44 -0200 Subject: Rename LabelSubscription javascript to ProjectLabelSubscription --- app/assets/javascripts/label_subscription.js.es6 | 53 ---------------------- .../javascripts/project_label_subscription.js.es6 | 53 ++++++++++++++++++++++ app/views/shared/_label.html.haml | 2 +- 3 files changed, 54 insertions(+), 54 deletions(-) delete mode 100644 app/assets/javascripts/label_subscription.js.es6 create mode 100644 app/assets/javascripts/project_label_subscription.js.es6 diff --git a/app/assets/javascripts/label_subscription.js.es6 b/app/assets/javascripts/label_subscription.js.es6 deleted file mode 100644 index 4ee8e02b088..00000000000 --- a/app/assets/javascripts/label_subscription.js.es6 +++ /dev/null @@ -1,53 +0,0 @@ -/* eslint-disable */ -(function(global) { - class LabelSubscription { - constructor(container) { - this.$container = $(container); - this.$buttons = this.$container.find('.js-subscribe-button'); - - this.$buttons.on('click', this.toggleSubscription.bind(this)); - } - - toggleSubscription(event) { - event.preventDefault(); - - const $btn = $(event.currentTarget); - const $span = $btn.find('span'); - const url = $btn.attr('data-url'); - const status = $btn.attr('data-status'); - - $btn.addClass('disabled'); - $span.toggleClass('hidden'); - - $.ajax({ - type: 'POST', - url: url - }).done(() => { - let newStatus, newAction; - - if (status === 'subscribed') { - [newStatus, newAction] = ['unsubscribed', 'Subscribe']; - } else { - [newStatus, newAction] = ['subscribed', 'Unsubscribe']; - } - - $span.toggleClass('hidden'); - $btn.removeClass('disabled'); - - this.$buttons.attr('data-status', newStatus); - this.$buttons.find('> span').text(newAction); - - for (let button of this.$buttons) { - let $button = $(button); - - if ($button.attr('data-original-title')) { - $button.tooltip('hide').attr('data-original-title', newAction).tooltip('fixTitle'); - } - } - }); - } - } - - global.LabelSubscription = LabelSubscription; - -})(window.gl || (window.gl = {})); diff --git a/app/assets/javascripts/project_label_subscription.js.es6 b/app/assets/javascripts/project_label_subscription.js.es6 new file mode 100644 index 00000000000..fd5146e2f12 --- /dev/null +++ b/app/assets/javascripts/project_label_subscription.js.es6 @@ -0,0 +1,53 @@ +/* eslint-disable */ +(function(global) { + class ProjectLabelSubscription { + constructor(container) { + this.$container = $(container); + this.$buttons = this.$container.find('.js-subscribe-button'); + + this.$buttons.on('click', this.toggleSubscription.bind(this)); + } + + toggleSubscription(event) { + event.preventDefault(); + + const $btn = $(event.currentTarget); + const $span = $btn.find('span'); + const url = $btn.attr('data-url'); + const status = $btn.attr('data-status'); + + $btn.addClass('disabled'); + $span.toggleClass('hidden'); + + $.ajax({ + type: 'POST', + url: url + }).done(() => { + let newStatus, newAction; + + if (status === 'subscribed') { + [newStatus, newAction] = ['unsubscribed', 'Subscribe']; + } else { + [newStatus, newAction] = ['subscribed', 'Unsubscribe']; + } + + $span.toggleClass('hidden'); + $btn.removeClass('disabled'); + + this.$buttons.attr('data-status', newStatus); + this.$buttons.find('> span').text(newAction); + + for (let button of this.$buttons) { + let $button = $(button); + + if ($button.attr('data-original-title')) { + $button.tooltip('hide').attr('data-original-title', newAction).tooltip('fixTitle'); + } + } + }); + } + } + + global.ProjectLabelSubscription = ProjectLabelSubscription; + +})(window.gl || (window.gl = {})); diff --git a/app/views/shared/_label.html.haml b/app/views/shared/_label.html.haml index fb75e130140..e2495b00f52 100644 --- a/app/views/shared/_label.html.haml +++ b/app/views/shared/_label.html.haml @@ -79,7 +79,7 @@ - if current_user && defined?(@project) - if label.is_a?(ProjectLabel) :javascript - new gl.LabelSubscription('##{dom_id(label)} .label-subscription'); + new gl.ProjectLabelSubscription('##{dom_id(label)} .label-subscription'); - else :javascript new gl.GroupLabelSubscription('##{dom_id(label)} .label-subscription'); -- cgit v1.2.1