Created
January 5, 2010 14:32
-
-
Save fakedarren/269406 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.Attributes.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
Native.implement([Element, Window, Document], { | |
attr: function(attr, val){ | |
if (!$defined(val)){ | |
return $type(attr) == 'string' ? this.getProperty(attr) : this.setProperties(attr); | |
} else if ($type(val) == 'function'){ | |
return this.setProperty(attr, val.call(this)); | |
} else { | |
return this.setProperty(attr, val); | |
} | |
}, | |
removeAttr: function(attr){ | |
return this.removeProperty(attr);; | |
}, | |
/* Class (ALREADY IMPLEMENTED IN MOOTOOLS) | |
addClass: function() | |
removeClass: function() | |
toggleClass: function() | |
*/ | |
html: function(html){ | |
if ($defined(html)){ | |
return this.set('html', html); | |
} else { | |
return this.get('html'); | |
} | |
}, | |
text: function(text){ | |
if ($defined(text)){ | |
return this.set('text', text); | |
} else { | |
return this.get('text'); | |
} | |
}, | |
val: function(val){ | |
if (!$defined(val)){ | |
return this.get('value'); | |
} else { | |
return this.set('value', val); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.Core.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
jQuery = function(selector){ | |
if ($type(selector) == 'function'){ | |
return window.addEvent('domready', selector); | |
} else { | |
jQuery.cache = $$(selector); | |
return $$(selector); | |
} | |
}; | |
jQuery.cache = null | |
jQuery.extend = function(obj){ | |
for (key in obj){ | |
this[key] = obj[key]; | |
} | |
Element.implement(obj); | |
return this; | |
}; | |
jQuery.fn = {} | |
Element.implement({ | |
data: function(key, val){ | |
return val != null ? this.store(key, val) : this.retrieve(key); | |
}, | |
removeData: function(key){ | |
return this.store(key, null); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.CSS.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
Native.implement([Element, Window, Document], { | |
// CSS | |
css: function(val1, val2) { | |
if($type(val1) == 'object') | |
return this.setStyles(val1); | |
else | |
return $defined(val2) ? | |
this.setStyle(val1, val2) : | |
this.getStyle(val1); | |
}, | |
// Positioning | |
offset: function() { | |
var position = this.getPosition(); | |
return {top: position.y, left: position.x}; | |
} | |
}); | |
Element.implement({ | |
height: function(val) { | |
return $defined(val) ? | |
this.setStyle('height', val) : | |
this.getStyle('height'); | |
}, | |
width: function() { | |
return $defined(val) ? | |
this.setStyle('width', val) : | |
this.getStyle('width'); | |
}, | |
outerHeight: function(margins) { | |
return this.getHeight(); | |
}, | |
outerWidth: function() { | |
return this.getWidth(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.Effects.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
$extend(Fx.Durations, {'slow':1000 , 'fast': 250}); | |
Native.implement([Element, Window, Document], { | |
show: function(speed, cb) { | |
return this.set('tween', { | |
duration: 0 | |
}).fade('show'); | |
}, | |
hide: function(speed, cb) { | |
return this.set('tween', { | |
duration: 0 | |
}).fade('hide'); | |
}, | |
toggle: function() { | |
return this.set('tween', { | |
duration: 0 | |
}).fade('toggle'); | |
}, | |
slideDown: function(speed, cb) { | |
if(!$defined(cb)) | |
this.set('slide', { | |
duration: speed || 1000, | |
onComplete: $empty | |
}); | |
else | |
this.set('slide', { | |
duration: speed || 1000, | |
onComplete: function(eff) { | |
cb.call(eff); | |
} | |
}); | |
return this.slide('in'); | |
}, | |
slideUp: function(speed, cb) { | |
if(!$defined(cb)) | |
this.set('slide', { | |
duration: speed || 1000, | |
onComplete: $empty | |
}); | |
else | |
this.set('slide', { | |
duration: speed || 1000, | |
onComplete: function(eff) { | |
cb.call(eff); | |
} | |
}); | |
return this.slide('out'); | |
}, | |
slideToggle: function(speed, cb) { | |
if(!$defined(cb)) | |
this.set('slide', { | |
duration: speed || 1000, | |
onComplete: $empty | |
}); | |
else | |
this.set('slide', { | |
duration: speed || 1000, | |
onComplete: function(eff) { | |
cb.call(eff); | |
} | |
}); | |
return this.slide('toggle'); | |
}, | |
fadeIn: function(speed, cb) { | |
if(!$defined(speed)) return this.fadeTo('normal', 1, $empty); | |
else return this.fadeTo(speed, 1, cb || $empty); | |
}, | |
fadeOut: function(speed, cb) { | |
if(!$defined(speed)) return this.fadeTo('normal', 0, $empty); | |
else return this.fadeTo(speed, 0, cb || $empty); | |
}, | |
fadeTo: function(speed, opacity, cb) { | |
if(!$defined(cb)) | |
this.set('tween', { | |
duration: speed, | |
onComplete: $empty | |
}).tween('opacity', opacity); | |
else | |
this.set('tween', { | |
duration: speed, | |
onComplete: function(eff) { | |
cb.call(eff); | |
} | |
}).tween('opacity', opacity); | |
return this; | |
}, | |
/*animate: function(params, dur, easing, cb) { | |
}//,*/ | |
animate: function(params, duration, easing, callback) { | |
if($type(duration) == 'object') | |
this.set('morph', duration); | |
else if(!$defined(easing)) | |
this.set('morph', { | |
duration: duration, | |
transition: Fx.Transitions.Sine.easeInOut, | |
onComplete: $empty | |
}); | |
else if(!$defined(callback)) | |
this.set('morph', { | |
duration: duration, | |
transition: easing, | |
onComplete: $empty | |
}); | |
else | |
this.set('morph', { | |
duration: duration, | |
transition: easing, | |
onComplete: callback | |
}); | |
return this.morph(params); | |
}, | |
stop: function() { | |
return this.get('morph').cancel(); | |
}, | |
queue: function(cb) { | |
alert('queue() - Not implemented yet'); | |
return this; | |
}, | |
dequeue: function() { | |
alert('dequeue() - Not implemented yet'); | |
return this; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.Events.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
Native.implement([Element, Window, Document], { | |
// Page Load | |
ready: function(fn) { | |
return this.addEvent('domready', fn); | |
}, | |
// Event Handling | |
bind: function(type, data, fn) { | |
return this; | |
}, | |
one: function(type, data, fn) { | |
if(!$defined(fn)) fn = data; | |
return this.addEvent(type, function() { | |
if(!$defined(this.retrieve(type + 'OnceEvent'))) { | |
this.store(type + 'OnceEvent', true); | |
fn.call(this); | |
} | |
}); | |
}, | |
trigger: function(type, data) { | |
this.fireEvent(type); | |
}, | |
triggerHandler: function(type, data) { | |
return this; | |
}, | |
unbind: function(type, data) { | |
this.removeEvent(type); | |
}, | |
// Interaction Handlers | |
hover: function(over, out) { | |
return this.addEvents({ | |
'mouseenter': over, | |
'mouseleave': out | |
}); | |
}, | |
toggle: function(fn1, fn2) { | |
this.store('toggleEvent', false); | |
return this.addEvent('click', function() { | |
var state = this.retrieve('toggleEvent'); | |
state ? | |
fn2.call(this) : | |
fn1.call(this); | |
this.store('toggleEvent', !state); | |
}); | |
}, | |
// Event Helpers | |
blur: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('blur', fn) : | |
this.fireEvent('blur'); | |
}, | |
change: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('change', fn) : | |
this.fireEvent('change'); | |
}, | |
click: function(fn){ | |
return $defined(fn) ? | |
this.addEvent('click', fn) : | |
this.fireEvent('click'); | |
}, | |
dblclick: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('doubleclick', fn) : | |
this.fireEvent('doubleclick'); | |
}, | |
error: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('error', fn) : | |
this.fireEvent('error'); | |
}, | |
focus: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('focus', fn) : | |
this.fireEvent('focus'); | |
}, | |
keydown: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('keydown', fn) : | |
this.fireEvent('keydown'); | |
}, | |
keypress: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('keypress', fn) : | |
this.fireEvent('keypress'); | |
}, | |
keyup: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('keyup', fn) : | |
this.fireEvent('keyup'); | |
}, | |
load: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('load', fn) : | |
this.fireEvent('load'); | |
}, | |
mousedown: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('mousedown', fn) : | |
this.fireEvent('mousedown'); | |
}, | |
mousemove: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('mousemove', fn) : | |
this.fireEvent('mousemove'); | |
}, | |
mouseout: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('mouseout', fn) : | |
this.fireEvent('mouseout'); | |
}, | |
mouseup: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('mouseup', fn) : | |
this.fireEvent('mouseup'); | |
}, | |
resize: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('resize', fn) : | |
this.fireEvent('resize'); | |
}, | |
scroll: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('scroll', fn) : | |
this.fireEvent('scroll'); | |
}, | |
select: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('select', fn) : | |
this.fireEvent('select'); | |
}, | |
submit: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('submit', fn) : | |
this.fireEvent('submit'); | |
}, | |
unload: function(fn) { | |
return $defined(fn) ? | |
this.addEvent('unload', fn) : | |
this.fireEvent('unload'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.Manipulation.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
Native.implement([Element, Window, Document], { | |
// Inserting Inside | |
append: function(content) { | |
return content.inject(this); | |
}, | |
appendTo: function(content) { | |
return content.grab(this); | |
}, | |
prepend: function(content) { | |
return content.inject(this, 'before'); | |
}, | |
prependTo: function(content) { | |
return content.grab(this, 'top'); | |
}, | |
// Inserting Outside | |
after: function(content) { | |
return this.inject(content, 'after'); | |
}, | |
before: function(content) { | |
return this.inject(content, 'before'); | |
}, | |
insertAfter: function(content) { | |
return content.inject(this, 'after'); | |
}, | |
insertBefore: function(content) { | |
return content.inject(this, 'before'); | |
}, | |
// Inserting Around | |
wrap: function(html) { | |
alert('wrap() - still to do'); | |
return this; | |
}, | |
wrapAll: function(html) { | |
alert('wrapAll() - still to do'); | |
return this; | |
}, | |
wrapInner: function(html) { | |
alert('wrapInner() - still to do'); | |
return this; | |
}, | |
// Replacing | |
replaceWith: function(content) { | |
alert('replaceWith() - still to do'); | |
return this; | |
}, | |
replaceAll: function(selector) { | |
alert('replaceAll() - still to do'); | |
return this; | |
}, | |
// Already a function | |
//empty: function() { | |
remove: function() { | |
this.dispose(); | |
}, | |
// Already a function | |
// clone: function(boolean) { | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.Traveral.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
Element.implement({ | |
is: function(expr) { | |
return this.match(expr); | |
}, | |
not: function(expr) { | |
return !this.match(expr); | |
}, | |
add: function(expr) { | |
return [$$(expr), this].flatten(); | |
}/*, | |
children: function(expr) { | |
return this.getChildren(expr); | |
}*/, | |
contents: function() { | |
alert($type(this)); | |
alert('contents: Not implemented yet'); | |
return this; | |
}, | |
find: function(expr) { | |
return this.getElements(expr); | |
}, | |
next: function(expr) { | |
return this.getNext(expr); | |
}, | |
nextAll: function(expr) { | |
return this.getAllNext(expr); | |
}, | |
parent: function(expr) { | |
return this.getParent(expr)[0]; | |
}, | |
parents: function(expr) { | |
return this.getParents(expr); | |
}, | |
prev: function(expr) { | |
return this.getPrevious(expr); | |
}, | |
prevAll: function(expr) { | |
return this.getAllPrevious(expr); | |
}, | |
siblings: function(expr) { | |
return [this.getAllPrevious(expr), this.getAllNext(expr)].flatten(); | |
} | |
}); | |
Elements.implement({ | |
// Filtering | |
eq: function(i) { | |
return this[i]; | |
}, | |
// hasClass | |
// filter | |
is: function(expr) { | |
return this.some(function(els) { | |
return els.match(expr); | |
}); | |
}, | |
// map | |
not: function(expr) { | |
return this.filter(function(els) { | |
return !els.match(expr); | |
}); | |
}, | |
slice: function(start, end) { | |
if(!$defined(end)) | |
var end = this.length; | |
return this.filter(function(item, index){ | |
return (index >= start && index <= end) ? item : null; | |
}); | |
}, | |
// Finding | |
add: function(expr) { | |
return new Elements([$$(expr), this].flatten()); | |
}/*, | |
children: function(expr) { | |
return new Elements(this.getChildren(expr).flatten()); | |
}*/, | |
contents: function() { | |
}, | |
find: function(expr) { | |
return new Elements(this.getElements(expr).flatten()); | |
}, | |
next: function(expr) { | |
return new Elements(this.getNext(expr).flatten()); | |
}, | |
nextAll: function(expr) { | |
return new Elements(this.getAllNext(expr).flatten()); | |
}, | |
parent: function(expr) { | |
return new Elements(this.getParent(expr)); | |
}, | |
parents: function(expr) { | |
return new Elements(this.getParents(expr).flatten()); | |
}, | |
prev: function(expr) { | |
return new Elements(this.getPrevious(expr).flatten()); | |
}, | |
prevAll: function(expr) { | |
return new Elements(this.getAllPrevious(expr).flatten()); | |
}, | |
siblings: function(expr) { | |
return new Elements([this.getAllPrevious(expr), this.getAllNext(expr)].flatten()); | |
}, | |
andSelf: function() { | |
return new Elements([this, jQueryCache].flatten()); | |
}, | |
end: function() { | |
return jQueryCache; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Script: mooQuery.Utilites.js | |
A jQuery 1.3.2 compatability layer for MooTools 1.2 (http://jquery.com, http://mootools.net) | |
Version: 0.1 | |
License: | |
MIT-style license. | |
Copyright: | |
Copyright (c) 2010 William Darren Waddell (http://blog.fakedarren.com) | |
*/ | |
$.browser = { | |
safari: Browser.Engine.webkit, | |
opera: Browser.Engine.presto, | |
msie: Browser.Engine.trident, | |
mozilla: Browser.Engine.gecko, | |
version: function() { | |
if(Browser.Engine.webkit) | |
return Browser.Engine.webkit419 ? 2 : 3; | |
else if(Browser.Engine.presto) | |
return Browser.Engine.presto925 ? 9.25 : 9.50; | |
else if(Browser.Engine.trident) | |
return Browser.Engine.trident4 ? 6 : 7; | |
else if(Browser.Engine.gecko) | |
return 2; | |
} | |
}; | |
$.boxModel = function() { | |
}; | |
$.each = function(obj, func) { | |
return obj.each(function(el, i) { | |
func.attempt(i, el); | |
}); | |
}; | |
$.extend = function(target, obj) { | |
return $extend(target, obj); | |
}; | |
$.grep = function() { | |
}; | |
$.makeArray = function() { | |
}; | |
$.map = function(arr, fn) { | |
return arr.map(fn); | |
}; | |
$.inArray = function(val, arr) { | |
return arr.contains(val); | |
}; | |
$.unique = function() { | |
}; | |
$.isFunction = function(obj) { | |
return ($type(obj) == 'function'); | |
} | |
$.trim = function(str) { | |
return str.clean(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment