Skip to content

Instantly share code, notes, and snippets.

:octocat:
Turtle hunting

Matijs Brinkhuis matijs

Block or report user

Report or block matijs

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View postforms.js
/*
Show a progress element for any form submission via POST.
Prevent the form element from being submitted twice.
*/
(function ( win, doc ) {
'use strict';
if ( !win.addEventListener ) {
// doesn't cut the mustard.
return;
}
View keybase.md

Keybase proof

I hereby claim:

  • I am matijs on github.
  • I am matijs (https://keybase.io/matijs) on keybase.
  • I have a public key whose fingerprint is F561 2602 AC9A 189A 0894 19D2 1D57 5FD0 310D EF84

To claim this, I am signing this object:

View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Overlay modals</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="overlay align-top">
@matijs
matijs / hasTransforms.js
Created Aug 6, 2014
feature detect css transforms
View hasTransforms.js
var hasTransforms = (function() {
var propNames = ["transform", "MozTransform", "webkitTransform", "msTransform"];
var i = 0;
var length = propNames.length;
for (; i < length; i++) {
if (typeof document.documentElement.style[propNames[i]] === "string") return true;
}
return false;
}());
View getScrollingElement.js
/*
* How to get the scrolling element in charge of scrolling the viewport:
*
* - in Quirks mode the scrolling element is the "body"
* - in Standard mode the scrolling element is the "documentElement"
*
* webkit based browsers always use the "body" element disrespectfull of the specifications:
* http://dev.w3.org/csswg/cssom-view/#dom-element-scrolltop
*/
function getScrollingElement() {
@matijs
matijs / click-handler.js
Last active Aug 29, 2015
jQuery-based method for handling clicks declared with a data-attribute
View click-handler.js
$(function() {
'use strict';
// generic click handler
$(document).on('click', '[data-handler]', function(event) {
var handler = this.getAttribute('data-handler');
// honour default behaviour when using modifier keys when clicking
// for example:
// cmd + click / ctrl + click opens a link in a new tab
// shift + click opens a link in a new window
if (this.tagName === 'A' && (event.metaKey || event.ctrlKey || event.shiftKey)) {
@matijs
matijs / enhancer.js
Created Nov 18, 2014
jQuery-based enhancing of components / elements declared with a data-attribute
View enhancer.js
$(function() {
'use strict';
// kick off js enhancements
$('[data-enhancer]').each(function() {
var enhancer = this.getAttribute('data-enhancer');
if (enhancers && typeof enhancers[enhancer] === 'function') {
enhancers[enhancer].call(this);
}
else {
if (window.console && typeof console.log === 'function') {
@matijs
matijs / loadCSS.js
Created Feb 23, 2015
load CSS using JS
View loadCSS.js
function loadCSS(href, options){
'use strict';
options = options || {};
var styleSheet = document.createElement('link');
var ref = options.before || document.getElementsByTagName('script')[0];
styleSheet.media = 'not all';
styleSheet.rel = 'stylesheet';
styleSheet.href = href;
styleSheet.onload = function () {
styleSheet.onload = null; // only run once
@matijs
matijs / slow_server.py
Created Feb 25, 2015
Enhanced Python SimpleHTTPServer to slowly serve a specific mimetypes
View slow_server.py
"""Simple HTTP Server.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
__version__ = "0.6"
View index.html
<p>
<a href="#" class="button">Foo Bar</a>
<button type="button" class="button">Baz Quux</button>
</p>
You can’t perform that action at this time.