mirror of
https://github.com/home-assistant/frontend.git
synced 2025-06-21 09:36:33 +00:00

* Move computeDomain and format functions to js * Add tests for computeStateDisplay * Always recalculate state display * Remove LANGUAGE from hassUtils object * Move AppLocalizeBehavior import to mixins * Import mixins to state-card-display * Safety check on computeStateDisplay * Don't store computed domains on stateObj * Integration tests for state-card-display * Include extractDomain code in polymer repo * Remove util function null checking * Dont render test element without hass and stateObj * Revert "Don't store computed domains on stateObj" This reverts commit e3509d71823ff5e42a4dcf4849a98c5bb6cb391c. * Revert "Always recalculate state display" This reverts commit 27c24e2694ee6f7c147782532268b3a67998d49b.
29 lines
1.2 KiB
JavaScript
29 lines
1.2 KiB
JavaScript
/**
|
|
* Export hass util functions to window.
|
|
*
|
|
* This file is a workaround for the fact that Polymer 2 doesn't work well with
|
|
* ES6 JS imports. Once we move to Polymer 3, we should be able to simply
|
|
* import these functions where we need them.
|
|
*/
|
|
|
|
import attributeClassNames from './common/util/attribute_class_names';
|
|
import computeDomain from './common/util/compute_domain';
|
|
import computeStateDisplay from './common/util/compute_state_display';
|
|
import formatDate from './common/util/format_date';
|
|
import formatDateTime from './common/util/format_date_time';
|
|
import formatTime from './common/util/format_time';
|
|
|
|
window.hassUtil = window.hassUtil || {};
|
|
|
|
const language = navigator.languages ?
|
|
navigator.languages[0] : navigator.language || navigator.userLanguage;
|
|
|
|
window.fecha.masks.haDateTime = window.fecha.masks.shortTime + ' ' + window.fecha.masks.mediumDate;
|
|
|
|
window.hassUtil.attributeClassNames = attributeClassNames;
|
|
window.hassUtil.computeDomain = computeDomain;
|
|
window.hassUtil.computeStateDisplay = computeStateDisplay;
|
|
window.hassUtil.formatDate = dateObj => formatDate(dateObj, language);
|
|
window.hassUtil.formatDateTime = dateObj => formatDateTime(dateObj, language);
|
|
window.hassUtil.formatTime = dateObj => formatTime(dateObj, language);
|