/*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) {
		console.error('Missing element or configuration for app header.');
	}
	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;

/*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 an incorrectly structured event or missing e.detail.element and/or e.detail.config');
	}
	
	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;

Change event error to event warning.
refactor: Change event error to event warning.
