Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Florence ryanflorence

View GitHub Profile
View Element.EmbedShell.js
// http://mooshell.net/tbdZW/
(function(){
var parseDimensions = function(element){
var array = element.get('class').match(/mooshell:[0-9]+:?([0-9]+)?/)[0].split(':');
var dimensions = { height: array[1] };
dimensions.width = (array[2]) ? dimensions.width = array[2] : '100%';
return dimensions;
};
View HashEvents.js
var HashEvents = new Class({
Implements: [Options, Events],
options: {
/*
onChange: $empty,
*/
delimiter: '&',
poll: 200
@ryanflorence
ryanflorence / Class.Mutators.jQuery.js
Created Feb 21, 2010
With MooTools Native and Class modules you can write MooTools classes with jQuery
View Class.Mutators.jQuery.js
(function(){
Class.Mutators.jQuery = function(name){
var self = this;
jQuery.fn[name] = function(arg){
var args = Array.prototype.slice.call(arguments, 1);
if ($type(arg) == 'string'){
var instance = jQuery(this).data(name);
if (instance) instance[arg].apply(instance, args);
View Class.Mutators.jQuery.js
Class.Mutators.jQuery = function(name){
var self = this;
jQuery.fn[name] = function(arg){
if ($type(arg) == 'string'){
var instance = this.data(name);
if($type(instance[arg]) == 'function'){
var returns = instance[arg].apply(instance, Array.slice(arguments, 1));
return (returns == instance) ? this : returns;
}
if(arguments[1] != null){
@ryanflorence
ryanflorence / Database.js
Created Mar 7, 2010
Hypothetical HTML5 Database Interface with MooTools
View Database.js
// create a database
var myDB = new DB('html5_database_with_mootools',{
adapter: 'html5'
/*
// gears?
adapter: 'gears',
// node.js ?
adapter: 'MySQL'
user: 'root',
@ryanflorence
ryanflorence / Override.rb
Created Mar 16, 2010
Self-referential model with has_many :through, Rails
View Override.rb
class Override < ActiveRecord::Base
belongs_to :recruiter, :class_name => "Rep"
belongs_to :signer, :class_name => "Rep"
end
View MultiPageApp.js
// app reflects server-side pages
var App = {
Store: {
Index: {},
Product: {},
Category: {},
ContentPage: {}
}
};
View AnonymousTransition.js
['pushTest2', function(previous, next, duration, instance){
var distance = instance.element.getStyle('width').toInt();
next.setStyle('left', distance);
new Fx.Elements.start({
0: { left: [-distance] },
1: { left: [0] }
});
return this;
}],
View hashchange.js
/*!
* Copyright yayQuery Peoples, 2010
*
* Licensed under the MIT license
* http://www.opensource.org/licenses/mit-license.php
*
* This plugin is loosely based on Ben Almans BBQ Plugin, but without the extra fluff. Just
* plain onhashchange cross-browser support through jQuery Special Event API.
*
* http://yayquery.com/ - http://github.com/yayquery/
View Browser.Features.extras.js
/*
---
script: Browser.Features.extras
description: Taken directly from jQuery 1.4.2 and adapted for MooTools. A collection of properties that represent the presence of different browser features or bugs.
license: MIT-style license.
authors: "The jQuery Core Developers", Ryan Florence (http://ryanflorence.com)