This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parentElement = document.querySelector('.card'); | |
document.addEventListener('click', (event) => { | |
// option 1 | |
const isClickInside = parentElement.contains(event.target); | |
if (!isClickInside) // click outside | |
// option 2 | |
const isNested = event.target.closest('.card') == parentElement; | |
if (!isNested) // click outside |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Find primary site's entry by path and return translated variant */ | |
public function getEntryByDefaultPath($defaultPath) | |
{ | |
$primaryHandle = Craft::$app->getSites()->getPrimarySite()->handle; | |
$currentHandle = Craft::$app->getSites()->getCurrentSite()->handle; | |
$primaryEntry = \craft\elements\Entry::find()->site($primaryHandle)->uri($defaultPath)->one(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @return array | |
*/ | |
public function getFilters() | |
{ | |
return [ | |
new TwigFilter('find', [$this, 'array_find']), | |
new TwigFilter('findIndex', [$this, 'array_find_index']), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resolveLocale(url, segmentIndex, defaultLanguage = 'en') { | |
const segments = url.split('/'); | |
// look for either ISO 3166-1 alpha-2 or combined with ISO 3166-2 | |
const pattern = /\b\w{2}(-\w{2})?\b/gim; | |
return (segmentIndex < segments.length && pattern.test(segments[segmentIndex])) | |
? segments[segmentIndex] | |
: defaultLanguage; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { STRING_MESSAGES } from '../components/comet-chat-components/utils/messageConstants'; | |
import { DA_MESSAGES } from '../i18n/da'; | |
import { DE_MESSAGES } from '../i18n/de'; | |
import { EN_MESSAGES } from '../i18n/en'; | |
import { ES_MESSAGES } from '../i18n/es'; | |
import { FR_MESSAGES } from '../i18n/fr'; | |
import { HU_MESSAGES } from '../i18n/hu'; | |
import { IT_MESSAGES } from '../i18n/it'; | |
import { NL_MESSAGES } from '../i18n/nl'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for language in languages|sort((a, b) => [b.selected, a.title] <=> [a.selected, b.title]) %} | |
<div class="{{ language.selected ? 'selected' }}">{{ language.title }}</div> | |
{% endfor %} | |
{# The order of properties determines priority #} | |
{# The order of a or b determines ASC or DESC sorting #} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as users from "/cometchat-users.json"; | |
import * as press from "/press.json"; | |
import * as dealers from "/dealers.json"; | |
import fuzzysort from "fuzzysort"; | |
const toName = (item) => ({ | |
name: item.firstName + " " + item.lastName, | |
...item, | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function domReady(callback) { | |
if (['interactive', 'complete'].includes(document.readyState)) { | |
callback(); | |
} else { | |
document.addEventListener('DOMContentLoaded', callback); | |
} | |
} | |
domReady(() => { | |
if (!document.body) return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {Number} time in seconds | |
**/ | |
export function secondsToObject(time) { | |
const hours = Math.floor(time / 3600); | |
const minutes = Math.floor((time - hours * 3600) / 60); | |
const seconds = Math.floor(time - minutes * 60); | |
return { hours, minutes, seconds }; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* (de)serialize an object to a search string, like ?key=value&other=more | |
**/ | |
export function getSearchValues(key: string) { | |
const params = new URLSearchParams(location.search); | |
return params.get(key); | |
} | |
export function setSearchParams(key: string, value: any, push = false) { |