Skip to content

Instantly share code, notes, and snippets.

View patrickfox's full-sized avatar
🦊

Patrick Fox patrickfox

🦊
  • Razorfish
  • Austin, TX
View GitHub Profile
/*
# announce_view_loaded
Requirements:
- An element with `data-page-title` whose:
- text content is the page title: `<h2 data-page-title="">About Us</h2>` -> "About Us" will be used
- value is the page title: `<h3 data-page-title="Real page title">Displayed Heading</h3>` -> "Real page title" will be used
- An announcer element with an ID of `a11y_announcer` - this element needs to be in the DOM at page load and left alone (e.g. not destroyed or moved)
const site_title = '{Your site's name/title} - ';
@aminimalanimal
aminimalanimal / Debugging: Focus: on focus and blur, log document.activeElement.js
Last active October 21, 2022 17:35
Debugging: Focus: on focus and blur, log document.activeElement
/* Non-jQuery, ES6 version. This won't definitely work in older browsers */
/* Short ES6 version (for single-line copy/pasting) */
const everything = document.querySelectorAll('*'); function trackEvent(event) { event.stopPropagation(); var eventType = event.type, eventTarget = event.target, activeElement = document.activeElement; setTimeout(function() { console.group(eventType); console.log('event.target:'); console.log(eventTarget); console.log('document.activeElement (immediate):'); console.log(activeElement); console.log('document.activeElement (after cycle completion):'); console.log(document.activeElement); console.groupEnd(); }, 0); }; ['click', 'focus', 'blur'].forEach((eventType) => { everything.forEach((el) => el.addEventListener(eventType, trackEvent));});
/* Expanded ES6 version (for editing/understanding) */
const everything = document.querySelectorAll('*');
function trackEvent(event) {
@ericelliott
ericelliott / essential-javascript-links.md
Last active May 17, 2024 03:38
Essential JavaScript Links
@Chaser324
Chaser324 / GitHub-Forking.md
Last active June 16, 2024 07:13
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j

(function($) {
function visible(element) {
return $.expr.filters.visible(element) && !$(element).parents().addBack().filter(function() {
return $.css(this, 'visibility') === 'hidden';
}).length;
}
function focusable(element, isTabIndexNotNaN) {
var map, mapName, img, nodeName = element.nodeName.toLowerCase();
if ('area' === nodeName) {
@lavoiesl
lavoiesl / object.create.js
Created September 20, 2013 18:49
Javascript Object.create() polyfill
// http://jsperf.com/new-vs-object-create-including-polyfill
if (typeof Object.create !== 'function') {
Object.create = function(o, props) {
function F() {}
F.prototype = o;
if (typeof(props) === "object") {
for (prop in props) {
if (props.hasOwnProperty((prop))) {
F[prop] = props[prop];
@bminer
bminer / changeTypeAttr.js
Created August 31, 2012 21:30
Cross-browser solution for changing the 'type' attribute of an `<input/>` tag.
/* x is the <input/> element
type is the type you want to change it to.
jQuery is required and assumed to be the "$" variable */
function changeType(x, type) {
if(x.prop('type') == type)
return x; //That was easy.
try {
return x.prop('type', type); //Stupid IE security will not allow this
} catch(e) {
//Try re-creating the element (yep... this sucks)