Created
January 6, 2010 20:14
-
-
Save fakedarren/270598 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) and Christoph Pojer (http://cpojer.net) | |
*/ | |
Native.implement([Element, Window, Document], { | |
attr: function(attr, val){ | |
if (arguments.length < 2) | |
return $type(attr) == 'string' ? this.getProperty(attr) : this.setProperties(attr); | |
return this.setProperty(attr, $type(val) == 'function' ? val.call(this) : val); | |
}, | |
/* Class (ALREADY IMPLEMENTED IN MOOTOOLS) | |
addClass: function(), | |
removeClass: function(), | |
toggleClass: function() | |
*/ | |
removeAttr: function(attr){ | |
return this.removeProperty(attr); | |
} | |
}); | |
Native.implement([Element, Window, Document], Hash.map({ | |
html: 'html', | |
text: 'text', | |
val: 'value' | |
}, function(value){ | |
return function(text){ | |
if (arguments.length) return this.set(value, text); | |
else return this.get(value); | |
}; | |
})); |
This file contains hidden or 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) and Christoph Pojer (http://cpojer.net) | |
*/ | |
(function(context){ | |
var jElement = context.jElement = new Native({ | |
initialize: function(elements){ | |
return $extend(elements, this); | |
} | |
}); | |
var jQuery = context.jQuery = function(selector){ | |
if ($type(selector) == 'function'){ | |
return window.addEvent('domready', selector); | |
} | |
var cache = $$(selector); | |
jQuery.cache = cache; | |
return new jElement(cache); | |
}; | |
jQuery.cache = null; | |
jQuery.extend = function(obj){ | |
for (key in obj){ | |
this[key] = obj[key]; | |
} | |
Element.implement(obj); | |
return this; | |
}; | |
jQuery.fn = jElement.prototype; | |
Element.implement({ | |
data: function(key, val){ | |
return arguments.length > 1 ? this.store(key, val) : this.retrieve(key); | |
}, | |
removeData: function(key){ | |
return this.store(key, null); | |
} | |
}); | |
})(this); |
This file contains hidden or 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 hidden or 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 hidden or 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) and Christoph Pojer (http://cpojer.net) | |
*/ | |
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); | |
}); | |
} | |
}); | |
(function(){ | |
var events = [ | |
'blur', 'change', 'click', 'dblclick', 'error', 'focus', | |
'keydown', 'keypress', 'keyup', 'load', 'mousedown', | |
'mousemove', 'mouseout', 'mouseup', 'resize', 'scroll', | |
'select', 'submit', 'unload' | |
]; | |
Native.implement([Element, Window, Document], Hash.map(events.associate(events), function(event){ | |
return function(fn){ | |
return arguments.length ? this.addEvent(event, fn) : this.fireEvent(event); | |
}; | |
})); | |
})(); |
This file contains hidden or 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 hidden or 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(); | |
} | |
}); | |
jElement.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)) | |
end = this.length; | |
return this.filter(function(item, index){ | |
return (index >= start && index <= end) ? item : null; | |
}); | |
}, | |
// Finding | |
add: function(expr){ | |
return new jElements([$$(expr), this].flatten()); | |
}/*, | |
children: function(expr){ | |
return new Elements(this.getChildren(expr).flatten()); | |
}*/, | |
contents: function(){ | |
}, | |
find: function(expr){ | |
return new jElements(this.getElements(expr).flatten()); | |
}, | |
next: function(expr){ | |
return new jElements(this.getNext(expr).flatten()); | |
}, | |
nextAll: function(expr){ | |
return new jElements(this.getAllNext(expr).flatten()); | |
}, | |
parent: function(expr){ | |
return new jElements(this.getParent(expr)); | |
}, | |
parents: function(expr){ | |
return new jElements(this.getParents(expr).flatten()); | |
}, | |
prev: function(expr){ | |
return new jElements(this.getPrevious(expr).flatten()); | |
}, | |
prevAll: function(expr){ | |
return new jElements(this.getAllPrevious(expr).flatten()); | |
}, | |
siblings: function(expr){ | |
return new jElements([this.getAllPrevious(expr), this.getAllNext(expr)].flatten()); | |
}, | |
andSelf: function(){ | |
return new jElements([this, jQueryCache].flatten()); | |
}, | |
end: function(){ | |
return jQueryCache; | |
} | |
}); |
This file contains hidden or 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(); | |
}; |
This file contains hidden or 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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | |
<!-- MooTools --> | |
<script src="../mootools-core/Source/Core/Core.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Core/Browser.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Native/Array.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Native/Function.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Native/Number.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Native/String.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Native/Hash.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Native/Event.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Class/Class.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Class/Class.Extras.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Element/Element.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Element/Element.Event.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Element/Element.Style.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Element/Element.Dimensions.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Utilities/Selectors.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Utilities/DomReady.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Utilities/JSON.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Utilities/Cookie.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Utilities/Swiff.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Fx/Fx.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Fx/Fx.CSS.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Fx/Fx.Tween.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Fx/Fx.Morph.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Fx/Fx.Transitions.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Request/Request.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Request/Request.HTML.js" type="text/javascript"></script> | |
<script src="../mootools-core/Source/Request/Request.JSON.js" type="text/javascript"></script> | |
<!-- Query !--> | |
<script src="mooquery.core.js" type="text/javascript"></script> | |
<script src="mooquery.utilities.js" type="text/javascript"></script> | |
<script src="mooquery.attributes.js" type="text/javascript"></script> | |
<script src="mooquery.manipulation.js" type="text/javascript"></script> | |
<script src="mooquery.events.js" type="text/javascript"></script> | |
<script src="mooquery.effects.js" type="text/javascript"></script> | |
<script src="mooquery.css.js" type="text/javascript"></script> | |
<script src="mooquery.traversal.js" type="text/javascript"></script> | |
<title>Moo!</title> | |
</head> | |
<body> | |
<div id="test"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment