@travlrcom/uikit
Version:
TRAVLR UiKit
89 lines (73 loc) • 2.15 kB
JavaScript
/**
****************************************************
*** ******* ****** ****
*** ****** ****** *****
*********** ************** ****** ******
*********** ************* ****** *******
*********** ************ ****** ********
*********** *********** ****** *********
*********** ********** ****** **********
*********** ********* ****** ***********
*********** ******** ****** ************
*********** ******* ****** *************
*********** ****** ****** **************
****************************************************
* --------------------------------------------------
* Travlr UiKit: example.js
* By Travlr Team
* --------------------------------------------------
*/
import ErrorMessageHandler from './utils/errorMessageHandler'
// const
const NAME = 'example'
const DATA_KEY = `trv.${NAME}`
const EVENT_KEY = `.${DATA_KEY}`
const Selector = {
TRV_TOGGLE: `[trv-toggle="${NAME}"]`,
TRV_BUTTON: `[trv-${NAME}^="#"]`,
TRV_STATUS: `[trv-status]`
}
const ClassName = {
ACTIVE: 'active'
}
const Event = {
ACTIVE: `active${EVENT_KEY}`,
INACTIVE: `inactive${EVENT_KEY}`
}
const ErrorMessages = [
{
ERROR_ID: 0,
ERROR_MESSAGE: 'Config must be an object'
}
]
const ConfigErrorMessage = {
errorId: 0,
errorMessages: ErrorMessages
}
class Example {
constructor (config) {
if (typeof config !== 'object') {
const ConfigError = Object.assign({}, ConfigErrorMessage, {
errorId: 0
})
new ErrorMessageHandler(ConfigError)
}
this._config = config
this._element = window.$TravlrSelector(this._config.element)
this._elementContext = ''
this._isActive = false
this._beforeAction = config.beforeAction
this._afterAction = config.afterAction
if (this._element.length === 0) {
this._element = window.$TravlrSelector(Selector.TRV_BUTTON)
}
this.init()
}
init () {
//
}
}
const ExampleInit = (config) => {
new Example(config)
}
export default ExampleInit