mirror of
https://github.com/discourse/discourse.git
synced 2025-04-09 01:40:44 +08:00
DEV: Fix the Function.prototype.on
deprecation (#8205)
https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-on
This commit is contained in:
parent
f6ea986aec
commit
7de3e7b322
@ -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) {
|
||||
|
@ -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", {
|
||||
|
@ -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")
|
||||
})
|
||||
});
|
||||
|
@ -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")
|
||||
})
|
||||
});
|
||||
|
@ -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")
|
||||
})
|
||||
});
|
||||
|
@ -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(
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Include this mixin if you want to be notified when the dom should be
|
||||
// cleaned (usually on route change.)
|
||||
export default Ember.Mixin.create({
|
||||
_initializeChooser: function() {
|
||||
_initializeChooser: Ember.on("didInsertElement", function() {
|
||||
this.appEvents.on("dom:clean", this, "cleanUp");
|
||||
}.on("didInsertElement"),
|
||||
}),
|
||||
|
||||
_clearChooser: function() {
|
||||
_clearChooser: Ember.on("willDestroyElement", function() {
|
||||
this.appEvents.off("dom:clean", this, "cleanUp");
|
||||
}.on("willDestroyElement")
|
||||
})
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ export default Ember.Mixin.create({
|
||||
return {};
|
||||
},
|
||||
|
||||
_initialize: function() {
|
||||
_initialize: Ember.on("didInsertElement", function() {
|
||||
const $upload = $(this.element);
|
||||
const reset = () =>
|
||||
this.setProperties({ uploading: false, uploadProgress: 0 });
|
||||
@ -101,9 +101,9 @@ export default Ember.Mixin.create({
|
||||
}
|
||||
reset();
|
||||
});
|
||||
}.on("didInsertElement"),
|
||||
}),
|
||||
|
||||
_destroy: function() {
|
||||
_destroy: Ember.on("willDestroyElement", function() {
|
||||
this.messageBus && this.messageBus.unsubscribe("/uploads/" + this.type);
|
||||
|
||||
const $upload = $(this.element);
|
||||
@ -113,5 +113,5 @@ export default Ember.Mixin.create({
|
||||
/* wasn't initialized yet */
|
||||
}
|
||||
$upload.off();
|
||||
}.on("willDestroyElement")
|
||||
})
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user