Skip to content

Instantly share code, notes, and snippets.

@GCheung55
GCheung55 / gist:73988
Created March 4, 2009 20:31 — forked from divoxx/gist:73976
dispatch some method everytime a dom change
var reapplyTimeoutId = null
$each(['insertBefore', 'replaceChild', 'removeChild', 'appendChild'], function(methodName) {
Node.prototype["_" + methodName] = Node.prototype[methodName]
Node.prototype[methodName] = function() {
var ret = this["_" + methodName](arguments[0], arguments[1])
if (reapplyTimeoutId) { clearTimeout(reapplyTimeoutId) }
reapplyTimeoutId = setTimeout(Attitude.applyDefinitions.bind(Attitude), 100)
return ret
}
Fx.Scroll.implement({
scrollToCenter: function(el, axes, offset){
axes = axes ? $splat(axes) : ['x', 'y'];
el = $(el);
var to = {},
pos = el.getPosition(this.element),
size = el.getSize(),
scroll = this.element.getScroll(),
containerSize = this.element.getSize(),
edge = {
@GCheung55
GCheung55 / gist:158806
Created July 30, 2009 17:47
MooPubSubBroker
/*
* Converted from: http://blog.narcvs.com/?p=43
*/
var MooPubSubBroker = new Class({
Implements: [Options, Events],
options:{},
initialize: function(args, options){
// -*- Mode: Javascript; tab-width: 4; -*-
/*
---
privides: [String.bound, String.prototype.bind]
description: Lets you bind to a method that doesn't exist yet, and then swap out methods without re-wiring all your codez
author: Thomas Aylott <subtlegradient.com>
copyright: 2009 Thomas Aylott
license: MIT Style
...
*/
@GCheung55
GCheung55 / Collection.js
Created December 2, 2009 23:37 — forked from keeto/Collection.js
Collection Native
function Collection(list){
this.list = $splat(list || []);
this.length = this.list.length;
};
new Native({name: 'Collection', initialize: Collection, generics: false});
(function() {
// Some browsers don't iterate over natives, so brute force is required.
/*
---
source: http://gist.github.com/133677
provides: document.write
description: MooTools based document.write replacement
requires: MooTools
author: Thomas Aylott -- SubtleGradient.com
thanks: Daniel Steigerwald -- daniel.steigerwald.cz
@GCheung55
GCheung55 / lightBoxOverlay.js
Created December 1, 2010 04:45
A really simple lightbox overlay MooTools Class.
// Lightbox Overlay
var LightBoxOverlay = new Class({
Implements: [Options, Events],
options:{
tag: 'div',
properties: {
id: 'lightbox_overlay',
'class': 'hide'
}
},
window.store('testCode', 'What is up?');
@GCheung55
GCheung55 / Queue.js
Created February 15, 2011 23:16 — forked from cpojer/Queue.js
cpojer's Queue (Chain)
(function(){
this.Queue = new Class({
Extends: Chain,
call: function(){
if (this.busy) return this;
this.busy = true;
@GCheung55
GCheung55 / gist:971178
Created May 13, 2011 19:39
Dynamic arguments to instantiate Class. Thanks Keeto!
Class.instantiate = function(C){
C.$prototyping = true;
var instance = new C;
delete C.$prototyping;
return instance;
};