Skip to content

Instantly share code, notes, and snippets.

View arielsalminen's full-sized avatar
🌸

Ariel Salminen arielsalminen

🌸
View GitHub Profile
@arielsalminen
arielsalminen / addEventListener-polyfill.js
Created June 6, 2012 10:48 — forked from eirikbacker/addEventListener-polyfill.js
addEventListener polyfill for IE6+
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}
@arielsalminen
arielsalminen / insertAdjacentHTML.js
Created June 6, 2012 18:01 — forked from eligrey/insertAdjacentHTML.js
insertAdjacentHTML polyfill
/*
* insertAdjacentHTML.js
* Cross-browser full HTMLElement.insertAdjacentHTML implementation.
*
* 2011-10-10
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@arielsalminen
arielsalminen / new.scrolltotop.js
Created June 8, 2012 12:07
Got rid of the jQuery library on http://viljamis.com and this is a short comparison between the old and new.
/*!
* viljamis.com/projects/ v1.6
* http://viljamis.com
* Copyright (c) 2011-2012 @viljamis
*/
// Get current position
function currentYPosition() {
// Firefox, Chrome, Opera, Safari
if (self.pageYOffset) {
// Variables
var hasTouch = false,
ua = navigator.userAgent,
docEl = document.documentElement;
// Clear html classes and add "js" class
docEl.className = "";
docEl.className += " js";
// Determine if the device supports touch
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@arielsalminen
arielsalminen / 2col_masonry_layout.html
Last active October 15, 2016 21:22
Easily turn simple 1-column layout into a fluid 2-column masonry layout without JS plugins. Works even in IE6! Check the live example here: http://viljamis.com/columns/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>2-column fluid masonry layout without JS plugins</title>
<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<style>
body {
text-align: center;
padding: 3% 8%;
function hasPlaceHolder() {
return 'placeholder' in document.createElement('input');
}
function html5forms() {
var formPlaceholder = hasPlaceHolder();
if (formPlaceholder === false) {
$('input[type=text]').each(function() {
if($(this).attr('placeholder')) {
var placeholderText = $(this).attr('placeholder');
@arielsalminen
arielsalminen / getElementsByClassName.js
Created March 4, 2013 20:55
A cross browser way to get elements by class name by Robert Nyman
/*
Developed by Robert Nyman, http://www.robertnyman.com
Code/licensing: http://code.google.com/p/getelementsbyclassname/
*/
var getElementsByClassName = function (className, tag, elm){
if (document.getElementsByClassName) {
getElementsByClassName = function (className, tag, elm) {
elm = elm || document;
var elements = elm.getElementsByClassName(className),
nodeName = (tag)? new RegExp("\\b" + tag + "\\b", "i") : null,
@arielsalminen
arielsalminen / nav.html
Last active December 14, 2015 12:18
Simple responsive navigation toggle script without library dependencies and with touch screen support (349 bytes minified and gzipped). Live demo: http://codepen.io/viljamis/full/gAatl
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<title>Nav toggle</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<ol id="nav" class="closed">
<li class="active"><a href="#">Home</a></li>
@arielsalminen
arielsalminen / gist:5432823
Created April 22, 2013 06:27
Responsive-nav.js together with other jQuery plugins/jQuery library.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Responsive Nav with jQuery</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="styles.css">
<script src="jquery.js"></script>
<script src="responsive-nav.js"></script>
<script src="responsive-slides.js"></script>