Skip to content

Instantly share code, notes, and snippets.

View SirPepe's full-sized avatar

Peter Kröner SirPepe

View GitHub Profile
<component lightWeight="true">
<attach event="onpropertychange" onevent="checkPropertyChange()" />
<attach event="ondetach" onevent="restore()" />
<attach event="onresize" for="window" onevent="restore();init()" />
<script type="text/javascript">
//<![CDATA[
var viewportwidth = (typeof window.innerWidth != 'undefined' ? window.innerWidth : element.document.documentElement.clientWidth);
// Shortcut for the document object
var doc = element.document;
@SirPepe
SirPepe / curry.js
Created July 14, 2011 21:23
JavaScript Curry
Function.prototype.curry = function(){
if(arguments.length < 1) return this;
var args = Array.prototype.slice.call(arguments),
method = this;
return function(){
return method.apply(this, args.concat(Array.prototype.slice.call(arguments)));
}
}
/* Source: http://nicolasgallagher.com/micro-clearfix-hack/ */
/* For modern browsers */
.cf:before,
.cf:after {
content:"";
display:table;
}
.cf:after {
@SirPepe
SirPepe / CanvasQuery.js
Created August 2, 2010 19:06
Micro canvas framework
// Init boilerplate
function CanvasQuery(c){
"use strict";
if(!(this instanceof CanvasQuery)) return new CanvasQuery(c);
if(typeof c == "string"){
var canvas = document.getElementById(c);
if(!canvas) throw new Error("Canvas element #" + c + " doesn't exist");
}
if(typeof canvas == "undefined"){
if(c.getContext) canvas = c;