Skip to content

Instantly share code, notes, and snippets.

View ralphholzmann's full-sized avatar

Ralph Holzmann ralphholzmann

View GitHub Profile
// Rough implementation, untested, etc
// Will obviously fail when non-overridden methods are used to change the DOM
(function($){
$.fn.isAncestorOf = function( elem ) {
// If parent and child element are the same, return false
if (this[0] == elem[0]) return false;
(function($){
function domchanged(methods, type) {
$.each( methods.split(' '), function( i, method ) {
// Store a reference to the original method.
var orig = $.fn[ method ];
// Override the original method.
$.fn[ method ] = function(){
var args = arguments,
$.fn.fadeSwap = function(content, callback) {
// Return each ...
return this.each( function() {
// Save reference to this
var $this = $(this);
// Fade to 0
$this.animate({
// Opacity fixes for IE
var alphaRegex = /^alpha\(opacity=(\d+)\)$/i;
$.each(['fadeIn', 'fadeOut'], function(i, method){
var _fn = $.fn[method];
$.fn[method] = function(easing, callback) {
alert('here');
if ( $.browser.msie && ( ! this[0].style.filter || alphaRegex.test( this[0].style.filter ))) {
function FBReady( func ) {
// If facebook is already loaded,
// just call the function
if ( FBReady.done ) return func();
// If the stack already exists,
// push the function onto it,
// otherwise, initialize a stack
// of functions
@ralphholzmann
ralphholzmann / jQuery Placeholder.js
Created September 8, 2010 19:40
This is what I use now
(function( $ ){
$.fn.placeholder = function() {
var id = 0;
return this.data('placeholder') ? this : this.each(function(){
// Create label
var $this = $(this)
, label = (function( props ) {
@ralphholzmann
ralphholzmann / jQuery immediate ready.js
Created November 4, 2010 19:36
Allows you to bind to jQuery.ready before jQuery has been loaded
// Bind functions to dom ready before jQuery has been loaded
// This only works if line 83 from jQuery 143 is changed from
// readyList = [],
// to
// readyList = window.jQuery.readyList || [],
(function(){
jQuery = $ = function( fn ) {
return typeof fn === "function" ?
jQuery.readyList.push( fn ) :
@ralphholzmann
ralphholzmann / iframe-facebook.js
Created November 13, 2010 19:44
Modernizr tests to detect if you're in an iframe or facebook iframe
Modernizr
.addTest('iframe', function() {
return window.top.location != window.location;
})
.addTest('facebook', function() {
return !! ~ location.href.indexOf( 'fb_sig_in_iframe=1' );
});
/**
* Yepnope JS
*
* Version 0.2.6pre
*
* by Alex Sexton - AlexSexton@gmail.com
*
* Tri-Licensed WTFPL, BSD, & MIT
*/
(function(window, doc, undef) {
DropboxClient.prototype.putFile = function(file, path, optargs, cb) {
if (typeof optargs == 'function') cb = optargs, optargs = {};
var boundary = 'sAxIqse3tPlHqUIUI9ofVlHvtdt3tpaG',
content_type = 'multipart/form-data; boundary=' + boundary,
self = this;
require('fs').readFile(file, function (err, data) {
if (err) return cb(err);
// Build request body.
path = escapePath(path);