2 var e = ["blur","focus","contextmenu","load","resize","scroll","unload",
3 "click","dblclick","mousedown","mouseup","mouseenter","mouseleave",
4 "mousemove","mouseover","mouseout","change","reset","select","submit",
5 "keydown","keypress","keyup","abort","error","ready"];
7 for ( var i = 0; i < e.length; i++ ) {
10 $.fn[o] = function(f){ return this.bind(o, f); };
11 $.fn["un"+o] = function(f){ return this.unbind(o, f); };
12 $.fn["do"+o] = function(){ return this.trigger(o); };
13 $.fn["one"+o] = function(f){ return this.bind(o, function(e){
14 if ( this[o+f] !== null ) { return true; }
16 return $.apply(this,f,[e]);
20 //$.fn["on"+o] = function(f){ return this.bind(o, f); };
25 $.fn.hover = function(f,g) {
26 // Check if mouse(over|out) are still within the same parent element
27 return this.each(function(){
29 $.event.add(this, "mouseover", function(e) {
30 var p = ( e.fromElement !== null ? e.fromElement : e.relatedTarget );
31 while ( p && p != obj ) { p = p.parentNode; }
32 if ( p == obj ) { return false; }
33 return $.apply(obj,f,[e]);
35 $.event.add(this, "mouseout", function(e) {
36 var p = ( e.toElement !== null ? e.toElement : e.relatedTarget );
37 while ( p && p != obj ) { p = p.parentNode; }
38 if ( p == obj ) { return false; }
39 return $.apply(obj,g,[e]);
47 // Handle when the DOM is ready
48 $.ready = function() {
51 for ( var i = 0; i < $.$$ready.length; i++ ) {
52 $.apply( document, $.$$ready[i] );
59 if ( $.browser == "mozilla" || $.browser == "opera" ) {
60 // Use the handy event callback
61 document.addEventListener( "DOMContentLoaded", $.ready, null );
63 // If IE is used, use the excellent hack by Matthias Miller
64 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
65 } else if ( $.browser == "msie" ) {
67 // Only works if you document.write() it
68 document.write('<scr' + 'ipt id=__ie_init defer=true ' +
69 'src=javascript:void(0)><\/script>');
71 // Use the defer script hack
72 var script = document.getElementById('__ie_init');
73 script.onreadystatechange = function() {
74 if ( this.readyState == 'complete' ) {
83 } else if ( $.browser == "safari" ) {
84 $.$$timer = setInterval(function(){
85 if ( document.readyState == "loaded" ||
86 document.readyState == "complete" ) {
88 clearInterval( $.$$timer );
96 // A fallback, that will always work, just in case
97 $.event.add( window, "load", $.ready );
100 * Bind a function to fire when the DOM is ready.
102 $.fn.ready = function(f) {
104 $.apply( document, f );
116 $.fn.toggle = function(a,b) {
117 return a && b ? this.click(function(e){
118 this.$$last = this.$$last == a ? b : a;
120 return $.apply( this, this.$$last, [e] ) || false;