1
0
mirror of https://github.com/locomotivemtl/locomotive-boilerplate.git synced 2026-01-15 00:55:08 +08:00
Files
locomotive-boilerplate/assets/scripts/modules/Title.js
2016-05-18 23:58:08 -04:00

36 lines
761 B
JavaScript

/* jshint esnext: true */
import { registerDocumentHiddenCallback, registerDocumentVisibleCallback } from '../utils/visibility';
import AbstractModule from './AbstractModule';
export default class extends AbstractModule {
constructor(options) {
super(options);
this.$label = this.$el.find('.js-label');
this.$document.on('title.changeLabel', (event, value) => {
this.changeLabel(value);
});
registerDocumentHiddenCallback(this.logHidden);
registerDocumentVisibleCallback(this.logVisible);
}
logHidden() {
console.log('Title is hidden');
}
logVisible() {
console.log('Title is visible');
}
changeLabel(value) {
this.$label.text(value);
}
destroy() {
this.$document.off('title.changeLabel');
this.$el.off('.Title');
}
}