-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
36 lines (25 loc) · 833 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*global require, module*/
'use strict';
// bundled styling for app-header
require('./main.scss');
var AppHeader = require('./src/js/AppHeader');
var instance;
var getOrCreateInstance = function (element, options) {
if (!instance) {
instance = new AppHeader(element, options);
return instance;
}
return instance.setMode(options.mode, options);
};
var construct = function (e) {
if (!e.detail || !e.detail.element || !e.detail.config) {
window.console && console.warn('AppHeader received event missing e.detail.element and/or e.detail.config');
return;
}
getOrCreateInstance(e.detail.element, e.detail.config);
};
document.addEventListener('o.DOMContentLoaded', construct);
module.exports = function (element, options) {
return getOrCreateInstance(element, options);
};
module.exports.init = AppHeader.init;