This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/watch-read.js.es6
2016-11-10 15:25:04 -05:00

25 lines
674 B
JavaScript

import isElementInViewport from "discourse/lib/is-element-in-viewport";
export default Ember.Component.extend({
didInsertElement() {
this._super();
const currentUser = this.currentUser;
if (!currentUser) { return; }
const path = this.get('path');
if (path === "faq" || path === "guidelines") {
$(window).on('load.faq resize.faq scroll.faq', () => {
const faqUnread = !currentUser.get('read_faq');
if (faqUnread && isElementInViewport($(".contents p").last())) {
this.sendAction();
}
});
}
},
willDestroyElement() {
this._super();
$(window).off('load.faq resize.faq scroll.faq');
}
});