annotate web/javascript/jquery.js @ 773:3b640272a966

Progres on resolve
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 12 Apr 2009 00:05:30 -0700
parents ad304b606163
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
673
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1 (function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2 /*
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
3 * jQuery 1.2.1 - New Wave Javascript
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
4 *
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
5 * Copyright (c) 2007 John Resig (jquery.com)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
6 * Dual licensed under the MIT (MIT-LICENSE.txt)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
7 * and GPL (GPL-LICENSE.txt) licenses.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
8 *
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
9 * $Date: 2007-09-16 23:42:06 -0400 (Sun, 16 Sep 2007) $
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
10 * $Rev: 3353 $
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
11 */
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
12
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
13 // Map over jQuery in case of overwrite
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
14 if ( typeof jQuery != "undefined" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
15 var _jQuery = jQuery;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
16
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
17 var jQuery = window.jQuery = function(selector, context) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
18 // If the context is a namespace object, return a new object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
19 return this instanceof jQuery ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
20 this.init(selector, context) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
21 new jQuery(selector, context);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
22 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
23
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
24 // Map over the $ in case of overwrite
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
25 if ( typeof $ != "undefined" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
26 var _$ = $;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
27
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
28 // Map the jQuery namespace to the '$' one
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
29 window.$ = jQuery;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
30
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
31 var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
32
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
33 jQuery.fn = jQuery.prototype = {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
34 init: function(selector, context) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
35 // Make sure that a selection was provided
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
36 selector = selector || document;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
37
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
38 // Handle HTML strings
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
39 if ( typeof selector == "string" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
40 var m = quickExpr.exec(selector);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
41 if ( m && (m[1] || !context) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
42 // HANDLE: $(html) -> $(array)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
43 if ( m[1] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
44 selector = jQuery.clean( [ m[1] ], context );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
45
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
46 // HANDLE: $("#id")
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
47 else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
48 var tmp = document.getElementById( m[3] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
49 if ( tmp )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
50 // Handle the case where IE and Opera return items
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
51 // by name instead of ID
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
52 if ( tmp.id != m[3] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
53 return jQuery().find( selector );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
54 else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
55 this[0] = tmp;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
56 this.length = 1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
57 return this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
58 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
59 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
60 selector = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
61 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
62
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
63 // HANDLE: $(expr)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
64 } else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
65 return new jQuery( context ).find( selector );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
66
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
67 // HANDLE: $(function)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
68 // Shortcut for document ready
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
69 } else if ( jQuery.isFunction(selector) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
70 return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( selector );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
71
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
72 return this.setArray(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
73 // HANDLE: $(array)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
74 selector.constructor == Array && selector ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
75
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
76 // HANDLE: $(arraylike)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
77 // Watch for when an array-like object is passed as the selector
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
78 (selector.jquery || selector.length && selector != window && !selector.nodeType && selector[0] != undefined && selector[0].nodeType) && jQuery.makeArray( selector ) ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
79
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
80 // HANDLE: $(*)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
81 [ selector ] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
82 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
83
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
84 jquery: "1.2.1",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
85
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
86 size: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
87 return this.length;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
88 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
89
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
90 length: 0,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
91
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
92 get: function( num ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
93 return num == undefined ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
94
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
95 // Return a 'clean' array
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
96 jQuery.makeArray( this ) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
97
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
98 // Return just the object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
99 this[num];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
100 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
101
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
102 pushStack: function( a ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
103 var ret = jQuery(a);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
104 ret.prevObject = this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
105 return ret;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
106 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
107
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
108 setArray: function( a ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
109 this.length = 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
110 Array.prototype.push.apply( this, a );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
111 return this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
112 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
113
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
114 each: function( fn, args ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
115 return jQuery.each( this, fn, args );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
116 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
117
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
118 index: function( obj ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
119 var pos = -1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
120 this.each(function(i){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
121 if ( this == obj ) pos = i;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
122 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
123 return pos;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
124 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
125
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
126 attr: function( key, value, type ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
127 var obj = key;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
128
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
129 // Look for the case where we're accessing a style value
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
130 if ( key.constructor == String )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
131 if ( value == undefined )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
132 return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
133 else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
134 obj = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
135 obj[ key ] = value;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
136 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
137
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
138 // Check to see if we're setting style values
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
139 return this.each(function(index){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
140 // Set all the styles
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
141 for ( var prop in obj )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
142 jQuery.attr(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
143 type ? this.style : this,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
144 prop, jQuery.prop(this, obj[prop], type, index, prop)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
145 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
146 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
147 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
148
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
149 css: function( key, value ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
150 return this.attr( key, value, "curCSS" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
151 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
152
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
153 text: function(e) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
154 if ( typeof e != "object" && e != null )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
155 return this.empty().append( document.createTextNode( e ) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
156
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
157 var t = "";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
158 jQuery.each( e || this, function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
159 jQuery.each( this.childNodes, function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
160 if ( this.nodeType != 8 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
161 t += this.nodeType != 1 ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
162 this.nodeValue : jQuery.fn.text([ this ]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
163 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
164 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
165 return t;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
166 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
167
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
168 wrapAll: function(html) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
169 if ( this[0] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
170 // The elements to wrap the target around
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
171 jQuery(html, this[0].ownerDocument)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
172 .clone()
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
173 .insertBefore(this[0])
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
174 .map(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
175 var elem = this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
176 while ( elem.firstChild )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
177 elem = elem.firstChild;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
178 return elem;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
179 })
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
180 .append(this);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
181
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
182 return this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
183 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
184
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
185 wrapInner: function(html) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
186 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
187 jQuery(this).contents().wrapAll(html);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
188 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
189 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
190
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
191 wrap: function(html) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
192 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
193 jQuery(this).wrapAll(html);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
194 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
195 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
196
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
197 append: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
198 return this.domManip(arguments, true, 1, function(a){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
199 this.appendChild( a );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
200 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
201 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
202
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
203 prepend: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
204 return this.domManip(arguments, true, -1, function(a){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
205 this.insertBefore( a, this.firstChild );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
206 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
207 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
208
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
209 before: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
210 return this.domManip(arguments, false, 1, function(a){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
211 this.parentNode.insertBefore( a, this );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
212 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
213 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
214
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
215 after: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
216 return this.domManip(arguments, false, -1, function(a){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
217 this.parentNode.insertBefore( a, this.nextSibling );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
218 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
219 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
220
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
221 end: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
222 return this.prevObject || jQuery([]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
223 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
224
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
225 find: function(t) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
226 var data = jQuery.map(this, function(a){ return jQuery.find(t,a); });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
227 return this.pushStack( /[^+>] [^+>]/.test( t ) || t.indexOf("..") > -1 ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
228 jQuery.unique( data ) : data );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
229 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
230
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
231 clone: function(events) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
232 // Do the clone
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
233 var ret = this.map(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
234 return this.outerHTML ? jQuery(this.outerHTML)[0] : this.cloneNode(true);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
235 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
236
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
237 // Need to set the expando to null on the cloned set if it exists
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
238 // removeData doesn't work here, IE removes it from the original as well
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
239 // this is primarily for IE but the data expando shouldn't be copied over in any browser
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
240 var clone = ret.find("*").andSelf().each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
241 if ( this[ expando ] != undefined )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
242 this[ expando ] = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
243 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
244
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
245 // Copy the events from the original to the clone
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
246 if (events === true)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
247 this.find("*").andSelf().each(function(i) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
248 var events = jQuery.data(this, "events");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
249 for ( var type in events )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
250 for ( var handler in events[type] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
251 jQuery.event.add(clone[i], type, events[type][handler], events[type][handler].data);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
252 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
253
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
254 // Return the cloned set
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
255 return ret;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
256 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
257
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
258 filter: function(t) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
259 return this.pushStack(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
260 jQuery.isFunction( t ) &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
261 jQuery.grep(this, function(el, index){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
262 return t.apply(el, [index]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
263 }) ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
264
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
265 jQuery.multiFilter(t,this) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
266 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
267
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
268 not: function(t) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
269 return this.pushStack(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
270 t.constructor == String &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
271 jQuery.multiFilter(t, this, true) ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
272
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
273 jQuery.grep(this, function(a) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
274 return ( t.constructor == Array || t.jquery )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
275 ? jQuery.inArray( a, t ) < 0
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
276 : a != t;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
277 })
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
278 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
279 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
280
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
281 add: function(t) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
282 return this.pushStack( jQuery.merge(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
283 this.get(),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
284 t.constructor == String ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
285 jQuery(t).get() :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
286 t.length != undefined && (!t.nodeName || jQuery.nodeName(t, "form")) ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
287 t : [t] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
288 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
289 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
290
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
291 is: function(expr) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
292 return expr ? jQuery.multiFilter(expr,this).length > 0 : false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
293 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
294
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
295 hasClass: function(expr) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
296 return this.is("." + expr);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
297 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
298
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
299 val: function( val ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
300 if ( val == undefined ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
301 if ( this.length ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
302 var elem = this[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
303
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
304 // We need to handle select boxes special
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
305 if ( jQuery.nodeName(elem, "select") ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
306 var index = elem.selectedIndex,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
307 a = [],
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
308 options = elem.options,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
309 one = elem.type == "select-one";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
310
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
311 // Nothing was selected
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
312 if ( index < 0 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
313 return null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
314
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
315 // Loop through all the selected options
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
316 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
317 var option = options[i];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
318 if ( option.selected ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
319 // Get the specifc value for the option
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
320 var val = jQuery.browser.msie && !option.attributes["value"].specified ? option.text : option.value;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
321
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
322 // We don't need an array for one selects
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
323 if ( one )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
324 return val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
325
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
326 // Multi-Selects return an array
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
327 a.push(val);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
328 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
329 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
330
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
331 return a;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
332
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
333 // Everything else, we just grab the value
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
334 } else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
335 return this[0].value.replace(/\r/g, "");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
336 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
337 } else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
338 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
339 if ( val.constructor == Array && /radio|checkbox/.test(this.type) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
340 this.checked = (jQuery.inArray(this.value, val) >= 0 ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
341 jQuery.inArray(this.name, val) >= 0);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
342 else if ( jQuery.nodeName(this, "select") ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
343 var tmp = val.constructor == Array ? val : [val];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
344
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
345 jQuery("option", this).each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
346 this.selected = (jQuery.inArray(this.value, tmp) >= 0 ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
347 jQuery.inArray(this.text, tmp) >= 0);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
348 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
349
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
350 if ( !tmp.length )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
351 this.selectedIndex = -1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
352 } else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
353 this.value = val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
354 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
355 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
356
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
357 html: function( val ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
358 return val == undefined ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
359 ( this.length ? this[0].innerHTML : null ) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
360 this.empty().append( val );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
361 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
362
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
363 replaceWith: function( val ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
364 return this.after( val ).remove();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
365 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
366
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
367 eq: function(i){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
368 return this.slice(i, i+1);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
369 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
370
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
371 slice: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
372 return this.pushStack( Array.prototype.slice.apply( this, arguments ) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
373 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
374
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
375 map: function(fn) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
376 return this.pushStack(jQuery.map( this, function(elem,i){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
377 return fn.call( elem, i, elem );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
378 }));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
379 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
380
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
381 andSelf: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
382 return this.add( this.prevObject );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
383 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
384
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
385 domManip: function(args, table, dir, fn) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
386 var clone = this.length > 1, a;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
387
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
388 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
389 if ( !a ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
390 a = jQuery.clean(args, this.ownerDocument);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
391 if ( dir < 0 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
392 a.reverse();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
393 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
394
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
395 var obj = this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
396
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
397 if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
398 obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
399
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
400 jQuery.each( a, function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
401 var elem = clone ? this.cloneNode(true) : this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
402 if ( !evalScript(0, elem) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
403 fn.call( obj, elem );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
404 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
405 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
406 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
407 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
408
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
409 function evalScript(i, elem){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
410 var script = jQuery.nodeName(elem, "script");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
411
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
412 if ( script ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
413 if ( elem.src )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
414 jQuery.ajax({ url: elem.src, async: false, dataType: "script" });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
415 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
416 jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
417
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
418 if ( elem.parentNode )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
419 elem.parentNode.removeChild(elem);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
420
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
421 } else if ( elem.nodeType == 1 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
422 jQuery("script", elem).each(evalScript);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
423
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
424 return script;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
425 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
426
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
427 jQuery.extend = jQuery.fn.extend = function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
428 // copy reference to target object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
429 var target = arguments[0] || {}, a = 1, al = arguments.length, deep = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
430
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
431 // Handle a deep copy situation
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
432 if ( target.constructor == Boolean ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
433 deep = target;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
434 target = arguments[1] || {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
435 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
436
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
437 // extend jQuery itself if only one argument is passed
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
438 if ( al == 1 ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
439 target = this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
440 a = 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
441 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
442
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
443 var prop;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
444
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
445 for ( ; a < al; a++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
446 // Only deal with non-null/undefined values
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
447 if ( (prop = arguments[a]) != null )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
448 // Extend the base object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
449 for ( var i in prop ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
450 // Prevent never-ending loop
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
451 if ( target == prop[i] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
452 continue;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
453
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
454 // Recurse if we're merging object values
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
455 if ( deep && typeof prop[i] == 'object' && target[i] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
456 jQuery.extend( target[i], prop[i] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
457
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
458 // Don't bring in undefined values
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
459 else if ( prop[i] != undefined )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
460 target[i] = prop[i];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
461 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
462
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
463 // Return the modified object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
464 return target;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
465 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
466
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
467 var expando = "jQuery" + (new Date()).getTime(), uuid = 0, win = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
468
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
469 jQuery.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
470 noConflict: function(deep) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
471 window.$ = _$;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
472 if ( deep )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
473 window.jQuery = _jQuery;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
474 return jQuery;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
475 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
476
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
477 // This may seem like some crazy code, but trust me when I say that this
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
478 // is the only cross-browser way to do this. --John
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
479 isFunction: function( fn ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
480 return !!fn && typeof fn != "string" && !fn.nodeName &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
481 fn.constructor != Array && /function/i.test( fn + "" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
482 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
483
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
484 // check if an element is in a XML document
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
485 isXMLDoc: function(elem) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
486 return elem.documentElement && !elem.body ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
487 elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
488 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
489
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
490 // Evalulates a script in a global context
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
491 // Evaluates Async. in Safari 2 :-(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
492 globalEval: function( data ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
493 data = jQuery.trim( data );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
494 if ( data ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
495 if ( window.execScript )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
496 window.execScript( data );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
497 else if ( jQuery.browser.safari )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
498 // safari doesn't provide a synchronous global eval
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
499 window.setTimeout( data, 0 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
500 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
501 eval.call( window, data );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
502 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
503 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
504
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
505 nodeName: function( elem, name ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
506 return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
507 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
508
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
509 cache: {},
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
510
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
511 data: function( elem, name, data ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
512 elem = elem == window ? win : elem;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
513
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
514 var id = elem[ expando ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
515
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
516 // Compute a unique ID for the element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
517 if ( !id )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
518 id = elem[ expando ] = ++uuid;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
519
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
520 // Only generate the data cache if we're
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
521 // trying to access or manipulate it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
522 if ( name && !jQuery.cache[ id ] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
523 jQuery.cache[ id ] = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
524
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
525 // Prevent overriding the named cache with undefined values
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
526 if ( data != undefined )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
527 jQuery.cache[ id ][ name ] = data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
528
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
529 // Return the named cache data, or the ID for the element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
530 return name ? jQuery.cache[ id ][ name ] : id;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
531 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
532
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
533 removeData: function( elem, name ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
534 elem = elem == window ? win : elem;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
535
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
536 var id = elem[ expando ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
537
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
538 // If we want to remove a specific section of the element's data
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
539 if ( name ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
540 if ( jQuery.cache[ id ] ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
541 // Remove the section of cache data
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
542 delete jQuery.cache[ id ][ name ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
543
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
544 // If we've removed all the data, remove the element's cache
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
545 name = "";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
546 for ( name in jQuery.cache[ id ] ) break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
547 if ( !name )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
548 jQuery.removeData( elem );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
549 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
550
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
551 // Otherwise, we want to remove all of the element's data
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
552 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
553 // Clean up the element expando
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
554 try {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
555 delete elem[ expando ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
556 } catch(e){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
557 // IE has trouble directly removing the expando
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
558 // but it's ok with using removeAttribute
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
559 if ( elem.removeAttribute )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
560 elem.removeAttribute( expando );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
561 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
562
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
563 // Completely remove the data cache
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
564 delete jQuery.cache[ id ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
565 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
566 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
567
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
568 // args is for internal usage only
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
569 each: function( obj, fn, args ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
570 if ( args ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
571 if ( obj.length == undefined )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
572 for ( var i in obj )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
573 fn.apply( obj[i], args );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
574 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
575 for ( var i = 0, ol = obj.length; i < ol; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
576 if ( fn.apply( obj[i], args ) === false ) break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
577
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
578 // A special, fast, case for the most common use of each
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
579 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
580 if ( obj.length == undefined )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
581 for ( var i in obj )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
582 fn.call( obj[i], i, obj[i] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
583 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
584 for ( var i = 0, ol = obj.length, val = obj[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
585 i < ol && fn.call(val,i,val) !== false; val = obj[++i] ){}
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
586 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
587
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
588 return obj;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
589 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
590
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
591 prop: function(elem, value, type, index, prop){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
592 // Handle executable functions
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
593 if ( jQuery.isFunction( value ) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
594 value = value.call( elem, [index] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
595
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
596 // exclude the following css properties to add px
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
597 var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
598
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
599 // Handle passing in a number to a CSS property
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
600 return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
601 value + "px" :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
602 value;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
603 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
604
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
605 className: {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
606 // internal only, use addClass("class")
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
607 add: function( elem, c ){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
608 jQuery.each( (c || "").split(/\s+/), function(i, cur){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
609 if ( !jQuery.className.has( elem.className, cur ) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
610 elem.className += ( elem.className ? " " : "" ) + cur;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
611 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
612 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
613
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
614 // internal only, use removeClass("class")
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
615 remove: function( elem, c ){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
616 elem.className = c != undefined ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
617 jQuery.grep( elem.className.split(/\s+/), function(cur){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
618 return !jQuery.className.has( c, cur );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
619 }).join(" ") : "";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
620 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
621
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
622 // internal only, use is(".class")
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
623 has: function( t, c ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
624 return jQuery.inArray( c, (t.className || t).toString().split(/\s+/) ) > -1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
625 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
626 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
627
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
628 swap: function(e,o,f) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
629 for ( var i in o ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
630 e.style["old"+i] = e.style[i];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
631 e.style[i] = o[i];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
632 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
633 f.apply( e, [] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
634 for ( var i in o )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
635 e.style[i] = e.style["old"+i];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
636 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
637
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
638 css: function(e,p) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
639 if ( p == "height" || p == "width" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
640 var old = {}, oHeight, oWidth, d = ["Top","Bottom","Right","Left"];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
641
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
642 jQuery.each( d, function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
643 old["padding" + this] = 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
644 old["border" + this + "Width"] = 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
645 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
646
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
647 jQuery.swap( e, old, function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
648 if ( jQuery(e).is(':visible') ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
649 oHeight = e.offsetHeight;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
650 oWidth = e.offsetWidth;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
651 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
652 e = jQuery(e.cloneNode(true))
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
653 .find(":radio").removeAttr("checked").end()
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
654 .css({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
655 visibility: "hidden", position: "absolute", display: "block", right: "0", left: "0"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
656 }).appendTo(e.parentNode)[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
657
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
658 var parPos = jQuery.css(e.parentNode,"position") || "static";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
659 if ( parPos == "static" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
660 e.parentNode.style.position = "relative";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
661
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
662 oHeight = e.clientHeight;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
663 oWidth = e.clientWidth;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
664
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
665 if ( parPos == "static" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
666 e.parentNode.style.position = "static";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
667
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
668 e.parentNode.removeChild(e);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
669 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
670 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
671
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
672 return p == "height" ? oHeight : oWidth;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
673 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
674
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
675 return jQuery.curCSS( e, p );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
676 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
677
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
678 curCSS: function(elem, prop, force) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
679 var ret, stack = [], swap = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
680
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
681 // A helper method for determining if an element's values are broken
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
682 function color(a){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
683 if ( !jQuery.browser.safari )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
684 return false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
685
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
686 var ret = document.defaultView.getComputedStyle(a,null);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
687 return !ret || ret.getPropertyValue("color") == "";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
688 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
689
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
690 if (prop == "opacity" && jQuery.browser.msie) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
691 ret = jQuery.attr(elem.style, "opacity");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
692 return ret == "" ? "1" : ret;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
693 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
694
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
695 if (prop.match(/float/i))
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
696 prop = styleFloat;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
697
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
698 if (!force && elem.style[prop])
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
699 ret = elem.style[prop];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
700
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
701 else if (document.defaultView && document.defaultView.getComputedStyle) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
702
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
703 if (prop.match(/float/i))
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
704 prop = "float";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
705
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
706 prop = prop.replace(/([A-Z])/g,"-$1").toLowerCase();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
707 var cur = document.defaultView.getComputedStyle(elem, null);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
708
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
709 if ( cur && !color(elem) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
710 ret = cur.getPropertyValue(prop);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
711
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
712 // If the element isn't reporting its values properly in Safari
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
713 // then some display: none elements are involved
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
714 else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
715 // Locate all of the parent display: none elements
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
716 for ( var a = elem; a && color(a); a = a.parentNode )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
717 stack.unshift(a);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
718
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
719 // Go through and make them visible, but in reverse
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
720 // (It would be better if we knew the exact display type that they had)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
721 for ( a = 0; a < stack.length; a++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
722 if ( color(stack[a]) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
723 swap[a] = stack[a].style.display;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
724 stack[a].style.display = "block";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
725 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
726
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
727 // Since we flip the display style, we have to handle that
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
728 // one special, otherwise get the value
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
729 ret = prop == "display" && swap[stack.length-1] != null ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
730 "none" :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
731 document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop) || "";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
732
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
733 // Finally, revert the display styles back
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
734 for ( a = 0; a < swap.length; a++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
735 if ( swap[a] != null )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
736 stack[a].style.display = swap[a];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
737 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
738
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
739 if ( prop == "opacity" && ret == "" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
740 ret = "1";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
741
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
742 } else if (elem.currentStyle) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
743 var newProp = prop.replace(/\-(\w)/g,function(m,c){return c.toUpperCase();});
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
744 ret = elem.currentStyle[prop] || elem.currentStyle[newProp];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
745
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
746 // From the awesome hack by Dean Edwards
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
747 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
748
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
749 // If we're not dealing with a regular pixel number
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
750 // but a number that has a weird ending, we need to convert it to pixels
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
751 if ( !/^\d+(px)?$/i.test(ret) && /^\d/.test(ret) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
752 var style = elem.style.left;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
753 var runtimeStyle = elem.runtimeStyle.left;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
754 elem.runtimeStyle.left = elem.currentStyle.left;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
755 elem.style.left = ret || 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
756 ret = elem.style.pixelLeft + "px";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
757 elem.style.left = style;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
758 elem.runtimeStyle.left = runtimeStyle;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
759 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
760 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
761
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
762 return ret;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
763 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
764
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
765 clean: function(a, doc) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
766 var r = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
767 doc = doc || document;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
768
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
769 jQuery.each( a, function(i,arg){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
770 if ( !arg ) return;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
771
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
772 if ( arg.constructor == Number )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
773 arg = arg.toString();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
774
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
775 // Convert html string into DOM nodes
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
776 if ( typeof arg == "string" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
777 // Fix "XHTML"-style tags in all browsers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
778 arg = arg.replace(/(<(\w+)[^>]*?)\/>/g, function(m, all, tag){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
779 return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area)$/i)? m : all+"></"+tag+">";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
780 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
781
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
782 // Trim whitespace, otherwise indexOf won't work as expected
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
783 var s = jQuery.trim(arg).toLowerCase(), div = doc.createElement("div"), tb = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
784
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
785 var wrap =
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
786 // option or optgroup
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
787 !s.indexOf("<opt") &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
788 [1, "<select>", "</select>"] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
789
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
790 !s.indexOf("<leg") &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
791 [1, "<fieldset>", "</fieldset>"] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
792
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
793 s.match(/^<(thead|tbody|tfoot|colg|cap)/) &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
794 [1, "<table>", "</table>"] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
795
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
796 !s.indexOf("<tr") &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
797 [2, "<table><tbody>", "</tbody></table>"] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
798
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
799 // <thead> matched above
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
800 (!s.indexOf("<td") || !s.indexOf("<th")) &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
801 [3, "<table><tbody><tr>", "</tr></tbody></table>"] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
802
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
803 !s.indexOf("<col") &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
804 [2, "<table><tbody></tbody><colgroup>", "</colgroup></table>"] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
805
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
806 // IE can't serialize <link> and <script> tags normally
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
807 jQuery.browser.msie &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
808 [1, "div<div>", "</div>"] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
809
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
810 [0,"",""];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
811
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
812 // Go to html and back, then peel off extra wrappers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
813 div.innerHTML = wrap[1] + arg + wrap[2];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
814
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
815 // Move to the right depth
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
816 while ( wrap[0]-- )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
817 div = div.lastChild;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
818
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
819 // Remove IE's autoinserted <tbody> from table fragments
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
820 if ( jQuery.browser.msie ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
821
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
822 // String was a <table>, *may* have spurious <tbody>
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
823 if ( !s.indexOf("<table") && s.indexOf("<tbody") < 0 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
824 tb = div.firstChild && div.firstChild.childNodes;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
825
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
826 // String was a bare <thead> or <tfoot>
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
827 else if ( wrap[1] == "<table>" && s.indexOf("<tbody") < 0 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
828 tb = div.childNodes;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
829
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
830 for ( var n = tb.length-1; n >= 0 ; --n )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
831 if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
832 tb[n].parentNode.removeChild(tb[n]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
833
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
834 // IE completely kills leading whitespace when innerHTML is used
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
835 if ( /^\s/.test(arg) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
836 div.insertBefore( doc.createTextNode( arg.match(/^\s*/)[0] ), div.firstChild );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
837
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
838 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
839
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
840 arg = jQuery.makeArray( div.childNodes );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
841 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
842
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
843 if ( 0 === arg.length && (!jQuery.nodeName(arg, "form") && !jQuery.nodeName(arg, "select")) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
844 return;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
845
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
846 if ( arg[0] == undefined || jQuery.nodeName(arg, "form") || arg.options )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
847 r.push( arg );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
848 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
849 r = jQuery.merge( r, arg );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
850
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
851 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
852
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
853 return r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
854 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
855
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
856 attr: function(elem, name, value){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
857 var fix = jQuery.isXMLDoc(elem) ? {} : jQuery.props;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
858
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
859 // Safari mis-reports the default selected property of a hidden option
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
860 // Accessing the parent's selectedIndex property fixes it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
861 if ( name == "selected" && jQuery.browser.safari )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
862 elem.parentNode.selectedIndex;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
863
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
864 // Certain attributes only work when accessed via the old DOM 0 way
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
865 if ( fix[name] ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
866 if ( value != undefined ) elem[fix[name]] = value;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
867 return elem[fix[name]];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
868 } else if ( jQuery.browser.msie && name == "style" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
869 return jQuery.attr( elem.style, "cssText", value );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
870
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
871 else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
872 return elem.getAttributeNode(name).nodeValue;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
873
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
874 // IE elem.getAttribute passes even for style
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
875 else if ( elem.tagName ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
876
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
877 if ( value != undefined ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
878 if ( name == "type" && jQuery.nodeName(elem,"input") && elem.parentNode )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
879 throw "type property can't be changed";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
880 elem.setAttribute( name, value );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
881 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
882
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
883 if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
884 return elem.getAttribute( name, 2 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
885
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
886 return elem.getAttribute( name );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
887
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
888 // elem is actually elem.style ... set the style
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
889 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
890 // IE actually uses filters for opacity
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
891 if ( name == "opacity" && jQuery.browser.msie ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
892 if ( value != undefined ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
893 // IE has trouble with opacity if it does not have layout
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
894 // Force it by setting the zoom level
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
895 elem.zoom = 1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
896
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
897 // Set the alpha filter to set the opacity
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
898 elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") +
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
899 (parseFloat(value).toString() == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
900 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
901
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
902 return elem.filter ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
903 (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100).toString() : "";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
904 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
905 name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
906 if ( value != undefined ) elem[name] = value;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
907 return elem[name];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
908 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
909 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
910
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
911 trim: function(t){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
912 return (t||"").replace(/^\s+|\s+$/g, "");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
913 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
914
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
915 makeArray: function( a ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
916 var r = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
917
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
918 // Need to use typeof to fight Safari childNodes crashes
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
919 if ( typeof a != "array" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
920 for ( var i = 0, al = a.length; i < al; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
921 r.push( a[i] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
922 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
923 r = a.slice( 0 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
924
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
925 return r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
926 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
927
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
928 inArray: function( b, a ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
929 for ( var i = 0, al = a.length; i < al; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
930 if ( a[i] == b )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
931 return i;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
932 return -1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
933 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
934
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
935 merge: function(first, second) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
936 // We have to loop this way because IE & Opera overwrite the length
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
937 // expando of getElementsByTagName
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
938
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
939 // Also, we need to make sure that the correct elements are being returned
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
940 // (IE returns comment nodes in a '*' query)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
941 if ( jQuery.browser.msie ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
942 for ( var i = 0; second[i]; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
943 if ( second[i].nodeType != 8 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
944 first.push(second[i]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
945 } else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
946 for ( var i = 0; second[i]; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
947 first.push(second[i]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
948
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
949 return first;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
950 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
951
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
952 unique: function(first) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
953 var r = [], done = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
954
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
955 try {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
956 for ( var i = 0, fl = first.length; i < fl; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
957 var id = jQuery.data(first[i]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
958 if ( !done[id] ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
959 done[id] = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
960 r.push(first[i]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
961 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
962 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
963 } catch(e) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
964 r = first;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
965 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
966
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
967 return r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
968 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
969
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
970 grep: function(elems, fn, inv) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
971 // If a string is passed in for the function, make a function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
972 // for it (a handy shortcut)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
973 if ( typeof fn == "string" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
974 fn = eval("false||function(a,i){return " + fn + "}");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
975
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
976 var result = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
977
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
978 // Go through the array, only saving the items
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
979 // that pass the validator function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
980 for ( var i = 0, el = elems.length; i < el; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
981 if ( !inv && fn(elems[i],i) || inv && !fn(elems[i],i) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
982 result.push( elems[i] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
983
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
984 return result;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
985 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
986
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
987 map: function(elems, fn) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
988 // If a string is passed in for the function, make a function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
989 // for it (a handy shortcut)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
990 if ( typeof fn == "string" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
991 fn = eval("false||function(a){return " + fn + "}");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
992
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
993 var result = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
994
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
995 // Go through the array, translating each of the items to their
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
996 // new value (or values).
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
997 for ( var i = 0, el = elems.length; i < el; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
998 var val = fn(elems[i],i);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
999
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1000 if ( val !== null && val != undefined ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1001 if ( val.constructor != Array ) val = [val];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1002 result = result.concat( val );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1003 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1004 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1005
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1006 return result;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1007 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1008 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1009
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1010 var userAgent = navigator.userAgent.toLowerCase();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1011
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1012 // Figure out what browser is being used
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1013 jQuery.browser = {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1014 version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1015 safari: /webkit/.test(userAgent),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1016 opera: /opera/.test(userAgent),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1017 msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1018 mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1019 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1020
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1021 var styleFloat = jQuery.browser.msie ? "styleFloat" : "cssFloat";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1022
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1023 jQuery.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1024 // Check to see if the W3C box model is being used
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1025 boxModel: !jQuery.browser.msie || document.compatMode == "CSS1Compat",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1026
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1027 styleFloat: jQuery.browser.msie ? "styleFloat" : "cssFloat",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1028
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1029 props: {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1030 "for": "htmlFor",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1031 "class": "className",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1032 "float": styleFloat,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1033 cssFloat: styleFloat,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1034 styleFloat: styleFloat,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1035 innerHTML: "innerHTML",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1036 className: "className",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1037 value: "value",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1038 disabled: "disabled",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1039 checked: "checked",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1040 readonly: "readOnly",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1041 selected: "selected",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1042 maxlength: "maxLength"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1043 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1044 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1045
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1046 jQuery.each({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1047 parent: "a.parentNode",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1048 parents: "jQuery.dir(a,'parentNode')",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1049 next: "jQuery.nth(a,2,'nextSibling')",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1050 prev: "jQuery.nth(a,2,'previousSibling')",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1051 nextAll: "jQuery.dir(a,'nextSibling')",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1052 prevAll: "jQuery.dir(a,'previousSibling')",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1053 siblings: "jQuery.sibling(a.parentNode.firstChild,a)",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1054 children: "jQuery.sibling(a.firstChild)",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1055 contents: "jQuery.nodeName(a,'iframe')?a.contentDocument||a.contentWindow.document:jQuery.makeArray(a.childNodes)"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1056 }, function(i,n){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1057 jQuery.fn[ i ] = function(a) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1058 var ret = jQuery.map(this,n);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1059 if ( a && typeof a == "string" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1060 ret = jQuery.multiFilter(a,ret);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1061 return this.pushStack( jQuery.unique(ret) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1062 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1063 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1064
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1065 jQuery.each({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1066 appendTo: "append",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1067 prependTo: "prepend",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1068 insertBefore: "before",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1069 insertAfter: "after",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1070 replaceAll: "replaceWith"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1071 }, function(i,n){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1072 jQuery.fn[ i ] = function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1073 var a = arguments;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1074 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1075 for ( var j = 0, al = a.length; j < al; j++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1076 jQuery(a[j])[n]( this );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1077 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1078 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1079 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1080
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1081 jQuery.each( {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1082 removeAttr: function( key ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1083 jQuery.attr( this, key, "" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1084 this.removeAttribute( key );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1085 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1086 addClass: function(c){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1087 jQuery.className.add(this,c);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1088 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1089 removeClass: function(c){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1090 jQuery.className.remove(this,c);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1091 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1092 toggleClass: function( c ){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1093 jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this, c);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1094 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1095 remove: function(a){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1096 if ( !a || jQuery.filter( a, [this] ).r.length ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1097 jQuery.removeData( this );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1098 this.parentNode.removeChild( this );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1099 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1100 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1101 empty: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1102 // Clean up the cache
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1103 jQuery("*", this).each(function(){ jQuery.removeData(this); });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1104
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1105 while ( this.firstChild )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1106 this.removeChild( this.firstChild );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1107 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1108 }, function(i,n){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1109 jQuery.fn[ i ] = function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1110 return this.each( n, arguments );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1111 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1112 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1113
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1114 jQuery.each( [ "Height", "Width" ], function(i,name){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1115 var n = name.toLowerCase();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1116
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1117 jQuery.fn[ n ] = function(h) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1118 return this[0] == window ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1119 jQuery.browser.safari && self["inner" + name] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1120 jQuery.boxModel && Math.max(document.documentElement["client" + name], document.body["client" + name]) ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1121 document.body["client" + name] :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1122
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1123 this[0] == document ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1124 Math.max( document.body["scroll" + name], document.body["offset" + name] ) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1125
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1126 h == undefined ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1127 ( this.length ? jQuery.css( this[0], n ) : null ) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1128 this.css( n, h.constructor == String ? h : h + "px" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1129 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1130 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1131
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1132 var chars = jQuery.browser.safari && parseInt(jQuery.browser.version) < 417 ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1133 "(?:[\\w*_-]|\\\\.)" :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1134 "(?:[\\w\u0128-\uFFFF*_-]|\\\\.)",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1135 quickChild = new RegExp("^>\\s*(" + chars + "+)"),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1136 quickID = new RegExp("^(" + chars + "+)(#)(" + chars + "+)"),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1137 quickClass = new RegExp("^([#.]?)(" + chars + "*)");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1138
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1139 jQuery.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1140 expr: {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1141 "": "m[2]=='*'||jQuery.nodeName(a,m[2])",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1142 "#": "a.getAttribute('id')==m[2]",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1143 ":": {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1144 // Position Checks
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1145 lt: "i<m[3]-0",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1146 gt: "i>m[3]-0",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1147 nth: "m[3]-0==i",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1148 eq: "m[3]-0==i",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1149 first: "i==0",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1150 last: "i==r.length-1",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1151 even: "i%2==0",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1152 odd: "i%2",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1153
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1154 // Child Checks
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1155 "first-child": "a.parentNode.getElementsByTagName('*')[0]==a",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1156 "last-child": "jQuery.nth(a.parentNode.lastChild,1,'previousSibling')==a",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1157 "only-child": "!jQuery.nth(a.parentNode.lastChild,2,'previousSibling')",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1158
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1159 // Parent Checks
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1160 parent: "a.firstChild",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1161 empty: "!a.firstChild",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1162
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1163 // Text Check
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1164 contains: "(a.textContent||a.innerText||jQuery(a).text()||'').indexOf(m[3])>=0",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1165
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1166 // Visibility
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1167 visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1168 hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1169
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1170 // Form attributes
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1171 enabled: "!a.disabled",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1172 disabled: "a.disabled",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1173 checked: "a.checked",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1174 selected: "a.selected||jQuery.attr(a,'selected')",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1175
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1176 // Form elements
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1177 text: "'text'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1178 radio: "'radio'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1179 checkbox: "'checkbox'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1180 file: "'file'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1181 password: "'password'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1182 submit: "'submit'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1183 image: "'image'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1184 reset: "'reset'==a.type",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1185 button: '"button"==a.type||jQuery.nodeName(a,"button")',
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1186 input: "/input|select|textarea|button/i.test(a.nodeName)",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1187
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1188 // :has()
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1189 has: "jQuery.find(m[3],a).length",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1190
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1191 // :header
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1192 header: "/h\\d/i.test(a.nodeName)",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1193
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1194 // :animated
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1195 animated: "jQuery.grep(jQuery.timers,function(fn){return a==fn.elem;}).length"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1196 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1197 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1198
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1199 // The regular expressions that power the parsing engine
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1200 parse: [
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1201 // Match: [@value='test'], [@foo]
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1202 /^(\[) *@?([\w-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1203
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1204 // Match: :contains('foo')
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1205 /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1206
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1207 // Match: :even, :last-chlid, #id, .class
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1208 new RegExp("^([:.#]*)(" + chars + "+)")
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1209 ],
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1210
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1211 multiFilter: function( expr, elems, not ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1212 var old, cur = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1213
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1214 while ( expr && expr != old ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1215 old = expr;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1216 var f = jQuery.filter( expr, elems, not );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1217 expr = f.t.replace(/^\s*,\s*/, "" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1218 cur = not ? elems = f.r : jQuery.merge( cur, f.r );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1219 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1220
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1221 return cur;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1222 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1223
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1224 find: function( t, context ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1225 // Quickly handle non-string expressions
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1226 if ( typeof t != "string" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1227 return [ t ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1228
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1229 // Make sure that the context is a DOM Element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1230 if ( context && !context.nodeType )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1231 context = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1232
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1233 // Set the correct context (if none is provided)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1234 context = context || document;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1235
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1236 // Initialize the search
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1237 var ret = [context], done = [], last;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1238
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1239 // Continue while a selector expression exists, and while
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1240 // we're no longer looping upon ourselves
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1241 while ( t && last != t ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1242 var r = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1243 last = t;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1244
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1245 t = jQuery.trim(t);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1246
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1247 var foundToken = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1248
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1249 // An attempt at speeding up child selectors that
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1250 // point to a specific element tag
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1251 var re = quickChild;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1252 var m = re.exec(t);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1253
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1254 if ( m ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1255 var nodeName = m[1].toUpperCase();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1256
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1257 // Perform our own iteration and filter
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1258 for ( var i = 0; ret[i]; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1259 for ( var c = ret[i].firstChild; c; c = c.nextSibling )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1260 if ( c.nodeType == 1 && (nodeName == "*" || c.nodeName.toUpperCase() == nodeName.toUpperCase()) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1261 r.push( c );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1262
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1263 ret = r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1264 t = t.replace( re, "" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1265 if ( t.indexOf(" ") == 0 ) continue;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1266 foundToken = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1267 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1268 re = /^([>+~])\s*(\w*)/i;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1269
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1270 if ( (m = re.exec(t)) != null ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1271 r = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1272
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1273 var nodeName = m[2], merge = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1274 m = m[1];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1275
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1276 for ( var j = 0, rl = ret.length; j < rl; j++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1277 var n = m == "~" || m == "+" ? ret[j].nextSibling : ret[j].firstChild;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1278 for ( ; n; n = n.nextSibling )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1279 if ( n.nodeType == 1 ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1280 var id = jQuery.data(n);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1281
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1282 if ( m == "~" && merge[id] ) break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1283
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1284 if (!nodeName || n.nodeName.toUpperCase() == nodeName.toUpperCase() ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1285 if ( m == "~" ) merge[id] = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1286 r.push( n );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1287 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1288
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1289 if ( m == "+" ) break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1290 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1291 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1292
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1293 ret = r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1294
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1295 // And remove the token
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1296 t = jQuery.trim( t.replace( re, "" ) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1297 foundToken = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1298 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1299 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1300
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1301 // See if there's still an expression, and that we haven't already
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1302 // matched a token
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1303 if ( t && !foundToken ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1304 // Handle multiple expressions
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1305 if ( !t.indexOf(",") ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1306 // Clean the result set
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1307 if ( context == ret[0] ) ret.shift();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1308
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1309 // Merge the result sets
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1310 done = jQuery.merge( done, ret );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1311
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1312 // Reset the context
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1313 r = ret = [context];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1314
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1315 // Touch up the selector string
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1316 t = " " + t.substr(1,t.length);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1317
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1318 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1319 // Optimize for the case nodeName#idName
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1320 var re2 = quickID;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1321 var m = re2.exec(t);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1322
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1323 // Re-organize the results, so that they're consistent
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1324 if ( m ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1325 m = [ 0, m[2], m[3], m[1] ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1326
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1327 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1328 // Otherwise, do a traditional filter check for
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1329 // ID, class, and element selectors
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1330 re2 = quickClass;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1331 m = re2.exec(t);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1332 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1333
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1334 m[2] = m[2].replace(/\\/g, "");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1335
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1336 var elem = ret[ret.length-1];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1337
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1338 // Try to do a global search by ID, where we can
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1339 if ( m[1] == "#" && elem && elem.getElementById && !jQuery.isXMLDoc(elem) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1340 // Optimization for HTML document case
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1341 var oid = elem.getElementById(m[2]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1342
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1343 // Do a quick check for the existence of the actual ID attribute
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1344 // to avoid selecting by the name attribute in IE
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1345 // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1346 if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1347 oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1348
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1349 // Do a quick check for node name (where applicable) so
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1350 // that div#foo searches will be really fast
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1351 ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1352 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1353 // We need to find all descendant elements
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1354 for ( var i = 0; ret[i]; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1355 // Grab the tag name being searched for
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1356 var tag = m[1] == "#" && m[3] ? m[3] : m[1] != "" || m[0] == "" ? "*" : m[2];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1357
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1358 // Handle IE7 being really dumb about <object>s
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1359 if ( tag == "*" && ret[i].nodeName.toLowerCase() == "object" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1360 tag = "param";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1361
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1362 r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1363 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1364
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1365 // It's faster to filter by class and be done with it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1366 if ( m[1] == "." )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1367 r = jQuery.classFilter( r, m[2] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1368
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1369 // Same with ID filtering
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1370 if ( m[1] == "#" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1371 var tmp = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1372
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1373 // Try to find the element with the ID
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1374 for ( var i = 0; r[i]; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1375 if ( r[i].getAttribute("id") == m[2] ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1376 tmp = [ r[i] ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1377 break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1378 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1379
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1380 r = tmp;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1381 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1382
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1383 ret = r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1384 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1385
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1386 t = t.replace( re2, "" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1387 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1388
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1389 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1390
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1391 // If a selector string still exists
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1392 if ( t ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1393 // Attempt to filter it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1394 var val = jQuery.filter(t,r);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1395 ret = r = val.r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1396 t = jQuery.trim(val.t);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1397 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1398 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1399
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1400 // An error occurred with the selector;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1401 // just return an empty set instead
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1402 if ( t )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1403 ret = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1404
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1405 // Remove the root context
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1406 if ( ret && context == ret[0] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1407 ret.shift();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1408
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1409 // And combine the results
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1410 done = jQuery.merge( done, ret );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1411
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1412 return done;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1413 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1414
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1415 classFilter: function(r,m,not){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1416 m = " " + m + " ";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1417 var tmp = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1418 for ( var i = 0; r[i]; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1419 var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1420 if ( !not && pass || not && !pass )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1421 tmp.push( r[i] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1422 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1423 return tmp;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1424 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1425
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1426 filter: function(t,r,not) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1427 var last;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1428
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1429 // Look for common filter expressions
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1430 while ( t && t != last ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1431 last = t;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1432
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1433 var p = jQuery.parse, m;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1434
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1435 for ( var i = 0; p[i]; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1436 m = p[i].exec( t );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1437
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1438 if ( m ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1439 // Remove what we just matched
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1440 t = t.substring( m[0].length );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1441
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1442 m[2] = m[2].replace(/\\/g, "");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1443 break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1444 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1445 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1446
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1447 if ( !m )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1448 break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1449
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1450 // :not() is a special case that can be optimized by
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1451 // keeping it out of the expression list
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1452 if ( m[1] == ":" && m[2] == "not" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1453 r = jQuery.filter(m[3], r, true).r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1454
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1455 // We can get a big speed boost by filtering by class here
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1456 else if ( m[1] == "." )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1457 r = jQuery.classFilter(r, m[2], not);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1458
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1459 else if ( m[1] == "[" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1460 var tmp = [], type = m[3];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1461
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1462 for ( var i = 0, rl = r.length; i < rl; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1463 var a = r[i], z = a[ jQuery.props[m[2]] || m[2] ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1464
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1465 if ( z == null || /href|src|selected/.test(m[2]) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1466 z = jQuery.attr(a,m[2]) || '';
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1467
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1468 if ( (type == "" && !!z ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1469 type == "=" && z == m[5] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1470 type == "!=" && z != m[5] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1471 type == "^=" && z && !z.indexOf(m[5]) ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1472 type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1473 (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1474 tmp.push( a );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1475 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1476
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1477 r = tmp;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1478
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1479 // We can get a speed boost by handling nth-child here
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1480 } else if ( m[1] == ":" && m[2] == "nth-child" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1481 var merge = {}, tmp = [],
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1482 test = /(\d*)n\+?(\d*)/.exec(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1483 m[3] == "even" && "2n" || m[3] == "odd" && "2n+1" ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1484 !/\D/.test(m[3]) && "n+" + m[3] || m[3]),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1485 first = (test[1] || 1) - 0, last = test[2] - 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1486
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1487 for ( var i = 0, rl = r.length; i < rl; i++ ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1488 var node = r[i], parentNode = node.parentNode, id = jQuery.data(parentNode);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1489
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1490 if ( !merge[id] ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1491 var c = 1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1492
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1493 for ( var n = parentNode.firstChild; n; n = n.nextSibling )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1494 if ( n.nodeType == 1 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1495 n.nodeIndex = c++;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1496
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1497 merge[id] = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1498 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1499
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1500 var add = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1501
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1502 if ( first == 1 ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1503 if ( last == 0 || node.nodeIndex == last )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1504 add = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1505 } else if ( (node.nodeIndex + last) % first == 0 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1506 add = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1507
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1508 if ( add ^ not )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1509 tmp.push( node );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1510 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1511
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1512 r = tmp;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1513
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1514 // Otherwise, find the expression to execute
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1515 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1516 var f = jQuery.expr[m[1]];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1517 if ( typeof f != "string" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1518 f = jQuery.expr[m[1]][m[2]];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1519
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1520 // Build a custom macro to enclose it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1521 f = eval("false||function(a,i){return " + f + "}");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1522
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1523 // Execute it against the current filter
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1524 r = jQuery.grep( r, f, not );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1525 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1526 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1527
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1528 // Return an array of filtered elements (r)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1529 // and the modified expression string (t)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1530 return { r: r, t: t };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1531 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1532
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1533 dir: function( elem, dir ){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1534 var matched = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1535 var cur = elem[dir];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1536 while ( cur && cur != document ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1537 if ( cur.nodeType == 1 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1538 matched.push( cur );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1539 cur = cur[dir];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1540 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1541 return matched;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1542 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1543
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1544 nth: function(cur,result,dir,elem){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1545 result = result || 1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1546 var num = 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1547
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1548 for ( ; cur; cur = cur[dir] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1549 if ( cur.nodeType == 1 && ++num == result )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1550 break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1551
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1552 return cur;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1553 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1554
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1555 sibling: function( n, elem ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1556 var r = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1557
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1558 for ( ; n; n = n.nextSibling ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1559 if ( n.nodeType == 1 && (!elem || n != elem) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1560 r.push( n );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1561 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1562
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1563 return r;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1564 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1565 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1566 /*
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1567 * A number of helper functions used for managing events.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1568 * Many of the ideas behind this code orignated from
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1569 * Dean Edwards' addEvent library.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1570 */
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1571 jQuery.event = {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1572
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1573 // Bind an event to an element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1574 // Original by Dean Edwards
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1575 add: function(element, type, handler, data) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1576 // For whatever reason, IE has trouble passing the window object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1577 // around, causing it to be cloned in the process
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1578 if ( jQuery.browser.msie && element.setInterval != undefined )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1579 element = window;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1580
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1581 // Make sure that the function being executed has a unique ID
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1582 if ( !handler.guid )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1583 handler.guid = this.guid++;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1584
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1585 // if data is passed, bind to handler
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1586 if( data != undefined ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1587 // Create temporary function pointer to original handler
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1588 var fn = handler;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1589
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1590 // Create unique handler function, wrapped around original handler
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1591 handler = function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1592 // Pass arguments and context to original handler
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1593 return fn.apply(this, arguments);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1594 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1595
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1596 // Store data in unique handler
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1597 handler.data = data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1598
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1599 // Set the guid of unique handler to the same of original handler, so it can be removed
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1600 handler.guid = fn.guid;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1601 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1602
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1603 // Namespaced event handlers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1604 var parts = type.split(".");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1605 type = parts[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1606 handler.type = parts[1];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1607
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1608 // Init the element's event structure
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1609 var events = jQuery.data(element, "events") || jQuery.data(element, "events", {});
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1610
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1611 var handle = jQuery.data(element, "handle", function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1612 // returned undefined or false
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1613 var val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1614
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1615 // Handle the second event of a trigger and when
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1616 // an event is called after a page has unloaded
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1617 if ( typeof jQuery == "undefined" || jQuery.event.triggered )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1618 return val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1619
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1620 val = jQuery.event.handle.apply(element, arguments);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1621
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1622 return val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1623 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1624
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1625 // Get the current list of functions bound to this event
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1626 var handlers = events[type];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1627
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1628 // Init the event handler queue
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1629 if (!handlers) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1630 handlers = events[type] = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1631
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1632 // And bind the global event handler to the element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1633 if (element.addEventListener)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1634 element.addEventListener(type, handle, false);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1635 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1636 element.attachEvent("on" + type, handle);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1637 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1638
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1639 // Add the function to the element's handler list
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1640 handlers[handler.guid] = handler;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1641
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1642 // Keep track of which events have been used, for global triggering
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1643 this.global[type] = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1644 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1645
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1646 guid: 1,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1647 global: {},
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1648
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1649 // Detach an event or set of events from an element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1650 remove: function(element, type, handler) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1651 var events = jQuery.data(element, "events"), ret, index;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1652
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1653 // Namespaced event handlers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1654 if ( typeof type == "string" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1655 var parts = type.split(".");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1656 type = parts[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1657 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1658
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1659 if ( events ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1660 // type is actually an event object here
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1661 if ( type && type.type ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1662 handler = type.handler;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1663 type = type.type;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1664 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1665
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1666 if ( !type ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1667 for ( type in events )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1668 this.remove( element, type );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1669
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1670 } else if ( events[type] ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1671 // remove the given handler for the given type
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1672 if ( handler )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1673 delete events[type][handler.guid];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1674
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1675 // remove all handlers for the given type
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1676 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1677 for ( handler in events[type] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1678 // Handle the removal of namespaced events
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1679 if ( !parts[1] || events[type][handler].type == parts[1] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1680 delete events[type][handler];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1681
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1682 // remove generic event handler if no more handlers exist
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1683 for ( ret in events[type] ) break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1684 if ( !ret ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1685 if (element.removeEventListener)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1686 element.removeEventListener(type, jQuery.data(element, "handle"), false);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1687 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1688 element.detachEvent("on" + type, jQuery.data(element, "handle"));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1689 ret = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1690 delete events[type];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1691 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1692 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1693
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1694 // Remove the expando if it's no longer used
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1695 for ( ret in events ) break;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1696 if ( !ret ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1697 jQuery.removeData( element, "events" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1698 jQuery.removeData( element, "handle" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1699 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1700 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1701 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1702
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1703 trigger: function(type, data, element, donative, extra) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1704 // Clone the incoming data, if any
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1705 data = jQuery.makeArray(data || []);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1706
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1707 // Handle a global trigger
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1708 if ( !element ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1709 // Only trigger if we've ever bound an event for it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1710 if ( this.global[type] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1711 jQuery("*").add([window, document]).trigger(type, data);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1712
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1713 // Handle triggering a single element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1714 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1715 var val, ret, fn = jQuery.isFunction( element[ type ] || null ),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1716 // Check to see if we need to provide a fake event, or not
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1717 evt = !data[0] || !data[0].preventDefault;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1718
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1719 // Pass along a fake event
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1720 if ( evt )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1721 data.unshift( this.fix({ type: type, target: element }) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1722
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1723 // Enforce the right trigger type
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1724 data[0].type = type;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1725
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1726 // Trigger the event
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1727 if ( jQuery.isFunction( jQuery.data(element, "handle") ) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1728 val = jQuery.data(element, "handle").apply( element, data );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1729
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1730 // Handle triggering native .onfoo handlers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1731 if ( !fn && element["on"+type] && element["on"+type].apply( element, data ) === false )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1732 val = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1733
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1734 // Extra functions don't get the custom event object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1735 if ( evt )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1736 data.shift();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1737
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1738 // Handle triggering of extra function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1739 if ( extra && extra.apply( element, data ) === false )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1740 val = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1741
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1742 // Trigger the native events (except for clicks on links)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1743 if ( fn && donative !== false && val !== false && !(jQuery.nodeName(element, 'a') && type == "click") ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1744 this.triggered = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1745 element[ type ]();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1746 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1747
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1748 this.triggered = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1749 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1750
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1751 return val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1752 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1753
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1754 handle: function(event) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1755 // returned undefined or false
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1756 var val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1757
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1758 // Empty object is for triggered events with no data
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1759 event = jQuery.event.fix( event || window.event || {} );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1760
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1761 // Namespaced event handlers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1762 var parts = event.type.split(".");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1763 event.type = parts[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1764
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1765 var c = jQuery.data(this, "events") && jQuery.data(this, "events")[event.type], args = Array.prototype.slice.call( arguments, 1 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1766 args.unshift( event );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1767
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1768 for ( var j in c ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1769 // Pass in a reference to the handler function itself
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1770 // So that we can later remove it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1771 args[0].handler = c[j];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1772 args[0].data = c[j].data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1773
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1774 // Filter the functions by class
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1775 if ( !parts[1] || c[j].type == parts[1] ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1776 var tmp = c[j].apply( this, args );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1777
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1778 if ( val !== false )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1779 val = tmp;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1780
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1781 if ( tmp === false ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1782 event.preventDefault();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1783 event.stopPropagation();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1784 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1785 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1786 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1787
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1788 // Clean up added properties in IE to prevent memory leak
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1789 if (jQuery.browser.msie)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1790 event.target = event.preventDefault = event.stopPropagation =
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1791 event.handler = event.data = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1792
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1793 return val;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1794 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1795
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1796 fix: function(event) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1797 // store a copy of the original event object
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1798 // and clone to set read-only properties
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1799 var originalEvent = event;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1800 event = jQuery.extend({}, originalEvent);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1801
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1802 // add preventDefault and stopPropagation since
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1803 // they will not work on the clone
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1804 event.preventDefault = function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1805 // if preventDefault exists run it on the original event
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1806 if (originalEvent.preventDefault)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1807 originalEvent.preventDefault();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1808 // otherwise set the returnValue property of the original event to false (IE)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1809 originalEvent.returnValue = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1810 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1811 event.stopPropagation = function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1812 // if stopPropagation exists run it on the original event
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1813 if (originalEvent.stopPropagation)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1814 originalEvent.stopPropagation();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1815 // otherwise set the cancelBubble property of the original event to true (IE)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1816 originalEvent.cancelBubble = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1817 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1818
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1819 // Fix target property, if necessary
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1820 if ( !event.target && event.srcElement )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1821 event.target = event.srcElement;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1822
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1823 // check if target is a textnode (safari)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1824 if (jQuery.browser.safari && event.target.nodeType == 3)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1825 event.target = originalEvent.target.parentNode;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1826
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1827 // Add relatedTarget, if necessary
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1828 if ( !event.relatedTarget && event.fromElement )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1829 event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1830
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1831 // Calculate pageX/Y if missing and clientX/Y available
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1832 if ( event.pageX == null && event.clientX != null ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1833 var e = document.documentElement, b = document.body;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1834 event.pageX = event.clientX + (e && e.scrollLeft || b.scrollLeft || 0);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1835 event.pageY = event.clientY + (e && e.scrollTop || b.scrollTop || 0);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1836 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1837
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1838 // Add which for key events
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1839 if ( !event.which && (event.charCode || event.keyCode) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1840 event.which = event.charCode || event.keyCode;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1841
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1842 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1843 if ( !event.metaKey && event.ctrlKey )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1844 event.metaKey = event.ctrlKey;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1845
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1846 // Add which for click: 1 == left; 2 == middle; 3 == right
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1847 // Note: button is not normalized, so don't use it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1848 if ( !event.which && event.button )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1849 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1850
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1851 return event;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1852 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1853 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1854
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1855 jQuery.fn.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1856 bind: function( type, data, fn ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1857 return type == "unload" ? this.one(type, data, fn) : this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1858 jQuery.event.add( this, type, fn || data, fn && data );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1859 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1860 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1861
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1862 one: function( type, data, fn ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1863 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1864 jQuery.event.add( this, type, function(event) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1865 jQuery(this).unbind(event);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1866 return (fn || data).apply( this, arguments);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1867 }, fn && data);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1868 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1869 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1870
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1871 unbind: function( type, fn ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1872 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1873 jQuery.event.remove( this, type, fn );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1874 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1875 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1876
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1877 trigger: function( type, data, fn ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1878 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1879 jQuery.event.trigger( type, data, this, true, fn );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1880 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1881 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1882
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1883 triggerHandler: function( type, data, fn ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1884 if ( this[0] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1885 return jQuery.event.trigger( type, data, this[0], false, fn );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1886 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1887
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1888 toggle: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1889 // Save reference to arguments for access in closure
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1890 var a = arguments;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1891
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1892 return this.click(function(e) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1893 // Figure out which function to execute
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1894 this.lastToggle = 0 == this.lastToggle ? 1 : 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1895
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1896 // Make sure that clicks stop
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1897 e.preventDefault();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1898
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1899 // and execute the function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1900 return a[this.lastToggle].apply( this, [e] ) || false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1901 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1902 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1903
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1904 hover: function(f,g) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1905
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1906 // A private function for handling mouse 'hovering'
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1907 function handleHover(e) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1908 // Check if mouse(over|out) are still within the same parent element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1909 var p = e.relatedTarget;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1910
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1911 // Traverse up the tree
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1912 while ( p && p != this ) try { p = p.parentNode; } catch(e) { p = this; };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1913
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1914 // If we actually just moused on to a sub-element, ignore it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1915 if ( p == this ) return false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1916
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1917 // Execute the right function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1918 return (e.type == "mouseover" ? f : g).apply(this, [e]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1919 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1920
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1921 // Bind the function to the two event listeners
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1922 return this.mouseover(handleHover).mouseout(handleHover);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1923 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1924
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1925 ready: function(f) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1926 // Attach the listeners
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1927 bindReady();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1928
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1929 // If the DOM is already ready
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1930 if ( jQuery.isReady )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1931 // Execute the function immediately
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1932 f.apply( document, [jQuery] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1933
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1934 // Otherwise, remember the function for later
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1935 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1936 // Add the function to the wait list
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1937 jQuery.readyList.push( function() { return f.apply(this, [jQuery]); } );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1938
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1939 return this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1940 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1941 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1942
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1943 jQuery.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1944 /*
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1945 * All the code that makes DOM Ready work nicely.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1946 */
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1947 isReady: false,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1948 readyList: [],
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1949
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1950 // Handle when the DOM is ready
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1951 ready: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1952 // Make sure that the DOM is not already loaded
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1953 if ( !jQuery.isReady ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1954 // Remember that the DOM is ready
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1955 jQuery.isReady = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1956
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1957 // If there are functions bound, to execute
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1958 if ( jQuery.readyList ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1959 // Execute all of them
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1960 jQuery.each( jQuery.readyList, function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1961 this.apply( document );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1962 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1963
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1964 // Reset the list of functions
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1965 jQuery.readyList = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1966 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1967 // Remove event listener to avoid memory leak
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1968 if ( jQuery.browser.mozilla || jQuery.browser.opera )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1969 document.removeEventListener( "DOMContentLoaded", jQuery.ready, false );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1970
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1971 // Remove script element used by IE hack
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1972 if( !window.frames.length ) // don't remove if frames are present (#1187)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1973 jQuery(window).load(function(){ jQuery("#__ie_init").remove(); });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1974 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1975 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1976 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1977
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1978 jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1979 "mousedown,mouseup,mousemove,mouseover,mouseout,change,select," +
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1980 "submit,keydown,keypress,keyup,error").split(","), function(i,o){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1981
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1982 // Handle event binding
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1983 jQuery.fn[o] = function(f){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1984 return f ? this.bind(o, f) : this.trigger(o);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1985 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1986 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1987
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1988 var readyBound = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1989
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1990 function bindReady(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1991 if ( readyBound ) return;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1992 readyBound = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1993
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1994 // If Mozilla is used
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1995 if ( jQuery.browser.mozilla || jQuery.browser.opera )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1996 // Use the handy event callback
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1997 document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1998
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
1999 // If IE is used, use the excellent hack by Matthias Miller
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2000 // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2001 else if ( jQuery.browser.msie ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2002
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2003 // Only works if you document.write() it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2004 document.write("<scr" + "ipt id=__ie_init defer=true " +
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2005 "src=//:><\/script>");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2006
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2007 // Use the defer script hack
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2008 var script = document.getElementById("__ie_init");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2009
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2010 // script does not exist if jQuery is loaded dynamically
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2011 if ( script )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2012 script.onreadystatechange = function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2013 if ( this.readyState != "complete" ) return;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2014 jQuery.ready();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2015 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2016
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2017 // Clear from memory
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2018 script = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2019
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2020 // If Safari is used
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2021 } else if ( jQuery.browser.safari )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2022 // Continually check to see if the document.readyState is valid
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2023 jQuery.safariTimer = setInterval(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2024 // loaded and complete are both valid states
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2025 if ( document.readyState == "loaded" ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2026 document.readyState == "complete" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2027
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2028 // If either one are found, remove the timer
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2029 clearInterval( jQuery.safariTimer );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2030 jQuery.safariTimer = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2031
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2032 // and execute any waiting functions
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2033 jQuery.ready();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2034 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2035 }, 10);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2036
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2037 // A fallback to window.onload, that will always work
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2038 jQuery.event.add( window, "load", jQuery.ready );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2039 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2040 jQuery.fn.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2041 load: function( url, params, callback ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2042 if ( jQuery.isFunction( url ) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2043 return this.bind("load", url);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2044
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2045 var off = url.indexOf(" ");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2046 if ( off >= 0 ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2047 var selector = url.slice(off, url.length);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2048 url = url.slice(0, off);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2049 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2050
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2051 callback = callback || function(){};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2052
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2053 // Default to a GET request
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2054 var type = "GET";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2055
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2056 // If the second parameter was provided
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2057 if ( params )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2058 // If it's a function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2059 if ( jQuery.isFunction( params ) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2060 // We assume that it's the callback
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2061 callback = params;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2062 params = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2063
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2064 // Otherwise, build a param string
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2065 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2066 params = jQuery.param( params );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2067 type = "POST";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2068 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2069
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2070 var self = this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2071
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2072 // Request the remote document
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2073 jQuery.ajax({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2074 url: url,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2075 type: type,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2076 data: params,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2077 complete: function(res, status){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2078 // If successful, inject the HTML into all the matched elements
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2079 if ( status == "success" || status == "notmodified" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2080 // See if a selector was specified
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2081 self.html( selector ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2082 // Create a dummy div to hold the results
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2083 jQuery("<div/>")
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2084 // inject the contents of the document in, removing the scripts
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2085 // to avoid any 'Permission Denied' errors in IE
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2086 .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, ""))
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2087
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2088 // Locate the specified elements
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2089 .find(selector) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2090
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2091 // If not, just inject the full result
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2092 res.responseText );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2093
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2094 // Add delay to account for Safari's delay in globalEval
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2095 setTimeout(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2096 self.each( callback, [res.responseText, status, res] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2097 }, 13);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2098 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2099 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2100 return this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2101 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2102
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2103 serialize: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2104 return jQuery.param(this.serializeArray());
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2105 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2106 serializeArray: function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2107 return this.map(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2108 return jQuery.nodeName(this, "form") ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2109 jQuery.makeArray(this.elements) : this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2110 })
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2111 .filter(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2112 return this.name && !this.disabled &&
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2113 (this.checked || /select|textarea/i.test(this.nodeName) ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2114 /text|hidden|password/i.test(this.type));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2115 })
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2116 .map(function(i, elem){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2117 var val = jQuery(this).val();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2118 return val == null ? null :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2119 val.constructor == Array ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2120 jQuery.map( val, function(val, i){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2121 return {name: elem.name, value: val};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2122 }) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2123 {name: elem.name, value: val};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2124 }).get();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2125 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2126 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2127
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2128 // Attach a bunch of functions for handling common AJAX events
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2129 jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2130 jQuery.fn[o] = function(f){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2131 return this.bind(o, f);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2132 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2133 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2134
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2135 var jsc = (new Date).getTime();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2136
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2137 jQuery.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2138 get: function( url, data, callback, type ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2139 // shift arguments if data argument was ommited
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2140 if ( jQuery.isFunction( data ) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2141 callback = data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2142 data = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2143 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2144
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2145 return jQuery.ajax({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2146 type: "GET",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2147 url: url,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2148 data: data,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2149 success: callback,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2150 dataType: type
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2151 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2152 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2153
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2154 getScript: function( url, callback ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2155 return jQuery.get(url, null, callback, "script");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2156 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2157
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2158 getJSON: function( url, data, callback ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2159 return jQuery.get(url, data, callback, "json");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2160 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2161
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2162 post: function( url, data, callback, type ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2163 if ( jQuery.isFunction( data ) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2164 callback = data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2165 data = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2166 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2167
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2168 return jQuery.ajax({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2169 type: "POST",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2170 url: url,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2171 data: data,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2172 success: callback,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2173 dataType: type
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2174 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2175 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2176
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2177 ajaxSetup: function( settings ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2178 jQuery.extend( jQuery.ajaxSettings, settings );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2179 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2180
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2181 ajaxSettings: {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2182 global: true,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2183 type: "GET",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2184 timeout: 0,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2185 contentType: "application/x-www-form-urlencoded",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2186 processData: true,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2187 async: true,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2188 data: null
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2189 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2190
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2191 // Last-Modified header cache for next request
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2192 lastModified: {},
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2193
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2194 ajax: function( s ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2195 var jsonp, jsre = /=(\?|%3F)/g, status, data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2196
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2197 // Extend the settings, but re-extend 's' so that it can be
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2198 // checked again later (in the test suite, specifically)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2199 s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2200
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2201 // convert data if not already a string
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2202 if ( s.data && s.processData && typeof s.data != "string" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2203 s.data = jQuery.param(s.data);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2204
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2205 // Handle JSONP Parameter Callbacks
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2206 if ( s.dataType == "jsonp" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2207 if ( s.type.toLowerCase() == "get" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2208 if ( !s.url.match(jsre) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2209 s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2210 } else if ( !s.data || !s.data.match(jsre) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2211 s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2212 s.dataType = "json";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2213 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2214
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2215 // Build temporary JSONP function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2216 if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2217 jsonp = "jsonp" + jsc++;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2218
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2219 // Replace the =? sequence both in the query string and the data
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2220 if ( s.data )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2221 s.data = s.data.replace(jsre, "=" + jsonp);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2222 s.url = s.url.replace(jsre, "=" + jsonp);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2223
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2224 // We need to make sure
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2225 // that a JSONP style response is executed properly
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2226 s.dataType = "script";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2227
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2228 // Handle JSONP-style loading
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2229 window[ jsonp ] = function(tmp){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2230 data = tmp;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2231 success();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2232 complete();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2233 // Garbage collect
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2234 window[ jsonp ] = undefined;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2235 try{ delete window[ jsonp ]; } catch(e){}
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2236 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2237 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2238
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2239 if ( s.dataType == "script" && s.cache == null )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2240 s.cache = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2241
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2242 if ( s.cache === false && s.type.toLowerCase() == "get" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2243 s.url += (s.url.match(/\?/) ? "&" : "?") + "_=" + (new Date()).getTime();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2244
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2245 // If data is available, append data to url for get requests
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2246 if ( s.data && s.type.toLowerCase() == "get" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2247 s.url += (s.url.match(/\?/) ? "&" : "?") + s.data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2248
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2249 // IE likes to send both get and post data, prevent this
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2250 s.data = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2251 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2252
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2253 // Watch for a new set of requests
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2254 if ( s.global && ! jQuery.active++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2255 jQuery.event.trigger( "ajaxStart" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2256
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2257 // If we're requesting a remote document
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2258 // and trying to load JSON or Script
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2259 if ( !s.url.indexOf("http") && s.dataType == "script" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2260 var head = document.getElementsByTagName("head")[0];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2261 var script = document.createElement("script");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2262 script.src = s.url;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2263
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2264 // Handle Script loading
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2265 if ( !jsonp && (s.success || s.complete) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2266 var done = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2267
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2268 // Attach handlers for all browsers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2269 script.onload = script.onreadystatechange = function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2270 if ( !done && (!this.readyState ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2271 this.readyState == "loaded" || this.readyState == "complete") ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2272 done = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2273 success();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2274 complete();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2275 head.removeChild( script );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2276 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2277 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2278 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2279
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2280 head.appendChild(script);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2281
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2282 // We handle everything using the script element injection
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2283 return;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2284 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2285
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2286 var requestDone = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2287
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2288 // Create the request object; Microsoft failed to properly
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2289 // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2290 var xml = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2291
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2292 // Open the socket
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2293 xml.open(s.type, s.url, s.async);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2294
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2295 // Set the correct header, if data is being sent
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2296 if ( s.data )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2297 xml.setRequestHeader("Content-Type", s.contentType);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2298
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2299 // Set the If-Modified-Since header, if ifModified mode.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2300 if ( s.ifModified )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2301 xml.setRequestHeader("If-Modified-Since",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2302 jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2303
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2304 // Set header so the called script knows that it's an XMLHttpRequest
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2305 xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2306
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2307 // Allow custom headers/mimetypes
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2308 if ( s.beforeSend )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2309 s.beforeSend(xml);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2310
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2311 if ( s.global )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2312 jQuery.event.trigger("ajaxSend", [xml, s]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2313
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2314 // Wait for a response to come back
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2315 var onreadystatechange = function(isTimeout){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2316 // The transfer is complete and the data is available, or the request timed out
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2317 if ( !requestDone && xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2318 requestDone = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2319
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2320 // clear poll interval
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2321 if (ival) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2322 clearInterval(ival);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2323 ival = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2324 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2325
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2326 status = isTimeout == "timeout" && "timeout" ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2327 !jQuery.httpSuccess( xml ) && "error" ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2328 s.ifModified && jQuery.httpNotModified( xml, s.url ) && "notmodified" ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2329 "success";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2330
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2331 if ( status == "success" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2332 // Watch for, and catch, XML document parse errors
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2333 try {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2334 // process the data (runs the xml through httpData regardless of callback)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2335 data = jQuery.httpData( xml, s.dataType );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2336 } catch(e) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2337 status = "parsererror";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2338 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2339 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2340
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2341 // Make sure that the request was successful or notmodified
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2342 if ( status == "success" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2343 // Cache Last-Modified header, if ifModified mode.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2344 var modRes;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2345 try {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2346 modRes = xml.getResponseHeader("Last-Modified");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2347 } catch(e) {} // swallow exception thrown by FF if header is not available
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2348
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2349 if ( s.ifModified && modRes )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2350 jQuery.lastModified[s.url] = modRes;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2351
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2352 // JSONP handles its own success callback
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2353 if ( !jsonp )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2354 success();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2355 } else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2356 jQuery.handleError(s, xml, status);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2357
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2358 // Fire the complete handlers
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2359 complete();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2360
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2361 // Stop memory leaks
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2362 if ( s.async )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2363 xml = null;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2364 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2365 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2366
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2367 if ( s.async ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2368 // don't attach the handler to the request, just poll it instead
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2369 var ival = setInterval(onreadystatechange, 13);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2370
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2371 // Timeout checker
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2372 if ( s.timeout > 0 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2373 setTimeout(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2374 // Check to see if the request is still happening
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2375 if ( xml ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2376 // Cancel the request
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2377 xml.abort();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2378
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2379 if( !requestDone )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2380 onreadystatechange( "timeout" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2381 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2382 }, s.timeout);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2383 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2384
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2385 // Send the data
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2386 try {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2387 xml.send(s.data);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2388 } catch(e) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2389 jQuery.handleError(s, xml, null, e);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2390 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2391
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2392 // firefox 1.5 doesn't fire statechange for sync requests
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2393 if ( !s.async )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2394 onreadystatechange();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2395
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2396 // return XMLHttpRequest to allow aborting the request etc.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2397 return xml;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2398
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2399 function success(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2400 // If a local callback was specified, fire it and pass it the data
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2401 if ( s.success )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2402 s.success( data, status );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2403
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2404 // Fire the global callback
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2405 if ( s.global )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2406 jQuery.event.trigger( "ajaxSuccess", [xml, s] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2407 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2408
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2409 function complete(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2410 // Process result
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2411 if ( s.complete )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2412 s.complete(xml, status);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2413
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2414 // The request was completed
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2415 if ( s.global )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2416 jQuery.event.trigger( "ajaxComplete", [xml, s] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2417
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2418 // Handle the global AJAX counter
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2419 if ( s.global && ! --jQuery.active )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2420 jQuery.event.trigger( "ajaxStop" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2421 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2422 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2423
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2424 handleError: function( s, xml, status, e ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2425 // If a local callback was specified, fire it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2426 if ( s.error ) s.error( xml, status, e );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2427
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2428 // Fire the global callback
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2429 if ( s.global )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2430 jQuery.event.trigger( "ajaxError", [xml, s, e] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2431 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2432
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2433 // Counter for holding the number of active queries
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2434 active: 0,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2435
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2436 // Determines if an XMLHttpRequest was successful or not
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2437 httpSuccess: function( r ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2438 try {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2439 return !r.status && location.protocol == "file:" ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2440 ( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2441 jQuery.browser.safari && r.status == undefined;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2442 } catch(e){}
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2443 return false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2444 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2445
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2446 // Determines if an XMLHttpRequest returns NotModified
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2447 httpNotModified: function( xml, url ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2448 try {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2449 var xmlRes = xml.getResponseHeader("Last-Modified");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2450
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2451 // Firefox always returns 200. check Last-Modified date
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2452 return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2453 jQuery.browser.safari && xml.status == undefined;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2454 } catch(e){}
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2455 return false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2456 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2457
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2458 httpData: function( r, type ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2459 var ct = r.getResponseHeader("content-type");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2460 var xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2461 var data = xml ? r.responseXML : r.responseText;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2462
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2463 if ( xml && data.documentElement.tagName == "parsererror" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2464 throw "parsererror";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2465
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2466 // If the type is "script", eval it in global context
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2467 if ( type == "script" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2468 jQuery.globalEval( data );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2469
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2470 // Get the JavaScript object, if JSON is used.
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2471 if ( type == "json" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2472 data = eval("(" + data + ")");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2473
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2474 return data;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2475 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2476
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2477 // Serialize an array of form elements or a set of
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2478 // key/values into a query string
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2479 param: function( a ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2480 var s = [];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2481
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2482 // If an array was passed in, assume that it is an array
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2483 // of form elements
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2484 if ( a.constructor == Array || a.jquery )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2485 // Serialize the form elements
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2486 jQuery.each( a, function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2487 s.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( this.value ) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2488 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2489
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2490 // Otherwise, assume that it's an object of key/value pairs
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2491 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2492 // Serialize the key/values
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2493 for ( var j in a )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2494 // If the value is an array then the key names need to be repeated
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2495 if ( a[j] && a[j].constructor == Array )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2496 jQuery.each( a[j], function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2497 s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2498 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2499 else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2500 s.push( encodeURIComponent(j) + "=" + encodeURIComponent( a[j] ) );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2501
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2502 // Return the resulting serialization
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2503 return s.join("&").replace(/%20/g, "+");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2504 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2505
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2506 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2507 jQuery.fn.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2508 show: function(speed,callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2509 return speed ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2510 this.animate({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2511 height: "show", width: "show", opacity: "show"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2512 }, speed, callback) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2513
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2514 this.filter(":hidden").each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2515 this.style.display = this.oldblock ? this.oldblock : "";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2516 if ( jQuery.css(this,"display") == "none" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2517 this.style.display = "block";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2518 }).end();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2519 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2520
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2521 hide: function(speed,callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2522 return speed ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2523 this.animate({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2524 height: "hide", width: "hide", opacity: "hide"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2525 }, speed, callback) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2526
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2527 this.filter(":visible").each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2528 this.oldblock = this.oldblock || jQuery.css(this,"display");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2529 if ( this.oldblock == "none" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2530 this.oldblock = "block";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2531 this.style.display = "none";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2532 }).end();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2533 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2534
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2535 // Save the old toggle function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2536 _toggle: jQuery.fn.toggle,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2537
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2538 toggle: function( fn, fn2 ){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2539 return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2540 this._toggle( fn, fn2 ) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2541 fn ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2542 this.animate({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2543 height: "toggle", width: "toggle", opacity: "toggle"
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2544 }, fn, fn2) :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2545 this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2546 jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2547 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2548 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2549
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2550 slideDown: function(speed,callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2551 return this.animate({height: "show"}, speed, callback);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2552 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2553
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2554 slideUp: function(speed,callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2555 return this.animate({height: "hide"}, speed, callback);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2556 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2557
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2558 slideToggle: function(speed, callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2559 return this.animate({height: "toggle"}, speed, callback);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2560 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2561
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2562 fadeIn: function(speed, callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2563 return this.animate({opacity: "show"}, speed, callback);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2564 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2565
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2566 fadeOut: function(speed, callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2567 return this.animate({opacity: "hide"}, speed, callback);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2568 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2569
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2570 fadeTo: function(speed,to,callback){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2571 return this.animate({opacity: to}, speed, callback);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2572 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2573
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2574 animate: function( prop, speed, easing, callback ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2575 var opt = jQuery.speed(speed, easing, callback);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2576
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2577 return this[ opt.queue === false ? "each" : "queue" ](function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2578 opt = jQuery.extend({}, opt);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2579 var hidden = jQuery(this).is(":hidden"), self = this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2580
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2581 for ( var p in prop ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2582 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2583 return jQuery.isFunction(opt.complete) && opt.complete.apply(this);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2584
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2585 if ( p == "height" || p == "width" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2586 // Store display property
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2587 opt.display = jQuery.css(this, "display");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2588
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2589 // Make sure that nothing sneaks out
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2590 opt.overflow = this.style.overflow;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2591 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2592 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2593
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2594 if ( opt.overflow != null )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2595 this.style.overflow = "hidden";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2596
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2597 opt.curAnim = jQuery.extend({}, prop);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2598
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2599 jQuery.each( prop, function(name, val){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2600 var e = new jQuery.fx( self, opt, name );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2601
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2602 if ( /toggle|show|hide/.test(val) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2603 e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2604 else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2605 var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2606 start = e.cur(true) || 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2607
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2608 if ( parts ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2609 var end = parseFloat(parts[2]),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2610 unit = parts[3] || "px";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2611
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2612 // We need to compute starting value
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2613 if ( unit != "px" ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2614 self.style[ name ] = (end || 1) + unit;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2615 start = ((end || 1) / e.cur(true)) * start;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2616 self.style[ name ] = start + unit;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2617 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2618
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2619 // If a +=/-= token was provided, we're doing a relative animation
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2620 if ( parts[1] )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2621 end = ((parts[1] == "-=" ? -1 : 1) * end) + start;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2622
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2623 e.custom( start, end, unit );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2624 } else
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2625 e.custom( start, val, "" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2626 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2627 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2628
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2629 // For JS strict compliance
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2630 return true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2631 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2632 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2633
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2634 queue: function(type, fn){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2635 if ( jQuery.isFunction(type) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2636 fn = type;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2637 type = "fx";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2638 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2639
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2640 if ( !type || (typeof type == "string" && !fn) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2641 return queue( this[0], type );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2642
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2643 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2644 if ( fn.constructor == Array )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2645 queue(this, type, fn);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2646 else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2647 queue(this, type).push( fn );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2648
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2649 if ( queue(this, type).length == 1 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2650 fn.apply(this);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2651 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2652 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2653 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2654
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2655 stop: function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2656 var timers = jQuery.timers;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2657
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2658 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2659 for ( var i = 0; i < timers.length; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2660 if ( timers[i].elem == this )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2661 timers.splice(i--, 1);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2662 }).dequeue();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2663 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2664
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2665 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2666
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2667 var queue = function( elem, type, array ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2668 if ( !elem )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2669 return;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2670
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2671 var q = jQuery.data( elem, type + "queue" );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2672
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2673 if ( !q || array )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2674 q = jQuery.data( elem, type + "queue",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2675 array ? jQuery.makeArray(array) : [] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2676
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2677 return q;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2678 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2679
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2680 jQuery.fn.dequeue = function(type){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2681 type = type || "fx";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2682
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2683 return this.each(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2684 var q = queue(this, type);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2685
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2686 q.shift();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2687
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2688 if ( q.length )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2689 q[0].apply( this );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2690 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2691 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2692
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2693 jQuery.extend({
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2694
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2695 speed: function(speed, easing, fn) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2696 var opt = speed && speed.constructor == Object ? speed : {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2697 complete: fn || !fn && easing ||
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2698 jQuery.isFunction( speed ) && speed,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2699 duration: speed,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2700 easing: fn && easing || easing && easing.constructor != Function && easing
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2701 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2702
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2703 opt.duration = (opt.duration && opt.duration.constructor == Number ?
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2704 opt.duration :
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2705 { slow: 600, fast: 200 }[opt.duration]) || 400;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2706
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2707 // Queueing
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2708 opt.old = opt.complete;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2709 opt.complete = function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2710 jQuery(this).dequeue();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2711 if ( jQuery.isFunction( opt.old ) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2712 opt.old.apply( this );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2713 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2714
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2715 return opt;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2716 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2717
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2718 easing: {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2719 linear: function( p, n, firstNum, diff ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2720 return firstNum + diff * p;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2721 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2722 swing: function( p, n, firstNum, diff ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2723 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2724 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2725 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2726
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2727 timers: [],
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2728
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2729 fx: function( elem, options, prop ){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2730 this.options = options;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2731 this.elem = elem;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2732 this.prop = prop;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2733
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2734 if ( !options.orig )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2735 options.orig = {};
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2736 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2737
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2738 });
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2739
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2740 jQuery.fx.prototype = {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2741
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2742 // Simple function for setting a style value
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2743 update: function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2744 if ( this.options.step )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2745 this.options.step.apply( this.elem, [ this.now, this ] );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2746
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2747 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2748
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2749 // Set display property to block for height/width animations
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2750 if ( this.prop == "height" || this.prop == "width" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2751 this.elem.style.display = "block";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2752 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2753
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2754 // Get the current size
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2755 cur: function(force){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2756 if ( this.elem[this.prop] != null && this.elem.style[this.prop] == null )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2757 return this.elem[ this.prop ];
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2758
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2759 var r = parseFloat(jQuery.curCSS(this.elem, this.prop, force));
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2760 return r && r > -10000 ? r : parseFloat(jQuery.css(this.elem, this.prop)) || 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2761 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2762
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2763 // Start an animation from one number to another
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2764 custom: function(from, to, unit){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2765 this.startTime = (new Date()).getTime();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2766 this.start = from;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2767 this.end = to;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2768 this.unit = unit || this.unit || "px";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2769 this.now = this.start;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2770 this.pos = this.state = 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2771 this.update();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2772
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2773 var self = this;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2774 function t(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2775 return self.step();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2776 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2777
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2778 t.elem = this.elem;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2779
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2780 jQuery.timers.push(t);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2781
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2782 if ( jQuery.timers.length == 1 ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2783 var timer = setInterval(function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2784 var timers = jQuery.timers;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2785
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2786 for ( var i = 0; i < timers.length; i++ )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2787 if ( !timers[i]() )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2788 timers.splice(i--, 1);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2789
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2790 if ( !timers.length )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2791 clearInterval( timer );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2792 }, 13);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2793 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2794 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2795
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2796 // Simple 'show' function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2797 show: function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2798 // Remember where we started, so that we can go back to it later
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2799 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2800 this.options.show = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2801
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2802 // Begin the animation
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2803 this.custom(0, this.cur());
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2804
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2805 // Make sure that we start at a small width/height to avoid any
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2806 // flash of content
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2807 if ( this.prop == "width" || this.prop == "height" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2808 this.elem.style[this.prop] = "1px";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2809
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2810 // Start by showing the element
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2811 jQuery(this.elem).show();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2812 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2813
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2814 // Simple 'hide' function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2815 hide: function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2816 // Remember where we started, so that we can go back to it later
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2817 this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2818 this.options.hide = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2819
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2820 // Begin the animation
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2821 this.custom(this.cur(), 0);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2822 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2823
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2824 // Each step of an animation
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2825 step: function(){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2826 var t = (new Date()).getTime();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2827
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2828 if ( t > this.options.duration + this.startTime ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2829 this.now = this.end;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2830 this.pos = this.state = 1;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2831 this.update();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2832
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2833 this.options.curAnim[ this.prop ] = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2834
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2835 var done = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2836 for ( var i in this.options.curAnim )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2837 if ( this.options.curAnim[i] !== true )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2838 done = false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2839
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2840 if ( done ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2841 if ( this.options.display != null ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2842 // Reset the overflow
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2843 this.elem.style.overflow = this.options.overflow;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2844
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2845 // Reset the display
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2846 this.elem.style.display = this.options.display;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2847 if ( jQuery.css(this.elem, "display") == "none" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2848 this.elem.style.display = "block";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2849 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2850
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2851 // Hide the element if the "hide" operation was done
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2852 if ( this.options.hide )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2853 this.elem.style.display = "none";
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2854
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2855 // Reset the properties, if the item has been hidden or shown
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2856 if ( this.options.hide || this.options.show )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2857 for ( var p in this.options.curAnim )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2858 jQuery.attr(this.elem.style, p, this.options.orig[p]);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2859 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2860
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2861 // If a callback was provided, execute it
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2862 if ( done && jQuery.isFunction( this.options.complete ) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2863 // Execute the complete function
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2864 this.options.complete.apply( this.elem );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2865
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2866 return false;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2867 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2868 var n = t - this.startTime;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2869 this.state = n / this.options.duration;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2870
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2871 // Perform the easing function, defaults to swing
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2872 this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2873 this.now = this.start + ((this.end - this.start) * this.pos);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2874
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2875 // Perform the next step of the animation
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2876 this.update();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2877 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2878
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2879 return true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2880 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2881
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2882 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2883
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2884 jQuery.fx.step = {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2885 scrollLeft: function(fx){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2886 fx.elem.scrollLeft = fx.now;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2887 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2888
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2889 scrollTop: function(fx){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2890 fx.elem.scrollTop = fx.now;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2891 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2892
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2893 opacity: function(fx){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2894 jQuery.attr(fx.elem.style, "opacity", fx.now);
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2895 },
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2896
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2897 _default: function(fx){
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2898 fx.elem.style[ fx.prop ] = fx.now + fx.unit;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2899 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2900 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2901 // The Offset Method
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2902 // Originally By Brandon Aaron, part of the Dimension Plugin
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2903 // http://jquery.com/plugins/project/dimensions
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2904 jQuery.fn.offset = function() {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2905 var left = 0, top = 0, elem = this[0], results;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2906
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2907 if ( elem ) with ( jQuery.browser ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2908 var absolute = jQuery.css(elem, "position") == "absolute",
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2909 parent = elem.parentNode,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2910 offsetParent = elem.offsetParent,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2911 doc = elem.ownerDocument,
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2912 safari2 = safari && parseInt(version) < 522;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2913
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2914 // Use getBoundingClientRect if available
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2915 if ( elem.getBoundingClientRect ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2916 box = elem.getBoundingClientRect();
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2917
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2918 // Add the document scroll offsets
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2919 add(
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2920 box.left + Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft),
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2921 box.top + Math.max(doc.documentElement.scrollTop, doc.body.scrollTop)
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2922 );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2923
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2924 // IE adds the HTML element's border, by default it is medium which is 2px
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2925 // IE 6 and IE 7 quirks mode the border width is overwritable by the following css html { border: 0; }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2926 // IE 7 standards mode, the border is always 2px
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2927 if ( msie ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2928 var border = jQuery("html").css("borderWidth");
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2929 border = (border == "medium" || jQuery.boxModel && parseInt(version) >= 7) && 2 || border;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2930 add( -border, -border );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2931 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2932
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2933 // Otherwise loop through the offsetParents and parentNodes
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2934 } else {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2935
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2936 // Initial element offsets
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2937 add( elem.offsetLeft, elem.offsetTop );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2938
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2939 // Get parent offsets
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2940 while ( offsetParent ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2941 // Add offsetParent offsets
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2942 add( offsetParent.offsetLeft, offsetParent.offsetTop );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2943
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2944 // Mozilla and Safari > 2 does not include the border on offset parents
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2945 // However Mozilla adds the border for table cells
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2946 if ( mozilla && /^t[d|h]$/i.test(parent.tagName) || !safari2 )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2947 border( offsetParent );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2948
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2949 // Safari <= 2 doubles body offsets with an absolutely positioned element or parent
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2950 if ( safari2 && !absolute && jQuery.css(offsetParent, "position") == "absolute" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2951 absolute = true;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2952
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2953 // Get next offsetParent
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2954 offsetParent = offsetParent.offsetParent;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2955 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2956
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2957 // Get parent scroll offsets
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2958 while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2959 // Work around opera inline/table scrollLeft/Top bug
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2960 if ( !/^inline|table-row.*$/i.test(jQuery.css(parent, "display")) )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2961 // Subtract parent scroll offsets
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2962 add( -parent.scrollLeft, -parent.scrollTop );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2963
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2964 // Mozilla does not add the border for a parent that has overflow != visible
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2965 if ( mozilla && jQuery.css(parent, "overflow") != "visible" )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2966 border( parent );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2967
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2968 // Get next parent
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2969 parent = parent.parentNode;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2970 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2971
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2972 // Safari doubles body offsets with an absolutely positioned element or parent
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2973 if ( safari2 && absolute )
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2974 add( -doc.body.offsetLeft, -doc.body.offsetTop );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2975 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2976
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2977 // Return an object with top and left properties
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2978 results = { top: top, left: left };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2979 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2980
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2981 return results;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2982
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2983 function border(elem) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2984 add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") );
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2985 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2986
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2987 function add(l, t) {
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2988 left += parseInt(l) || 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2989 top += parseInt(t) || 0;
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2990 }
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2991 };
ad304b606163 Initial cut at web comment system import
Bryan O'Sullivan <bos@serpentine.com>
parents:
diff changeset
2992 })();