discourse/app/assets/javascripts/discourse/views/static.js.es6
2015-05-19 12:51:03 -04:00

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')
});