DEV: Fix the `Function.prototype.on` deprecation (#8205)

DEV: Fix the Function.prototype.on deprecation (#8205)

Ember.js - Deprecations

diff --git a/app/assets/javascripts/admin/components/ace-editor.js.es6 b/app/assets/javascripts/admin/components/ace-editor.js.es6
index 8fd9089b2e..887b99d368 100644
--- a/app/assets/javascripts/admin/components/ace-editor.js.es6
+++ b/app/assets/javascripts/admin/components/ace-editor.js.es6
@@ -48,7 +48,7 @@ export default Ember.Component.extend({
     }
   },
 
-  _destroyEditor: function() {
+  _destroyEditor: Ember.on("willDestroyElement", function() {
     if (this._editor) {
       this._editor.destroy();
       this._editor = null;
@@ -59,7 +59,7 @@ export default Ember.Component.extend({
     }
 
     $(window).off("ace:resize");
-  }.on("willDestroyElement"),
+  }),
 
   resize() {
     if (this._editor) {
diff --git a/app/assets/javascripts/admin/mixins/setting-component.js.es6 b/app/assets/javascripts/admin/mixins/setting-component.js.es6
index 397817d793..97873a2bd8 100644
--- a/app/assets/javascripts/admin/mixins/setting-component.js.es6
+++ b/app/assets/javascripts/admin/mixins/setting-component.js.es6
@@ -89,18 +89,18 @@ export default Ember.Mixin.create({
     return settingDefault !== bufferedValue;
   },
 
-  _watchEnterKey: function() {
+  _watchEnterKey: Ember.on("didInsertElement", function() {
     $(this.element).on("keydown.setting-enter", ".input-setting-string", e => {
       if (e.keyCode === 13) {
         // enter key
         this.send("save");
       }
     });
-  }.on("didInsertElement"),
+  }),
 
-  _removeBindings: function() {
+  _removeBindings: Ember.on("willDestroyElement", function() {
     $(this.element).off("keydown.setting-enter");
-  }.on("willDestroyElement"),
+  }),
 
   _save() {
     Ember.warn("You should define a `_save` method", {
diff --git a/app/assets/javascripts/discourse/components/backup-uploader.js.es6 b/app/assets/javascripts/discourse/components/backup-uploader.js.es6
index 66b2665095..1fe3565aa3 100644
--- a/app/assets/javascripts/discourse/components/backup-uploader.js.es6
+++ b/app/assets/javascripts/discourse/components/backup-uploader.js.es6
@@ -34,7 +34,7 @@ export default Ember.Component.extend(UploadMixin, {
     };
   },
 
-  _init: function() {
+  _init: Ember.on("didInsertElement", function() {
     const $upload = $(this.element);
 
     $upload.on("fileuploadadd", (e, data) => {
@@ -47,5 +47,5 @@ export default Ember.Component.extend(UploadMixin, {
         })
         .catch(popupAjaxError);
     });
-  }.on("didInsertElement")
+  })
 });
diff --git a/app/assets/javascripts/discourse/components/csv-uploader.js.es6 b/app/assets/javascripts/discourse/components/csv-uploader.js.es6
index a37e10f3cc..8178fdc09e 100644
--- a/app/assets/javascripts/discourse/components/csv-uploader.js.es6
+++ b/app/assets/javascripts/discourse/components/csv-uploader.js.es6
@@ -31,7 +31,7 @@ export default Ember.Component.extend(UploadMixin, {
     return { autoUpload: false };
   },
 
-  _init: function() {
+  _init: Ember.on("didInsertElement", function() {
     const $upload = $(this.element);
 
     $upload.on("fileuploadadd", (e, data) => {
@@ -42,5 +42,5 @@ export default Ember.Component.extend(UploadMixin, {
         result => (result ? data.submit() : data.abort())
       );
     });
-  }.on("didInsertElement")
+  })
 });
diff --git a/app/assets/javascripts/discourse/components/signup-cta.js.es6 b/app/assets/javascripts/discourse/components/signup-cta.js.es6
index dbbc7ad1d5..287e30c651 100644
--- a/app/assets/javascripts/discourse/components/signup-cta.js.es6
+++ b/app/assets/javascripts/discourse/components/signup-cta.js.es6
@@ -16,9 +16,9 @@ export default Ember.Component.extend({
     }
   },
 
-  _turnOffIfHidden: function() {
+  _turnOffIfHidden: Ember.on("willDestroyElement", function() {
     if (this.session.get("hideSignupCta")) {
       this.session.set("showSignupCta", false);
     }
-  }.on("willDestroyElement")
+  })
 });
diff --git a/app/assets/javascripts/discourse/components/topic-list-item.js.es6 b/app/assets/javascripts/discourse/components/topic-list-item.js.es6
index 1116d97e61..ad822dfb42 100644
--- a/app/assets/javascripts/discourse/components/topic-list-item.js.es6
+++ b/app/assets/javascripts/discourse/components/topic-list-item.js.es6
@@ -202,7 +202,7 @@ export const ListItemDefaults = {
     $topic.on("animationend", () => $topic.removeClass("highlighted"));
   },
 
-  _highlightIfNeeded: function() {
+  _highlightIfNeeded: Ember.on("didInsertElement", function() {
     // highlight the last topic viewed
     if (this.session.get("lastTopicIdViewed") === this.get("topic.id")) {
       this.session.set("lastTopicIdViewed", null);
@@ -212,7 +212,7 @@ export const ListItemDefaults = {
       this.set("topic.highlight", false);
       this.highlight();
     }
-  }.on("didInsertElement")
+  })
 };
 
 export default Ember.Component.extend(
diff --git a/app/assets/javascripts/discourse/components/topic-list.js.es6 b/app/assets/javascripts/discourse/components/topic-list.js.es6
index 44846d5b0d..294563feaa 100644
--- a/app/assets/javascripts/discourse/components/topic-list.js.es6
+++ b/app/assets/javascripts/discourse/components/topic-list.js.es6
@@ -12,12 +12,12 @@ export default Ember.Component.extend({
   // Overwrite this to perform client side filtering of topics, if desired
   filteredTopics: Ember.computed.alias("topics"),
 
-  _init: function() {
+  _init: Ember.on("init", function() {
     this.addObserver("hideCategory", this.rerender);
     this.addObserver("order", this.rerender);
     this.addObserver("ascending", this.rerender);
     this.refreshLastVisited();
-  }.on("init"),
+  }),
 
   @computed("bulkSelectEnabled")
   toggleInTitle(bulkSelectEnabled) {
diff --git a/app/assets/javascripts/discourse/components/user-stream.js.es6 b/app/assets/javascripts/discourse/components/user-stream.js.es6
index 7054358457..ffb5c68603 100644
--- a/app/assets/javascripts/discourse/components/user-stream.js.es6
+++ b/app/assets/javascripts/discourse/components/user-stream.js.es6
@@ -7,7 +7,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
 import { getOwner } from "discourse-common/lib/get-owner";
 
 export default Ember.Component.extend(LoadMore, {
-  _initialize: function() {
+  _initialize: Ember.on("init", function() {
     const filter = this.get("stream.filter");
     if (filter) {
       this.set("classNames", [
@@ -15,7 +15,7 @@ export default Ember.Component.extend(LoadMore, {
         "filter-" + filter.toString().replace(",", "-")
       ]);
     }
-  }.on("init"),
+  }),
 
   loading: false,
   eyelineSelector: ".user-stream .item",
@@ -25,7 +25,7 @@ export default Ember.Component.extend(LoadMore, {
     Ember.run.schedule("afterRender", () => $(document).scrollTop(0));
   }.observes("stream.user.id"),
 
-  _inserted: function() {
+  _inserted: Ember.on("didInsertElement", function() {
     this.bindScrolling({ name: "user-stream-view" });
 
     $(window).on("resize.discourse-on-scroll", () => this.scrolled());
@@ -38,17 +38,17 @@ export default Ember.Component.extend(LoadMore, {
     $(this.element).on("click.discourse-redirect", ".excerpt a", function(e) {
       return ClickTrack.trackClick(e);
     });
-  }.on("didInsertElement"),
+  }),
 
   // This view is being removed. Shut down operations
-  _destroyed: function() {
+  _destroyed: Ember.on("willDestroyElement", function() {
     this.unbindScrolling("user-stream-view");
     $(window).unbind("resize.discourse-on-scroll");
     $(this.element).off("click.details-disabled", "details.disabled");
 
     // Unbind link tracking
     $(this.element).off("click.discourse-redirect", ".excerpt a");
-  }.on("willDestroyElement"),
+  }),
 
   actions: {
     removeBookmark(userAction) {
diff --git a/app/assets/javascripts/discourse/mixins/cleans-up.js.es6 b/app/assets/javascripts/discourse/mixins/cleans-up.js.es6
index 09d469af1c..8392aacf27 100644
--- a/app/assets/javascripts/discourse/mixins/cleans-up.js.es6
+++ b/app/assets/javascripts/discourse/mixins/cleans-up.js.es6
@@ -1,11 +1,11 @@

[... diff too long, it was truncated ...]

GitHub sha: 7de3e7b3