Cleanup example modules (todo: add in documentation)

This commit is contained in:
Dominic Lord
2017-03-02 08:53:44 -05:00
parent a1695c499f
commit c9cedfa727
3 changed files with 0 additions and 108 deletions

View File

@@ -1,3 +1 @@
/* jshint esnext: true */
export {default as Button} from './modules/Button';
export {default as Title} from './modules/Title';

View File

@@ -1,30 +0,0 @@
/* jshint esnext: true */
import AbstractModule from './AbstractModule';
import { $document, APP_NAME, DATA_API_KEY } from '../utils/environment';
const DATA_KEY = `${APP_NAME}.button`;
const EVENT_KEY = `.${DATA_KEY}`;
const Event = {
CLICK : `click${EVENT_KEY}`
};
/**
* Button
*/
export default class extends AbstractModule
{
constructor(options)
{
super(options);
this.$el.on(Event.CLICK, (event) => {
$document.trigger(`changeLabel.Title.${APP_NAME}`, [ $(event.currentTarget).val() ]);
});
}
destroy()
{
this.$el.off(EVENT_KEY);
}
}

View File

@@ -1,76 +0,0 @@
/* jshint esnext: true */
import AbstractModule from './AbstractModule';
import { visibilityApi } from '../utils/visibility';
import { $document, APP_NAME, DATA_API_KEY } from '../utils/environment';
const DATA_KEY = `${APP_NAME}.Title`;
const EVENT_KEY = `.${DATA_KEY}`;
const Event = {
CHANGE_LABEL : `changeLabel${EVENT_KEY}`
};
const Selector = {
LABEL : '.js-label'
}
export default class extends AbstractModule
{
constructor(options)
{
super(options);
this.$label = this.$el.find(Selector.LABEL);
$document.on(Event.CHANGE_LABEL, (event, value) => {
this.changeLabel(value);
this.destroy();
});
this.hiddenCallbackIdent = visibilityApi({
action: 'addCallback',
state: 'hidden',
callback: this.logHidden
});
this.visibleCallbackIdent = visibilityApi({
action: 'addCallback',
state: 'visible',
callback: this.logVisible
});
}
logHidden()
{
console.log('Title is hidden');
}
logVisible()
{
console.log('Title is visible');
}
changeLabel(value)
{
this.$label.text(value);
}
destroy()
{
$document.off(EVENT_KEY);
this.$el.off(EVENT_KEY);
visibilityApi({
action: 'removeCallback',
state: 'hidden',
ident: this.hiddenCallbackIdent
});
visibilityApi({
action: 'removeCallback',
state: 'visible',
ident: this.visibleCallbackIdent
});
}
}