mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-28 18:17:29 -05:00
24 lines
750 B
JavaScript
24 lines
750 B
JavaScript
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
|
import ScrollTop from 'discourse/mixins/scroll-top';
|
|
|
|
var readFaq = false;
|
|
|
|
export default Ember.View.extend(ScrollTop, {
|
|
|
|
_checkRead: function() {
|
|
const path = this.get('controller.model.path');
|
|
if (path === "faq" || path === "guidelines") {
|
|
const controller = this.get('controller');
|
|
$(window).on('load.faq resize.faq scroll.faq', function() {
|
|
if (!readFaq && isElementInViewport($(".contents p").last())) {
|
|
readFaq = true;
|
|
controller.send('markFaqRead');
|
|
}
|
|
});
|
|
}
|
|
}.on('didInsertElement'),
|
|
|
|
_stopChecking: function(){
|
|
$(window).off('load.faq resize.faq scroll.faq');
|
|
}.on('willDestroyElement')
|
|
});
|