Skip to content

Instantly share code, notes, and snippets.

var ProForm = (function(){
/*
* IE 6 & 7 cannot handle dynamic radio and checkboxes correctly.
*/
BROWSER_SUCKS = (function (){
var sucks = false;
if(Prototype.Browser.IE){
version_number = navigator.appVersion.match(/MSIE\s(\d+)/);
/**
* Methods for extending Prototype
*/
var Position = {
/**
* Centers an element against the parent or body
* parent should be display: relative
*/
center: function(elem, parent){
Element.addMethods('FORM', {
clone: function(form, id){
// if no id was passed use native clone
if( ! Object.isString(id) ) return Element.clone(form, id);
var form = Element.clone(form, true);
form.writeAttribute('id', id);
// change elements with id attr
(function(){
function loaded(elem){
var elem = $(elem);
var images = elem.retrieve('loadingImages', elem.select('img'));
var loading = images.find(function(elem){
return !elem.complete;
});
if(loading) return loaded.delay(.3, elem);
else {elem.fire('images:loaded'); elem.store('loadingImages', undefined);}
return elem;
@diago
diago / gist:331054
Created March 13, 2010 02:23
snipmate Class.create()
# Class
snippet pcc
var ${1:ClassName} = (
var $1 = Class.create();
$1.Version = ${2:'1.0.0'};
$1.options = {${4}};
$1.prototype = {
var Dispatcher = (function(){
var Dispatcher = Class.create();
Dispatcher.Version = '1.0.0';
Dispatcher.options = {};
Dispatcher.instance = undefined;
Dispatcher.prototype = {
var dispatch = {
events: {},
observe: function(action){
this.events[action] = {};
document.observe(action, function(ev){
for(var x in dispatch.events[action]){
if(ev.findElement(x)) return dispatch.events[action][x](ev);
}
});
@diago
diago / ajax-extend.js
Created December 7, 2010 14:27
Extending Jquery functions
// jQuery Extended
var $ajax = $.ajax;
$.ajax = function(options){
var options = $.extend({cache: false}, options || {});
return $ajax(options);
}
@diago
diago / Gemfile
Created April 5, 2011 13:31
Padrino Gemfile
source :rubygems
# Project requirements
gem 'rake'
gem 'rack-flash'
gem 'thin' # or mongrel
# Component requirements
gem 'bcrypt-ruby', :require => "bcrypt"
gem 'compass'
@diago
diago / spec_helper.rb
Created April 5, 2011 13:36
Padrino Rspec Config
PADRINO_ENV = 'test' unless defined?(PADRINO_ENV)
require 'rubygems'
require 'spork'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
require File.expand_path(File.dirname(__FILE__) + "/../config/boot")