Skip to content

Instantly share code, notes, and snippets.

View jasondmoss's full-sized avatar
😗

Jason D. Moss jasondmoss

😗
View GitHub Profile
/**
* @file
*
* Module: Toggle.
*
* @author Jason D. Moss <jason@jdmlabs.com>
* @copyright 2024 Jason D. Moss. All rights reserved.
*/
import { Exists } from "./exists.js";
@jasondmoss
jasondmoss / accordian.js
Last active March 17, 2024 15:03
Custom Web Component to 'progressively enhance' the <details> element.
/**
* Custom Web Component to 'progressively enhance' the <details> element used
* with our form filters.
*
* @author Jason D. Moss <jason@jdmlabs.com>
* @copyright 2024 Jason D. Moss. All rights reserved.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_components
*
* <details>
@jasondmoss
jasondmoss / simpleXmlToArray.php
Last active June 22, 2022 21:12
Convert a SimpleXML object to associative array
<?php
/**
* Convert a SimpleXML object to an associative array
*
* @param object $xmlObject
*
* @return array
* @access public
*/
@jasondmoss
jasondmoss / stripNamespaceFromClassName.php
Last active February 18, 2021 00:06
Strip the namespace from the class to get the actual class name
<?php
/**
* Strip the namespace from the class to get the actual class name
*
* @param string $obj Class name with full namespace
*
* @return string
* @access public
*/
@jasondmoss
jasondmoss / screen-reader-style.css
Last active December 10, 2019 03:59 — forked from ffoodd/improved-sr-only.markdown
Text meant only for screen readers
.reader,
.sr-only,
.text-assistive {
clip: rect(0 0 0 0);
overflow: hidden;
position: absolute;
width: 1px;
height: 1px;
margin: -1px;
padding: 0;
@jasondmoss
jasondmoss / includes.js
Last active December 10, 2019 03:52
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `String.prototype.includes()`
*
* @param {String} String to search for.
* @param {Integer} Start search at 'this' position.
*
* @return {Boolean}
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
*/
@jasondmoss
jasondmoss / closest.js
Last active December 10, 2019 03:52
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `Element.prototype.closest()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
*/
if (!Element.prototype.closest) {
Element.prototype.closest = function (s) {
"use strict";
var el = this;
@jasondmoss
jasondmoss / starts-with.js
Created December 10, 2019 03:52
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `String.prototype.startsWith()`
*
* @return {Boolean}
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
*/
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, "startsWith", {
value: function (search, pos) {
@jasondmoss
jasondmoss / replace-with.js
Last active December 10, 2019 03:51
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `ChildNode.replaceWith()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/replaceWith
*/
function replaceWith()
{
"use-strict";
var parent = this.parentNode;
@jasondmoss
jasondmoss / matches.js
Created December 10, 2019 03:48
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `Element.prototype.matches()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
*/
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}
/* <> */